|
|
@ -1,11 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Expressions; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
@ -15,6 +17,8 @@ using Volo.Abp.Validation; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Basedata.Domain; |
|
|
|
using Win_in.Sfs.Basedata.Domain.Shared; |
|
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
|
using Win_in.Sfs.Shared.Application.Contracts.ExportAndImport; |
|
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
|
|
|
|
@ -29,14 +33,17 @@ public class EquipmentAppService |
|
|
|
//private readonly ItemValidator _itemValidator;
|
|
|
|
private readonly IEquipmentManager _manager; |
|
|
|
private new readonly IEquipmentRepository _repository; |
|
|
|
|
|
|
|
private readonly IExportImportService _importService; |
|
|
|
|
|
|
|
public EquipmentAppService( |
|
|
|
IEquipmentRepository repository, |
|
|
|
IDistributedCache<EquipmentDTO> cache, |
|
|
|
IExportImportService importService, |
|
|
|
// ItemValidator itemValidator,
|
|
|
|
IEquipmentManager manager) |
|
|
|
: base(repository, cache) |
|
|
|
{ |
|
|
|
_importService=importService; |
|
|
|
_repository = repository; |
|
|
|
//_itemValidator = itemValidator;
|
|
|
|
_manager = manager; |
|
|
@ -52,7 +59,52 @@ public class EquipmentAppService |
|
|
|
{ |
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
} |
|
|
|
//public override async Task<IActionResult> ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file)
|
|
|
|
//{
|
|
|
|
// List<EquipmentErrorDTO> errors = new List<EquipmentErrorDTO>();
|
|
|
|
// using var ms = new MemoryStream();
|
|
|
|
// await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false);
|
|
|
|
// var inputFileBytes = ms.GetAllBytes();
|
|
|
|
// var dtos=_importService.Import<EquipmentEditInput>(inputFileBytes).ToList();
|
|
|
|
// var list=ObjectMapper.Map<List<EquipmentEditInput>, List<Equipment>>(dtos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// foreach (var itm in list)
|
|
|
|
// {
|
|
|
|
// itm.SetId(GuidGenerator.Create());
|
|
|
|
// itm.Code = string.Format("{0}{1}", "Q", itm.Code);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ////var bytes = result.FileContents;
|
|
|
|
// ////result.FileContents = null;
|
|
|
|
|
|
|
|
// ////HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders = "X-Response";
|
|
|
|
// ////HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response",
|
|
|
|
// //// JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result }));
|
|
|
|
|
|
|
|
// ////Console.WriteLine(@"导入错误信息:" + result.ExceptionMessage);
|
|
|
|
|
|
|
|
// ////var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName };
|
|
|
|
// ////resultAction.errorNum = result.ErrorNum;
|
|
|
|
// ////resultAction.successNum = resultAction.successNum;
|
|
|
|
// //return resultAction;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // return base.ImportAsync(requestInput, file);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService<ICategoryAppService>();
|
|
|
|
//protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService<IItemCategoryAppService>();
|
|
|
|