|
@ -182,37 +182,44 @@ namespace CK.SCP.UniApi.Controller |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public static void SendOrderMail() |
|
|
public static void SendOrderMail() |
|
|
{ |
|
|
{ |
|
|
AppBoxContext DB = EntitiesFactory.CreateAppBoxInstance(); |
|
|
|
|
|
ScpEntities SDB = EntitiesFactory.CreateScpInstance(); |
|
|
ScpEntities SDB = EntitiesFactory.CreateScpInstance(); |
|
|
var emailList = SDB.TS_Email.Where(q => q.EmailSendState == 0).ToList(); |
|
|
var emailList = SDB.TS_Email.Where(q => q.EmailSendState == 0).ToList(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
foreach (var item in emailList) |
|
|
foreach (var item in emailList) |
|
|
{ |
|
|
{ |
|
|
MailManager.SendMailOrders(item.EmailAddress, item.EmailString, "材料订单提醒"); |
|
|
try |
|
|
Console.WriteLine($"发送邮件:供应商为{ item.EmailToUser}"); |
|
|
{ |
|
|
|
|
|
MailManager.SendMailOrders(item.EmailAddress, item.EmailString, "材料订单提醒"); |
|
|
|
|
|
Console.WriteLine($"发送邮件:供应商为{ item.EmailToUser}"); |
|
|
|
|
|
item.EmailSendState = 1; |
|
|
|
|
|
item.UpdateTime = DateTime.Now.ToString(); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
item.EmailSendState = 2; |
|
|
|
|
|
item.EmailSendFailReason = ex.Message; |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
emailList.ForEach(q => |
|
|
|
|
|
{ |
|
|
|
|
|
q.EmailSendState = 1; |
|
|
|
|
|
}); |
|
|
|
|
|
SDB.TS_Email.AddOrUpdate(q => q.UID, emailList.ToArray()); |
|
|
SDB.TS_Email.AddOrUpdate(q => q.UID, emailList.ToArray()); |
|
|
SDB.SaveChanges(); |
|
|
SDB.SaveChanges(); |
|
|
} |
|
|
} |
|
|
catch(Exception ex) |
|
|
catch(Exception ex) |
|
|
{ |
|
|
{ |
|
|
emailList.ForEach(q => |
|
|
//emailList.ForEach(q =>
|
|
|
{ |
|
|
//{
|
|
|
q.EmailSendState = 2; |
|
|
// q.EmailSendState = 2;
|
|
|
q.EmailSendFailReason = ex.Message; |
|
|
// q.EmailSendFailReason = ex.Message;
|
|
|
}); |
|
|
//});
|
|
|
Console.WriteLine(ex.Message); |
|
|
Console.WriteLine(ex.Message); |
|
|
if (ex.InnerException != null) |
|
|
if (ex.InnerException != null) |
|
|
{ |
|
|
{ |
|
|
Console.WriteLine(ex.InnerException.Message); |
|
|
Console.WriteLine(ex.InnerException.Message); |
|
|
} |
|
|
} |
|
|
SDB.TS_Email.AddOrUpdate(q => q.UID, emailList.ToArray()); |
|
|
//SDB.TS_Email.AddOrUpdate(q => q.UID, emailList.ToArray());
|
|
|
SDB.SaveChanges(); |
|
|
//SDB.SaveChanges();
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|