移除 Magicodes 导入excel
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-05-24 09:17:30 +08:00
parent 4a01960426
commit e10bca6892
16 changed files with 121 additions and 131 deletions
@@ -5,7 +5,6 @@ using IRaCIS.Application.Contracts;
using IRaCIS.Application.Interfaces;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Domain.Share;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
@@ -14,7 +13,6 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.XSSF.UserModel;
using SkiaSharp;
using System.Collections;
using System.IO;
@@ -15,7 +15,6 @@ using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using SkiaSharp;
namespace IRaCIS.Core.Application.Helper
{
@@ -78,14 +78,6 @@
<PackageReference Include="fo-dicom.Imaging.ImageSharp" Version="5.1.2" />
<PackageReference Include="fo-dicom.Codecs" Version="5.12.0" />
<PackageReference Include="IP2Region.Net" Version="2.0.2" />
<PackageReference Include="Magicodes.IE.Core" Version="2.7.4.5" />
<PackageReference Include="Magicodes.IE.Csv" Version="2.7.4.5">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Magicodes.IE.Excel" Version="2.7.4.5">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Magicodes.IE.Excel.AspNetCore" Version="2.7.4.5" />
<PackageReference Include="MailKit" Version="4.5.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="MimeKit" Version="4.5.0" />
@@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Authorization;
using IRaCIS.Core.Application.Helper;
using EasyCaching.Core;
using IRaCIS.Core.Domain.Share;
using OfficeOpenXml.FormulaParsing.Utilities;
namespace IRaCIS.Core.Application.Service
{
@@ -25,7 +25,6 @@ using Microsoft.AspNetCore.Http;
using System;
using System.Runtime.InteropServices;
using SharpCompress.Common;
using SkiaSharp;
using DocumentFormat.OpenXml.Bibliography;
using System.Linq.Dynamic.Core;
@@ -10,7 +10,6 @@ using MassTransit;
using MathNet.Numerics;
using Medallion.Threading;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml.FormulaParsing.Utilities;
using System;
using System.Collections.Generic;
using System.IO.Compression;
@@ -18,7 +18,6 @@ using IRaCIS.Core.Domain.Share.Management;
using System.Text.Json.Nodes;
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Infrastructure.Extention;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
namespace IRaCIS.Core.Application.Service
{
@@ -15,7 +15,6 @@ using Medallion.Threading;
using EasyCaching.Core;
using IRaCIS.Core.Application.Contracts;
using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO;
using OfficeOpenXml.FormulaParsing.Utilities;
namespace IRaCIS.Application.Services
{
@@ -16,7 +16,6 @@ using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Application.Service.Reading.Interface;
using IRaCIS.Core.Application.Contracts;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
namespace IRaCIS.Core.Application.Service
{
@@ -8,7 +8,6 @@ using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using Medallion.Threading;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml.FormulaParsing.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Domain.Share;
using Magicodes.ExporterAndImporter.Core;
using MiniExcelLibs.Attributes;
using Newtonsoft.Json;
using IRaCIS.Core.Application.Contracts;
@@ -74,28 +73,28 @@ namespace IRaCIS.Application.Contracts
public string State => IsDeleted ? "退出" : "加入";
[ValueMapping(text: "退出", true)]
[ValueMapping(text: "加入", false)]
//[ValueMapping(text: "退出", true)]
//[ValueMapping(text: "加入", false)]
[DictionaryTranslateAttribute("IsUserExitTrial")]
public bool IsDeleted { get; set; }
[ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
//[ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
[ExcelFormat("yyyy-MM-dd hh:mm:ss")]
public DateTime? DeletedTime { get; set; }
[ExporterHeader(Format = "yyyy-mm-DD")]
//[ExporterHeader(Format = "yyyy-mm-DD")]
[ExcelFormat("yyyy-MM-dd")]
public DateTime? RemoveTime { get; set; }
[ExporterHeader(Format = "yyyy-mm-DD")]
//[ExporterHeader(Format = "yyyy-mm-DD")]
[ExcelFormat("yyyy-MM-dd")]
public DateTime? JoinTime { get; set; }
[ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
//[ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
[ExcelFormat("yyyy-MM-dd HH:mm:ss")]
public DateTime CreateTime { get; set; }
@@ -9,7 +9,7 @@ namespace IRaCIS.Application.Interfaces
Task<IResponseOutput> AddOrUpdateVisitStage(VisitPlanCommand visitPlan);
Task<IResponseOutput> ConfirmTrialVisitPlan(Guid trialId);
Task<IResponseOutput> DeleteVisitStage(Guid id);
Task<IActionResult> DownloadInflunceStudyList(Guid visitPlanInfluenceStatId);
//Task<IActionResult> DownloadInflunceStudyList(Guid visitPlanInfluenceStatId);
Task<List<VisitPlanInfluenceSubjectVisitStatDTO>> GetInfluenceHistoryList(Guid trialId, [FromServices] IRepository<VisitPlanInfluenceStat> _influnceStatRepository);
Task<PageOutput<VisitStageDTO>> GetTrialVisitStageList(VisitPlanQueryDTO param);
Task<IEnumerable<VisitStageSelectDTO>> GetTrialVisitStageSelect(Guid trialId);
@@ -4,9 +4,6 @@ using IRaCIS.Core.Application.Filter;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Application.MediatR.CommandAndQueries;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using IRaCIS.Core.Infrastructure;
using Microsoft.AspNetCore.Authorization;
using IRaCIS.Core.Application.Auth;
@@ -482,21 +479,21 @@ namespace IRaCIS.Application.Services
return list;
}
[HttpGet("{visitPlanInfluenceStatId:guid}")]
public async Task<IActionResult> DownloadInflunceStudyList(Guid visitPlanInfluenceStatId)
{
var list = _influnceRepository.Where(t => t.VisitPlanInfluenceStatId == visitPlanInfluenceStatId)
.ProjectTo<VisitPlanInfluenceSubjectVisitDTO>(_mapper.ConfigurationProvider).ToList();
//[HttpGet("{visitPlanInfluenceStatId:guid}")]
//public async Task<IActionResult> DownloadInflunceStudyList(Guid visitPlanInfluenceStatId)
//{
// var list = _influnceRepository.Where(t => t.VisitPlanInfluenceStatId == visitPlanInfluenceStatId)
// .ProjectTo<VisitPlanInfluenceSubjectVisitDTO>(_mapper.ConfigurationProvider).ToList();
IExporter exporter = new ExcelExporter();
// IExporter exporter = new ExcelExporter();
var result = await exporter.ExportAsByteArray(list);
// var result = await exporter.ExportAsByteArray(list);
//$"检查导出_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx"
return new XlsxFileResult(bytes: result, fileDownloadName: _localizer["VisitPlan_CheckExport", DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")]);
// //$"检查导出_{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx"
// return new XlsxFileResult(bytes: result, fileDownloadName: _localizer["VisitPlan_CheckExport", DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")]);
}
//}
@@ -1,8 +1,4 @@
using IRaCIS.Core.Domain.Share;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core.Filters;
using Magicodes.ExporterAndImporter.Core.Models;
using Magicodes.ExporterAndImporter.Excel;
using MediatR;
using MiniExcelLibs.Attributes;
using System.ComponentModel.DataAnnotations;
@@ -27,33 +23,33 @@ namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
public class ImportResultFilteTest : IImportResultFilter
{
//public class ImportResultFilteTest : IImportResultFilter
//{
public ImportResult<T> Filter<T>(ImportResult<T> importResult) where T : class, new()
{
if (typeof(T).IsAssignableFrom(typeof(CheckViewModel)))
{
var data = (List<CheckViewModel>)importResult.Data;
// public ImportResult<T> Filter<T>(ImportResult<T> importResult) where T : class, new()
// {
// if (typeof(T).IsAssignableFrom(typeof(CheckViewModel)))
// {
// var data = (List<CheckViewModel>)importResult.Data;
var dt = DateTime.Now ;
// var dt = DateTime.Now ;
foreach (var item in data)
{
// foreach (var item in data)
// {
var index= data.IndexOf(item);
if ( DateTime.TryParse(item.StudyDate, out dt) == false)
{
// var index= data.IndexOf(item);
// if ( DateTime.TryParse(item.StudyDate, out dt) == false)
// {
importResult.RowErrors.Add(new DataRowErrorInfo() { RowIndex = index, FieldErrors = new Dictionary<string, string> { { StaticData.International("ConsistencyVerification_Tech") , StaticData.International("ConsistencyVerification_Time") } } });
}
}
}
// importResult.RowErrors.Add(new DataRowErrorInfo() { RowIndex = index, FieldErrors = new Dictionary<string, string> { { StaticData.International("ConsistencyVerification_Tech") , StaticData.International("ConsistencyVerification_Time") } } });
// }
// }
// }
return importResult;
}
}
// return importResult;
// }
//}
public class ParamInfoDto
@@ -69,23 +65,23 @@ namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
}
[ExcelImporter(/*ImportResultFilter = typeof(ImportResultFilteTest),*/ IsLabelingError = true)]
//[ExcelImporter(/*ImportResultFilter = typeof(ImportResultFilteTest),*/ IsLabelingError = true)]
public class CheckViewModel
{
//[Required(ErrorMessage = "中心编号不能为空")]
[ImporterHeader(Name = "Site ID", AutoTrim = true)]
[ExcelColumnIndex("Site ID")]
//[ImporterHeader(Name = "Site ID", AutoTrim = true)]
[ExcelColumnName("Site ID")]
public string SiteCode { get; set; } = string.Empty;
//[Required(ErrorMessage = "受试者筛选号不能为空")]
[ImporterHeader(Name = "Subject ID", AutoTrim = true)]
//[ImporterHeader(Name = "Subject ID", AutoTrim = true)]
[ExcelColumnName("Subject ID")]
public string SubjectCode { get; set; } = string.Empty;
//[Required(ErrorMessage = "访视名称不能为空")]
[ImporterHeader(Name = "Visit Name", AutoTrim = true)]
//[ImporterHeader(Name = "Visit Name", AutoTrim = true)]
[ExcelColumnName("Visit Name")]
public string VisitName { get; set; } = string.Empty;
@@ -94,14 +90,14 @@ namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
//[Required(ErrorMessage = "检查日期不能为空")]
[CanConvertToTime(ErrorMessage = "Does not conform to Study Date format")]
[ImporterHeader(Name = "Study Date", AutoTrim = true)]
//[ImporterHeader(Name = "Study Date", AutoTrim = true)]
[ExcelColumnName("Study Date")]
public string StudyDate { get; set; } = string.Empty;
//[Required(ErrorMessage = "Modality不能为空")]
[ImporterHeader(Name = "Modality", AutoTrim = true)]
//[ImporterHeader(Name = "Modality", AutoTrim = true)]
[ExcelColumnName("Modality")]
public string Modality { get; set; } = string.Empty;
@@ -131,48 +127,48 @@ namespace IRaCIS.Core.Application.MediatR.CommandAndQueries
public class VisitPlanInfluenceSubjectVisitDTO
{
[ExporterHeader(IsIgnore = true)]
//[ExporterHeader(IsIgnore = true)]
public Guid StudyId { get; set; }
[ExporterHeader(IsIgnore = true)]
//[ExporterHeader(IsIgnore = true)]
public Guid TrialId { get; set; }
[ExporterHeader(IsIgnore = true)]
//[ExporterHeader(IsIgnore = true)]
public Guid SubjectVisitId { get; set; }
[ExporterHeader(DisplayName = "中心编号")]
//[ExporterHeader(DisplayName = "中心编号")]
public string TrialSiteCode { get; set; } = string.Empty;
[ExporterHeader(DisplayName = "受试者")]
//[ExporterHeader(DisplayName = "受试者")]
public string SubjectCode { get; set; } = string.Empty;
[ExporterHeader(DisplayName = "访视名称")]
//[ExporterHeader(DisplayName = "访视名称")]
public string VisitName { get; set; } = string.Empty;
[ExporterHeader(DisplayName = "检查时间", Format = "yyyy-mm-dd hh:mm:ss")]
//[ExporterHeader(DisplayName = "检查时间", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime StudyTime { get; set; }
[ExporterHeader(DisplayName = "检查技术")]
//[ExporterHeader(DisplayName = "检查技术")]
public string Modality { get; set; } = string.Empty;
[ExporterHeader(IsIgnore = true)]
//[ExporterHeader(IsIgnore = true)]
public bool IsDicomStudy { get; set; }
[ExporterHeader(DisplayName = "影像类型")]
//[ExporterHeader(DisplayName = "影像类型")]
public string ImageType => IsDicomStudy ? "Dicom" : "非Dicom";
[ExporterHeader(DisplayName = "历史窗口")]
//[ExporterHeader(DisplayName = "历史窗口")]
public string HistoryWindow { get; set; } = string.Empty;
[ExporterHeader(DisplayName = "之前超窗调整后没超窗")]
[ValueMapping(text: "yes", true)]
[ValueMapping(text: "no", false)]
//[ExporterHeader(DisplayName = "之前超窗调整后没超窗")]
//[ValueMapping(text: "yes", true)]
//[ValueMapping(text: "no", false)]
public bool IsOverWindowNowNotOverWindow { get; set; }
[ExporterHeader(DisplayName = "目前窗口")]
//[ExporterHeader(DisplayName = "目前窗口")]
public string NowWindow { get; set; } = string.Empty;
[ExporterHeader(IsIgnore = true)]
//[ExporterHeader(IsIgnore = true)]
public DateTime CreateTime { get; set; }
}