Ejemplo n.º 1
0
        public static bool set_value(Guid applicationId, RVSettingsItem name, string value, Guid currentUserId)
        {
            Dictionary <RVSettingsItem, string> items = new Dictionary <RVSettingsItem, string>();

            items[name] = value;
            return(set_value(applicationId, items, currentUserId));
        }
Ejemplo n.º 2
0
        private static int get_int(Guid?applicationId, RVSettingsItem name, int defaultValue, int?minValue)
        {
            int val = 0;

            if (!int.TryParse(get_value(applicationId, name), out val))
            {
                val = defaultValue;
            }
            return(minValue.HasValue ? Math.Max(val, minValue.Value) : val);
        }
Ejemplo n.º 3
0
 private static void save_value(Guid applicationId, RVSettingsItem name, string value)
 {
     lock (SettingsDic)
     {
         if (!SettingsDic.ContainsKey(applicationId))
         {
             SettingsDic[applicationId] = new Dictionary <RVSettingsItem, string>();
         }
         SettingsDic[applicationId][name] = string.IsNullOrEmpty(value) ? string.Empty : value;
     }
 }
Ejemplo n.º 4
0
        private static DateTime get_time(Guid applicationId, RVSettingsItem name, DateTime defaultValue)
        {
            string   val = get_value(applicationId, name);
            DateTime tm  = defaultValue;

            if (!string.IsNullOrEmpty(val))
            {
                string[] t = val.Split(':');
                int      n = 0;
                if (t.Length >= 2 && int.TryParse(t[0], out n) && n >= 0 && n <= 23 && int.TryParse(t[1], out n) && n >= 0 && n <= 59)
                {
                    tm = new DateTime(defaultValue.Year, defaultValue.Month, defaultValue.Day,
                                      int.Parse(t[0]), int.Parse(t[1]), 0);
                }
            }

            return(tm);
        }
Ejemplo n.º 5
0
        private static string get_value(Guid?applicationId, RVSettingsItem name, string defaultValue = "")
        {
            if (!applicationId.HasValue)
            {
                applicationId = Guid.Empty;
            }

            if (SettingsDic.ContainsKey(applicationId.Value) && SettingsDic[applicationId.Value].ContainsKey(name))
            {
                return(string.IsNullOrEmpty(SettingsDic[applicationId.Value][name]) ? defaultValue : SettingsDic[applicationId.Value][name]);
            }
            else
            {
                Dictionary <RVSettingsItem, string> dic = get_value(applicationId.Value, new List <RVSettingsItem>()
                {
                    name
                });
                string value = !dic.ContainsKey(name) ? string.Empty : dic[name];
                return(string.IsNullOrEmpty(value) ? defaultValue : value);
            }
        }
Ejemplo n.º 6
0
        private static int _GetDurationInSeconds(Guid?applicationId, RVSettingsItem name,
                                                 int defaultDuration, int maxDuration)
        {
            int val = 0;

            int hours = 0, minutes = 0, seconds = 0;

            string[] timeElements = (get_value(applicationId, name)).Split(':');

            if (timeElements.Length == 3 && int.TryParse(timeElements[0], out hours) &&
                int.TryParse(timeElements[1], out minutes) && int.TryParse(timeElements[2], out seconds))
            {
                val = (hours * 60 * 60) + (minutes * 60) + seconds;
            }
            else
            {
                val = defaultDuration;
            }

            val = val <= 0 ? defaultDuration : val;

            return(maxDuration > 0 && val > maxDuration ? maxDuration : val);
        }