/// <summary> /// 读取节点的上一步节点信息 /// </summary> /// <param name="runningActivity">当前节点</param> /// <param name="hasPassedGatewayNode">是否经由路由节点</param> /// <returns></returns> internal List <WfActivityInstance> GetPreviousActivity(WfActivityInstance runningActivity, bool isSendback, out bool hasPassedGatewayNode) { hasPassedGatewayNode = false; var transitionList = GetTransitionList(runningActivity.ProcessInsUid).ToList(); string backSrcActivityInstanceId = ""; if (isSendback == true && runningActivity.BackSrcActivityId != null) { //节点时曾经发生退回的节点 backSrcActivityInstanceId = runningActivity.BackSrcActivityId; } else { if (!string.IsNullOrWhiteSpace(runningActivity.MainActivityId))//如果是会签节点找到主节点ID { backSrcActivityInstanceId = runningActivity.MainActivityId; } else { backSrcActivityInstanceId = runningActivity.Fid; } } var aim = new ActivityInstanceManager(_dataAccessor, _loggerFactory); var runningTransitionList = transitionList.Where(o => o.TargetActivityInsUid == backSrcActivityInstanceId).ToList(); List <WfActivityInstance> previousActivityList = new List <WfActivityInstance>(); foreach (var entity in runningTransitionList) { //如果是逻辑节点,则继续查找 if (entity.SourceActivityNodeType == WfActivityType.GatewayNode) { GetPreviousOfGatewayActivity(transitionList, entity.SourceActivityNodeId, previousActivityList); hasPassedGatewayNode = true; } else { previousActivityList.Add(aim.GetByFid(entity.SourceActivityNodeId)); } } return(previousActivityList); }
private void GetPreviousOfGatewayActivity(IList <WfTransitionInstance> transitionList, string toActivityId, List <WfActivityInstance> previousActivityList) { var previousTransitionList = transitionList.Where(o => o.TargetActivityNodeId == toActivityId).ToList(); var aim = new ActivityInstanceManager(_dataAccessor, _loggerFactory); foreach (var entity in previousTransitionList) { if (entity.SourceActivityNodeType == WfActivityType.TaskNode || entity.SourceActivityNodeType == WfActivityType.PluginNode || entity.SourceActivityNodeType == WfActivityType.ScriptNode || entity.SourceActivityNodeType == WfActivityType.StartNode) { previousActivityList.Add(aim.GetByFid(entity.SourceActivityInsUid)); } else if (entity.SourceActivityNodeType == WfActivityType.GatewayNode) { GetPreviousOfGatewayActivity(transitionList, entity.SourceActivityNodeId, previousActivityList); } } }