Ejemplo n.º 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, "通过");

                IWriteBackService bwb = _serviceProvider.GetService <IWriteBackService>();
                //改变单据状态为通过
                bwb.Approved(billTable, billUid);
                //单据回写业务
                bwb.WriteBackToBusiness(billTable, billUid);
            }
            else
            {
                _logger.LogWarning($"{processInsUid}流程不在运行状态,不能被完成!");
                throw new ProcessInstanceException("流程不在运行状态,不能被完成!");
            }
        }
Ejemplo n.º 2
0
 public WorkflowService(IServiceProvider serviceProvider)
 {
     _serviceProvider    = serviceProvider;
     _dbContext          = serviceProvider.GetService <IDbContext>();
     _loggerFactory      = serviceProvider.GetService <ILoggerFactory>();
     _applicationContext = serviceProvider.GetService <IFapApplicationContext>();
     _logger             = serviceProvider.GetService <ILoggerFactory>().CreateLogger <WorkflowService>();
     _writeBack          = serviceProvider.GetService <IWriteBackService>();
 }
Ejemplo n.º 3
0
 public RecruitService(IDbContext dbContext, IServiceProvider serviceProvider, IFapFileService fapFileService, ILoggerFactory loggerFactory, IFapApplicationContext applicationContext)
 {
     _dbContext          = dbContext;
     _logger             = loggerFactory.CreateLogger <RecruitService>();
     _fapFileService     = fapFileService;
     _applicationContext = applicationContext;
     _serviceProvider    = serviceProvider;
     _messageService     = serviceProvider.GetService <IMessageService>();
     _writeBackService   = serviceProvider.GetService <IWriteBackService>();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 驳回流程,将流程状态置为驳回
        /// </summary>
        /// <param name="processInsUid"></param>
        internal void Revoke(string processInsUid)
        {
            var processIns = _dataAccessor.Get <WfProcessInstance>(processInsUid, false);

            if (processIns.ProcessState == WfProcessInstanceState.Running)
            {
                processIns.ProcessState  = WfProcessInstanceState.Revoked;
                processIns.ApproveResult = WfApproveState.Disagree;
                //processIns.IsHandling = 0;
                _dataAccessor.Update <WfProcessInstance>(processIns);

                MessageManager msgManager = new MessageManager(_dataAccessor, _loggerFactory);
                msgManager.SendMessageWhenProcessCompleted(processIns, "驳回");

                IWriteBackService bwb = _serviceProvider.GetService <IWriteBackService>();
                //改变单据状态为驳回
                bwb.Rejected(processIns.BillTable, processIns.BillUid);
            }
            else
            {
                throw new ProcessInstanceException("流程不在运行状态,不能被驳回!");
            }
        }