public override void OnActionExecuting(ActionExecutingContext context)
        {
            var currentUserResult = Sys_UserService.GetCurrentUserBySession();

            if (currentUserResult.flag)
            {
                CurrentUser = new Sys_UserDto
                {
                    Id       = currentUserResult.data.Id,
                    UserName = currentUserResult.data.UserName
                };
                SysService.currentUserId = CurrentUser.Id.ToString();
                if (!WebHelper.IsAjax(context.HttpContext))
                {
                    var operationLogService = ServiceLocator.Get <ISys_OperationLogService>();
                    operationLogService.AddAsync(new Sys_OperationLogDto
                    {
                        ClientIP             = WebHelper.GetClientIP(),
                        ClientMac            = WebHelper.GetClientMac(),
                        Description          = "访问",
                        OperationDescription = "访问",
                        OperationUrl         = context.HttpContext.Request.Path,
                        UserId   = CurrentUser.Id,
                        UserName = CurrentUser.UserName
                    });
                }
            }
            else
            {
                if (!WebHelper.IsAjax(context.HttpContext))
                {
                    var operationLogService = ServiceLocator.Get <ISys_OperationLogService>();
                    operationLogService.AddAsync(new Sys_OperationLogDto
                    {
                        ClientIP             = WebHelper.GetClientIP(),
                        ClientMac            = WebHelper.GetClientMac(),
                        Description          = "访问",
                        OperationDescription = "访问",
                        OperationUrl         = context.HttpContext.Request.Path,
                        UserId   = 0,
                        UserName = "******"
                    });
                    CurrentUser = null;
                }
            }
            base.OnActionExecuting(context);
        }
Exemple #2
0
        public static Hashtable Search(string key, int index, int size, string sortField, string sortOrder)
        {
            string sqland = "";
            //数据权限
            string isadmin = Sys_UserService.GetSession("FUserType").ToString();

            if (isadmin != "1")
            {
                //数据权限
                string customerid = Sys_UserService.GetSession("FCustomerID").ToString();
                sqland += " and FCustomerID = '" + customerid + "'";
            }



            string sql = @"select * from PumpManager where FDeleted !='1' " + sqland;

            if (String.IsNullOrEmpty(sortField) == false)
            {
                if (sortOrder != "desc")
                {
                    sortOrder = "asc";
                }
                sql += " order by " + sortField + " " + sortOrder;
            }

            DataTable dt = DBUtil.SelectDataTablePager(sql, index, size);

            dt.Columns.Add("DataMain");


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["FIsOnline"].ToString() == "1")
                {
                    string    id       = dt.Rows[i]["ID"].ToString();
                    String    sqlalarm = "select * from  T_Alarm where FPumpID='" + id + "' and FStatus='1' ";
                    DataTable dtalarm  = Dal.DBUtil.SelectDataTable(sqlalarm);

                    if (dtalarm.Rows.Count > 0)
                    {
                        dt.Rows[i]["FIsOnline"] = "2";
                    }
                }

                String    _FPumpID = dt.Rows[i]["ID"].ToString();
                String    sql_data = "select top 1 * from  T_DataMain  where FPumpID='" + _FPumpID + "'";
                DataTable dt_data  = Dal.DBUtil.SelectDataTable(sql_data);

                if (dt_data.Rows.Count == 1)
                {
                    dt.Rows[i]["DataMain"] = new Commond.Json().Dtb2Json(dt_data).ToString();
                }
            }

            ArrayList data = DBUtil.DataTable2ArrayList(dt);

            int count = DBUtil.ExecuteScalar(sql);

            Hashtable result = new Hashtable();

            result["data"]  = data;
            result["total"] = count;

            return(result);
        }
Exemple #3
0
 public static void SetService()
 {
     Sys_InfoService = new Sys_InfoService(Autofac.AutofacContainer.GetInstance().GetObject <ISys_InfoDao>());
     Sys_UserService = new Sys_UserService(Autofac.AutofacContainer.GetInstance().GetObject <ISys_UserDao>());
 }