Exemple #1
0
        public static List <RoleUser> GetRoles(string userId)
        {
            List <RoleUser> list = new List <RoleUser>();

            DataRowView[] array = ((RoleUserCache) new RoleUserCache().GetData()).dvRoleUserBy_UserId.FindRows(userId);
            for (int i = 0; i < array.Length; i++)
            {
                DataRowView dataRowView = array[i];
                RoleUser    roleUser    = new RoleUser();
                RoleUser    @object     = RoleUserUtils.GetObject(dataRowView.Row);
                list.Add(@object);
            }
            return(list);
        }
Exemple #2
0
        public static UserModulePermission GetUserModulePermission(string userId, int amId)
        {
            UserModulePermission modulePermission = new UserModulePermission();
            User user = UserUtils.GetUser(userId);
            bool flag = user == null;
            UserModulePermission result;

            if (flag)
            {
                result = modulePermission;
            }
            else
            {
                Module module = ModuleUtils.GetModule(amId);
                bool   flag2  = module == null;
                if (flag2)
                {
                    result = modulePermission;
                }
                else
                {
                    modulePermission.UserId = user.UserId;
                    modulePermission.AmId   = module.MdId;
                    bool flag3 = (user.Type == UserType.S && amId >= 102010001 && amId <= 102019999) || !ModuleUtils.IsRequirePermission(module);
                    if (flag3)
                    {
                        modulePermission.View = (modulePermission.Insert = (modulePermission.Edit = (modulePermission.Delete = (modulePermission.Print = (modulePermission.Design = true)))));
                        result = modulePermission;
                    }
                    else
                    {
                        Permission permission = PermissionUtils.GetPermission(PermissionType.U, userId, amId);
                        bool       flag4      = permission != null;
                        if (flag4)
                        {
                            modulePermission.Insert = permission.Insert;
                            modulePermission.Edit   = permission.Edit;
                            modulePermission.Delete = permission.Delete;
                            modulePermission.Print  = permission.Print;
                            modulePermission.View   = permission.View;
                            modulePermission.Design = permission.Design;
                            modulePermission.View   = (modulePermission.Insert || modulePermission.Edit || modulePermission.Delete || modulePermission.Print || modulePermission.View || modulePermission.Design);
                        }
                        foreach (RoleUser roleUser in RoleUserUtils.GetRoles(userId))
                        {
                            Permission permission2 = PermissionUtils.GetPermission(PermissionType.R, roleUser.RoleId, amId);
                            bool       flag5       = permission2 != null;
                            if (flag5)
                            {
                                modulePermission.Insert = (permission2.Insert || modulePermission.Insert);
                                modulePermission.Edit   = (permission2.Edit || modulePermission.Edit);
                                modulePermission.Delete = (permission2.Delete || modulePermission.Delete);
                                modulePermission.Print  = (permission2.Print || modulePermission.Print);
                                modulePermission.View   = (permission2.View || modulePermission.View);
                                modulePermission.Design = (permission2.Design || modulePermission.Design);
                                modulePermission.View   = (modulePermission.Insert || modulePermission.Edit || modulePermission.Delete || modulePermission.Print || modulePermission.View || modulePermission.Design);
                            }
                        }
                        result = modulePermission;
                    }
                }
            }
            return(result);
        }
Exemple #3
0
        public static string GetParamValue(int amId, string pmId)
        {
            string str  = string.Empty;
            bool   flag = string.IsNullOrEmpty(pmId);

            if (flag)
            {
                throw new Exception("参数名不允许为空");
            }
            pmId = pmId.ToUpper();
            bool flag2 = amId == 0 && LogicContext.Current != null && LogicContext.Current.AmId != 0;

            if (flag2)
            {
                amId = LogicContext.Current.AmId;
            }
            bool flag3 = ModuleUtils.IsExtModule(amId);

            if (flag3)
            {
            }
            Parameter parameter = ParameterUtils.GetParameter(pmId);
            bool      flag4     = parameter == null;

            if (flag4)
            {
                throw new Exception(string.Format("参数【{0}】不存在,无法获取对应参数值!", pmId.ToString().Trim()));
            }
            bool   flag5 = parameter != null && parameter.Type != ParameterType.S;
            string result;

            if (flag5)
            {
                string userId = LogicContext.Current.UserId;
                bool   flag6  = UserUtils.GetUser(userId) == null;
                if (flag6)
                {
                    result = string.Empty;
                    return(result);
                }
                List <RoleUser> roles    = RoleUserUtils.GetRoles(userId);
                PmConfig        pmConfig = PmConfigUtils.GetPmConfig("", userId, amId, pmId);
                bool            flag7    = pmConfig != null;
                if (flag7)
                {
                    result = pmConfig.Value;
                    return(result);
                }
                foreach (RoleUser roleUser in roles)
                {
                    PmConfig pmConfig2 = PmConfigUtils.GetPmConfig(roleUser.RoleId, "", amId, pmId);
                    bool     flag8     = pmConfig2 != null;
                    if (flag8)
                    {
                        result = pmConfig2.Value;
                        return(result);
                    }
                }
                PmConfig pmConfig3 = PmConfigUtils.GetPmConfig("", userId, 0, pmId);
                bool     flag9     = pmConfig3 != null;
                if (flag9)
                {
                    result = pmConfig3.Value;
                    return(result);
                }
                foreach (RoleUser roleUser2 in roles)
                {
                    PmConfig pmConfig4 = PmConfigUtils.GetPmConfig(roleUser2.RoleId, "", 0, pmId);
                    bool     flag10    = pmConfig4 != null;
                    if (flag10)
                    {
                        result = pmConfig4.Value;
                        return(result);
                    }
                }
                PmConfig pmConfig5 = PmConfigUtils.GetPmConfig("", "", amId, pmId);
                bool     flag11    = pmConfig5 != null;
                if (flag11)
                {
                    result = pmConfig5.Value;
                    return(result);
                }
            }
            PmConfig pmConfig6 = PmConfigUtils.GetPmConfig("", "", 0, pmId);
            bool     flag12    = pmConfig6 != null;

            if (flag12)
            {
                result = pmConfig6.Value;
            }
            else
            {
                bool flag13 = parameter != null;
                if (flag13)
                {
                    result = parameter.DefaultValue;
                }
                else
                {
                    result = str;
                }
            }
            return(result);
        }