<PackageReference Include="Relativity.Transfer.Client" Version="7.1.40" />

InstanceDetailsService

using Polly; using Relativity.Transfer.Resources; using System; using System.Globalization; using System.Net; using System.Threading; using System.Threading.Tasks; namespace Relativity.Transfer { internal class InstanceDetailsService : RestServiceBase, IInstanceDetailsService { public InstanceDetailsService(RelativityConnectionInfo connectionInfo) : base(connectionInfo) { } public InstanceDetailsService(RelativityConnectionInfo connectionInfo, ITransferLog log) : base(connectionInfo, log) { } public InstanceDetailsService(RelativityConnectionInfo connectionInfo, ITransferLog log, int maxRetryAttempts, double timeoutSeconds) : base(connectionInfo, log, maxRetryAttempts, timeoutSeconds) { } public async Task<Version> GetRelativityVersionAsync(CancellationToken token) { string key = CoreMemoryCacheKeys.CreateRelativityVersionKey(base.ServiceFactory.ConnectionInfo.Host); using (MemoryCacheRepository cacheRepository = new MemoryCacheRepository(TransferCache.Default)) { Version version = cacheRepository.SelectByKey<Version>(key); if (version == (Version)null) { base.Log.LogDebug("Preparing to retrieve the version from the '{Host}' Relativity instance.", base.ConnectionInfo.Host); HttpConnectionInfo httpConnectionInfo = new HttpConnectionInfo(base.ConnectionInfo); RestClient restClient = new RestClient(httpConnectionInfo, base.Log, base.TimeoutSeconds, base.MaxRetryAttempts); string response2 = await restClient.RequestJsonPostAsync("/relativity.rest/api/Relativity.Services.InstanceDetails.IInstanceDetailsModule/InstanceDetailsService/GetRelativityVersionAsync", null, (int retryAttempt) => TimeSpan.FromSeconds(Math.Pow(2, (double)retryAttempt)), delegate(Exception exception, TimeSpan timespan, Context context) { base.Log.LogError(exception, "Retry - {Timespan} - Failed to retrieve the version from the '{Host}' Relativity instance.", timespan, base.ConnectionInfo.Host); }, (HttpStatusCode code) => "Relativiy version", (HttpStatusCode code) => string.Format(CultureInfo.CurrentCulture, CoreStrings.RelativityVersionHttpPostExceptionMessage, base.ConnectionInfo.Host), CancellationToken.None).ConfigureAwait(false); base.Log.LogDebug("Successfully retrieved the version from the '{Host}' Relativity instance.", base.ConnectionInfo.Host); if (!string.IsNullOrEmpty(response2)) { response2 = response2.Trim(new char[1] { '"' }); if (!Version.TryParse(response2, out version)) base.Log.LogError("Failed to parse the {Version} response to a Version object.", response2); } } if (version == (Version)null) version = new Version(); cacheRepository.Upsert(key, version); return version; } } } }