Beispiel #1
0
        public static bool IsValid(ActionTypeEnum actionType)
        {
            HttpContext context = HttpContext.Current;

            if (context.Request.Browser.Crawler)
            {
                return(false);
            }

            string key = actionType.ToString() + context.Request.UserHostAddress;
            var    hit = (HitInfo)(context.Cache[key] ?? new HitInfo());

            if (hit.Hits > (int)actionType)
            {
                return(false);
            }
            else
            {
                hit.Hits++;
            }

            if (hit.Hits == 1)
            {
                context.Cache.Add(key, hit, null, TimeZoneManager.DateTimeNow.AddMinutes(DURATION),
                                  System.Web.Caching.Cache.NoSlidingExpiration,
                                  System.Web.Caching.CacheItemPriority.Normal, null);
            }
            return(true);
        }
Beispiel #2
0
        public static bool IsValid(ActionTypeEnum actionType)
        {
            if (ConstantHelper.DisableDOSCheck)
            {
                return(true);
            }

            HttpContext context = HttpContext.Current;

            // We want crawler to index Dropthings
            //if( context.Request.Browser.Crawler ) return false;

            string key = actionType.ToString() + context.Request.UserHostAddress;

            var hit = (HitInfo)(context.Cache[key] ?? new HitInfo());

            if (hit.Hits > (int)actionType)
            {
                return(false);
            }
            else
            {
                hit.Hits++;
            }

            if (hit.Hits == 1)
            {
                context.Cache.Add(key, hit, null, DateTime.Now.AddMinutes(DURATION),
                                  System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
            }

            return(true);
        }
Beispiel #3
0
        public static void CreateActionStateCookie(HttpResponseBase response, ActionTypeEnum actionType, string message)
        {
            var cookie = new HttpCookie(Constants.ACTION_STATE_COOKIE);

            cookie.Values.Add(Constants.COOKIE_VALUE_ACTION_TYPE, actionType.ToString());
            var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));

            cookie.Values.Add(Constants.COOKIE_VALUE_MESSAGE, encodedMessage);
            response.Cookies.Add(cookie);
        }
        public DBResponseModel UpdateTriggerMaintenance(DBSetting dbSetting, CategoryEnum category, ActionTypeEnum actionType, string maintenanceValue)
        {
            string sQuery = string.Format(DBScripts.TRIGGERMAINTENANCE_UPDATE, DBParams.PARAM_MODIFIEDDATE, DBParams.PARAM_DOCTYPE, DBParams.PARAM_VALUE, DBParams.PARAM_STATUS);

            sQuery = DBHelper.Instance.QueryScript(DBTables.TABLE_TRIGGERMAINTENANCE, sQuery);

            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add(DBParams.PARAM_MODIFIEDDATE, DateTime.Now);
            param.Add(DBParams.PARAM_DOCTYPE, category.ToString().ToUpper());
            param.Add(DBParams.PARAM_VALUE, maintenanceValue);
            param.Add(DBParams.PARAM_STATUS, actionType.ToString().ToUpper());

            var response = DBHelper.Instance.Execute(dbSetting, sQuery, param);

            return(response);
        }
Beispiel #5
0
        public static bool IsValid( ActionTypeEnum actionType )
        {
            HttpContext context = HttpContext.Current;
            if( context.Request.Browser.Crawler ) return false;

            string key = actionType.ToString() + context.Request.UserHostAddress;

            var hit = (HitInfo)(context.Cache[key] ?? new HitInfo());

            if( hit.Hits > (int)actionType ) return false;
            else hit.Hits ++;

            if( hit.Hits == 1 )
                context.Cache.Add(key, hit, null, DateTime.Now.AddMinutes(DURATION), 
                    System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Normal, null);
            
            return true;
        }
 private Action(ActionTypeEnum actionTypeEnum)
 {
     Id   = (int)actionTypeEnum;
     Name = actionTypeEnum.ToString();
 }
        public DataTable GetTriggerMaintenance_ByMaintenanceValue(DBSetting dbSetting, CategoryEnum category, ActionTypeEnum actionType, string maintenanceValue)
        {
            string sQuery = string.Format(DBScripts.TRIGGERMAINTENANCE_GETLIST_BYMAINTENANCEVALUE, category.ToString().ToUpper(), maintenanceValue.ToString(), actionType.ToString().ToUpperInvariant());

            sQuery = DBHelper.Instance.QueryScript(DBTables.TABLE_TRIGGERMAINTENANCE, sQuery);

            DataTable dt = dbSetting.GetDataTable(sQuery, false);

            return(dt);
        }