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

WebApiVsKepler

Toggle which provides methods to determine what service implementation (Kepler or WebApi) should be used.
using Relativity.DataExchange.Logger; using Relativity.DataTransfer.Legacy.SDK.ImportExport.V1.Models; using Relativity.Logging; using Relativity.Services.Exceptions; using System; using System.Diagnostics.CodeAnalysis; namespace Relativity.DataExchange.Service.WebApiVsKeplerSwitch { public class WebApiVsKepler : IWebApiVsKepler { private readonly IServiceAvailabilityChecker serviceAvailabilityChecker; private readonly ILog logger; public WebApiVsKepler(IServiceAvailabilityChecker serviceAvailabilityChecker, ILog logger) { this.serviceAvailabilityChecker = serviceAvailabilityChecker; this.logger = (((object)logger) ?? ((object)RelativityLogger.Instance)); } public WebApiVsKepler(IServiceAvailabilityChecker serviceAvailabilityChecker) : this(serviceAvailabilityChecker, RelativityLogger.Instance) { } [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", Justification = "'WebApi' and 'Kepler' tokens are correct.")] public bool UseKepler() { bool flag = serviceAvailabilityChecker.IsKeplerAvailable(); if (flag && GetKeplerUsageByCommunicationModeAndAppSettings()) { ILog obj = logger; if (obj != null) obj.LogWarning("Kepler service is available. Kepler will be used.", Array.Empty<object>()); return true; } if (serviceAvailabilityChecker.IsWebApiAvailable()) { ILog obj2 = logger; if (obj2 != null) obj2.LogWarning("WebApi service is available. WebApi will be used.", Array.Empty<object>()); return false; } if (flag) { ILog obj3 = logger; if (obj3 != null) obj3.LogWarning("WebApi service not available. Kepler service will be used.", Array.Empty<object>()); return true; } string text = "The request could not be executed because the Import API service endpoint could not be found. A system administrator can attempt to resolve this issue by 1) Installing the web certificates to the Trusted Root store 2) Add the web server to Internet Options -> Trusted Sites, and 3) Verify the WebAPI URL is configured to the Web server. If the problem persists, Restart the \"kCura Service Host Manager\" and \"kCura Agent manager\" Windows services or contact your system administrator for assistance."; ILog obj4 = logger; if (obj4 != null) obj4.LogError(text, Array.Empty<object>()); throw new NotFoundException(text); } private bool GetKeplerUsageByCommunicationModeAndAppSettings() { IAPICommunicationMode? nullable = serviceAvailabilityChecker.ReadImportApiCommunicationMode(); bool? useKepler = AppSettings.Instance.UseKepler; object obj; IAPICommunicationMode val; if (!nullable.HasValue) obj = "not set"; else { val = nullable.Value; obj = "is set to " + ((object)val).ToString(); } string text = (string)obj; string text2 = useKepler.HasValue ? ("is set to " + useKepler.Value.ToString()) : "not set"; ILog obj2 = logger; if (obj2 != null) obj2.LogWarning("Instance Setting IAPICommunicationMode {iApiCommunicationModeString}. Application setting UseKepler {keplerUsageLocalSettingsValueString}.", new object[2] { text, text2 }); IAPICommunicationMode? nullable2 = nullable; val = 3; if ((nullable2.GetValueOrDefault() == val) & nullable2.HasValue) return true; nullable2 = nullable; val = 2; if ((nullable2.GetValueOrDefault() == val) & nullable2.HasValue) return false; if (useKepler.HasValue) return useKepler.Value; nullable2 = nullable; val = 1; if ((nullable2.GetValueOrDefault() == val) & nullable2.HasValue) return true; nullable2 = nullable; val = 0; if ((nullable2.GetValueOrDefault() == val) & nullable2.HasValue) return false; return true; } } }