Implement result getter
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
namespace Hcs.WebApp.BackgroundServices.ResultGetters
|
||||
{
|
||||
public interface IResultGetter
|
||||
{
|
||||
Task<ResultGetterResponse> GetAsync();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
using Hcs.Broker;
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using Hcs.WebApp.Services;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices.ResultGetters.NsiCommon
|
||||
{
|
||||
public class ExportNsiItemGetter_15_7_0_1(IClient client, IServiceScope scope, Operation operation) : ResultGetterBase(client, scope, operation)
|
||||
{
|
||||
public override async Task<ResultGetterResponse> GetAsync()
|
||||
{
|
||||
var result = await client.NsiCommon.GetExportNsiItemResultAsync(operation.MessageGuid!);
|
||||
if (!result.Ready)
|
||||
{
|
||||
return ResultGetterResponse.NotReady;
|
||||
}
|
||||
|
||||
if (result.Success)
|
||||
{
|
||||
var registryService = scope.ServiceProvider.GetRequiredService<RegistryService>();
|
||||
var registry = await registryService.GetRegistryByOperationIdAsync(operation.Id);
|
||||
// TODO
|
||||
|
||||
return ResultGetterResponse.Successful;
|
||||
}
|
||||
|
||||
return ResultGetterResponse.Failed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using Hcs.Broker;
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices.ResultGetters
|
||||
{
|
||||
public abstract class ResultGetterBase(IClient client, IServiceScope scope, Operation operation) : IResultGetter
|
||||
{
|
||||
protected readonly IClient client = client;
|
||||
protected readonly IServiceScope scope = scope;
|
||||
protected readonly Operation operation = operation;
|
||||
|
||||
public abstract Task<ResultGetterResponse> GetAsync();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
using Hcs.Broker;
|
||||
using Hcs.WebApp.BackgroundServices.ResultGetters.NsiCommon;
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices.ResultGetters
|
||||
{
|
||||
public class ResultGetterFactory
|
||||
{
|
||||
public IResultGetter CreateResultGetter(IServiceScope scope, IClient client, Operation operation)
|
||||
{
|
||||
switch (operation.Type)
|
||||
{
|
||||
case Operation.OperationType.NsiCommon_ExportNsiItem_15_7_0_1:
|
||||
return new ExportNsiItemGetter_15_7_0_1(client, scope, operation);
|
||||
}
|
||||
|
||||
throw new NotImplementedException($"Не удалось создать получателя результата операции типа {operation.Type}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
namespace Hcs.WebApp.BackgroundServices.ResultGetters
|
||||
{
|
||||
public enum ResultGetterResponse
|
||||
{
|
||||
NotReady,
|
||||
Successful,
|
||||
Failed
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user