private bool PostcheckValidRetryOption(RetryOption retryOption) { if (retryOption != null && retryOption.NumberOfRetries > 0 && retryOption.Interval > 0) { return(true); } else { return(false); } }
/// <summary> /// Get RetryOption object from xml file. /// </summary> /// <param name="filePath"> Absolute path of xml file.</param> /// <returns>RetryOption object.</returns> public virtual RetryOption GetRetryOptionFromXMLFile(string filePath) { if (!this.PrecheckInterfaceExisted()) { return(null); } try { if (File.Exists(filePath) && this.watcherConfig != null) { RetryOption retryOption = Mapper.Map <RetryOptionConfigDto, RetryOption>(this.watcherConfig.ReadRetryOption(filePath)); if (this.PostcheckValidRetryOption(retryOption)) { NLogger.Info( "Loaded RetryOption: " + Environment.NewLine + "NumberOfRetries: {0}." + Environment.NewLine + "Interval: {1}.", retryOption.NumberOfRetries, retryOption.Interval); } else { NLogger.Info("There's no valid config for RetryOption. ROBOCOPY's default will be used."); } return(retryOption); } else { NLogger.Info("Config file does not exist."); return(null); } } catch (InvalidOperationException ex) { NLogger.Error(ex, "Error while reading config file."); return(null); } }