示例#1
0
文件: User.cs 项目: riyuexing/rms
        /// <summary>
        /// 判断该用户是否能访问这个资源, 如果找不到该资源返回 true;
        /// </summary>
        /// <param name="code"></param>
        /// <param name="operationCode"></param>
        /// <returns></returns>
        public bool HasResourceRight(string code, string operationCode)
        {
            if (!AvailableFunction.isAvailableFunction(operationCode))
            {
                return(false);
            }

            string classCode    = operationCode.Substring(0, 4);
            string resourceCode = BLL.ResourceRule.GetResourceCode(code, classCode);

            if (resourceCode == "")
            {
                return(true);
            }
            AccessRangeStrategyBuilder sb = new AccessRangeStrategyBuilder();

            sb.AddStrategy(new Strategy(AccessRangeStrategyName.ResourceCode, resourceCode));
            ArrayList ar = new ArrayList();

            ar.Add(this.m_UserCode);
            ar.Add(BuildStationCodes());
            sb.AddStrategy(new Strategy(AccessRangeStrategyName.AccessRelation1, ar));
            sb.AddStrategy(new Strategy(AccessRangeStrategyName.OperationCode, operationCode));
            QueryAgent qa     = new QueryAgent();
            string     sql    = sb.BuildMainQueryString();
            EntityData entity = qa.FillEntityData("AccessRange", sql);

            qa.Dispose();
            bool canAccess = entity.HasRecord();

            entity.Dispose();
            return(canAccess);
        }
示例#2
0
文件: User.cs 项目: riyuexing/rms
        public string GetOperationType()
        {
            string temp = "";

            /*if(HasOperationRight("200101"))
             *      temp += "Y1";
             * if(HasOperationRight("200102"))
             *      temp += "Y2";
             * if(HasOperationRight("200103"))
             *      temp += "Y3";
             * if(HasOperationRight("200201"))
             *      temp += "N1";
             * if(HasOperationRight("200202"))
             *      temp += "N2";*/

            AccessRangeStrategyBuilder sb = new AccessRangeStrategyBuilder();
            ArrayList ar = new ArrayList();

            ar.Add(this.m_UserCode);
            ar.Add(BuildStationCodes());
            sb.AddStrategy(new Strategy(AccessRangeStrategyName.AccessRelation1, ar));
            sb.AddStrategy(new Strategy(AccessRangeStrategyName.OperationCodeIn, "'Y1','Y2','Y3','N1','N2'"));
            QueryAgent qa     = new QueryAgent();
            string     sql    = sb.BuildMainQueryString();
            EntityData entity = qa.FillEntityData("AccessRange", sql);

            qa.Dispose();

            for (int i = 0; i < entity.CurrentTable.Rows.Count; i++)
            {
                temp += "," + entity.CurrentTable.Rows[i]["OperationCode"].ToString();
            }
            return(temp);
        }
示例#3
0
        public static EntityData GetAccessRangeByGroupRelation(string GroupCode, string AccessRangeType, string RelationCode)
        {
            EntityData data2;

            try
            {
                AccessRangeStrategyBuilder builder = new AccessRangeStrategyBuilder();
                builder.AddStrategy(new Strategy(AccessRangeStrategyName.GroupCode, GroupCode));
                ArrayList pas = new ArrayList();
                pas.Add(AccessRangeType);
                pas.Add(RelationCode);
                builder.AddStrategy(new Strategy(AccessRangeStrategyName.AccessRelation0, pas));
                builder.AddOrder("OperationCode", true);
                string     queryString = builder.BuildQueryViewString();
                QueryAgent agent       = new QueryAgent();
                EntityData data        = agent.FillEntityData("AccessRange", queryString);
                agent.Dispose();
                data2 = data;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
示例#4
0
        public static string GetAccessRange(string code, string classCode, string operationCode, ref string userCodes, ref string userNames, ref string stationCodes, ref string stationNames)
        {
            string text3;

            try
            {
                userCodes    = "";
                userNames    = "";
                stationCodes = "";
                stationNames = "";
                string resourceCode = GetResourceCode(code, classCode);
                if (resourceCode != "")
                {
                    AccessRangeStrategyBuilder builder = new AccessRangeStrategyBuilder();
                    builder.AddStrategy(new Strategy(AccessRangeStrategyName.ResourceCode, resourceCode));
                    builder.AddStrategy(new Strategy(AccessRangeStrategyName.OperationCode, operationCode));
                    QueryAgent agent = new QueryAgent();
                    EntityData data  = agent.FillEntityData("AccessRange", builder.BuildMainQueryString());
                    agent.Dispose();
                    int count = data.CurrentTable.Rows.Count;
                    for (int i = 0; i < count; i++)
                    {
                        data.SetCurrentRow(i);
                        int    @int     = data.GetInt("AccessRangeType");
                        string userCode = data.GetString("RelationCode");
                        if (@int == 0)
                        {
                            if (userCodes != "")
                            {
                                userCodes = userCodes + ",";
                                userNames = userNames + ",";
                            }
                            userCodes = userCodes + userCode;
                            userNames = userNames + SystemRule.GetUserName(userCode);
                        }
                        else
                        {
                            if (stationCodes != "")
                            {
                                stationCodes = stationCodes + ",";
                                stationNames = stationNames + ",";
                            }
                            stationCodes = stationCodes + userCode;
                            stationNames = stationNames + SystemRule.GetStationName(userCode);
                        }
                    }
                    data.Dispose();
                }
                text3 = resourceCode;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text3);
        }
示例#5
0
        public static EntityData GetAccessRangeByResourceCode(string ResourceCode)
        {
            EntityData data2;

            try
            {
                AccessRangeStrategyBuilder builder = new AccessRangeStrategyBuilder();
                builder.AddStrategy(new Strategy(AccessRangeStrategyName.ResourceCode, ResourceCode));
                builder.AddOrder("OperationCode", true);
                string     queryString = builder.BuildQueryViewString();
                QueryAgent agent       = new QueryAgent();
                EntityData data        = agent.FillEntityData("AccessRange", queryString);
                agent.Dispose();
                data2 = data;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }