Пример #1
0
        /// <summary>
        /// fill module accessright from datarow
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="allowAccessActionList"></param>
        /// <param name="accessRightDA"></param>
        /// <returns></returns>
        private ModuleRightModel FillModuleRightModel(DataRow dr, List <string> allowAccessActionList, AccessRightDA accessRightDA)
        {
            ModuleRightModel mrModel = new ModuleRightModel();

            mrModel.ModuleCode = CommUtil.ConvertObjectToString(dr["code"]);
            mrModel.ModuleName = CommUtil.ConvertObjectToString(dr["name"]);

            DataTable dtAccessRight             = accessRightDA.GetAccessRightByModuleCode(dr["code"].ToString());
            Dictionary <string, bool> dicAction = new Dictionary <string, bool>();

            for (int j = 0; j < dtAccessRight.Rows.Count; j++)
            {
                DataRow drAction = dtAccessRight.Rows[j];
                if (drAction["name"] != null)
                {
                    if (allowAccessActionList.Contains(mrModel.ModuleCode + "_" + drAction["code"].ToString()))
                    {
                        dicAction[drAction["name"].ToString()] = true;
                    }
                    else
                    {
                        dicAction[drAction["name"].ToString()] = false;
                    }
                }
            }
            mrModel.DicAction = dicAction;
            return(mrModel);
        }
Пример #2
0
        /// <summary>
        /// Get all module accessright
        /// </summary>
        /// <param name="allowAccessActionList"></param>
        /// <returns></returns>
        private List <ModuleRightModel> GetAllModule(List <string> allowAccessActionList)
        {
            ModuleDA      moduleDA      = null;
            AccessRightDA accessRightDA = null;

            List <ModuleRightModel> moduleRightList = new List <ModuleRightModel>();
            DataTable dtAllModule = new DataTable();

            try
            {
                moduleDA      = new ModuleDA();
                accessRightDA = new AccessRightDA();
                dtAllModule   = moduleDA.GetAllLevel1Module();
                for (int i = 0; i < dtAllModule.Rows.Count; i++)
                {
                    DataRow dr = dtAllModule.Rows[i];
                    if (dr["code"] != null)
                    {
                        ModuleRightModel mrModel = FillModuleRightModel(dr, allowAccessActionList, accessRightDA);

                        if (CommUtil.ConvertObjectToBool(dr["IsFatherNode"]))
                        {
                            mrModel.SubModule = GetSubModule(moduleDA, accessRightDA, allowAccessActionList, mrModel.ModuleCode, 1);
                        }
                        moduleRightList.Add(mrModel);
                    }
                }
            }
            finally
            {
                if (accessRightDA != null)
                {
                    accessRightDA.CloseConnection();
                }
                if (moduleDA != null)
                {
                    moduleDA.CloseConnection();
                }
            }
            return(moduleRightList);
        }
Пример #3
0
        /// <summary>
        /// get sub module accessright
        /// </summary>
        /// <param name="allowAccessActionList"></param>
        /// <param name="moduleCode"></param>
        /// <param name="deep"></param>
        /// <returns></returns>
        private List <ModuleRightModel> GetSubModule(ModuleDA moduleDA, AccessRightDA accessRightDA, List <string> allowAccessActionList, string moduleCode, int deep)
        {
            List <ModuleRightModel> moduleRightList = new List <ModuleRightModel>();

            DataTable dtAllModule = moduleDA.GetModuleByFatherCode(moduleCode);

            for (int i = 0; i < dtAllModule.Rows.Count; i++)
            {
                DataRow dr = dtAllModule.Rows[i];
                if (dr["code"] != null)
                {
                    ModuleRightModel mrModel = FillModuleRightModel(dr, allowAccessActionList, accessRightDA);

                    if (CommUtil.ConvertObjectToBool(dr["IsFatherNode"]) && deep <= 5)
                    {
                        mrModel.SubModule = GetSubModule(moduleDA, accessRightDA, allowAccessActionList, mrModel.ModuleCode, deep);
                    }
                    moduleRightList.Add(mrModel);
                }
            }
            return(moduleRightList);
        }