Ejemplo n.º 1
0
        public IActionResult FlowMonitorFrame()
        {
            base.SetGlobalViewBag();
            string         UserId      = CPExpressionHelper.Instance.RunCompile("${CPUser.UserId()}");
            string         UserRoleIds = CPExpressionHelper.Instance.RunCompile("${CPUser.UserRoleIds()}");
            CPFlowTemplate template    = CPFlowTemplate.Instance();
            List <int>     roleIdCol   = new List <int>();

            UserRoleIds.Split(',').ToList().ForEach(t => {
                if (string.IsNullOrEmpty(t) == false)
                {
                    roleIdCol.Add(int.Parse(t));
                }
            });
            List <CPFlow> col        = template.GetHasMonitorRightFlow(int.Parse(UserId), roleIdCol);
            string        flowVerIds = "";

            col.ForEach(t => {
                if (string.IsNullOrEmpty(flowVerIds))
                {
                    flowVerIds = t.FlowVerId.ToString();
                }
                else
                {
                    flowVerIds += "," + t.FlowVerId.ToString();
                }
            });
            if (string.IsNullOrEmpty(flowVerIds))
            {
                flowVerIds = "-1";
            }
            CPAppContext.GetHttpContext().Session.SetString("UserHasMonitorRightFlowVerIds", flowVerIds);
            return(Redirect(CPAppContext.CPWebRootPath() + "/Plat/Grid/GridView?GridCode=" + CPAppContext.QueryString <string>("GridCode")));
        }
Ejemplo n.º 2
0
        public IActionResult LoginOut()
        {
            CPAppContext.GetHttpContext().Session.Clear();
            string loginUrl = CPAppContext.GetPara("LoginUrl");

            if (string.IsNullOrEmpty(loginUrl))
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                return(Redirect(CPAppContext.CPWebRootPath() + loginUrl));
            }
            //
        }
Ejemplo n.º 3
0
        public IActionResult FlowStartFrame()
        {
            base.SetGlobalViewBag();
            string         UserId      = CPExpressionHelper.Instance.RunCompile("${CPUser.UserId()}");
            string         UserRoleIds = CPExpressionHelper.Instance.RunCompile("${CPUser.UserRoleIds()}");
            string         DepIds      = CPExpressionHelper.Instance.RunCompile("${CPUser.DepIds()}");
            CPFlowTemplate template    = CPFlowTemplate.Instance();
            List <int>     roleIdCol   = new List <int>();
            List <int>     depIdCol    = new List <int>();

            UserRoleIds.Split(',').ToList().ForEach(t => {
                if (string.IsNullOrEmpty(t) == false)
                {
                    roleIdCol.Add(int.Parse(t));
                }
            });
            DepIds.Split(',').ToList().ForEach(t => {
                if (string.IsNullOrEmpty(t) == false)
                {
                    depIdCol.Add(int.Parse(t));
                }
            });
            List <CPFlow> col        = template.GetHasStartRightFlow(int.Parse(UserId), roleIdCol, depIdCol);
            string        flowVerIds = "";

            col.ForEach(t => {
                if (string.IsNullOrEmpty(flowVerIds))
                {
                    flowVerIds = t.FlowVerId.ToString();
                }
                else
                {
                    flowVerIds += "," + t.FlowVerId.ToString();
                }
            });
            if (string.IsNullOrEmpty(flowVerIds))
            {
                flowVerIds = "-1";
            }
            CPAppContext.GetHttpContext().Session.SetString("UserHasRightFlowVerIds", flowVerIds);
            return(View());
        }
