/// <summary> /// Gets and bulk updates web part containers. Called when the "Get and bulk update containers" button is pressed. /// Expects the CreateWebPartContainer method to be run first. /// </summary> private bool GetAndBulkUpdateWebPartContainers() { // Prepare the parameters string where = "ContainerName LIKE N'MyNewContainer%'"; string orderBy = ""; int topN = 0; string columns = ""; // Get the data DataSet containers = WebPartContainerInfoProvider.GetContainers(where, orderBy, topN, columns); if (!DataHelper.DataSourceIsEmpty(containers)) { // Loop through the individual items foreach (DataRow containerDr in containers.Tables[0].Rows) { // Create object from DataRow WebPartContainerInfo modifyContainer = new WebPartContainerInfo(containerDr); // Update the properties modifyContainer.ContainerDisplayName = modifyContainer.ContainerDisplayName.ToUpper(); // Save the changes WebPartContainerInfoProvider.SetWebPartContainerInfo(modifyContainer); } return(true); } return(false); }
private bool Save(bool closeOnSave) { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return(false); } // Parse the container text string text = txtContainerText.Text; string after = ""; int wpIndex = text.IndexOf(WebPartContainerInfoProvider.WP_CHAR); if (wpIndex >= 0) { after = text.Substring(wpIndex + 1).Replace(WebPartContainerInfoProvider.WP_CHAR, ""); text = text.Substring(0, wpIndex); } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo() { ContainerTextBefore = text, ContainerTextAfter = after, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return(false); } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); CMSContext.EditedObject = webPartContainerObj; CMSObjectManager.CheckOutNewObject(Page); if (mDialogMode) { ProcessDialog(webPartContainerObj, closeOnSave); } else { ProcessPage(webPartContainerObj); } return(true); }
/// <summary> /// Saves the web part container. /// </summary> /// <returns>true if web part container was saved successfully, otherwise false.</returns> private bool Save() { string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("general.invalidcodename")) .Result; if (errorMessage != string.Empty) { ShowError(errorMessage); return(false); } // If webPartContainer doesnt already exist, create new one if (webPartContainerObj == null) { webPartContainerObj = new WebPartContainerInfo(); } webPartContainerObj.ContainerTextBefore = txtContainerTextBefore.Text; webPartContainerObj.ContainerTextAfter = txtContainerTextAfter.Text; webPartContainerObj.ContainerCSS = txtContainerCSS.Text; webPartContainerObj.ContainerName = txtContainerName.Text.Trim(); webPartContainerObj.ContainerDisplayName = txtContainerDisplayName.Text.Trim(); // Check existing name if (!mDialogMode) { WebPartContainerInfo wPcI = WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName); if ((wPcI != null) && (wPcI.ContainerID != webPartContainerObj.ContainerID)) { ShowError(GetString("Container_Edit.UniqueError")); return(false); } } // Save the container WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); ShowInformation(GetString("General.ChangesSaved")); // Reload header if changes were saved if (TabMode) { ScriptHelper.RefreshTabHeader(Page, null); } return(true); }
/// <summary> /// Creates web part container. Called when the "Create container" button is pressed. /// </summary> private bool CreateWebPartContainer() { // Create new web part container object WebPartContainerInfo newContainer = new WebPartContainerInfo(); // Set the properties newContainer.ContainerDisplayName = "My new container"; newContainer.ContainerName = "MyNewContainer"; newContainer.ContainerTextBefore = "<div class=\"myNewContainer\">"; newContainer.ContainerTextAfter = "</div>"; // Save the web part container WebPartContainerInfoProvider.SetWebPartContainerInfo(newContainer); return(true); }
/// <summary> /// Gets and updates web part container. Called when the "Get and update container" button is pressed. /// Expects the CreateWebPartContainer method to be run first. /// </summary> private bool GetAndUpdateWebPartContainer() { // Get the web part container WebPartContainerInfo updateContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo("MyNewContainer"); if (updateContainer != null) { // Update the properties updateContainer.ContainerDisplayName = updateContainer.ContainerDisplayName.ToLower(); // Save the changes WebPartContainerInfoProvider.SetWebPartContainerInfo(updateContainer); return(true); } return(false); }
private bool Save(bool closeOnSave) { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return(false); } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo { ContainerTextBefore = txtContainerTextBefore.Text, ContainerTextAfter = txtContainerTextAfter.Text, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return(false); } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); if (mDialogMode) { ProcessDialog(webPartContainerObj, closeOnSave); } else { ProcessPage(webPartContainerObj); } return(true); }
private void SaveContainer() { try { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return; } // Parse the container text string text = txtContainerText.Text; string after = ""; int wpIndex = text.IndexOf(WebPartContainerInfoProvider.WP_CHAR); if (wpIndex >= 0) { after = text.Substring(wpIndex + 1).Replace(WebPartContainerInfoProvider.WP_CHAR, ""); text = text.Substring(0, wpIndex); } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo() { ContainerTextBefore = text, ContainerTextAfter = after, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return; } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); UIContext.EditedObject = webPartContainerObj; CMSObjectManager.CheckOutNewObject(Page); if (mDialogMode) { ProcessDialog(webPartContainerObj, true); } else { ProcessPage(webPartContainerObj); } } catch (SecurityException ex) { ShowError(!SystemContext.IsFullTrustLevel ? ResHelper.GetStringFormat("general.fulltrustrequired", ex.Message) : ex.Message); } catch (Exception ex) { ShowError(ex.Message); } }