public static void Main() { FlowSteps steps = new FlowSteps(); FlowManager flow = new FlowManager(steps.getFirstStep()); while (flow.NextAction != null) { flow.Continue(); } /* Expected output: * Step1 * Step2 * Step3 */ }
public static void Main() { FlowSteps steps = new FlowSteps(); Dictionary <string, object> init_data = new Dictionary <string, object>(3); init_data.Add("repeat", 3); FlowManager flow = new FlowManager(steps.getFirstStep(), init_data); while (flow.NextAction != null) { flow.Continue(); } /* Expected output: * Step1 * Step2_0 * Step2_1 * Step2_2 * Step3 */ }
/// <summary> /// 获取 可退回的步骤 /// </summary> /// <param name="TaskId">流程任务Id</param> /// <param name="FlowId">流程Id</param> /// <returns>步骤<StepId,StepName>的键值对数据集</returns> public Dictionary <int, string> GetBackSteps(Guid TaskId, Guid FlowId) { Dictionary <int, string> steps = new Dictionary <int, string>(); //当前任务 var task = FlowTasks.Where(c => c.Id == TaskId).Select(m => new { m.StepId, m.PrevId }).SingleOrDefault(); //当前步骤 var step = FlowSteps.Where(c => c.FlowDesignId == FlowId && c.StepId == task.StepId).Select(m => new { m.StepType, m.BackType, m.SpecifiedBackStep }).FirstOrDefault(); if (step.StepType != 0) { switch (step.BackType) { //退回到上一步 case 1: var prevTask = FlowTasks.Where(c => c.Id == task.PrevId).Select(m => new { m.StepId, m.StepName }).SingleOrDefault(); steps.Add(prevTask.StepId, prevTask.StepName); break; //退回到第一步 case 2: var fisrtStep = FlowSteps.Where(c => c.StepType == 0 && c.FlowDesignId == FlowId).Select(m => new { m.StepId, m.StepName }).SingleOrDefault(); steps.Add(fisrtStep.StepId, fisrtStep.StepName); break; //退回到指定步 case 3: if (!string.IsNullOrEmpty(step.SpecifiedBackStep)) { var singStep = FlowSteps.Where(c => c.FlowDesignId == FlowId && c.StepName == step.SpecifiedBackStep).Select(m => new { m.StepId, m.StepName }).SingleOrDefault(); steps.Add(singStep.StepId, singStep.StepName); } break; default: break; } } return(steps); }