From 7578387986f65c61342fb26674ebe8223d1d78e6 Mon Sep 17 00:00:00 2001 From: qian Date: Mon, 4 Mar 2024 09:17:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=B2=E5=8E=8B=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/SCP_ASK_CONTROLLER.cs | 13 ++- SCP/Common/MailHelper.cs | 117 ++++++++-------------- SCP/Views/PlanData/SCP_ASK_DETAIL.aspx | 2 +- SCP/Views/PlanData/SCP_ASK_DETAIL.aspx.cs | 3 +- 4 files changed, 58 insertions(+), 77 deletions(-) diff --git a/Controller/SCP_ASK_CONTROLLER.cs b/Controller/SCP_ASK_CONTROLLER.cs index 5438978..3c8e674 100644 --- a/Controller/SCP_ASK_CONTROLLER.cs +++ b/Controller/SCP_ASK_CONTROLLER.cs @@ -2650,6 +2650,7 @@ namespace CK.SCP.Controller { using (ScpEntities db = EntitiesFactory.CreateScpInstance()) { + switch (p_state) { case AskState.Close: @@ -2781,7 +2782,17 @@ namespace CK.SCP.Controller } break; case AskState.Release: - var _ls4 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); + List _ls4 = new List(); + foreach (var item in p_list) + { + TB_ASK ask = db.TB_ASK.FirstOrDefault(q => q.AskBillNum == item); + if (ask != null) + { + _ls4.Add(ask); + } + + } + //var _ls4 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); foreach (var mail in _ls4) { TB_SUPPLIER_MAIL mall = new TB_SUPPLIER_MAIL(); diff --git a/SCP/Common/MailHelper.cs b/SCP/Common/MailHelper.cs index c10e817..9468f51 100644 --- a/SCP/Common/MailHelper.cs +++ b/SCP/Common/MailHelper.cs @@ -14,31 +14,31 @@ using MailKit.Security; namespace SCP.Common { - public class MailManager + public class MailManager { - public static void SendMail(string p_VendId, string p_Content, string p_title,string p_site) + public static void SendMail(string p_VendId, string p_Content, string p_title, string p_site) { try { using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) { - - StringBuilder _buffer = new StringBuilder(); - _buffer.Append("SELECT b.Email "); - _buffer.Append(" FROM VenderUsers AS a INNER JOIN "); - _buffer.Append(" Users AS b ON a.UserId = b.ID INNER JOIN "); - _buffer.Append(" FactoryUsers AS c ON a.UserId = c.UserID INNER JOIN "); - _buffer.Append(" TA_FACTORY AS d ON c.FACTORY_ID = d.ID INNER JOIN "); - _buffer.Append(" Users AS f ON c.UserID = f.ID INNER JOIN "); - _buffer.Append(" RoleUsers AS g ON a.UserId = g.UserID INNER JOIN "); - _buffer.Append(" Roles AS h ON g.RoleID = h.ID "); - _buffer.AppendFormat(" WHERE(h.Name = '供应商' and a.VenderId='{0}' and d.FactoryId='{1}' ) ", p_VendId, p_site); - var _userList = db.Database.SqlQuery(_buffer.ToString()).ToList(); - - if (_userList != null && _userList.Count > 0) + + StringBuilder _buffer = new StringBuilder(); + _buffer.Append("SELECT b.Email "); + _buffer.Append(" FROM VenderUsers AS a INNER JOIN "); + _buffer.Append(" Users AS b ON a.UserId = b.ID INNER JOIN "); + _buffer.Append(" FactoryUsers AS c ON a.UserId = c.UserID INNER JOIN "); + _buffer.Append(" TA_FACTORY AS d ON c.FACTORY_ID = d.ID INNER JOIN "); + _buffer.Append(" Users AS f ON c.UserID = f.ID INNER JOIN "); + _buffer.Append(" RoleUsers AS g ON a.UserId = g.UserID INNER JOIN "); + _buffer.Append(" Roles AS h ON g.RoleID = h.ID "); + _buffer.AppendFormat(" WHERE(h.Name = '供应商' and a.VenderId='{0}' and d.FactoryId='{1}' ) ", p_VendId, p_site); + var _userList = db.Database.SqlQuery(_buffer.ToString()).ToList(); + + if (_userList != null && _userList.Count > 0) + { + foreach (var itm in _userList) { - foreach (var itm in _userList) - { if (itm.Contains('@')) { @@ -53,27 +53,27 @@ namespace SCP.Common } } } - - string mails = ""; - mails += itm + ","; - if (mails != "") - { - mails = mails.Substring(0, mails.Length - 1); - } - string mailbody = ""; - mailbody += "尊敬的供应商
"; - mailbody += "你好!

"; - mailbody += "" + p_Content + " ," + ConfigurationManager.AppSettings["ResetPassWord"] + "
"; - mailbody += "



日期:" + DateTime.Now; - MyWebSmtpMail webmail = new MyWebSmtpMail(); - webmail.Send(mails, mailbody, p_title); + string mails = ""; + mails += itm + ","; + if (mails != "") + { + mails = mails.Substring(0, mails.Length - 1); } + + string mailbody = ""; + mailbody += "尊敬的供应商
"; + mailbody += "你好!

"; + mailbody += "" + p_Content + " ," + ConfigurationManager.AppSettings["ResetPassWord"] + "
"; + mailbody += "



日期:" + DateTime.Now; + MyWebSmtpMail webmail = new MyWebSmtpMail(); + webmail.Send(mails, mailbody, p_title); } } } - - catch(Exception e) + } + + catch (Exception e) { LogHelper.Writlog(LogHelper.LogType.Error, typeof(MailManager), "MailManager", e.Message); } @@ -85,7 +85,7 @@ namespace SCP.Common /// 供应商编码 /// 邮件内容 /// 邮件头 - public static void SendMail(string p_VendId,string p_Content,string p_title) + public static void SendMail(string p_VendId, string p_Content, string p_title) { using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) { @@ -98,7 +98,7 @@ namespace SCP.Common _buffer.AppendFormat(" WHERE(h.Name = '供应商' and a.VenderId='{0}' ) ", p_VendId); var _userList = db.Database.SqlQuery(_buffer.ToString()).ToList(); //var _vender = ScpCache.VenderList.Where(itm => itm.VendId == p_VendId).FirstOrDefault(); - if (_userList != null && _userList.Count>0) + if (_userList != null && _userList.Count > 0) { foreach (var itm in _userList) { @@ -111,13 +111,13 @@ namespace SCP.Common string mailbody = ""; mailbody += "尊敬的供应商
"; mailbody += "你好!

"; - mailbody += "" + p_Content + " ,请到供应商协同网站"+ ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看!
"; + mailbody += "" + p_Content + " ,请到供应商协同网站" + ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看!
"; mailbody += "



日期:" + DateTime.Now; MyWebSmtpMail webmail = new MyWebSmtpMail(); webmail.Send(mails, mailbody, p_title); } } - } + } } public static void SendMails(string p_VendId, string p_Content, string p_title) @@ -270,7 +270,7 @@ namespace SCP.Common } } - public static void SendCompanyMail(string p_tl,string p_User, string p_Content, string p_title) + public static void SendCompanyMail(string p_tl, string p_User, string p_Content, string p_title) { using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) { @@ -286,7 +286,7 @@ namespace SCP.Common mails = mails.Substring(0, mails.Length - 1); } string mailbody = ""; - mailbody += "尊敬的"+ p_tl+ "
"; + mailbody += "尊敬的" + p_tl + "
"; mailbody += "你好!

"; mailbody += "" + p_Content + " ,请到供应商协同网站" + ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看!
"; mailbody += "



日期:" + DateTime.Now; @@ -303,6 +303,7 @@ namespace SCP.Common try { List result = new List(); + List _userList = new List(); using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) { StringBuilder _buffer = new StringBuilder(); @@ -315,46 +316,15 @@ namespace SCP.Common _buffer.Append(" RoleUsers AS g ON a.UserId = g.UserID INNER JOIN "); _buffer.Append(" Roles AS h ON g.RoleID = h.ID "); _buffer.AppendFormat(" WHERE(h.Name = '供应商' and a.VenderId='{0}' and d.FactoryId='{1}' ) ", p_VendId, p_site); - var _userList = db.Database.SqlQuery(_buffer.ToString()).ToList(); - - if (_userList != null && _userList.Count > 0) - { - foreach (var itm in _userList) - { - - if (itm.Contains('@')) - { - using (ScpEntities dbb = EntitiesFactory.CreateScpInstance()) - { - string[] arr = itm.Split('@'); - string vendid = arr[0]; - var vend = dbb.TA_VENDER.FirstOrDefault(p => p.VendId == vendid); - if (vend != null) - { - break; - } - } - } - - string mails = ""; - mails += itm + ","; - if (mails != "") - { - mails = mails.Substring(0, mails.Length - 1); - - result.Add(mails); - } - } - } + _userList = db.Database.SqlQuery(_buffer.ToString()).ToList(); } - var toMail = result; string mailbody = ""; mailbody += "尊敬的供应商
"; mailbody += "你好!

"; mailbody += "" + p_Content + " ," + ConfigurationManager.AppSettings["ResetPassWord"] + "
"; mailbody += "



日期:" + DateTime.Now; List toList = new List(); - foreach (var em1 in toMail) + foreach (var em1 in _userList) { EmailAddress add = new EmailAddress(em1, em1); toList.Add(add); @@ -368,7 +338,6 @@ namespace SCP.Common "BCC" ); smtpMailSender.Send(); - LogHelper.Writlog(LogHelper.LogType.Debug, typeof(MailManager), "ASKSendMail", "发送成功"); } catch (Exception e) diff --git a/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx b/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx index bf8e6cb..4b562b1 100644 --- a/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx +++ b/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx @@ -1,4 +1,4 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SCP_ASK_DETAIL.aspx.cs" Inherits="SCP.PlanData.SCP_ASK_DETAIL" %> +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SCP_ASK_DETAIL.aspx.cs" Inherits="SCP.PlanData.SCP_ASK_DETAIL" %> diff --git a/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx.cs b/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx.cs index 7e94f05..174b687 100644 --- a/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx.cs +++ b/SCP/Views/PlanData/SCP_ASK_DETAIL.aspx.cs @@ -264,7 +264,8 @@ namespace SCP.PlanData { if (CurrentUser.FactoryList != null && CurrentUser.FactoryList.Count > 0) { - SCP.Common.MailManager.ASKSendMail(_ask.VendId, string.Format("发布了新的要货看板编号{0}", _ask.AskBillNum), string.Format("新的要货单信息{0}", _ask.AskBillNum), CurrentUser.FactoryList.FirstOrDefault()); + + Common.MailManager.ASKSendMail(_ask.VendId, string.Format("发布了新的要货看板编号{0}", _ask.AskBillNum), string.Format("新的要货单信息{0}", _ask.AskBillNum), CurrentUser.FactoryList.FirstOrDefault()); //SCP.Common.MailManager.GetPoMailList(); }