You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.2 KiB
C#

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<ISqlSugarClient>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
_formSetService = _serviceProvider.GetRequiredService<IClientCommonService>();
_commonSetService = _serviceProvider.GetRequiredService<IOpCommonService>();
//_commonService = _serviceProvider.GetRequiredService<ICommonService>();
}
[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<SeaExport>();
Assert.True(true);
}
[Fact]
public void FileRead()
{
//var tenantDb = saasService.GetBizDbScopeById("1750335377144680448");
//var data = _commonSetService.GetSequenceNext<SeaExport>();
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))
{
// <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
byte[] data = System.Text.Encoding.UTF8.GetBytes("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>11232");
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ļ<EFBFBD>
fs.Write(data, 0, data.Length);
}
//var result = new FileStreamResult(stream, "application/octet-stream") { FileDownloadName = "1800846562843299840.txt" };
}
catch (Exception ex)
{
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Console.WriteLine(ex.Message);
throw;
}
Assert.True(true);
}
}