Exemple #1
0
        public void CancelProcessInstance(String authenticatedActorId, Int64 processInstanceId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            // first check if the actor is allowed to cancel this process instance
            authorizationHelper.CheckCancelProcessInstance(authenticatedActorId, processInstanceId, dbSession);

            ProcessInstanceImpl processInstance = (ProcessInstanceImpl)dbSession.Load(typeof(ProcessInstanceImpl), processInstanceId);

            log.Info("actor '" + authenticatedActorId + "' cancels processInstance '" + processInstanceId + "'...");

            if (!processInstance.EndHasValue)
            {
                CancelFlowRecursive((FlowImpl)processInstance.RootFlow, DateTime.Now);
                ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, (FlowImpl)processInstance.RootFlow, dbSession, organisationComponent);
                executionContext.CreateLog(authenticatedActorId, EventType.PROCESS_INSTANCE_CANCEL);
                EndStateImpl endState = (EndStateImpl)processInstance.ProcessDefinition.EndState;
                engine.ProcessEndState(endState, executionContext, dbSession);
                processInstance.End = DateTime.Now;

                // flush the updates to the db
                dbSession.Update(processInstance);
                dbSession.Flush();
            }
            else
            {
                throw new SystemException("couldn't cancel process instance : process instance '" + processInstanceId + "' was already finished");
            }
        }
Exemple #2
0
        public void ProcessEndState(EndStateImpl endState, ExecutionContextImpl executionContext, DbSession dbSession)
        {
            delegationService.RunActionsForEvent(EventType.PROCESS_INSTANCE_END, endState.ProcessDefinition.Id, executionContext, dbSession);
            executionContext.CreateLog(EventType.PROCESS_INSTANCE_END);

            FlowImpl rootFlow = (FlowImpl)executionContext.GetFlow();

            rootFlow.ActorId = null;
            rootFlow.End     = DateTime.Now;
            rootFlow.Node    = endState;          // setting the node is not necessary if this method is called
            // from processTransition, but it is necessary if this method is
            // called from cancelProcessInstance in the component-impl.

            ProcessInstanceImpl processInstance  = (ProcessInstanceImpl)executionContext.GetProcessInstance();
            FlowImpl            superProcessFlow = (FlowImpl)processInstance.SuperProcessFlow;

            if (superProcessFlow != null)
            {
                log.Debug("reactivating the super process...");

                // create the execution context for the parent-process
                ExecutionContextImpl superExecutionContext = new ExecutionContextImpl(executionContext.PreviousActorId, superProcessFlow, executionContext.DbSession, executionContext.GetOrganisationComponent());
                superExecutionContext.SetInvokedProcessContext(executionContext);

                // delegate the attributeValues
                ProcessStateImpl processState    = (ProcessStateImpl)superProcessFlow.Node;
                Object[]         completionData  = delegationHelper.DelegateProcessTermination(processState.ProcessInvokerDelegation, superExecutionContext);
                IDictionary      attributeValues = (IDictionary)completionData[0];
                String           transitionName  = (String)completionData[1];
                TransitionImpl   transition      = transitionRepository.GetTransition(transitionName, processState, executionContext.DbSession);

                // process the super process transition
                ProcessTransition(transition, superExecutionContext, dbSession);
            }
        }
Exemple #3
0
        private EndStateImpl end()
        {
            XmlElement   endElement = xmlElement.GetChildElement("end-state");
            EndStateImpl endState   = new EndStateImpl();

            endState.ProcessDefinition = ProcessDefinition;
            this.state(endElement, endState, ProcessDefinition);

            return(endState);
        }
Exemple #4
0
        public void CancelFlow(String authenticatedActorId, Int64 flowId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            // first check if the actor is allowed to cancel this flow
            authorizationHelper.CheckCancelFlow(authenticatedActorId, flowId, dbSession);

            FlowImpl flow = (FlowImpl)dbSession.Load(typeof(FlowImpl), flowId);

            log.Info("actor '" + authenticatedActorId + "' cancels flow '" + flowId + "'...");

            // only perform the cancel if this flow is not finished yet
            if (!flow.EndHasValue)
            {
                ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, flow, dbSession, organisationComponent);
                executionContext.CreateLog(authenticatedActorId, EventType.FLOW_CANCEL);

                if (flow.IsRootFlow())
                {
                    // set the flow in the end-state
                    log.Debug("setting root flow to the end state...");
                    EndStateImpl endState = (EndStateImpl)flow.ProcessInstance.ProcessDefinition.EndState;
                    engine.ProcessEndState(endState, executionContext, dbSession);
                }
                else
                {
                    // set the flow in the join
                    ConcurrentBlockImpl concurrentBlock = (ConcurrentBlockImpl)flow.Node.ProcessBlock;
                    JoinImpl            join            = (JoinImpl)concurrentBlock.Join;
                    log.Debug("setting concurrent flow to join '" + join + "'");
                    engine.ProcessJoin(join, executionContext, dbSession);
                }

                // flush the updates to the db
                dbSession.Update(flow);
                dbSession.Flush();
            }
        }
Exemple #5
0
 private void ProcessEndState(EndStateImpl endState, FlowImpl flow, DbSession dbSession)
 {
     flow.ActorId = null;
     flow.End     = DateTime.Now;
     flow.Node    = endState;
 }