AppDotNetSettings
Represents a class object that provide a thread-safe copy of all .NET application settings. This class cannot be inherited.
using Relativity.DataExchange.Io;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
namespace Relativity.DataExchange
{
[Serializable]
internal sealed class AppDotNetSettings : IAppSettings, IAppSettingsInternal
{
private int batchInProgressNumberOfRetries;
private int batchInProgressWaitTimeInSeconds;
private int exportErrorWaitTimeInSeconds;
private int exportErrorNumberOfRetries;
private int ioErrorNumberOfRetries;
private int ioErrorWaitTimeInSeconds;
private int httpTimeoutSeconds;
private int httpExtractedTextTimeoutSeconds;
private int httpErrorNumberOfRetries;
private int httpErrorWaitTimeInSeconds;
private int internalKeplerTimeoutSeconds;
private int maximumReloginTries;
private int tapiMinDataRateMbps;
private int tapiMaxInactivitySeconds;
private int tapiMaxJobParallelism;
private int iApiMetricsThrottlingSeconds;
private int tapiTargetDataRateMbps;
private int tapiAsperaDatagramSize;
private int webBasedFileDownloadChunkSize;
private int exportLongTextDataGridThreadCount;
private int exportLongTextSqlThreadCount;
private int exportLongTextBufferSizeBytes;
private string webApiServiceMappedUrl;
private string programmaticWebApiServiceUrl;
[AppSetting("kCura.WinEDDS", "ApplicationName", "")]
string IAppSettings.ApplicationName { get; set; }
[AppSetting("kCura.WinEDDS", "AuditLevel", "FullAudit")]
string IAppSettings.AuditLevel { get; set; }
[AppSetting("Relativity.DataExchange", "BatchInProgressNumberOfRetries", 40)]
int IAppSettings.BatchInProgressNumberOfRetries {
get {
if (batchInProgressNumberOfRetries < 0)
batchInProgressNumberOfRetries = 40;
return batchInProgressNumberOfRetries;
}
set {
batchInProgressNumberOfRetries = value;
}
}
[AppSetting("Relativity.DataExchange", "BatchInProgressWaitTimeInSeconds", 30)]
int IAppSettings.BatchInProgressWaitTimeInSeconds {
get {
if (batchInProgressWaitTimeInSeconds < 1)
batchInProgressWaitTimeInSeconds = 30;
return batchInProgressWaitTimeInSeconds;
}
set {
batchInProgressWaitTimeInSeconds = value;
}
}
[AppSetting("kCura.WinEDDS", "CreateErrorForEmptyNativeFile", false)]
bool IAppSettings.CreateErrorForEmptyNativeFile { get; set; }
[AppSetting("Relativity.DataExchange", "CreateErrorForEmptyPdfFile", false)]
bool IAppSettings.CreateErrorForEmptyPdfFile { get; set; }
[AppSetting("kCura.WinEDDS", "CreateErrorForInvalidDate", true)]
bool IAppSettings.CreateErrorForInvalidDate { get; set; }
[AppSetting("kCura.WinEDDS", "CreateFoldersInWebAPI", true)]
bool IAppSettings.CreateFoldersInWebApi { get; set; }
[AppSetting("kCura.WinEDDS", "DefaultMaxErrorCount", 1000)]
int IAppSettings.DefaultMaxErrorCount { get; set; }
[AppSetting("kCura.WinEDDS", "DisableImageLocationValidation", false)]
bool IAppSettings.DisableImageLocationValidation { get; set; }
[AppSetting("kCura.WinEDDS", "DisableImageTypeValidation", false)]
bool IAppSettings.DisableImageTypeValidation { get; set; }
[AppSetting("kCura.WinEDDS", "DisableNativeValidation", false)]
bool IAppSettings.DisableOutsideInFileIdentification { get; set; }
[AppSetting("kCura.WinEDDS", "DisableTextFileEncodingCheck", false)]
bool IAppSettings.DisableTextFileEncodingCheck { get; set; }
[AppSetting("kCura.WinEDDS", "DisableNativeLocationValidation", false)]
bool IAppSettings.DisableThrowOnIllegalCharacters { get; set; }
[AppSetting("kCura.WinEDDS", "DynamicBatchResizingOn", true)]
bool IAppSettings.DynamicBatchResizingOn { get; set; }
[AppSetting("kCura.WinEDDS", "EnableCaseSensitiveSearchOnImport", true)]
bool IAppSettings.EnableCaseSensitiveSearchOnImport { get; set; }
[AppSetting]
public bool EnforceMinRetryCount { get; set; }
[AppSetting]
public bool EnforceMinWaitTime { get; set; }
[AppSetting("Relativity.DataExchange", "40B88CBC-9435-4A91-8F65-48B52C51B3FD", true)]
bool IAppSettingsInternal.EnforceVersionCompatibilityCheck { get; set; }
[AppSetting("kCura.WinEDDS", "ExportBatchSize", 1000)]
int IAppSettings.ExportBatchSize { get; set; }
[AppSetting("kCura.Utility", "ExportErrorNumberOfRetries", 20)]
int IAppSettings.ExportErrorNumberOfRetries {
get {
if (EnforceMinRetryCount && exportErrorNumberOfRetries < 1)
exportErrorNumberOfRetries = 20;
return exportErrorNumberOfRetries;
}
set {
exportErrorNumberOfRetries = value;
}
}
[AppSetting("kCura.Utility", "ExportErrorWaitTimeInSeconds", 30)]
int IAppSettings.ExportErrorWaitTimeInSeconds {
get {
if (EnforceMinWaitTime && exportErrorWaitTimeInSeconds < 1)
exportErrorWaitTimeInSeconds = 30;
return exportErrorWaitTimeInSeconds;
}
set {
exportErrorWaitTimeInSeconds = value;
}
}
[AppSetting("Relativity.DataExchange", "ExportLongTextBufferSizeBytes", 16384)]
int IAppSettings.ExportLongTextBufferSizeBytes {
get {
if (exportLongTextBufferSizeBytes < 128 || exportLongTextBufferSizeBytes > 1048576)
exportLongTextBufferSizeBytes = 16384;
return exportLongTextBufferSizeBytes;
}
set {
exportLongTextBufferSizeBytes = value;
}
}
[AppSetting("Relativity.DataExchange", "ExportLongTextLargeFileProgressRateSeconds", 3)]
int IAppSettings.ExportLongTextLargeFileProgressRateSeconds { get; set; }
[AppSetting("Relativity.DataExchange", "ExportLongTextObjectManagerEnabled", true)]
public bool ExportLongTextObjectManagerEnabled { get; set; }
[AppSetting("Relativity.DataExchange", "ExportLongTextDataGridThreadCount", 4)]
public int ExportLongTextDataGridThreadCount {
get {
if (exportLongTextDataGridThreadCount < 1 || exportLongTextDataGridThreadCount > 16)
exportLongTextDataGridThreadCount = 4;
return exportLongTextDataGridThreadCount;
}
set {
exportLongTextDataGridThreadCount = value;
}
}
[AppSetting("Relativity.DataExchange", "ExportLongTextSqlThreadCount", 2)]
public int ExportLongTextSqlThreadCount {
get {
if (exportLongTextSqlThreadCount < 1 || exportLongTextSqlThreadCount > 16)
exportLongTextSqlThreadCount = 2;
return exportLongTextSqlThreadCount;
}
set {
exportLongTextSqlThreadCount = value;
}
}
[AppSetting("Relativity.DataExchange", "FileTypeIdentifyTimeoutSeconds", 10)]
int IAppSettings.FileTypeIdentifyTimeoutSeconds { get; set; }
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "This is required for backwards compatibility.")]
[AppSetting]
bool IAppSettings.ForceFolderPreview {
get {
string registryKeyValue = AppSettingsManager.GetRegistryKeyValue("ForceFolderPreview");
if (string.IsNullOrEmpty(registryKeyValue)) {
AppSettingsManager.SetRegistryKeyValue("ForceFolderPreview", bool.TrueString.ToLowerInvariant());
return true;
}
return string.Compare(registryKeyValue, bool.TrueString, StringComparison.OrdinalIgnoreCase) == 0;
}
set {
AppSettingsManager.SetRegistryKeyValue("ForceFolderPreview", value.ToString().ToLowerInvariant());
}
}
[AppSetting("kCura.WinEDDS", "ForceWebUpload", false)]
bool IAppSettings.ForceWebUpload { get; set; }
[AppSetting("Relativity.DataExchange", "HttpErrorNumberOfRetries", 20)]
int IAppSettings.HttpErrorNumberOfRetries {
get {
if (EnforceMinRetryCount && httpErrorNumberOfRetries < 1)
httpErrorNumberOfRetries = 20;
return httpErrorNumberOfRetries;
}
set {
httpErrorNumberOfRetries = value;
}
}
[AppSetting("Relativity.DataExchange", "HttpErrorWaitTimeInSeconds", 10)]
int IAppSettings.HttpErrorWaitTimeInSeconds {
get {
if (httpErrorWaitTimeInSeconds < 1)
httpErrorWaitTimeInSeconds = 10;
return httpErrorWaitTimeInSeconds;
}
set {
httpErrorWaitTimeInSeconds = value;
}
}
[AppSetting("kCura.WinEDDS", "HttpTimeoutSeconds", 300)]
int IAppSettings.HttpTimeoutSeconds {
get {
if (httpTimeoutSeconds < 1)
httpTimeoutSeconds = 300;
return httpTimeoutSeconds;
}
set {
httpTimeoutSeconds = value;
}
}
[AppSetting("Relativity.DataExchange", "HttpExtractedTextTimeoutSeconds", 900)]
int IAppSettings.HttpExtractedTextTimeoutSeconds {
get {
if (httpExtractedTextTimeoutSeconds < 1)
httpExtractedTextTimeoutSeconds = 900;
return httpExtractedTextTimeoutSeconds;
}
set {
httpExtractedTextTimeoutSeconds = value;
}
}
[AppSetting("kCura.WinEDDS", "ImportBatchMaxVolume", 10485760)]
int IAppSettings.ImportBatchMaxVolume { get; set; }
[AppSetting("kCura.WinEDDS", "ImportBatchSize", 1000)]
int IAppSettings.ImportBatchSize { get; set; }
[AppSetting("Relativity.DataExchange", "InternalKeplerTimeoutSeconds", 300)]
int IAppSettings.InternalKeplerTimeoutInSeconds {
get {
if (internalKeplerTimeoutSeconds < 1)
internalKeplerTimeoutSeconds = 300;
return internalKeplerTimeoutSeconds;
}
set {
internalKeplerTimeoutSeconds = value;
}
}
[AppSetting("kCura.Utility", "IOErrorNumberOfRetries", 20)]
int IAppSettings.IoErrorNumberOfRetries {
get {
if (EnforceMinRetryCount && ioErrorNumberOfRetries < 1)
ioErrorNumberOfRetries = 20;
return ioErrorNumberOfRetries;
}
set {
ioErrorNumberOfRetries = value;
}
}
[AppSetting("kCura.Utility", "IOErrorWaitTimeInSeconds", 30)]
int IAppSettings.IoErrorWaitTimeInSeconds {
get {
if (EnforceMinWaitTime && ioErrorWaitTimeInSeconds < 1)
ioErrorWaitTimeInSeconds = 30;
return ioErrorWaitTimeInSeconds;
}
set {
ioErrorWaitTimeInSeconds = value;
}
}
[AppSetting("kCura.Utility", "RetryInTheOriginalTransferMode", true)]
bool IAppSettings.RetryInTheOriginalTransferMode { get; set; }
[AppSetting("kCura.WinEDDS", "JobCompleteBatchSize", 50000)]
int IAppSettings.JobCompleteBatchSize { get; set; }
[AppSetting("kCura.WinEDDS", "LoadImportedFullTextFromServer", false)]
bool IAppSettings.LoadImportedFullTextFromServer { get; set; }
[AppSetting("kCura.Windows.Process", "LogAllEvents", false)]
bool IAppSettings.LogAllEvents { get; set; }
[AppSetting("kCura.WinEDDS", "LogConfigFile", "LogConfig.xml")]
string IAppSettings.LogConfigXmlFileName { get; set; }
[AppSetting("Relativity.DataExchange", "LogHashingEnabled", false)]
public bool LogHashingEnabled { get; set; }
[AppSetting("kCura.WinEDDS", "MaximumReloginTries", 4)]
int IAppSettings.MaxReloginTries {
get {
if (maximumReloginTries < 1)
maximumReloginTries = 4;
return maximumReloginTries;
}
set {
maximumReloginTries = value;
}
}
[AppSetting("kCura.WinEDDS", "MinimumBatchSize", 100)]
int IAppSettings.MinBatchSize { get; set; }
[AppSetting("Relativity.DataExchange", "OAuth2ImplicitCredentialRedirectUrl", "rdc://relativityimplicit/")]
string IAppSettings.OAuth2ImplicitCredentialRedirectUrl { get; set; }
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This is required for backwards compatibility.")]
[AppSetting]
IList<int> IAppSettings.ObjectFieldIdListContainsArtifactId {
get {
string registryKeyValue = AppSettingsManager.GetRegistryKeyValue("ObjectFieldIdListContainsArtifactId");
if (string.IsNullOrEmpty(registryKeyValue)) {
AppSettingsManager.SetRegistryKeyValue("ObjectFieldIdListContainsArtifactId", string.Empty);
return new List<int>();
}
return registryKeyValue.Split(new string[1] {
","
}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
}
set {
if (value != null)
AppSettingsManager.SetRegistryKeyValue("ObjectFieldIdListContainsArtifactId", string.Join(",", from x in value
select x.ToString()));
}
}
[AppSetting]
string IAppSettings.OpenIdConnectHomeRealmDiscoveryHint {
get {
return AppSettingsManager.GetRegistryKeyValue("HRDHint");
}
}
[AppSetting("kCura.WinEDDS", "PermissionErrorsRetry", false)]
bool IAppSettings.PermissionErrorsRetry { get; set; }
[AppSetting("kCura.WinEDDS", "ExportPermissionErrorsRetry", false)]
bool IAppSettings.ExportPermissionErrorsRetry { get; set; }
[AppSetting("kCura.WinEDDS", "PreviewThreshold", 1000)]
int IAppSettings.PreviewThreshold { get; set; }
[AppSetting("kCura.WinEDDS", "ProcessFormRefreshRate", 0)]
int IAppSettings.ProcessFormRefreshRate { get; set; }
[AppSetting]
string IAppSettings.ProgrammaticWebApiServiceUrl {
get {
return programmaticWebApiServiceUrl;
}
set {
programmaticWebApiServiceUrl = ValidateUriFormat(value);
}
}
[AppSetting]
RetryOptions IAppSettings.RetryOptions {
get {
RetryOptions retryOptions = RetryOptions.Io;
if (!((IAppSettings)this).PermissionErrorsRetry)
return retryOptions & ~RetryOptions.Permissions;
return retryOptions | RetryOptions.Permissions;
}
}
[AppSetting("kCura.WinEDDS", "SuppressCertificateCheckOnClient", false)]
bool IAppSettings.SuppressServerCertificateValidation { get; set; }
[AppSetting("kCura.WinEDDS", "TapiAsperaBcpRootFolder", "")]
string IAppSettings.TapiAsperaBcpRootFolder { get; set; }
[AppSetting("kCura.WinEDDS", "TapiAsperaNativeDocRootLevels", 1)]
int IAppSettings.TapiAsperaNativeDocRootLevels { get; set; }
[AppSetting("Relativity.DataExchange", "TapiAsperaDatagramSize", 0)]
int IAppSettings.TapiAsperaDatagramSize {
get {
return tapiAsperaDatagramSize;
}
set {
tapiAsperaDatagramSize = ((value >= 296 && value <= 10000) ? value : 0);
}
}
[AppSetting("kCura.WinEDDS", "BadPathErrorsRetry", false)]
bool IAppSettings.TapiBadPathErrorsRetry { get; set; }
[AppSetting("Relativity.DataExchange", "TapiFileNotFoundErrorsDisabled", false)]
bool IAppSettings.TapiFileNotFoundErrorsDisabled { get; set; }
[AppSetting("Relativity.DataExchange", "TapiExportFileNotFoundErrorsDisabled", true)]
bool IAppSettings.TapiExportFileNotFoundErrorsDisabled { get; set; }
[AppSetting("Relativity.DataExchange", "TapiFileNotFoundErrorsRetry", true)]
bool IAppSettings.TapiFileNotFoundErrorsRetry { get; set; }
[AppSetting("Relativity.DataExchange", "TapiExportFileNotFoundErrorsRetry", false)]
bool IAppSettings.TapiExportFileNotFoundErrorsRetry { get; set; }
[AppSetting("kCura.WinEDDS", "TapiForceAsperaClient", false)]
bool IAppSettings.TapiForceAsperaClient { get; set; }
[AppSetting("kCura.WinEDDS", "TapiForceBcpHttpClient", false)]
bool IAppSettings.TapiForceBcpHttpClient { get; set; }
[AppSetting("kCura.WinEDDS", "TapiForceClientCandidates", "")]
string IAppSettings.TapiForceClientCandidates { get; set; }
[AppSetting("kCura.WinEDDS", "TapiForceFileShareClient", false)]
bool IAppSettings. { get; set; }
[AppSetting("kCura.WinEDDS", "TapiForceHttpClient", false)]
bool IAppSettings.TapiForceHttpClient { get; set; }
[AppSetting("kCura.WinEDDS", "TapiLargeFileProgressEnabled", true)]
bool IAppSettings.TapiLargeFileProgressEnabled { get; set; }
[AppSetting("Relativity.DataExchange", "TapiMaxInactivitySeconds", 180)]
int IAppSettings.TapiMaxInactivitySeconds {
get {
if (tapiMaxInactivitySeconds < 1)
tapiMaxInactivitySeconds = 180;
return tapiMaxInactivitySeconds;
}
set {
tapiMaxInactivitySeconds = value;
}
}
[AppSetting("kCura.WinEDDS", "TapiMaxJobParallelism", 10)]
int IAppSettings.TapiMaxJobParallelism {
get {
if (tapiMaxJobParallelism < 1)
tapiMaxJobParallelism = 10;
return tapiMaxJobParallelism;
}
set {
tapiMaxJobParallelism = value;
}
}
[AppSetting("kCura.WinEDDS", "TapiMinDataRateMbps", 0)]
int IAppSettings.TapiMinDataRateMbps {
get {
if (tapiMinDataRateMbps < 1)
tapiMinDataRateMbps = 0;
return tapiMinDataRateMbps;
}
set {
tapiMinDataRateMbps = value;
}
}
[AppSetting("kCura.WinEDDS", "TapiPreserveFileTimestamps", false)]
bool IAppSettings.TapiPreserveFileTimestamps { get; set; }
[AppSetting("kCura.WinEDDS", "TapiSubmitApmMetrics", true)]
bool IAppSettings.TapiSubmitApmMetrics { get; set; }
[AppSetting("Relativity.DataExchange", "TelemetrySubmitApmMetrics", true)]
bool IAppSettings.TelemetrySubmitApmMetrics { get; set; }
[AppSetting("Relativity.DataExchange", "TelemetrySubmitSumMetrics", true)]
bool IAppSettings.TelemetrySubmitSumMetrics { get; set; }
[AppSetting("Relativity.DataExchange", "TelemetryMetricsThrottlingSeconds", 30)]
int IAppSettings.TelemetryMetricsThrottlingSeconds {
get {
if (iApiMetricsThrottlingSeconds < 1)
iApiMetricsThrottlingSeconds = 30;
return iApiMetricsThrottlingSeconds;
}
set {
iApiMetricsThrottlingSeconds = value;
}
}
[AppSetting("kCura.WinEDDS", "TapiTargetDataRateMbps", 100)]
int IAppSettings.TapiTargetDataRateMbps {
get {
if (tapiTargetDataRateMbps < 1)
tapiTargetDataRateMbps = 100;
return tapiTargetDataRateMbps;
}
set {
tapiTargetDataRateMbps = value;
}
}
[AppSetting("kCura.WinEDDS", "TapiTransferLogDirectory", "")]
string IAppSettings.TapiTransferLogDirectory { get; set; }
[AppSetting("kCura.WinEDDS", "TempDirectory", "")]
string IAppSettings.TempDirectory { get; set; }
[AppSetting("kCura.WinEDDS", "UsePipeliningForNativeAndObjectImports", true)]
bool IAppSettings.UsePipeliningForNativeAndObjectImports { get; set; }
[AppSetting("kCura.Config", "ValueRefreshThreshold", 10000)]
int IAppSettings.ValueRefreshThreshold { get; set; }
[AppSetting("kCura.WinEDDS", "WaitBeforeReconnect", 2000)]
int IAppSettings.WaitBeforeReconnect { get; set; }
[AppSetting("kCura.WinEDDS", "WebAPIOperationTimeout", 600000)]
int IAppSettings.WebApiOperationTimeout { get; set; }
[AppSetting("kCura.WinEDDS", "WebServiceURL", "")]
public string WebApiServiceMappedUrl {
get {
return webApiServiceMappedUrl;
}
set {
webApiServiceMappedUrl = ValidateUriFormat(value);
}
}
[AppSetting]
string IAppSettings.WebApiServiceUrl {
get {
string registryKeyValue = ((IAppSettings)this).ProgrammaticWebApiServiceUrl;
if (string.IsNullOrWhiteSpace(registryKeyValue) && !string.IsNullOrWhiteSpace(WebApiServiceMappedUrl))
registryKeyValue = WebApiServiceMappedUrl;
if (string.IsNullOrWhiteSpace(registryKeyValue))
registryKeyValue = AppSettingsManager.GetRegistryKeyValue("WebServiceURL");
return ValidateUriFormat(registryKeyValue);
}
set {
AppSettingsManager.SetRegistryKeyValue("WebServiceURL", ValidateUriFormat(value));
}
}
[AppSetting("kCura.WinEDDS", "WebBasedFileDownloadChunkSize", 1048576)]
int IAppSettings.WebBasedFileDownloadChunkSize {
get {
return Math.Max(webBasedFileDownloadChunkSize, 1024);
}
set {
webBasedFileDownloadChunkSize = value;
}
}
[AppSetting("kCura.WinEDDS", "UseSynchronizedImportBatchMode", true)]
bool IAppSettings.UseSynchronizedImportBatchMode { get; set; }
[AppSetting("Relativity.DataExchange", "UseSearchablePdf", true)]
bool IAppSettings.UseSearchablePdf { get; set; }
[AppSetting("Relativity.DataExchange", "UseKepler", null)]
bool? IAppSettings.UseKepler { get; set; }
[AppSetting("Relativity.DataExchange", "ReadCommunicationModeErrorNumberOfRetries", 1)]
int IAppSettings.ReadCommunicationModeErrorNumberOfRetries { get; set; }
[AppSetting("Relativity.DataExchange", "ReadCommunicationModeErrorWaitTimeInSeconds", 1)]
int IAppSettings.ReadCommunicationModeErrorWaitTimeInSeconds { get; set; }
public AppDotNetSettings()
{
EnforceMinWaitTime = true;
EnforceMinRetryCount = true;
}
public AppDotNetSettings(IAppSettings settings)
{
if (settings == null)
throw new ArgumentNullException("settings");
PropertyInfo[] properties = typeof(AppDotNetSettings).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (PropertyInfo propertyInfo in properties) {
if (propertyInfo.SetMethod != (MethodInfo)null) {
object value = propertyInfo.GetValue(settings, null);
propertyInfo.SetValue(this, value, null);
}
}
if (settings.ObjectFieldIdListContainsArtifactId != null)
((IAppSettings)this).ObjectFieldIdListContainsArtifactId = new List<int>(settings.ObjectFieldIdListContainsArtifactId);
}
public static string ValidateUriFormat(string value)
{
if (!string.IsNullOrEmpty(value) && !value.Trim().EndsWith("/", StringComparison.OrdinalIgnoreCase))
value = value.Trim() + "/";
if (!Uri.TryCreate(value, UriKind.Absolute, out Uri _))
return string.Empty;
return value;
}
IAppSettings IAppSettings.DeepCopy()
{
return new AppDotNetSettings(this);
}
string IAppSettings.ValidateUriFormat(string value)
{
return ValidateUriFormat(value);
}
}
}