<PackageReference Include="Relativity.Server.Transfer.SDK" Version="7.7.0" />

ConnectionServiceBase

public abstract class ConnectionServiceBase : IDisposable
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Globalization; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; namespace Relativity.Transfer { public abstract class ConnectionServiceBase : IDisposable { private readonly ConcurrentDictionary<string, object> healthCheckDetail; private TempDirectory tempDir; private bool disposed; public abstract Guid ClientId { get; } public abstract string ClientDisplayName { get; } protected RelativityConnectionInfo ConnectionInfo { get; } protected ClientConfiguration Configuration { get; } protected DiagnosticsContext Context { get; } protected IFileSystemService FileSystemService { get; } protected Guid TempFileId { get; } protected string TempFile { get; } protected ITransferLog Log { get; } protected ConnectionServiceBase(RelativityConnectionInfo connectionInfo, ClientConfiguration configuration, IFileSystemService fileSystemService, ITransferLog log, DiagnosticsContext context) { if (connectionInfo == null) throw new ArgumentNullException("connectionInfo"); if (configuration == null) throw new ArgumentNullException("configuration"); if (fileSystemService == null) throw new ArgumentNullException("fileSystemService"); if (log == null) throw new ArgumentNullException("log"); if (context == null) throw new ArgumentNullException("context"); ConnectionInfo = connectionInfo; Configuration = configuration; Context = context; Log = log; FileSystemService = fileSystemService; healthCheckDetail = new ConcurrentDictionary<string, object>(); TempFileId = Guid.NewGuid(); TempFile = FileSystemService.GetTempFileName(); } public Task<IConnectionCheckResult> ExecConnectionCheckAsync() { return ExecConnectionCheckAsync(CancellationToken.None); } [AsyncStateMachine(typeof(<ExecConnectionCheckAsync>d__30))] public virtual Task<IConnectionCheckResult> ExecConnectionCheckAsync(CancellationToken token) { <ExecConnectionCheckAsync>d__30 stateMachine = default(<ExecConnectionCheckAsync>d__30); stateMachine.<>t__builder = AsyncTaskMethodBuilder<IConnectionCheckResult>.Create(); stateMachine.<>4__this = this; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } [AsyncStateMachine(typeof(<RunUploadTestAsync>d__32))] protected Task RunUploadTestAsync(CancellationToken token) { <RunUploadTestAsync>d__32 stateMachine = default(<RunUploadTestAsync>d__32); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [AsyncStateMachine(typeof(<RunDownloadTestAsync>d__33))] protected Task RunDownloadTestAsync(CancellationToken token) { <RunDownloadTestAsync>d__33 stateMachine = default(<RunDownloadTestAsync>d__33); stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create(); stateMachine.<>4__this = this; stateMachine.token = token; stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } protected virtual Task RunPreTestsAsync(CancellationToken token) { return Task.FromResult(true); } protected virtual Task RunPortsTestAsync(CancellationToken token) { return Task.FromResult(true); } protected abstract Task TestUploadAsync(CancellationToken token); protected abstract Task TestDownloadAsync(CancellationToken token); protected void WriteStatusMessage(string message, params object[] args) { string message2 = message; if (args != null && args.Length != 0) try { message2 = string.Format(CultureInfo.CurrentCulture, message, args); } catch (FormatException) { } Context?.PublishStatusMessage(ClientId, message2); } protected void WriteErrorMessage(string message, params object[] args) { string str = message; if (args != null && args.Length != 0) try { str = string.Format(CultureInfo.CurrentCulture, message, args); } catch (FormatException) { } Context?.PublishStatusMessage(ClientId, "Error : " + str); } protected TempDirectory GetTempDirectory() { if (tempDir == null) { tempDir = new TempDirectory(); tempDir.Create(); } return tempDir; } protected void AddClientInfoToHealthCheck(string key, object value) { if (string.IsNullOrEmpty(key)) throw new ArgumentNullException("key"); healthCheckDetail.TryAdd(key, value); } protected void AddClientInfoToHealthCheck(IDictionary<string, object> keyValuePair) { if (keyValuePair == null) throw new ArgumentNullException("keyValuePair"); foreach (KeyValuePair<string, object> item in keyValuePair) { healthCheckDetail.TryAdd(item.Key, item.Value); } } private void CreateTestUploadFile() { int num = 8000 / "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.".Length; string contents = string.Join(Environment.NewLine, Array.ConvertAll(new int[num], (int i) => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")); FileSystemService.WriteAllText(TempFile, contents); } private void Dispose(bool disposing) { if (!disposed) { if (disposing) CleanTempFile(); disposed = true; } } private void CleanTempFile() { try { if (tempDir != null) tempDir.Dispose(); } finally { if (FileSystemService.FileExists(TempFile)) FileSystemService.DeleteFile(TempFile); } } } }