コード例 #1
0
ファイル: BusiItemManage.cs プロジェクト: hijushen/WindowDemo
        /// <summary>
        /// 返回该用户在该菜单中所能操作的环节
        /// </summary>
        /// <param name="user"></param>
        /// <param name="funCode"></param>
        /// <returns></returns>
        public string GetNodeIdByLoginUser(LoginUser user, string funCode)
        {
            string nodeId = string.Empty;
            string wfUserSql = string.Empty;
            if (user.CompanyType == CompanyTypeEnum.SHI || user.CompanyType == CompanyTypeEnum.XIAN)
            {
                ////角色条件
                string strRoleWhere = string.Empty;
                string[] roleAry = user.RoleId.Split(new char[] { ',' });
                for (int i = 0; i < roleAry.Length; i++)
                {
                    if (roleAry[i] != string.Empty)
                    {
                        strRoleWhere += string.Format(" or instr(',' || NodeRoleId || ',', ',{0},') <> 0", roleAry[i]);
                    }
                }
                ////部门条件
                string strDeptWhere = string.Empty;
                if (!string.IsNullOrEmpty(user.DepartCode))
                    strDeptWhere = string.Format(" or instr(',' || NodeDepartCode || ',', ',{0},') <> 0", user.DepartCode);

                wfUserSql = "select * from wf_node a left join wf_workflow b on a.flowid = b.flowid"
                       + " where (instr(',' || NodeUserId || ',', ',{0},') <> 0 "
                       + " {1} {2}) and a.functionCode = {3} and b.ccode = '{4}'";
                wfUserSql = string.Format(wfUserSql, user.UserId, strDeptWhere, strRoleWhere, funCode,
                    CommonHelper.GetSHICode(user.CompanyCode));
            }
            DataTable dt = OracleHelper.ExecuteDataTable(wfUserSql);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                nodeId += dt.Rows[i]["nodeid"].ToString();
                nodeId += ",";
            }
            if (nodeId != string.Empty) nodeId = nodeId.Substring(0, nodeId.Length - 1);
            return nodeId;
        }
コード例 #2
0
ファイル: BusiItemManage.cs プロジェクト: hijushen/WindowDemo
        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public Dictionary<string, string> GetNodeByLoginUser(LoginUser user)
        {
            string wfUserSql = string.Empty;
            Dictionary<string, string> nodeList = new Dictionary<string, string>();
            if (user.CompanyType == CompanyTypeEnum.SHI || user.CompanyType == CompanyTypeEnum.XIAN)
            {
                ////角色条件
                string strRoleWhere = string.Empty;
                string[] roleAry = user.RoleId.Split(new char[] { ',' });
                for (int i = 0; i < roleAry.Length; i++)
                {
                    if (roleAry[i] != string.Empty)
                    {
                        strRoleWhere += string.Format(" or instr(',' || NodeRoleId || ',', ',{0},') <> 0", roleAry[i]);
                    }
                }
                ////部门条件
                string strDeptWhere = string.Empty;
                if (!string.IsNullOrEmpty(user.DepartCode))
                    strDeptWhere = string.Format(" or instr(',' || NodeDepartCode || ',', ',{0},') <> 0", user.DepartCode);

                wfUserSql = "select * from wf_node a left join wf_workflow b on a.flowid = b.flowid"
                       + " where (instr(',' || NodeUserId || ',', ',{0},') <> 0 "
                       + " {1} {2}) and b.ccode = '{3}' and a.nodetype = 1";
                wfUserSql = string.Format(wfUserSql, user.UserId, strDeptWhere, strRoleWhere,
                    CommonHelper.GetSHICode(user.CompanyCode));
            }
            IDataReader dr = OracleHelper.ExecuteReader(wfUserSql);
            while (dr.Read())
            {
                if (!nodeList.ContainsKey(dr["nodeId"].ToString()))
                {
                    nodeList.Add(dr["nodeId"].ToString(), EnumHelper.GetFieldDescription(typeof(WorkFlowNode), int.Parse(dr["nodeId"].ToString())));
                }
            }
            dr.Close();
            return nodeList;
        }
コード例 #3
0
        /// <summary>
        /// 根据登录用户获取角色的集合
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public IList<Role> GetRoles(LoginUser user)
        {
            IList<Role> datalist = new List<Role>();

            string strSql = "select * from role where ((roletype = 1 and instr(RoleLevel,{0}) <> 0) or (roletype = 0 and ccode = '{1}')) order by RoleId";
            strSql = string.Format(strSql, ((int)user.CompanyType).ToString(), user.CompanyCode);
            IDataReader dr = OracleHelper.ExecuteReader(strSql);
            while (dr.Read())
            {
                Role roleEntity = new Role();
                roleEntity.RoleId = dr["RoleId"].ToString();
                roleEntity.RoleName = dr["RoleName"].ToString();
                roleEntity.DisplayName = dr["RoleName"].ToString();
                roleEntity.RoleKey = dr["RoleKey"].ToString();
                roleEntity.RoleType = dr["RoleType"].ToString();
                roleEntity.Description = dr["Description"].ToString();
                datalist.Add(roleEntity);
            }
            dr.Close();
            return datalist;
        }
