Exemplo n.º 1
0
 public static RFMonitoredFile ReadFromConfig(RFEnum fileKey, IRFUserConfig config, Func <string, string> nameTransform = null, bool throwIfFail = true)
 {
     try
     {
         var m = new RFMonitoredFile
         {
             FileKey          = fileKey,
             FileNameWildcard = config.GetString(CONFIG_SECTION, fileKey, false, "FileNameWildcard"),
             FileNameRegex    = config.GetString(CONFIG_SECTION, fileKey, false, "FileNameRegex"),
             GetSubDirectory  = config.GetString(CONFIG_SECTION, fileKey, false, "GetSubDirectory") ?? config.GetString(CONFIG_SECTION, fileKey, false, "SubDirectory"),
             PutSubDirectory  = config.GetString(CONFIG_SECTION, fileKey, false, "PutSubDirectory"),
             NameTransform    = nameTransform,
             Recursive        = config.GetBool(CONFIG_SECTION, fileKey, false, false, "RecursiveSearch"),
             RemoveExpired    = config.GetBool(CONFIG_SECTION, fileKey, false, false, "RemoveExpired"),
             LatestOnly       = config.GetBool(CONFIG_SECTION, fileKey, false, false, "LatestOnly"),
             ContentPasswords = config.GetString(CONFIG_SECTION, fileKey, false, "ContentPasswords"),
         };
         if (string.IsNullOrWhiteSpace(m.FileNameWildcard) && string.IsNullOrWhiteSpace(m.FileNameRegex) && throwIfFail)
         {
             throw new RFSystemException(typeof(RFMonitoredFile), "Invalid monitored file {0} configuration: missing file name.", fileKey.ToString());
         }
         return(m);
     }
     catch (Exception)
     {
         if (throwIfFail)
         {
             throw;
         }
     }
     return(null);
 }
Exemplo n.º 2
0
 public static RFEmailConfig ReadFromConfig(IRFUserConfig config, string section, string emailName)
 {
     return(new RFEmailConfig
     {
         Enabled = config.GetBool(section, emailName, true, true, "Enabled"),
         To = config.GetString(section, emailName, true, "To"),
         Cc = config.GetString(section, emailName, false, "Cc"),
         Bcc = config.GetString(section, emailName, false, "Bcc"),
         SendAsImage = config.GetBool(section, emailName, false, false, "Send as Image")
     });
 }
Exemplo n.º 3
0
 public static RFLocalMirrorSite ReadFromConfig(RFEnum siteKey, IRFUserConfig userConfig, string connectionString)
 {
     return(new RFLocalMirrorSite(siteKey, userConfig, userConfig.GetString(CONFIG_SECTION, siteKey, true, "RootDirectory"), connectionString)
     {
         SiteKey = siteKey,
         PreserveModifiedDate = userConfig.GetBool(CONFIG_SECTION, siteKey, false, true, "PreserveModifiedDate"),
         CacheDirectoryList = true
     });
 }
Exemplo n.º 4
0
        protected RFFileSite(RFEnum siteKey, string configSection, IRFUserConfig userConfig)
        {
            SiteKey = siteKey;
            Enabled = true;
            MaxAge  = null;

            if (userConfig != null)
            {
                MaxAge           = userConfig.GetDecimal(configSection, siteKey, false, null, "MaxAge");
                Enabled          = userConfig.GetBool(configSection, siteKey, false, true, "Enabled");
                PGPSuffixes      = userConfig.GetString(configSection, siteKey, false, "PGPSuffixes");
                PGPKeyPath       = userConfig.GetString(configSection, siteKey, false, "PGPKeyPath");
                PGPKeyPassword   = userConfig.GetString(configSection, siteKey, false, "PGPKeyPassword");
                WriteCooldown    = userConfig.GetInt(configSection, siteKey, false, null, "WriteCooldown");
                ScanArchives     = userConfig.GetBool(configSection, siteKey, false, false, "ScanArchives");
                ArchivePath      = userConfig.GetString(configSection, siteKey, false, "ArchivePath");
                UseTemporaryName = userConfig.GetBool(configSection, siteKey, false, false, "UseTemporaryName");
            }
        }
