/// <summary> /// Saves new wokflow step's data into DB. /// </summary> /// <returns>Returns ID of created wokflow step</returns> protected int SaveNewWorkflowStep() { WorkflowStepInfo wsi = new WorkflowStepInfo(); wsi.StepDisplayName = txtWorkflowDisplayName.Text; wsi.StepName = txtWorkflowCodeName.Text; // Get published step info for the proper position WorkflowStepInfo psi = WorkflowStepInfoProvider.GetPublishedStep(workflowid); if (psi != null) { wsi.StepOrder = psi.StepOrder; // Move the published step down psi.StepOrder += 1; WorkflowStepInfoProvider.SetWorkflowStepInfo(psi); // Move the archived step down WorkflowStepInfo asi = WorkflowStepInfoProvider.GetArchivedStep(workflowid); if (asi != null) { asi.StepOrder += 1; WorkflowStepInfoProvider.SetWorkflowStepInfo(asi); } } wsi.StepWorkflowID = workflowid; WorkflowStepInfoProvider.SetWorkflowStepInfo(wsi); return(wsi.StepID); }
protected void Page_Load(object sender, EventArgs e) { workflowStepId = QueryHelper.GetInteger("workflowstepid", 0); string currentWorkflowStep = null; int workflowId = 0; if (workflowStepId > 0) { wsi = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowStepId); // Set edited object EditedObject = wsi; if (wsi != null) { workflowId = wsi.StepWorkflowID; currentWorkflowStep = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowStepId).StepDisplayName; } } string workflowStepsUrl = "~/CMSModules/Workflows/Workflow_Steps.aspx?workflowid=" + workflowId + "&showtab=steps"; string workflowSteps = GetString("Publish.WorkflowSteps"); if (!RequestHelper.IsPostBack()) { InitalizeMenu(); } // Initialize PageTitle InitializeMasterPage(workflowSteps, workflowStepsUrl, currentWorkflowStep); }
protected void btnRefresh_Click(object sender, EventArgs e) { TreeNode node = DocumentManager.Node; // Check permission to modify document if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Ensure version for later detection whether node is published node.VersionManager.EnsureVersion(node, node.IsPublished); // Tree refresh is needed only if node was archived or published WorkflowStepInfo currentStep = node.WorkflowStep; bool refreshTree = (currentStep != null) && (currentStep.StepIsArchived || currentStep.StepIsPublished); // Move to edit step node.MoveToFirstStep(); // Refresh tree if (refreshTree) { ScriptHelper.RefreshTree(this, node.NodeID, node.NodeID); } // Reload form formElem.LoadForm(true); if (DocumentManager.SaveChanges) { ScriptHelper.RegisterStartupScript(this, typeof(string), "moveToEditStepChange", ScriptHelper.GetScript("Changed();")); } } }
/// <summary> /// Creates process. Called when the "Create process" button is pressed. /// </summary> private bool CreateProcess() { // Create new process object and set its properties WorkflowInfo newProcess = new WorkflowInfo() { WorkflowDisplayName = "My new process", WorkflowName = "MyNewProcess", WorkflowType = WorkflowTypeEnum.Automation, WorkflowRecurrenceType = ProcessRecurrenceTypeEnum.Recurring }; // Save the process WorkflowInfoProvider.SetWorkflowInfo(newProcess); // Create default steps WorkflowStepInfoProvider.CreateDefaultWorkflowSteps(newProcess); // Get the step with codename 'Finished' and allow Move to previous WorkflowStepInfo finishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Finished", newProcess.WorkflowID); finishedStep.StepAllowReject = true; // Save the 'Finished' step WorkflowStepInfoProvider.SetWorkflowStepInfo(finishedStep); return(true); }
/// <summary> /// Saves new wokflow step's data into DB. /// </summary> /// <returns>Returns ID of created wokflow step</returns> protected int SaveNewWorkflowStep() { WorkflowStepInfo wsi = new WorkflowStepInfo(); wsi.StepDisplayName = txtWorkflowDisplayName.Text; wsi.StepName = txtWorkflowCodeName.Text; // Get published step info for the proper position WorkflowStepInfo psi = WorkflowStepInfoProvider.GetPublishedStep(workflowid); if (psi != null) { wsi.StepOrder = psi.StepOrder; // Move the published step down psi.StepOrder += 1; WorkflowStepInfoProvider.SetWorkflowStepInfo(psi); // Move the archived step down WorkflowStepInfo asi = WorkflowStepInfoProvider.GetArchivedStep(workflowid); if (asi != null) { asi.StepOrder += 1; WorkflowStepInfoProvider.SetWorkflowStepInfo(asi); } } wsi.StepWorkflowID = workflowid; WorkflowStepInfoProvider.SetWorkflowStepInfo(wsi); return wsi.StepID; }
protected void Page_Init(object sender, EventArgs e) { node = (TreeNode)Form.EditedObject; TreeNode workflowNode; if (Form.IsInsertMode) { workflowNode = (TreeNode)Form.ParentObject; } else { workflowNode = (TreeNode)Form.EditedObject; } // Setup the workflow information WorkflowManager wm = WorkflowManager.GetInstance(new TreeProvider(CMSContext.CurrentUser)); WorkflowInfo wi = wm.GetNodeWorkflow(workflowNode); if (wi != null) { // Get current step info, do not update document WorkflowStepInfo si = wm.GetStepInfo(workflowNode) ?? WorkflowStepInfoProvider.GetFirstStep(wi.WorkflowID); // Set IsWorkflow. mIsWorkflow = !string.IsNullOrEmpty(si.StepName); } else { mIsWorkflow = false; } }
/// <summary> /// Creates process transitions. Called when the "Create transitions" button is pressed. /// Expects the CreateProcess and CreateProcessStep method to be run first. /// </summary> private bool CreateProcessTransitions() { // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (process != null) { // Get the previously created process step WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewProcessStep", process.WorkflowID); // Get the step with codename 'Finished' WorkflowStepInfo finishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Finished", process.WorkflowID); if ((step != null) && (finishedStep != null)) { // Get existed transition from 'Start' step to 'Finished' step InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(process.WorkflowID, null, null, 1, null); WorkflowTransitionInfo existedTransition = transitions.First <WorkflowTransitionInfo>(); // Change existed transition to leads from 'Start' step to 'My new step' step existedTransition.TransitionEndStepID = step.StepID; // Save existed transition WorkflowTransitionInfoProvider.SetWorkflowTransitionInfo(existedTransition); // Connect 'My new step' step to 'Finished' step step.ConnectTo(step.StepDefinition.SourcePoints[0].Guid, finishedStep); return(true); } } return(false); }
/// <summary> /// Refresh button click event handler. /// </summary> protected void btnRefresh_Click(object sender, EventArgs e) { if (Node != null) { // Check permission to modify document if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Ensure version for later detection whether node is published Node.VersionManager.EnsureVersion(Node, Node.IsPublished); // Get workflow manager WorkflowManager wm = WorkflowManager.GetInstance(Tree); // Tree refresh is needed only if node was archived or published WorkflowStepInfo currentStep = wm.GetStepInfo(Node); bool refreshTree = (currentStep != null) && (currentStep.StepIsArchived || currentStep.StepIsPublished); // Move to edit step wm.MoveToFirstStep(Node); // Refresh frames and tree string script = "if(window.FramesRefresh){FramesRefresh(" + refreshTree.ToString().ToLowerCSafe() + ", " + Node.NodeID + ");}"; ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAction", ScriptHelper.GetScript(script)); } } }
/// <summary> /// Gets the automation state and move contact to specific step. Called when the "Move to specific step" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool MoveContactToSpecificStep() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; var contacts = ContactInfoProvider.GetContacts().Where(where).TopN(topN); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null)) { // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Get the automation state AutomationStateInfo state = contact.Processes.FirstItem as AutomationStateInfo; if (state != null) { // Get the finished step WorkflowStepInfo finishedStep = manager.GetFinishedStep(contact, state); // Move contact to specific step manager.MoveToSpecificStep(contact, state, finishedStep, "Move to specific step"); return(true); } } return(false); }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that threw event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void OnAction(string actionName, object actionArgument) { int workflowstepid = Convert.ToInt32(actionArgument); if (actionName == "delete") { // Check if documents use the workflow WorkflowStepInfo si = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid); if (si != null) { List <string> documentNames = new List <string>(); if (WorkflowStepInfoProvider.CheckDependencies(workflowstepid, ref documentNames)) { // Encode and localize names StringBuilder sb = new StringBuilder(); documentNames.ForEach(item => sb.Append("<br />", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(item)))); Control.ShowError(Control.GetString("Workflow.CannotDeleteStepUsed"), Control.GetString("workflow.documentlist") + sb); } else { // Delete the workflow step WorkflowStepInfoProvider.DeleteWorkflowStepInfo(workflowstepid); } } } else if (actionName == "moveup") { WorkflowStepInfoProvider.MoveStepUp(WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid)); } else if (actionName == "movedown") { WorkflowStepInfoProvider.MoveStepDown(WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid)); } }
/// <summary> /// Getting WorkFlowStatus by noadAliaspath /// </summary> /// <param name="data">noadAliaspath</param> public static string WorkFlowStatusBynodeAliasPath(string nodeAliasPath) { // Create an instance of the Tree provider first //TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeProvider tree = new TreeProvider(); // Get the document TreeNode node = tree.SelectSingleNode(SiteContext.CurrentSiteName, nodeAliasPath, "en-us", false, null, false, false, false); var workFlow = string.Empty; if (node != null) { //Get the document per NodeID and culture TreeNode tn = tree.SelectSingleNode(node.NodeID, "en-us"); //Return its workflow step ID int iStepID = tn.DocumentWorkflowStepID; if (iStepID > 0) { // Get workflow step display name WorkflowStepInfo wsi = WorkflowStepInfoProvider.GetWorkflowStepInfo(iStepID); if (wsi != null) { workFlow = ResHelper.LocalizeString(wsi.StepDisplayName); } } } return(workFlow); }
/// <summary> /// Creates workflow transitions. Called when the "Create transition" button is pressed. /// Expects the CreateWorklow and CreateStep method to be run first. /// </summary> private bool CreateTransition() { // Get the workflow WorkflowInfo worklow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval); if (worklow != null) { // Get steps with codename 'MyNewStep' and 'Published' WorkflowStepInfo myNewStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewStep", worklow.WorkflowID); WorkflowStepInfo publishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Published", worklow.WorkflowID); if ((myNewStep != null) && (publishedStep != null)) { // Get existing transition leading to 'Published step' string where = "TransitionEndStepID = " + publishedStep.StepID; InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(worklow.WorkflowID, where, null, 1, null); WorkflowTransitionInfo existingTransition = transitions.First <WorkflowTransitionInfo>(); // Change existing transition to leads from 'Start step' to 'My new step' existingTransition.TransitionEndStepID = myNewStep.StepID; // Save existing transition WorkflowTransitionInfoProvider.SetWorkflowTransitionInfo(existingTransition); // Connect 'My new step' step to 'Published' step myNewStep.ConnectTo(myNewStep.StepDefinition.SourcePoints[0].Guid, publishedStep); return(true); } } return(false); }
/// <summary> /// Archive event handler. /// </summary> protected void btnArchive_Click(object sender, EventArgs e) { // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } // Get original step WorkflowStepInfo originalStep = WorkflowManager.GetStepInfo(Node); // Archive document WorkflowStepInfo nextStep = WorkflowManager.ArchiveDocument(Node, txtComment.Text); currentStepId = nextStep.StepID; // Send workflow e-mails if (chkSendMail.Checked && SendWorkflowEmails) { WorkflowManager.SendWorkflowEmails(Node, CMSContext.CurrentUser, originalStep, nextStep, WorkflowActionEnum.Archived, txtComment.Text); } ClearComment(); string siteName = CMSContext.CurrentSiteName; // Refresh tree if (UIHelper.DisplayArchivedIcon(siteName) || UIHelper.DisplayPublishedIcon(siteName) || UIHelper.DisplayNotPublishedIcon(siteName)) { ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshTree", ScriptHelper.GetScript("RefreshTree(" + Node.NodeParentID + ", " + Node.NodeID + ");")); } }
/// <summary> /// Reject event handler. /// </summary> protected void btnReject_Click(object sender, EventArgs e) { // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } // Get original step WorkflowStepInfo originalStep = WorkflowManager.GetStepInfo(Node); // Reject document WorkflowStepInfo previousStep = WorkflowManager.MoveToPreviousStep(Node, txtComment.Text); currentStepId = previousStep.StepID; // Send workflow e-mails if (chkSendMail.Checked && SendWorkflowEmails) { WorkflowManager.SendWorkflowEmails(Node, CMSContext.CurrentUser, originalStep, previousStep, WorkflowActionEnum.Rejected, txtComment.Text); } ClearComment(); string siteName = CMSContext.CurrentSiteName; // Refresh tree when original step name was 'published' and icon published or icon not published should be displayed if ((originalStep.StepName.ToLower() == "published") && (UIHelper.DisplayPublishedIcon(siteName) || UIHelper.DisplayNotPublishedIcon(siteName))) { ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshTree", ScriptHelper.GetScript("RefreshTree(" + Node.NodeParentID + ", " + Node.NodeID + ");")); } }
/// <summary> /// Deletes workflow transition. Called when the "Delete transition" button is pressed. /// Expects the CreateWorklow and CreateTransitions method to be run first. /// </summary> private bool DeleteTransition() { // Get the process WorkflowInfo worklow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval); if (worklow != null) { // Get step WorkflowStepInfo startStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewStep", worklow.WorkflowID); if (startStep != null) { // Get existing transition leading from 'My new step' string where = "TransitionStartStepID = " + startStep.StepID; InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(worklow.WorkflowID, where, null, 1, null); WorkflowTransitionInfo existingTransition = transitions.First <WorkflowTransitionInfo>(); if (existingTransition != null) { // Delete transition WorkflowTransitionInfoProvider.DeleteWorkflowTransitionInfo(existingTransition); return(true); } } } return(false); }
/// <summary> /// Saves new workflow step's data into DB. /// </summary> /// <returns>Returns ID of created workflow step</returns> protected int SaveNewWorkflowStep() { SetFormValues(CurrentStepInfo); // Ensure correct order for basic workflow if (CurrentWorkflow.IsBasic) { // Get published step info for the proper position WorkflowStepInfo psi = WorkflowStepInfoProvider.GetPublishedStep(WorkflowID); if (psi != null) { CurrentStepInfo.StepOrder = psi.StepOrder; // Move the published step down psi.StepOrder += 1; WorkflowStepInfoProvider.SetWorkflowStepInfo(psi); // Move the archived step down WorkflowStepInfo asi = WorkflowStepInfoProvider.GetArchivedStep(WorkflowID); if (asi != null) { asi.StepOrder += 1; WorkflowStepInfoProvider.SetWorkflowStepInfo(asi); } } } CurrentStepInfo.StepWorkflowID = WorkflowID; WorkflowStepInfoProvider.SetWorkflowStepInfo(CurrentStepInfo); return(CurrentStepInfo.StepID); }
/// <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 static bool Publish(TreeNode node, WorkflowManager wm) { WorkflowStepInfo currentStep = wm.GetStepInfo(node); bool toReturn = true; if (currentStep != null) { // For archive step start new version if (currentStep.StepName.ToLower() == "archived") { VersionManager vm = new VersionManager(node.TreeProvider); currentStep = vm.CheckOut(node, node.IsPublished, true); vm.CheckIn(node, null, null); } // Remove possible checkout if (node.GetIntegerValue("DocumentCheckedOutByUserID") > 0) { TreeProvider.ClearCheckoutInformation(node); node.Update(); } // Approve until the document is published while ((currentStep != null) && (currentStep.StepName.ToLower() != "published")) { currentStep = wm.MoveToNextStep(node, string.Empty); toReturn = false; } } return(toReturn); }
/// <summary> /// Creates a new workflow step. Called when the "Create workflow step" button is pressed. /// Expects the CreateWorkflow method to be run first. /// </summary> private bool CreateWorkflowStep() { // Get the workflow WorkflowInfo myWorkflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (myWorkflow != null) { // Create new workflow step object WorkflowStepInfo newStep = new WorkflowStepInfo(); // Set the properties newStep.StepWorkflowID = myWorkflow.WorkflowID; newStep.StepName = "MyNewWorkflowStep"; newStep.StepDisplayName = "My new workflow step"; newStep.StepOrder = 1; newStep.StepType = WorkflowStepTypeEnum.Standard; // Save the step into database WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep); // Ensure correct step order WorkflowStepInfoProvider.InitStepOrders(myWorkflow); return(true); } return(false); }
/// <summary> /// UniGrid external data bound. /// </summary> private object gridDocs_OnExternalDataBound(object sender, string sourceName, object parameter) { sourceName = sourceName.ToLowerCSafe(); switch (sourceName) { // Column 'DocumentWorkflowStepID' case "documentworkflowstepid": int stepId = ValidationHelper.GetInteger(parameter, 0); if (stepId > 0) { // Get workflow step display name WorkflowStepInfo wsi = WorkflowStepInfoProvider.GetWorkflowStepInfo(stepId); if (wsi != null) { return(ResHelper.LocalizeString(wsi.StepDisplayName)); } } break; // Column 'Published' case "published": bool published = ValidationHelper.GetBoolean(parameter, true); return(published ? GetString("General.Yes") : GetString("General.No")); case "documentmodifiedwhen": case "documentmodifiedwhentooltip": TimeZoneInfo tzi = null; // Get current time for user contribution list on live site string result = TimeZoneMethods.GetDateTimeForControl(this, ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME), out tzi).ToString(); // Display time zone shift if needed if ((tzi != null) && TimeZoneHelper.TimeZonesEnabled) { if (sourceName.EndsWithCSafe("tooltip")) { result = TimeZoneHelper.GetUTCLongStringOffset(tzi); } else { result += TimeZoneHelper.GetUTCStringOffset(tzi); } } return(result); // Action 'edit' case "edit": ((Control)sender).Visible = AllowEdit && CheckGroupPermission("editpages"); break; // Action 'delete' case "delete": ((Control)sender).Visible = AllowDelete && CheckGroupPermission("deletepages"); break; } return(parameter); }
/// <summary> /// Sets values from edit form to edited workflows step info /// </summary> /// <param name="step">Edited workflow step info</param> private void SetFormValues(WorkflowStepInfo step) { if (step == null) { return; } if (ShowTimeoutForm) { Step definition = step.StepDefinition; definition.TimeoutEnabled = ucTimeout.TimeoutEnabled; definition.TimeoutInterval = ucTimeout.ScheduleInterval; if (ucTimeoutTarget.Visible) { Guid timeoutTarget = ucTimeoutTarget.SourcePointGuid; // Add timeout source point if (step.StepAllowDefaultTimeoutTarget && !definition.SourcePoints.Exists(s => (s is TimeoutSourcePoint))) { TimeoutSourcePoint timeout = new TimeoutSourcePoint(); // Timeout source point is selected if (!definition.SourcePoints.Exists(s => (s.Guid == timeoutTarget))) { timeout.Guid = timeoutTarget; } definition.SourcePoints.Add(timeout); } definition.TimeoutTarget = timeoutTarget; } else { // Remove timeout source point var timeoutPoints = definition.SourcePoints.FindAll(s => (s is TimeoutSourcePoint)); foreach (var t in timeoutPoints) { string result = step.RemoveSourcePoint(t.Guid); if (result != null) { ShowError(result); } } } } if (step.StepIsAction && ucActionParameters.Visible) { step.StepActionParameters.LoadData(ucActionParameters.Parameters.GetData()); } if (plcCondition.Visible) { CurrentStepInfo.StepDefinition.DefinitionPoint.Text = ucSourcePointEdit.CurrentSourcePoint.Text; CurrentStepInfo.StepDefinition.DefinitionPoint.Tooltip = ucSourcePointEdit.CurrentSourcePoint.Tooltip; CurrentStepInfo.StepDefinition.DefinitionPoint.Condition = ucSourcePointEdit.CurrentSourcePoint.Condition; CurrentStepInfo.StepDefinition.DefinitionPoint.Label = ucSourcePointEdit.CurrentSourcePoint.Label; } }
private bool GetShowCondition(WorkflowStepInfo step) { if (CurrentWorkflow.IsAutomation && step.StepType == WorkflowStepTypeEnum.Wait) { return(false); } return(step.StepType != WorkflowStepTypeEnum.Userchoice && step.StepType != WorkflowStepTypeEnum.Multichoice && step.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin); }
/// <summary> /// Reloads the form status. /// </summary> protected void SetupForm() { // Check modify permissions if ((CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) && !CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Content", "ManageWorkflow")) { ShowInfo(String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath), true); } else { bool autoPublishChanges = false; // Check if auto publish changes is allowed if (WorkflowInfo != null) { autoPublishChanges = WorkflowInfo.WorkflowAutoPublishChanges; } if ((WorkflowInfo != null) || (currentStepId > 0)) { // Setup the form WorkflowStepInfo stepInfo = null; if (Node.IsPublished && (Node.DocumentCheckedOutVersionHistoryID <= 0)) { stepInfo = WorkflowStepInfoProvider.GetPublishedStep(WorkflowInfo.WorkflowID); } else { stepInfo = WorkflowStepInfoProvider.GetWorkflowStepInfo(currentStepId) ?? WorkflowStepInfoProvider.GetFirstStep(WorkflowInfo.WorkflowID); } if (stepInfo != null) { currentStepId = stepInfo.StepID; if (plcAdvanced.Visible) { ucDesigner.SelectedStepID = currentStepId; } } } } // Check if document isn't checked out if (DocumentIsCheckedOut) { ShowInfo(GetString("WorfklowProperties.DocumentIsCheckedOut"), true); } // If no workflow scope set for node, hide the data if (WorkflowInfo == null) { lblWorkflow.Text = GetString("properties.scopenotset"); lblWorkflow.Visible = true; pnlWorkflow.Visible = false; } }
/// <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); }
public IHttpActionResult ReturnTask(WorkflowStepInfo info) { var task = TaskWork.GetTaskBySN(info.SN); if (task == null || task.Status != TaskWorkStatus.UnFinish) { return(Ok()); } var entityId = new Guid(info.EntityID); string projectId = string.Empty; switch (info.WorkflowName) { case FlowCode.Closure_ClosurePackage: var closurePackage = ClosurePackage.Get(entityId); projectId = closurePackage.ProjectId; break; case FlowCode.TempClosure_ClosurePackage: var tempClosurePackage = TempClosurePackage.Get(entityId); projectId = tempClosurePackage.ProjectId; break; case FlowCode.MajorLease_Package: var majorLeasePackage = MajorLeaseChangePackage.Get(entityId); projectId = majorLeasePackage.ProjectId; break; case FlowCode.Rebuild_Package: var rebuildPackage = RebuildPackage.Get(entityId); projectId = rebuildPackage.ProjectId; break; case FlowCode.Renewal_Package: var renewalPackage = RenewalPackage.Get(entityId); projectId = renewalPackage.ProjectId; break; case FlowCode.Reimage_Package: var reimagePackage = RenewalPackage.Get(entityId); projectId = reimagePackage.ProjectId; break; default: break; } if (!string.IsNullOrEmpty(projectId)) { TaskWork.Finish(e => e.RefID == projectId && e.TypeCode == info.WorkflowName && e.Status == TaskWorkStatus.UnFinish && e.ActivityName != "Originator"); } return(Ok()); }
/// <summary> /// Sets values from edit form to edited workflows step info /// </summary> /// <param name="wsi">Edited workflow step info</param> private void SetFormValues(WorkflowStepInfo wsi) { if (wsi != null) { wsi.StepDisplayName = txtWorkflowStepDisplayName.Text; wsi.StepName = txtWorkflowStepCodeName.Text; wsi.StepAllowReject = chkAllowReject.Checked; wsi.StepAllowPublish = chkAllowPublish.Checked; if (ShowTimeout) { Step definition = wsi.StepDefinition; definition.TimeoutEnabled = ucTimeout.TimeoutEnabled; definition.TimeoutInterval = ucTimeout.ScheduleInterval; if (ucTimeoutTarget.Visible) { Guid timeouTarget = ucTimeoutTarget.SourcePointGuid; // Add timeout source point if (wsi.StepAllowDefaultTimeoutTarget && !definition.SourcePoints.Exists(s => (s is TimeoutSourcePoint))) { TimeoutSourcePoint timeout = new TimeoutSourcePoint(); // Timeout source point is selected if (!definition.SourcePoints.Exists(s => (s.Guid == timeouTarget))) { timeout.Guid = timeouTarget; } definition.SourcePoints.Add(timeout); } definition.TimeoutTarget = timeouTarget; } else { // Remove timeout source point var timeoutPoints = definition.SourcePoints.FindAll(s => (s is TimeoutSourcePoint)); foreach (var t in timeoutPoints) { string result = wsi.RemoveSourcePoint(t.Guid); if (result != null) { ShowError(result); } } } } if (wsi.StepIsAction) { wsi.StepActionParameters.LoadData(ucActionParameters.Parameters.GetData()); } } }
private string GetActionText(WorkflowStepInfo currentStep, WorkflowStepInfo nextStep) { string text = ResHelper.LocalizeString(nextStep.StepDisplayName); WorkflowTransitionInfo transition = nextStep.RelatedTransition; SourcePoint def = (transition != null) ? currentStep.GetSourcePoint(transition.TransitionSourcePointGUID) : null; if (!String.IsNullOrEmpty(def?.Text)) { text = String.Format(ResHelper.LocalizeString(def.Text), text); } return(text); }
private bool CanAddSourcePoint(WorkflowStepInfo step) { if (step != null) { Node node = WorkflowNode.GetInstance(step); if (NodeSourcePointsLimits.Max[node.Type] <= step.StepDefinition.SourcePoints.Count) { return(false); } return(true); } return(false); }
/// <summary> /// Loads data of edited workflow from DB into TextBoxes. /// </summary> protected void LoadData(WorkflowStepInfo wsi) { txtWorkflowStepCodeName.Text = wsi.StepName; switch (wsi.StepName.ToLower()) { case "edit": case "published": case "archived": txtWorkflowStepCodeName.Enabled = false; break; } txtWorkflowStepDisplayName.Text = wsi.StepDisplayName; }
private bool CanAddSourcePoint(WorkflowStepInfo step) { if (step != null) { Node node = WorkflowNode.GetInstance(step); if (NodeSourcePointsLimits.Max[node.Type] <= step.StepDefinition.SourcePoints.Count) { return false; } return true; } return false; }
private void ClearProperties() { // Clear actions next = null; specific = null; previous = null; delete = null; start = null; mStep = null; // Clear security result AutomationManager.ClearProperties(); }
/// <summary> /// Approve event handler. /// </summary> protected void btnApprove_Click(object sender, EventArgs e) { // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } // Get original step WorkflowStepInfo originalStep = WorkflowManager.GetStepInfo(Node); // Approve document WorkflowStepInfo nextStep = WorkflowManager.MoveToNextStep(Node, txtComment.Text); // Send workflow e-mails if (chkSendMail.Checked && SendWorkflowEmails) { if ((nextStep == null) || (nextStep.StepName.ToLower() == "published")) { // Publish e-mails WorkflowManager.SendWorkflowEmails(Node, CMSContext.CurrentUser, originalStep, nextStep, WorkflowActionEnum.Published, txtComment.Text); } else { // Approve e-mails WorkflowManager.SendWorkflowEmails(Node, CMSContext.CurrentUser, originalStep, nextStep, WorkflowActionEnum.Approved, txtComment.Text); } } ClearComment(); if (nextStep != null) { currentStepId = nextStep.StepID; } else { // If no next step (workflow cancelled), hide the form lblInfo.Text = GetString("WorfklowProperties.WorkflowFinished"); pnlWorkflow.Visible = false; } string siteName = CMSContext.CurrentSiteName; // Refresh tree if document is published and icon published or not published or version not published should be displayed if (DocumentIsPublished(Node) && (UIHelper.DisplayPublishedIcon(siteName) || UIHelper.DisplayNotPublishedIcon(siteName) || UIHelper.DisplayVersionNotPublishedIcon(siteName))) { ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshTree", ScriptHelper.GetScript("RefreshTree(" + Node.NodeParentID + ", " + Node.NodeID + ");")); } }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { if (ddlSourcePoints.Items.Count == 0) { WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo(WorkflowStepID); if (step != null) { Step definition = step.StepDefinition; if ((definition == null) || (definition.SourcePoints == null)) { Visible = false; } else { List <SourcePoint> sourcePoints = definition.SourcePoints; Guid?defaultCase = null; List <WorkflowTransitionInfo> connections = WorkflowTransitionInfoProvider.GetStepTransitions(step, null); foreach (SourcePoint sp in sourcePoints) { AddItem(sp, connections); if (sp.Type == SourcePointTypeEnum.SwitchDefault) { defaultCase = sp.Guid; } } // Ensure default source point for timeout if (step.StepAllowDefaultTimeoutTarget && !sourcePoints.Exists(s => (s is TimeoutSourcePoint))) { AddItem(new TimeoutSourcePoint(), connections); } if (definition.TimeoutTarget != Guid.Empty) { ddlSourcePoints.SelectedValue = definition.TimeoutTarget.ToString(); } else if (defaultCase.HasValue) { ddlSourcePoints.SelectedValue = defaultCase.Value.ToString(); } } } } // Set visibility Visible = IsVisible(); }
private string GetActionText(WorkflowStepInfo currentStep, WorkflowStepInfo nextStep) { string text = ResHelper.LocalizeString(nextStep.StepDisplayName); WorkflowTransitionInfo transition = nextStep.RelatedTransition; SourcePoint def = (transition != null) ? currentStep.GetSourcePoint(transition.TransitionSourcePointGUID) : null; if (def != null) { if (!string.IsNullOrEmpty(def.Text)) { text = string.Format(ResHelper.LocalizeString(def.Text), text); } } return text; }
protected static object stepsGrid_OnExternalDataBound(object sender, string sourceName, object parameter) { WorkflowStepTypeEnum stepType = WorkflowStepTypeEnum.Undefined; GridViewRow container = null; switch (sourceName.ToLowerCSafe()) { case "allowaction": container = (GridViewRow)parameter; stepType = (WorkflowStepTypeEnum)ValidationHelper.GetInteger(DataHelper.GetDataRowViewValue((DataRowView)container.DataItem, "StepType"), 3); switch (stepType) { case WorkflowStepTypeEnum.DocumentEdit: case WorkflowStepTypeEnum.DocumentPublished: case WorkflowStepTypeEnum.DocumentArchived: ((Control)sender).Visible = false; break; } break; case "steptype": stepType = (WorkflowStepTypeEnum)ValidationHelper.GetInteger(parameter, 3); WorkflowNode node = WorkflowNode.GetInstance(stepType); return HTMLHelper.HTMLEncode(node.Name); case "#objectmenu": container = (GridViewRow)parameter; WorkflowStepInfo step = new WorkflowStepInfo(((DataRowView)container.DataItem).Row); if (step.StepIsDefault) { ImageButton button = ((ImageButton)sender); button.Visible = false; } break; } return parameter; }
/// <summary> /// Creates workflow step. Called when the "Create step" button is pressed. /// Expects the CreateWorkflow method to be run first. /// </summary> private bool CreateStepForTransition() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval); if (workflow != null) { // Create new workflow step object and set its properties WorkflowStepInfo newStep = new WorkflowStepInfo() { StepWorkflowID = workflow.WorkflowID, StepName = "MyNewStep", StepDisplayName = "My new step", StepType = CMS.SettingsProvider.WorkflowStepTypeEnum.Standard }; // Save the step WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep); return true; } return false; }
/// <summary> /// Sets values from edit form to edited workflows step info /// </summary> /// <param name="wsi">Edited workflow step info</param> private void SetFormValues(WorkflowStepInfo wsi) { if (wsi == null) { return; } if (ShowTimeout) { Step definition = wsi.StepDefinition; definition.TimeoutEnabled = ucTimeout.TimeoutEnabled; definition.TimeoutInterval = ucTimeout.ScheduleInterval; if (ucTimeoutTarget.Visible) { Guid timeouTarget = ucTimeoutTarget.SourcePointGuid; // Add timeout source point if (wsi.StepAllowDefaultTimeoutTarget && !definition.SourcePoints.Exists(s => (s is TimeoutSourcePoint))) { TimeoutSourcePoint timeout = new TimeoutSourcePoint(); // Timeout source point is selected if (!definition.SourcePoints.Exists(s => (s.Guid == timeouTarget))) { timeout.Guid = timeouTarget; } definition.SourcePoints.Add(timeout); } definition.TimeoutTarget = timeouTarget; } else { // Remove timeout source point var timeoutPoints = definition.SourcePoints.FindAll(s => (s is TimeoutSourcePoint)); foreach (var t in timeoutPoints) { string result = wsi.RemoveSourcePoint(t.Guid); if (result != null) { ShowError(result); } } } } if (wsi.StepIsAction) { wsi.StepActionParameters.LoadData(ucActionParameters.Parameters.GetData()); } if (plcCondition.Visible) { CurrentStepInfo.StepDefinition.DefinitionPoint.Text = ucSourcePointEdit.CurrentSourcePoint.Text; CurrentStepInfo.StepDefinition.DefinitionPoint.Tooltip = ucSourcePointEdit.CurrentSourcePoint.Tooltip; CurrentStepInfo.StepDefinition.DefinitionPoint.Condition = ucSourcePointEdit.CurrentSourcePoint.Condition; CurrentStepInfo.StepDefinition.DefinitionPoint.Label = ucSourcePointEdit.CurrentSourcePoint.Label; } }
/// <summary> /// Creates process step. Called when the "Create step" button is pressed. /// Expects the CreateProcess method to be run first. /// </summary> private bool CreateProcessStep() { // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (process != null) { // Create new process step object and set its properties WorkflowStepInfo newStep = new WorkflowStepInfo() { StepWorkflowID = process.WorkflowID, StepName = "MyNewProcessStep", StepDisplayName = "My new step", StepType = WorkflowStepTypeEnum.Standard }; // Save the process step WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep); return true; } return false; }
private void ClearProperties() { // Clear actions save = null; saveAnother = null; saveAndClose = null; approve = null; reject = null; checkin = null; checkout = null; undoCheckout = null; archive = null; delete = null; prop = null; spellcheck = null; publish = null; newVersion = null; applyWorkflow = null; mStep = null; // Clear security result DocumentManager.ClearProperties(); }
/// <summary> /// Publishes document. /// </summary> /// <param name="node">Node to publish</param> /// <param name="wm">Workflow manager</param> /// <param name="currentStep">Current workflow step</param> /// <returns>Whether node is already published</returns> private static bool Publish(TreeNode node, WorkflowManager wm, WorkflowStepInfo currentStep) { bool toReturn = true; if (currentStep != null) { // For archive step start new version if (currentStep.StepName.ToLower() == "archived") { VersionManager vm = new VersionManager(node.TreeProvider); currentStep = vm.CheckOut(node, node.IsPublished, true); vm.CheckIn(node, null, null); } // Approve until the step is publish while ((currentStep != null) && (currentStep.StepName.ToLower() != "published")) { currentStep = wm.MoveToNextStep(node, string.Empty); toReturn = false; } // Document is already published, check if still under workflow if (toReturn && (currentStep.StepName.ToLower() == "published")) { WorkflowScopeInfo wsi = wm.GetNodeWorkflowScope(node); if (wsi == null) { DocumentHelper.ClearWorkflowInformation(node); VersionManager vm = new VersionManager(node.TreeProvider); vm.RemoveWorkflow(node); } } } return toReturn; }
/// <summary> /// Loads data of edited workflow from DB into TextBoxes. /// </summary> protected void LoadData(WorkflowStepInfo wsi) { // Don't display settings for archived, edit and action step plcReject.Visible = !wsi.StepIsArchived && !wsi.StepIsEdit && !wsi.StepIsStart && !wsi.StepIsAction; // Change reject label if (CurrentWorkflow.IsAutomation) { lblAllowReject.ResourceString = "WorkflowStep.AllowMoveToPrevious"; lblAllowReject.RefreshText(); } // Display settings for Standard, DocumentEdit and Start step type only plcPublish.Visible = !CurrentWorkflow.IsAutomation && ((wsi.StepType == WorkflowStepTypeEnum.Standard) || wsi.StepIsEdit || wsi.StepIsStart || (wsi.StepType == WorkflowStepTypeEnum.Wait)); // Timeout UI is always enabled for wait step type ucTimeout.AllowNoTimeout = (wsi.StepType != WorkflowStepTypeEnum.Wait); // Display action parameters form only for action step type if (wsi.StepIsAction) { WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(wsi.StepActionID); if (action != null) { if (!RequestHelper.IsPostBack()) { pnlContainer.CssClass += " " + action.ActionName.ToLowerCSafe(); } ucActionParameters.FormInfo = new FormInfo(action.ActionParameters); } ucActionParameters.BasicForm.AllowMacroEditing = true; ucActionParameters.BasicForm.ResolverName = WorkflowHelper.GetResolverName(CurrentWorkflow); ucActionParameters.Parameters = wsi.StepActionParameters; ucActionParameters.ReloadData(!RequestHelper.IsPostBack()); ucActionParameters.Visible = ucActionParameters.CheckVisibility(); pnlParameters.GroupingText = string.Format(GetString("workflowstep.parameters"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(action.ActionDisplayName))); } pnlParameters.Visible = ucActionParameters.Visible; if (plcTimeoutTarget.Visible) { ucTimeoutTarget.WorkflowStepID = WorkflowStepID; } // Initialize condition edit for certain step types ucSourcePointEdit.StopProcessing = true; if (!CurrentWorkflow.IsBasic) { plcStepType.Visible = true; WorkflowNode node = WorkflowNode.GetInstance(wsi.StepType); lblWorkflowStepTypeValue.Text = node.Name; bool conditionStep = (wsi.StepType == WorkflowStepTypeEnum.Condition); if (conditionStep || (wsi.StepType == WorkflowStepTypeEnum.Wait) || (!wsi.StepIsStart && !wsi.StepIsAction && !wsi.StepIsFinished && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin))) { // Initialize source point edit control ucSourcePointEdit.WorkflowStepId = WorkflowStepID; var sourcePoint = CurrentStepInfo.StepDefinition.DefinitionPoint; if (sourcePoint != null) { pnlCondition.Visible = true; pnlCondition.GroupingText = conditionStep ? GetString("workflowstep.conditionsettings") : GetString("workflowstep.advancedsettings"); ucSourcePointEdit.StopProcessing = false; ucSourcePointEdit.SourcePointGuid = sourcePoint.Guid; ucSourcePointEdit.SimpleMode = !conditionStep; ucSourcePointEdit.ShowCondition = (wsi.StepType != WorkflowStepTypeEnum.Userchoice) && (wsi.StepType != WorkflowStepTypeEnum.Multichoice) && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin); ucSourcePointEdit.RuleCategoryNames = CurrentWorkflow.IsAutomation ? ModuleEntry.ONLINEMARKETING : WorkflowObjectType.WORKFLOW; } } } if (!RequestHelper.IsPostBack()) { if (ShowTimeout) { ucTimeout.TimeoutEnabled = wsi.StepDefinition.TimeoutEnabled; ucTimeout.ScheduleInterval = wsi.StepDefinition.TimeoutInterval; } txtWorkflowStepCodeName.Text = wsi.StepName; txtWorkflowStepDisplayName.Text = wsi.StepDisplayName; chkAllowReject.Checked = wsi.StepAllowReject; chkAllowPublish.Checked = wsi.StepAllowPublish; } }
/// <summary> ///Creates the document, workflow scope and step needed for this example. Called when the "Create example objects" button is pressed. /// </summary> private bool CreateExampleObjects() { // Create a new tree provider TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get the root node TreeNode parent = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", "en-us"); if (parent != null) { // Create the API document TreeNode node = TreeNode.New("CMS.MenuItem", tree); node.DocumentName = "API Example"; node.DocumentCulture = "en-us"; // Insert it to database DocumentHelper.InsertDocument(node, parent, tree); // Get the default workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("default"); if (workflow != null) { // Get the document data node = DocumentHelper.GetDocument(node, tree); // Create new workflow scope WorkflowScopeInfo scope = new WorkflowScopeInfo(); // Assign to the default workflow and current site and set starting alias path to the example document scope.ScopeWorkflowID = workflow.WorkflowID; scope.ScopeStartingPath = node.NodeAliasPath; scope.ScopeSiteID = SiteContext.CurrentSiteID; // Save the scope into the database WorkflowScopeInfoProvider.SetWorkflowScopeInfo(scope); // Create a new workflow step WorkflowStepInfo step = new WorkflowStepInfo(); // Set its properties step.StepWorkflowID = workflow.WorkflowID; step.StepName = "MyNewWorkflowStep"; step.StepDisplayName = "My new workflow step"; step.StepOrder = 1; // Save the workflow step WorkflowStepInfoProvider.SetWorkflowStepInfo(step); // Ensure correct step order WorkflowStepInfoProvider.InitStepOrders(workflow); return true; } else { apiCreateExampleObjects.ErrorMessage = "The default workflow was not found."; } } return false; }
/// <summary> /// Loads data of edited workflow from DB into TextBoxes. /// </summary> protected void LoadData(WorkflowStepInfo wsi) { // Timeout UI is always enabled for wait step type ucTimeout.AllowNoTimeout = (wsi.StepType != WorkflowStepTypeEnum.Wait); // Display action parameters form only for action step type if (wsi.StepIsAction) { WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(wsi.StepActionID); if (action != null) { if (!RequestHelper.IsPostBack()) { pnlContainer.CssClass += " " + action.ActionName.ToLowerCSafe(); } ucActionParameters.FormInfo = new FormInfo(action.ActionParameters); lblParameters.Text = String.Format(GetString("workflowstep.parameters"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(action.ActionDisplayName))); } ucActionParameters.BasicForm.AllowMacroEditing = true; ucActionParameters.BasicForm.ShowValidationErrorMessage = false; ucActionParameters.BasicForm.ResolverName = WorkflowHelper.GetResolverName(CurrentWorkflow); ucActionParameters.Parameters = wsi.StepActionParameters; ucActionParameters.ReloadData(!RequestHelper.IsPostBack()); ucActionParameters.Visible = ucActionParameters.CheckVisibility(); } plcParameters.Visible = ucActionParameters.Visible; if (plcTimeoutTarget.Visible) { ucTimeoutTarget.WorkflowStepID = CurrentStepInfo.StepID; } // Initialize condition edit for certain step types ucSourcePointEdit.StopProcessing = true; if ((CurrentWorkflow != null) && !CurrentWorkflow.IsBasic) { bool conditionStep = (wsi.StepType == WorkflowStepTypeEnum.Condition); if (conditionStep || (wsi.StepType == WorkflowStepTypeEnum.Wait) || (!wsi.StepIsStart && !wsi.StepIsAction && !wsi.StepIsFinished && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin))) { // Initialize source point edit control var sourcePoint = CurrentStepInfo.StepDefinition.DefinitionPoint; if (sourcePoint != null) { plcCondition.Visible = true; lblCondition.ResourceString = conditionStep ? "workflowstep.conditionsettings" : "workflowstep.advancedsettings"; ucSourcePointEdit.StopProcessing = false; ucSourcePointEdit.SourcePointGuid = sourcePoint.Guid; ucSourcePointEdit.SimpleMode = !conditionStep; ucSourcePointEdit.ShowCondition = (wsi.StepType != WorkflowStepTypeEnum.Userchoice) && (wsi.StepType != WorkflowStepTypeEnum.Multichoice) && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin); ucSourcePointEdit.RuleCategoryNames = CurrentWorkflow.IsAutomation ? ModuleName.ONLINEMARKETING : WorkflowInfo.OBJECT_TYPE; } } } if (!RequestHelper.IsPostBack()) { if (ShowTimeout) { ucTimeout.TimeoutEnabled = wsi.StepDefinition.TimeoutEnabled; ucTimeout.ScheduleInterval = wsi.StepDefinition.TimeoutInterval; } } }
/// <summary> /// Process save action with special script handling /// </summary> /// <param name="origMode">Original workflow mode</param> /// <param name="originalStep">Original workflow step</param> /// <param name="isDialog">Indicates whether is in dialog</param> private bool ProcessSaveAction(FormModeEnum origMode, WorkflowStepInfo originalStep, bool isDialog) { bool refreshTree = false; switch (origMode) { case FormModeEnum.Update: if (DocumentManager.AutoCheck) { if ((originalStep == null) || originalStep.StepIsArchived || originalStep.StepIsPublished) { refreshTree = true; } } // Document properties changed refreshTree |= ((originalDocumentName != Node.DocumentName) || (wasInPublishedStep != Node.IsInPublishStep) || (wasArchived != Node.IsArchived) || (((originalPublishFrom != Node.DocumentPublishFrom) || (originalPublishTo != Node.DocumentPublishTo)) && (DocumentManager.AutoCheck || (WorkflowManager.GetNodeWorkflow(Node) == null)))); break; case FormModeEnum.Insert: case FormModeEnum.InsertNewCultureVersion: TreeNode node = Node; // Handle new culture version for linked documents from different site int sourceNodeId = QueryHelper.GetInteger("sourcenodeid", 0); if (sourceNodeId > 0) { node = node.TreeProvider.SelectSingleNode(TreeProvider.ALL_SITES, null, node.DocumentCulture, false, node.NodeClassName, "NodeID = " + sourceNodeId, null, -1, false); } // Create another document if (DocumentManager.CreateAnother) { string refreshScript = string.Empty; // Call RefreshTree() only when not in a modal dialog, otherwise the dialog would be closed if (!isDialog) { refreshScript = "RefreshTree(" + node.NodeParentID + "," + node.NodeParentID + ");"; } refreshScript += " CreateAnother();"; AddScript(refreshScript); } else { // Refresh frame in split mode if ((origMode == FormModeEnum.InsertNewCultureVersion) && UIContext.DisplaySplitMode && (CultureHelper.GetOriginalPreferredCulture() != node.DocumentCulture)) { AddScript("SplitModeRefreshFrame();"); } else { string refreshScript = null; string tab = "Page"; // If not menu item type nor EditLive view mode, switch to form mode to keep editing the form if (!TreePathUtils.IsMenuItemType(node.NodeClassName) && (PortalContext.ViewMode != ViewModeEnum.EditLive)) { refreshScript = String.Format("SetMode('{0}', true);", ViewModeEnum.EditForm); PortalContext.ViewMode = ViewModeEnum.EditForm; tab = "EditForm"; } refreshScript += String.Format("RefreshTree({0}, {0}); SelectNode({0}, null, '{1}');", node.NodeID, tab); // Document tree is refreshed and new document is displayed AddScript(refreshScript); } } break; } return refreshTree; }
/// <summary> /// Creates a new workflow step. Called when the "Create workflow step" button is pressed. /// Expects the CreateWorkflow method to be run first. /// </summary> private bool CreateWorkflowStep() { // Get the workflow WorkflowInfo myWorkflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (myWorkflow != null) { // Create new workflow step object WorkflowStepInfo newStep = new WorkflowStepInfo(); // Set the properties newStep.StepWorkflowID = myWorkflow.WorkflowID; newStep.StepName = "MyNewWorkflowStep"; newStep.StepDisplayName = "My new workflow step"; newStep.StepOrder = 1; newStep.StepType = WorkflowStepTypeEnum.Standard; // Save the step into database WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep); // Ensure correct step order WorkflowStepInfoProvider.InitStepOrders(myWorkflow); return true; } return false; }
/// <summary> /// Publishes document. /// </summary> /// <param name="node">Node to publish</param> /// <param name="wm">Workflow manager</param> /// <param name="currentStep">Current workflow step</param> /// <returns>TRUE if operation fails</returns> private bool Publish(TreeNode node, WorkflowManager wm, WorkflowStepInfo currentStep) { string pathCulture = HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")"); bool alreadyPublished = (currentStep == null) || currentStep.StepIsPublished; if (!alreadyPublished) { // 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.StepIsPublished) { AddError(string.Format(ResHelper.GetString("content.PublishWasApproved"), pathCulture)); return true; } else { // Add log record AddLog(pathCulture); } return false; }
private void ProcessAction(HeaderAction action, WorkflowStepInfo currentStep, WorkflowStepInfo nextStep) { if (action == null) { return; } string nextStepName = null; SourcePoint def = null; if (nextStep != null) { WorkflowTransitionInfo transition = nextStep.RelatedTransition; if (transition != null) { def = currentStep.GetSourcePoint(transition.TransitionSourcePointGUID); nextStepName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nextStep.StepDisplayName)); } } else { def = currentStep.StepDefinition.DefinitionPoint; } if (def != null) { if (!string.IsNullOrEmpty(def.Text)) { action.Text = string.Format(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(def.Text)), nextStepName); } if (!string.IsNullOrEmpty(def.Tooltip)) { action.Tooltip = string.Format(ResHelper.LocalizeString(def.Tooltip), action.Text); } } }