public async Task <Dictionary <string, object> > Calculate(RealWorkfolwActivity activity, RealWorkfolwContext context) { /*var inputParameters = await GetInputParameters(activity); * Dictionary<string, object> inputObjects = new Dictionary<string, object>(); * foreach(var inputItem in inputParameters) * { * inputObjects.Add(inputItem.Key, await _realWorkfolwActivityParameterHandle.Execute(inputItem.Value, context)); * } */ RealWorkfolwActivityDescription activityDescription = null; if (!activity.Extensions.TryGetValue("description", out object objActivityDescription)) { activityDescription = await _realWorkfolwActivityResolve.Execute(activity.Configuration); lock (activity) { activity.Extensions["description"] = activityDescription; } } else { activityDescription = (RealWorkfolwActivityDescription)objActivityDescription; } var outputObjects = await _realWorkfolwActivityCalculate.Execute(activityDescription, context, new Dictionary <string, object>()); //context.ActivityOutputParameters[activity.ID.ToString()] = outputObjects; return(outputObjects); }
public async Task <Dictionary <string, object> > Calculate(RealWorkfolwContext context) { return(await _imp.Calculate(this, context)); }
public async Task <Dictionary <string, object> > Execute(RealWorkfolw workflow, RealWorkfolwContext context) { List <RealWorkfolwActivity> activities; if (!workflow.Extensions.TryGetValue("activities", out object objActivities)) { activities = await _activityConfigurationService.SeparateActivities(workflow.Configuration); objActivities = activities; lock (workflow) { workflow.Extensions["activities"] = objActivities; } } activities = (List <RealWorkfolwActivity>)objActivities; int index = 0, count = activities.Count; for (index = 0; index <= count - 1; index++) { var activityResult = await activities[index].Calculate(context); var activityOutputs = await activities[index].GetOutputParameters(); foreach (var activityResultItem in activityResult) { if (!activityOutputs.TryGetValue(activityResultItem.Key, out RealWorkfolwActivityParameter outputParameter)) { var fragment = new TextFragment() { Code = TextCodes.NotFoundRealWorkfolwActivityOutputParameterByActivityResult, DefaultFormatting = "工作流活动{0}的结果中的输出参数名称{1}在工作流活动的输出参数中未定义,工作流id为{2}", ReplaceParameters = new List <object>() { activities[index].ID.ToString(), activityResultItem.Key, workflow.ID.ToString() } }; throw new UtilityException((int)Errors.NotFoundRealWorkfolwActivityOutputParameterByActivityResult, fragment); } var outputDataHandle = _realWorkfolwActivityParameterDataHandleSelector.Choose(outputParameter.DataType); var outputDataValidateResult = await outputDataHandle.ValidateType(activityResultItem.Value); if (!outputDataValidateResult) { string strResult; if (activityResultItem.Value == null) { strResult = "null"; } else { strResult = activityResultItem.Value.GetType().FullName; } var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityOutputParameterDataHandleValidateError, DefaultFormatting = "工作流活动参数数据处理验证失败,验证器数据类型为{0},要验证的实际数据类型为{1},参数名称为{2},工作流活动Id为{3},工作流Id为{4}", ReplaceParameters = new List <object>() { outputParameter.DataType, strResult, outputParameter.Name, activities[index].ID.ToString(), workflow.ID.ToString() } }; throw new UtilityException((int)Errors.RealWorkfolwActivityOutputParameterDataHandleValidateError, fragment); } } context.ActivityOutputParameters[activities[index].ID.ToString()] = activityResult; } Dictionary <string, object> result = new Dictionary <string, object>(); foreach (var resultItem in context.Result) { result.Add(resultItem.Key, resultItem.Value); } return(result); }