string GetGroupName(string displayExpression, string rawExpression, ref int grpIdx, ref string item, ref string groupName) { var expr = displayExpression; if (displayExpression.Contains("().") || displayExpression.Contains("(*).")) { grpIdx++; var index = grpIdx.ToString(CultureInfo.InvariantCulture); if (rawExpression.Contains(".WarewolfPositionColumn")) { index = item; item = ""; } groupName = rawExpression.Replace(".WarewolfPositionColumn", ""); expr = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(_variable), DataListUtil.ExtractFieldNameFromValue(_variable), index)).Replace(".WarewolfPositionColumn", ""); } else { var indexRegionFromRecordset = DataListUtil.ExtractIndexRegionFromRecordset(expr); int.TryParse(indexRegionFromRecordset, out int indexForRecset); if (indexForRecset > 0) { var indexOfOpenningBracket = expr.IndexOf("(", StringComparison.Ordinal) + 1; var group = expr.Substring(0, indexOfOpenningBracket) + "*" + expr.Substring(indexOfOpenningBracket + indexRegionFromRecordset.Length); grpIdx++; groupName = @group; } } return(expr); }
static void ProcessRecordsetInputs(IServiceTestModelTO serviceTestModelTO, IDev2Definition dev2Definition) { var rec = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, ""); var indexes = serviceTestModelTO.Inputs.Where(input => DataListUtil.ExtractRecordsetNameFromValue(input.Variable) == dev2Definition.RecordSetName).Select(input => DataListUtil.ExtractIndexRegionFromRecordset(input.Variable)).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); if (serviceTestModelTO.Inputs.FirstOrDefault(input => DataListUtil.ReplaceRecordsetIndexWithBlank(input.Variable) == rec) == null) { if (indexes.Count == 0) { serviceTestModelTO.Inputs.Add(new ServiceTestInputTO { Variable = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, "1"), Value = "", EmptyIsNull = false }); } else { foreach (var index in indexes) { serviceTestModelTO.Inputs.Add(new ServiceTestInputTO { Variable = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, index), Value = "", EmptyIsNull = false }); } } } }
void MapForInputOutput(XElement rootEl) { if (rootEl == null) { return; } Inputs.AddRange( rootEl.Elements().Where(el => { var firstOrDefault = el.Attributes("ColumnIODirection").FirstOrDefault(); var removeCondition = firstOrDefault != null && (firstOrDefault.Value == enDev2ColumnArgumentDirection.Input.ToString() || firstOrDefault.Value == enDev2ColumnArgumentDirection.Both.ToString()); return removeCondition && !el.HasElements; }).Select(element => element.Name.ToString())); Outputs.AddRange( rootEl.Elements().Where(el => { var firstOrDefault = el.Attributes("ColumnIODirection").FirstOrDefault(); var removeCondition = firstOrDefault != null && (firstOrDefault.Value == enDev2ColumnArgumentDirection.Output.ToString() || firstOrDefault.Value == enDev2ColumnArgumentDirection.Both.ToString()); return removeCondition && !el.HasElements; }).Select(element => element.Name.ToString())); var xElements = rootEl.Elements().Where(el => el.HasElements); var enumerable = xElements as IList<XElement> ?? xElements.ToList(); Inputs.AddRange(enumerable.Elements().Select(element => { var xAttribute = element.Attributes("ColumnIODirection").FirstOrDefault(); var include = xAttribute != null && (xAttribute.Value == enDev2ColumnArgumentDirection.Input.ToString() || xAttribute.Value == enDev2ColumnArgumentDirection.Both.ToString()); if (include) { if (element.Parent != null) { return DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*")); } } return ""; })); Outputs.AddRange(enumerable.Elements().Select(element => { var xAttribute = element.Attributes("ColumnIODirection").FirstOrDefault(); var include = xAttribute != null && (xAttribute.Value == enDev2ColumnArgumentDirection.Output.ToString() || xAttribute.Value == enDev2ColumnArgumentDirection.Both.ToString()); if (include) { if (element.Parent != null) { return DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*")); } } return ""; })); }
IList <IDataListItem> ConvertToIDataListItem(IRecordSet recordSet, enDev2ColumnArgumentDirection directionToGet) { IList <IDataListItem> result = new List <IDataListItem>(); var dataListEntry = recordSet; foreach (var column in dataListEntry.Columns) { var fields = column.Value.Where(c => c.IODirection == enDev2ColumnArgumentDirection.Both || c.IODirection == directionToGet).ToList(); foreach (var col in fields) { IDataListItem singleRes = new DataListItem { CanHaveMutipleRows = true, Recordset = recordSet.Name, Field = col.Name, Index = column.Key.ToString(), Value = col.Value.UnescapeString(), DisplayValue = DataListUtil.CreateRecordsetDisplayValue(recordSet.Name, col.Name, column.Key.ToString()), Description = col.Description }; result.Add(singleRes); } } return(result); }
static List <IDebugItemResult> ProcessRecordSet(XElement recordSetElement, IEnumerable <XElement> elements) { var processRecordSet = new List <IDebugItemResult>(); var recSetName = recordSetElement.Name.LocalName; var xAttribute = recordSetElement.Attribute("Index"); if (xAttribute != null) { var index = xAttribute.Value; foreach (var xElement in elements) { var debugItemResult = new DebugItemResult { GroupName = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.MakeValueIntoHighLevelRecordset(recSetName, true)), Value = xElement.Value, GroupIndex = int.Parse(index), Variable = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(recSetName, xElement.Name.LocalName, index)), Operator = "=", Type = DebugItemResultType.Variable }; processRecordSet.Add(debugItemResult); } } return(processRecordSet); }
static void LoadInputsFromAllElements(List <string> inputs, XElement rootEl) { if (rootEl is null) { return; } var inputsWithNoElements = rootEl.Elements() .Where(element => !element.HasElements) .Select(element => element.Name.ToString()); inputs.AddRange(inputsWithNoElements); var elementsWithElements = rootEl.Elements().Where(el => el.HasElements); var enumerable = elementsWithElements as IEnumerable <XElement> ?? elementsWithElements.ToList(); inputs.AddRange(elementsWithElements.Elements().Select(element => { if (element.Parent != null) { return(DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*"))); } return(""); })); }
void AddTableToDataList(Table table) { // build up DataTable foreach (TableRow row in table.Rows) { var i = 0; foreach (string columnName in table.Header) { var value = row[i] == "blank" ? "" : row[i]; if (value.ToUpper() == "NULL") { var recordsetDisplayValue = DataListUtil.CreateRecordsetDisplayValue("rs", columnName, ""); DataObject.Environment.AssignDataShape(DataListUtil.AddBracketsToValueIfNotExist(recordsetDisplayValue)); } else { var recordsetDisplayValue = DataListUtil.CreateRecordsetDisplayValue("rs", columnName, ""); var assignValue = new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(recordsetDisplayValue), row[i]); DataObject.Environment.AssignWithFrame(assignValue, 0); } i++; } DataObject.Environment.CommitAssign(); } // Execute Translator }
protected void GetRecordSetFieldValueFromDataList(IExecutionEnvironment environment, string recordSet, string fieldNameToRetrieve, out IList <string> result, out string error) { var variableName = recordSet; result = new List <string>(); error = ""; try { if (!string.IsNullOrEmpty(fieldNameToRetrieve)) { variableName = DataListUtil.CreateRecordsetDisplayValue(recordSet, fieldNameToRetrieve, "*"); } var warewolfEvalResult = environment.Eval(DataListUtil.AddBracketsToValueIfNotExist(variableName), 0, true); if (warewolfEvalResult == null) { return; } if (warewolfEvalResult is CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult listResult) { foreach (var res in listResult.Item) { result.Add(ExecutionEnvironment.WarewolfAtomToString(res)); } } } catch (Exception e) { error = e.Message; } }
private void UpdateOutputsForTest(IServiceTestModelTO serviceTestModelTO, IList <IDev2Definition> outputDefs) { if (outputDefs.Count == 0) { serviceTestModelTO.Outputs = new List <IServiceTestOutput>(); } else { if (serviceTestModelTO.Outputs == null) { serviceTestModelTO.Outputs = new List <IServiceTestOutput>(); } foreach (var dev2Definition in outputDefs) { if (dev2Definition.IsRecordSet) { ProcessRecordsetOutputs(serviceTestModelTO, dev2Definition); } else { if (serviceTestModelTO.Outputs.FirstOrDefault(output => output.Variable == dev2Definition.Name) == null) { serviceTestModelTO.Outputs.Add(new ServiceTestOutputTO { Variable = dev2Definition.Name, AssertOp = "=", Value = "" }); } } } for (int i = serviceTestModelTO.Outputs.Count - 1; i >= 0; i--) { var output = serviceTestModelTO.Outputs[i]; if (outputDefs.FirstOrDefault(definition => { if (definition.IsRecordSet) { var rec = DataListUtil.CreateRecordsetDisplayValue(definition.RecordSetName, definition.Name, ""); var inRec = DataListUtil.ReplaceRecordsetIndexWithBlank(output.Variable); return(rec == inRec); } return(definition.Name == output.Variable); }) == null) { serviceTestModelTO.Outputs.Remove(output); } } foreach (var serviceTestOutput in serviceTestModelTO.Outputs) { serviceTestOutput.Result = new TestRunResult { RunTestResult = RunResult.TestInvalid }; } serviceTestModelTO.Outputs.Sort((output, testOutput) => string.Compare(output.Variable, testOutput.Variable, StringComparison.InvariantCultureIgnoreCase)); } }
public List <IDebugItem> GetDebugInputs(IExecutionEnvironment env, IDev2LanguageParser parser) { IList <IDev2Definition> inputs = parser.Parse(InputMapping); var results = new List <IDebugItem>(); foreach (IDev2Definition dev2Definition in inputs) { if (string.IsNullOrEmpty(dev2Definition.RawValue)) { continue; } var tmpEntry = env.Eval(dev2Definition.RawValue); DebugItem itemToAdd = new DebugItem(); if (tmpEntry.IsWarewolfAtomResult) { var warewolfAtomResult = tmpEntry as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomResult; if (warewolfAtomResult != null) { var variableName = dev2Definition.Name; if (!string.IsNullOrEmpty(dev2Definition.RecordSetName)) { variableName = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, "1"); } AddDebugItem(new DebugItemWarewolfAtomResult(warewolfAtomResult.Item.ToString(), DataListUtil.AddBracketsToValueIfNotExist(variableName), ""), itemToAdd); } results.Add(itemToAdd); } else { var warewolfAtomListResult = tmpEntry as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult; if (warewolfAtomListResult != null) { var variableName = dev2Definition.Name; if (!string.IsNullOrEmpty(dev2Definition.RecordSetName)) { variableName = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, "*"); AddDebugItem(new DebugItemWarewolfAtomListResult(warewolfAtomListResult, "", "", DataListUtil.AddBracketsToValueIfNotExist(variableName), "", "", "="), itemToAdd); } else { var warewolfAtom = warewolfAtomListResult.Item.Last(); AddDebugItem(new DebugItemWarewolfAtomResult(warewolfAtom.ToString(), DataListUtil.AddBracketsToValueIfNotExist(variableName), ""), itemToAdd); } } results.Add(itemToAdd); } } foreach (IDebugItem debugInput in results) { debugInput.FlushStringBuilder(); } return(results); }
/// <summary> /// A new version of GetValue since Evaluate will now handle complex expressions it is now possible to create gnarly looking debug items /// This method handles these ;) /// </summary> /// <param name="dlEntry">The dl entry.</param> /// <param name="indexType">Type of the index.</param> /// <param name="results">The results.</param> /// <param name="initExpression">The init expression.</param> /// <param name="recordField">The record field.</param> /// <param name="index">The index.</param> /// <param name="labelText"></param> void NewGetValue(IBinaryDataListEntry dlEntry, enRecordsetIndexType indexType, IList <IDebugItemResult> results, string initExpression, IBinaryDataListItem recordField, int index, string labelText) { string injectVal = string.Empty; ComplexExpressionAuditor auditorObj = dlEntry.ComplexExpressionAuditor; if (indexType == enRecordsetIndexType.Star && auditorObj != null) { string instanceData; IList <ComplexExpressionAuditItem> auditData = auditorObj.FetchAuditItems(); if (index <= auditData.Count && index > 0) { ComplexExpressionAuditItem useData = auditData[index - 1]; instanceData = useData.TokenBinding; injectVal = useData.BoundValue; } else { string recsetName = DataListUtil.CreateRecordsetDisplayValue(dlEntry.Namespace, recordField.FieldName, index.ToString(CultureInfo.InvariantCulture)); instanceData = DataListUtil.AddBracketsToValueIfNotExist(recsetName); } results.Add(new DebugItemResult { Label = labelText, Type = DebugItemResultType.Variable, Value = injectVal, Operator = string.IsNullOrEmpty(instanceData) ? "" : "=", Variable = instanceData, GroupName = initExpression, GroupIndex = index }); } else { injectVal = recordField.TheValue; string displayValue = recordField.DisplayValue; if (displayValue.IndexOf(GlobalConstants.NullEntryNamespace, StringComparison.Ordinal) >= 0) { displayValue = DataListUtil.CreateRecordsetDisplayValue("Evaluated", GlobalConstants.EvaluationRsField, index.ToString(CultureInfo.InvariantCulture)); } results.Add(new DebugItemResult { Type = DebugItemResultType.Variable, Variable = DataListUtil.AddBracketsToValueIfNotExist(displayValue), Operator = string.IsNullOrEmpty(displayValue) ? "" : "=", GroupName = initExpression, Value = injectVal, GroupIndex = index }); } }
void LoadListFields(bool isFromListChange = false, System.Action continueWith = null) { if (!IsListSelected) { if (continueWith != null) { continueWith(); } return; } var selectedSharepointServer = SelectedSharepointServer; var selectedList = SelectedList; // ReSharper disable ImplicitlyCapturedClosure _asyncWorker.Start(() => GetListFields(selectedSharepointServer, selectedList), columnList => // ReSharper restore ImplicitlyCapturedClosure { if (columnList != null) { var fieldMappings = columnList.Select(mapping => { var recordsetDisplayValue = DataListUtil.CreateRecordsetDisplayValue(selectedList.FullName.Replace(" ", "").Replace(".", ""), GetValidVariableName(mapping), "*"); var sharepointReadListTo = new SharepointReadListTo(DataListUtil.AddBracketsToValueIfNotExist(recordsetDisplayValue), mapping.Name, mapping.InternalName, mapping.Type.ToString()) { IsRequired = mapping.IsRequired }; return(sharepointReadListTo); }).ToList(); if (ReadListItems == null || ReadListItems.Count == 0 || isFromListChange) { ReadListItems = fieldMappings; } else { foreach (var sharepointReadListTo in fieldMappings) { var listTo = sharepointReadListTo; var readListTo = ReadListItems.FirstOrDefault(to => to.FieldName == listTo.FieldName); if (readListTo == null) { ReadListItems.Add(sharepointReadListTo); } } } ListItems = ReadListItems; } if (continueWith != null) { continueWith(); } }); }
private void UpdateInputsForTest(IServiceTestModelTO serviceTestModelTO, IList <IDev2Definition> inputDefs) { if (inputDefs.Count == 0) { serviceTestModelTO.Inputs = new List <IServiceTestInput>(); } else { if (serviceTestModelTO.Inputs == null) { serviceTestModelTO.Inputs = new List <IServiceTestInput>(); } foreach (var dev2Definition in inputDefs) { if (dev2Definition.IsRecordSet) { ProcessRecordsetInputs(serviceTestModelTO, dev2Definition); } else { if (serviceTestModelTO.Inputs.FirstOrDefault(input => input.Variable == dev2Definition.Name) == null) { serviceTestModelTO.Inputs.Add(new ServiceTestInputTO { Variable = dev2Definition.Name, Value = "", EmptyIsNull = false }); } } } for (int i = serviceTestModelTO.Inputs.Count - 1; i >= 0; i--) { var input = serviceTestModelTO.Inputs[i]; if (inputDefs.FirstOrDefault(definition => { if (definition.IsRecordSet) { var rec = DataListUtil.CreateRecordsetDisplayValue(definition.RecordSetName, definition.Name, ""); var inRec = DataListUtil.ReplaceRecordsetIndexWithBlank(input.Variable); return(rec == inRec); } return(definition.Name == input.Variable); }) == null) { serviceTestModelTO.Inputs.Remove(input); } } serviceTestModelTO.Inputs.Sort((input, testInput) => string.Compare(input.Variable, testInput.Variable, StringComparison.InvariantCultureIgnoreCase)); } }
private void AddWarewolfAtomResults(List <IDebugItem> results, IDev2Definition dev2Definition, CommonFunctions.WarewolfEvalResult tmpEntry, DebugItem itemToAdd) { if (tmpEntry is CommonFunctions.WarewolfEvalResult.WarewolfAtomResult warewolfAtomResult) { var variableName = dev2Definition.Name; if (!string.IsNullOrEmpty(dev2Definition.RecordSetName)) { variableName = DataListUtil.CreateRecordsetDisplayValue(dev2Definition.RecordSetName, dev2Definition.Name, "1"); } AddDebugItem(new DebugItemWarewolfAtomResult(warewolfAtomResult.Item.ToString(), DataListUtil.AddBracketsToValueIfNotExist(variableName), ""), itemToAdd); } results.Add(itemToAdd); }
private void AddAllFolders(IList <OutputTO> outputs, SharepointSource sharepointSource, string path, string recsetName, string fieldName) { var folders = GetSharePointFolders(sharepointSource, path); var indexToUpsertTo = 1; foreach (var folder in folders) { var fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName, indexToUpsertTo.ToString(CultureInfo.InvariantCulture)); outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), folder)); indexToUpsertTo++; } }
void OldGetValue(IBinaryDataListEntry dlEntry, string value, int iterCnt, string fieldName, enRecordsetIndexType indexType, IList <IDebugItemResult> results, string initExpression, IBinaryDataListItem recordField, int index, string labelText) { if ((string.IsNullOrEmpty(fieldName) || recordField.FieldName.Equals(fieldName, StringComparison.InvariantCultureIgnoreCase))) { string injectVal; try { injectVal = recordField.TheValue; } catch (Exception) { injectVal = ""; } if (!string.IsNullOrEmpty(value) && recordField.ItemCollectionIndex == (iterCnt + 1)) { injectVal = value; _rsCachedValues[recordField.DisplayValue] = injectVal; } else if (string.IsNullOrEmpty(injectVal) && recordField.ItemCollectionIndex != (iterCnt + 1)) { // is it in the cache? ;) _rsCachedValues.TryGetValue(recordField.DisplayValue, out injectVal); if (injectVal == null) { injectVal = string.Empty; } } string recsetName; if (indexType == enRecordsetIndexType.Star) { recsetName = DataListUtil.CreateRecordsetDisplayValue(dlEntry.Namespace, recordField.FieldName, index.ToString(CultureInfo.InvariantCulture)); recsetName = DataListUtil.AddBracketsToValueIfNotExist(recsetName); } else { recsetName = DataListUtil.AddBracketsToValueIfNotExist(recordField.DisplayValue); } results.Add(new DebugItemResult { Label = labelText, Type = DebugItemResultType.Variable, Variable = recsetName, Operator = string.IsNullOrEmpty(recsetName) ? "" : "=", Value = injectVal, GroupName = initExpression, GroupIndex = index }); } }
private void RecordsetGroupName(ref int grpIdx, ref string displayExpression, string rawExpression, ref string groupName) { grpIdx++; groupName = rawExpression; var dataLanguageParser = new Dev2DataLanguageParser(); var vals = dataLanguageParser.ParseForActivityDataItems(_assignedToVariableName); if (vals != null) { foreach (var val in vals) { var repVal = DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(val), DataListUtil.ExtractFieldNameFromValue(val), grpIdx.ToString()); displayExpression = _assignedToVariableName.Replace(val, repVal); } } }
private void AddTableToDataList(Table table) { // build up DataTable foreach (TableRow row in table.Rows) { var i = 0; foreach (string columnName in table.Header) { var recordsetDisplayValue = DataListUtil.CreateRecordsetDisplayValue("rs", columnName, ""); var assignValue = new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(recordsetDisplayValue), row[i]); DataObject.Environment.AssignWithFrame(assignValue, 0); i++; } DataObject.Environment.CommitAssign(); } // Execute Translator }
private void SetInputAttributesContainingColumnIoDirection(IList <XElement> enumerable) { Inputs.AddRange(enumerable.Elements() .Select(element => { var xAttribute = element.Attributes("ColumnIODirection").FirstOrDefault(); var include = xAttribute != null && (xAttribute.Value == enDev2ColumnArgumentDirection.Input.ToString() || xAttribute.Value == enDev2ColumnArgumentDirection.Both.ToString()); if (include && element.Parent != null) { return(DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*"))); } return(""); }) .Where(o => !string.IsNullOrEmpty(o))); }
static void UpdateInputsForTest(IServiceTestModelTO serviceTestModelTO, IList <IDev2Definition> inputDefs, int i) { var input = serviceTestModelTO.Inputs[i]; if (inputDefs.FirstOrDefault(definition => { if (definition.IsRecordSet) { var rec = DataListUtil.CreateRecordsetDisplayValue(definition.RecordSetName, definition.Name, ""); var inRec = DataListUtil.ReplaceRecordsetIndexWithBlank(input.Variable); return(rec == inRec); } return(definition.Name == input.Variable); }) == null) { serviceTestModelTO.Inputs.Remove(input); } }
void ExecuteForListOfDir(IList <IActivityIOPath> listOfDir, IList <OutputTO> outputs) { var recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result); var fieldName = DataListUtil.ExtractFieldNameFromValue(Result); var indexToUpsertTo = 1; if (listOfDir != null) { foreach (IActivityIOPath pa in listOfDir) { var fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName, indexToUpsertTo.ToString(CultureInfo.InvariantCulture)); outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), pa.Path)); indexToUpsertTo++; } } }
private string GetObjectDisplayExpression(int grpIdx) { string displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(_variable), DataListUtil.ExtractFieldNameOnlyFromValue(DataListUtil.AddBracketsToValueIfNotExist(_variable)), grpIdx.ToString())); if (DataListUtil.GetRecordsetIndexType(_variable) == enRecordsetIndexType.Star) { displayExpression += _variable.Replace(DataListUtil.ReplaceRecordsetIndexWithStar(displayExpression), ""); } else { if (DataListUtil.GetRecordsetIndexType(_variable) == enRecordsetIndexType.Blank) { displayExpression += _variable.Replace(DataListUtil.ReplaceRecordsetIndexWithBlank(displayExpression), ""); } } return(displayExpression); }
void Map(XElement rootEl) { if (rootEl == null) { return; } Inputs.AddRange(rootEl.Elements().Where(element => !element.HasElements).Select(element => element.Name.ToString())); var xElements = rootEl.Elements().Where(el => el.HasElements); var enumerable = xElements as IList<XElement> ?? xElements.ToList(); Inputs.AddRange(enumerable.Elements().Select(element => { if (element.Parent != null) { return DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(element.Parent.Name.ToString(), element.Name.ToString(), "*")); } return ""; })); }
private void ExecuteConcreteAction(IList <OutputTO> outputs, WarewolfListIterator colItr, SharepointSource sharepointSource, WarewolfIterator serverInputFromItr, WarewolfIterator serverInputFromTo) { var serverPath = colItr.FetchNextValue(serverInputFromItr); var localPath = colItr.FetchNextValue(serverInputFromTo); if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric) { if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star) { var recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result); var fieldName = DataListUtil.ExtractFieldNameFromValue(Result); var newPath = CopyFile(sharepointSource, serverPath, localPath); var indexToUpsertTo = 1; foreach (var file in newPath) { var fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName, indexToUpsertTo.ToString(CultureInfo.InvariantCulture)); outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), file)); indexToUpsertTo++; } } else { if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank) { AddOutputsForBlankIndex(outputs, sharepointSource, serverPath, localPath); } } } else { var newPath = CopyFile(sharepointSource, serverPath, localPath); var xmlList = string.Join(",", newPath.Select(c => c)); outputs.Add(DataListFactory.CreateOutputTO(Result)); outputs.Last().OutputStrings.Add(xmlList); } }
public bool GetRecordSetFieldValueFromDataList(IExecutionEnvironment environment, string recordSet, string fieldNameToRetrieve, out IList <string> result, out string error) { bool isCool = true; var variableName = recordSet; result = new List <string>(); error = ""; try { if (!string.IsNullOrEmpty(fieldNameToRetrieve)) { variableName = DataListUtil.CreateRecordsetDisplayValue(recordSet, fieldNameToRetrieve, "*"); } var warewolfEvalResult = environment.Eval(DataListUtil.AddBracketsToValueIfNotExist(variableName)); if (warewolfEvalResult == null) { return(false); } var listResult = warewolfEvalResult as WarewolfDataEvaluationCommon.WarewolfEvalResult.WarewolfAtomListresult; if (listResult != null) { foreach (var res in listResult.Item) { result.Add(ExecutionEnvironment.WarewolfAtomToString(res)); } } } catch (Exception e) { error = e.Message; } if (!string.IsNullOrEmpty(error)) { isCool = false; } return(isCool); }
private IEnumerable <string> RefreshRecordSets(IEnumerable <IRecordSetItemModel> toList, IList <string> accList) { foreach (var dataListItemModel in toList) { if (!string.IsNullOrEmpty(dataListItemModel.DisplayName)) { var recsetAppend = DataListUtil.MakeValueIntoHighLevelRecordset(dataListItemModel.DisplayName); var recsetStar = DataListUtil.MakeValueIntoHighLevelRecordset(dataListItemModel.DisplayName, true); accList.Add(DataListUtil.AddBracketsToValueIfNotExist(recsetAppend)); accList.Add(DataListUtil.AddBracketsToValueIfNotExist(recsetStar)); } foreach (var listItemModel in dataListItemModel.Children) { if (!string.IsNullOrEmpty(listItemModel.Name)) { var rec = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(dataListItemModel.DisplayName, listItemModel.DisplayName, "")); if (ExecutionEnvironment.IsRecordsetIdentifier(rec)) { accList.Add(DataListUtil.ReplaceRecordBlankWithStar(rec)); accList.Add(rec); } } } foreach (var listItemModel in ScalarCollection) { if (!string.IsNullOrEmpty(listItemModel.DisplayName)) { var rec = "[[" + listItemModel.DisplayName + "]]"; if (ExecutionEnvironment.IsScalar(rec)) { accList.Add(rec); } } } } return(accList); }
void UpdateMappedToValue(string newRecordsetName) { if (!string.IsNullOrEmpty(_recordSetName) && !string.IsNullOrEmpty(_mappedTo) && DataListUtil.IsValueRecordsetWithFields(_mappedTo)) { var recSetName = DataListUtil.ExtractRecordsetNameFromValue(_mappedTo); var fieldName = DataListUtil.ExtractFieldNameOnlyFromValue(_mappedTo); if (string.Equals(recSetName, _recordSetName, StringComparison.OrdinalIgnoreCase) && !string.Equals(recSetName, newRecordsetName, StringComparison.OrdinalIgnoreCase)) { MappedTo = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(newRecordsetName, fieldName, "")); } if (string.IsNullOrEmpty(newRecordsetName) && string.IsNullOrEmpty(DataListUtil.ExtractRecordsetNameFromValue(_mappedTo))) { MappedTo = DataListUtil.AddBracketsToValueIfNotExist(fieldName); } } else { if (string.IsNullOrEmpty(_recordSetName) && !string.IsNullOrEmpty(newRecordsetName) && !string.IsNullOrEmpty(_mappedTo) && !DataListUtil.IsValueRecordsetWithFields(_mappedTo)) { var varName = DataListUtil.RemoveLanguageBrackets(_mappedTo); MappedTo = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(newRecordsetName, varName, "")); } } }
void TranslateDataTableToEnvironment(DataTable executeService, IExecutionEnvironment environment) { if (executeService != null && InstanceOutputDefintions != null) { var defs = DataListFactory.CreateOutputParser().Parse(InstanceOutputDefintions); HashSet <string> processedRecNames = new HashSet <string>(); IDictionary <int, string> colMapping = BuildColumnNameToIndexMap(executeService.Columns, defs); foreach (var def in defs) { var expression = def.Value; var rs = def.RawValue; var rsName = DataListUtil.ExtractRecordsetNameFromValue(expression); var rsType = DataListUtil.GetRecordsetIndexType(expression); var rowIndex = DataListUtil.ExtractIndexRegionFromRecordset(expression); var rsNameUse = def.RecordSetName; environment.AssignDataShape(def.RawValue); if (DataListUtil.IsValueRecordset(rs)) { if (string.IsNullOrEmpty(rsName)) { rsName = rsNameUse; } if (string.IsNullOrEmpty(rsName)) { rsName = def.Name; } if (processedRecNames.Contains(rsName)) { continue; } processedRecNames.Add(rsName); // now convert to binary datalist ;) int rowIdx = 1; if (environment.HasRecordSet(rs)) { rowIdx = environment.GetLength(rs); } if (rsType == enRecordsetIndexType.Star) { rowIdx = 1; } if (rsType == enRecordsetIndexType.Numeric) { rowIdx = int.Parse(rowIndex); } if (executeService.Rows != null) { foreach (DataRow row in executeService.Rows) { // build up the row int idx = 0; foreach (var item in row.ItemArray) { string colName; if (colMapping.TryGetValue(idx, out colName)) { var displayExpression = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(def.Value), colName, rowIdx.ToString())); environment.Assign(displayExpression, item.ToString(), 0); } idx++; } rowIdx++; } } } else { // handle a scalar coming out ;) if (executeService.Rows != null && executeService.Rows.Count == 1) { var row = executeService.Rows[0].ItemArray; // Look up the correct index from the columns ;) int pos = 0; var cols = executeService.Columns; int idx = -1; while (pos < cols.Count && idx == -1) { if (colMapping[pos] == expression) { idx = pos; } pos++; } environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(expression), row[idx].ToString(), 0); } } } } }
protected override IList <OutputTO> ExecuteConcreteAction(IDSFDataObject dataObject, out ErrorResultTO allErrors, int update) { IsNotCertVerifiable = true; allErrors = new ErrorResultTO(); IList <OutputTO> outputs = new List <OutputTO>(); var colItr = new WarewolfListIterator(); //get all the possible paths for all the string variables var inputItr = new WarewolfIterator(dataObject.Environment.Eval(InputPath, update)); colItr.AddVariableToIterateOn(inputItr); var unameItr = new WarewolfIterator(dataObject.Environment.Eval(Username, update)); colItr.AddVariableToIterateOn(unameItr); var passItr = new WarewolfIterator(dataObject.Environment.Eval(DecryptedPassword, update)); colItr.AddVariableToIterateOn(passItr); if (dataObject.IsDebugMode()) { AddDebugInputItem(InputPath, "Input Path", dataObject.Environment, update); AddDebugInputItem(new DebugItemStaticDataParams(GetReadType().GetDescription(), "Read")); AddDebugInputItemUserNamePassword(dataObject.Environment, update); } while (colItr.HasMoreData()) { IActivityOperationsBroker broker = ActivityIOFactory.CreateOperationsBroker(); IActivityIOPath ioPath = ActivityIOFactory.CreatePathFromString(colItr.FetchNextValue(inputItr), colItr.FetchNextValue(unameItr), colItr.FetchNextValue(passItr), true); IActivityIOOperationsEndPoint endPoint = ActivityIOFactory.CreateOperationEndPointFromIOPath(ioPath); try { IList <IActivityIOPath> listOfDir = broker.ListDirectory(endPoint, GetReadType()); if (DataListUtil.IsValueRecordset(Result) && DataListUtil.GetRecordsetIndexType(Result) != enRecordsetIndexType.Numeric) { if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Star) { string recsetName = DataListUtil.ExtractRecordsetNameFromValue(Result); string fieldName = DataListUtil.ExtractFieldNameFromValue(Result); int indexToUpsertTo = 1; if (listOfDir != null) { foreach (IActivityIOPath pa in listOfDir) { string fullRecsetName = DataListUtil.CreateRecordsetDisplayValue(recsetName, fieldName, indexToUpsertTo.ToString(CultureInfo.InvariantCulture)); outputs.Add(DataListFactory.CreateOutputTO(DataListUtil.AddBracketsToValueIfNotExist(fullRecsetName), pa.Path)); indexToUpsertTo++; } } } else if (DataListUtil.GetRecordsetIndexType(Result) == enRecordsetIndexType.Blank) { if (listOfDir != null) { foreach (IActivityIOPath pa in listOfDir) { outputs.Add(DataListFactory.CreateOutputTO(Result, pa.Path)); } } } } else { if (listOfDir != null) { string xmlList = string.Join(",", listOfDir.Select(c => c.Path)); outputs.Add(DataListFactory.CreateOutputTO(Result)); outputs.Last().OutputStrings.Add(xmlList); } } } catch (Exception e) { outputs.Add(DataListFactory.CreateOutputTO(null)); allErrors.AddError(e.Message); break; } } return(outputs); }
protected override void ExecuteTool(IDSFDataObject dataObject, int update) { IDev2IndexFinder indexFinder = new Dev2IndexFinder(); ErrorResultTO allErrors = new ErrorResultTO(); ErrorResultTO errors = new ErrorResultTO(); InitializeDebug(dataObject); try { var outerIteratorCollection = new WarewolfListIterator(); var innerIteratorCollection = new WarewolfListIterator(); allErrors.MergeErrors(errors); #region Iterate and Find Index if (dataObject.IsDebugMode()) { AddDebugInputItem(new DebugEvalResult(InField, "In Field", dataObject.Environment, update)); AddDebugInputItem(new DebugItemStaticDataParams(Index, "Index")); AddDebugInputItem(new DebugEvalResult(Characters, "Characters", dataObject.Environment, update)); AddDebugInputItem(new DebugItemStaticDataParams(Direction, "Direction")); } var itrChar = new WarewolfIterator(dataObject.Environment.Eval(Characters, update)); outerIteratorCollection.AddVariableToIterateOn(itrChar); var completeResultList = new List <string>(); if (String.IsNullOrEmpty(InField)) { allErrors.AddError("'In Field' is blank"); } else if (String.IsNullOrEmpty(Characters)) { allErrors.AddError("'Characters' is blank"); } else { while (outerIteratorCollection.HasMoreData()) { allErrors.MergeErrors(errors); errors.ClearErrors(); var itrInField = new WarewolfIterator(dataObject.Environment.Eval(InField, update)); innerIteratorCollection.AddVariableToIterateOn(itrInField); string chars = outerIteratorCollection.FetchNextValue(itrChar); while (innerIteratorCollection.HasMoreData()) { if (!string.IsNullOrEmpty(InField) && !string.IsNullOrEmpty(Characters)) { var val = innerIteratorCollection.FetchNextValue(itrInField); if (val != null) { IEnumerable <int> returedData = indexFinder.FindIndex(val, Index, chars, Direction, MatchCase, StartIndex); completeResultList.AddRange(returedData.Select(value => value.ToString(CultureInfo.InvariantCulture)).ToList()); //2013.06.03: Ashley Lewis for bug 9498 - handle multiple regions in result } } } } var rule = new IsSingleValueRule(() => Result); var single = rule.Check(); if (single != null) { allErrors.AddError(single.Message); } else { if (DataListUtil.IsValueRecordset(Result)) { var rsType = DataListUtil.GetRecordsetIndexType(Result); if (rsType == enRecordsetIndexType.Numeric) { dataObject.Environment.Assign(Result, string.Join(",", completeResultList), update); allErrors.MergeErrors(errors); } else { var idx = 1; foreach (var res in completeResultList) { if (rsType == enRecordsetIndexType.Blank) { dataObject.Environment.Assign(Result, res, update); } if (rsType == enRecordsetIndexType.Star) { var expression = DataListUtil.CreateRecordsetDisplayValue(DataListUtil.ExtractRecordsetNameFromValue(Result), DataListUtil.ExtractFieldNameFromValue(Result), idx.ToString()); dataObject.Environment.Assign(DataListUtil.AddBracketsToValueIfNotExist(expression), res, update); idx++; } } } } else { dataObject.Environment.Assign(Result, string.Join(",", completeResultList), update); } allErrors.MergeErrors(errors); if (!allErrors.HasErrors() && dataObject.IsDebugMode()) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } } } #endregion } catch (Exception e) { Dev2Logger.Log.Error("DSFFindActivity", e); allErrors.AddError(e.Message); } finally { #region Handle Errors var hasErrors = allErrors.HasErrors(); if (hasErrors) { DisplayAndWriteError("DsfIndexActivity", allErrors); var errorString = allErrors.MakeDisplayReady(); dataObject.Environment.AddError(errorString); } #endregion if (dataObject.IsDebugMode()) { if (hasErrors) { AddDebugOutputItem(new DebugEvalResult(Result, "", dataObject.Environment, update)); } DispatchDebugState(dataObject, StateType.Before, update); DispatchDebugState(dataObject, StateType.After, update); } } }