Beispiel #1
0
        public void Approve(string comment)
        {
            AssertOperation(Current, OperationCode.Approve);
            AssertPrivilege(Current);

            //构建下一个Activity Instance
            var activityTemplate = Current.ActivityTemplate.AllowedActions.FirstOrDefault(p => p.OperationCode == OperationCode.Approve)
                                   .Transit;
            var nextActivityInstance = NewActivityInstance(activityTemplate);

            _originateActivityInstance = Current;
            _originateActivityInstance.MarkFinish();

            Current = nextActivityInstance;

            _isDirty = true;
        }
Beispiel #2
0
        public void Submit(string comment)
        {
            AssertOperation(Current, OperationCode.Submit);
            //提交时不进行权限验证,后面可能要加上,某些用户可能不具备提交特定流程的权限
            //AssertPrivilege(Current);

            var action = GetCurrentAction(Current, OperationCode.Submit);

            //判断是否本节点回环
            if (action.Transit.ActivityTemplateId != Current.ActivityTemplate.ActivityTemplateId)
            {
                //非本节点回环,创建下个节点实例
                var nextActivityInstance = NewActivityInstance(action.Transit);

                //标记该Activity已完成
                _originateActivityInstance = Current;
                _originateActivityInstance.MarkFinish();
                //_originateActivityInstance.Tail.MarkFinished();

                //替换当前节点
                Current = nextActivityInstance;
            }

            //相应的创建Action实例
            var actionRecord = new ActionRecord()
            {
                ActivityInstanceId = Current.ActivityInstanceId,
                RequiredRole       = Current.ActivityTemplate.RequiredRole.Id
            };

            Current.AddAction(actionRecord);

            //当前节点替换
            var auditTrail = new AuditTrailEntry()
            {
                IsNew = true
            };

            //添加审核日志
            AuditTrails.Add(auditTrail);

            _isDirty = true;
        }