Ejemplo n.º 1
0
        void IWorkItemService.Release(WorkItem workItem)
        {
            if (workItem.Status != WorkItemStatus.Open)
            {
                throw new InvalidOperationException(string.Format("不能释放处于{0}状态的任务", workItem.Status));
            }
            workItem.ChangeStatus(WorkItemStatus.New);
            _repository.Update(workItem);

            //释放任务会释放slot,需要将该节点的NoSlot的任务置为New
            if (workItem.GetReferredSetting().IsUsingSlot)
            {
                _repository.FindWorkItemsByActivityInstance(workItem.Process, workItem.ActivityInstance)
                .Where(o => o.Status == WorkItemStatus.NoSlot).ToList()
                .ForEach(o =>
                {
                    o.ChangeStatus(WorkItemStatus.New);
                    _repository.Update(workItem);
                });
            }
        }