邮件通知文案

parent 5debbd47
...@@ -30,6 +30,7 @@ public class AllotService : IAutoInjection ...@@ -30,6 +30,7 @@ public class AllotService : IAutoInjection
private IEmailService emailService; private IEmailService emailService;
private PerforPeragainallotRepository _againallotRepository; private PerforPeragainallotRepository _againallotRepository;
private PerforLogcheckRepository perforLogcheckRepository; private PerforLogcheckRepository perforLogcheckRepository;
private readonly PerforHospitalRepository perforHospitalRepository;
public AllotService(PerforPerallotRepository allotRepository, public AllotService(PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService, BaiscNormService baiscNormService,
...@@ -42,7 +43,8 @@ public class AllotService : IAutoInjection ...@@ -42,7 +43,8 @@ public class AllotService : IAutoInjection
IHostingEnvironment evn, ILogger<AllotService> logger, IHostingEnvironment evn, ILogger<AllotService> logger,
IEmailService emailService, IEmailService emailService,
PerforPeragainallotRepository againallotRepository, PerforPeragainallotRepository againallotRepository,
PerforLogcheckRepository perforLogcheckRepository) PerforLogcheckRepository perforLogcheckRepository,
PerforHospitalRepository perforHospitalRepository)
{ {
_allotRepository = allotRepository; _allotRepository = allotRepository;
_againallotRepository = againallotRepository; _againallotRepository = againallotRepository;
...@@ -57,6 +59,7 @@ public class AllotService : IAutoInjection ...@@ -57,6 +59,7 @@ public class AllotService : IAutoInjection
this.configService = configService; this.configService = configService;
this.logdbug = logdbug; this.logdbug = logdbug;
this.perforLogcheckRepository = perforLogcheckRepository; this.perforLogcheckRepository = perforLogcheckRepository;
this.perforHospitalRepository = perforHospitalRepository;
} }
#region 基础功能 #region 基础功能
...@@ -185,6 +188,7 @@ public bool Update(per_allot allot) ...@@ -185,6 +188,7 @@ public bool Update(per_allot allot)
/// <param name="user"></param> /// <param name="user"></param>
public void Generate(per_allot allot, UserIdentity user) public void Generate(per_allot allot, UserIdentity user)
{ {
DateTime time = DateTime.Now;
try try
{ {
logdbug.Add(allot.ID, "绩效开始执行", JsonHelper.Serialize(allot)); logdbug.Add(allot.ID, "绩效开始执行", JsonHelper.Serialize(allot));
...@@ -195,7 +199,7 @@ public void Generate(per_allot allot, UserIdentity user) ...@@ -195,7 +199,7 @@ public void Generate(per_allot allot, UserIdentity user)
if (!checkDataService.Check(excel, allot)) if (!checkDataService.Check(excel, allot))
{ {
_allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.CheckFail, EnumHelper.GetDescription(AllotStates.CheckFail)); _allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.CheckFail, EnumHelper.GetDescription(AllotStates.CheckFail));
SendEmail(allot, user.Mail, "数值健康,绩效数据校验失败", "绩效数据校验失败"); SendEmail(allot, user.Mail, 3, time);
logdbug.Add(allot.ID, "绩效数据校验失败", JsonHelper.Serialize(allot)); logdbug.Add(allot.ID, "绩效数据校验失败", JsonHelper.Serialize(allot));
return; return;
} }
...@@ -213,13 +217,13 @@ public void Generate(per_allot allot, UserIdentity user) ...@@ -213,13 +217,13 @@ public void Generate(per_allot allot, UserIdentity user)
_allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed)); _allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
//发送邮件 //发送邮件
SendEmail(allot, user.Mail, "绩效生成成功", "绩效生成成功"); SendEmail(allot, user.Mail, 1, time);
logdbug.Add(allot.ID, "绩效开始执行", "绩效生成成功"); logdbug.Add(allot.ID, "绩效开始执行", "绩效生成成功");
} }
catch (Exception ex) catch (Exception ex)
{ {
_allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateFail, EnumHelper.GetDescription(AllotStates.GenerateFail)); _allotRepository.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateFail, EnumHelper.GetDescription(AllotStates.GenerateFail));
SendEmail(allot, user.Mail, "绩效生成失败", ex.ToString()); SendEmail(allot, user.Mail, 2, time);
logdbug.Add(allot.ID, "绩效开始执行", ex.ToString()); logdbug.Add(allot.ID, "绩效开始执行", ex.ToString());
//throw ex; //throw ex;
} }
...@@ -230,17 +234,34 @@ public void Generate(per_allot allot, UserIdentity user) ...@@ -230,17 +234,34 @@ public void Generate(per_allot allot, UserIdentity user)
/// </summary> /// </summary>
/// <param name="allot"></param> /// <param name="allot"></param>
/// <param name="mail"></param> /// <param name="mail"></param>
/// <param name="subject"></param> /// <param name="type"> 1 成功 2 异常 3 验证失败</param>
/// <param name="body"></param> private void SendEmail(per_allot allot, string mail, int type, DateTime time)
private void SendEmail(per_allot allot, string mail, string subject, string body)
{ {
var message = new EmailMessage var hospital = perforHospitalRepository.GetEntity(t => t.ID == allot.HospitalId);
var message = new EmailMessage();
message.To = new List<string> { mail };
message.DisplayName = "溯直健康";
message.Subject = $"绩效生成任务结束提醒!";
if (type == 1)
{
message.Body = $"<p>尊敬的用户!</p><p>&nbsp;&nbsp;&nbsp;&nbsp;数值健康提醒您,您在{time.ToString("yyyy-MM-dd hh:mm:ss")}发布" +
$"{hospital.HosName}{allot.Year}{allot.Month}月的绩效生成任务<strong><span style=\"color:#E53333;\">“执行成功”</span></strong>," +
$"您可以登录<a href=\"http://jixiao.suvalue.com\" target=\"_blank\">http://jixiao.suvalue.com</a>查看绩效结果。</p>";
}
else if (type == 2)
{ {
To = new List<string> { mail }, message.Body = $"<p>尊敬的用户!</p><p>&nbsp;&nbsp;&nbsp;&nbsp;数值健康提醒您,您在{time.ToString("yyyy-MM-dd hh:mm:ss")}发布" +
DisplayName = "溯直健康", $"{hospital.HosName}{allot.Year}{allot.Month}月的绩效生成任务<strong><span style=\"color:#E53333;\">“执行失败”</span></strong>," +
Subject = subject, $"执行过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!</p>";
Body = body }
}; else if (type == 1)
{
message.Body = $"<p>尊敬的用户!</p><p>&nbsp;&nbsp;&nbsp;&nbsp;数值健康提醒您,您在{time.ToString("yyyy-MM-dd hh:mm:ss")}发布" +
$"{hospital.HosName}{allot.Year}{allot.Month}月的绩效生成任务<strong><span style=\"color:#E53333;\">“校验失败”</span></strong>," +
$"您可以登录<a href=\"http://jixiao.suvalue.com\" target=\"_blank\">http://jixiao.suvalue.com</a>查看详细清空。</p>";
}
emailService.SendAsync(message); emailService.SendAsync(message);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment