Exemplo n.º 1
0
        public void CompleteApproveWorkItem(int workItemId, ApproveResultEnum approveResult, string approveComment, List <IApproveUser> nextApproveUserList, bool addUser = false, int?addUserId = new int?())
        {
            DataContext context = this.GetContext();

            try
            {
                this.GetEngineProxy(context).CompleteApproveWorkItemAsync(workItemId, approveResult, approveComment, nextApproveUserList, addUser, addUserId);
            }
            finally
            {
                this.ReleaseContext(context);
            }
        }
Exemplo n.º 2
0
 public void CompleteApproveWorkItem(int workItemId, ApproveResultEnum approveResult, string approveComment, List <IApproveUser> nextApproveUserList, bool addUser = false, int?addUserId = new int?())
 {
     try
     {
         ProcessInstanceCacheFactory runtimeContext = new ProcessInstanceCacheFactory(this._context);
         SysProcessInstance          processInstanceCacheByWorkItem = runtimeContext.GetProcessInstanceCacheByWorkItem(workItemId);
         new ProcessEngine(runtimeContext, processInstanceCacheByWorkItem).CompleteApproveWorkItem(workItemId, approveResult, approveComment, nextApproveUserList, addUser, addUserId);
     }
     catch (Exception exception)
     {
         AppLogHelper.Error(string.Format("完成【签核流程】的工作项[{0}]失败", workItemId), exception);
         throw exception;
     }
 }
Exemplo n.º 3
0
        public void CompleteApproveWorkItem(int workItemId, ApproveResultEnum approveResult, string approveComment, bool addUser = false, int?addUserId = new int?())
        {
            DataContext context = this.GetContext();

            try
            {
                int?nullable = addUserId;
                this.GetEngineProxy(context).CompleteApproveWorkItemAsync(workItemId, approveResult, approveComment, null, addUser, new int?(nullable.HasValue ? nullable.GetValueOrDefault() : -1));
            }
            finally
            {
                this.ReleaseContext(context);
            }
        }
Exemplo n.º 4
0
        public void CompleteApproveWorkItemSelf(int workItemId, ApproveResultEnum approveResult, string approveComment, bool addUser = false, int?addUserId = new int?())
        {
            DataContext context = this.GetContext();

            try
            {
                InternalEngineProxy engineProxy = this.GetEngineProxy(context);
                using (TransactionScope scope = new TransactionScope())
                {
                    int?nullable = addUserId;
                    engineProxy.CompleteApproveWorkItemSelf(workItemId, approveResult, approveComment, addUser, new int?(nullable.HasValue ? nullable.GetValueOrDefault() : -1));
                    scope.Complete();
                }
            }
            finally
            {
                this.ReleaseContext(context);
            }
        }
Exemplo n.º 5
0
        internal void AddInstanceData(SysWorkItem work_item, ApproveResultEnum approveResult, string approveComment)
        {
            SysApproveActivityData data = new SysApproveActivityData {
                DataId             = work_item.WorkItemId,
                ActivityInstanceId = work_item.ActivityInstanceId,
                AddingUserId       = work_item.AddingUserId,
                IsAdded            = work_item.IsAdded,
                IsProxy            = work_item.IsProxy,
                ProxyUserId        = work_item.ProxyUserId,
                WorkItemId         = new int?(work_item.WorkItemId),
                ApproveComment     = approveComment,
                ApproveGroupId     = work_item.ApproveGroupId,
                ApproveResult      = new int?((int)approveResult),
                ApproveTime        = new DateTime?(DateTime.Now),
                ApproveUserId      = work_item.OwnerId
            };

            this._piCacheFactory.AddApproveData(data);
        }
Exemplo n.º 6
0
        internal virtual void CompleteApproveWorkItem(int workItemId, ApproveResultEnum approveResult, string approveComment, bool addUser = false, int?addUserId = new int?())
        {
            SysWorkItem item;

            if (addUser && (!addUserId.HasValue || (addUserId <= 0)))
            {
                throw new ApplicationException("指定了加签,但未指定加签用户");
            }
            this._pi = this._piCacheFactory.GetProcessInstanceCacheByWorkItem(workItemId, out item);
            if (!item.Status.HasValue)
            {
                item.Status = 0;
            }
            if (item.Status.Value == 1)
            {
                throw new ApplicationException("该工作项已完成");
            }
            if (item.Status.Value == 3)
            {
                throw new ApplicationException("该工作项已被系统取消");
            }
            if (item.Status.Value != 0)
            {
                throw new ApplicationException("该工作项已完成或被取消");
            }
            this.AddInstanceData(item, approveResult, approveComment);
            if (addUser && (approveResult == ApproveResultEnum.Pass))
            {
                this.CreateAddingWorkItem(item, addUserId.Value);
            }
            Queue <WorkflowMessage> queue   = new Queue <WorkflowMessage>(10);
            WorkflowMessage         message = this.NewCompleteWorkItemApproveMessage(item);

            queue.Enqueue(message);
            while (queue.Count > 0)
            {
                queue.Dequeue().Execute(queue);
            }
            this._piCacheFactory.ClearCache(this._pi.ProcessInstanceId);
        }
Exemplo n.º 7
0
 public void CompleteApproveWorkItemAsync(int workItemId, ApproveResultEnum approveResult, string approveComment, List <IApproveUser> nextApproveUserList, bool addUser = false, int?addUserId = new int?())
 {
     try
     {
         this.UpdateWorkItemAsCompleting(workItemId);
         int num = this._context.GetNextIdentity_Int(false);
         SysWorkflowMessage message = new SysWorkflowMessage {
             MessageId      = num,
             MessageType    = WorkflowMessageTypeEnum.CompletingApproveWorkItem,
             WorkItemId     = workItemId,
             State          = SysWorkflowMessageStateEnum.Inited,
             CreateTime     = DateTime.Now,
             ApproveResult  = approveResult,
             ApproveComment = approveComment,
             AddUser        = addUser,
             AddUserId      = addUserId
         };
         if ((nextApproveUserList != null) && (nextApproveUserList.Count > 0))
         {
             foreach (IApproveUser user in nextApproveUserList)
             {
                 MessageApproveUser user2 = new MessageApproveUser(user)
                 {
                     WorkflowMessageId    = num,
                     MessageApproveUserId = this._context.GetNextIdentity_Int(false)
                 };
                 this._context.Insert(user2);
             }
         }
         this._context.Insert(message);
     }
     catch (Exception exception)
     {
         AppLogHelper.Error(exception, "完成签核工作项失败,workitem_id={0}", new object[] { workItemId });
         throw;
     }
 }