77 lines
3.2 KiB
C#
77 lines
3.2 KiB
C#
namespace Kreta.Job.Tasks
|
|
{
|
|
using Hangfire.Server;
|
|
using Kreta.Client.Eugyintezes;
|
|
using Kreta.Client.Eugyintezes.Configuration;
|
|
using Kreta.DataAccessManual;
|
|
using Kreta.Enums.ManualEnums;
|
|
using Kreta.Job.Tasks.Core;
|
|
using Kreta.Resources;
|
|
using static Kreta.Core.Constants;
|
|
|
|
public class EugyintezesJob : IEugyintezesJob
|
|
{
|
|
public void BaiSzinkronizacio(PerformContext context, string baseUrl, string apiKey, string intezmenyAzonosio, int kretaId, string jsonData)
|
|
{
|
|
int retryCount = context.GetJobParameter<int>("RetryCount");
|
|
var eUgyClient = new EugyintezesClient(new EugyConfig { BaseUrl = baseUrl, ApiKey = apiKey });
|
|
var result = eUgyClient.PostBAIHatarozatok(jsonData);
|
|
|
|
Dal.OrganizationConnection.Run(intezmenyAzonosio, h =>
|
|
{
|
|
var dal = h.Nebulo();
|
|
if (!string.IsNullOrWhiteSpace(result) && result.Replace("\"", "").Length > 0)
|
|
{
|
|
dal.UpdateNebuloStatusz(kretaId, result, (int)EugyStatuszEnum.Sikeres);
|
|
}
|
|
else if (result == "\"\"")
|
|
{
|
|
dal.UpdateNebuloStatusz(kretaId, result.Replace("\"", ""), (int)EugyStatuszEnum.HibasRosszAStatuszHianypotlas);
|
|
}
|
|
else
|
|
{
|
|
if (General.BaiAdatszinkronRetryAttempts <= retryCount)
|
|
{
|
|
dal.UpdateNebuloStatusz(kretaId, result, (int)EugyStatuszEnum.Hibas);
|
|
}
|
|
throw new System.Exception("Ervénytelen kísérlet!");
|
|
}
|
|
});
|
|
}
|
|
|
|
public void TeremBerbeadhatoStatuszValtozas(PerformContext context, string baseUrl, string apiKey, string intezmenyAzonosio, string jsonData)
|
|
{
|
|
int retryCount = context.GetJobParameter<int>("RetryCount");
|
|
var eUgyClient = new EugyintezesClient(new EugyConfig { BaseUrl = baseUrl, ApiKey = apiKey });
|
|
var result = eUgyClient.PostTeremBerbeadhatoStatuszValtozas(jsonData, intezmenyAzonosio);
|
|
|
|
if (General.EugySzinkronRetryAttempts <= retryCount)
|
|
{
|
|
throw new System.Exception(ErrorResource.EugySzinkronRetryAttempts);
|
|
}
|
|
}
|
|
|
|
public void TanuloOsztalyBesorolasStatuszValtozas(PerformContext context, string baseUrl, string apiKey, string intezmenyAzonosio, string jsonData)
|
|
{
|
|
int retryCount = context.GetJobParameter<int>("RetryCount");
|
|
var eUgyClient = new EugyintezesClient(new EugyConfig { BaseUrl = baseUrl, ApiKey = apiKey });
|
|
var result = eUgyClient.PostTanuloOsztalyBesorolasStatuszValtozas(jsonData);
|
|
|
|
if (General.EugySzinkronRetryAttempts <= retryCount)
|
|
{
|
|
throw new System.Exception(ErrorResource.EugySzinkronRetryAttempts);
|
|
}
|
|
}
|
|
|
|
private class EugyConfig : IEugyintezesClientConfiguration
|
|
{
|
|
public string BaseUrl { get; set; }
|
|
|
|
public string ApiKey { get; set; }
|
|
|
|
public bool IsUzenetekEnable { get; set; }
|
|
|
|
public int UzenetekFrequencyRate { get; set; }
|
|
}
|
|
}
|
|
}
|