导入代码修改
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MiniExcelLibs;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
@@ -46,6 +49,41 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从上传文件中获取Datatable
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<DataTable> GetDataTableFromUpload(IFormFile file)
|
||||
{
|
||||
DataTable result = new DataTable();
|
||||
var fileFolder = "Upload\\";
|
||||
if (!Directory.Exists(fileFolder))
|
||||
{
|
||||
Directory.CreateDirectory(fileFolder);
|
||||
}
|
||||
|
||||
var fileName = DateTime.Now.ToString("yyyyMMddHHmmss") +
|
||||
Path.GetExtension(file.FileName);
|
||||
var filePath = Path.Combine(fileFolder, fileName);
|
||||
try
|
||||
{
|
||||
using (var stream = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
file.CopyTo(stream);
|
||||
stream.Position = 0;
|
||||
result = stream.QueryAsDataTable(useHeaderRow: false);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
File.Delete(filePath);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加计算错误日志
|
||||
/// </summary>
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using System.Data;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
@@ -45,6 +48,8 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取Service
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using DocumentFormat.OpenXml.Presentation;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
@@ -7,6 +8,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using MiniExcelLibs;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
{
|
||||
@@ -576,7 +578,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
|
||||
var values = new
|
||||
{
|
||||
SubjectID = taskinfo.BlindSubjectCode.IsNotNullOrEmpty()? taskinfo.Subject.Code: taskinfo.BlindSubjectCode,
|
||||
SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty()? taskinfo.Subject.Code: taskinfo.BlindSubjectCode,
|
||||
TaskBlindName = taskinfo.TaskBlindName,
|
||||
};
|
||||
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
|
||||
@@ -595,10 +597,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
public async Task UploadIVUSTemplate()
|
||||
{
|
||||
var request = httpContext.HttpContext!.Request;
|
||||
var File = request.Form.Files[0];
|
||||
var file = request.Form.Files[0];
|
||||
Guid visitTaskId = Guid.Parse(request.Form["VisitTaskId"]);
|
||||
|
||||
|
||||
var dataTable = _generalCalculateService.GetDataTableFromUpload(file);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Data;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
@@ -36,5 +38,12 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// <param name="lesionType"></param>
|
||||
/// <returns></returns>
|
||||
Task LogRecord(ReadingCalculateDto inDto, string lesionName, LesionType lesionType);
|
||||
|
||||
/// <summary>
|
||||
/// 从上传文件中获取Datatable
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataTable> GetDataTableFromUpload(IFormFile file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Data;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
@@ -54,5 +56,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// <returns></returns>
|
||||
Task<object> GetReadingCalculationData(GetReadingCalculationDataInDto inDto);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user