Example #1
0
        public void There_Should_Be_No_Action_Log_If_No_Action_Executed()
        {
            var flowDefinition = new FlowDefinition(
                states: new List <State>()
            {
                new State(
                    name: "State1",
                    events:
                    new List <Event>()
                {
                    new Event(name: "Event1")
                }
                    )
            }
                );

            var flowInstance = new FlowInstance(
                currentState: "State1",
                flowDefinition: flowDefinition
                );

            {
            };

            var result = flowInstance.SendEvent("Event1");

            Assert.IsFalse(result.CreatedLogs.Any(cl => cl.LogType == "ActionLog"));
        }
Example #2
0
        public void Event_Changes_Flow_Instances_State_2()
        {
            var flowDefinition = new FlowDefinition(
                states: new List <State>()
            {
                new State(
                    name: "StateA",
                    events:
                    new List <Event>()
                {
                    new Event(
                        name: "EventA",
                        destinationState: "StateB"
                        )
                }
                    ),
                new State(name: "StateB")
            }
                );

            var flowInstance = new FlowInstance(
                currentState: "StateA",
                flowDefinition: flowDefinition
                );

            SendEventResult result = flowInstance.SendEvent("EventA");

            Assert.IsTrue(result.Succeeded);
            Assert.AreEqual("StateB", flowInstance.CurrentState);
        }
        public override void Process(FlowInstance flow, Runners.IRunFlows runner)
        {
            var engine = new ValidationEngine(ExitRules, Variables);

            _isValid    = engine.IsValid;
            IsProcessed = true;
        }
Example #4
0
        public void Action_Execution_Creates_Logs()
        {
            var mockAction = new Mock <IAction>();

            var flowDefinition = new FlowDefinition(
                states: new List <State>()
            {
                new State(
                    name: "State1",
                    events:
                    new List <Event>()
                {
                    new Event(
                        name: "Event1",
                        actions: new List <IAction>()
                    {
                        mockAction.Object
                    }
                        )
                }
                    )
            }
                );

            var flowInstance = new FlowInstance(
                currentState: "State1",
                flowDefinition: flowDefinition
                );


            var result = flowInstance.SendEvent("Event1");

            Assert.IsTrue(result.CreatedLogs.Any(cl => cl.LogType == "Action_PostExecution"));
        }
Example #5
0
 /// <summary>
 /// 创建工作流实例
 /// </summary>
 /// <returns></returns>
 public async Task CreateFlowInstance(FlowInstance flowInstance)
 {
     using (var flowInstanceDao = new FlowInstanceDao())
     {
         await flowInstanceDao.CreateAsync(flowInstance);
     }
 }
