Ejemplo n.º 1
0
        public ActionResult DoForget()
        {
            object notice = new object();
            if (!string.IsNullOrEmpty(Request.Params["txtEmail"]))
            {
                string _email = Request.Params["txtEmail"].Trim().ToLower();
                if (!Regex.IsMatch(_email, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_EMAIL_FORMAT_ERROR + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                _vendorImp = new VendorMgr(connectionString);
                //Caller caller = null;
                BLL.gigade.Model.Vendor vendor = null;
                ICallerImplMgr callerMgr = new CallerMgr(connectionString);
                BLL.gigade.Model.Vendor query = new BLL.gigade.Model.Vendor();
                try
                {
                    query.vendor_email = _email;
                    vendor = _vendorImp.Login(query);
                }
                catch (Exception ex)
                {
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                }

                if (vendor == null)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMIAL_NOT_MATCH + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                if (vendor.vendor_status >= 2)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMAIL_STATUS_INACTIVE + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                string sUser_Confirm_Code = BLL.gigade.Common.CommonFunction.Generate_Rand_String(8);

                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();

                try
                {
                    _vendorImp.Modify_Vendor_Confirm_Code(Convert.ToInt32(vendor.vendor_id), hash.SHA256Encrypt(sUser_Confirm_Code));
                }
                catch (Exception ex)
                {
                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                }



                ///////////////////////
                //發郵件
                ///////////////////////

                //return Redirect("/Login/ChangePasswd?uid=" + caller.user_id + "&code=" + sUser_Confirm_Code);

                ViewBag.ConfirmSend = "請檢查您的E-mail信箱,以取得密碼的相關資訊!";
                return View("NoticeShow");

            }
            else
            {
                notice = "{result:'Notice',msg:'登錄信箱不能為空!'}";
                ViewBag.notice = notice;
                return View("Forget");
            }
        }