Commit 331719ba by 李承祥

发送邮件

parent e6d1e7cf
......@@ -435,6 +435,7 @@ public void AddItems(int moduleId)
ItemName = t.Value.ToString(),
FactorValue1 = 0m,
FactorValue2 = 0m,
FactorValue3 = 0m,
ModuleId = module.Id,
ExtractId = module.ExtractId,
ReadOnly = 1
......
......@@ -29,6 +29,7 @@ public class NewExtractService : IAutoInjection
#region
private readonly ILogger<ExtractService> logger;
private readonly IHostingEnvironment environment;
private readonly IEmailService emailService;
private readonly PerSheetService perSheetService;
private readonly PerforHospitalRepository perforHospitalRepository;
private readonly PerforHospitalconfigRepository perforHospitalconfigRepository;
......@@ -48,6 +49,7 @@ public class NewExtractService : IAutoInjection
public NewExtractService(ILogger<ExtractService> logger,
IHostingEnvironment environment,
IEmailService emailService,
PerSheetService perSheetService,
PerforHospitalRepository perforHospitalRepository,
PerforHospitalconfigRepository perforHospitalconfigRepository,
......@@ -64,6 +66,7 @@ public class NewExtractService : IAutoInjection
{
this.logger = logger;
this.environment = environment;
this.emailService = emailService;
this.perSheetService = perSheetService;
this.perforHospitalRepository = perforHospitalRepository;
this.perforHospitalconfigRepository = perforHospitalconfigRepository;
......@@ -176,12 +179,13 @@ public string ExtractData(int allotId, string email, int hospitalId)
{
workbook.Write(file);
}
SendEmail(email, newPath, $"{hospital.HosName}HIS数据提取成功", $"{hospital.HosName}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}成功提取。");
return newPath;
}
catch (Exception ex)
{
LogHelper.Error($"数据写入出现异常{ex.ToString()}", "提取绩效数据", "异常");
SendEmail(email, "", $"{hospital.HosName}HIS数据提取失败", $"{hospital.HosName}提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!");
throw ex;
}
finally
......@@ -811,5 +815,27 @@ public string Judge(int allotId, int hospitalId, int useTemplate)
return result;
}
#endregion
#region 发送邮件
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="path"></param>
/// <param name="subject"></param>
/// <param name="body"></param>
private void SendEmail(string mail, string path, string subject, string body)
{
var message = new EmailMessage
{
To = new List<string> { mail },
DisplayName = "溯直健康",
Subject = subject,
Body = body
};
if (!string.IsNullOrEmpty(path))
message.Attachments = new List<string> { path };
emailService.Send(message);
}
#endregion
}
}
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