Example #6
0
        private void updateTaskForUserStatesAfterAction(EnouFlowInstanceContext db,
                                                        int actionUserId, DateTime bizTimeStamp, DateTime newBizTimeStamp,
                                                        string currentActivityGuid, FlowInstance flowInst, FlowActionRequest reqInDb)
        {
            var tasks = db.flowTaskForUsers.Where(t =>
                                                  t.FlowInstance.flowInstanceId == flowInst.flowInstanceId &&
                                                  t.bizTimeStamp == bizTimeStamp &&
                                                  t.currentActivityGuid == currentActivityGuid).ToList();

            tasks.ForEach(t =>
            {
                if (t.userId != actionUserId)
                {
                    // 其他用户已删除该任务或是已完成的邀请提供处理意见的任务,不需要标记为过期
                    if (t.taskState != EnumFlowTaskState.deletedByUser && t.taskState != EnumFlowTaskState.done)
                    {
                        t.taskState = EnumFlowTaskState.obsoleted;
                    }
                }
                else
                {
                    t.finishTime        = newBizTimeStamp;
                    t.taskState         = EnumFlowTaskState.done;
                    t.FlowActionRequest = reqInDb;
                    t.delegateeUserId   = reqInDb.delegateeUserId; // 有可能是被任务代理人完成
                    t.delegateeUserGuid = reqInDb.delegateeUserGuid;
                }
            });

            //db.SaveChanges();
        }
            //AppovedEventDriven事件驱动方法的实现,开发人员在此实现AppovedEventDriven的逻辑
            private State Appover_AppovedEventDrivenImp(UFIDA.U9.GeneralEvents.ApprovalResultEvent ev)
            {
                State toState = CurrentState;

                //TODO:实现转移条件
                if (this.Entity.DocType.ConfirmType == UFIDA.U9.Base.Doc.ConfirmTypeEnum.ComfirmWork)
                {
                    toState = State.Appover;
                    return(toState);
                }
                //终止审批事件
                if (ev.IsTerminate)
                {
                    ApprovalService.Instance.TerminateApproval(this.Entity);
                    toState = State.Opened;
                }
                else if (ev.IsApprovaled)
                {
                    toState = State.UnAppover;
                }
                else
                {
                    FlowInstance flow = FlowInstance.Finder.Find("SourceOrg=@SourceOrg and OwnerEntity.EntityID=@EntityID and OwnerEntity.EntityType=@EntityType order by ID desc", new OqlParam(this.Entity.Org.ID), new OqlParam(this.Entity.ID), new OqlParam(this.Entity.Key.EntityType));
                    if (flow != null && (flow.ApprovalResult == ApprovalStateEnum.EnumReject || flow.ApprovalResult == ApprovalStateEnum.EnumTerminated))
                    {
                        toState = State.Opened;
                    }
                }
                return(toState);
            }
Example #8
0
        private static void addFlowInstanceFriendlyLog(
            FlowInstance flowInstance, int flowActionRequestId,
            string currentActivityName, int paticipantUserId,
            int?delegateeUserId, string actionName,
            string paticipantMemo, EnouFlowInstanceContext db)
        {
            var log = db.flowFriendlyLogs.Create();

            log.FlowInstance        = flowInstance;
            log.flowActionRequestId = flowActionRequestId;
            log.currentActivityName = currentActivityName;
            using (var orgDb = new EnouFlowOrgMgmtContext())
            {
                UserHelper userHelper = new UserHelper(orgDb);

                var paticipant = userHelper.getUserDTO(paticipantUserId);
                log.paticipantName = paticipant.name +
                                     (paticipant.englishName == null ? "" : "/" + paticipant.englishName);

                if (delegateeUserId.HasValue)
                {
                    var delegatee = userHelper.getUserDTO(delegateeUserId.Value);
                    log.delegateeName = delegatee.name +
                                        (delegatee.englishName == null ? "" : "/" + delegatee.englishName);
                }
            }
            log.actionName     = actionName;
            log.paticipantMemo = paticipantMemo;

            db.flowFriendlyLogs.Add(log);
        }
Example #9
0
        public void Should_return_first_step_if_no_steps_are_completed()
        {
            // arrange
            var steps = new List <IStep> {
                new StartStep {
                    Id = 1
                }, new CollectDataStep {
                    Id = 2
                }, new StopStep {
                    Id = 3
                }
            };
            var template = new FlowTemplate {
                Steps = steps
            };
            var sut = new FlowInstance {
                Template = template
            };

            // act
            var result = sut.NextStep();

            // assert
            Assert.NotNull(result);
            Assert.IsType <StartStep>(result);
        }
Example #10
0
    public IEnumerator ExitFlow()
    {
        isExiting = true;
        PlayerController.controlsAble = false;
        //Destroy flow parent
        transform.parent = null;
        Destroy(theFlowParent);
        flowMovement = null;
        playerController.anim.SetBool("isSwimming", false);

        //Reset waterControl

        //Init lerp
        GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
        Vector3    originPosition = transform.position;
        Quaternion originRotation = transform.rotation;
        Vector3    rayDirection   = detectedExitPoint.GetComponent <ExitPoint> ().GetExitTarget(transform) - transform.position;
        Vector3    targetPosition = new Vector3(0, 0, 0);
        Quaternion targetRotation = new Quaternion(0, 0, 0, 0);

        if (Physics.Raycast(transform.position, rayDirection, out hit, 10f, layer))
        {
            targetPosition = hit.point;
            targetRotation = Quaternion.LookRotation(transform.forward, hit.normal);
        }

        PlayerController.inFlow = false;
        //Lerp & Slerp
        float vol = soundMan.flowSource.volume;

        for (float i = 0; i < 1; i += Time.deltaTime * outSpeed)
        {
            //transform.position = Vector3.Lerp(originPosition, targetPosition, exitCurve.Evaluate(i));
            transform.rotation = Quaternion.Slerp(originRotation, targetRotation, exitCurve.Evaluate(i));

            //Lerp in the flow sound

            soundMan.flowSource.volume = Mathf.Lerp(vol, 0f, i);

            yield return(new WaitForFixedUpdate());
        }

        leftSwimBubbles.Stop();
        rightSwimBubbles.Stop();
        soundMan.flowSource.Stop();
        soundMan.flowSource.volume = vol;
        impactCloud.Play();

        isExiting = false;

        //Switch to not in flow mode
        FlowMode(false);
        PlayerController.controlsAble = true;
        waterControl.ResetFlow();
        currentFlow = null;

        //Reset exit point
        //detectedExitPoint.GetComponent<Renderer>().material.SetFloat("_OutlineSwitch", 0);
        detectedExitPoint = null;
    }
Example #11
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public FlowRuntime(FlowInstance instance)
        {
            dynamic schemeContentJson = instance.SchemeContent.ToJson();//获取工作流模板内容的json对象;

            InitLines(schemeContentJson);
            InitNodes(schemeContentJson);

            currentNodeId   = (instance.ActivityId == "" ? startNodeId : instance.ActivityId);
            currentNodeType = GetNodeType(currentNodeId);
            FrmData         = instance.FrmData;
            title           = schemeContentJson.title;
            initNum         = schemeContentJson.initNum;
            previousId      = instance.PreviousId;
            flowInstanceId  = instance.Id;

            //会签开始节点和流程结束节点没有下一步
            if (currentNodeType == 0 || currentNodeType == 4)
            {
                nextNodeId   = "-1";
                nextNodeType = -1;
            }
            else
            {
                nextNodeId   = GetNextNodeId();//下一个节点
                nextNodeType = GetNodeType(nextNodeId);
            }
        }
Example #12
0
        /// <summary>
        /// 建構函式
        /// </summary>
        public FlowRuntime(FlowInstance instance)
        {
            dynamic schemeContentJson = instance.SchemeContent.ToJson();//獲取工作流模板內容的json對像;

            InitLines(schemeContentJson);
            InitNodes(schemeContentJson);

            currentNodeId   = (instance.ActivityId == "" ? startNodeId : instance.ActivityId);
            currentNodeType = GetNodeType(currentNodeId);
            FrmData         = instance.FrmData;
            title           = schemeContentJson.title;
            initNum         = schemeContentJson.initNum ?? 0;
            previousId      = instance.PreviousId;
            flowInstanceId  = instance.Id;

            //會簽開始節點和流程結束節點沒有下一步
            if (currentNodeType == 0 || currentNodeType == 4)
            {
                nextNodeId   = "-1";
                nextNodeType = -1;
            }
            else
            {
                nextNodeId   = GetNextNodeId();//下一個節點
                nextNodeType = GetNodeType(nextNodeId);
            }
        }
