/// <summary> /// 处理邮件队列任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void work_email(object sender, System.Timers.ElapsedEventArgs e) { lock (this) { int Mail_SendTop = 0; int.TryParse(conf.Mail_SendTop, out Mail_SendTop); string where = "(Type_id_EmailStatus=270 and Count_send < " + Mail_SendTop + ") and Time_Task<=GetDate()"; List <Lebi_Email> models = B_Lebi_Email.GetList(where, "", 100, 1); int Type_id_EmailStatus = 270; foreach (Lebi_Email model in models) { Type_id_EmailStatus = 270; model.Count_send++; Lebi_User user = B_Lebi_User.GetModel(model.User_id); if (user == null) { user = new Lebi_User(); } if (model.TableName == "Supplier" && model.Keyid > 0) { Email.Send(model.Email, model.Title, model.Content, user, "Supplier", model.Keyid, model.id); } else if (model.TableName == "DT" && model.Keyid > 0) { Email.Send(model.Email, model.Title, model.Content, user, "DT", model.Keyid, model.id); } else { Email.Send(model.Email, model.Title, model.Content, user, model.id); } model.Type_id_EmailStatus = Type_id_EmailStatus; B_Lebi_Email.Update(model); } } }
/// <summary> /// 添加邮件发送记录 /// </summary> public static void SMSJob(string Emailto, string Content, bool sendstatus, Lebi_User user, BaseConfig conf) { Lebi_Email log = new Lebi_Email(); int Type_id_EmailStatus = 270; if (sendstatus) { Type_id_EmailStatus = 271; } else { int Mail_SendTop = 0; int.TryParse(conf.Mail_SendTop, out Mail_SendTop); if (Mail_SendTop < 1) { Type_id_EmailStatus = 272; } } log.Content = Content; log.Count_send = 1; log.Email = Emailto; log.Type_id_EmailStatus = Type_id_EmailStatus; log.User_id = user.id; log.User_Name = user.UserName; B_Lebi_Email.Add(log); }
/// <summary> /// 处理邮件队列任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void work_email(object sender, System.Timers.ElapsedEventArgs e) { lock (this) { string where = "Type_id_EmailStatus=270 and Time_Task<=GetDate()"; List <Lebi_Email> models = B_Lebi_Email.GetList(where, "", 100, 1); bool sendstatus = true; int Type_id_EmailStatus = 270; foreach (Lebi_Email model in models) { Type_id_EmailStatus = 270; model.Count_send++; if (model.TableName == "Supplier" && model.Keyid > 0) { sendstatus = Email.Send(model.Email, model.Title, model.Content, "Supplier", model.Keyid); } else if (model.TableName == "DT" && model.Keyid > 0) { sendstatus = Email.Send(model.Email, model.Title, model.Content, "DT", model.Keyid); } else { sendstatus = Email.Send(model.Email, model.Title, model.Content); } if (sendstatus) { Type_id_EmailStatus = 271; } else { int Mail_SendTop = 0; int.TryParse(conf.Mail_SendTop, out Mail_SendTop); if (Mail_SendTop <= model.Count_send) { Type_id_EmailStatus = 272; } } model.Type_id_EmailStatus = Type_id_EmailStatus; B_Lebi_Email.Update(model); } } }