Commit e578045e by lcx

文件上传添加文件格式判断

parent 37780167
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
...@@ -85,6 +86,9 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -85,6 +86,9 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (file == null) if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var again = againAllotService.GetAgainallot(againid); var again = againAllotService.GetAgainallot(againid);
if (again == null) if (again == null)
return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在"); return new ApiResponse(ResponseType.Fail, "二次绩效记录不存在");
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
...@@ -407,6 +408,9 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -407,6 +408,9 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (file == null) if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var allot = allotService.GetAllot(allotid); var allot = allotService.GetAllot(allotid);
if (allot == null) if (allot == null)
return new ApiResponse(ResponseType.Fail, "allotid不存在"); return new ApiResponse(ResponseType.Fail, "allotid不存在");
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
using Performance.DtoModels; using Performance.DtoModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using Performance.Services.ExtractExcelService;
namespace Performance.Api.Controllers namespace Performance.Api.Controllers
{ {
...@@ -47,6 +48,9 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -47,6 +48,9 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (file == null) if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var name = $"History_{FileHelper.GetFileNameNoExtension(file.FileName)}{DateTime.Now:yyyyMMddHHmmssfff}"; var name = $"History_{FileHelper.GetFileNameNoExtension(file.FileName)}{DateTime.Now:yyyyMMddHHmmssfff}";
var ext = FileHelper.GetExtension(file.FileName); var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(evn.ContentRootPath, "Files", hospitalid.ToString()); var dpath = Path.Combine(evn.ContentRootPath, "Files", hospitalid.ToString());
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
...@@ -103,6 +104,9 @@ public ApiResponse Import(int hospitalId, [FromForm] IFormCollection form) ...@@ -103,6 +104,9 @@ public ApiResponse Import(int hospitalId, [FromForm] IFormCollection form)
if (file == null) if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
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, "Files", $"{hospitalId}", $"ImportDataFiles"); var dpath = Path.Combine(env.ContentRootPath, "Files", $"{hospitalId}", $"ImportDataFiles");
......
...@@ -129,6 +129,9 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -129,6 +129,9 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (file == null) if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var hospital = hospitalService.GetHopital(hospitalid); var hospital = hospitalService.GetHopital(hospitalid);
if (hospital == null) if (hospital == null)
return new ApiResponse(ResponseType.Fail, "hospitalid不存在"); return new ApiResponse(ResponseType.Fail, "hospitalid不存在");
......
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