Example #13
0
        public void Flow_Instance_Construction_Wrong_State_Name_Throws_Error()
        {
            var flowDefinition = new FlowDefinition(
                states: new List <State>()
            {
                new State(
                    name: "StateA",
                    events:
                    new List <Event>()
                {
                    new Event(name: "EventA")
                }
                    )
            }

                );

            FlowInstance flowInstance;


            var ex = Assert.Throws <FlowInstanceException>(
                () =>
            {
                flowInstance = new FlowInstance(currentState: "StateB", flowDefinition: flowDefinition);
            });
        }
Example #14
0
        public void Undefined_Event_Returns_Unsuccessful_Result()
        {
            var flowDefinition = new FlowDefinition(
                states: new List <State>()
            {
                new State(
                    name: "StateA",
                    events:
                    new List <Event>()
                {
                    new Event(name: "EventA")
                }
                    )
            }
                );

            var flowInstance = new FlowInstance(
                currentState: "StateA",
                flowDefinition: flowDefinition
                );

            SendEventResult result = flowInstance.SendEvent("EventB");

            Assert.AreEqual(false, result.Succeeded);
        }
Example #15
0
        public void Event_Triggers_Action()
        {
            var mockAction = new Mock <IAction>();

            var flowDefinition = new FlowDefinition(
                states: new List <State>()
            {
                new State(
                    name: "State1",
                    events:
                    new List <Event>()
                {
                    new Event(
                        name: "Event1",
                        actions: new List <IAction>()
                    {
                        mockAction.Object
                    }
                        )
                }
                    )
            }
                );

            var flowInstance = new FlowInstance(
                currentState: "State1",
                flowDefinition: flowDefinition
                );

            var result = flowInstance.SendEvent("Event1");

            mockAction.Verify(action => action.Execute());
        }
Example #16
0
        public void Event_Does_Not_Change_The_State()
        {
            var flowDefinition = new FlowDefinition(
                states: new List <State>()
            {
                new State(
                    name: "State1",
                    events:
                    new List <Event>()
                {
                    new Event(name: "Event1")
                }
                    )
            }

                );

            var flowInstance = new FlowInstance(
                currentState: "State1",
                flowDefinition: flowDefinition
                );

            var result = flowInstance.SendEvent("Event1");

            Assert.AreEqual("State1", flowInstance.CurrentState);
        }
Example #17
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="currentNodeId">当前节点</param>
        /// <param name="frmData">表单数据</param>
        /// <param name="instance"></param>
        public FlowRuntime(FlowInstance instance)
        {
            _runtimeModel = new FlowRuntimeModel();
            dynamic schemeContentJson = instance.SchemeContent.ToJson();//获取工作流模板内容的json对象;

            _runtimeModel.frmData           = instance.FrmData;
            _runtimeModel.schemeContentJson = schemeContentJson;               //模板流程json对象
            _runtimeModel.nodes             = GetNodes(schemeContentJson);     //节点集合
            _runtimeModel.lines             = GetFromLines(schemeContentJson); //线条集合
            _runtimeModel.currentNodeId     = (instance.ActivityId == "" ? _runtimeModel.startNodeId : instance.ActivityId);
            _runtimeModel.currentNodeType   = GetNodeType(_runtimeModel.currentNodeId);

            //会签开始节点和流程结束节点没有下一步
            if (_runtimeModel.currentNodeType == 0 || _runtimeModel.currentNodeType == 4)
            {
                _runtimeModel.nextNodeId   = "-1";
                _runtimeModel.nextNodeType = -1;
            }
            else
            {
                _runtimeModel.nextNodeId   = GetNextNodeId(_runtimeModel.frmData);//下一个节点
                _runtimeModel.nextNodeType = GetNodeType(_runtimeModel.nextNodeId);
            }

            _runtimeModel.previousId     = instance.PreviousId;
            _runtimeModel.flowInstanceId = instance.Id;
        }
Example #18
0
 public void InitFlow(FlowInstance detectedFlow, float percentage, Vector3 upVector)
 {
     //Get values from the current flow
     currentFlow        = detectedFlow;
     speed              = currentFlow.speed;
     currentPathPercent = percentage;
     waypoints          = currentFlow.waypoints;
     upDirection        = upVector;
 }
