3 changed files with 188 additions and 0 deletions
-
5src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
-
92src/Shentun.Peis.HttpApi.Host/Schedulers/ImportElectrocardiogramResultInterfaceWorker.cs
-
91src/Shentun.Peis.HttpApi.Host/Schedulers/SyncPatientRegisterReportInterfaceWorker.cs
@ -0,0 +1,92 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Logging; |
|||
using Shentun.Peis.ThirdInterfaces; |
|||
using Shentun.Utilities; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.Peis.Schedulers |
|||
{ |
|||
public interface IImportElectrocardiogramResultInterfaceWorker |
|||
{ |
|||
public void DoWork(Guid interfaceId); |
|||
public void DoWork(); |
|||
} |
|||
|
|||
public class ImportElectrocardiogramResultInterfaceWorker : ThirdInterfaceWorkerBase, IImportElectrocardiogramResultInterfaceWorker |
|||
{ |
|||
|
|||
private static long i; |
|||
private static bool _isRunning = false; |
|||
private static readonly object lockObject = new object(); |
|||
public virtual void DoWork(Guid interfaceId) |
|||
{ |
|||
if (_isRunning) return; |
|||
//lock (lockObject)
|
|||
//{
|
|||
_isRunning = true; |
|||
try |
|||
{ |
|||
//Logger.LogInformation("Executed" + GetType().Name + "..!");
|
|||
var appServiceHelper = new AppServiceHelper(); |
|||
//appServiceHelper.Login();
|
|||
var thirdInterfaceDtos = appServiceHelper.CallAppService<object, List<ThirdInterfaceDto>>("api/app/ThirdInterface/GetList", null); |
|||
var thirdInterfaceDto = thirdInterfaceDtos.Where(o => o.Id == interfaceId).FirstOrDefault(); |
|||
if (thirdInterfaceDto == null) |
|||
{ |
|||
_isRunning = false; |
|||
return; |
|||
} |
|||
if (thirdInterfaceDto.IsActive != 'Y') |
|||
{ |
|||
_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(); |
|||
|
|||
var 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[] classConstructorArg = new object[] { thirdInterfaceDto.Id }; |
|||
ReflectionHelper.Invoke(assemblyName, className, classConstructorArg, funName); |
|||
} |
|||
|
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
_isRunning = false; |
|||
Logger.LogError("Executed " + GetType().Name + " Error" + ex.Message); |
|||
} |
|||
_isRunning = false; |
|||
return; |
|||
//}
|
|||
} |
|||
|
|||
public void DoWork() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public override Task DoWorkAsync(CancellationToken cancellationToken = default) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,91 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Logging; |
|||
using Shentun.Peis.ThirdInterfaces; |
|||
using Shentun.Utilities; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.Peis.Schedulers |
|||
{ |
|||
public interface ISyncPatientRegisterReportInterfaceWorker |
|||
{ |
|||
public void DoWork(Guid interfaceId); |
|||
public void DoWork(); |
|||
} |
|||
|
|||
public class SyncPatientRegisterReportInterfaceWorker : ThirdInterfaceWorkerBase, ISyncPatientRegisterReportInterfaceWorker |
|||
{ |
|||
private static long i; |
|||
private static bool _isRunning = false; |
|||
private static readonly object lockObject = new object(); |
|||
public virtual void DoWork(Guid interfaceId) |
|||
{ |
|||
if (_isRunning) return; |
|||
//lock (lockObject)
|
|||
//{
|
|||
_isRunning = true; |
|||
try |
|||
{ |
|||
//Logger.LogInformation("Executed" + GetType().Name + "..!");
|
|||
var appServiceHelper = new AppServiceHelper(); |
|||
//appServiceHelper.Login();
|
|||
var thirdInterfaceDtos = appServiceHelper.CallAppService<object, List<ThirdInterfaceDto>>("api/app/ThirdInterface/GetList", null); |
|||
var thirdInterfaceDto = thirdInterfaceDtos.Where(o => o.Id == interfaceId).FirstOrDefault(); |
|||
if (thirdInterfaceDto == null) |
|||
{ |
|||
_isRunning = false; |
|||
return; |
|||
} |
|||
if (thirdInterfaceDto.IsActive != 'Y') |
|||
{ |
|||
_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(); |
|||
|
|||
var 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[] classConstructorArg = new object[] { thirdInterfaceDto.Id }; |
|||
ReflectionHelper.Invoke(assemblyName, className, classConstructorArg, funName); |
|||
} |
|||
|
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
_isRunning = false; |
|||
Logger.LogError("Executed " + GetType().Name + " Error" + ex.Message); |
|||
} |
|||
_isRunning = false; |
|||
return; |
|||
//}
|
|||
} |
|||
|
|||
public void DoWork() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public override Task DoWorkAsync(CancellationToken cancellationToken = default) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue