Пример #1
0
        /// <summary>
        /// 流程完成,设置流程的状态为完成
        /// </summary>
        /// <param name="processInsUid">流程实例</param>
        /// <returns>是否成功</returns>
        internal void Complete(string processInsUid, string billUid)
        {
            var processIns = _dataAccessor.Get <WfProcessInstance>(processInsUid, false);

            if (WfProcessInstanceState.Running == processIns.ProcessState)
            {
                processIns.ProcessState = WfProcessInstanceState.Completed;
                processIns.EndTime      = DateTimeUtils.CurrentDateTimeStr;
                _dataAccessor.Update <WfProcessInstance>(processIns);
                string billTable = processIns.BillTable;

                MessageManager msgManager = new MessageManager(_dataAccessor, _loggerFactory);
                msgManager.SendMessageWhenProcessCompleted(processIns, "通过");

                IWriteBackRule bwb = new BillWriteBack(_dataAccessor);
                //改变单据状态为通过
                bwb.Approved(billTable, billUid);
                //单据回写业务
                bwb.WriteBackToBusiness(billTable, billUid);
            }
            else
            {
                _logger.LogWarning($"{processInsUid}流程不在运行状态,不能被完成!");
                throw new ProcessInstanceException("流程不在运行状态,不能被完成!");
            }
        }
Пример #2
0
        public void BillWriteBack()
        {
            //获取没有回写的流程实例
            IEnumerable <WfProcessInstance> processes = _dataAccessor.QueryWhere <WfProcessInstance>($"ProcessState='Completed' and ApproveResult='Agree' and (WriteBackState=0 or WriteBackState is null)");

            if (processes != null && processes.Any())
            {
                IWriteBackRule writeBackRule = new BillWriteBack(_dataAccessor);
                foreach (var process in processes)
                {
                    writeBackRule.WriteBackToBusiness(process.BillTable, process.BillUid);
                }
            }
        }