|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Hangfire; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Shentun.Utilities; |
|
|
|
using System; |
|
|
|
@ -12,7 +13,7 @@ namespace Shentun.Peis.Schedulers |
|
|
|
{ |
|
|
|
public interface IImportLisResultInterfaceWorker |
|
|
|
{ |
|
|
|
Task DoWork(Guid interfaceId); |
|
|
|
public void DoWork(Guid interfaceId); |
|
|
|
public void DoWork(); |
|
|
|
} |
|
|
|
public class ImportLisResultInterfaceWorker : HangfireBackgroundWorkerBase, IImportLisResultInterfaceWorker |
|
|
|
@ -21,54 +22,57 @@ namespace Shentun.Peis.Schedulers |
|
|
|
private static long i; |
|
|
|
private static bool _isRunning = false; |
|
|
|
private static readonly object lockObject = new object(); |
|
|
|
public async Task DoWork(Guid interfaceId) |
|
|
|
|
|
|
|
[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)] |
|
|
|
public void DoWork(Guid interfaceId) |
|
|
|
{ |
|
|
|
if (_isRunning) return; |
|
|
|
|
|
|
|
_isRunning = true; |
|
|
|
try |
|
|
|
lock (lockObject) |
|
|
|
{ |
|
|
|
Logger.LogInformation("Executed ImportLisResultInterfaceWorker..!"); |
|
|
|
var appServiceHelper = new AppServiceHelper(); |
|
|
|
appServiceHelper.Login(); |
|
|
|
var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService<object, ThirdInterFaceForHostOutDto>("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)) |
|
|
|
_isRunning = true; |
|
|
|
try |
|
|
|
{ |
|
|
|
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") |
|
|
|
Logger.LogInformation("Executed ImportLisResultInterfaceWorker..!"); |
|
|
|
var appServiceHelper = new AppServiceHelper(); |
|
|
|
appServiceHelper.Login(); |
|
|
|
var thirdInterFaceForHostOutDto = appServiceHelper.CallAppService<object, ThirdInterFaceForHostOutDto>("api/app/ThirdInterface/GetList", null); |
|
|
|
var thirdInterfaceDto = thirdInterFaceForHostOutDto.Data.Where(o => o.Id == interfaceId).FirstOrDefault(); |
|
|
|
if (thirdInterfaceDto == null) |
|
|
|
{ |
|
|
|
_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 };
|
|
|
|
await ReflectionHelper.InvokeAsync(assemblyName, className, parmValue, funName); |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
Logger.LogError("Executed ImportLisResultInterfaceWorker Error" + ex.Message); |
|
|
|
} |
|
|
|
_isRunning = false; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void DoWork() |
|
|
|
|