コード例 #4
0
        /// <summary>
        /// 根据登录用户获取菜单权限。
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public IList<Function> GetFunction(LoginUser user)
        {
            IList<Function> datalist = new List<Function>();

            string strSql = string.Empty;
            //// 1 所有人默认菜单(个人管理)
            string allUserSql = "select * from function where Instr(FunctionLevel,'{0}') <> 0 and FunctionCode like '20%'";
            allUserSql = string.Format(allUserSql, ((int)user.CompanyType).ToString());

            //// 2 系统管理员
            string sysUserSql = string.Empty;
            if (user.RoleKey.Contains("SYSMANAGE"))
            {
                sysUserSql = "select * from function where Instr(FunctionLevel,'{0}') <> 0";
                sysUserSql = string.Format(sysUserSql, ((int)user.CompanyType).ToString());
            }

            //// 3 根据角色配置的菜单
            string roleUserSql = string.Empty;
            if (user.RoleId != string.Empty)
            {
                roleUserSql = "select b.* from roleandfunction a inner join  function b on a.functioncode = b.functioncode where a.roleid  in ({0})";
                roleUserSql = string.Format(roleUserSql, user.RoleId);
            }

            //// 4 流程用户(只针对市县用户)
            string wfUserSql = string.Empty;

            if (user.CompanyType == CompanyTypeEnum.SHI || user.CompanyType == CompanyTypeEnum.XIAN)
            {
                string nodeStr = string.Empty;

                List<WfNode> nodeList = this.GetNodeListByUser(user);

                var beginNode = from item in nodeList where item.WorkFlowNode == WorkFlowNode.TB select item;

                if (CommonManage.SystemStyle == SystemStyle.Stage)
                {
                    if (nodeList.Count > 0)
                    {
                        nodeStr = string.Join(",", (from item in nodeList
                                                    where item.FunctionCode != string.Empty
                                                    select item.FunctionCode).ToArray());
                        if (beginNode.Count<WfNode>() > 0)
                        {
                            nodeStr += ",3010";
                        }
                        wfUserSql = string.Format("select * from function where FunctionCode in (30,{0})", nodeStr);
                    }
                }

                if (CommonManage.SystemStyle == SystemStyle.WorkFlow)
                {
                    if (beginNode.Count<WfNode>() > 0)
                    {
                        nodeStr = ",3018";
                    }
                    wfUserSql = string.Format("select * from function where FunctionCode in (30,3019,3020,3021{0})", nodeStr);

                }
            }

            if (allUserSql != string.Empty) strSql += allUserSql + " union ";
            if (sysUserSql != string.Empty) strSql += sysUserSql + " union ";
            if (roleUserSql != string.Empty) strSql += roleUserSql + " union ";
            if (wfUserSql != string.Empty) strSql += wfUserSql + " union ";

            if (strSql != string.Empty) strSql = strSql.Substring(0, strSql.Length - 6);

            OracleDataReader dr = OracleHelper.ExecuteReader(strSql);

            while (dr.Read())
            {
                Function function = new Function();
                function.FunctionCode = dr["FunctionCode"].ToString();
                function.FunctionName = dr["FunctionName"].ToString();
                function.FunctionUrl = dr["FunctionUrl"].ToString();
                function.IsFristPage = dr["FristPage"].Equals("1");
                function.OrderNo = int.Parse(dr["OrderNo"].ToString());
                datalist.Add(function);
            }
            dr.Close();
            return datalist;
        }
コード例 #5
0
        /// <summary>
        /// 获取登录用户的环节权限
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public List<WfNode> GetNodeListByUser(LoginUser user)
        {
            List<WfNode> nodeList = new List<WfNode>();

            ////角色条件
            string strRoleWhere = string.Empty;
            string[] roleAry = user.RoleId.Split(new char[] { ',' });
            for (int i = 0; i < roleAry.Length; i++)
            {
                if (roleAry[i] != string.Empty)
                {
                    strRoleWhere += string.Format(" or instr(',' || NodeRoleId || ',', ',{0},') <> 0", roleAry[i]);
                }
            }
            ////部门条件
            string strDeptWhere = string.Empty;
            if (!string.IsNullOrEmpty(user.DepartCode))
            {
                strDeptWhere = string.Format(" or instr(',' || NodeDepartCode || ',', ',{0},') <> 0", user.DepartCode);
            }

            string strSql = "select * from wf_node where instr(',' || NodeUserId || ',', ',{0},') <> 0 "
                   + " {1} {2} ";
            strSql = string.Format(strSql, user.UserId, strDeptWhere, strRoleWhere);

            IDataReader dr = OracleHelper.ExecuteReader(strSql);
            while (dr.Read())
            {
                WfNode node = new WfNode();
                node.NodeId = dr["nodeId"].ToString();
                node.NodeType = (NodeType)EnumHelper.StringValueToEnum(typeof(NodeType), dr["nodeType"].ToString());
                node.FunctionCode = dr["FunctionCode"].ToString();
                nodeList.Add(node);
            }
            dr.Close();
            return nodeList;
        }