예제 #1
0
        public static void ImportRolesAndPermissions(this SCApplication app, DataTable table, Action <RolesFunctionsImportContext> callerAction = null)
        {
            if (table.Columns.Count > StartColumn)
            {
                ProcessProgress.Current.MinStep     = 0;
                ProcessProgress.Current.MaxStep     = 1;
                ProcessProgress.Current.CurrentStep = 0;
                ProcessProgress.Current.Response();

                SCRolesAndPermissions rolesAndPermissions = table.GetRolesAndPermissions(app.CurrentPermissions);

                SCRoleCollection       roles       = rolesAndPermissions.Roles;
                SCPermissionCollection permissions = rolesAndPermissions.Permissions;

                app.UpdateImportedRoles(roles, callerAction);
                app.UpdateImportedPermissions(permissions, callerAction);

                app = app.Refresh();

                app.UpdateImportedPermissionsInRoles(roles, callerAction);

                app = app.Refresh();
                app.SyncGroupsInRoles(callerAction);
            }
        }
예제 #2
0
        public static SCRoleCollection GetRoles(this DataTable table)
        {
            SCRoleCollection roles = new SCRoleCollection();

            if (table != null && table.Columns.Count > StartColumn)
            {
                for (int i = StartColumn; i < table.Columns.Count; i++)
                {
                    string roleName = table.Columns[i].ColumnName;

                    SCRole role = new SCRole();

                    roles.Add(InitProperties(role, roleName));
                }
            }

            return(roles);
        }
예제 #3
0
        public static SCRolesAndPermissions GetRolesAndPermissions(this DataTable table, SCPermissionCollection existedPermissions)
        {
            table.NullCheck("table");

            SCRoleCollection       roles       = new SCRoleCollection();
            SCPermissionCollection permissions = table.GetPermissions(existedPermissions);

            if (table.Columns.Contains("权限点/数据权限") && table.Columns.Count > StartColumn)
            {
                for (int i = StartColumn; i < table.Columns.Count; i++)
                {
                    string roleName = table.Columns[i].ColumnName;

                    SCRole role = roles.Append(InitProperties(new SCRole(), roleName));

                    foreach (DataRow row in table.Rows)
                    {
                        string permissionName = row["权限点/数据权限"].ToString();

                        if (permissionName.IsNotEmpty())
                        {
                            SCPermission permission = permissions.Find(p => string.Compare(permissionName, p.CodeName, true) == 0);

                            if (permission != null)
                            {
                                string cellValue = row[roleName].ToString();

                                if (cellValue.IsNullOrEmpty() || cellValue.Trim().IsNullOrEmpty() || cellValue.Trim().ToUpper() == "N")
                                {
                                    continue;
                                }

                                role.CurrentPermissions.Append(permission);
                            }
                        }
                    }
                }
            }

            return(new SCRolesAndPermissions(roles, permissions));
        }
예제 #4
0
		/// <summary>
		/// 处理ID改变
		/// </summary>
		protected override void OnIDChanged()
		{
			base.OnIDChanged();

			this._AllRoles = null;
			this._AllRolesRelations = null;
			this._CurrentRoles = null;
		}