Пример #1
0
        public virtual void testRestoreProcessInstance()
        {
            //given parent execution
            IList <ExecutionEntity> entities = new List <ExecutionEntity>();
            ExecutionEntity         parent   = new ExecutionEntity();

            parent.Id = "parent";
            entities.Add(parent);
            //when restore process instance is called
            parent.RestoreProcessInstance(entities, null, null, null, null, null, null);
            //then no problem should occure

            //when child is added and restore is called again
            ExecutionEntity entity = new ExecutionEntity();

            entity.Id = "child";
            entity.SetParentId(parent.Id);
            entities.Add(entity);

            parent.RestoreProcessInstance(entities, null, null, null, null, null, null);
            //then again no problem should occure

            //when parent is deleted from the list
            entities.Remove(parent);
            //删除父后会异常
            var exc = Assert.Throws <ProcessEngineException>(() => parent.RestoreProcessInstance(entities, null, null, null, null, null, null));

            Assert.IsTrue(exc.Message.Contains("Cannot resolve parent with id 'parent' of execution 'child', perhaps it was deleted in the meantime"));
            //then exception is thrown because child reference to parent which does not exist anymore
            //thrown.Expect(typeof(ProcessEngineException));
            //thrown.ExpectMessage("Cannot resolve parent with id 'parent' of execution 'child', perhaps it was deleted in the meantime");
            //parent.RestoreProcessInstance(entities, null, null, null, null, null, null);
        }
Пример #2
0
        protected internal virtual IList <ExecutionEntity> LoadFromDb(string processInstanceId, CommandContext commandContext)
        {
            IList <ExecutionEntity> executions      = commandContext.ExecutionManager.FindExecutionsByProcessInstanceId(processInstanceId);
            ExecutionEntity         processInstance = commandContext.ExecutionManager.FindExecutionById(processInstanceId);

            // initialize parent/child sets
            if (processInstance != null)
            {
                processInstance.RestoreProcessInstance(executions, null, null, null, null, null, null);
            }

            return(executions);
        }