private void CreateDataSource() { //Create a data table users //DataTable dataTable = new DataTable(); string RoleId = ddlRoleList.SelectedValue; TabPermissionController tab_permission_obj=new TabPermissionController(); DataTable dataTable = tab_permission_obj.GetListByRoleId(RoleId); //Create a column TabId to store the tabId & View - Add - Edit - Delete - All to store the add permission access //DataColumn tabId = new DataColumn("TabId", Type.GetType("System.String")); //DataColumn tabName = new DataColumn("TabName", Type.GetType("System.String")); DataColumn view = new DataColumn("View", Type.GetType("System.Boolean")); DataColumn add = new DataColumn("Add", Type.GetType("System.Boolean")); DataColumn edit = new DataColumn("Edit", Type.GetType("System.Boolean")); DataColumn delete = new DataColumn("Delete", Type.GetType("System.Boolean")); DataColumn all = new DataColumn("All", Type.GetType("System.Boolean")); //Add the columns to the table //dataTable.Columns.Add(tabId); //dataTable.Columns.Add(tabName); dataTable.Columns.Add(view); dataTable.Columns.Add(add); dataTable.Columns.Add(edit); dataTable.Columns.Add(all); //Bind the grid view with the data source GridView1.DataSource = dataTable; GridView1.DataBind(); }
private int DeleteOldData() { string RoleId = ddlRoleList.SelectedValue; int PermissionId = Convert.ToInt32(ddlPermissionList.SelectedValue); TabPermissionController tab_permission_obj = new TabPermissionController(); DataTable dt = tab_permission_obj.GetListByRoleIdPermissionId(RoleId, PermissionId); int TabPermissionId = -1, result = -1; for (int i = 0; i < dt.Rows.Count; i++) { TabPermissionId = Convert.ToInt32(dt.Rows[i]["TabPermissionId"].ToString()); result = tab_permission_obj.DeleteTabPermission(TabPermissionId); } return result; }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string TabId = GridView1.DataKeys[e.Row.RowIndex].Value.ToString(); string RoleId = ddlRoleList.SelectedValue; int PermissionId = Convert.ToInt32(ddlPermissionList.SelectedValue); string SelectedTabId = null, UserId=null; TabPermissionController tab_permission_obj = new TabPermissionController(); DataTable dt = tab_permission_obj.GetListByRoleIdPermissionId(RoleId, PermissionId); for (int i = 0; i < dt.Rows.Count; i++) { SelectedTabId = dt.Rows[i]["TabId"].ToString(); if(dt.Rows[i]["UserId"].ToString() != string.Empty) UserId = dt.Rows[i]["UserId"].ToString(); else { if (Session["UserId"] != null && Session["UserId"].ToString() != string.Empty) UserId = Session["UserId"].ToString(); } if (TabId == SelectedTabId) { CheckBox chkSelectedPermissionRight = (CheckBox)e.Row.Cells[2].FindControl("chkSelectedPermissionRight"); if (chkSelectedPermissionRight != null) chkSelectedPermissionRight.Checked = true; CheckBox chkSelectedAllowAccessRight = (CheckBox)e.Row.Cells[3].FindControl("chkSelectedAllowAccessRight"); if (chkSelectedAllowAccessRight != null) chkSelectedAllowAccessRight.Checked = true; //TextBox txtUserId = (TextBox)e.Row.Cells[4].FindControl("txtUserId"); //txtUserId.Text = UserId; //txtUserId.Attributes.Add("value", txtUserId.Text); DropDownList ddlUserList = (DropDownList)e.Row.FindControl("ddlUserList"); PopulateUserList(ddlUserList, UserId); } } } }
private static void UpgradeToVersion_500() { PortalController objPortals = new PortalController(); ArrayList arrPortals = objPortals.GetPortals(); TabController controller = new TabController(); //Add Edit Permissions for Admin Tabs to legacy portals PermissionController permissionControler = new PermissionController(); TabPermissionController tabPermissionControler = new TabPermissionController(); ArrayList permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT"); int permissionID = Null.NullInteger; if (permissions.Count == 1) { PermissionInfo permission = permissions[0] as PermissionInfo; permissionID = permission.PermissionID; foreach (PortalInfo portal in arrPortals) { TabInfo adminTab = controller.GetTab(portal.AdminTabId, portal.PortalID, true); if (adminTab != null) { TabPermissionInfo tabPermission = new TabPermissionInfo(); tabPermission.TabID = adminTab.TabID; tabPermission.PermissionID = permissionID; tabPermission.AllowAccess = true; tabPermission.RoleID = portal.AdministratorRoleId; if (!TabPermissionExists(tabPermission, portal.PortalID)) { adminTab.TabPermissions.Add(tabPermission); } //Save Tab Permissions to Data Base TabPermissionController.SaveTabPermissions(adminTab); foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID)) { tabPermission = new TabPermissionInfo(); tabPermission.TabID = childTab.TabID; tabPermission.PermissionID = permissionID; tabPermission.AllowAccess = true; tabPermission.RoleID = portal.AdministratorRoleId; if (!TabPermissionExists(tabPermission, portal.PortalID)) { childTab.TabPermissions.Add(tabPermission); } //Save Tab Permissions to Data Base TabPermissionController.SaveTabPermissions(childTab); } } } } //Update Host/Admin modules Visibility setting bool superTabProcessed = Null.NullBoolean; ModuleController moduleController = new ModuleController(); foreach (PortalInfo portal in arrPortals) { if (!superTabProcessed) { //Process Host Tabs foreach (TabInfo childTab in TabController.GetTabsByParent(portal.SuperTabId, Null.NullInteger)) { foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values) { tabModule.Visibility = VisibilityState.None; moduleController.UpdateModule(tabModule); } } } //Process Portal Tabs foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID)) { foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values) { tabModule.Visibility = VisibilityState.None; moduleController.UpdateModule(tabModule); } } } //Upgrade PortalDesktopModules to support new "model" permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY"); if (permissions.Count == 1) { PermissionInfo permission = permissions[0] as PermissionInfo; permissionID = permission.PermissionID; foreach (PortalInfo portal in arrPortals) { foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values) { if (!desktopModule.IsPremium) { //Parse the permissions DesktopModulePermissionCollection deployPermissions = new DesktopModulePermissionCollection(); DesktopModulePermissionInfo deployPermission = default(DesktopModulePermissionInfo); // if Not IsAdmin add Registered Users if (!desktopModule.IsAdmin) { deployPermission = new DesktopModulePermissionInfo(); deployPermission.PermissionID = permissionID; deployPermission.AllowAccess = true; deployPermission.RoleID = portal.RegisteredRoleId; deployPermissions.Add(deployPermission); } // if Not a Host Module add Administrators string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions"; if (!hostModules.Contains(desktopModule.ModuleName)) { deployPermission = new DesktopModulePermissionInfo(); deployPermission.PermissionID = permissionID; deployPermission.AllowAccess = true; deployPermission.RoleID = portal.AdministratorRoleId; deployPermissions.Add(deployPermission); } //Add Portal/Module to PortalDesktopModules DesktopModuleController.AddDesktopModuleToPortal(portal.PortalID, desktopModule, deployPermissions, false); } } DataCache.ClearPortalCache(portal.PortalID, true); } } LegacyUtil.ProcessLegacyModules(); LegacyUtil.ProcessLegacyLanguages(); LegacyUtil.ProcessLegacySkins(); LegacyUtil.ProcessLegacySkinControls(); }