Esempio n. 1
0
        /// <summary>
        /// 取有权限的操作列表(仅资源权限)
        /// </summary>
        /// <param name="code"></param>
        /// <param name="className"></param>
        /// <returns></returns>
        public EntityData GetOperationEntityDataOfResource(string code, string className)
        {
            try
            {
                string stationCodes = BuildStationCodeString(this.BuildStationCodes());

                object[] ooo = new object[] { code
                                              , SystemClassDescription.GetItemClassCode(className)
                                              , this.UserCode
                                              , stationCodes
                                              , SystemClassDescription.GetItemTableName(className)
                                              , SystemClassDescription.GetItemKeyColumnName(className)
                                              , SystemClassDescription.GetItemTypeColumnName(className)
                                              , SystemClassDescription.GetItemCreateUserColumnName(className) };

                string selfAccessString = String.Format(" ( AccessRange.ResourceCode = ( Select ResourceCode from Resource where RelationCode='{0}' and ClassCode='{1}' ) and ( ( AccessRange.AccessRangeType=0 and AccessRange.relationCode = '{2}' )  or ( AccessRange.AccessRangeType=1 and AccessRange.relationCode in ( {3} ) and ( RoleLevel <> 1 or RoleLevel is null ) )   or ( AccessRange.AccessRangeType=1 and AccessRange.relationCode in ( {3} ) and  RoleLevel = 1 and {4}.{7}='{2}'  )  )  ) "
                                                        , ooo);

                string sss = String.Format("select accessrange.* from accessrange , {4} where substring (AccessRange.operationCode,1,4 )='{1}' and {4}.{5} = '{0}' and ( " + selfAccessString + " )"
                                           , ooo);

                QueryAgent qa     = new QueryAgent();
                EntityData entity = qa.FillEntityData("AccessRange", sss);
                qa.Dispose();
                return(entity);
            }
            catch (Exception ex)
            { throw ex; }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取用户对某个资源类的权限表
        /// </summary>
        /// <param name="className"></param>
        /// <returns></returns>
        public ArrayList GetClassRight(string className)
        {
            try
            {
                string stationCodes = BuildStationCodeString(this.BuildStationCodes());

                object[] ooo = new object[] { SystemClassDescription.GetItemClassCode(className)
                                              , this.UserCode
                                              , stationCodes };

                string s0 = String.Format(" ( AccessRange.AccessRangeType=0 and AccessRange.relationCode = '{1}' ) "
                                          , ooo);
                string s1 = "";
                if (stationCodes != "")
                {
                    s1 = String.Format(" or ( AccessRange.AccessRangeType=1 and AccessRange.relationCode in ( {2} ) ) "
                                       , ooo);
                }

                string sss = String.Format("select distinct(operationCode) from accessrange where substring(operationcode,1,4)='{0}' and  isnull( groupCode ,'') <> '' and  (  {1}  {2}  )"
                                           , new object[] { SystemClassDescription.GetItemClassCode(className), s0, s1 });
                QueryAgent qa     = new QueryAgent();
                DataSet    entity = qa.ExecSqlForDataSet(sss);
                qa.Dispose();

                ArrayList ar = new ArrayList();
                foreach (DataRow dr in entity.Tables[0].Rows)
                {
                    if (!dr.IsNull("OperationCode"))
                    {
                        string oCode = (string)dr["OperationCode"];
                        if (!ar.Contains(oCode))
                        {
                            ar.Add(oCode);
                        }
                    }
                }
                entity.Dispose();
                return(ar);
            }
            catch (Exception ex)
            { throw ex; }
        }