KeplerManager
using kCura.WinEDDS.Mapping;
using kCura.WinEDDS.Service.Kepler;
using Microsoft.VisualBasic.CompilerServices;
using Relativity.DataExchange.Service;
using Relativity.DataTransfer.Legacy.SDK.ImportExport.V1.Models;
using Relativity.Logging;
using System;
using System.Data;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Web.Services.Protocols;
namespace kCura.WinEDDS.Service.Replacement
{
public abstract class KeplerManager : IDisposable
{
private readonly IServiceProxyFactory _serviceProxyFactory;
private readonly IKeplerProxy _keplerProxy;
private readonly IServiceExceptionMapper _exceptionMapper;
protected readonly Func<string> CorrelationIdFunc;
public KeplerManager(IServiceProxyFactory serviceProxyFactory, IServiceExceptionMapper exceptionMapper, Func<string> correlationIdFunc)
{
_serviceProxyFactory = serviceProxyFactory;
_keplerProxy = new KeplerProxy(serviceProxyFactory, Log.get_Logger());
_exceptionMapper = exceptionMapper;
CorrelationIdFunc = correlationIdFunc;
}
protected T Execute<T>(Func<IServiceProxyFactory, Task<T>> func)
{
return ExecuteAsync(func).GetAwaiter().GetResult();
}
protected T ExecuteWithoutRetries<T>(Func<IServiceProxyFactory, Task<T>> func)
{
return ExecuteWithoutRetriesAsync(func).GetAwaiter().GetResult();
}
protected DataSet Execute(Func<IServiceProxyFactory, Task<DataSetWrapper>> func)
{
return ExecuteAsync(func).GetAwaiter().GetResult().Unwrap();
}
[AsyncStateMachine(typeof(VB$StateMachine_8_ExecuteAsync<>))]
private Task<T> ExecuteAsync<T>(Func<IServiceProxyFactory, Task<T>> func)
{
VB$StateMachine_8_ExecuteAsync<T> stateMachine = default(VB$StateMachine_8_ExecuteAsync<T>);
stateMachine.$VB$Me = this;
stateMachine.$VB$Local_func = func;
stateMachine.$State = -1;
stateMachine.$Builder = AsyncTaskMethodBuilder<T>.Create();
stateMachine.$Builder.Start(ref stateMachine);
return stateMachine.$Builder.Task;
}
[AsyncStateMachine(typeof(VB$StateMachine_9_ExecuteWithoutRetriesAsync<>))]
private Task<T> ExecuteWithoutRetriesAsync<T>(Func<IServiceProxyFactory, Task<T>> func)
{
VB$StateMachine_9_ExecuteWithoutRetriesAsync<T> stateMachine = default(VB$StateMachine_9_ExecuteWithoutRetriesAsync<T>);
stateMachine.$VB$Me = this;
stateMachine.$VB$Local_func = func;
stateMachine.$State = -1;
stateMachine.$Builder = AsyncTaskMethodBuilder<T>.Create();
stateMachine.$Builder.Start(ref stateMachine);
return stateMachine.$Builder.Task;
}
protected virtual Exception ConvertSoapExceptionToRelativityException(SoapException soapException)
{
return null;
}
private void UnpackSoapException(SoapException soapException)
{
Exception ex = null;
try {
ex = ConvertSoapExceptionToRelativityException(soapException);
} catch (Exception projectError) {
ProjectData.SetProjectError(projectError);
ProjectData.ClearProjectError();
}
if (ex != null)
throw ex;
}
public void Dispose()
{
_serviceProxyFactory?.Dispose();
}
void IDisposable.Dispose()
{
this.Dispose();
}
}
}