Exemplo n.º 5
0
        public static RFSchedulerSchedule ReadFromConfig(string configSection, string configKey, IRFUserConfig config)
        {
            var timeZone = config.GetString(configSection, configKey, false, "Time Zone");

            if (timeZone.IsBlank())
            {
                timeZone = null;
            }

            var compositeSchedule = new RFCompositeSchedule();

            var explicitTimes = config.GetString(configSection, configKey, false, "Times");

            if (explicitTimes.NotBlank())
            {
                foreach (var token in explicitTimes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Where(t => t.NotBlank()).Select(t => t.Trim()))
                {
                    compositeSchedule.DailySchedules.Add(new RFDailySchedule(TimeSpan.Parse(token), timeZone));
                }
            }

            var offsetConfig = config.GetString(configSection, configKey, false, "Offset");
            var offset       = new TimeSpan();

            if (offsetConfig.NotBlank())
            {
                offset = TimeSpan.Parse(offsetConfig);
            }

            var explicitIntervals = config.GetString(configSection, configKey, false, "Intervals");

            if (explicitIntervals.NotBlank())
            {
                foreach (var token in explicitIntervals.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Where(t => t.NotBlank()).Select(t => t.Trim()))
                {
                    compositeSchedule.IntervalSchedules.Add(new RFIntervalSchedule(TimeSpan.Parse(token), offset));
                }
            }

            return(compositeSchedule);
        }
Exemplo n.º 6
0
 public static RFFTPFileSite ReadFromConfig(RFEnum siteKey, IRFUserConfig userConfig)
 {
     return(new RFFTPFileSite(siteKey, userConfig)
     {
         SiteKey = siteKey,
         SiteType = (RFFTPSiteType)Enum.Parse(typeof(RFFTPSiteType), userConfig.GetString(CONFIG_SECTION, siteKey, true, "SiteType"), true),
         Hostname = userConfig.GetString(CONFIG_SECTION, siteKey, true, "Hostname"),
         Port = userConfig.GetInt(CONFIG_SECTION, siteKey, false, null, "Port"),
         Username = userConfig.GetString(CONFIG_SECTION, siteKey, true, "Username"),
         Password = userConfig.GetString(CONFIG_SECTION, siteKey, false, "Password"),
         ConnectionKeyPath = userConfig.GetString(CONFIG_SECTION, siteKey, false, "ConnectionKeyPath"),
         ConnectionKeyPassword = userConfig.GetString(CONFIG_SECTION, siteKey, false, "ConnectionKeyPassword"),
         RootDirectory = userConfig.GetString(CONFIG_SECTION, siteKey, false, "RootDirectory")
     });
 }
Exemplo n.º 7
0
        public static RFSchedulerRange ReadFromConfig(string configSection, string configKey, IRFUserConfig config)
        {
            var compositeRange = new RFCompositeRange();
            var timeZone       = config.GetString(configSection, configKey, false, "Time Zone");

            if (timeZone.IsBlank())
            {
                timeZone = null;
            }

            var allowDays = config.GetString(configSection, configKey, false, "Allow Days"); // mon,tue or mon-fri

            if (allowDays.NotBlank())
            {
                compositeRange.AllowRanges.Add(new RFWeeklyWindow(ParseDays(allowDays), timeZone));
            }
            var denyDays = config.GetString(configSection, configKey, false, "Deny Days"); // mon,tue or mon-fri

            if (denyDays.NotBlank())
            {
                compositeRange.DenyRanges.Add(new RFWeeklyWindow(ParseDays(denyDays), timeZone));
            }

            var awindowStart = config.GetString(configSection, configKey, false, "Allow Window Start"); // HH:mm
            var awindowEnd   = config.GetString(configSection, configKey, false, "Allow Window End");   // HH:mm

            if (awindowStart.NotBlank() || awindowEnd.NotBlank())
            {
                var window = ParseWindow(awindowStart, awindowEnd);
                compositeRange.AllowRanges.Add(new RFDailyWindow(window.Item1, window.Item2, timeZone));
            }

            var dwindowStart = config.GetString(configSection, configKey, false, "Deny Window Start"); // HH:mm
            var dwindowEnd   = config.GetString(configSection, configKey, false, "Deny Window End");   // HH:mm

            if (dwindowStart.NotBlank() || dwindowEnd.NotBlank())
            {
                var window = ParseWindow(dwindowStart, dwindowEnd);
                compositeRange.DenyRanges.Add(new RFDailyWindow(window.Item1, window.Item2, timeZone));
            }

            return(compositeRange);
        }
Exemplo n.º 8
0
 public static string GetRootDirectory(RFEnum siteKey, IRFUserConfig userConfig)
 {
     return(userConfig.GetString(CONFIG_SECTION, siteKey, true, "RootDirectory"));
 }