/// <summary> /// Try loading remote configuration /// In case of exception return null /// </summary> /// <param name="localConfiguration"></param> /// <returns></returns> private void TryLoadRemoteConfiguration(Domain.Configuration localConfiguration) { try { System.Diagnostics.Stopwatch stopWatch = System.Diagnostics.Stopwatch.StartNew();; Utilities.Logger.Log(NLog.LogLevel.Trace, Resources.Messages.StartReadingRemoteConfiguration, localConfiguration.UrlPostFile); Domain.ConfigurationRequest request = new ConfigurationRequest(localConfiguration); Domain.ConfigurationResponse configurationResponse = new RestClient(localConfiguration).GetRemoteConfiguration(request); Utilities.Logger.Log(NLog.LogLevel.Trace, Resources.Messages.EndOfExecution, "Configuration.TryLoadRemoteConfiguration", Logger.GetTimeElapsed(stopWatch)); this._configurationResponse = configurationResponse; } catch (Exception ex) { Utilities.Logger.Log(ex); this._configurationResponse = null; } }
/// <summary> /// Update local configuration using response from the server /// </summary> /// <param name="configurationResponse"></param> internal void UpdateLocalConfiguration(Domain.ConfigurationResponse configurationResponse) { if (configurationResponse != null) { this.LocationKey = SelectValue <string>(configurationResponse.LocationKey, this.LocationKey); this.UrlPostFile = SelectValue <string>(configurationResponse.UrlPostFile, this.UrlPostFile); this.ScheduledIntervalSec = SelectValue <int?>(configurationResponse.ScheduledIntervalSec, (int?)this.ScheduledIntervalSec).Value; this.FileSizeLimitMb = SelectValue <int?>(configurationResponse.FileSizeLimitMb, (int?)this.FileSizeLimitMb).Value; this.ImmutabilityIntervalSec = SelectValue <int?>(configurationResponse.ImmutabilityIntervalSec, (int?)this.ImmutabilityIntervalSec).Value; this.MaxThreads = SelectValue <int?>(configurationResponse.MaxThreads, (int?)this.MaxThreads).Value; this.ThreadTimeToLiveSec = SelectValue <int?>(configurationResponse.ThreadTimeToLiveSec, (int?)this.ThreadTimeToLiveSec).Value; this.SequenceId = SelectValue <string>(configurationResponse.SequenceId, this.SequenceId); this.Files = configurationResponse.Files ?? new HashSet <FileSettings>(); this.RunCommand = this.SelectValue <string>(configurationResponse.RunCommand, this.RunCommand); this.RunCommandArgs = this.SelectValue <string>(configurationResponse.RunCommandArgs, this.RunCommandArgs); this.Save(GetConfigurationFilePath()); } }