Пример #1
0
        private void Load(System.Data.DataRow row)
        {
            _rowid = row.GetLong("rowid");

            _path = row.GetString("path");
            if (string.IsNullOrWhiteSpace(_path))
            {
                throw new SettingsException("No location specified.");
            }

            _type           = row.GetEnum <LocationType>("type", LocationType.Directory);
            _updateFreq     = row.GetInt("update_freq", k_defaultUpdateInterval);
            _updatePeriod   = row.GetEnum <Period>("update_period", k_defaultUpdatePeriod);
            _updateInterval = TimeSpanUtil.CalcInterval(_updateFreq, _updatePeriod);

            _disabled = row.GetBoolean("disabled", false);

            _lastUpdate = row.GetDateTime("last_update", DateTime.MinValue);
        }
Пример #2
0
 public void SetUpdateInterval(int freq, Period period)
 {
     _updateFreq     = freq;
     _updatePeriod   = period;
     _updateInterval = TimeSpanUtil.CalcInterval(freq, period);
 }
Пример #3
0
 public Location(LocationType type, string path)
 {
     _type           = type;
     _path           = path;
     _updateInterval = TimeSpanUtil.CalcInterval(_updateFreq, _updatePeriod);
 }
Пример #4
0
        public void Load(XmlElement topElement)
        {
            var path = topElement.InnerText;

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new SettingsException("No location specified.");
            }

            LocationType type;

            if (!Enum.TryParse <LocationType>(topElement.GetAttribute("Type"), out type))
            {
                type = File.Exists(path) ? LocationType.File : LocationType.Directory;
            }

            _type = type;
            _path = path;

            var str = topElement.GetAttribute("UpdateFreq");

            if (!string.IsNullOrWhiteSpace(str))
            {
                int freq;
                if (Int32.TryParse(str, out freq))
                {
                    _updateFreq = freq;
                }
                else
                {
                    _updateFreq = k_defaultUpdateInterval;
                }
            }

            str = topElement.GetAttribute("UpdatePeriod");
            if (!string.IsNullOrWhiteSpace(str))
            {
                Period period;
                if (Enum.TryParse <Period>(str, out period))
                {
                    _updatePeriod = period;
                }
                else
                {
                    _updatePeriod = k_defaultUpdatePeriod;
                }
            }

            str = topElement.GetAttribute("Disabled");
            if (!string.IsNullOrWhiteSpace(str))
            {
                bool disabled;
                if (bool.TryParse(str, out disabled))
                {
                    _disabled = disabled;
                }
                else
                {
                    _disabled = false;
                }
            }

            _updateInterval = TimeSpanUtil.CalcInterval(_updateFreq, _updatePeriod);
        }