private void SaveData() { if (node != null) { // Update fields node.NodeBodyElementAttributes = txtBodyCss.Text; node.NodeDocType = txtDocType.Text; node.NodeHeadTags = txtHeadTags.Value.ToString(); // Update the node node.Update(); // Update search index if (DocumentHelper.IsSearchTaskCreationAllowed(node)) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, TreeNode.OBJECT_TYPE, SearchFieldsConstants.ID, node.GetSearchID(), node.DocumentID); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree); RegisterRefreshScript(); // Empty variable for exitwithoutchanges dialog ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "SubmitAction", "CMSContentManager.changed(false);", true); // Clear cache PageInfoProvider.RemoveAllPageInfosFromCache(); ShowChangesSaved(); // Clear content changed flag DocumentManager.ClearContentChanged(); } }
/// <summary> /// Undoes checkout for given node. /// </summary> /// <param name="tree">Tree provider</param> /// <param name="node">Node to undo checkout</param> /// <returns>FALSE when document is checked out and checkbox for undoing checkout is not checked</returns> private bool UndoPossibleCheckOut(TreeProvider tree, TreeNode node) { if (node.IsCheckedOut) { if (chkUndoCheckOut.Checked && ((CurrentUser.UserID == node.DocumentCheckedOutByUserID) || (CurrentUser.IsAuthorizedPerResource("CMS.Content", "checkinall")))) { TreeProvider.ClearCheckoutInformation(node); node.Update(); } else { string nodeAliasPath = HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")"); if (CurrentUser.UserID != node.DocumentCheckedOutByUserID) { // Get checked out message var user = UserInfoProvider.GetUserInfo(node.DocumentCheckedOutByUserID); string userName = (user != null) ? user.GetFormattedUserName(false) : ""; AddError(String.Format(GetString("editcontent.documentnamecheckedoutbyanother"), nodeAliasPath, userName)); } else { AddError(string.Format(ResHelper.GetString("content.checkedoutdocument"), nodeAliasPath)); } return(false); } } return(true); }
private void SaveData() { if (node != null) { // Update fields node.NodeBodyElementAttributes = txtBodyCss.Text; node.NodeDocType = txtDocType.Text; node.NodeHeadTags = txtHeadTags.Value.ToString(); // Update the node node.Update(); // Update search index if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled)) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID()); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree); RegisterRefreshScript(); // Empty variable for exitwithoutchanges dialog ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "SubmitAction", ScriptHelper.GetScript("NotChanged();")); // Clear cache PageInfoProvider.RemoveAllPageInfosFromCache(); ShowChangesSaved(); } }
/// <summary> /// update the campaign /// Sets the properties of the new page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Edit(object sender, EventArgs e) { string categoryName = txtName.Text; string categroyDes = txtDescription.Text; try { if (!string.IsNullOrEmpty(categoryName)) { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); CMS.DocumentEngine.TreeNode editPage = tree.SelectNodes("KDA.ProductCategory").OnCurrentSite().Where("ProductCategoryID", QueryOperator.Equals, categoyId); if (editPage != null) { editPage.DocumentName = categoryName; editPage.DocumentCulture = DocumentContext.CurrentDocument.DocumentCulture; editPage.SetValue("ProductCategoryTitle", categoryName); editPage.SetValue("ProductCategoryDescription", categroyDes); editPage.SetValue("Status", ValidationHelper.GetBoolean(ddlStatus.SelectedValue, false)); editPage.Update(); Response.Cookies["status"].Value = QueryStringStatus.Updated; Response.Cookies["status"].HttpOnly = false; URLHelper.Redirect($"{CurrentDocument.Parent.DocumentUrlPath}?status={QueryStringStatus.Updated}"); } else { lblFailureText.Visible = true; } } } catch (Exception ex) { EventLogProvider.LogException("CategroyCreateFormEdit", "EXCEPTION", ex); } }
/// <summary> /// Publishes document. /// </summary> /// <param name="node">Node to publish</param> /// <param name="wm">Workflow manager</param> /// <returns>Whether node is already published</returns> private bool Publish(TreeNode node, WorkflowManager wm) { string pathCulture = HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")"); WorkflowStepInfo currentStep = wm.GetStepInfo(node); bool alreadyPublished = (currentStep == null) || currentStep.StepIsPublished; if (!alreadyPublished) { using (CMSActionContext ctx = new CMSActionContext() { LogEvents = false }) { // Remove possible checkout if (node.DocumentCheckedOutByUserID > 0) { TreeProvider.ClearCheckoutInformation(node); node.Update(); } } // Publish document currentStep = wm.PublishDocument(node, null); } // Document is already published, check if still under workflow if (alreadyPublished && (currentStep != null) && currentStep.StepIsPublished) { WorkflowScopeInfo wsi = wm.GetNodeWorkflowScope(node); if (wsi == null) { DocumentHelper.ClearWorkflowInformation(node); VersionManager vm = VersionManager.GetInstance(node.TreeProvider); vm.RemoveWorkflow(node); } } // Document already published if (alreadyPublished) { AddLog(string.Format(ResHelper.GetString("content.publishedalready"), pathCulture)); } else if ((currentStep == null) || !currentStep.StepIsPublished) { AddError(string.Format(ResHelper.GetString("content.PublishWasApproved"), pathCulture)); return(true); } else { // Add log record AddLog(pathCulture); } return(false); }
/// <summary> /// Creates document. /// </summary> /// <param name="createAnother">If false user will be redirected to created document</param> public int Save(bool createAnother) { // Validate input data string message = new Validator().NotEmpty(txtDocumentName.Text.Trim(), GetString("om.enterdocumentname")).Result; if (message == String.Empty) { if (node != null) { // Select parent node TreeNode parent = tree.SelectSingleNode(CMSContext.CurrentSiteName, ucPath.Value.ToString(), TreeProvider.ALL_CULTURES, false, null, false); if (parent != null) { // Check security if (!CMSContext.CurrentUser.IsAuthorizedToCreateNewDocument(parent.NodeID, node.NodeClassName)) { RedirectToAccessDenied(GetString("cmsdesk.notauthorizedtocreatedocument")); return(0); } TreeNode newNode = ProcessAction(node, parent, "copynode", false, true, true); if (newNode != null) { newNode.SetValue("DocumentMenuItemHideInNavigation", !chkShowInNavigation.Checked); newNode.SetValue("DocumentShowInSiteMap", chkShowInSiteMap.Checked); newNode.SetValue("DocumentSearchExcluded", chkExcludeFromSearch.Checked); // Limit length to 100 characters string nodeAlias = TextHelper.LimitLength(txtDocumentName.Text.Trim(), 100, String.Empty); newNode.NodeAlias = nodeAlias; newNode.DocumentName = nodeAlias; // Update menu item name newNode.SetDocumentNameSource(nodeAlias); newNode.Update(); // If ABTest selected - create new variant int abTestID = ValidationHelper.GetInteger(ucABTestSelector.Value, 0); if (abTestID != 0) { ABTestInfo abTest = ABTestInfoProvider.GetABTestInfo(abTestID); if (abTest != null) { string defaultCodeName = TextHelper.LimitLength(ValidationHelper.GetCodeName(newNode.GetDocumentName()), 45, String.Empty); string codeName = defaultCodeName; ABVariantInfo info = ABVariantInfoProvider.GetABVariantInfo(codeName, abTest.ABTestName, CMSContext.CurrentSiteName); // Find non existing variant code name int index = 0; while (info != null) { index++; codeName = defaultCodeName + "-" + index; info = ABVariantInfoProvider.GetABVariantInfo(codeName, abTest.ABTestName, CMSContext.CurrentSiteName); } // Save AB Variant ABVariantInfo variantInfo = new ABVariantInfo(); variantInfo.ABVariantTestID = abTestID; variantInfo.ABVariantPath = newNode.NodeAliasPath; variantInfo.ABVariantName = codeName; variantInfo.ABVariantDisplayName = newNode.GetDocumentName(); variantInfo.ABVariantSiteID = CMSContext.CurrentSiteID; ABVariantInfoProvider.SetABVariantInfo(variantInfo); } } // Get the page mode if (CMSContext.ViewMode != ViewModeEnum.EditLive) { CMSContext.ViewMode = ViewModeEnum.EditForm; } txtDocumentName.Text = String.Empty; return(newNode.NodeID); } } else { message = GetString("om.pathdoesnotexists"); } } } if (message != String.Empty) { lblError.Visible = true; lblError.Text = message; } return(0); }
private void RemoveWorkflow(object parameter) { VersionManager verMan = VersionManager.GetInstance(Tree); TreeNode node = null; // Custom logging Tree.LogEvents = false; Tree.AllowAsyncActions = false; CanceledString = ResHelper.GetString("workflowdocuments.removingcanceled", currentCulture); try { // Begin log AddLog(ResHelper.GetString("content.preparingdocuments", currentCulture)); string where = parameter as string; // Get the documents DataSet documents = GetDocumentsToProcess(where); if (!DataHelper.DataSourceIsEmpty(documents)) { // Begin log AddLog(ResHelper.GetString("workflowdocuments.removingwf", currentCulture)); foreach (DataTable classTable in documents.Tables) { foreach (DataRow nodeRow in classTable.Rows) { // Get the current document string className = ValidationHelper.GetString(nodeRow["ClassName"], string.Empty); string aliasPath = ValidationHelper.GetString(nodeRow["NodeAliasPath"], string.Empty); string docCulture = ValidationHelper.GetString(nodeRow["DocumentCulture"], string.Empty); string siteName = ValidationHelper.GetString(nodeRow["SiteName"], string.Empty); // Get published version node = Tree.SelectSingleNode(siteName, aliasPath, docCulture, false, className, false); string encodedAliasPath = HTMLHelper.HTMLEncode(ValidationHelper.GetString(aliasPath, string.Empty) + " (" + node.GetValue("DocumentCulture") + ")"); // Destroy document history verMan.DestroyDocumentHistory(node.DocumentID); // Clear workflow DocumentHelper.ClearWorkflowInformation(node); node.Update(); // Add log record AddLog(encodedAliasPath); // Add record to eventlog LogContext.LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, "Content", "REMOVEDOCWORKFLOW", currentUser.UserID, currentUser.UserName, node.NodeID, node.GetDocumentName(), HTTPHelper.UserHostAddress, string.Format(GetString("workflowdocuments.removeworkflowsuccess"), encodedAliasPath), node.NodeSiteID, HTTPHelper.GetAbsoluteUri(), HTTPHelper.MachineName, HTTPHelper.GetUrlReferrer(), HTTPHelper.GetUserAgent()); } } CurrentInfo = GetString("workflowdocuments.removecomplete"); } else { AddError(ResHelper.GetString("workflowdocuments.nodocumentstoclear", currentCulture)); } } catch (ThreadAbortException ex) { string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty); if (state == CMSThread.ABORT_REASON_STOP) { // When canceled CurrentInfo = CanceledString; } else { int siteId = (node != null) ? node.NodeSiteID : CMSContext.CurrentSiteID; // Log error LogExceptionToEventLog("REMOVEDOCWORKFLOW", "workflowdocuments.removefailed", ex, siteId); } } catch (Exception ex) { int siteId = (node != null) ? node.NodeSiteID : CMSContext.CurrentSiteID; // Log error LogExceptionToEventLog("REMOVEDOCWORKFLOW", "workflowdocuments.removefailed", ex, siteId); } }
private void RemoveWorkflow(object parameter) { VersionManager verMan = VersionManager.GetInstance(Tree); TreeNode node = null; // Custom logging Tree.LogEvents = false; Tree.AllowAsyncActions = false; CanceledString = GetString("workflowdocuments.removingcanceled", mCurrentCulture); try { // Begin log AddLog(GetString("content.preparingdocuments", mCurrentCulture)); string where = parameter as string; // Get the documents DataSet documents = GetDocumentsToProcess(where); if (!DataHelper.DataSourceIsEmpty(documents)) { // Begin log AddLog(GetString("workflowdocuments.removingwf", mCurrentCulture)); foreach (DataTable classTable in documents.Tables) { foreach (DataRow nodeRow in classTable.Rows) { // Get the current document string className = ValidationHelper.GetString(nodeRow["ClassName"], string.Empty); string aliasPath = ValidationHelper.GetString(nodeRow["NodeAliasPath"], string.Empty); string docCulture = ValidationHelper.GetString(nodeRow["DocumentCulture"], string.Empty); string siteName = SiteInfoProvider.GetSiteName(nodeRow["NodeSiteID"].ToInteger(0)); // Get published version node = Tree.SelectSingleNode(siteName, aliasPath, docCulture, false, className, false); string encodedAliasPath = HTMLHelper.HTMLEncode(ValidationHelper.GetString(aliasPath, string.Empty) + " (" + node.GetValue("DocumentCulture") + ")"); // Destroy document history verMan.DestroyDocumentHistory(node.DocumentID); using (new CMSActionContext { LogEvents = false }) { // Clear workflow DocumentHelper.ClearWorkflowInformation(node); node.Update(); } // Add log record AddLog(encodedAliasPath); // Add record to eventlog LogContext.LogEventToCurrent(EventType.INFORMATION, "Content", "REMOVEDOCWORKFLOW", string.Format(GetString("workflowdocuments.removeworkflowsuccess"), encodedAliasPath), RequestContext.RawURL, mCurrentUser.UserID, mCurrentUser.UserName, node.NodeID, node.GetDocumentName(), RequestContext.UserHostAddress, node.NodeSiteID, SystemContext.MachineName, RequestContext.URLReferrer, RequestContext.UserAgent, DateTime.Now); } } CurrentInfo = GetString("workflowdocuments.removecomplete"); } else { AddError(GetString("workflowdocuments.nodocumentstoclear", mCurrentCulture)); } } catch (ThreadAbortException ex) { if (CMSThread.Stopped(ex)) { // When canceled CurrentInfo = CanceledString; } else { int siteId = (node != null) ? node.NodeSiteID : SiteContext.CurrentSiteID; // Log error LogExceptionToEventLog("REMOVEDOCWORKFLOW", "workflowdocuments.removefailed", ex, siteId); } } catch (Exception ex) { int siteId = (node != null) ? node.NodeSiteID : SiteContext.CurrentSiteID; // Log error LogExceptionToEventLog("REMOVEDOCWORKFLOW", "workflowdocuments.removefailed", ex, siteId); } }
/// <summary> /// Updates the current Group or creates new if no GroupID is present. /// </summary> public void SaveData() { if (!CheckPermissions("cms.groups", PERMISSION_MANAGE, GroupID)) { return; } // Trim display name and code name string displayName = txtDisplayName.Text.Trim(); string codeName = txtCodeName.Text.Trim(); // Validate form entries string errorMessage = ValidateForm(displayName, codeName); if (errorMessage == "") { GroupInfo group = null; try { bool newGroup = false; // Update existing item if ((GroupID > 0) && (gi != null)) { group = gi; } else { group = new GroupInfo(); newGroup = true; } if (group != null) { if (displayName != group.GroupDisplayName) { // Refresh a breadcrumb if used in the tabs layout ScriptHelper.RefreshTabHeader(Page, displayName); } if (DisplayAdvanceOptions) { // Update Group fields group.GroupDisplayName = displayName; group.GroupName = codeName; group.GroupNodeGUID = ValidationHelper.GetGuid(groupPageURLElem.Value, Guid.Empty); } if (AllowChangeGroupDisplayName && IsLiveSite) { group.GroupDisplayName = displayName; } group.GroupDescription = txtDescription.Text; group.GroupAccess = GetGroupAccess(); group.GroupSiteID = SiteID; group.GroupApproveMembers = GetGroupApproveMembers(); group.GroupSendJoinLeaveNotification = chkJoinLeave.Checked; group.GroupSendWaitingForApprovalNotification = chkWaitingForApproval.Checked; groupPictureEdit.UpdateGroupPicture(group); // If new group was created if (newGroup) { // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user var user = MembershipContext.AuthenticatedUser; if (user != null) { group.GroupCreatedByUserID = user.UserID; group.GroupApprovedByUserID = user.UserID; group.GroupApproved = true; } } if (!IsLiveSite && (group.GroupNodeGUID == Guid.Empty)) { plcStyleSheetSelector.Visible = false; } // Save theme int selectedSheetID = ValidationHelper.GetInteger(ctrlSiteSelectStyleSheet.Value, 0); if (plcStyleSheetSelector.Visible) { if (group.GroupNodeGUID != Guid.Empty) { // Save theme for every site culture var cultures = CultureSiteInfoProvider.GetSiteCultureCodes(SiteContext.CurrentSiteName); if (cultures != null) { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Return class name of selected tree node TreeNode treeNode = tree.SelectSingleNode(group.GroupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName); if (treeNode != null) { // Return all culture version of node DataSet ds = tree.SelectNodes(SiteContext.CurrentSiteName, null, TreeProvider.ALL_CULTURES, false, treeNode.NodeClassName, "NodeGUID ='" + group.GroupNodeGUID + "'", String.Empty, -1, false); if (!DataHelper.DataSourceIsEmpty(ds)) { // Loop through all nodes foreach (DataRow dr in ds.Tables[0].Rows) { // Create node and set tree provider for user validation TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["className"], String.Empty), dr); node.TreeProvider = tree; // Update stylesheet id if set if (selectedSheetID == 0) { node.DocumentStylesheetID = 0; node.DocumentInheritsStylesheet = true; } else { node.DocumentStylesheetID = selectedSheetID; } node.Update(); } } } } } } if (!IsLiveSite && (group.GroupNodeGUID != Guid.Empty)) { plcStyleSheetSelector.Visible = true; } if (plcOnline.Visible) { // On-line marketing setting is visible => set flag according to checkbox group.GroupLogActivity = chkLogActivity.Checked; } else { // On-line marketing setting is not visible => set flag to TRUE as default value group.GroupLogActivity = true; } // Save Group in the database GroupInfoProvider.SetGroupInfo(group); groupPictureEdit.GroupInfo = group; txtDisplayName.Text = group.GroupDisplayName; txtCodeName.Text = group.GroupName; // Flush cached information DocumentContext.CurrentDocument = null; DocumentContext.CurrentPageInfo = null; DocumentContext.CurrentDocumentStylesheet = null; // Display information on success ShowChangesSaved(); // If new group was created if (newGroup) { GroupID = group.GroupID; RaiseOnSaved(); } } } catch (Exception ex) { // Display error message ShowError(GetString("general.saveerror"), ex.Message, null); } } else { // Display error message ShowError(errorMessage); } }
private object gridData_OnExternalDataBound(object sender, string sourceName, object parameter) { DataRowView row = parameter as DataRowView; if (DocumentListingDisplayed) { switch (sourceName.ToLowerCSafe()) { case "skunumber": case "skuavailableitems": case "publicstatusid": case "allowforsale": case "skusiteid": case "typename": case "skuprice": if (ShowSections && (row["NodeSKUID"] == DBNull.Value)) { return(NO_DATA_CELL_VALUE); } break; case "edititem": row = ((GridViewRow)parameter).DataItem as DataRowView; if ((row != null) && ((row["NodeSKUID"] == DBNull.Value) || showProductsInTree)) { CMSGridActionButton btn = sender as CMSGridActionButton; if (btn != null) { int currentNodeId = ValidationHelper.GetInteger(row["NodeID"], 0); int nodeParentId = ValidationHelper.GetInteger(row["NodeParentID"], 0); if (row["NodeSKUID"] == DBNull.Value) { btn.IconCssClass = "icon-eye"; btn.IconStyle = GridIconStyle.Allow; btn.ToolTip = GetString("com.sku.viewproducts"); } // Go to the selected document btn.OnClientClick = "EditItem(" + currentNodeId + ", " + nodeParentId + "); return false;"; } } break; } } switch (sourceName.ToLowerCSafe()) { case "skunumber": string skuNumber = ValidationHelper.GetString(row["SKUNumber"], null); return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(skuNumber) ?? "")); case "skuavailableitems": var sku = new SKUInfo(row.Row); int availableItems = sku.SKUAvailableItems; // Inventory tracked by variants if (sku.SKUTrackInventory == TrackInventoryTypeEnum.ByVariants) { return(GetString("com.inventory.trackedbyvariants")); } // Inventory tracking disabled if (sku.SKUTrackInventory == TrackInventoryTypeEnum.Disabled) { return(GetString("com.inventory.nottracked")); } // Ensure correct values for unigrid export if (sender == null) { return(availableItems); } // Tracking by products InlineEditingTextBox inlineAvailableItems = new InlineEditingTextBox(); inlineAvailableItems.Text = availableItems.ToString(); inlineAvailableItems.DelayedReload = DocumentListingDisplayed; inlineAvailableItems.EnableEncode = false; inlineAvailableItems.Formatting += (s, e) => { var reorderAt = sku.SKUReorderAt; // Emphasize the number when product needs to be reordered if (availableItems <= reorderAt) { // Format message informing about insufficient stock level string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt); string message = string.Format("<span class=\"alert-status-error\" onclick=\"UnTip()\" onmouseout=\"UnTip()\" onmouseover=\"Tip('{1}')\">{0}</span>", availableItems, reorderMsg); inlineAvailableItems.FormattedText = message; } }; // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data. // Update data only if external data bound is called for the first time. if (!forceReloadData) { inlineAvailableItems.Update += (s, e) => { var newNumberOfItems = ValidationHelper.GetInteger(inlineAvailableItems.Text, availableItems); if (ValidationHelper.IsInteger(inlineAvailableItems.Text) && (-1000000000 <= newNumberOfItems) && (newNumberOfItems <= 1000000000)) { CheckModifyPermission(sku); // Ensures that grid will display inserted value sku.SKUAvailableItems = newNumberOfItems; // Document list is used to display products -> document has to be updated to ensure correct sku mapping if (DocumentListingDisplayed) { int documentId = ValidationHelper.GetInteger(row.Row["DocumentID"], 0); // Create an instance of the Tree provider and select edited document with coupled data TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode document = tree.SelectSingleDocument(documentId); if (document == null) { return; } document.SetValue("SKUAvailableItems", newNumberOfItems); document.Update(); forceReloadData = true; } // Stand-alone product -> only product has to be updated else { sku.MakeComplete(true); sku.Update(); gridData.ReloadData(); } } else { inlineAvailableItems.ErrorText = GetString("com.productedit.availableitemsinvalid"); } }; } return(inlineAvailableItems); case "skuprice": SKUInfo product = new SKUInfo(row.Row); // Ensure correct values for unigrid export if (sender == null) { return(product.SKUPrice); } InlineEditingTextBox inlineSkuPrice = new InlineEditingTextBox(); inlineSkuPrice.Text = product.SKUPrice.ToString(); inlineSkuPrice.DelayedReload = DocumentListingDisplayed; inlineSkuPrice.Formatting += (s, e) => { // Format price inlineSkuPrice.FormattedText = CurrencyInfoProvider.GetFormattedPrice(product.SKUPrice, product.SKUSiteID); }; // Unigrid with delayed reload in combination with inline edit control requires additional postback to sort data. // Update data only if external data bound is called for the first time. if (!forceReloadData) { inlineSkuPrice.Update += (s, e) => { CheckModifyPermission(product); // Price must be a double number double price = ValidationHelper.GetDouble(inlineSkuPrice.Text, -1); if (ValidationHelper.IsDouble(inlineSkuPrice.Text) && (price >= 0)) { // Ensures that grid will display inserted price product.SKUPrice = price; // Document list is used to display products -> document has to be updated to ensure correct sku mapping if (DocumentListingDisplayed) { int documentId = ValidationHelper.GetInteger(row.Row["DocumentID"], 0); // Create an instance of the Tree provider and select edited document with coupled data TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode document = tree.SelectSingleDocument(documentId); if (document != null) { document.SetValue("SKUPrice", price); document.Update(); forceReloadData = true; } } // Stand-alone product -> only product has to be updated else { product.MakeComplete(true); product.Update(); gridData.ReloadData(); } } else { inlineSkuPrice.ErrorText = GetString("com.productedit.priceinvalid"); } }; } return(inlineSkuPrice); case "publicstatusid": int id = ValidationHelper.GetInteger(row["SKUPublicStatusID"], 0); PublicStatusInfo publicStatus = PublicStatusInfoProvider.GetPublicStatusInfo(id); if (publicStatus != null) { // Localize and encode return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(publicStatus.PublicStatusDisplayName))); } return(string.Empty); case "allowforsale": // Get "on sale" flag return(UniGridFunctions.ColoredSpanYesNo(ValidationHelper.GetBoolean(row["SKUEnabled"], false))); case "typename": string docTypeName = ValidationHelper.GetString(row["ClassDisplayName"], null); // Localize class display name if (!string.IsNullOrEmpty(docTypeName)) { return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(docTypeName))); } return(string.Empty); } return(parameter); }
/// <summary> /// Undoes checkout for given node. /// </summary> /// <param name="tree">Tree provider</param> /// <param name="node">Node to undo checkout</param> /// <returns>FALSE when document is checked out and checkbox for undoing checkout is not checked</returns> private bool UndoPossibleCheckOut(TreeProvider tree, TreeNode node) { if (node.IsCheckedOut) { if (chkUndoCheckOut.Checked && ((CurrentUser.UserID == node.DocumentCheckedOutByUserID) || (CurrentUser.IsAuthorizedPerResource("CMS.Content", "checkinall")))) { TreeProvider.ClearCheckoutInformation(node); node.Update(); } else { string nodeAliasPath = HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")"); if (CurrentUser.UserID != node.DocumentCheckedOutByUserID) { // Get checked out message var user = UserInfoProvider.GetUserInfo(node.DocumentCheckedOutByUserID); string userName = (user != null) ? user.GetFormattedUserName(false) : ""; AddError(String.Format(GetString("editcontent.documentnamecheckedoutbyanother"), nodeAliasPath, userName)); } else { AddError(string.Format(ResHelper.GetString("content.checkedoutdocument"), nodeAliasPath)); } return false; } } return true; }
/// <summary> /// Publishes document. /// </summary> /// <param name="node">Node to publish</param> /// <param name="wm">Workflow manager</param> /// <returns>Whether node is already published</returns> private bool Publish(TreeNode node, WorkflowManager wm) { string pathCulture = HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")"); WorkflowStepInfo currentStep = wm.GetStepInfo(node); bool alreadyPublished = (currentStep == null) || currentStep.StepIsPublished; if (!alreadyPublished) { using (new CMSActionContext { LogEvents = false }) { // Remove possible checkout if (node.DocumentCheckedOutByUserID > 0) { TreeProvider.ClearCheckoutInformation(node); node.Update(); } } // Publish document currentStep = wm.PublishDocument(node); } // Document is already published, check if still under workflow if (alreadyPublished && (currentStep != null) && currentStep.StepIsPublished) { WorkflowScopeInfo wsi = wm.GetNodeWorkflowScope(node); if (wsi == null) { VersionManager vm = VersionManager.GetInstance(node.TreeProvider); vm.RemoveWorkflow(node); } } // Document already published if (alreadyPublished) { AddLog(string.Format(ResHelper.GetString("content.publishedalready"), pathCulture)); } else if ((currentStep == null) || !currentStep.StepIsPublished) { AddError(string.Format(ResHelper.GetString("content.PublishWasApproved"), pathCulture)); return true; } else { // Add log record AddLog(pathCulture); } return false; }
public string GetJobs() { string resultCount = string.Empty; oJob = new RecuritingAPI(sEndpoint, sUser, sPass); Get_Job_Postings_RequestType oRequest = new Get_Job_Postings_RequestType(); WorkdayAPI.RecuritingService1.Response_FilterType oRespFilter = new WorkdayAPI.RecuritingService1.Response_FilterType(); Job_Posting_Response_GroupType oRespGroup = new Job_Posting_Response_GroupType(); Job_Posting_Site_Request_ReferencesType siteref = new Job_Posting_Site_Request_ReferencesType(); Job_Posting_SiteObjectType jobsiteObj = new Job_Posting_SiteObjectType(); Job_Posting_SiteObjectIDType ID = new Job_Posting_SiteObjectIDType(); // TODO: need to investigate the purpose of those values below and if we can move them into the appSettings ID.type = "WID"; ID.Value = "03ca6cbf24cc10fabe92ff4b5f82a0ac"; jobsiteObj.ID = new Job_Posting_SiteObjectIDType[1]; jobsiteObj.ID[0] = ID; siteref.Job_Posting_Site_Reference = new Job_Posting_SiteObjectType[1]; siteref.Job_Posting_Site_Reference[0] = jobsiteObj; Job_Posting_Request_CriteriaType criteria = new Job_Posting_Request_CriteriaType(); criteria.Job_Posting_Site_Reference = siteref.Job_Posting_Site_Reference; criteria.Show_Only_Active_Job_PostingsSpecified = true; criteria.Show_Only_Active_Job_Postings = true; oRequest.Request_Criteria = criteria; oRespFilter.Count = 999; oRespFilter.CountSpecified = true; oRequest.Response_Filter = oRespFilter; oRespGroup.Include_Reference = true; oRespGroup.Include_Job_Requisition_Restrictions_Data = true; oRespGroup.Include_Job_Requisition_Definition_Data = true; oRespGroup.Include_Qualifications = true; oRespGroup.Include_Job_Requisition_Attachments = false; oRequest.Response_Group = oRespGroup; Get_Job_Postings_ResponseType oResponse = oJob.GetJobPosting(oRequest, oRespFilter, oRespGroup); string jobsxml = XmlTools.ToXmlString(oResponse); jobsxml = jobsxml.Replace("utf-16", "utf-8"); xmlDocument = xmlDocument + DateTime.Now.Ticks + ".xml"; using (System.IO.StreamWriter file = new System.IO.StreamWriter(xmlDocument)) { file.Write(jobsxml); } XmlDocument doc = new XmlDocument(); doc.Load(xmlDocument); var nodes = doc.GetElementsByTagName("d1p1:Job_Posting_Data"); int jobsCreatedCount = 0; int jobsUpdatedCount = 0; int jobsErrorCount = 0; int jobsDeletedCount = 0; string jobsDeletedID = "", jobsUpdatedID = "", jobsErrorID = "", jobsCreatedID = ""; TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode parentNode = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/Company/Jobs", "en-us"); DocumentQuery cmsjobs = DocumentHelper.GetDocuments("AT.Jobs") .Path("/Company/Jobs", PathTypeEnum.Children) .OnSite(SiteContext.CurrentSiteName); foreach (XmlNode xn in nodes) { var jobPostingID = xn.ChildNodes.Item(0).InnerText.ToString(); try { bool isJobInCMS = false; foreach (var jobs in cmsjobs) { string jobsID = jobs.GetValue("Job_Posting_ID").ToString(); if (jobsID.ToString().ToLower() == xn.ChildNodes.Item(0).InnerText.ToString().ToLower()) { if (parentNode != null) { var documents = DocumentHelper.GetDocuments() .Types("AT.Jobs") .Path("/Company/Jobs", PathTypeEnum.Children) .WhereLike("Job_Posting_ID", jobPostingID) .OnSite(SiteContext.CurrentSiteName) .Culture("en-us") .WithCoupledColumns(); if (!DataHelper.DataSourceIsEmpty(documents) && documents.Tables[0].Rows.Count == 1) { // Loop through all documents foreach (DataRow documentRow in documents.Tables[0].Rows) { // Create a new Tree node from the data row CMS.DocumentEngine.TreeNode editDocument = CMS.DocumentEngine.TreeNode.New("AT.Jobs", documentRow, tree); // Change coupled data SetNodeValue(xn, editDocument); editDocument.Update(); } } jobsUpdatedCount++; jobsUpdatedID += jobPostingID + "\r\n"; } isJobInCMS = true; break; } } if (!isJobInCMS) { if (parentNode != null) { // Create a new instance of the Tree node CMS.DocumentEngine.TreeNode newNode = CMS.DocumentEngine.TreeNode.New("AT.Jobs", tree); // Set the document's properties newNode.DocumentName = xn.ChildNodes.Item(1).InnerText; newNode.DocumentCulture = "en-us"; SetNodeValue(xn, newNode); newNode.Insert(parentNode); jobsCreatedCount++; jobsCreatedID += jobPostingID + "\r\n"; } else { EventLogProvider.LogInformation("No parent", "No parent", "Page can't be created as there is no parent page."); } } } catch (Exception ex) { jobsErrorCount++; jobsErrorID += jobPostingID + "\r\n"; } finally { CleanupXMLFIles(); } } string result = jobsCreatedCount + " Jobs were created and " + jobsUpdatedCount + " Jobs were updated and " + jobsDeletedCount + " Jobs were deleted and " + jobsErrorCount + " Jobs have errors."; string reportResults = String.Format("{0} \r\n\r\n========List of jobs created IDs========\r\n\r\n {1}\r\n========List of jobs updated IDs========\r\n\r\n {2}\r\n========List of jobs deleted IDs========\r\n\r\n {3}\r\n========List of jobs with error IDs========\r\n\r\n {4}", result, jobsCreatedID, jobsUpdatedID, jobsDeletedID, jobsErrorID); EventLogProvider.LogEvent(EventType.INFORMATION, "Workday", "Workday Import Report", reportResults); return(result); }