|
|
@ -16,29 +16,29 @@ namespace SCP.Common |
|
|
|
{ |
|
|
|
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<string>(_buffer.ToString()).ToList(); |
|
|
|
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<string>(_buffer.ToString()).ToList(); |
|
|
|
|
|
|
|
if (_userList != null && _userList.Count > 0) |
|
|
|
if (_userList != null && _userList.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var itm in _userList) |
|
|
|
{ |
|
|
|
foreach (var itm in _userList) |
|
|
|
{ |
|
|
|
|
|
|
|
if (itm.Contains('@')) |
|
|
|
{ |
|
|
@ -54,26 +54,26 @@ namespace SCP.Common |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
string mails = ""; |
|
|
|
mails += itm + ","; |
|
|
|
if (mails != "") |
|
|
|
{ |
|
|
|
mails = mails.Substring(0, mails.Length - 1); |
|
|
|
} |
|
|
|
|
|
|
|
string mailbody = ""; |
|
|
|
mailbody += "尊敬的供应商<br>"; |
|
|
|
mailbody += "你好!<br><br>"; |
|
|
|
mailbody += "<b>" + p_Content + "</b> ," + ConfigurationManager.AppSettings["ResetPassWord"] + "<br>"; |
|
|
|
mailbody += "<br><br><br><br>日期:" + 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 += "尊敬的供应商<br>"; |
|
|
|
mailbody += "你好!<br><br>"; |
|
|
|
mailbody += "<b>" + p_Content + "</b> ," + ConfigurationManager.AppSettings["ResetPassWord"] + "<br>"; |
|
|
|
mailbody += "<br><br><br><br>日期:" + 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 |
|
|
|
/// <param name="p_VendId">供应商编码</param>
|
|
|
|
/// <param name="p_Content">邮件内容</param>
|
|
|
|
/// <param name="p_title">邮件头</param>
|
|
|
|
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<string>(_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,7 +111,7 @@ namespace SCP.Common |
|
|
|
string mailbody = ""; |
|
|
|
mailbody += "尊敬的供应商<br>"; |
|
|
|
mailbody += "你好!<br><br>"; |
|
|
|
mailbody += "<b>" + p_Content + "</b> ,请到供应商协同网站"+ ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看!<br>"; |
|
|
|
mailbody += "<b>" + p_Content + "</b> ,请到供应商协同网站" + ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看!<br>"; |
|
|
|
mailbody += "<br><br><br><br>日期:" + DateTime.Now; |
|
|
|
MyWebSmtpMail webmail = new MyWebSmtpMail(); |
|
|
|
webmail.Send(mails, mailbody, 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+ "<br>"; |
|
|
|
mailbody += "尊敬的" + p_tl + "<br>"; |
|
|
|
mailbody += "你好!<br><br>"; |
|
|
|
mailbody += "<b>" + p_Content + "</b> ,请到供应商协同网站" + ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看!<br>"; |
|
|
|
mailbody += "<br><br><br><br>日期:" + DateTime.Now; |
|
|
@ -303,6 +303,7 @@ namespace SCP.Common |
|
|
|
try |
|
|
|
{ |
|
|
|
List<String> result = new List<String>(); |
|
|
|
List<String> _userList = new List<String>(); |
|
|
|
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<string>(_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<string>(_buffer.ToString()).ToList(); |
|
|
|
} |
|
|
|
var toMail = result; |
|
|
|
string mailbody = ""; |
|
|
|
mailbody += "尊敬的供应商<br>"; |
|
|
|
mailbody += "你好!<br><br>"; |
|
|
|
mailbody += "<b>" + p_Content + "</b> ," + ConfigurationManager.AppSettings["ResetPassWord"] + "<br>"; |
|
|
|
mailbody += "<br><br><br><br>日期:" + DateTime.Now; |
|
|
|
List<EmailAddress> toList = new List<EmailAddress>(); |
|
|
|
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) |
|
|
|