protected void ExecuteService(int update, out ErrorResultTO errors, IPluginAction method, INamespaceItem namespaceItem, IDSFDataObject dataObject) { errors = new ErrorResultTO(); var itrs = new List <IWarewolfIterator>(5); IWarewolfListIterator itrCollection = new WarewolfListIterator(); var methodParameters = Inputs.Select(a => new MethodParameter { EmptyToNull = a.EmptyIsNull, IsRequired = a.RequiredField, Name = a.Name, Value = a.Value, TypeName = a.TypeName }).ToList(); BuildParameterIterators(update, methodParameters.ToList(), itrCollection, itrs, dataObject); var args = new PluginInvokeArgs { AssemblyLocation = Namespace.AssemblyLocation, AssemblyName = Namespace.AssemblyName, Fullname = namespaceItem.FullName, Method = method.Method, Parameters = methodParameters }; try { TryExecute(update, dataObject, itrs, itrCollection, methodParameters, args); } catch (Exception e) { errors.AddError(e.Message); } }
private static void AddJObjToEnvironment(IPluginAction pluginAction, int update, IDSFDataObject dataObject, string outputVariable, JToken jObj) { if (jObj.IsEnumerableOfPrimitives()) { var values = jObj.Children().Select(token => token.ToString()).ToList(); if (DataListUtil.IsValueScalar(outputVariable)) { var valueString = string.Join(",", values); dataObject.Environment.Assign(outputVariable, valueString, update); } else { foreach (var value in values) { dataObject.Environment.Assign(outputVariable, value, update); } } } else { if (jObj.IsPrimitive()) { var value = jObj.ToString(); if (!value.IsJSON() && !pluginAction.IsObject) { value = value.TrimEnd('\"').TrimStart('\"'); } if (!string.IsNullOrEmpty(outputVariable)) { dataObject.Environment.Assign(outputVariable, value, update); } } } }
protected void ExecuteService(int update, out ErrorResultTO errors, IPluginAction method, IDSFDataObject dataObject) { errors = new ErrorResultTO(); var itrs = new List <IWarewolfIterator>(5); IWarewolfListIterator itrCollection = new WarewolfListIterator(); var source = ResourceCatalog.GetResource <ComPluginSource>(dataObject.WorkspaceID, SourceId); var methodParameters = Inputs?.Select(a => new MethodParameter { EmptyToNull = a.EmptyIsNull, IsRequired = a.RequiredField, Name = a.Name, Value = a.Value, TypeName = a.TypeName }).ToList() ?? new List <MethodParameter>(); BuildParameterIterators(update, methodParameters.ToList(), itrCollection, itrs, dataObject); var args = new ComPluginInvokeArgs { ClsId = source.ClsId, Is32Bit = source.Is32Bit, Method = method.Method, AssemblyName = Namespace?.AssemblyName, Parameters = methodParameters }; try { TryExecute(update, dataObject, itrs, itrCollection, methodParameters, args); } catch (Exception e) { errors.AddError(e.Message); } }
private void AssignMethodResult(IPluginAction pluginAction, int update, IDSFDataObject dataObject, DateTime start) { { var methodResult = pluginAction.MethodResult; var outputVariable = pluginAction.OutputVariable; if (pluginAction.IsObject) { var jContainer = JToken.Parse(methodResult) as JContainer ?? methodResult.DeserializeToObject(); if (!string.IsNullOrEmpty(outputVariable)) { dataObject.Environment.AddToJsonObjects(outputVariable, jContainer); } } else { if (!pluginAction.IsVoid) { JToken jObj = JToken.Parse(methodResult) ?? methodResult.DeserializeToObject(); if (!methodResult.IsJSON() && !pluginAction.IsObject) { pluginAction.MethodResult = methodResult.TrimEnd('\"').TrimStart('\"'); } if (jObj != null) { if (jObj.IsEnumerableOfPrimitives()) { var values = jObj.Children().Select(token => token.ToString()).ToList(); if (DataListUtil.IsValueScalar(outputVariable)) { var valueString = string.Join(",", values); dataObject.Environment.Assign(outputVariable, valueString, update); } else { foreach (var value in values) { dataObject.Environment.Assign(outputVariable, value, update); } } } else if (jObj.IsPrimitive()) { var value = jObj.ToString(); if (!value.IsJSON() && !pluginAction.IsObject) { value = value.TrimEnd('\"').TrimStart('\"'); } if (!string.IsNullOrEmpty(outputVariable)) { dataObject.Environment.Assign(outputVariable, value, update); } } } } } DispatchDebugStateForMethod(pluginAction, dataObject, update, false, start); } }
protected void ExecuteService(int update, out ErrorResultTO errors, IPluginAction method, INamespaceItem namespaceItem, IDSFDataObject dataObject) { errors = new ErrorResultTO(); var itrs = new List<IWarewolfIterator>(5); IWarewolfListIterator itrCollection = new WarewolfListIterator(); var methodParameters = Inputs.Select(a => new MethodParameter { EmptyToNull = a.EmptyIsNull, IsRequired = a.RequiredField, Name = a.Name, Value = a.Value, TypeName = a.TypeName }).ToList(); BuildParameterIterators(update, methodParameters.ToList(), itrCollection, itrs, dataObject); var args = new PluginInvokeArgs { AssemblyLocation = Namespace.AssemblyLocation, AssemblyName = Namespace.AssemblyName, Fullname = namespaceItem.FullName, Method = method.Method, Parameters = methodParameters }; try { while (itrCollection.HasMoreData()) { int pos = 0; foreach (var itr in itrs) { string injectVal = itrCollection.FetchNextValue(itr); var param = methodParameters.ToList()[pos]; param.Value = param.EmptyToNull && (injectVal == null || string.Compare(injectVal, string.Empty, StringComparison.InvariantCultureIgnoreCase) == 0) ? null : injectVal; pos++; } if (!IsObject) { int i = 0; foreach (var serviceOutputMapping in Outputs) { OutputDescription.DataSourceShapes[0].Paths[i].OutputExpression = DataListUtil.AddBracketsToValueIfNotExist(serviceOutputMapping.MappedTo); i++; } var outputFormatter = OutputFormatterFactory.CreateOutputFormatter(OutputDescription); args.OutputFormatter = outputFormatter; } var result = PluginServiceExecutionFactory.InvokePlugin(args).ToString(); ResponseManager = new ResponseManager { OutputDescription = OutputDescription, Outputs = Outputs, IsObject = IsObject, ObjectName = ObjectName }; ResponseManager.PushResponseIntoEnvironment(result, update, dataObject,false); } } catch (Exception e) { errors.AddError(e.Message); } }
protected void ExecuteService(int update, out ErrorResultTO errors, IPluginAction method, IDSFDataObject dataObject) { errors = new ErrorResultTO(); var itrs = new List <IWarewolfIterator>(5); IWarewolfListIterator itrCollection = new WarewolfListIterator(); var source = ResourceCatalog.GetResource <ComPluginSource>(dataObject.WorkspaceID, SourceId); var methodParameters = Inputs?.Select(a => new MethodParameter { EmptyToNull = a.EmptyIsNull, IsRequired = a.RequiredField, Name = a.Name, Value = a.Value, TypeName = a.TypeName }).ToList() ?? new List <MethodParameter>(); BuildParameterIterators(update, methodParameters.ToList(), itrCollection, itrs, dataObject); var args = new ComPluginInvokeArgs { ClsId = source.ClsId, Is32Bit = source.Is32Bit, Method = method.Method, AssemblyName = Namespace?.AssemblyName, Parameters = methodParameters }; try { if (Inputs == null || Inputs.Count == 0) { PerfromExecution(update, dataObject, args); } else { while (itrCollection.HasMoreData()) { int pos = 0; foreach (var itr in itrs) { string injectVal = itrCollection.FetchNextValue(itr); var param = methodParameters.ToList()[pos]; param.Value = param.EmptyToNull && (injectVal == null || string.Compare(injectVal, string.Empty, StringComparison.InvariantCultureIgnoreCase) == 0) ? null : injectVal; pos++; } PerfromExecution(update, dataObject, args); } } } catch (Exception e) { errors.AddError(e.Message); } }
IEnumerable <DebugItem> BuildMethodInputs(IExecutionEnvironment env, IPluginAction action, int update, bool isMock) { var inputs = new List <DebugItem>(); if (action.Inputs.Any()) { foreach (var methodParameter in action.Inputs) { var debugItem = new DebugItem(); AddDebugItem(new DebugEvalResult(methodParameter.Value ?? "", methodParameter.Name, env, update, false, false, isMock), debugItem); inputs.Add(debugItem); } } return(inputs); }
private static void UpdateEnvironment(IPluginAction pluginAction, int update, IDSFDataObject dataObject, string methodResult, string outputVariable) { if (!pluginAction.IsVoid) { var jObj = JToken.Parse(methodResult) ?? methodResult.DeserializeToObject(); if (!methodResult.IsJSON() && !pluginAction.IsObject) { pluginAction.MethodResult = methodResult.TrimEnd('\"').TrimStart('\"'); } if (jObj != null) { AddJObjToEnvironment(pluginAction, update, dataObject, outputVariable, jObj); } } }
IEnumerable <DebugItem> BuildMethodOutputs(IExecutionEnvironment env, IPluginAction action, int update, bool isMock) { var debugOutputs = new List <DebugItem>(); if (!string.IsNullOrEmpty(action.MethodResult)) { var debugItem = new DebugItem(); if (action.IsVoid) { AddDebugItem(new DebugItemStaticDataParams("None", ""), debugItem); } else { AddDebugItem(new DebugEvalResult(string.IsNullOrEmpty(action.OutputVariable) ? action.MethodResult : action.OutputVariable, "", env, update, false, false, isMock), debugItem); } debugOutputs.Add(debugItem); } return(debugOutputs); }
void AssignMethodResult(IPluginAction pluginAction, int update, IDSFDataObject dataObject, DateTime start) { var methodResult = pluginAction.MethodResult; var outputVariable = pluginAction.OutputVariable; if (pluginAction.IsObject) { var jContainer = JToken.Parse(methodResult) as JContainer ?? methodResult.DeserializeToObject(); if (!string.IsNullOrEmpty(outputVariable)) { dataObject.Environment.AddToJsonObjects(outputVariable, jContainer); } } else { UpdateEnvironment(pluginAction, update, dataObject, methodResult, outputVariable); } DispatchDebugStateForMethod(pluginAction, dataObject, update, false, start); }
void DispatchDebugStateForMethod(IPluginAction action, IDSFDataObject dataObject, int update, bool isMock, DateTime start) { var debugState = PopulateDebugStateWithDefaultValues(dataObject); debugState.ID = action.ID; debugState.StartTime = start; debugState.EndTime = DateTime.Now; debugState.DisplayName = action.Method; debugState.IsSimulation = false; debugState.HasError = action.HasError; debugState.ErrorMessage = action.ErrorMessage; debugState.Name = action.IsProperty ? "Property" : "Method"; debugState.Inputs.AddRange(BuildMethodInputs(dataObject.Environment, action, update, isMock)); var buildMethodOutputs = BuildMethodOutputs(dataObject.Environment, action, update, isMock).ToList(); debugState.Outputs.AddRange(buildMethodOutputs); if (isMock) { debugState.AssertResultList.AddRange(buildMethodOutputs); } _childStatesToDispatch.Add(debugState); }
public IEnumerable <IServiceOutputMapping> GetPluginOutputMappings(IPluginAction action) { return(new List <IServiceOutputMapping> { new ServiceOutputMapping("bob", "The", ""), new ServiceOutputMapping("dora", "The", ""), new ServiceOutputMapping("Tree", "The", "") }); }