public int GetDefaultTabWorkflowId(int portalId) { var workflowId = PortalController.GetPortalSettingAsInteger(DefaultTabWorkflowKey, portalId, Null.NullInteger); if (workflowId == Null.NullInteger) { var workflow = _systemWorkflowManager.GetDirectPublishWorkflow(portalId); workflowId = (workflow != null) ? workflow.WorkflowID : Null.NullInteger; if (workflowId != Null.NullInteger) { PortalController.UpdatePortalSetting(portalId, DefaultTabWorkflowKey, workflowId.ToString(CultureInfo.InvariantCulture), true); } } return(workflowId); }
public void StartWorkflow(int workflowId, int contentItemId, int userId) { Requires.NotNegative("workflowId", workflowId); var contentItem = _contentController.GetContentItem(contentItemId); var workflow = _workflowManager.GetWorkflow(contentItem); //If already exists a started workflow if (workflow != null && !IsWorkflowCompleted(contentItem)) { throw new WorkflowInvalidOperationException(Localization.GetExceptionMessage("WorkflowAlreadyStarted", "Workflow cannot get started for this Content Item. It already has a started workflow.")); } if (workflow == null || workflow.WorkflowID != workflowId) { workflow = _workflowRepository.GetWorkflow(workflowId); } var initialTransaction = CreateInitialTransaction(contentItemId, workflow.FirstState.StateID, userId); //Perform action before starting workflow PerformWorkflowActionOnStateChanging(initialTransaction, WorkflowActionTypes.StartWorkflow); UpdateContentItemWorkflowState(workflow.FirstState.StateID, contentItem); //Send notifications to stater if (workflow.WorkflowID != _systemWorkflowManager.GetDirectPublishWorkflow(workflow.PortalID).WorkflowID) //This notification is not sent in Direct Publish WF { SendNotificationToWorkflowStarter(initialTransaction, workflow, contentItem, userId, WorkflowActionTypes.StartWorkflow); } // Delete previous logs _workflowLogRepository.DeleteWorkflowLogs(contentItemId, workflowId); // Add logs AddWorkflowLog(contentItem, WorkflowLogType.WorkflowStarted, userId); AddWorkflowLog(contentItem, WorkflowLogType.StateInitiated, userId); //Perform action after starting workflow PerformWorkflowActionOnStateChanged(initialTransaction, WorkflowActionTypes.StartWorkflow); }