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 <RealWorkfolwActivityDescription> Execute(string activityConfiguration) { XElement configuration = null; try { configuration = XElement.Parse(activityConfiguration); } catch (Exception ex) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationParseXMLError, DefaultFormatting = "工作流活动配置转换成XML时出错,活动配置:{0},错误原因:{1}", ReplaceParameters = new List <object>() { activityConfiguration, ex.Message } }; var exception = new UtilityException((int)Errors.RealWorkfolwActivityConfigurationParseXMLError, fragment); exception.Data[UtilityExceptionDataKeys.Catch] = true; throw exception; } RealWorkfolwActivityDescriptionDataForTransaction data = new RealWorkfolwActivityDescriptionDataForTransaction(); data.Activities = new List <RealWorkfolwActivityDescription>(); var scopeAttribute = configuration.Attribute("scope"); if (scopeAttribute == null) { data.Scope = "1"; } else { data.Scope = scopeAttribute.Value; } var levelAttribute = configuration.Attribute("level"); if (levelAttribute == null) { data.Level = "1"; } else { data.Level = levelAttribute.Value; } var timeoutAttribute = configuration.Attribute("timeout"); if (timeoutAttribute != null) { try { data.Timeout = TimeSpan.Parse(timeoutAttribute.Value); } catch { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationAttributeParseTypeError, DefaultFormatting = "工作流活动配置中的属性{0}的值无法转换为类型{1},属性值为{2},所属节点的值为{3}", ReplaceParameters = new List <object>() { "timeout", typeof(TimeSpan).FullName, timeoutAttribute.Value, configuration.ToString() } }; throw new UtilityException((int)Errors.RealWorkfolwActivityConfigurationAttributeParseTypeError, fragment); } } var activitiesElement = configuration.Element("activities"); if (activitiesElement != null) { var activitise = await _activityConfigurationService.SeparateActivities(activitiesElement.ToString()); foreach (var activityItem in activitise) { var activityDescription = await _realWorkfolwActivityResolve.Execute(activityItem.Configuration); data.Activities.Add(activityDescription); } } RealWorkfolwActivityDescription description = new RealWorkfolwActivityDescription() { Data = data }; return(description); }
public async Task <RealWorkfolwActivityDescription> Execute(string activityConfiguration) { XElement configuration = null; try { configuration = XElement.Parse(activityConfiguration); } catch (Exception ex) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationParseXMLError, DefaultFormatting = "工作流活动配置转换成XML时出错,活动配置:{0},错误原因:{1}", ReplaceParameters = new List <object>() { activityConfiguration, ex.Message } }; var exception = new UtilityException((int)Errors.RealWorkfolwActivityConfigurationParseXMLError, fragment); exception.Data[UtilityExceptionDataKeys.Catch] = true; throw exception; } RealWorkfolwActivityDescriptionDataForWhile data = new RealWorkfolwActivityDescriptionDataForWhile(); var activitiesElement = configuration.Element("activities"); if (activitiesElement == null) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationParseXMLError, DefaultFormatting = "工作流活动配置转换成XML时出错,活动配置:{0},错误原因:{1}", ReplaceParameters = new List <object>() { activityConfiguration, new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationMissXMLElement, DefaultFormatting = "工作流活动配置缺少XML节点{0}", ReplaceParameters = new List <object>() { "activities" } } } }; var exception = new UtilityException((int)Errors.RealWorkfolwActivityConfigurationParseXMLError, fragment); exception.Data[UtilityExceptionDataKeys.Catch] = true; throw exception; } var activities = await _activityConfigurationService.SeparateActivities(activitiesElement.ToString()); List <RealWorkfolwActivityDescription> activityDescriptionList = new List <RealWorkfolwActivityDescription>(); foreach (var itemActivity in activities) { var activityDescription = await _realWorkfolwActivityResolve.Execute(itemActivity.Configuration); activityDescriptionList.Add(activityDescription); } RealWorkfolwActivityDescription description = new RealWorkfolwActivityDescription() { Data = data }; return(description); }
public async Task <RealWorkfolwActivityDescription> Execute(string activityConfiguration) { XElement configuration = null; try { configuration = XElement.Parse(activityConfiguration); } catch (Exception ex) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationParseXMLError, DefaultFormatting = "工作流活动配置转换成XML时出错,活动配置:{0},错误原因:{1}", ReplaceParameters = new List <object>() { activityConfiguration, ex.Message } }; var exception = new UtilityException((int)Errors.RealWorkfolwActivityConfigurationParseXMLError, fragment); exception.Data[UtilityExceptionDataKeys.Catch] = true; throw exception; } RealWorkfolwActivityDescriptionDataForParallel data = new RealWorkfolwActivityDescriptionDataForParallel(); data.Items = new List <RealWorkfolwActivityDescriptionDataForParallelItem>(); var maxAttribute = configuration.Attribute("max"); if (maxAttribute == null) { data.Max = 4; } else { if (!int.TryParse(maxAttribute.Value, out int max)) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationAttributeParseTypeError, DefaultFormatting = "工作流活动配置中的属性{0}的值无法转换为类型{1},属性值为{2},所属节点的值为{3}", ReplaceParameters = new List <object>() { "max", typeof(int).FullName, maxAttribute.Value, configuration.ToString() } }; throw new UtilityException((int)Errors.RealWorkfolwActivityConfigurationAttributeParseTypeError, fragment); } data.Max = max; } var itemsElement = configuration.Element("items"); if (itemsElement != null) { var itemElementList = itemsElement.Elements("item"); foreach (var itemElement in itemElementList) { var activitiesElement = itemsElement.Element("activities"); var errorHandleElement = itemsElement.Element("errorhandle"); RealWorkfolwActivityDescriptionDataForParallelItem item = new RealWorkfolwActivityDescriptionDataForParallelItem() { Activities = new List <RealWorkfolwActivityDescription>(), ErrorHandle = null }; data.Items.Add(item); if (activitiesElement != null) { var activitise = await _activityConfigurationService.SeparateActivities(activitiesElement.ToString()); foreach (var activityItem in activitise) { var activityDescription = await _realWorkfolwActivityResolve.Execute(activityItem.Configuration); item.Activities.Add(activityDescription); } } if (errorHandleElement != null && errorHandleElement.FirstNode != null) { var errorHandleActivity = await _activityConfigurationService.ResolveActivity(errorHandleElement.FirstNode.ToString()); var errorHandleActivityDescription = await _realWorkfolwActivityResolve.Execute(errorHandleActivity.Configuration); item.ErrorHandle = errorHandleActivityDescription; } } } RealWorkfolwActivityDescription description = new RealWorkfolwActivityDescription() { Data = data }; return(description); }
public async Task <RealWorkfolwActivityDescription> Execute(string activityConfiguration) { XElement configuration = null; try { configuration = XElement.Parse(activityConfiguration); } catch (Exception ex) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationParseXMLError, DefaultFormatting = "工作流活动配置转换成XML时出错,活动配置:{0},错误原因:{1}", ReplaceParameters = new List <object>() { activityConfiguration, ex.Message } }; var exception = new UtilityException((int)Errors.RealWorkfolwActivityConfigurationParseXMLError, fragment); exception.Data[UtilityExceptionDataKeys.Catch] = true; throw exception; } RealWorkfolwActivityDescriptionDataForCondition data = new RealWorkfolwActivityDescriptionDataForCondition(); var matchElement = configuration.Element("match"); if (matchElement == null) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationParseXMLError, DefaultFormatting = "工作流活动配置转换成XML时出错,活动配置:{0},错误原因:{1}", ReplaceParameters = new List <object>() { activityConfiguration, new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationMissXMLElement, DefaultFormatting = "工作流活动配置缺少XML节点{0}", ReplaceParameters = new List <object>() { "match" } } } }; var exception = new UtilityException((int)Errors.RealWorkfolwActivityConfigurationParseXMLError, fragment); exception.Data[UtilityExceptionDataKeys.Catch] = true; throw exception; } var matchActivities = await _activityConfigurationService.SeparateActivities(matchElement.ToString()); List <RealWorkfolwActivityDescription> matchList = new List <RealWorkfolwActivityDescription>(); foreach (var itemMatchActivity in matchActivities) { var match = await _realWorkfolwActivityResolve.Execute(itemMatchActivity.Configuration); matchList.Add(match); } data.Match = matchList; data.ElseIfs = await GetElseifs(activityConfiguration, configuration); var elseElement = configuration.Element("else"); if (elseElement == null) { var fragment = new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationParseXMLError, DefaultFormatting = "工作流活动配置转换成XML时出错,活动配置:{0},错误原因:{1}", ReplaceParameters = new List <object>() { activityConfiguration, new TextFragment() { Code = TextCodes.RealWorkfolwActivityConfigurationMissXMLElement, DefaultFormatting = "工作流活动配置缺少XML节点{0}", ReplaceParameters = new List <object>() { "else" } } } }; var exception = new UtilityException((int)Errors.RealWorkfolwActivityConfigurationParseXMLError, fragment); exception.Data[UtilityExceptionDataKeys.Catch] = true; throw exception; } var elseActivities = await _activityConfigurationService.SeparateActivities(elseElement.ToString()); List <RealWorkfolwActivityDescription> elseList = new List <RealWorkfolwActivityDescription>(); foreach (var itemElseActivity in elseActivities) { var elseActivity = await _realWorkfolwActivityResolve.Execute(itemElseActivity.Configuration); elseList.Add(elseActivity); } data.Else = elseList; RealWorkfolwActivityDescription description = new RealWorkfolwActivityDescription() { Data = data }; return(description); }