protected void BindData(string SortField) { DataTable dt = RecyclerDB.GetModulesInRecycler(portalSettings.PortalID, SortField); DataGrid1.DataSource = dt; DataGrid1.DataBind(); }
/// <summary> /// Handles the Click event of the restoreButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void restoreButton_Click(object sender, EventArgs e) { if (this._moduleID > 0) { RecyclerDB.MoveModuleToNewTab(int.Parse(this.ddTabs.SelectedValue), this._moduleID); } if (this._pageID > 0) { RecyclerDB.RestorePage(this._pageID, int.Parse(this.ddTabs.SelectedValue)); } this.RedirectBackToReferringPage(); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { this.DeleteButton.Visible = true; this.UpdateButton.Visible = false; try { int.TryParse(Request.Params["mID"], out this._moduleID); if (_moduleID > 0) { module = RecyclerDB.GetModuleSettingsForIndividualModule(_moduleID); if (RecyclerDB.ModuleIsInRecycler(_moduleID)) { if (!Page.IsPostBack) { LoadPageDropDown(); } // create an instance of the module PortalModuleControl myPortalModule = (PortalModuleControl)LoadControl(Path.ApplicationRoot + "/" + this.module.DesktopSrc); myPortalModule.PortalID = this.PortalSettings.PortalID; myPortalModule.ModuleConfiguration = module; selecteditem.InnerHtml = "Selected Module : " + module.ModuleTitle; // add the module to the placeholder PrintPlaceHolder.Controls.Add(myPortalModule); } else //they're trying to view a module that isn't in the recycler - maybe a manual manipulation of the url...? { pnlMain.Visible = false; pnlError.Visible = true; } } int.TryParse(Request.Params["pID"], out _pageID); if (_pageID > 0) { if (!Page.IsPostBack) { LoadPageDropDown(); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { deleteButton.Visible = true; updateButton.Visible = false; try { _moduleID = int.Parse(Request.Params["mID"]); module = RecyclerDB.GetModuleSettingsForIndividualModule(_moduleID); if (RecyclerDB.ModuleIsInRecycler(_moduleID)) { if (!Page.IsPostBack) { //load tab names for the dropdown list, then bind them // TODO check if this works //portalTabs = new PagesDB().GetPagesFlat(portalSettings.PortalID); portalTabs = new PagesDB().GetPagesFlatTable(portalSettings.PortalID); ddTabs.DataBind(); //on initial load, disable the restore button until they make a selection restoreButton.Enabled = false; ddTabs.Items.Insert(0, "--Choose a Tab to Restore this Module--"); } // create an instance of the module PortalModuleControl myPortalModule = (PortalModuleControl)LoadControl(Path.ApplicationRoot + "/" + module.DesktopSrc); myPortalModule.PortalID = portalSettings.PortalID; myPortalModule.ModuleConfiguration = module; // add the module to the placeholder PrintPlaceHolder.Controls.Add(myPortalModule); } else //they're trying to view a module that isn't in the recycler - maybe a manual manipulation of the url...? { pnlMain.Visible = false; pnlError.Visible = true; } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void BindPagesData(string SortField, bool IsLoad = false) { DataTable dt1 = RecyclerDB.GetPagesInRecycler(this.PortalSettings.PortalID, SortField); DataView dv1 = new DataView(dt1); if (GridViewSortDirectionPages == SortDirection.Descending && !IsLoad) { GridViewSortDirectionPages = SortDirection.Ascending; dv1.Sort = SortField + ASCENDING; } else { GridViewSortDirectionPages = SortDirection.Descending; dv1.Sort = SortField + DESCENDING; } dtgPages.DataSource = dv1; dtgPages.DataBind(); }
protected void BindData(string SortField, bool IsLoad = false) { DataTable dt = RecyclerDB.GetModulesInRecycler(this.PortalSettings.PortalID, SortField); DataView dv = new DataView(dt); if (GridViewSortDirection == SortDirection.Descending && !IsLoad) { GridViewSortDirection = SortDirection.Ascending; dv.Sort = SortField + ASCENDING; } else { GridViewSortDirection = SortDirection.Descending; dv.Sort = SortField + DESCENDING; } DataGrid1.DataSource = dv; DataGrid1.DataBind(); }
/// <summary> /// Determines whether the specified module ID has permissions. /// </summary> /// <param name="moduleID"> /// The module ID. /// </param> /// <param name="procedureName"> /// Name of the procedure. /// </param> /// <param name="parameterRol"> /// The parameter rol. /// </param> /// <returns> /// <c>true</c> if the specified module ID has permissions; otherwise, <c>false</c>. /// </returns> /// <remarks> /// </remarks> private static bool hasPermissions(int moduleID, string procedureName, string parameterRol) { if (Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "Admins")) { return(true); } if (RecyclerDB.ModuleIsInRecycler(moduleID)) { procedureName = procedureName + "Recycler"; } if (moduleID <= 0) { return(false); } // Obtain PortalSettings from Current Context var PortalSettings = (PortalSettings)HttpContext.Current.Items[StringsPortalSettings]; int portalID; if (PortalSettings != null) { portalID = PortalSettings.PortalID; } else { var alias = HttpContext.Current.Items["PortalAlias"]; var db = new Massive.DynamicModel("ConnectionString", "rb_Portals"); var elemenents = db.All("PortalAlias = @0", columns: "PortalID", args: alias); if (elemenents.Count() != 1) { return(false); } portalID = ((dynamic)((System.Dynamic.ExpandoObject)(elemenents.First()))).PortalID; } // [email protected]: Get users & roles from true portal (2004/09/23) if (Config.UseSingleUserBase) { portalID = 0; } // Create Instance of Connection and Command Object using (var myConnection = Config.SqlConnectionString) { using (var myCommand = new SqlCommand(procedureName, myConnection)) { // Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC var parameterModuleID = new SqlParameter("@ModuleID", SqlDbType.Int, 4); parameterModuleID.Value = moduleID; myCommand.Parameters.Add(parameterModuleID); var parameterPortalID = new SqlParameter("@PortalID", SqlDbType.Int, 4); parameterPortalID.Value = portalID; myCommand.Parameters.Add(parameterPortalID); // Add out parameters to Sproc var parameterAccessRoles = new SqlParameter("@AccessRoles", SqlDbType.NVarChar, 256); parameterAccessRoles.Direction = ParameterDirection.Output; myCommand.Parameters.Add(parameterAccessRoles); var parameterRoles = new SqlParameter(parameterRol, SqlDbType.NVarChar, 256); parameterRoles.Direction = ParameterDirection.Output; myCommand.Parameters.Add(parameterRoles); // Open the database connection and execute the command myConnection.Open(); try { myCommand.ExecuteNonQuery(); } finally { } return(IsInRoles(parameterAccessRoles.Value.ToString()) && IsInRoles(parameterRoles.Value.ToString())); } } }
/// <summary> /// Determines whether the specified module ID has permissions. /// </summary> /// <param name="moduleID">The module ID.</param> /// <param name="procedureName">Name of the procedure.</param> /// <param name="parameterRol">The parameter rol.</param> /// <returns> /// <c>true</c> if the specified module ID has permissions; otherwise, <c>false</c>. /// </returns> private static bool hasPermissions(int moduleID, string procedureName, string parameterRol) { if (RecyclerDB.ModuleIsInRecycler(moduleID)) { procedureName = procedureName + "Recycler"; } if (moduleID <= 0) { return(false); } // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items[strPortalSettings]; int portalID = portalSettings.PortalID; // [email protected]: Get users & roles from true portal (2004/09/23) if (Config.UseSingleUserBase) { portalID = 0; } // Create Instance of Connection and Command Object using (SqlConnection myConnection = Config.SqlConnectionString) { using (SqlCommand myCommand = new SqlCommand(procedureName, myConnection)) { // Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC SqlParameter parameterModuleID = new SqlParameter("@ModuleID", SqlDbType.Int, 4); parameterModuleID.Value = moduleID; myCommand.Parameters.Add(parameterModuleID); SqlParameter parameterPortalID = new SqlParameter("@PortalID", SqlDbType.Int, 4); parameterPortalID.Value = portalID; myCommand.Parameters.Add(parameterPortalID); // Add out parameters to Sproc SqlParameter parameterAccessRoles = new SqlParameter("@AccessRoles", SqlDbType.NVarChar, 256); parameterAccessRoles.Direction = ParameterDirection.Output; myCommand.Parameters.Add(parameterAccessRoles); SqlParameter parameterRoles = new SqlParameter(parameterRol, SqlDbType.NVarChar, 256); parameterRoles.Direction = ParameterDirection.Output; myCommand.Parameters.Add(parameterRoles); // Open the database connection and execute the command myConnection.Open(); try { myCommand.ExecuteNonQuery(); } finally { myConnection.Close(); } return(IsInRoles(parameterAccessRoles.Value.ToString()) && IsInRoles(parameterRoles.Value.ToString())); } } }