public static int InserWebViewLog(WebViewLog entity)
        {
            var sql = @"INSERT INTO WebViewLog (IPAddress, Controller, [Action], Parameter, UserAgent, IsLogin, CreateTime) 
                        VALUES (@IPAddress, @Controller, @Action, @Parameter, @UserAgent, @IsLogin, GETDATE())";

            return(Execute(ConnectionStrings.Scan, sql, entity));
        }
Exemple #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            WebViewLog log = new WebViewLog();

            log.IPAddress  = filterContext.RequestContext.HttpContext.Request.UserHostAddress;
            log.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            log.UserAgent  = filterContext.RequestContext.HttpContext.Request.UserAgent;
            log.Action     = filterContext.ActionDescriptor.ActionName;

            var    arrParameter = filterContext.ActionDescriptor.GetParameters();
            string paramter     = "?";

            foreach (var pName in arrParameter)
            {
                var parameterValue = filterContext.ActionParameters[pName.ParameterName];

                paramter += pName.ParameterName + "=" + parameterValue.ToString() + "&";
            }
            log.Parameter = paramter;

            var uNameStr = filterContext.RequestContext.HttpContext.Request.Cookies.AllKeys.FirstOrDefault(x => x == "uName");
            var tokenStr = filterContext.RequestContext.HttpContext.Request.Cookies.AllKeys.FirstOrDefault(x => x == "token");

            if (uNameStr != null && tokenStr != null)
            {
                var uName = filterContext.RequestContext.HttpContext.Request.Cookies.Get("uName");
                var token = filterContext.RequestContext.HttpContext.Request.Cookies.Get("token");

                var guid = CacheTools.GetCache <string>(uName.Value);

                if (token.Value == guid)
                {
                    log.IsLogin = 1;
                    ScanDataBaseManager.InserWebViewLog(log);
                    base.OnActionExecuting(filterContext);
                }
                else
                {
                    ScanDataBaseManager.InserWebViewLog(log);
                    filterContext.RequestContext.HttpContext.Response.Redirect("/webav/NoRights");
                }
            }
            else
            {
                ScanDataBaseManager.InserWebViewLog(log);
                filterContext.RequestContext.HttpContext.Response.Redirect("/webav/NoRights");
            }

            ScanDataBaseManager.InserWebViewLog(log);
        }
Exemple #3
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            WebViewLog log = new WebViewLog();

            log.IPAddress  = filterContext.RequestContext.HttpContext.Request.UserHostAddress;
            log.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            log.UserAgent  = filterContext.RequestContext.HttpContext.Request.UserAgent;
            log.Action     = filterContext.ActionDescriptor.ActionName;

            var    arrParameter = filterContext.ActionDescriptor.GetParameters();
            string paramter     = "?";

            foreach (var pName in arrParameter)
            {
                var parameterValue = filterContext.ActionParameters[pName.ParameterName];

                paramter += pName.ParameterName + "=" + parameterValue.ToString() + "&";
            }
            log.Parameter = paramter;

            ScanDataBaseManager.InserWebViewLog(log);
            base.OnActionExecuting(filterContext);
        }
        public static int InserWebViewLog(WebViewLog entity)
        {
            var sql = string.Format(@"INSERT INTO WebViewLog (IPAddress, Controller, [Action], Parameter, UserAgent, IsLogin, CreateTime) VALUES ('{0}', '{1}', '{5}', '{2}', '{3}', {4}, GETDATE())", entity.IPAddress, entity.Controller, entity.Parameter, entity.UserAgent, entity.IsLogin, entity.Action);

            return(SqlHelper.ExecuteNonQuery(con, CommandType.Text, sql));
        }