diff --git a/API/Wood.Service/Datas/SupplierEmployeeDtService.cs b/API/Wood.Service/Datas/SupplierEmployeeDtService.cs new file mode 100644 index 0000000..fc4414e --- /dev/null +++ b/API/Wood.Service/Datas/SupplierEmployeeDtService.cs @@ -0,0 +1,64 @@ +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using TaskManager.Entity; +using TaskManager.EntityFramework.Repository; +using TaskManager.EntityFramework; +using Wood.Service.Controllers; +using Magicodes.ExporterAndImporter.Core.Models; + +namespace Wood.Service.Datas +{ + + + public class SupplierEmployeeDtService : NormalBaseController + { + public SupplierEmployeeDtService(JobDbContext context, IServiceProvider builder, IConfiguration configuration, IRepository repository) : base(context, builder, configuration, repository) + { + } + + [HttpPost] + [Route("import")] + public async Task Import(IFormFile file) + { + if (file == null || file.Length == 0) + { + return NotFound(); + } + MemoryStream memStream = new MemoryStream(); + await file.CopyToAsync(memStream); + + var importer = new ExcelImporter(); + ImportResult impResult = await importer.Import(memStream); + if (impResult.HasError) + { + StringBuilder sb = new StringBuilder(); + foreach (var rowErr in impResult.RowErrors) + { + string temp = string.Join(";", rowErr.FieldErrors.Select(itm => $"第{rowErr.RowIndex}行:{itm.Key}-{itm.Value}")); + sb.AppendLine(temp); + } + foreach (var templateErr in impResult.TemplateErrors) + { + string temp = $"列名:{templateErr.RequireColumnName},错误信息:{templateErr.Message}"; + sb.AppendLine(temp); + } + throw new Exception(sb.ToString()); + } + foreach (var item in impResult.Data) //??增加批量插入 + { + await Create(item); + } + return Ok(true); + } + } + +} diff --git a/API/Wood.Service/Datas/SupplierInfoDtService.cs b/API/Wood.Service/Datas/SupplierInfoDtService.cs new file mode 100644 index 0000000..c5a0944 --- /dev/null +++ b/API/Wood.Service/Datas/SupplierInfoDtService.cs @@ -0,0 +1,64 @@ +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using TaskManager.Entity; +using TaskManager.EntityFramework.Repository; +using TaskManager.EntityFramework; +using Wood.Service.Controllers; +using Magicodes.ExporterAndImporter.Core.Models; + +namespace Wood.Service.Datas +{ + + + public class SupplierInfoDtService : NormalBaseController + { + public SupplierInfoDtService(JobDbContext context, IServiceProvider builder, IConfiguration configuration, IRepository repository) : base(context, builder, configuration, repository) + { + } + + [HttpPost] + [Route("import")] + public async Task Import(IFormFile file) + { + if (file == null || file.Length == 0) + { + return NotFound(); + } + MemoryStream memStream = new MemoryStream(); + await file.CopyToAsync(memStream); + + var importer = new ExcelImporter(); + ImportResult impResult = await importer.Import(memStream); + if (impResult.HasError) + { + StringBuilder sb = new StringBuilder(); + foreach (var rowErr in impResult.RowErrors) + { + string temp = string.Join(";", rowErr.FieldErrors.Select(itm => $"第{rowErr.RowIndex}行:{itm.Key}-{itm.Value}")); + sb.AppendLine(temp); + } + foreach (var templateErr in impResult.TemplateErrors) + { + string temp = $"列名:{templateErr.RequireColumnName},错误信息:{templateErr.Message}"; + sb.AppendLine(temp); + } + throw new Exception(sb.ToString()); + } + foreach (var item in impResult.Data) //??增加批量插入 + { + await Create(item); + } + return Ok(true); + } + } + +} diff --git a/API/Wood.Service/Datas/SupplierProAttachmentDataDtService.cs b/API/Wood.Service/Datas/SupplierProAttachmentDataDtService.cs new file mode 100644 index 0000000..76c8604 --- /dev/null +++ b/API/Wood.Service/Datas/SupplierProAttachmentDataDtService.cs @@ -0,0 +1,65 @@ +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using TaskManager.Entity; +using TaskManager.EntityFramework.Repository; +using TaskManager.EntityFramework; +using Wood.Service.Controllers; +using Magicodes.ExporterAndImporter.Core.Models; +using TaskManager.Entity.Entitys; + +namespace Wood.Service.Datas +{ + + + public class SupplierProAttachmentDataDtService : NormalBaseController + { + public SupplierProAttachmentDataDtService(JobDbContext context, IServiceProvider builder, IConfiguration configuration, IRepository repository) : base(context, builder, configuration, repository) + { + } + + [HttpPost] + [Route("import")] + public async Task Import(IFormFile file) + { + if (file == null || file.Length == 0) + { + return NotFound(); + } + MemoryStream memStream = new MemoryStream(); + await file.CopyToAsync(memStream); + + var importer = new ExcelImporter(); + ImportResult impResult = await importer.Import(memStream); + if (impResult.HasError) + { + StringBuilder sb = new StringBuilder(); + foreach (var rowErr in impResult.RowErrors) + { + string temp = string.Join(";", rowErr.FieldErrors.Select(itm => $"第{rowErr.RowIndex}行:{itm.Key}-{itm.Value}")); + sb.AppendLine(temp); + } + foreach (var templateErr in impResult.TemplateErrors) + { + string temp = $"列名:{templateErr.RequireColumnName},错误信息:{templateErr.Message}"; + sb.AppendLine(temp); + } + throw new Exception(sb.ToString()); + } + foreach (var item in impResult.Data) //??增加批量插入 + { + await Create(item); + } + return Ok(true); + } + } + +} diff --git a/API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs b/API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs new file mode 100644 index 0000000..0b93ffd --- /dev/null +++ b/API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs @@ -0,0 +1,65 @@ +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using TaskManager.Entity; +using TaskManager.EntityFramework.Repository; +using TaskManager.EntityFramework; +using Wood.Service.Controllers; +using Magicodes.ExporterAndImporter.Core.Models; +using TaskManager.Entity.Entitys; + +namespace Wood.Service.Datas +{ + + + public class SupplierProProcessEquipmentDtService : NormalBaseController + { + public SupplierProProcessEquipmentDtService(JobDbContext context, IServiceProvider builder, IConfiguration configuration, IRepository repository) : base(context, builder, configuration, repository) + { + } + + [HttpPost] + [Route("import")] + public async Task Import(IFormFile file) + { + if (file == null || file.Length == 0) + { + return NotFound(); + } + MemoryStream memStream = new MemoryStream(); + await file.CopyToAsync(memStream); + + var importer = new ExcelImporter(); + ImportResult impResult = await importer.Import(memStream); + if (impResult.HasError) + { + StringBuilder sb = new StringBuilder(); + foreach (var rowErr in impResult.RowErrors) + { + string temp = string.Join(";", rowErr.FieldErrors.Select(itm => $"第{rowErr.RowIndex}行:{itm.Key}-{itm.Value}")); + sb.AppendLine(temp); + } + foreach (var templateErr in impResult.TemplateErrors) + { + string temp = $"列名:{templateErr.RequireColumnName},错误信息:{templateErr.Message}"; + sb.AppendLine(temp); + } + throw new Exception(sb.ToString()); + } + foreach (var item in impResult.Data) //??增加批量插入 + { + await Create(item); + } + return Ok(true); + } + } + +}