Example #19
0
 public void Flow_Instance_Construction_Missing_Flow_Definition_Throws_Error()
 {
     FlowInstance flowInstance;
     var          ex = Assert.Throws <FlowInstanceException>(
         () =>
     {
         flowInstance = new FlowInstance(flowDefinition: null, currentState: "StateB");
     });
 }
Example #20
0
 public FlowActionStartResult(int flowActionRequestId,
                              string clientRequestGuid,
                              FlowInstance flowInstance,
                              bool succeed = true, string failReason = null)
     : base(flowActionRequestId, clientRequestGuid,
            EnumFlowActionRequestType.start, flowInstance
            , succeed, failReason)
 {
 }
Example #21
0
        public ActionResult Save()
        {
            //当前登录人员信息
            var userInfo = Session[CommonSession.CurrentUser] as SysUser;

            if (userInfo != null)
            {
                //request.CreateTime = DateTime.Now;
                //1.保存请假单
                //context.LeaveRequests.AddOrUpdate(request);

                var Bid = Guid.NewGuid(); //业务Id

                //2.创建工作流
                var flowInstance = new FlowInstance
                {
                    //工作流当前节点
                    NodeNumber = _flowNodeService.GetFlowNodeByNodeName("发起申请").Result.NodeNumber,
                    NodeName   = "发起申请",
                    //申请处理状态
                    StatusName = "已申请",
                    //申请人(流程发起人)
                    StartUserId = userInfo.Id,
                    StartUser   = userInfo.RealName,
                    //当前操作者
                    OperatingUserId = userInfo.Id,
                    OperatingUser   = userInfo.RealName,
                    //下一个节点处理人
                    ToDoUserId = _flowNodeService.GetFlowNodeByNodeName("部门经理审批").Result.OperateUserId,
                    ToDoUser   = _flowNodeService.GetFlowNodeByNodeName("部门经理审批").Result.OperateUser,
                    ////申请单ID
                    RequisitionId = Bid,
                    UpdateTime    = DateTime.Now,
                    CreateTime    = DateTime.Now,
                    //已操作过的人
                    OperatedUserId = userInfo.Id,
                    OperatedUser   = userInfo.RealName
                };

                //添加
                _flowInstanceSvc.CreateFlowInstance(flowInstance);

                ////3.新建流操作记录
                var flowRecord = new FlowRecord
                {
                    WorkId            = flowInstance.Id,         //流程实例Id
                    OperateUser       = userInfo.RealName,       //当前处理人
                    OperateUserId     = userInfo.Id,
                    CurrentNodeNumber = flowInstance.NodeNumber, ////当前节点
                    CurrentNode       = flowInstance.NodeName,
                    IsRead            = true,                    ////是否已读
                    IsPass            = true,                    ////是否通过
                    UpdateTime        = DateTime.Now
                };
            }
            return(View());
        }
Example #22
0
 public FlowActionInviteOtherFeedbackResult(int flowActionRequestId,
                                            string clientRequestGuid,
                                            FlowInstance flowInstance,
                                            bool succeed = true, string failReason = null)
     : base(flowActionRequestId, clientRequestGuid,
            EnumFlowActionRequestType.inviteOtherFeedback, flowInstance
            , succeed, failReason)
 {
 }
Example #23
0
 public FlowActionMoveToAutoGeneratedResult(int flowActionRequestId,
                                            string clientRequestGuid,
                                            FlowInstance flowInstance,
                                            bool succeed = true, string failReason = null)
     : base(flowActionRequestId, clientRequestGuid,
            EnumFlowActionRequestType.moveToAutoGenerated, flowInstance
            , succeed, failReason)
 {
 }
