<PackageReference Include="Relativity.Server.Import.SDK" Version="2.9.2" />

KeplerDistributedReplacement

Kepler facade which provides methods for downloading a file.
using Relativity.DataExchange.Io; using Relativity.Logging; using Relativity.Services.Exceptions; using System; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Runtime.CompilerServices; namespace Relativity.DataExchange.Service.RelativityDistributed { internal sealed class KeplerDistributedReplacement : IRelativityDistributedFacade { private readonly IKeplerProxy keplerProxy; private readonly IFile fileHelper; private readonly ILog logger; private readonly Func<string> correlationIdFunc; public KeplerDistributedReplacement(IKeplerProxy keplerProxy, IFile fileHelper, ILog logger, Func<string> correlationIdFunc) { this.keplerProxy = keplerProxy; this.fileHelper = fileHelper; this.logger = logger; this.correlationIdFunc = correlationIdFunc; } [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exception is included in the response")] public FileDownloadResponse DownloadFile(FileDownloadRequest request) { if (!int.TryParse(request.WorkspaceId, out int _)) throw new ArgumentException("WorkspaceID is not integer", "request"); if (Guid.TryParse(request.RemoteFileGuid, out Guid _)) try { <>c__DisplayClass5_0 <>4__this; keplerProxy.ExecuteAsync(delegate(IServiceProxyFactory serviceProxyFactory) { <>c__DisplayClass5_0.<<DownloadFile>g__DownloadFileOrThrowException|0>d stateMachine = default(<>c__DisplayClass5_0.<<DownloadFile>g__DownloadFileOrThrowException|0>d); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = <>4__this; stateMachine.serviceProxyFactory = serviceProxyFactory; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; }).GetAwaiter().GetResult(); return new FileDownloadResponse(); } catch (NotAuthorizedException val) { NotAuthorizedException exception = val; LogError((Exception)exception, request); return new FileDownloadResponse(RelativityDistributedErrorType.Authentication, (Exception)exception); } catch (ConflictException val2) { ConflictException exception2 = val2; LogError((Exception)exception2, request); return new FileDownloadResponse(RelativityDistributedErrorType.NotFound, (Exception)exception2); } catch (ServiceException val3) { ServiceException exception3 = val3; LogError((Exception)exception3, request); return new FileDownloadResponse(RelativityDistributedErrorType.InternalServerError, (Exception)exception3); } catch (Exception exception4) { LogError(exception4, request); return new FileDownloadResponse(RelativityDistributedErrorType.Unknown, exception4); } throw new ArgumentException("Remote File Guid is not valid guid", "request"); } private void LogError(Exception exception, FileDownloadRequest request) { logger.LogError(exception, "An error occurred when downloading the error file. Request: {@request}", new object[1] { request }); } private Stream GetDestinationFileStream(string destinationFilePath, bool shouldRetry = true) { try { return fileHelper.Create(destinationFilePath); } catch (Exception ex) { logger.LogError(ex, "An error occurred when creating destination file: {destinationFilePath}. Will retry: {shouldRetry}", new object[2] { destinationFilePath, shouldRetry }); if (!shouldRetry) throw; return GetDestinationFileStream(destinationFilePath, false); } } } }