Esempio n. 1
0
        public static int UserActivityValidUntil(UserActivityWhat activityWhat)
        {
            UserActivitySettings settings = UserActivityLoadSettings();

            if (settings.ActivitySetting.ContainsKey(activityWhat))
            {
                return(settings.ActivitySetting[activityWhat]);
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 2
0
        private static UserActivitySettings UserActivityLoadSettings()
        {
            UserActivitySettings settings = HttpRuntime.Cache["UserActivitySettings"] as UserActivitySettings;

            if (settings == null)
            {
                settings = new UserActivitySettings();
                settings.ActivitySetting = new Dictionary <UserActivityWhat, int>(10);
                settings.MaximalAmount   = 0;

                try
                {
                    settings.MaximalAmount = LoadDataAccessConfig().SelectSingleNode("root/UserActivitySettings/MaximalAmount").InnerText.ToInt32(25);

                    XmlNode xmlValid = LoadDataAccessConfig().SelectSingleNode("root/UserActivitySettings/Default/ValidUntil");
                    if (xmlValid != null)
                    {
                        TimeSpan tisDefault = xmlValid.InnerText.ToTimeSpan();
                        if (tisDefault.TotalMinutes >= 1)
                        {
                            foreach (UserActivityWhat what in Enum.GetValues(typeof(UserActivityWhat)))
                            {
                                xmlValid = LoadDataAccessConfig().SelectSingleNode(string.Format("root/UserActivitySettings/{0}/ValidUntil", what.ToString()));
                                if (xmlValid != null)
                                {
                                    TimeSpan timeSpan = xmlValid.InnerText.ToTimeSpan();
                                    if (timeSpan.TotalMinutes >= 1)
                                    {
                                        settings.ActivitySetting.Add(what, Convert.ToInt32(timeSpan.TotalMinutes));
                                    }
                                }
                                else
                                {
                                    settings.ActivitySetting.Add(what, Convert.ToInt32(tisDefault.TotalMinutes));
                                }
                            }
                        }
                    }
                }
                catch
                {
                    // do nothing
                }
                HttpRuntime.Cache.Insert("UserActivitySettings", settings);
            }

            return(settings);
        }
Esempio n. 3
0
        public static bool UserActivityIsActivityActiv(UserActivityWhat activityWhat)
        {
            UserActivitySettings settings = UserActivityLoadSettings();

            return(settings.ActivitySetting.ContainsKey(activityWhat));
        }