Example #24
0
 private bool updateBizDataPayloadJsonOfFlowInst(FlowInstance flowInst,
                                                 FlowAction req)
 {
     if (!string.IsNullOrEmpty(req.bizDataPayloadJson))
     {
         flowInst.bizDataPayloadJson = req.bizDataPayloadJson;
         return(true);
     }
     return(false);
 }
Example #25
0
        /// <summary>
        /// 显示编辑框和里面的用户数据
        /// </summary>
        /// <param name="contentdata">The contentdata.</param>
        /// <param name="contentParse">The content parse.</param>
        /// <param name="frmData">The FRM data.</param>
        /// <returns>System.String.</returns>
        public static string Preview(FlowInstance flowInstance)
        {
            if (flowInstance.FrmType != 0)  //只有开原版动态表单才需要转换
            {
                return(string.Empty);
            }

            return(GetHtml(flowInstance.FrmContentData, flowInstance.FrmContentParse,
                           flowInstance.FrmData, "view"));
        }
Example #26
0
 private void updateRequestToSuccess(FlowActionRequest reqInDb,
                                     FlowInstance flowInst)
 {
     reqInDb.isProcessed = true;
     reqInDb.finishTime  = DateTime.Now;
     reqInDb.resultType  = EnumFlowActionRequestResultType.success;
     if (reqInDb.flowInstance == null || reqInDb.flowInstanceGuid == null)
     {
         reqInDb.flowInstance     = flowInst;
         reqInDb.flowInstanceGuid = flowInst.guid;
     }
 }
 public string Update(FlowInstance obj)
 {
     try
     {
         _app.Update(obj);
     }
     catch (Exception ex)
     {
         Result.Code    = 500;
         Result.Message = ex.InnerException?.Message ?? ex.Message;
     }
     return(JsonHelper.Instance.Serialize(Result));
 }
        public Response Update(FlowInstance obj)
        {
            var result = new Response();

            try {
                _app.Update(obj);
            } catch (Exception ex) {
                result.Code    = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return(result);
        }
Example #29
0
        public ActionResult FlowSubmit(int flowType, int flowInstanceId)
        {
            switch (flowType)
            {
            case 1: break;

            case 2: break;

            case 3: break;

            case 4: break;
            }

            //当前登录人员信息
            var userInfo = Session[CommonSession.CurrentUser] as SysUser;

            if (userInfo != null)
            {
                //2.创建工作流
                var flowInstance = new FlowInstance
                {
                    //工作流当前节点
                    NodeNumber = _flowNodeService.GetFlowNodeByNodeName("工程申请计划").Result.Id,
                    //申请处理状态
                    StatusName = "已申请",
                    //申请人(流程发起人)
                    StartUserId = userInfo.Id,
                    //当前操作者
                    OperatingUserId = userInfo.Id,
                    //下一个节点处理人
                    ToDoUserId = _flowNodeService.GetFlowNodeByNodeName("工程审核计划").Result.SysRoleId,
                    UpdateTime = DateTime.Now,
                    CreateTime = DateTime.Now,
                    //已操作过的人
                    OperatedUserId = userInfo.Id
                };

                //添加
                _flowInstanceSvc.CreateFlowInstance(flowInstance);

                ////3.新建流操作记录
                var flowRecord = new FlowRecord
                {
                    FlowInstanceId = flowInstance.Id, //流程实例Id
                    IsRead         = true,            ////是否已读
                    IsPass         = true,            ////是否通过
                    UpdateTime     = DateTime.Now
                };
            }
            return(View());
        }
Example #30
0
        private FlowInstance getFlowInstance(EnouFlowInstanceContext db,
                                             int flowInstanceId, string bizDocumentGuid)
        {
            FlowInstance flowInst = db.flowInstances.Find(flowInstanceId);

            if (flowInst == null)
            {
                flowInst = db.flowInstances.Where(
                    inst => inst.bizDocumentGuid == bizDocumentGuid)
                           .ToList().FirstOrDefault();
            }

            return(flowInst);
        }