using System.IO; using System.Reflection; using DS.Module.Core; using DS.Module.Core.Extensions; using DS.Module.SqlSugar; using DS.WMS.Core.Code.Interface; using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Interface; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using NPOI.HPSF; using SharpCompress.Common; using SqlSugar; using SqlSugar.IOC; using Xunit; namespace Ds.WMS.Test; public class OpTest { private readonly IServiceProvider _serviceProvider; private readonly SqlSugarScope db; private readonly ISaasDbService saasService; private readonly IClientCommonService _formSetService; private readonly IOpCommonService _commonSetService; //private readonly ICommonService _commonService; public OpTest(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; db = (SqlSugarScope)_serviceProvider.GetRequiredService(); saasService = _serviceProvider.GetRequiredService(); _formSetService = _serviceProvider.GetRequiredService(); _commonSetService = _serviceProvider.GetRequiredService(); //_commonService = _serviceProvider.GetRequiredService(); } [Fact] public async void OpTest1() { //var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); var data = await _formSetService.GetFormSetCreateInfoAsync("1750335377144680448"); Assert.True(true); } [Fact] public void OpTest2() { //var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); //var data = _commonSetService.GetSequenceNext(); Assert.True(true); } [Fact] public void FileRead() { //var tenantDb = saasService.GetBizDbScopeById("1750335377144680448"); //var data = _commonSetService.GetSequenceNext(); var path = "D:\\Code\\DS\\ds8-solution\\ds-wms-service\\DS.WMS.MainApi\\wwwroot\\LinkAttach\\1800846562843299840.txt"; //var temp = new FileStream("D:\\Code\\DS\\ds8-solution\\ds-wms-service\\DS.WMS.MainApi\\wwwroot\\LinkAttach\\1800846562843299840.txt", FileMode.Open); try { var temp1 = File.ReadAllBytes(path); var stream = new MemoryStream(temp1); //using (var stream1= System.IO.File.Create(path)) //{ // await file.CopyToAsync(stream); //} using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate)) { // 将字符串转换为字节数组 byte[] data = System.Text.Encoding.UTF8.GetBytes("这里是内容11232"); // 写入数据到文件 fs.Write(data, 0, data.Length); } //var result = new FileStreamResult(stream, "application/octet-stream") { FileDownloadName = "1800846562843299840.txt" }; } catch (Exception ex) { // 记录或处理异常 Console.WriteLine(ex.Message); throw; } Assert.True(true); } }