using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LHDN.CRM.BC.Common
{
    public class Helper
    {
        #region Console App Helper
        public static void LogMessage(string strMessage)
        {
            string strLogFile = Utilities.GetAppSetting(Constant.AppLog.LogPath);
            string strLogFileName = string.Format(Utilities.GetAppSetting(Constant.AppLog.LogName), DateTime.Now.ToString(Utilities.GetAppSetting(Constant.AppLog.LogDateTimeFormat)));

            if (string.IsNullOrEmpty(strLogFile.Trim()))
                strLogFile = Utilities.GetAppPath();

            bool blnLogEnabled = Convert.ToBoolean(Utilities.GetAppSetting(Constant.AppLog.LogEnabled));

            if (blnLogEnabled)
            {
                using (System.IO.StreamWriter sw = new StreamWriter(strLogFile + @"\" + strLogFileName, true))
                {
                    sw.WriteLine(DateTime.Now + ": " + strMessage);
                }
            }
        }

        #endregion
    }
}
