From 4b21aecaa5e21e209d18b470321a50aab1008ada Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Sun, 12 May 2024 15:05:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PeisHttpApiHostModule.cs | 4 + .../ChargeRequestInterfaceQueryWorker.cs | 86 +------------------ .../ImportLisResultInterfaceWorker.cs | 60 +------------ .../ImportPacsResultInterfaceWorker.cs | 36 ++++++++ .../Schedulers/ThirdInterfaceWorkerBase.cs | 13 +-- 5 files changed, 53 insertions(+), 146 deletions(-) create mode 100644 src/Shentun.Peis.HttpApi.Host/Schedulers/ImportPacsResultInterfaceWorker.cs diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 5f3cea1..f0fa7aa 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -615,6 +615,10 @@ public class PeisHttpApiHostModule : AbpModule { RecurringJob.AddOrUpdate("导入检验结果接口", o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local); } + else if (thirdInterfaceDto.ThirdInterfaceType == "04") + { + RecurringJob.AddOrUpdate("导入Pacs结果接口", o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local); + } } } diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs index 3fb0332..5b088a0 100644 --- a/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ChargeRequestInterfaceQueryWorker.cs @@ -20,19 +20,11 @@ namespace Shentun.Peis.Schedulers public void DoWork(Guid interfaceId); public void DoWork(); } - public class ChargeRequestInterfaceQueryWorker : HangfireBackgroundWorkerBase, IChargeRequestInterfaceQueryWorker + public class ChargeRequestInterfaceQueryWorker : ThirdInterfaceWorkerBase, IChargeRequestInterfaceQueryWorker { - private string isActive = "N"; - private static long i; - private static bool _isRunning = false; - private static readonly object lockObject = new object(); - - public ChargeRequestInterfaceQueryWorker() + public void DoWork() { - //RecurringJobId = nameof(ChargeRequestInterfaceQueryWorker); - //CronExpression = Cron.Daily(); - //获取所有第三方接口 - + throw new NotImplementedException(); } public override Task DoWorkAsync(CancellationToken cancellationToken = default) @@ -41,76 +33,6 @@ namespace Shentun.Peis.Schedulers return Task.CompletedTask; } //[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)] - public void DoWork(Guid interfaceId) - { - if (_isRunning) return; - lock (lockObject) - { - _isRunning = true; - try - { - Logger.LogInformation("Executed ChargeRequestInterfaceQueryWorker..!"); - var appServiceHelper = new AppServiceHelper(); - appServiceHelper.Login(); - var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService("api/app/ThirdInterface/GetList", null); - var thirdInterfaceDto = thirdInterFaceForHostOutDto.Data.Where(o => o.Id == interfaceId).FirstOrDefault(); - if (thirdInterfaceDto == null) - { - _isRunning = false; - return; - } - - var parmValue = thirdInterfaceDto.ParmValue; - if (!string.IsNullOrWhiteSpace(parmValue)) - { - var configurationBuilder = new ConfigurationBuilder() - .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); - var interfaceConfig = configurationBuilder.Build(); - - isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler") - .GetSection("IsActive").Value; - if (isActive != "Y") - { - _isRunning = false; - return; - } - var assemblyName = interfaceConfig.GetSection("Interface").GetSection("AssemblyName").Value; - var className = interfaceConfig.GetSection("Interface").GetSection("ClassName").Value; - var funName = "DoWork"; - //object[] objects = new object[] { chargeRequestPlugInsInput }; - ReflectionHelper.Invoke(assemblyName, className, parmValue, funName); - } - - - } - catch (Exception ex) - { - Logger.LogError("Executed ChargeRequestInterfaceQueryWorker Error" + ex.Message); - } - _isRunning = false; - return; - } - } - - public void DoWork() - { - if (_isRunning) return; - lock (lockObject) - { - _isRunning = true; - try - { - - - } - catch (Exception ex) - { - Logger.LogError("Executed ChargeRequestInterfaceQueryWorker Error" + ex.Message); - } - _isRunning = false; - return; - } - - } + } } diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs index bcf0d97..9f3bd70 100644 --- a/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportLisResultInterfaceWorker.cs @@ -16,65 +16,9 @@ namespace Shentun.Peis.Schedulers public void DoWork(Guid interfaceId); public void DoWork(); } - public class ImportLisResultInterfaceWorker : HangfireBackgroundWorkerBase, IImportLisResultInterfaceWorker + public class ImportLisResultInterfaceWorker : ThirdInterfaceWorkerBase, IImportLisResultInterfaceWorker { - private string isActive = "N"; - private static long i; - private static bool _isRunning = false; - private static readonly object lockObject = new object(); - - //[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)] - public void DoWork(Guid interfaceId) - { - if (_isRunning) return; - lock (lockObject) - { - _isRunning = true; - try - { - Logger.LogInformation("Executed ImportLisResultInterfaceWorker..!"); - var appServiceHelper = new AppServiceHelper(); - appServiceHelper.Login(); - var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService("api/app/ThirdInterface/GetList", null); - var thirdInterfaceDto = thirdInterFaceForHostOutDto.Data.Where(o => o.Id == interfaceId).FirstOrDefault(); - if (thirdInterfaceDto == null) - { - _isRunning = false; - return; - } - - var parmValue = thirdInterfaceDto.ParmValue; - if (!string.IsNullOrWhiteSpace(parmValue)) - { - var configurationBuilder = new ConfigurationBuilder() - .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); - var interfaceConfig = configurationBuilder.Build(); - - isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler") - .GetSection("IsActive").Value; - if (isActive != "Y") - { - _isRunning = false; - return; - } - var assemblyName = interfaceConfig.GetSection("Interface").GetSection("AssemblyName").Value; - var className = interfaceConfig.GetSection("Interface").GetSection("ClassName").Value; - var funName = "DoWork"; - //object[] objects = new object[] { chargeRequestPlugInsInput }; - ReflectionHelper.Invoke(assemblyName, className, parmValue, funName); - } - - - } - catch (Exception ex) - { - Logger.LogError("Executed ImportLisResultInterfaceWorker Error" + ex.Message); - } - _isRunning = false; - return; - } - } - + public void DoWork() { throw new System.NotImplementedException(); diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportPacsResultInterfaceWorker.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportPacsResultInterfaceWorker.cs new file mode 100644 index 0000000..211bff6 --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ImportPacsResultInterfaceWorker.cs @@ -0,0 +1,36 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Shentun.Utilities; +using System; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.BackgroundWorkers.Hangfire; + +namespace Shentun.Peis.Schedulers +{ + public interface IImportPacsResultInterfaceWorker + { + public void DoWork(Guid interfaceId); + public void DoWork(); + } + public class ImportPacsResultInterfaceWorker : ThirdInterfaceWorkerBase, IImportPacsResultInterfaceWorker + { + private string isActive = "N"; + private static long i; + private static bool _isRunning = false; + private static readonly object lockObject = new object(); + + + public void DoWork() + { + throw new NotImplementedException(); + } + + public override Task DoWorkAsync(CancellationToken cancellationToken = default) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs b/src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs index b71ee84..2b9b112 100644 --- a/src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs +++ b/src/Shentun.Peis.HttpApi.Host/Schedulers/ThirdInterfaceWorkerBase.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Shentun.Utilities; +using Spire.Pdf.Exporting.XPS.Schema; using System; using System.IO; using System.Linq; @@ -12,11 +13,11 @@ namespace Shentun.Peis.Schedulers { public class ThirdInterfaceWorkerBase: HangfireBackgroundWorkerBase { - private string isActive = "N"; + private static long i; private static bool _isRunning = false; private static readonly object lockObject = new object(); - public void DoWork(Guid interfaceId) + public virtual void DoWork(Guid interfaceId) { if (_isRunning) return; lock (lockObject) @@ -24,7 +25,7 @@ namespace Shentun.Peis.Schedulers _isRunning = true; try { - Logger.LogInformation("Executed ImportLisResultInterfaceWorker..!"); + Logger.LogInformation("Executed" + GetType().Name + "..!"); var appServiceHelper = new AppServiceHelper(); appServiceHelper.Login(); var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService("api/app/ThirdInterface/GetList", null); @@ -42,7 +43,7 @@ namespace Shentun.Peis.Schedulers .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); var interfaceConfig = configurationBuilder.Build(); - isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler") + var isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler") .GetSection("IsActive").Value; if (isActive != "Y") { @@ -53,14 +54,14 @@ namespace Shentun.Peis.Schedulers var className = interfaceConfig.GetSection("Interface").GetSection("ClassName").Value; var funName = "DoWork"; //object[] objects = new object[] { chargeRequestPlugInsInput }; - ReflectionHelper.InvokeAsync(assemblyName, className, parmValue, funName); + ReflectionHelper.Invoke(assemblyName, className, parmValue, funName); } } catch (Exception ex) { - Logger.LogError("Executed ImportLisResultInterfaceWorker Error" + ex.Message); + Logger.LogError("Executed " + GetType().Name + " Error" + ex.Message); } _isRunning = false; return;