Exemple #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);
        }
Exemple #2
0
        public virtual void Execute(IBaseDelegateExecution execution)
        {
            throw new NotImplementedException("C#与java之间db操作机制不一样,java在这里的逻辑会引发外键约束异常");
            var existingId = execution.Id;

            // insert an execution referencing the current execution

            var newExecution = new ExecutionEntity();

            newExecution.Id = "someId";
            newExecution.SetParentId(existingId);

            var insertOperation = new DbEntityOperation();

            insertOperation.OperationType = DbOperationType.Insert;
            insertOperation.Entity        = newExecution;

            newExecution.Insert();
            //Context.CommandContext.DbSqlSession.ExecuteDbOperation(insertOperation);
        }