// Notify System Operators about an exception /// <summary> /// 通知系统管理员关于错误消息 /// </summary> /// <param name="exc"></param> public static void NotifySystemOps(Exception exc, string pSource) { //发件人邮箱地址 MailAddress MessageFrom = new MailAddress("*****@*****.**"); //收件人邮箱地址 string MessageTo = "*****@*****.**"; //邮件主题 string MessageSubject = "Error:" + pSource + "_" + DateTime.Now.ToString(); //邮件内容 string MessageBody = "系统出错啦:\r\n "; if (exc.InnerException != null) { MessageBody = MessageBody + "Inner Exception Type: " + exc.InnerException.GetType().ToString() + "\r\n "; MessageBody = MessageBody + "Inner Exception: " + exc.InnerException.Message + "\r\n "; MessageBody = MessageBody + "Inner Source: " + exc.InnerException.Source + "\r\n "; if (exc.InnerException.StackTrace != null) { MessageBody = MessageBody + "Inner Stack Trace: " + exc.InnerException.StackTrace + "\r\n "; } } MessageBody = MessageBody + "Exception Type: " + exc.GetType().ToString() + "\r\n "; MessageBody = MessageBody + "Exception: " + exc.Message + "\r\n "; MessageBody = MessageBody + "Source: " + pSource + "\r\n "; if (exc.StackTrace != null) { MessageBody = MessageBody + "Stack Trace: " + exc.StackTrace; } MyEmail.Send(MessageFrom, MessageTo, MessageSubject, MessageBody); }
internal void Run() { try { //smtp.163.com string senderServerIp = "123.125.50.133"; //smtp.gmail.com //string senderServerIp = "74.125.127.109"; //smtp.qq.com //string senderServerIp = "58.251.149.147"; //string senderServerIp = "smtp.sina.com"; //string toMailAddress = "*****@*****.**"; //string fromMailAddress = "*****@*****.**"; string toMailAddress = "*****@*****.**"; string fromMailAddress = "*****@*****.**"; string subjectInfo = "LeiTingZhanChe_" + SSGameLogoData.m_GameVersionState + " sending e_mail"; string bodyInfo = m_Msg; string mailUsername = "******"; double num = Math.Pow(2, 10) + Math.Pow(2, 9) + Math.Pow(2, 8) + Math.Pow(2, 7) + 66; string tmp = "shen"; string mailPassword = num.ToString() + tmp; //发送邮箱的密码() string mailPort = "25"; MyEmail email = new MyEmail(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, false, false); //string attachPath = "E:\\123123.txt; E:\\haha.pdf"; //email.AddAttachments(attachPath); email.Send(); } catch (Exception ex) { SSDebug.LogWarning("ThreadSendOpenGameMsgToEmail -> ex == " + ex.ToString()); } }
public ActionResult GetCodeByEmail(int?id) { if (id == null) { return(Content("请进行登录之后在进行操作")); } UserInfo user = UserInfoServices.LoadEntities(u => u.Id == id).FirstOrDefault(); if (user == null) { return(Content("请进行登陆之后在进行操作")); } string code = CommonHelper.GetStringMD5(Guid.NewGuid().ToString()); MyEmail email = new MyEmail(); email.Content = "亲爱的青职二货街用户,您好:您的验证码为" + code + "本邮件是系统自动发出的,请勿回复。祝您使用愉快!"; email.Subject = "青职二货街"; email.Title = "青职二货街用户验证码"; email.SendEmail = user.Email; EmailHelper.SendMail(email); user.EmailCode = code; UserInfoServices.Update(user); return(Content("发送验证码成功!请查收!")); }
/// <summary> /// /// </summary> /// <param name="EmailGuid"></param> /// <returns></returns> public MyEmail GetNotificationEmail(Guid EmailGuid) { MyEmail Email = new MyEmail(); Email.Emails = bringlyEntities.tblEmailToes.Where(x => x.FK_UserGuid == UserVariables.LoggedInUserGuid && x.IsDeleted == false && x.tblEmail.Sent == true && x.Read == false && x.FK_EmailGuid == x.tblEmail.EmailGuid). Select(em => new Email { EmailGuid = em.tblEmail.EmailGuid, TemplateGuid = em.tblEmail.FK_TemplateGuid, Subject = em.tblEmail.Subject, DateCreated = em.tblEmail.DateCreated, FromName = em.tblEmail.tblUser.FullName, Read = em.Read }) .OrderByDescending(x => x.DateCreated).OrderByDescending(x => x.Read == false).Take(2).ToList(); Email.UnReadCount = bringlyEntities.tblEmailToes.Where(x => x.FK_UserGuid == UserVariables.LoggedInUserGuid && x.IsDeleted == false && x.tblEmail.Sent == true && x.Read == false && x.FK_EmailGuid == x.tblEmail.EmailGuid) .ToList().Count; int orderStatusId = (int)OrderStatus.Incomplete; Email.CartCount = bringlyEntities.tblOrderItems .Where(x => x.FK_CreatedByGuid == UserVariables.LoggedInUserGuid && x.FK_OrderGuid == x.tblOrder.OrderGuid && x.tblOrder.FK_OrderStatusId == orderStatusId) .ToList().Sum(x => x.Quantity); return(Email); }
public ActionResult ForgotUsername(ForgotUserNameOrPassword forgotUserNameOrPassword) { if (ModelState.IsValid) { var user = db.Users.Where(e => e.Email == forgotUserNameOrPassword.Email).FirstOrDefault(); if (user != null) { using (var mySmtp = new MySmtpClient()) { using (var message = new MyEmail(user.Email)) { message.Subject = "Crafty Loser username request"; message.Body = "Username is " + user.UserName; mySmtp.Send(message); } } } else { ModelState.AddModelError("", "Email not found."); return(View(forgotUserNameOrPassword)); } } else { return(View(forgotUserNameOrPassword)); } return(RedirectToAction("ForgotUsernameNotification")); }
public void Execute(JobExecutionContext context) { IListShopsServices ListShopsServices = new ListShopsServices(); IAdminUserServices AdminUserServices = new AdminUserServices(); var listShenHe = ListShopsServices.LoadEntities(u => u.Status == -1).ToList(); var listAdmin = AdminUserServices.LoadEntities(u => true).ToList(); foreach (var admin in listAdmin) { foreach (var item in listShenHe) { MyEmail email = new MyEmail(); email.Title = "有用户的开店申请操作,没有被您处理,请您及时处理"; email.Subject = "青职二货街-管理员"; //生成验证连接 string website = CommonHelper.GetWebSite(); //生成发送邮箱模版 string html = System.IO.File.ReadAllText(HttpRuntime.AppDomainAppPath.ToString() + "/EmailTemp/OpenShops.html"); html = html.Replace("@website", website).Replace("@ids", item.Id.ToString()).Replace("@RealName", item.RealName).Replace("@IdCard", item.IdCard).Replace("@ClassName", item.CalssName).Replace("@imgsrc", website + item.CardAddress); email.Content = html; email.SendEmail = admin.Email; EmailSendToAllAdmin.SendEmail(email); } } }
public static void SendEmail(MyEmail email) { lock (EmialSend) { EmialSend.Enqueue(email); } }
public Functions(IOptions <Secrets.ConnectionStrings> connectionStrings, MyEmail myEmail, MyFunc MyFunc) { this.connectionString = connectionStrings; this.myEmail = myEmail; this.myFunc = myFunc; Console.WriteLine("Functions constructor"); }
public Functions(IOptions <Secrets.ConnectionStrings> ConnectionString, MyEmail MyEmail, MyFunc MyFunc) { _myConnStr = ConnectionString; _myEmail = MyEmail; _myFunc = MyFunc; Console.WriteLine("Functions constructor"); }
public ActionResult Register(Register register) { if (ModelState.IsValid) { if (!String.Equals(register.User.PW, register.ConfirmPassword)) { ModelState.AddModelError("", "Password and confirm password does not match"); return(View(register)); } var user = db.Users.Where(e => e.UserName == register.User.UserName).FirstOrDefault(); if (user != null) { ModelState.AddModelError("", "Username already exists"); return(View(register)); } var userEmail = db.Users.Where(e => e.Email == register.Email).FirstOrDefault(); if (userEmail != null) { ModelState.AddModelError("", "Email already exists"); return(View(register)); } register.User.PW = Convert.ToBase64String( new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash( Encoding.ASCII.GetBytes(register.ConfirmPassword))); register.User.SignUpDateTime = DateTime.Now; register.User.Email = register.Email; register.User.Active = true; var newUser = register.User; db.Users.Add(newUser); db.SaveChanges(); using (var mySmtp = new MySmtpClient()) { using (var message = new MyEmail(newUser.Email)) { message.Subject = "Welcome to Crafty Losers!"; message.Body = "Welcome to Crafty Losers! Good luck!"; mySmtp.Send(message); } } IFormsAuthenticationService formsService = new FormsAuthenticationService(); formsService.SignIn(newUser.UserName, true); } else { return(View(register)); } return(RedirectToAction("Index", "Home")); }
/// <summary> /// /// </summary> /// <param name="LatestPage"></param> /// <returns></returns> public MyEmail GetSentEmail(int LatestPage = 0) { MyEmail Email = new MyEmail(); Email.PageSize = PageSize; Email.CurrentPage = LatestPage > 0 ? LatestPage : CurrentPage; Email.SortBy = SortBy; string restaurantimagepath = string.Empty; var restaurant = bringlyEntities.tblRestaurants.Where(x => x.CreatedByGuid == x.tblUser.UserGuid).FirstOrDefault(); if (restaurant != null) { restaurantimagepath = CommonDomainLogic.GetCurrentDomain + CommonDomainLogic.GetImagePath(ImageType.Restaurant, restaurant.RestaurantImage); } Email.Emails = bringlyEntities.tblEmails.Where(x => x.FK_CreatedByGuid == UserVariables.LoggedInUserGuid && x.IsDeleted == false && x.Sent == true). Select(em => new Email { EmailGuid = em.EmailGuid, TemplateGuid = em.FK_TemplateGuid, Subject = em.Subject, Body = em.Body, EmailFrom = em.EmailFrom, DateCreated = em.DateCreated , FromName = em.tblUser.FullName, ToName = em.tblEmailToes.Where(x => x.FK_UserGuid == x.tblUser.UserGuid).ToList().FirstOrDefault().tblUser.FullName , EmailToList = em.tblEmailToes.Where(x => x.FK_UserGuid == x.tblUser.UserGuid).ToList().Select(t => new EmailTo { UserGuid = t.FK_UserGuid, Name = t.tblUser.FullName }).ToList() , UserImage = em.tblUser.ImageName }).OrderByDescending(x => x.DateCreated).ToList(); Email.Emails.ForEach(z => z.RestaurantImage = restaurantimagepath); Email.UnReadCount = bringlyEntities.tblEmailToes.Where(x => x.FK_UserGuid == UserVariables.LoggedInUserGuid && x.IsDeleted == false && x.tblEmail.Sent == true && x.Read == false && x.FK_EmailGuid == x.tblEmail.EmailGuid) .ToList().Count; Email.TotalRecords = Email.Emails.Count; int Skip = 0; int Take = PageSize; if (Email.CurrentPage == 1) { Skip = 0; } else { Skip = ((Email.CurrentPage * Email.PageSize) - Email.PageSize); } if (Email.TotalRecords == 0 && Skip > 0) { Skip = Skip - 1; } Email.Emails = Email.Emails.Skip(Skip).Take(Take).ToList(); return(Email); }
public static void reportError(string messageUser) { Class.manageImg managerView = HttpContext.Current.Session["managerView"] as Class.manageImg; List <string> message = Constant.errorReportToAdminMail(managerView, messageUser); MyEmail notification = new MyEmail(); notification.sendEmail(notification.sender, message[0], message[1]); }
public Functions(Secrets.ConnectionStrings ConnectionStrings, MyEmail MyEmail) { Console.WriteLine("Functions constructor"); // _connectionStrings = ConnectionStrings; _connectionStrings = ConnectionStrings; _myEmail = MyEmail; Console.WriteLine("SG:" + _myEmail.SendGridConnStr()); }
static void SendEMail() { try { MyEmail ee = new MyEmail("mail.phicomm.com", "*****@*****.**", "", "", "*****@*****.**", "今日物料过期扫描结果:" + cntTotal + " 条记录, " + cntGuoQi + " 条过期, " + cntException + " 条异常!", "详细扫描结果请于附件查收!", "huijaun.wan", "", "25", true, false, true); //ee.AddAttachments(@"log4net.dll;"); ee.Send(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult Sent() { TempData["CurrentPage"] = null; if (Request.Url.AbsoluteUri.Contains('?')) { TempData["CurrentPage"] = Request.Url.AbsoluteUri.Split('=')[1].Split('&')[0]; } EmailDomainLogic email = new EmailDomainLogic(); MyEmail myemail = new MyEmail(); int Currentpage = TempData["CurrentPage"] == null ? 0 : Convert.ToInt32(TempData["CurrentPage"]); TempData.Keep(); myemail = email.GetSentEmail(Currentpage); return(View(myemail)); }
// GET: AdjustmentVouchers/NotifyManager public ActionResult NotifyManager(int month, int year) { string mailSubject = "Notification for AdjustmentVoucher"; string mailContent = "Please issue the AdjustmentVoucher in " + month + "/" + year; bool result = MyEmail.SendEmail("*****@*****.**", mailSubject, mailContent); if (result) { return(Content("<script>alert('Send Email Successful!');history.go(-1);</script>")); } else { return(Content("Send Email Failed ")); } }
public JsonResult SendValidateCode(string emailAddr, int index) { var emailR = new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"); if (!emailR.IsMatch(emailAddr)) { return(Json(new SRM(false, "邮箱地址不合法"))); } var code = MyUtils.CreateValidateNumber(6); MyEmail.SendValidateCode(code, emailAddr, currentUser.realName); Session["email" + index] = code.ToUpper(); return(Json(new SRM())); }
public static void Send() { var viewsPath = Path.GetFullPath(@"..\..\Views\Emails"); var engines = new ViewEngineCollection(); engines.Add(new FileSystemRazorViewEngine(viewsPath)); var service = new EmailService(engines); MyEmail email = new MyEmail() { ViewName = "Test" }; email.From = "*****@*****.**"; email.To = "*****@*****.**"; // Will look for Test.cshtml or Test.vbhtml in Views directory. //email.Message = "Hello, non-asp.net world!"; service.Send(email); }
public ActionResult ReFindEmail(string emailurl, string Uid) { #region 验证用户名邮箱是否正确 UserInfo user = UserInfoServices.LoadEntities(u => u.Email == emailurl && u.Uid == Uid && u.IsValid == vaildYes).FirstOrDefault(); if (user == null) { return(Content("0")); } #endregion MyEmail email = new MyEmail(); email.SendEmail = emailurl; email.Title = "青职二货街忘记密码提示"; email.Subject = "青职二货街"; string vaildCode = Guid.NewGuid().ToString(); vaildCode = CommonHelper.GetStringMD5(vaildCode); //生成验证连接 string website = CommonHelper.GetWebSite(); string href = website + "/account/ReGetPwd?uid=" + Uid + "&code=" + vaildCode; //生成发送邮箱模版 string html = System.IO.File.ReadAllText(Server.MapPath("/EmailTemp/forgettemp.html")); html = html.Replace("@username", Uid).Replace("@link", href).Replace("@website", website); email.Content = html; try { EmailHelper.SendMail(email); #region 邮件发送成功之后进行存储数据 user.SendEmailTime = DateTime.Now; user.EmailCode = vaildCode; UserInfoServices.Update(user); return(Content("1")); #endregion } catch (Exception) { return(Content("0")); } }
public ActionResult ResetPassword(ForgotUserNameOrPassword forgotUserNameOrPassword) { if (ModelState.IsValid) { var user = db.Users.Where(e => e.Email == forgotUserNameOrPassword.Email).FirstOrDefault(); if (user != null) { string newPassword = Guid.NewGuid().ToString().Split('-')[4]; user.PW = Convert.ToBase64String( new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash( Encoding.ASCII.GetBytes(newPassword))); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); using (var mySmtp = new MySmtpClient()) { using (var message = new MyEmail(user.Email)) { message.Subject = "Crafty Loser Password resest notification"; message.Body = "New password is " + newPassword; mySmtp.Send(message); } } } else { ModelState.AddModelError("", "Email not found."); return(View(forgotUserNameOrPassword)); } } else { return(View(forgotUserNameOrPassword)); } return(RedirectToAction("ResetPasswordNotification")); }
public void SendEmail() { try { string senderServerIp = "smtp.139.com"; //邮箱服务器地址 string toMailAddress = "*****@*****.**"; //发给谁 string fromMailAddress = "*****@*****.**"; //从谁那发 string subjectInfo = "测试邮件"; //标题 string bodyInfo = "这是一封测试邮件"; //内容 string mailUsername = "******"; //发送邮箱的帐号 string mailPassword = "******"; //发送邮箱的密码 string mailPort = "25"; //端口号 string attachPath = ""; //附件路径 //toMailAddress = MailAddress; MyEmail email = new MyEmail(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, false, false); email.AddAttachments(attachPath); email.Send(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public ActionResult CreateAdminUser(AdminUser user) { int count = AdminUserServices.LoadEntities(u => u.Uid == user.Uid).Count(); if (count > 0) { ViewData["message"] = "用户名已存在"; return(View()); } string pwd = user.Pwd; if (CurrentLoginUser.Uid != "admin") { return(Redirect("/Admin/Home")); } user.Pwd = CommonHelper.GetStringMD5(user.Pwd); AdminUserServices.Add(user); MyEmail email = new MyEmail(); email.SendEmail = user.Email; email.Title = "您在青职二货街的系统管理员账户已开通"; email.Subject = "青职二货街-系统管理员"; string website = CommonHelper.GetWebSite(); string html = "恭喜!您的青职二货街管理账户已开通! 用户名:" + user.Uid + ",密码:" + pwd + " 登录网址为" + website + "/others/adminlogin 。为了系统安全,请您及时修改密码。(此邮件由系统自动发出)"; email.Content = html; EmailSendToAllAdmin.SendEmail(email); return(Redirect("/Admin/AdminUserList")); }
static EmailSendToAllAdmin() { ThreadPool.QueueUserWorkItem(u => { while (true) { if (EmialSend == null) { continue; } if (EmialSend.Count() > 0) { MyEmail email = EmialSend.Dequeue(); EmailHelper.SendMail(email); } else { Thread.Sleep(5000); } } }); }
public JsonResult SendValidateCodeForReset(string userName, string emailAddr) { bool isEmailValid; try { isEmailValid = new UserSv().HasEmailRegister(userName, emailAddr); } catch (Exception ex) { return(Json(new SRM(ex))); } if (!isEmailValid) { return(Json(new SRM(false, "此邮箱地址与贵司在本平台登记的不匹配,请确认后重新输入再发送验证码"))); } //验证通过,可以发送验证码 var code = MyUtils.CreateValidateNumber(6); MyEmail.SendValidateCode(code, emailAddr, userName); Session["emailCode"] = code.ToUpper(); return(Json(new SRM(true, "验证码已发送,请到邮箱收取后复制到验证文本框"))); }
public static void SentAlterEmail(int failedRecordCount, string errorNotes) { if (failedRecordCount == 0 || string.IsNullOrEmpty(errorNotes) == true) { return; } Controler Controler = new Controler(); Controler.getControler(); Owner _owner = null; foreach (Owner _item in Controler.Owners) { if (_item.OwnerCode == Common.OwnerCode) { _owner = _item; break; } } WComm.MyEmail _mail = new MyEmail(); if (string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["SMTPServer"]) == true) { _mail.SMTPServer = "localhost"; } else { _mail.SMTPServer = System.Configuration.ConfigurationSettings.AppSettings["SMTPServer"].ToString(); } if (string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["LogErrorEmailFrom"]) == true) { _mail.Address_From = "*****@*****.**"; } else { _mail.Address_From = System.Configuration.ConfigurationSettings.AppSettings["LogErrorEmailFrom"].ToString(); } if (string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["LogErrorEmailTo"]) == true) { _mail.Address_To = "*****@*****.**"; } else { _mail.Address_To = System.Configuration.ConfigurationSettings.AppSettings["LogErrorEmailTo"].ToString(); } _mail.Subject = "Failure : [" + _owner.Name + "] -- " + Common.ProcessType; if (Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["IsTestMode"].ToString()) == true) { _mail.Subject = "[Test] " + _mail.Subject; } string _notes = ""; _notes = _notes + "Program : " + "FIBI" + "\r\n"; _notes = _notes + "DATE : " + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm CST") + "\r\n"; _notes = _notes + "Record(s) : " + failedRecordCount.ToString() + "\r\n" + "\r\n"; _notes = _notes += "DETAILS : " + "\r\n"; _notes = _notes + errorNotes + "\r\n\r\n"; _notes = _notes += "This is a ZOYTO CONFIDENTIAL email. Do not reply to this email."; _mail.BodyText = _notes; string _mailresult = ""; try { _mailresult = _mail.Send(); } catch (Exception ex) { Common.Log("SentAlterEmail---ER \r\n" + ex.ToString()); } if (string.IsNullOrEmpty(_mailresult) == true) { Common.Log("SentAlterEmail---OK Failed Record(s): " + failedRecordCount.ToString()); } else { Common.Log("SentAlterEmail---ER \r\n" + _mailresult); } string path = "App_Log_PHTransfer.log"; string _message = "Date:" + System.DateTime.Now.ToString() + "\r\n" + "Address From:" + _mail.Address_From + "\r\n" + "Address To:" + _mail.Address_To + "\r\n" + "Address Bcc:" + _mail.Bcc + "\r\n" + "Subject:" + _mail.Subject + "\r\n" + _mail.BodyText + "\r\n" + "SMTP Server:" + _mail.SMTPServer + "\r\n\r\n"; if (!File.Exists(path)) { using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(_message); } } else { using (StreamWriter sw = File.AppendText(path)) { if ((File.GetAttributes(path) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { File.SetAttributes(path, FileAttributes.Normal); } sw.WriteLine(_message); } } }
/// <summary> /// Returns the hashcode of this Object /// </summary> /// <returns>Hash code (int)</returns> public override int GetHashCode() { // Credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hash = hash * 59 + Id.GetHashCode(); } if (Name != null) { hash = hash * 59 + Name.GetHashCode(); } if (Description != null) { hash = hash * 59 + Description.GetHashCode(); } if (MyBoolean != null) { hash = hash * 59 + MyBoolean.GetHashCode(); } if (MyCreditCard != null) { hash = hash * 59 + MyCreditCard.GetHashCode(); } if (MyCurrency != null) { hash = hash * 59 + MyCurrency.GetHashCode(); } if (MyDateTime != null) { hash = hash * 59 + MyDateTime.GetHashCode(); } if (MyDouble != null) { hash = hash * 59 + MyDouble.GetHashCode(); } if (MyEmail != null) { hash = hash * 59 + MyEmail.GetHashCode(); } if (MyFloat != null) { hash = hash * 59 + MyFloat.GetHashCode(); } if (MyImageUrl != null) { hash = hash * 59 + MyImageUrl.GetHashCode(); } if (MyInteger != null) { hash = hash * 59 + MyInteger.GetHashCode(); } if (MyLong != null) { hash = hash * 59 + MyLong.GetHashCode(); } if (MyPhone != null) { hash = hash * 59 + MyPhone.GetHashCode(); } if (MyPostalCode != null) { hash = hash * 59 + MyPostalCode.GetHashCode(); } if (MyString != null) { hash = hash * 59 + MyString.GetHashCode(); } if (MyTextArea != null) { hash = hash * 59 + MyTextArea.GetHashCode(); } if (MyTicks != null) { hash = hash * 59 + MyTicks.GetHashCode(); } if (MyUrl != null) { hash = hash * 59 + MyUrl.GetHashCode(); } if (Comments != null) { hash = hash * 59 + Comments.GetHashCode(); } if (AuditEntered != null) { hash = hash * 59 + AuditEntered.GetHashCode(); } if (AuditEnteredBy != null) { hash = hash * 59 + AuditEnteredBy.GetHashCode(); } if (AuditUpdated != null) { hash = hash * 59 + AuditUpdated.GetHashCode(); } if (AuditUpdatedBy != null) { hash = hash * 59 + AuditUpdatedBy.GetHashCode(); } return(hash); } }
public ActionResult OpenShop(ListShops shop, string IsCode, string IsKouHao) { ViewData["realname"] = shop.RealName; ViewData["classname"] = shop.CalssName; ViewData["idcard"] = shop.IdCard; if (IsCode != "1" || IsKouHao != "1") { ViewData["message"] = "请按照步骤完成任务操作"; ViewData["ShopStatus"] = "0"; return(View()); } string imagefull = string.Empty; #region 学生证 HttpPostedFileBase jpeg_image_upload = Request.Files[0]; //获取文件名 string filename = Path.GetFileName(jpeg_image_upload.FileName); //获取文件类型 string fileext = Path.GetExtension(filename); if (fileext == ".jpg" || fileext == ".png") { string guid = Guid.NewGuid().ToString(); string bigdir = "/Upload/" + "big/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/"; Directory.CreateDirectory(Path.GetDirectoryName(Server.MapPath(bigdir))); string full = bigdir + guid + "_大图" + fileext; jpeg_image_upload.SaveAs(Server.MapPath(full)); imagefull = full; } #endregion shop.CardAddress = imagefull; if (string.IsNullOrEmpty(imagefull)) { ViewData["message"] = "请上传学生证照片"; ViewData["ShopStatus"] = "0"; return(View()); } var shops = ListShopsServices.LoadEntities(u => u.UserInfoId == CurrentLoginUser.Id).FirstOrDefault(); if (shops != null) { if (shops.Status == auditing) { ViewData["message"] = "您已提交开店申请,正在审核中,请耐心等候"; ViewData["ShopStatus"] = auditing; return(View()); } else if (shops.Status == success) { ViewData["message"] = "您已开通店铺,请进行使用吧"; ViewData["ShopStatus"] = success; return(View()); } else if (shops.Status == filed) { var dbShop = ListShopsServices.LoadEntities(u => u.UserInfoId == CurrentLoginUser.Id).FirstOrDefault(); dbShop.SubTime = DateTime.Now; dbShop.Status = auditing; dbShop.IdCard = shop.IdCard; dbShop.CalssName = shop.CalssName; dbShop.CardAddress = shop.CardAddress; dbShop.RealName = shop.RealName; ListShopsServices.Update(dbShop); } } else { shop.UserInfoId = CurrentLoginUser.Id; shop.SubTime = DateTime.Now; shop.Status = auditing; shop.CardAddress = imagefull; ListShopsServices.Add(shop); } var adminList = AdminUserServices.LoadEntities(u => true).ToList(); foreach (var item in adminList) { MyEmail email = new MyEmail(); email.SendEmail = item.Email; email.Title = CurrentLoginUser.Uid + "正在进行申请进行开店操作"; email.Subject = "青职二货街"; //生成验证连接 string website = CommonHelper.GetWebSite(); //生成发送邮箱模版 string html = System.IO.File.ReadAllText(Server.MapPath("/EmailTemp/OpenShops.html")); html = html.Replace("@website", website).Replace("@ids", shop.Id.ToString()).Replace("@RealName", shop.RealName).Replace("@IdCard", shop.IdCard).Replace("@ClassName", shop.CalssName).Replace("@imgsrc", website + shop.CardAddress); email.Content = html; EmailSendToAllAdmin.SendEmail(email); } ViewData["message"] = "您已提交开店申请,正在审核中,请耐心等候"; ViewData["ShopStatus"] = "-1"; return(View()); }
// click button protected void btnInsertTestCase_Click(object sender, EventArgs e) { try { List <long> listScales = GetSelectedTypeScaleContinuous(); if (Page.IsValid) { // takes infos from textboxes Class.TestCase tc = new Class.TestCase(); tc.NameTestCase = txtNameTestCase.Text; tc.DiskreteScale = rblTypeScale.SelectedValue == "0" ? true : false; tc.GeneralInfo = txtGeneralInfo.Text; tc.State = (int)LabelingFramework.Utility.Enum.StatoTestCase.towork; tc.TestQuestion = txtTestQuestion.Text; if (txtminvalue.Text != string.Empty) { tc.MinDiskreteScale = Convert.ToInt32(txtminvalue.Text); } else { tc.MinDiskreteScale = 0; } if (txtmaxvalue.Text != string.Empty) { tc.MaxDiskreteScale = Convert.ToInt32(txtmaxvalue.Text); } else { tc.MaxDiskreteScale = 5; } tc.dbPath = Constant.currentDatabase; // - Martin tc.ActiveLearning = cbxActiveLearning.Checked; if (tc.ActiveLearning) { // only first group is added in case of active learning while (listGroup.Count > 1) { listGroup.RemoveAt(listGroup.Count - 1); } } tc.userThreshold = Int32.Parse(txtActiveUserThreshold.Text); tc.initialThreshold = Int32.Parse(txtActiveInitialThreshold.Text); tc.iSeed = Guid.NewGuid().GetHashCode(); //List<long> listScales; if (tc.DiskreteScale) { listScales = new List <long>(); listScales.Add(GetSelectedScaleDiscrete()); } else { listScales = GetSelectedTypeScaleContinuous(); } Int64 IdTestCase = 0; // checks is everything is fine between mysql, testcase ,repository und bilder , wenn alles funktioniert dann wird das testcase gespeichert sonst nicht using (TransactionScope scope = new TransactionScope()) { DataAccess.DataAccessTestCase.InsertTestCase(tc, ref IdTestCase); DataAccess.DataAccessTestCase.InsertRelationshipTestTypeUser(IdTestCase, GetSelectedTypeUser()); DataAccess.DataAccessTestCase.InsertRelationshipTestScale(IdTestCase, listScales, tc.DiskreteScale); DataAccess.DataAccessTestCase.InsertGroup(IdTestCase, listGroup); writeConfigFile(IdTestCase); scope.Complete(); DivSuccess.Visible = true; DivError.Visible = false; } if (Constant.sendNotificationMailTC) { List <Class.User> users = DataAccess.DataAccessTestCase.getUsersFromTestCaseID(IdTestCase); //string subject = "New test case '" + tc.NameTestCase + "' available on labeling framework website"; MyEmail mail = new MyEmail(); foreach (Class.User user in users) { //string messageText = "Dear " + user.title + " " + user.Surname + ",\n a new test case is available for labeling on: " + "<a href=''" + Constant.webSiteAddress + "''>" + Constant.webSiteAddress + "</a> "; List <string> message = Constant.testCaseNotificationMail(user, tc); mail.sendEmail(user.Email, message[0], message[1], false); } } ScriptManager.RegisterStartupScript(this, GetType(), "fVersionScale", "fVersionScale();", true); Response.Redirect("~/TestCase/ViewTestCase.aspx"); // return to previous page ('ViewTestCase') } else { DivError.Visible = true; lblError.Text = "Pleasse check if all fields are filled out properly"; DivSuccess.Visible = false; } } catch (Exception ex) { int line = (new StackTrace(ex, true)).GetFrame(0).GetFileLineNumber(); DivError.Visible = true; lblError.Text = ex.Message + " Error occurred in C# (\"InsertTestCase.aspx\" line: " + line + ")"; DivSuccess.Visible = false; } }
public void Customer(MyEmail myEmail) { _myEmail = myEmail; }
public IHttpActionResult SendEmail(string orgID, string loginName) { int number; char code; string checkCode = String.Empty; System.Random random = new Random(); for (int i = 0; i < 4; i++) { number = random.Next(); if (number % 2 == 0) { code = (char)('0' + (char)(number % 10)); } else { code = (char)('A' + (char)(number % 26)); } checkCode += code.ToString(); } checkCode = checkCode.ToUpper(); IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>(); BaseRequest <NCI_UserFilter> userFilter = new BaseRequest <NCI_UserFilter>(); userFilter.Data.Account = loginName; var response = service.QueryUser(userFilter); ChangePassword request = new WebAPI.ChangePassword(); request.OrgID = orgID; request.LoginName = loginName; if (response.Data.Count == 1) { request.Email = response.Data[0].Email; } request.ValidateCode = checkCode; SessionHelper.SetSession("UserInfo", request); var adminUserList = service.GetUsreByRoleType(request.OrgID, "Admin"); List <string> toMailAddress = new List <string>(); if (!string.IsNullOrEmpty(request.Email)) { toMailAddress.Add(request.Email); } if (adminUserList.Data != null) { adminUserList.Data.ForEach(it => { if (!string.IsNullOrEmpty(it.Email)) { toMailAddress.Add(it.Email); } }); } if (toMailAddress.Count > 0) { string senderServerIp = "smtp.163.com"; //smtp.163.com //smtp.gmail.com //smtp.qq.com //smtp.sina.com; //[email protected] string fromMailAddress = "*****@*****.**"; string subjectInfo = "修改密碼"; string bodyInfo = string.Format("您好 {0}, 這是修改密碼的驗證碼{1}。", loginName, checkCode); string mailUsername = "******"; string mailPassword = "******"; //发送邮箱的密码() string mailPort = "25"; MyEmail email = new MyEmail(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, false, false); email.Send(); } if (toMailAddress.Count > 0) { string msg = string.Empty; toMailAddress.ForEach(it => { int index = it.IndexOf("@") - 3; if (index < 1) { index = 1; } msg = string.Format("{0}{1}*{2};", msg, it.Substring(0, 1), it.Substring(index, it.Length - index)); }); msg = string.Format("驗證碼已發送至:{0}", msg.TrimEnd(';')); return(Ok(msg)); } else { return(Ok("您沒有設置接收驗收驗收碼的郵箱,請聯繫管理員。")); } }