Commit 084b90fd by 李承祥

Merge branch 'develop' of http://192.168.0.110:8880/zry/performance into develop

parents c2ff7db2 0c9df750
...@@ -91,7 +91,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -91,7 +91,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff"); var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName); var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(env.ContentRootPath.Substring(0, env.ContentRootPath.LastIndexOf("\\")), "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}"); var dpath = Path.Combine(env.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}"); var path = Path.Combine(dpath, $"{name}{ext}");
......
...@@ -120,7 +120,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -120,7 +120,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff"); var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName); var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(_evn.ContentRootPath.Substring(0, _evn.ContentRootPath.LastIndexOf("\\")), "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}"); var dpath = Path.Combine(_evn.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}"); var path = Path.Combine(dpath, $"{name}{ext}");
......
...@@ -69,7 +69,7 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -69,7 +69,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff"); var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName); var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(evn.ContentRootPath.Substring(0, evn.ContentRootPath.LastIndexOf("\\")), "Files", $"{hospitalid}", "first"); var dpath = Path.Combine(evn.ContentRootPath, "Files", $"{hospitalid}", "first");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}"); var path = Path.Combine(dpath, $"{name}{ext}");
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Net; using System.Net;
using System.Net.Mail; using System.Net.Mail;
using System.Text; using System.Text;
...@@ -79,9 +80,9 @@ public Task<bool> SendAsync(EmailMessage message) ...@@ -79,9 +80,9 @@ public Task<bool> SendAsync(EmailMessage message)
public bool Send(EmailMessage message) public bool Send(EmailMessage message)
{ {
MailMessage mail = new MailMessage();
try try
{ {
MailMessage mail = new MailMessage();
mail.From = new MailAddress(options.Account, message.DisplayName); mail.From = new MailAddress(options.Account, message.DisplayName);
//多邮箱地址处理 //多邮箱地址处理
message.To.ForEach(t => mail.To.Add(t)); message.To.ForEach(t => mail.To.Add(t));
...@@ -92,7 +93,11 @@ public bool Send(EmailMessage message) ...@@ -92,7 +93,11 @@ public bool Send(EmailMessage message)
mail.IsBodyHtml = true;//设置为HTML格式 mail.IsBodyHtml = true;//设置为HTML格式
mail.Priority = MailPriority.Low;//优先级 mail.Priority = MailPriority.Low;//优先级
//发送附件 指明附件的绝对地址 //发送附件 指明附件的绝对地址
message.Attachments.ForEach(t => mail.Attachments.Add(new Attachment(t))); message.Attachments.ForEach(t =>
{
if (FileHelper.IsExistFile(t))
mail.Attachments.Add(new Attachment(t));
});
SmtpClient client = new SmtpClient(options.SmtpServer, 80); SmtpClient client = new SmtpClient(options.SmtpServer, 80);
client.Timeout = 10000; client.Timeout = 10000;
client.UseDefaultCredentials = true; client.UseDefaultCredentials = true;
...@@ -106,6 +111,11 @@ public bool Send(EmailMessage message) ...@@ -106,6 +111,11 @@ public bool Send(EmailMessage message)
logger.LogError(ex.ToString()); logger.LogError(ex.ToString());
throw ex; throw ex;
} }
finally
{
if (message.Attachments.Any())
mail.Attachments.Dispose();
}
} }
} }
......
...@@ -123,7 +123,7 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital) ...@@ -123,7 +123,7 @@ public void ExtractData(int allotId, string mail, sys_hospital hospital)
} }
} }
LogHelper.Information($"基础数据提取完成,", "提取绩效数据"); LogHelper.Information($"基础数据提取完成,", "提取绩效数据");
var dpath = Path.Combine(environment.ContentRootPath.Substring(0, environment.ContentRootPath.LastIndexOf("\\")), "Files", $"{hospital.ID}", "autoextract"); var dpath = Path.Combine(environment.ContentRootPath, "Files", $"{hospital.ID}", "autoextract");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
string path = Path.Combine(dpath, $"绩效数据{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx"); string path = Path.Combine(dpath, $"绩效数据{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx");
//根据SHEET页信息,列头信息,创建EXCEL文件 //根据SHEET页信息,列头信息,创建EXCEL文件
......
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