private static void DeserializeModulePermissions(XmlNodeList nodeModulePermissions, int PortalId, int TabId, ModuleInfo objModule) { RoleController objRoleController = new RoleController(); PermissionController objPermissionController = new PermissionController(); PermissionInfo objPermission; int PermissionID; ArrayList arrPermissions; int i; foreach (XmlNode node in nodeModulePermissions) { string PermissionKey = XmlUtils.GetNodeValue(node.CreateNavigator(), "permissionkey"); string PermissionCode = XmlUtils.GetNodeValue(node.CreateNavigator(), "permissioncode"); string RoleName = XmlUtils.GetNodeValue(node.CreateNavigator(), "rolename"); bool AllowAccess = XmlUtils.GetNodeValueBoolean(node, "allowaccess"); int RoleID = int.MinValue; switch (RoleName) { case Globals.glbRoleAllUsersName: RoleID = Convert.ToInt32(Globals.glbRoleAllUsers); break; case Common.Globals.glbRoleUnauthUserName: RoleID = Convert.ToInt32(Globals.glbRoleUnauthUser); break; default: RoleInfo objRole = objRoleController.GetRoleByName(PortalId, RoleName); if (objRole != null) { RoleID = objRole.RoleID; } break; } if (RoleID != int.MinValue) { PermissionID = -1; arrPermissions = objPermissionController.GetPermissionByCodeAndKey(PermissionCode, PermissionKey); for (i = 0; i <= arrPermissions.Count - 1; i++) { objPermission = (PermissionInfo)arrPermissions[i]; PermissionID = objPermission.PermissionID; } if (PermissionID != -1) { ModulePermissionInfo objModulePermission = new ModulePermissionInfo(); objModulePermission.ModuleID = objModule.ModuleID; objModulePermission.PermissionID = PermissionID; objModulePermission.RoleID = RoleID; objModulePermission.AllowAccess = Convert.ToBoolean(XmlUtils.GetNodeValue(node.CreateNavigator(), "allowaccess")); objModule.ModulePermissions.Add(objModulePermission); } } } }
private void ParseFolderPermissions(XmlNodeList nodeFolderPermissions, int PortalId, FolderInfo folder) { Security.Permissions.PermissionController objPermissionController = new Security.Permissions.PermissionController(); Security.Permissions.FolderPermissionController objFolderPermissionController = new Security.Permissions.FolderPermissionController(); RoleController objRoleController = new RoleController(); int PermissionID = 0; folder.FolderPermissions.Clear(); foreach (XmlNode xmlFolderPermission in nodeFolderPermissions) { string PermissionKey = XmlUtils.GetNodeValue(xmlFolderPermission.CreateNavigator(), "permissionkey"); string PermissionCode = XmlUtils.GetNodeValue(xmlFolderPermission.CreateNavigator(), "permissioncode"); string RoleName = XmlUtils.GetNodeValue(xmlFolderPermission.CreateNavigator(), "rolename"); bool AllowAccess = XmlUtils.GetNodeValueBoolean(xmlFolderPermission, "allowaccess"); foreach (PermissionInfo objPermission in objPermissionController.GetPermissionByCodeAndKey(PermissionCode, PermissionKey)) { PermissionID = objPermission.PermissionID; } int RoleID = int.MinValue; switch (RoleName) { case Globals.glbRoleAllUsersName: RoleID = Convert.ToInt32(Globals.glbRoleAllUsers); break; case Common.Globals.glbRoleUnauthUserName: RoleID = Convert.ToInt32(Globals.glbRoleUnauthUser); break; default: RoleInfo objRole = objRoleController.GetRoleByName(PortalId, RoleName); if (objRole != null) { RoleID = objRole.RoleID; } break; } if (RoleID != int.MinValue) { FolderPermissionInfo objFolderPermission = new FolderPermissionInfo(); objFolderPermission.FolderID = folder.FolderID; objFolderPermission.PermissionID = PermissionID; objFolderPermission.RoleID = RoleID; objFolderPermission.AllowAccess = AllowAccess; folder.FolderPermissions.Add(objFolderPermission); } } FolderPermissionController.SaveFolderPermissions(folder); }
private static void DeserializeTabPermissions(XmlNodeList nodeTabPermissions, TabInfo objTab, bool IsAdminTemplate) { Security.Permissions.PermissionController objPermissionController = new Security.Permissions.PermissionController(); Security.Permissions.PermissionInfo objPermission; Security.Permissions.TabPermissionInfo objTabPermission; RoleController objRoleController = new RoleController(); RoleInfo objRole; int RoleID; int PermissionID = 0; string PermissionKey; string PermissionCode; string RoleName; bool AllowAccess; ArrayList arrPermissions; int i; foreach (XmlNode xmlTabPermission in nodeTabPermissions) { PermissionKey = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "permissionkey"); PermissionCode = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "permissioncode"); RoleName = XmlUtils.GetNodeValue(xmlTabPermission.CreateNavigator(), "rolename"); AllowAccess = XmlUtils.GetNodeValueBoolean(xmlTabPermission, "allowaccess"); arrPermissions = objPermissionController.GetPermissionByCodeAndKey(PermissionCode, PermissionKey); for (i = 0; i <= arrPermissions.Count - 1; i++) { objPermission = (Security.Permissions.PermissionInfo)arrPermissions[i]; PermissionID = objPermission.PermissionID; } RoleID = int.MinValue; switch (RoleName) { case Globals.glbRoleAllUsersName: RoleID = Convert.ToInt32(Globals.glbRoleAllUsers); break; case Common.Globals.glbRoleUnauthUserName: RoleID = Convert.ToInt32(Globals.glbRoleUnauthUser); break; default: PortalController objPortals = new PortalController(); PortalInfo objPortal = objPortals.GetPortal(objTab.PortalID); objRole = objRoleController.GetRoleByName(objPortal.PortalID, RoleName); if (objRole != null) { RoleID = objRole.RoleID; } else { if (IsAdminTemplate && RoleName.ToLower() == "administrators") { RoleID = objPortal.AdministratorRoleId; } } break; } if (RoleID != int.MinValue) { objTabPermission = new Security.Permissions.TabPermissionInfo(); objTabPermission.TabID = objTab.TabID; objTabPermission.PermissionID = PermissionID; objTabPermission.RoleID = RoleID; objTabPermission.AllowAccess = AllowAccess; objTab.TabPermissions.Add(objTabPermission); } } }
private int CreateRole(RoleInfo role) { RoleInfo objRoleInfo; RoleController objRoleController = new RoleController(); int roleId = Null.NullInteger; objRoleInfo = objRoleController.GetRoleByName(role.PortalID, role.RoleName); if (objRoleInfo == null) { roleId = objRoleController.AddRole(role); } else { roleId = objRoleInfo.RoleID; } return roleId; }