|
|
@ -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) |
|
|
|