| | |
| | | using Swifter.Tools; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Microsoft.CodeAnalysis.Options; |
| | | using System.IO; |
| | | using System.Runtime.Loader; |
| | | |
| | | namespace Tiger.Api.Controllers.Test |
| | | { |
| | |
| | | public async Task<IActionResult> GetAsync(string param) |
| | | { |
| | | //var data = await Biz.Db.Queryable<SYS_PARAM>().Where(q => q.PARAM_CODE == param).FirstAsync(); |
| | | //var data = Biz.SysParam["Blue"]; |
| | | //var data = Biz.SysParam.Groups; |
| | | //var data = Biz.CodeRule["X0001"]; |
| | | //var data = Cache.SysParam["Blue"]; |
| | | //var data = Cache.SysParam.Groups; |
| | | //var data = Cache.CodeRule["X0001"]; |
| | | //取号测试 |
| | | //var data = Biz.Db.Queryable<BAS_CODE_RULE>().Where(q => q.RULE_CODE == "X0001").IncludesAllFirstLayer().First(); |
| | | //var key = string.Join("|", data.Details.Where(q => q.DATA_TYPE == BAS_CODE_DTL.DATA_TYPEs.DbCheck.GetValue()).Select(q => q.GenerateValue)); |
| | |
| | | // try |
| | | // { |
| | | // var dtl = data.Details.First(q => q.RULE_SEQ == 6); |
| | | // var sn = Biz.CodeRule.FetchSerialNo(key, dtl, index.ToString(), false); |
| | | // var sn = Cache.CodeRule.FetchSerialNo(key, dtl, index.ToString(), false); |
| | | // Console.WriteLine($"{index}: {DateTime.Now:HH:mm:ss.fff} > 取号完成[{sn}]"); |
| | | // } |
| | | // catch (Exception ex) |
| | |
| | | // } |
| | | // }); |
| | | //} |
| | | //var data = Biz.CodeRule["X0001"].Generate("PDFG", 5); |
| | | //var data1 = Biz.CodeRule["X0001"].TryGenerate("PDFG", 6); |
| | | //var data = Cache.CodeRule["X0001"].Generate("PDFG", 5); |
| | | //var data1 = Cache.CodeRule["X0001"].TryGenerate("PDFG", 6); |
| | | //条码规则验证 |
| | | //Expression<Func<BAS_CODE_RULE, bool>> predicate = q => true; |
| | | ////predicate = predicate.And(q => q.RULE_CODE == "X0002" || q.RULE_CODE == "X0001"); |
| | | //predicate = predicate.And(q => q.RULE_TYPE == 0); |
| | | ////var data = Biz.CodeRule.Rules.Where(predicate.Compile()); |
| | | //var data = Biz.CodeRule.Verify("AB23#7930000002010", predicate.Compile()); |
| | | ////var data = Cache.CodeRule.Rules.Where(predicate.Compile()); |
| | | //var data = Cache.CodeRule.Verify("AB23#7930000002010", predicate.Compile()); |
| | | return Ok(""); |
| | | } |
| | | |
| | |
| | | [HttpGet] |
| | | public async Task<IActionResult> D1Async(string param) |
| | | { |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=01"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 01 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=02"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 02 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=03"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 03 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=04"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 04 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=05"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 05 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=06"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 06 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=07"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 07 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=08"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 08 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=09"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 09 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=10"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 10 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=11"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 11 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=12"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 12 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=13"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 13 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=14"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 14 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=15"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 15 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=16"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 16 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=17"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 17 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=18"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 18 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=19"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 19 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=20"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 20 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=21"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 21 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=22"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 22 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=23"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 23 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=24"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 24 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=25"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 25 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=26"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 26 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=27"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 27 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=28"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 28 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=29"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 29 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=30"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 30 Finished", ConsoleColor.Blue); }); |
| | | ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - Send Finished", ConsoleColor.Blue); |
| | | //Logger.Scheduler.Info("这是一次成功的测试"); |
| | | //var data = iBiz.Biz.Db.Queryable<BAS_CODE_RULE>() |
| | | // .IncludesAllFirstLayer() |
| | |
| | | public partial class _TestController : ControllerBase |
| | | { |
| | | [HttpGet] |
| | | public async Task<IActionResult> DoSomething(int duration) |
| | | public async Task<IActionResult> DoSomething(int duration, string code) |
| | | { |
| | | Barcode b = new("asdasd"); |
| | | var begin = DateTime.Now; |
| | | while ((DateTime.Now - begin).TotalSeconds <= duration) |
| | | { |
| | | Thread.Sleep(1000); |
| | | var total = (DateTime.Now - begin).TotalSeconds; |
| | | var percent = total / duration; |
| | | ConsoleExt.WriteLine($"Working {begin:mmssfff} ... {(percent > 1 ? 1 : percent):P0} ...", ConsoleColor.Green); |
| | | } |
| | | Logger.Default.Info($"{begin:mmssfff} completed"); |
| | | return Ok($"{begin:mmssfff} completed {b.DateCode}"); |
| | | Work.Do(() => { |
| | | while ((DateTime.Now - begin).TotalSeconds <= duration) |
| | | { |
| | | //Thread.Sleep(1000); |
| | | var total = (DateTime.Now - begin).TotalSeconds; |
| | | var percent = total / duration; |
| | | //ConsoleExt.WriteLine($"Working {begin:mmssfff} ... {(percent > 1 ? 1 : percent):P0} ...", ConsoleColor.Green); |
| | | } |
| | | Logger.Default.Info($"{begin:mmssfff} completed"); |
| | | }); |
| | | return Ok($"{code.IsNullOrEmpty("", code + ": ")}{begin:mmssfff} completed"); |
| | | } |
| | | |
| | | [HttpPost] |
| | |
| | | |
| | | return Ok(result?.ToJson()); |
| | | } |
| | | |
| | | [HttpGet] |
| | | public async Task<IActionResult> RefreashPlugin(string path) |
| | | { |
| | | var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | // 查找指定名称的程序集 |
| | | //var assembly = Array.Find(assemblies, a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | //var ass = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "\\Tiger.Business.MES1.dll"); |
| | | |
| | | |
| | | var mes1 = new AssemblyLoadContext("mes1", true); |
| | | var assembly1 = mes1.LoadFromAssemblyPath(AppDomain.CurrentDomain.BaseDirectory + "\\Tiger.Business1.MES.dll"); |
| | | mes1.Unloading += context => { Console.WriteLine($"当前卸载{context.Name}程序集:" + string.Join(',', context.Assemblies.Select(x => x.FullName))); }; |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | var mes2 = new AssemblyLoadContext("mes2", true); |
| | | var assembly2 = mes2.LoadFromAssemblyPath(AppDomain.CurrentDomain.BaseDirectory + "\\Tiger.Business2.MES.dll"); |
| | | mes2.Unloading += context => { Console.WriteLine($"当前卸载{context.Name}程序集:" + string.Join(',', context.Assemblies.Select(x => x.FullName))); }; |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | mes1.Unload(); |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | mes2.Unload(); |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //var newBuilder = new ContainerBuilder(); |
| | | |
| | | ////AutoFac 配置文件注入 |
| | | //AutoFacContainer.Init(newBuilder); |
| | | //newBuilder.RegisterBuildCallback(scope => |
| | | //{ |
| | | |
| | | // AutoFacContainer.Instance = (IContainer)scope; |
| | | //}); |
| | | //var newContainer = newBuilder.Build(); |
| | | //var trans = AutoFacContainer.Instance.Resolve<ITestNode>().Init("action.ID", "Request.Host.Value", "action.Data?.USER_CODE", "OQC001"); |
| | | //var d = trans.GetDefects(); |
| | | return Ok($""); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |