protected void Page_Load(object sender, EventArgs e) { Title = "Workflow Edit - Header"; workflowId = QueryHelper.GetInteger("workflowid", 0); WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(workflowId); // Set edited object EditedObject = wi; const string workflowListUrl = "~/CMSModules/Workflows/Workflow_List.aspx"; string workflows = GetString("Development-Workflow_Edit.Workflows"); string currentWorkflow = string.Empty; string title = GetString("Development-Workflow_Edit.Title"); if (wi != null) { currentWorkflow = wi.WorkflowDisplayName; } if (!RequestHelper.IsPostBack()) { InitalizeMenu(); if (QueryHelper.GetString("showtab", string.Empty) == "steps") { CurrentMaster.Tabs.SelectedTab = 1; } } // Initialize master page title InitializeMasterPage(title, workflows, workflowListUrl, currentWorkflow); }
protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { // Do nothing! } else { plcLabel.Visible = !SimpleMode; RequiredFieldValidatorLabel.ErrorMessage = GetString("workflowstep.sourcepoint.requireslabel"); if (CurrentSourcePoint != null) { // Switch default doesn't have condition if ((CurrentSourcePoint.Type == SourcePointTypeEnum.SwitchDefault) || (CurrentSourcePoint.Type == SourcePointTypeEnum.Timeout)) { lblCondition.Visible = cbCondition.Visible = false; } if (!RequestHelper.IsPostBack()) { txtLabel.Text = CurrentSourcePoint.Label; txtText.Text = CurrentSourcePoint.Text; txtTooltip.Text = CurrentSourcePoint.Tooltip; cbCondition.Text = CurrentSourcePoint.Condition; } } if (cbCondition.Visible) { WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(CurrentStepInfo.StepWorkflowID); cbCondition.ResolverName = WorkflowHelper.GetResolverName(wi); } } }
/// <summary> /// Gets the automation state and move contact to previous step. Called when the "Move to previous step" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool MoveContactToPreviousStep() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null); // 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 process state AutomationStateInfo state = contact.Processes.FirstItem as AutomationStateInfo; if (state != null) { // Move contact to next step manager.MoveToPreviousStep(contact, state, "Move to previous step"); return(true); } } return(false); }
/// <summary> /// Saves data of edited workflow from TextBoxes into DB. /// </summary> protected void ButtonOK_Click(object sender, EventArgs e) { // finds whether required fields are not empty string result = new Validator().NotEmpty(TextBoxWorkflowDisplayName.Text, GetString("Development-Workflow_New.RequiresDisplayName")) .NotEmpty(txtCodeName.Text, GetString("Development-Workflow_New.RequiresCodeName")) .IsCodeName(txtCodeName.Text, GetString("general.invalidcodename")) .Result; if (result == "") { if (currentWorkflow != null) { // Codename must be unique WorkflowInfo wiCodename = WorkflowInfoProvider.GetWorkflowInfo(txtCodeName.Text); if ((wiCodename == null) || (wiCodename.WorkflowID == currentWorkflow.WorkflowID)) { if (currentWorkflow.WorkflowDisplayName != TextBoxWorkflowDisplayName.Text) { // Refresh header ScriptHelper.RefreshTabHeader(Page, null); } currentWorkflow.WorkflowDisplayName = TextBoxWorkflowDisplayName.Text; currentWorkflow.WorkflowName = txtCodeName.Text; currentWorkflow.WorkflowAutoPublishChanges = chkAutoPublish.Checked; // Inherited from global settings if (radSiteSettings.Checked) { currentWorkflow.WorkflowUseCheckinCheckout = null; } else { currentWorkflow.WorkflowUseCheckinCheckout = radYes.Checked; } // Save workflow info WorkflowInfoProvider.SetWorkflowInfo(currentWorkflow); lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } else { lblError.Visible = true; lblError.Text = GetString("Development-Workflow_New.WorkflowExists"); } } else { lblError.Visible = true; lblError.Text = GetString("Development-Workflow_General.WorkflowDoesNotExists"); } } else { lblError.Visible = true; lblError.Text = result; } }
/// <summary> /// Creates process trigger. Called when the "Create trigger" button is pressed. /// Expects the CreateProcess method to be run first. /// </summary> private bool CreateProcessTrigger() { // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (process != null) { // Create new process trigger object and set its properties ObjectWorkflowTriggerInfo newTrigger = new ObjectWorkflowTriggerInfo() { TriggerDisplayName = "My new trigger", TriggerType = WorkflowTriggerTypeEnum.Change, TriggerSiteID = SiteContext.CurrentSiteID, TriggerWorkflowID = process.WorkflowID, TriggerObjectType = "om.contact" }; // Save the process trigger ObjectWorkflowTriggerInfoProvider.SetObjectWorkflowTriggerInfo(newTrigger); return(true); } return(false); }
/// <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> /// Initializes contact selector. /// </summary> private void InitContactSelector() { // Initialize contact selector ucSelector.UniSelector.SelectionMode = SelectionModeEnum.SingleButton; WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo(ProcessID); if (process == null) { RedirectToInformation("editedobject.notexists"); } // Check permissions if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(listContacts.SiteID)) && (listContacts.SiteID != UniSelector.US_GLOBAL_AND_SITE_RECORD) && ((process != null) && process.WorkflowEnabled)) { ucSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; ucSelector.SiteID = listContacts.SiteID; ucSelector.IsLiveSite = false; ucSelector.IsSiteManager = ContactHelper.IsSiteManager; ucSelector.Enabled = true; ucSelector.UniSelector.DialogButton.ToolTipResourceString = "automenu.startstatedesc"; } else { ucSelector.Enabled = false; ucSelector.UniSelector.DialogButton.ToolTipResourceString = process.WorkflowEnabled ? "general.nopermission" : "autoMenu.DisabledStateDesc"; } }
/// <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); }
protected void Page_Load(object sender, EventArgs e) { string workflowName = string.Empty; WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo(ProcessID); if (workflow != null) { workflowName = workflow.WorkflowDisplayName; } InitalizeMenu(); if (!RequestHelper.IsPostBack()) { switch (QueryHelper.GetString("showtab", String.Empty).ToLowerCSafe()) { case "steps": CurrentMaster.Tabs.SelectedTab = 1; break; case "triggers": CurrentMaster.Tabs.SelectedTab = 2; break; case "contacts": CurrentMaster.Tabs.SelectedTab = 3; break; } } // Initialize master page title InitializeMasterPage(workflowName); }
/// <summary> /// Saves new workflow's data and redirects to Workflow_Edit.aspx. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> protected void ButtonOK_Click(object sender, EventArgs e) { // finds whether required fields are not empty string result = new Validator().NotEmpty(txtWorkflowDisplayName.Text, GetString("Development-Workflow_New.RequiresDisplayName")).NotEmpty(txtWorkflowCodeName.Text, GetString("Development-Workflow_New.RequiresCodeName")) .IsCodeName(txtWorkflowCodeName.Text, GetString("general.invalidcodename")) .Result; if (result == "") { WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(txtWorkflowCodeName.Text); if (wi == null) { int workflowId = SaveNewWorkflow(); if (workflowId > 0) { WorkflowStepInfoProvider.CreateDefaultWorkflowSteps(workflowId); URLHelper.Redirect("Workflow_Edit.aspx?workflowid=" + workflowId + "&saved=1"); } } else { lblError.Visible = true; lblError.Text = GetString("Development-Workflow_New.WorkflowExists"); } } else { lblError.Visible = true; lblError.Text = result; } }
/// <summary> /// Creates workflow scope. Called when the "Create scope" button is pressed. /// Expects the "CreateWorkflow" method to be run first. /// </summary> private bool CreateWorkflowScope() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (workflow != null) { // Create new workflow scope object WorkflowScopeInfo newScope = new WorkflowScopeInfo(); // Get the site default culture from settings string cultureCode = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultCultureCode"); CultureInfo culture = CultureInfoProvider.GetCultureInfo(cultureCode); // Get root document type class ID int classID = DataClassInfoProvider.GetDataClassInfo("CMS.Root").ClassID; // Set the properties newScope.ScopeStartingPath = "/"; newScope.ScopeCultureID = culture.CultureID; newScope.ScopeClassID = classID; newScope.ScopeWorkflowID = workflow.WorkflowID; newScope.ScopeSiteID = SiteContext.CurrentSiteID; // Save the workflow scope WorkflowScopeInfoProvider.SetWorkflowScopeInfo(newScope); return(true); } return(false); }
/// <summary> /// Creates automation state. Called when the "Start process" button is pressed. /// Expects the CreateProcess, CreateProcessStep and CreateTemporaryObjects method to be run first. /// </summary> private bool CreateAutomationState() { // 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); // Start the process manager.StartProcess(contact, process.WorkflowID); return(true); } return(false); }
/// <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> /// 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> /// Gets and updates workflow scope. Called when the "Get and update scope" button is pressed. /// Expects the CreateWorkflowScope method to be run first. /// </summary> private bool GetAndUpdateWorkflowScope() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (workflow != null) { // Get the workflow's scopes InfoDataSet <WorkflowScopeInfo> scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID); if (!DataHelper.DataSourceIsEmpty(scopes)) { // Create the scope info object WorkflowScopeInfo updateScope = scopes.First <WorkflowScopeInfo>(); // Update the properties - the scope will include all cultures and document types updateScope.ScopeCultureID = 0; updateScope.ScopeClassID = 0; // Save the changes WorkflowScopeInfoProvider.SetWorkflowScopeInfo(updateScope); return(true); } else { // No scope was found apiGetAndUpdateWorkflowScope.ErrorMessage = "The scope was not found."; } } return(false); }
/// <summary> /// Deletes workflow scope. Called when the "Delete scope" button is pressed. /// Expects the CreateWorkflowScope method to be run first. /// </summary> private bool DeleteWorkflowScope() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval); if (workflow != null) { // Get the workflow's scopes InfoDataSet <WorkflowScopeInfo> scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID); if (!DataHelper.DataSourceIsEmpty(scopes)) { // Create the scope info object WorkflowScopeInfo deleteScope = scopes.First <WorkflowScopeInfo>(); // Delete the workflow scope WorkflowScopeInfoProvider.DeleteWorkflowScopeInfo(deleteScope); return(true); } else { // No scope was found apiDeleteWorkflowScope.ErrorMessage = "The scope was not found."; } } return(false); }
/// <summary> /// Initializes the master page elements. /// </summary> private void InitializeMasterPage(int workflowId) { // Get workflow WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(workflowId); // Set edited object EditedObject = wi; if (wi != null) { // Check if 'automatically publish changes' is allowed if (wi.WorkflowAutoPublishChanges) { ShowInformation(GetString("Development-Workflow_Steps.CustomStepsCanNotBeCreated")); } else { // Set actions string[,] actions = new string[1, 8]; actions[0, 0] = "HyperLink"; actions[0, 1] = GetString("Development-Workflow_Steps.NewStep"); actions[0, 3] = "~/CMSModules/Workflows/Workflow_Step_New.aspx?workflowid=" + workflowId; actions[0, 5] = GetImageUrl("Objects/CMS_WorkflowStep/add.png"); CurrentMaster.HeaderActions.Actions = actions; } } }
/// <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> /// Deletes workflow scope. Called when the "Delete scope" button is pressed. /// Expects the CreateWorkflowScope method to be run first. /// </summary> private bool DeleteWorkflowScope() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (workflow != null) { // Get the workflow's scopes DataSet scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID); if (!DataHelper.DataSourceIsEmpty(scopes)) { // Create the scope info object WorkflowScopeInfo deleteScope = new WorkflowScopeInfo(scopes.Tables[0].Rows[0]); // Delete the workflow scope WorkflowScopeInfoProvider.DeleteWorkflowScopeInfo(deleteScope); return(true); } else { // No scope was found apiDeleteWorkflowScope.ErrorMessage = "The scope was not found."; } } return(false); }
/// <summary> /// Deletes workflow. Called when the "Delete workflow" button is pressed. /// Expects the CreateWorkflow method to be run first. /// </summary> private bool DeleteWorkflow() { // Get the workflow WorkflowInfo deleteWorkflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval); // Delete the workflow WorkflowInfoProvider.DeleteWorkflowInfo(deleteWorkflow); return(deleteWorkflow != null); }
/// <summary> /// Deletes process. Called when the "Delete process" button is pressed. /// Expects the CreateProcess method to be run first. /// </summary> private bool DeleteProcess() { // Get the process WorkflowInfo deleteProcess = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); // Delete the process WorkflowInfoProvider.DeleteWorkflowInfo(deleteProcess); return(deleteProcess != null); }
/// <summary> /// Converts existing workflow to advanced workflow. Called when the "Convert to advanced workflow" button is pressed. /// Expects the CreateWorkflow method to be run first. /// </summary> private bool ConvertToAdvancedWorkflow() { // Get the workflow WorkflowInfo convertWorkflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (convertWorkflow != null) { // Convert to advanced workflow WorkflowInfoProvider.ConvertToAdvancedWorkflow(convertWorkflow.WorkflowID); return(true); } return(false); }
/// <summary> /// Deletes the workflow scope, workflow step and the document used for this example. Called when the "Delete example objects" button is pressed. /// Expects the "CreateExampleObjects" method to be run first. /// </summary> private bool DeleteExampleObjects() { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Get the example document TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", "en-us"); if (node != null) { // Delete the document DocumentHelper.DeleteDocument(node, tree, true, true, true); } string where = "ScopeStartingPath LIKE '/API-Example%'"; // Get example workflow scopes DataSet scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(where, null, 0, null); if (!DataHelper.DataSourceIsEmpty(scopes)) { // Loop through all the scopes in case more identical scopes were accidentally created foreach (DataRow scopeRow in scopes.Tables[0].Rows) { // Create scope info object WorkflowScopeInfo scope = new WorkflowScopeInfo(scopeRow); // Delete the scope WorkflowScopeInfoProvider.DeleteWorkflowScopeInfo(scope); } } // Get the default workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("default"); if (workflow != null) { // Get the example step WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewWorkflowStep", workflow.WorkflowID); if (step != null) { // Delete the step WorkflowStepInfoProvider.DeleteWorkflowStepInfo(step); } } return(true); }
/// <summary> /// Removes the assignment of the CMS Editors role from a workflow step. Called when the "Remove role from step" button is pressed. /// Expects the CreateWorkflow, CreateWorkflowStep and AddRoleToStep methods to be run first. /// </summary> private bool RemoveRoleFromStep() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval); if (workflow != null) { // Get the custom step WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewWorkflowStep", workflow.WorkflowID); if (step != null) { // Get the role to be assigned to the step RoleInfo role = RoleInfoProvider.GetRoleInfo("CMSEditor", SiteContext.CurrentSiteID); if (role != null) { // Get the step - role relationship WorkflowStepRoleInfo stepRoleInfo = WorkflowStepRoleInfoProvider.GetWorkflowStepRoleInfo(step.StepID, role.RoleID); if (stepRoleInfo != null) { // Remove the assignment WorkflowStepRoleInfoProvider.RemoveRoleFromWorkflowStep(step.StepID, role.RoleID); return(true); } else { // The role is not assigned to the step apiRemoveRoleFromStep.ErrorMessage = "The 'CMS Editors' role is not assigned to the step."; } } else { // The role was not found apiRemoveRoleFromStep.ErrorMessage = "The role 'CMS Editors' was not found."; } } else { // The step was not found apiRemoveRoleFromStep.ErrorMessage = "The step 'My new workflow step' was not found."; } } return(false); }
/// <summary> /// Gets and updates workflow. Called when the "Get and update workflow" button is pressed. /// Expects the CreateWorkflow method to be run first. /// </summary> private bool GetAndUpdateWorkflow() { // Get the workflow WorkflowInfo updateWorkflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (updateWorkflow != null) { // Update the properties updateWorkflow.WorkflowDisplayName = updateWorkflow.WorkflowDisplayName.ToLowerCSafe(); // Save the changes WorkflowInfoProvider.SetWorkflowInfo(updateWorkflow); return(true); } return(false); }
protected void Page_Load(object sender, EventArgs e) { // Initialize form and controls Title = "Workflow Edit - General"; rfvCodeName.ErrorMessage = GetString("Development-Workflow_New.RequiresCodeName"); RequiredFieldValidatorDisplayName.ErrorMessage = GetString("Development-Workflow_New.RequiresDisplayName"); if (QueryHelper.GetInteger("saved", 0) == 1) { lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } // Get ID of workflow from querystring workflowId = QueryHelper.GetInteger("workflowid", 0); if (workflowId > 0) { currentWorkflow = WorkflowInfoProvider.GetWorkflowInfo(workflowId); // Set edited object EditedObject = currentWorkflow; } if (!RequestHelper.IsPostBack() && (currentWorkflow != null)) { txtCodeName.Text = currentWorkflow.WorkflowName; TextBoxWorkflowDisplayName.Text = currentWorkflow.WorkflowDisplayName; chkAutoPublish.Checked = currentWorkflow.WorkflowAutoPublishChanges; bool?useCheckInCheckOut = currentWorkflow.WorkflowUseCheckinCheckout; // Is enabled or disabled check-in/check-out if (useCheckInCheckOut.HasValue) { radYes.Checked = useCheckInCheckOut.Value; radNo.Checked = !useCheckInCheckOut.Value; } // Inherit from global settings else { radSiteSettings.Checked = true; } } }
/// <summary> /// Gets and updates process. Called when the "Get and update process" button is pressed. /// Expects the CreateProcess method to be run first. /// </summary> private bool GetAndUpdateProcess() { // Get the process WorkflowInfo modifyProcess = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (modifyProcess != null) { // Update the properties modifyProcess.WorkflowDisplayName = modifyProcess.WorkflowDisplayName.ToLower(); // Save the changes WorkflowInfoProvider.SetWorkflowInfo(modifyProcess); return(true); } return(false); }
/// <summary> /// Deletes the workflow step. Called when the "Delete workflow step" button is pressed. /// Expects the CreateWorkflow and CreateWorkflowStep methods to be run first. /// </summary> private bool DeleteWorkflowStep() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval); if (workflow != null) { // Get the custom step WorkflowStepInfo deleteStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewWorkflowStep", workflow.WorkflowID); if (deleteStep != null) { // Remove the step WorkflowStepInfoProvider.DeleteWorkflowStepInfo(deleteStep); return(true); } } return(false); }
/// <summary> /// Remove contact from process. Called when the "Remove contact from process" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool RemoveContactFromProcess() { // 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)) { return(false); } // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Get the states var states = AutomationStateInfoProvider.GetAutomationStates() .WhereEquals("StateWorkflowID", process.WorkflowID) .WhereEquals("StateObjectID", contact.ContactID) .WhereEquals("StateObjectType", PredefinedObjectType.CONTACT); if (states.Any()) { // Loop through the individual items foreach (AutomationStateInfo state in states) { // Remove contact from process manager.RemoveProcess(contact, state); } return(true); } return(false); }
/// <summary> /// Remove contact from process. Called when the "Remove contact from process" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool RemoveContactFromProcess() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null); // 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); // Prepare the parameters where = "StateWorkflowID = " + process.WorkflowID + " AND StateObjectID = " + contact.ContactID + " AND StateObjectType = '" + PredefinedObjectType.CONTACT + "'"; // Get the states InfoDataSet <AutomationStateInfo> states = AutomationStateInfoProvider.GetStates(where, null); if (!DataHelper.DataSourceIsEmpty(states)) { // Loop through the individual items foreach (AutomationStateInfo state in states) { // Remove contact from process manager.RemoveProcess(contact, state); } return(true); } } return(false); }