Beispiel #1
0
        public void ValidateReCaptcha(string reCaptchaResponse)
        {
            try
            {
                string _RecaptchaSecretKey = CommonFuc.GetConfig("RecaptchaSecretKey");
                if (string.IsNullOrEmpty(reCaptchaResponse) || string.IsNullOrWhiteSpace(reCaptchaResponse))
                {
                    return;
                }

                // Request to Google Server
                var req = (HttpWebRequest)WebRequest.Create("https://www.google.com/recaptcha/api/siteverify?secret=" + _RecaptchaSecretKey + "&response=" + reCaptchaResponse.Trim('"'));

                // Google recaptcha Response
                using (var wResponse = req.GetResponse())
                {
                    var responseStream = wResponse.GetResponseStream();
                    if (responseStream == null)
                    {
                        return;
                    }
                    using (var readStream = new StreamReader(responseStream))
                    {
                        var jsonResponse = readStream.ReadToEnd();
                        var js           = new JavaScriptSerializer();
                        var data         = js.Deserialize <GoogleResponse>(jsonResponse); // Deserialize Json
                        this.IsReCaptchaValid = Convert.ToBoolean(data.Success);
                    }
                }
            }
            catch (Exception)
            {
                // Ignored
            }
        }
Beispiel #2
0
        internal void LoadWebAppDataWhenResetPool()
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure();
                Configuration.GetConfigAppSetting();
                EmailHelper.EmailOriginal = new EmailInfo()
                {
                    Host        = CommonFuc.GetConfig("EMailHost"),
                    Port        = Convert.ToInt32(CommonFuc.GetConfig("EmailPost")),
                    EMailFrom   = CommonFuc.GetConfig("EMailFrom"),
                    PassWord    = Configuration.EMailPass,
                    DisplayName = CommonFuc.GetConfig("DisplayName"),
                    IsSsl       = CommonFuc.GetConfig("SSL") == "Y",
                    EmailCC     = CommonFuc.GetConfig("EmailCC"),

                    EMailFrom_Business   = CommonFuc.GetConfig("EMailFrom_Business"),
                    PassWord_Business    = Configuration.EMailPass_Business,
                    DisplayName_Business = CommonFuc.GetConfig("DisplayName_Business")
                };

                CommonVariables.AssemblyVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                CommonVariables.KnFileLogin     = HttpContext.Current.Server.MapPath(@"~/log/LogInApp" + DateTime.Now.ToString("MMyyyy") + ".log");
                MemoryData.LoadAllMemoryData();

                // lấy thông tin fee
                List <AllCodeInfo> _lstTax = WebApps.CommonFunction.AppsCommon.AllCode_GetBy_CdTypeCdName("BILLING", "TAX");
                if (_lstTax.Count > 0)
                {
                    Common.Tax = Convert.ToDecimal(_lstTax[0].CdVal);
                }

                // thread chuyên load dữ liệu tĩnh khi có sự thay đổi
                Thread _th1 = new Thread(ThreadReloadWhenChangeData);
                _th1.IsBackground = true;
                _th1.Start();

                // tự động change trạng thái của remind
                Thread _th2 = new Thread(ThreadReadTodo4SendEmail);
                _th2.IsBackground = true;
                _th2.Start();

                Thread _th3 = new Thread(ThreadSendEmail);
                _th3.IsBackground = true;
                _th3.Start();

                Logger.Log().Info("Start Application_Start");
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Beispiel #3
0
        private void ThreadReadTodo4SendEmail()
        {
            int _timeSleep = Convert.ToInt16(CommonFuc.GetConfig("TimeSleepSendMail"));

            while (true)
            {
                try
                {
                    //if (DateTime.Now.ToString("HH:mm") == "00:55" && Common.c_is_call_change_remind == false)
                    //{
                    //    B_Remind_BL _bl = new B_Remind_BL();
                    //    _bl.Auto_change_remind();
                    //    Logger.Log().Info("ChangeRemind " + DateTime.Now.ToString("dd/MM/yyyy"));
                    //    Common.c_is_call_change_remind = true;
                    //}
                    //else if (DateTime.Now.ToString("HH:mm") != "00:55")
                    //{
                    //    Common.c_is_call_change_remind = false;
                    //}

                    // đọc thông tin cần gửi email
                    B_Todos_BL          _B_Todos_BL    = new B_Todos_BL();
                    List <B_Todos_Info> _lst           = _B_Todos_BL.GetSend_Email();
                    List <string>       _LstAttachment = new List <string>();

                    List <B_Todos_Info> _lst_update = new List <B_Todos_Info>();

                    foreach (B_Todos_Info item in _lst)
                    {
                        Email_Info _Email_Info = new Email_Info
                        {
                            EmailFrom     = EmailHelper.EmailOriginal.EMailFrom,
                            Pass          = EmailHelper.EmailOriginal.PassWord,
                            Display_Name  = EmailHelper.EmailOriginal.DisplayName,
                            EmailTo       = item.Email_Send,
                            EmailCC       = "",
                            Subject       = item.Subject,
                            Content       = item.CONTENT,
                            LstAttachment = _LstAttachment,
                        };

                        CommonFunction.AppsCommon.EnqueueSendEmail(_Email_Info);

                        // update todo-id
                        _lst_update.Add(item);

                        Thread.Sleep(_timeSleep);
                    }

                    // update todo-id
                    if (_lst_update.Count > 0)
                    {
                        _B_Todos_BL.Update_Todo_Email(_lst_update);
                    }

                    Thread.Sleep(10000);
                }
                catch (Exception ex)
                {
                    Thread.Sleep(2000);
                    Logger.Log().Error(ex.ToString());
                }
            }
        }