예제 #1
0
        public void AddWorkflow(Entities.Workflow workflow)
        {
            _workflowRepository.AddWorkflow(workflow);

            var firstDefaultState = _systemWorkflowManager.GetDraftStateDefinition(1);
            var lastDefaultState  = _systemWorkflowManager.GetPublishedStateDefinition(2);

            firstDefaultState.WorkflowID = workflow.WorkflowID;
            lastDefaultState.WorkflowID  = workflow.WorkflowID;

            _workflowStateRepository.AddWorkflowState(firstDefaultState);
            _workflowStateRepository.AddWorkflowState(lastDefaultState);

            workflow.States = new List <WorkflowState>
            {
                firstDefaultState,
                lastDefaultState
            };
        }
예제 #2
0
        private void CreateDirectPublishWorkflow(int portalId)
        {
            var workflow = new Entities.Workflow
            {
                WorkflowName = Localization.GetString("DefaultDirectPublishWorkflowName"),
                Description  = Localization.GetString("DefaultDirectPublishWorkflowDescription"),
                WorkflowKey  = DirectPublishWorkflowKey,
                IsSystem     = true,
                PortalID     = portalId
            };

            _workflowRepository.AddWorkflow(workflow);
            var publishedState = GetPublishedStateDefinition(1);

            publishedState.WorkflowID = workflow.WorkflowID;
            _workflowStateRepository.AddWorkflowState(publishedState);
        }
        public void AddWorkflowState(WorkflowState state)
        {
            var workflow = _workflowRepository.GetWorkflow(state.WorkflowID);

            if (workflow == null)
            {
                throw new WorkflowDoesNotExistException();
            }

            if (workflow.IsSystem)
            {
                throw new WorkflowInvalidOperationException(Localization.GetString("WorkflowNewStateCannotBeAddedToSystemWorkflows", Localization.ExceptionsResourceFile));
            }

            var lastState = workflow.LastState;

            // New States always goes before the last state
            state.Order = lastState.Order;

            lastState.Order++;
            _workflowStateRepository.AddWorkflowState(state);
            _workflowStateRepository.UpdateWorkflowState(lastState); // Update last state order
        }