Ejemplo n.º 4
0
        public CPWebApiBaseReturnEntity SetRoleModuleIdsToSession(int RoleId, int SysId, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            try
            {
                List <CPPortalModule> col = CPModuleEngine.Instance(CurUserId).GetModulesWithRight(new List <int>()
                {
                    RoleId
                }, SysId);
                string ids = "";
                col.ForEach(t =>
                {
                    if (string.IsNullOrEmpty(ids))
                    {
                        ids = t.Id.ToString();
                    }
                    else
                    {
                        ids += "," + t.Id.ToString();
                    }
                });
                CPAppContext.GetHttpContext().Session.SetString("CurUserModuleRightInRole", ids);
                re.Result = true;
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
Ejemplo n.º 5
0
        public GetGridDataReturn GetGridData(string GridCode, int CurUserId, string CurUserIden,
                                             int page, int pageSize, string OtherCondition)
        {
            base.SetHeader();
            GridCode    = CPAppContext.FormatSqlPara(GridCode);
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            //OtherCondition = CPAppContext.FormatSqlPara(OtherCondition);
            if (OtherCondition != null)
            {
                OtherCondition = System.Web.HttpUtility.UrlDecode(OtherCondition);
                OtherCondition = OtherCondition.Replace("@", "%");
            }
            GetGridDataReturn re = new GetGridDataReturn();

            try
            {
                CPGrid Grid    = CPGridEngine.Instance(CurUserId).GetGrid(GridCode, true, true);
                string orderBy = "";
                #region 获取排序字段
                List <string> querys     = CPAppContext.GetHttpContext().Request.Query.Keys.Where(t => t.StartsWith("sort[")).ToList();
                var           queryCount = querys.Count(m => m.EndsWith("[field]"));
                for (int i = 0; i < queryCount; i++)
                {
                    //请查询字段和对应的值存储在一个字典中
                    string field = CPAppContext.QueryString <string>("sort[" + i + "][field]");
                    field = field.Replace("Column", "");
                    List <CPGridColumn> colTmp = Grid.ColumnCol.Where(c => c.Id.Equals(int.Parse(field))).ToList();
                    if (colTmp.Count > 0)
                    {
                        field = colTmp[0].FieldName;
                    }
                    string fieldValue = CPAppContext.QueryString <string>("sort[" + i + "][dir]");
                    if (string.IsNullOrEmpty(orderBy))
                    {
                        orderBy = field + " " + fieldValue;
                    }
                    else
                    {
                        orderBy += "," + field + " " + fieldValue;
                    }
                }
                #endregion


                if (this.CheckUserIden(CurUserId, CurUserIden) == false)
                {
                    re.Result   = false;
                    re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                    return(re);
                }

                try
                {
                    int       recordSize = 0;
                    DataTable dt         = CPGridEngine.Instance(CurUserId).ReadDataAndFormat(Grid, page, pageSize, OtherCondition, orderBy, out recordSize);
                    re.RecordSize = recordSize;
                    re.DataJson   = CPUtils.DataTable2Json(dt);
                    re.Result     = true;
                }
                catch (Exception ex)
                {
                    re.Result   = false;
                    re.ErrorMsg = ex.Message.ToString();
                }

                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }
Ejemplo n.º 6
0
        private void AddUserSession(COUserIdentity userIden, COUser user)
        {
            CPAppContext.GetHttpContext().Session.SetString("UserId", userIden.UserId.ToString());
            CPAppContext.GetHttpContext().Session.SetString("UserKey", userIden.UserKey.ToString());
            CPAppContext.GetHttpContext().Session.SetString("UserName", user.UserName);
            CPAppContext.GetHttpContext().Session.SetString("UserLoginName", user.LoginName.ToString());
            if (string.IsNullOrEmpty(user.UserPhotoPath))
            {
                CPAppContext.GetHttpContext().Session.SetString("UserPhotoPath", "");
            }
            else
            {
                CPAppContext.GetHttpContext().Session.SetString("UserPhotoPath", user.UserPhotoPath.ToString());
            }
            //获取用户所在的角色
            List <CORole> userRole  = this.GetUserStaticRoles(user.Id);
            string        RoleIds   = "";
            string        RoleNames = "";

            userRole.ForEach(t => {
                if (string.IsNullOrEmpty(RoleIds))
                {
                    RoleIds   = t.Id.ToString();
                    RoleNames = t.RoleName;
                }
                else
                {
                    RoleIds   += "," + t.Id.ToString();
                    RoleNames += "," + t.RoleName;
                }
            });
            CPAppContext.GetHttpContext().Session.SetString("RoleIds", RoleIds.ToString());
            CPAppContext.GetHttpContext().Session.SetString("RoleNames", RoleNames.ToString());
            //获取部门
            List <CODep> depCol   = this.GetDepByUser(user.Id);
            string       DepIds   = "";
            string       DepNames = "";

            depCol.ForEach(t => {
                if (string.IsNullOrEmpty(DepIds))
                {
                    DepIds   = t.Id.ToString();
                    DepNames = t.DepName;
                }
                else
                {
                    DepIds   += "," + t.Id.ToString();
                    DepNames += "," + t.DepName;
                }
            });
            CPAppContext.GetHttpContext().Session.SetString("DepIds", DepIds.ToString());
            CPAppContext.GetHttpContext().Session.SetString("DepNames", DepNames.ToString());
            //获取当前用户拥有管理员权限的子系统
            List <CPSystem> sysCol = CPSystemHelper.Instance().GetSystems();
            string          sysIds = "";

            sysCol.ForEach(t => {
                if (string.IsNullOrEmpty(t.AdminUserIds))
                {
                    return;
                }
                if (t.AdminUserIds.Split(',').Contains(user.Id.ToString()))
                {
                    if (string.IsNullOrEmpty(sysIds))
                    {
                        sysIds = t.Id.ToString();
                    }
                    else
                    {
                        sysIds += "," + t.Id.ToString();
                    }
                }
            });
            CPAppContext.GetHttpContext().Session.SetString("UserAdminSysIds", sysIds.ToString());
        }