public IHttpActionResult sendEmailForgotPassword(string email, long hosID) { try { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); string code = DateTime.Now.ToString("yyyyMMddhhmmsstt"); string code_encrypt = LVCrypto.GetMd5Hash(md5, code); // Luu thong tin lai: UserAccount account = this.Repository.GetQuery <UserAccount>().FirstOrDefault(m => m.AccountNameEmailAddress == email); if (account != null) { account.isBlocked = true; account.RequestDateForPWD = DateTime.Now; account.ForgotPwdCode = code_encrypt; this.Repository.Update <UserAccount>(account); this.Repository.UnitOfWork.SaveChanges(); } RegisterMailController mailCtrl = new RegisterMailController(); string report = GetMailTemplate(); //Dictionary<long, string> appStatusDic = GetAppStatusDic(); string Body = ""; var hosInfo = (from h in this.Repository.GetQuery <HCProvider>() where h.HosID == hosID select new { hospital = h.HCPrvProviderName, slogan = h.Slogan, addressHos = h.HCPractAddressText, logo = h.HosLogoImgPath }).FirstOrDefault(); Body = report; var url = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace(HttpContext.Current.Request.UrlReferrer.AbsolutePath, ""); Body = Body.Replace("@hospital", hosInfo.hospital); Body = Body.Replace("@addressHos", hosInfo.addressHos); //slogan Body = Body.Replace("@slogan", hosInfo.slogan); LV.Common.LVCrypto cry = new LVCrypto(); Body = Body.Replace("@ForgotPassword", url + "/eportal/NewPassword/" + code_encrypt); List <LinkedResource> res = new List <LinkedResource>(); LinkedResource pic1 = new LinkedResource(HttpContext.Current.Server.MapPath("~") + hosInfo.logo); pic1.ContentId = "logo"; res.Add(pic1); mailCtrl._SendMail(email, "Cấp lại mật khẩu", Body, null, res); return(Ok(true)); } catch (Exception exp) { return(Ok(false)); } }
public bool RegisterMailD(string to, string subject, long AccountID, string ActivationCode) { try { RegisterMailController mailCtrl = new RegisterMailController(); int hosID = 11163; string report = GetMailTemplate(); //Dictionary<long, string> appStatusDic = GetAppStatusDic(); string Body = ""; var hosInfo = (from h in this.Repository.GetQuery <HCProvider>() where h.HosID == hosID select new { hospital = h.HCPrvProviderName, slogan = h.Slogan, addressHos = h.HCPractAddressText, logo = h.HosLogoImgPath }).FirstOrDefault(); Body = report; var url = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace(HttpContext.Current.Request.UrlReferrer.AbsolutePath, ""); Body = Body.Replace("@hospital", hosInfo.hospital); Body = Body.Replace("@addressHos", hosInfo.addressHos); //slogan Body = Body.Replace("@slogan", hosInfo.slogan); LV.Common.LVCrypto cry = new LVCrypto(); Body = Body.Replace("@linkActive", url + "/eportal/ActiveRegister/" + ActivationCode); List <LinkedResource> res = new List <LinkedResource>(); LinkedResource pic1 = new LinkedResource(HttpContext.Current.Server.MapPath("~") + hosInfo.logo); pic1.ContentId = "logo"; res.Add(pic1); mailCtrl._SendMail(to, subject, Body, null, res); return(true); } catch (Exception exp) { return(false); } }
public bool RegisterAccount(string to, string subject, string ActivationCode, string Url) { try { int HosID = int.Parse(ConfigurationManager.AppSettings["HosID"]); string Body = GetAnnTemp("RegAccountNotify"); if (!string.IsNullOrWhiteSpace(Body)) { var objName = new object[] { "HosID" }; var objParam = new object[] { HosID }; var hosInfo = this.Repository.ExecuteStoreScalar("usp_GetHCProviderInfor", objName, objParam); List <LinkedResource> res = new List <LinkedResource>(); foreach (DataRow dr in hosInfo.Tables[0].Rows) { Body = Body.Replace("@hospital", dr["HCPrvProviderName"] == null ? "" : dr["HCPrvProviderName"].ToString()); Body = Body.Replace("@addressHos", dr["HCPractAddressText"] == null ? "" : dr["HCPractAddressText"].ToString()); Body = Body.Replace("@slogan", dr["Slogan"] == null? "" : dr["Slogan"].ToString()); //LinkedResource pic1 = new LinkedResource(HttpContext.Current.Server.MapPath("~") + dr["HosLogoImgPath"] == null ? "" : dr["HosLogoImgPath"].ToString()); //pic1.ContentId = "logo"; //res.Add(pic1); break; } //var url = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace(HttpContext.Current.Request.UrlReferrer.AbsolutePath, ""); LV.Common.LVCrypto cry = new LVCrypto(); Body = Body.Replace("@linkActive", Url + "/ActiveRegister/" + ActivationCode); _SendMail(to, subject, Body, null, res); } return(true); } catch (Exception ex) { log.Error(ex.Message); return(false); } }