public ActionResult Approve(int id) { var order = _orderService.GetOrderById(id); if (order == null) { return(RedirectToAction("List")); } if (!order.DeliverId.HasValue) { ErrorNotification("Please select a deliver for order!."); return(RedirectToAction("Edit", new { order.Id })); } var customer = _customerService.GetCustomerById(order.CustomerId); var currentUser = Session[Values.USER_SESSION] as UserModel; if (currentUser != null) { order.ApproverId = currentUser.Id; } _orderService.Approved(order); if (customer != null) { string emailContent = GetBodyOfOrderInformation(order, customer); SendEmailHelper.SendEmailToCustomer(customer.Email, customer.LastName + " " + customer.FirstName, "Order information", emailContent); string smsContent = "Your order have been approved. Please check your email for more information of order. Thanks!!!"; SendSmsToCustomer(customer.Phone, smsContent); } SuccessNotification("Approve order successfully."); return(RedirectToAction("Edit", new { order.Id })); }
public ActionResult Reply(FeedbackModel model) { try { var feedback = _feedbackService.GetFeedbackById(model.Id); if (feedback == null) { return(RedirectToAction("List")); } if (string.IsNullOrEmpty(model.ReplyContent)) { ErrorNotification("Reply content is required!"); return(RedirectToAction("Edit", new { id = feedback.Id })); } var currentUser = Session[Values.USER_SESSION] as UserModel; feedback.ReplierId = currentUser.Id; feedback.RepliedDateTime = DateTime.Now; feedback.ReplyContent = model.ReplyContent; SendEmailHelper.SendEmailToCustomer(feedback.Email, feedback.FullName, "Feedback information", feedback.ReplyContent); _feedbackService.AddReply(feedback); SuccessNotification("Reply feedback successfully!"); return(RedirectToAction("Edit", new { id = feedback.Id })); } catch (Exception e) { ErrorNotification("Reply feedback failed!"); return(RedirectToAction("Edit", new { id = model.Id })); } }
public ActionResult Cancel(int id) { var order = _orderService.GetOrderById(id); if (order == null) { return(RedirectToAction("List")); } var customer = _customerService.GetCustomerById(order.CustomerId); var currentUser = Session[Values.USER_SESSION] as UserModel; if (currentUser != null && RefundMoneyFromPaymentId(order.PaymentId)) { order.CanceledBy = currentUser.Id; _orderService.Cancel(order); SuccessNotification("Cancel order successfully."); if (customer != null) { string emailContent = GetBodyCancelOrder(customer); SendEmailHelper.SendEmailToCustomer(customer.Email, customer.LastName + " " + customer.FirstName, "Order information", emailContent); string smsContent = "Your order have been cancelled. Please check your email for more information of order. Thanks!!!"; SendSmsToCustomer(customer.Phone, smsContent); } } else { ErrorNotification("Cancel order failed"); } return(RedirectToAction("Edit", new { order.Id })); }
public static async Task Main(string[] args) { List <string> scopes = new List <string>() { "user.read", "Reports.Read.All" }; string token = await Authentication.getTokenAuthAsync(scopes); Console.WriteLine(token); args[0] = "D7"; if (args.Length != 0) { string graphAPIEndpoint = $"https://graph.microsoft.com/v1.0/reports/getEmailActivityUserDetail(period='{args[0]}')"; Console.Write(graphAPIEndpoint); HttpHelper httpHelper = new HttpHelper(); string filepath = Path.GetTempPath() + $"\\MailUsageReport{args[0]}.csv"; await httpHelper.GetHttpContentAsync(graphAPIEndpoint, token, filepath); await CSVHelper.sortCSV(filepath); SendEmailHelper emailHelper = new SendEmailHelper(System.Configuration.ConfigurationManager.AppSettings["Server"], System.Configuration.ConfigurationManager.AppSettings["Server"], 587); List <string> receivers = System.Configuration.ConfigurationManager.AppSettings["Receivers"].Split(',').ToList(); List <string> ccs = System.Configuration.ConfigurationManager.AppSettings["CCs"].Split(',').ToList(); await emailHelper.SendEmail(System.Configuration.ConfigurationManager.AppSettings["Email"], System.Configuration.ConfigurationManager.AppSettings["Password"], receivers, ccs, args[0] == "D7"?"Weekly Report Mail Usage" : "Monthly Report Mail Usage", args[0] == "D7"? "Weekly Report Mail Usage" : "Monthly Report Mail Usage", filepath); } }
public async Task <IActionResult> SendEmail(int logId) { SendEmailLogBll sendEmailLogBll = new SendEmailLogBll(); var log = await sendEmailLogBll.GetById(logId); SendEmailHelper.SendEmail(log); return(Json(new { code = 1, msg = "OK" })); }
public ActionResult SendEmail(EmailBodyViewModel contactModel) { if (!ModelState.IsValid) { //Not necessary, but another way to get hold of validation errors IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); List <string> errorList = new List <string>(); var modelErrors = allErrors as ModelError[] ?? allErrors.ToArray(); errorList.Add("<ul class=\"list-unstyled\">"); foreach (var error in modelErrors) { errorList.Add($"<li class=\"text-danger\">{error.ErrorMessage}</li>"); } errorList.Add("</ul>"); string displayErrors = string.Join(" ", errorList.ToArray()); TempData["ErrorList"] = displayErrors; return(View("Home")); } EmailBodyViewModel emailBodyModel = new EmailBodyViewModel { Email = contactModel.Email, Name = contactModel.Name, Subject = contactModel.Subject, Message = contactModel.Message }; //Instead of using stringbuilder to create email body, use an online source to create email body such as https://chamaileon.io/ var emailBody = _renderMvcPartialsContact.RenderPartialViewToString("pvContactPartialViewTemplate", emailBodyModel); EmailParametersHelper emailModel = new EmailParametersHelper { BodyText = emailBody, EmailModelHelper = emailBodyModel }; bool emailSentStatus = SendEmailHelper.SendEmail(emailModel); if (emailSentStatus) { TempData["Status"] = "Email Sent"; return(View()); } TempData["Status"] = "Email Failed"; return(View()); }
/// <summary> /// -- Build mail body -- /// </summary> /// <param name="itemKey"></param> /// <param name="itemValue"></param> /// <param name="bcc"></param> /// <param name="cc"></param> private bool BuildMailBody(string itemKey, string itemValue, string bcc = null, string cc = null) { string currentMonth = DateTime.Now.ToString("MMMM").ToUpper(); string sujet = $"Fihe de paie de {currentMonth}."; //string fullName = itemKey.ToString().Split('@')[0].ToString(); //string corpsDuMail = $"Bonjour {fullName.ToUpper()},\n\nTu trouvera ci-joint ta fiche de paie de du mois de " + // $"{currentMonth}. \n\nEn te souhaitant bonne réception"; if (IsPreviewEmail && string.IsNullOrEmpty(AdminEmail)) { ErrorMessage = ErrorMessageLabels.CheckAdminEmailMsg; _logger.Debug($"==> {ErrorMessage}."); _dialogService.ShowMessage(ErrorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Yes); return(false); } else { // -- Création d'objet mailMessage -- _emailMessage.MailBody = corpsDuMail; _emailMessage.Suject = sujet; _emailMessage.FilePath = itemValue; _emailMessage.ToEmail = itemKey; _emailMessage.Bcc = bcc; _emailMessage.Cc = cc; _emailMessage.AdminEmail = AdminEmail; _emailMessage.IsPreviewMail = IsPreviewEmail; var sendMailResponse = SendEmailHelper.SendEmail(_emailMessage); if (sendMailResponse == false) { ErrorMessage = "Erreur durant l'envoie de l'email. \n Vous devez saisir l'adresse mail administrateur!"; _logger.Debug($"==> {ErrorMessage}."); _dialogService.ShowMessage(ErrorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Yes); } return(sendMailResponse); } }
public static bool SendVerificationEmail(string emailAddress, string guid) { try { StringBuilder emailMessage = new StringBuilder(); emailMessage.Append("<p>Hello,</p>"); emailMessage.Append(string.Format("<p><a href='{0}?email={1}&token={2}'>Please click here to verify your email</a></p>", AppSettingConfigurations.AppSettings.VerifyEmailUrl, emailAddress, guid)); emailMessage.Append("<p>Thank you for using Tenant!</p>"); SendEmailHelper.SendEmail(emailAddress, emailMessage, "Tenant - Email verification", true); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 发送昨日报表 /// </summary> /// <param name="context"></param> public void Execute(IJobExecutionContext context) { JobDataMap data = context.JobDetail.JobDataMap; string receive = data.GetString("ReceiveEmail"); if (string.IsNullOrEmpty(receive)) { OrderMonitorViewModel.Instance().ShowMessage("接收人的邮箱为空"); return; } DataTable dataTable = devJsrmOrderManager.GetYesterdayDispatchingOrderTable(); List <Order> orders = devJsrmOrderManager.ConvertToOrderList(dataTable); //获取已处理工单的完成时间 orders.Where(x => x.FinishTime == DateTime.MinValue).ToList().ForEach(x => { string TrueResponsiblePerson = ""; x.FinishTime = OrderMonitorViewModel.Instance().GetTimePointByGDAsync(x.problemCode, true, out TrueResponsiblePerson); if (x.FinishTime != DateTime.MinValue) { devJsrmOrderManager.UpdateFinsihTime(x.problemCode, x.FinishTime, TrueResponsiblePerson); } }); DataTable dataTableForEmail = devJsrmOrderManager.GetYesterdayDispatchingOrderTableForEmail(); int count = orders.Count(); if (count <= 0) { OrderMonitorViewModel.Instance().ShowMessage("无昨日工单"); return; } string content = SendEmailHelper.HtmlBody(dataTableForEmail); SendEmailHelper.SendEmailAsync(receive, $"{DateTime.Now.AddDays(-1).ToString("yyyyMMdd")}日捷服务处理报表", content, true); OrderMonitorViewModel.Instance().ShowMessage($"已发送昨日报表邮件"); orders.Where(x => x.Dispatched == 0).ToList().ForEach(x => { devJsrmOrderManager.UpdateDispatch(x.problemCode); }); }
public static bool SendPasswordResetEmail(string emailAddress, string guid) { try { StringBuilder emailMessage = new StringBuilder(); emailMessage.Append("<p>Hello,</p>"); emailMessage.Append("<p>You have requested a password reset for the Tenant website.</p>"); emailMessage.Append(string.Format("<p><a href='{0}?email={1}&token={2}'>Please click here to reset your password</a></p>", AppSettingConfigurations.AppSettings.ResetPasswordUrl, emailAddress, guid)); emailMessage.Append("<p>If you did not request a password reset, please just ignore this email."); emailMessage.Append("<p>Thank you for using Tenant!</p>"); SendEmailHelper.SendEmail(emailAddress, emailMessage, "Tenant - Password Reset Request", true); return(true); } catch (Exception ex) { return(false); } }
public void Approve() { DataSet ds; DataSet ds1; Models.TicketingEventsNew _Events = null; int EventID = Convert.ToInt32(Request.QueryString["ID"]); if (EventID > 0) { ds = new Musika.Repository.SPRepository.SpRepository().ShiftDatetoOriginalTables(EventID); GenericRepository <TicketingEventsNew> _EventsRepo = new GenericRepository <TicketingEventsNew>(_unitOfWork); _Events = _EventsRepo.Repository.GetById(EventID); bool tourdata = new Musika.Repository.SPRepository.SpRepository().SpUpdateTourData(_Events.ArtistId, _Events.VenueName, _Events.StartDate, _Events.EventTitle, _Events.EventID); // if (ds.Tables[0].Rows.Count > 0) // { ds1 = new Musika.Repository.SPRepository.SpRepository().SpGetTicketingEventUsersToSendEmail(EventID); if (ds1.Tables[0].Rows.Count > 0) { DataRow dr = ds1.Tables[0].Rows[0]; ltMessage.Text = "Event Approved successfully."; string html = string.Empty; string Email = dr["Email"].ToString(); html = "<p>Hi " + dr["UserName"].ToString() + "," + " </p>"; html += "<p>Your Event Changes Has been approved by Admin." + "</p>"; html += "<p><br>You can view your changes in your panel" + "<p>"; // html += "<p><br>User Name : " + dr["UserName"].ToString() + "<p>"; html += "<p><br><br><strong>Thanks,<br><br>The " + WebConfigurationManager.AppSettings["AppName"] + " Team</strong></p>"; SendEmailHelper.SendMail(Email, "Event Changes Approved", html, ""); } // } else { ltMessage.Text = "Invalid Activation code."; } } }
static void Main(string[] args) { Console.WriteLine("----------------------1内置节点-----------------------"); var val = ConfigurationManager.AppSettings["MailServer"]; var user = ConfigurationManager.AppSettings["MailUser"]; var pwd = ConfigurationManager.AppSettings["MailPassword"]; Console.WriteLine("MailServer:" + val); Console.WriteLine("MailUser:"******"MailPassword:"******"\r"); Console.WriteLine("----------------------2自定义节点,内置处理程序-----------------------"); Hashtable mailServer = (Hashtable)ConfigurationManager.GetSection("mailServer"); Console.WriteLine("address:" + mailServer["address"].ToString()); Console.WriteLine("userName:"******"userName"].ToString()); Console.WriteLine("password:"******"password"].ToString()); Console.WriteLine("\r"); Console.WriteLine("-----------3自定义节点,自定义处理程序 IConfigurationSectionHandler--------------"); MailServerConfig mailConfig = (MailServerConfig)ConfigurationManager.GetSection("mailServerGroup"); Console.WriteLine("provider:" + mailConfig.Provider); Console.WriteLine("\r"); Console.WriteLine("client1:" + mailConfig[0].Client); Console.WriteLine("address1:" + mailConfig[0].Address); Console.WriteLine("userName1:" + mailConfig[0].UserName); Console.WriteLine("password1:" + mailConfig[0].Password); Console.WriteLine("\r"); Console.WriteLine("client2:" + mailConfig[1].Client); Console.WriteLine("address2:" + mailConfig[1].Address); Console.WriteLine("userName2:" + mailConfig[1].UserName); Console.WriteLine("password2:" + mailConfig[1].Password); Console.WriteLine("\r"); Console.WriteLine("----------3自定义节点,自定义处理程序 ConfigurationSection------------"); MailServerSection mailSection = (MailServerSection)ConfigurationManager.GetSection("mailServerGroup2"); Console.WriteLine("provider:" + mailSection.Provider); Console.WriteLine("\r"); Console.WriteLine("client1:" + mailSection.MailServers[0].Client); Console.WriteLine("address1:" + mailSection.MailServers[0].Address); Console.WriteLine("userName1:" + mailSection.MailServers[0].UserName); Console.WriteLine("password1:" + mailSection.MailServers[0].Password); Console.WriteLine("\r"); Console.WriteLine("client2:" + mailSection.MailServers[1].Client); Console.WriteLine("address2:" + mailSection.MailServers[1].Address); Console.WriteLine("userName2:" + mailSection.MailServers[1].UserName); Console.WriteLine("password2:" + mailSection.MailServers[1].Password); Console.WriteLine("\r"); Console.WriteLine("----------4存储对象------------"); //IGreetingStrategy greetingStrategy = new ChineseGreeting(); //GeneralClass generalObj = new GeneralClass(greetingStrategy); //if (generalObj != null) // generalObj.SayHello(); //string strategy = ConfigurationManager.AppSettings["GreetingLanguage"]; //IGreetingStrategy greetingStrategy = null; //GeneralClass generalObj = null; //if (strategy == "Chinese") // greetingStrategy = new ChineseGreeting(); //else if (strategy == "English") // greetingStrategy = new EnglishGreeting(); //if (greetingStrategy != null) // generalObj = new GeneralClass(greetingStrategy); //if (generalObj != null) // generalObj.SayHello(); IGreetingStrategy greetingStrategy = (IGreetingStrategy)ConfigurationManager.GetSection("greetingStrategy"); GeneralClass generalObj = null; if (greetingStrategy != null) { generalObj = new GeneralClass(greetingStrategy); } if (generalObj != null) { generalObj.SayHello(); } //Console.WriteLine("----------5统一结点配置管理------------"); ConfigManager config = (ConfigManager)ConfigurationManager.GetSection("traceFact"); Console.WriteLine("Name:" + config.ForumConfig.Name); Console.WriteLine("OfflineTime:" + config.ForumConfig.OfflineTime.ToString()); Console.WriteLine("PageSize:" + config.ForumConfig.PageSize.ToString()); Console.WriteLine("ReplyCount:" + config.ForumConfig.ReplyCount.ToString()); Console.WriteLine("RootUrl:" + config.ForumConfig.RootUrl.ToString()); //var ordre_info = new List<string>() { "1", "2", "3", "4", "5" }; //while (ordre_info.Count() > 3) //{ // var li_ = ordre_info.Take(3).ToList(); // ordre_info.RemoveRange(0, 3); //} Console.WriteLine("----------Xsd第三方元数据验证------------"); Console.WriteLine("\r"); XsdHelper.XmlValidationByXsd("", "", "http://www.oncefly.com"); Console.WriteLine("----------配置分类读取------------"); Console.WriteLine("\r"); //JackyFei.Config.Config.Configuration.ConfigurationManager.ProductConfig.Promotions.ForEach(promotion => //{ // Console.WriteLine(promotion.DomainModelPath.Path); //}); //JackyFei.Config.Config.Configuration.ConfigurationManager.ServiceConfig.Services.ForEach(service => //{ // Console.WriteLine("Address:{0};Timeout:{1}", service.Address, service.Timeout); //}); //var distributeTime = JackyFei.Config.Config.Configuration.ConfigurationManager.OrderConfig.DistributeTime; //Console.WriteLine("StartTime:{0};StartTime:{1};DistributeType:{2}", distributeTime.StartTime, distributeTime.EndTime, distributeTime.DistributeType); //var distributeArea = JackyFei.Config.Config.Configuration.ConfigurationManager.OrderConfig.DistributeArea; //Console.WriteLine("BeginArea:{0};EndArea:{1}", distributeArea.BeginArea, distributeArea.EndArea); Order order = new Order() { Id = "001", State = OrderState.BeginDistribute }; SendEmailHelper.SendEmail(order); Console.ReadLine(); }
public async Task <IActionResult> SaveSendEmailTask() { SendEmailTask sendEmailTask = new SendEmailTask(); SendEmailLogBll sendEmailLogBll = new SendEmailLogBll(); sendEmailTask.EmailTempId = Request.Form["EmailTempId"].TryToInt(0); sendEmailTask.TaskName = Request.Form["TaskName"].TryToString(); sendEmailTask.CreateTime = DateTime.Now; string Email = Request.Form["Email"].TryToString(); bool flag = Request.Form["sendAll"].TryToString() == "on"; SendEmailTaskBll bll = new SendEmailTaskBll(); int id = await bll.AddAsync(sendEmailTask); if (id > 0) { Task.Run(async() => { if (!Email.IsNull()) { SendEmailLog log = new SendEmailLog { SendEmailTaskId = id, Email = Email, IsRead = false, IsSend = false, IsSendOk = false, Name = Email, EmailTempId = sendEmailTask.EmailTempId, }; await sendEmailLogBll.AddAsync(log); } if (flag) { TargetEmailBll targetEmailBll = new TargetEmailBll(); int pageIndex = 0; int pageSize = 50; A: pageIndex++; var tup = await targetEmailBll.GetList(pageIndex, pageSize); if (tup.Item1 != null && tup.Item1.Count > 0) { foreach (TargetEmail targetEmail in tup.Item1) { SendEmailLog log1 = new SendEmailLog { SendEmailTaskId = id, Email = targetEmail.Email, IsRead = false, IsSend = false, IsSendOk = false, Name = targetEmail.Name, EmailTempId = sendEmailTask.EmailTempId, }; await sendEmailLogBll.AddAsync(log1); } goto A; } } SendEmailHelper.StartSendEmail(id); }); } return(Json(new { code = 1, msg = "OK" })); }
/// <summary> /// SendErrorMail /// </summary> /// <param name="emailRequest"></param> /// <returns></returns> public bool SendErrorMail(EmailRequestErrorDTO emailRequest) { try { SendEmailHelper objEmail = new SendEmailHelper(); objEmail.HostName = _configuration["HostName"]; objEmail.Port = Int32.Parse(_configuration["Port"]); objEmail.FromEmail = _configuration["FromEmail"]; objEmail.EnableSsl = true; objEmail.DeliveryMethod = SmtpDeliveryMethod.Network; objEmail.Password = _configuration["Password"]; objEmail.UserName = _configuration["UserNameData"]; objEmail.TO = emailRequest.To; if (emailRequest.CC != null) { objEmail.CC = emailRequest.CC; } if (emailRequest.BCC != null) { objEmail.BCC = emailRequest.BCC; } var emaiTemplate = dataContext.EmailTemplates.FirstOrDefault(x => x.EmailTemplateName == emailRequest.EmailTemplateName); if (emaiTemplate != null) { objEmail.Subject = emaiTemplate.Subject; string body = emaiTemplate.EmailBody; if (emailRequest.IPAddress != null) { body = body.Replace("#IPAddress#", emailRequest.IPAddress); } if (emailRequest.LogType != null) { body = body.Replace("#LogType#", emailRequest.LogType); } if (emailRequest.CustomErrorMessage != null) { body = body.Replace("#CustomErrorMessage#", emailRequest.CustomErrorMessage); } if (emailRequest.ModuleName != null) { body = body.Replace("#ModuleName#", emailRequest.ModuleName); } if (emailRequest.TrackTrace != null) { body = body.Replace("#TrackTrace#", emailRequest.TrackTrace); } if (emailRequest.SystemErrorMesage != null) { body = body.Replace("#SystemErrorMesage#", emailRequest.SystemErrorMesage); } if (emailRequest.CreatedAt != null) { string currentDateString = String.Format("{0:MM-dd-yyyy}", emailRequest.CreatedAt); body = body.Replace("#CreatedDate#", currentDateString); } body = body.Replace("#Year#", DateTime.Now.Year.ToString()); objEmail.Body = body; var mail = objEmail.SendEmail(); return(mail); } else { return(false); } } catch { return(false); } }
public void Execute(IJobExecutionContext context) { try { //过了晚上十二点,把前一天未完成的 并且未分配的工单的接收时间设为今日 if (DateTime.Now.Hour == 1) { devJsrmOrderManager.UpdateYesterdayFinsihTime(); OrderMonitorViewModel.Instance().ShowMessage("更新前一晚数据"); } if (DateTime.Now.Hour >= 18 || DateTime.Now.Hour < 8) { OrderMonitorViewModel.Instance().ShowMessage("18点之后的工单,隔天处理"); return; } JobDataMap data = context.JobDetail.JobDataMap; string receive = data.GetString("ReceiveEmail"); if (string.IsNullOrEmpty(receive)) { OrderMonitorViewModel.Instance().ShowMessage("接收人的邮箱为空"); return; } DataTable dataTable = devJsrmOrderManager.GetDispatchingOrderTable(); List <Order> orders = devJsrmOrderManager.ConvertToOrderList(dataTable); #region 更新研发完成时间 //获取已处理工单的完成时间 DataTable dataTableForUpdate = devJsrmOrderManager.GetAllNotFinsihOrderTable(); List <Order> ordersForUpdate = devJsrmOrderManager.ConvertToOrderList(dataTableForUpdate); ordersForUpdate.Where(x => x.FinishTime == DateTime.MinValue).ToList().ForEach(x => { string TrueResponsiblePerson = ""; x.FinishTime = OrderMonitorViewModel.Instance().GetTimePointByGDAsync(x.problemCode, true, out TrueResponsiblePerson); if (x.FinishTime != DateTime.MinValue) { devJsrmOrderManager.UpdateFinsihTime(x.problemCode, x.FinishTime, TrueResponsiblePerson); } }); #endregion DataTable dataTableForEmail = devJsrmOrderManager.GetDispatchingOrderTableForEmail(); int count = orders.Where(x => x.Dispatched == 0).Count(); var isDelay = devJsrmOrderManager.GetIsDelay(7); if (count <= 0 && isDelay.Count == 0) { OrderMonitorViewModel.Instance().ShowMessage("没有新增的工单"); return; } //if (!(count >= 2 || DateTime.Now.Hour > 16)) //{ // OrderMonitorViewModel.Instance().ShowMessage($"新增工单{count}单,暂不发送邮件"); // return; //} string content = SendEmailHelper.HtmlBody(dataTableForEmail); //仅在上班时间报这个警 if (isDelay.Count > 0 && DateTime.Now.Hour >= 9 && DateTime.Now.Hour < 18) { string title = isDelay[0] + "等" + isDelay.Count + "个工单即将超时,需优先处理"; SendEmailHelper.SendEmailAsync(receive, title, content, true); OrderMonitorViewModel.Instance().ShowMessage(title); } else if (count > 0) { SendEmailHelper.SendEmailAsync(receive, $"{DateTime.Now.ToString("yyyyMMddHH")}待处理捷服务工单", content, true); OrderMonitorViewModel.Instance().ShowMessage($"新增工单{count}单,已发送邮件"); } orders.Where(x => x.Dispatched == 0).ToList().ForEach(x => { devJsrmOrderManager.UpdateDispatch(x.problemCode); }); } catch (Exception ex) { LogHelper.CommLogger.Error(ex.ToString()); } }
/// <summary> /// -- Build mail body -- /// </summary> /// <param name="itemKey"></param> /// <param name="itemValue"></param> /// <param name="bcc"></param> /// <param name="cc"></param> private bool BuildMailBody(string itemKey, string itemValue, string bcc = null, string cc = null) { string currentMonth = DateTime.Now.ToString("MMMM").ToUpper(); string sujet = $"Fihe de paie de {currentMonth}."; try { if (string.IsNullOrEmpty(AdminEmail)) { ErrorMessage = ErrorMessageLabels.CheckAdminEmailMsg; _logger.Error($"==> {ErrorMessage}."); return(false); } else { _logger.Debug($"==> Appel à la méthode de création d'objet mailMessage [MailConsolidateHelper.BuildMailDetail]"); if (string.IsNullOrEmpty(_templateFilePath)) { ErrorMessage = ErrorMessageLabels.PleaseMailBodyMsg; // -- Set Reminding message color -- RemindingMsgForeground = System.Windows.Media.Brushes.Red; return(false); } MailConsolidateHelper.BuildMailDetail(_emailMessage, _templateFilePath, sujet, itemValue, itemKey, bcc, cc, AdminEmail, IsPreviewEmail); _logger.Debug($"==> Appel de la fontion SendMail [SendEmailHelper.SendEmail]"); var sendMailResponse = SendEmailHelper.SendEmail(_emailMessage); if (sendMailResponse == false) { ErrorMessage = ErrorMessageLabels.ErrorDuringSendingMailMsg; _logger.Error($"==> {ErrorMessage}."); BorderThickness = 2; BorderBrush = System.Windows.Media.Brushes.Red; } else { BorderThickness = 1; BorderBrush = System.Windows.Media.Brushes.Transparent; } return(sendMailResponse); } } finally { if (!string.IsNullOrWhiteSpace(ErrorMessage)) { _dialogService.ShowMessage(ErrorMessage, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Yes); } } }
public void Execute(IJobExecutionContext context) { //过了晚上十二点,把前一天未完成的 并且未分配的工单的接收时间设为今日 if (DateTime.Now.Hour == 1) { devJsrmOrderManager.UpdateYesterdayFinsihTime(); OrderMonitorViewModel.Instance().ShowMessage("更新前一晚数据"); } if (DateTime.Now.Hour >= 18) { OrderMonitorViewModel.Instance().ShowMessage("18点之后的工单,隔天处理"); return; } JobDataMap data = context.JobDetail.JobDataMap; string receive = data.GetString("ReceiveEmail"); if (string.IsNullOrEmpty(receive)) { OrderMonitorViewModel.Instance().ShowMessage("接收人的邮箱为空"); return; } DataTable dataTable = devJsrmOrderManager.GetDispatchingOrderTable(); List <Order> orders = devJsrmOrderManager.ConvertToOrderList(dataTable); //获取已处理工单的完成时间 orders.Where(x => x.FinishTime == DateTime.MinValue).ToList().ForEach(x => { string TrueResponsiblePerson = ""; x.FinishTime = OrderMonitorViewModel.Instance().GetTimePointByGDAsync(x.problemCode, true, out TrueResponsiblePerson); if (x.FinishTime != DateTime.MinValue) { devJsrmOrderManager.UpdateFinsihTime(x.problemCode, x.FinishTime, TrueResponsiblePerson); } }); DataTable dataTableForEmail = devJsrmOrderManager.GetDispatchingOrderTableForEmail(); int count = orders.Where(x => x.Dispatched == 0).Count(); if (count <= 0) { OrderMonitorViewModel.Instance().ShowMessage("没有新增的工单"); return; } if (!(count >= 2 || DateTime.Now.Hour > 16)) { OrderMonitorViewModel.Instance().ShowMessage($"新增工单{count}单,暂不发送邮件"); return; } string content = SendEmailHelper.HtmlBody(dataTableForEmail); SendEmailHelper.SendEmailAsync(receive, $"{DateTime.Now.ToString("yyyyMMddHH")}待处理捷服务工单", content, true); OrderMonitorViewModel.Instance().ShowMessage($"新增工单{count}单,已发送邮件"); orders.Where(x => x.Dispatched == 0).ToList().ForEach(x => { devJsrmOrderManager.UpdateDispatch(x.problemCode); }); }
public ApplyForScholarshipController() { _manager = new ApplyForScholarshipManager(); _sendEmailHelper = new SendEmailHelper(); }
public ActionResult SendEmail() { SendEmailHelper.Execute().Wait(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { DataSet ds; if (!this.IsPostBack) { string activationCode = !string.IsNullOrEmpty(Request.QueryString["ActivationCode"]) ? Request.QueryString["ActivationCode"] : Guid.Empty.ToString(); ds = new Musika.Repository.SPRepository.SpRepository().UpdateUserActivationStatus(activationCode); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; ltMessage.Text = "Activation successful."; #region "Mail for Activation" #region "Mail To Admin" // Mail To admin string html = string.Empty; html = "<p>Hi Administrator," + "</p>"; html += "<p>A new user is added in Musika application." + "</p>"; html += "<p><br>The details of the user is as follows :" + "<p>"; html += "<p><br>User Name : " + dr["UserName"].ToString() + "<p>"; html += "<p><br><br><strong>Thanks,<br><br>The " + WebConfigurationManager.AppSettings["AppName"] + " Team</strong></p>"; SendEmailHelper.SendMail(System.Configuration.ConfigurationManager.AppSettings["ADMIN_EMAIL"].ToString(), "New Musika User Registration", html, ""); #endregion //#region "Mail To Event Organizer" //// Mail To admin string AdminEmail = System.Configuration.ConfigurationManager.AppSettings["ADMIN_EMAIL"].ToString(); html = string.Empty; html = "<p>Hi " + dr["Email"].ToString() + "," + "</p>"; html += "<p>Thanks for using " + WebConfigurationManager.AppSettings["AppName"] + "! </p>"; html += "<p>Thanks for Registering on Musika Application." + "</p>"; html += "<p><br>As per registration your details are as follows :" + "<p>"; html += "<p><br>User Name : " + dr["UserName"].ToString() + "<p>"; html += "<p><br><br><strong>Thanks,<br><br>The " + WebConfigurationManager.AppSettings["AppName"] + " Team</strong></p>"; //#region "Send Mail Implementation" SendEmailHelper.SendMail(dr["Email"].ToString(), "New Musika User Registration", html, ""); //#endregion #endregion } else { ltMessage.Text = "Invalid Activation code."; } #region "Unused Code" //string constr = @"Data Source=23.111.138.246,2728; Initial Catalog=Musika;App=Musika; User ID=sa; Password=sdsol99!;"; //string activationCode = !string.IsNullOrEmpty(Request.QueryString["ActivationCode"]) ? Request.QueryString["ActivationCode"] : Guid.Empty.ToString(); //using (SqlConnection con = new SqlConnection(constr)) //{ // using (SqlCommand cmd = new SqlCommand("DELETE FROM UserActivation WHERE ActivationCode = @ActivationCode")) // { // using (SqlDataAdapter sda = new SqlDataAdapter()) // { // cmd.CommandType = CommandType.Text; // cmd.Parameters.AddWithValue("@ActivationCode", activationCode); // cmd.Connection = con; // con.Open(); // int rowsAffected = cmd.ExecuteNonQuery(); // con.Close(); // } // } //} #endregion } }