public void NoResultVariableInAnyRow_Expected_Still_Split_But_Dont_Insert_Any() { IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); _resultsCollection.Add(new DataSplitDTO("", "Index", "15", 1)); _resultsCollection.Add(new DataSplitDTO("", "Index", "15", 2)); SetupArguments("<root></root>", ActivityStrings.DataSplit_preDataList, _source, _resultsCollection); IDSFDataObject result = ExecuteProcess(); List <bool> isPopulated = new List <bool>(); ErrorResultTO errors; IBinaryDataList dList = compiler.FetchBinaryDataList(result.DataListID, out errors); foreach (string data in dList.FetchAllUserKeys()) { IBinaryDataListEntry entry; string error; dList.TryGetEntry(data, out entry, out error); isPopulated.Add(entry.FetchAppendRecordsetIndex() != 1); } // remove test datalist ;) DataListRemoval(result.DataListID); CollectionAssert.DoesNotContain(isPopulated, true); }
/// <summary> /// Converts the and filter. /// </summary> /// <param name="payload">The payload.</param> /// <param name="filterShape">The filter shape.</param> /// <param name="errors">The errors.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">payload</exception> public StringBuilder ConvertAndFilter(IBinaryDataList payload, StringBuilder filterShape, out ErrorResultTO errors) { if (payload == null) { throw new ArgumentNullException("payload"); } int keyCnt = 0; errors = new ErrorResultTO(); TranslatorUtils tu = new TranslatorUtils(); ErrorResultTO invokeErrors; IBinaryDataList targetDl = tu.TranslateShapeToObject(filterShape, false, out invokeErrors); errors.MergeErrors(invokeErrors); IList <string> itemKeys = targetDl.FetchAllUserKeys(); StringBuilder result = new StringBuilder("{"); foreach (string key in itemKeys) { IBinaryDataListEntry entry; IBinaryDataListEntry tmpEntry; string error; if (payload.TryGetEntry(key, out entry, out error) && targetDl.TryGetEntry(key, out tmpEntry, out error)) { if (entry.IsRecordset) { result.Append(ProcessRecordSet(entry, out error)); errors.AddError(error); } else { result.Append(ProcessScalar(entry)); } // wack in , for field separator ;) keyCnt++; if (keyCnt < itemKeys.Count) { result.Append(","); } } errors.AddError(error); } result.Append("}"); return(result); }
/// <summary> /// Converts from a binary representation in the standard format to the specified <see cref="Format" />. /// </summary> /// <param name="input">The binary representation of the datalist.</param> /// <param name="errors">The errors.</param> /// <returns> /// An array of bytes that represent the datalist in the specified <see cref="Format" /> /// </returns> /// <exception cref="System.ArgumentNullException">input</exception> public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList input, out ErrorResultTO errors) { errors = new ErrorResultTO(); if (input == null) { throw new ArgumentNullException("input"); } IList <string> itemKeys = input.FetchAllUserKeys(); errors = new ErrorResultTO(); StringBuilder result = new StringBuilder("{"); int keyCnt = 0; foreach (string key in itemKeys) { IBinaryDataListEntry entry; // This check was never here - this means this method has no testing and was never sane ;) string error; if (input.TryGetEntry(key, out entry, out error)) { if (entry.IsRecordset) { result.Append(ProcessRecordSet(entry, out error)); errors.AddError(error); } else { result.Append(ProcessScalar(entry)); } } errors.AddError(error); // wack in , for field separator ;) keyCnt++; if (keyCnt < itemKeys.Count) { result.Append(","); } } result.Append("}"); DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString()); return(tmp); }
/// <summary> /// Converts from a binary representation in the standard format to the specified <see cref="Format" />. /// </summary> /// <param name="input">The binary representation of the datalist.</param> /// <param name="errors">The errors.</param> /// <returns> /// An array of bytes that represent the datalist in the specified <see cref="Format" /> /// </returns> /// <exception cref="System.ArgumentNullException">input</exception> public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList input, out ErrorResultTO errors) { errors = new ErrorResultTO(); if(input == null) throw new ArgumentNullException("input"); IList<string> itemKeys = input.FetchAllUserKeys(); errors = new ErrorResultTO(); StringBuilder result = new StringBuilder("{"); int keyCnt = 0; foreach(string key in itemKeys) { IBinaryDataListEntry entry; // This check was never here - this means this method has no testing and was never sane ;) string error; if(input.TryGetEntry(key, out entry, out error)) { if(entry.IsRecordset) { result.Append(ProcessRecordSet(entry, out error)); errors.AddError(error); } else { result.Append(ProcessScalar(entry)); } } errors.AddError(error); // wack in , for field separator ;) keyCnt++; if(keyCnt < itemKeys.Count) { result.Append(","); } } result.Append("}"); DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString()); return tmp; }
public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors) { if(payload == null) { throw new ArgumentNullException("payload"); } TranslatorUtils tu = new TranslatorUtils(); StringBuilder result = new StringBuilder("<" + RootTag + ">"); errors = new ErrorResultTO(); IList<string> itemKeys = payload.FetchAllUserKeys(); foreach(string key in itemKeys) { IBinaryDataListEntry entry; string error; if(payload.TryGetEntry(key, out entry, out error)) { if(entry.IsRecordset && !entry.IsEmpty()) { var idxItr = entry.FetchRecordsetIndexes(); while(idxItr.HasMore()) { var i = idxItr.FetchNextIndex(); IList<IBinaryDataListItem> rowData = entry.FetchRecordAt(i, out error); errors.AddError(error); result.Append("<"); result.Append(entry.Namespace); result.Append(">"); foreach(IBinaryDataListItem col in rowData) { string fName = col.FieldName; result.Append("<"); result.Append(fName); result.Append(">"); try { result.Append(tu.FullCleanForEmit(col.TheValue)); } // ReSharper disable EmptyGeneralCatchClause catch(Exception) // ReSharper restore EmptyGeneralCatchClause { } result.Append("</"); result.Append(fName); result.Append(">"); } result.Append("</"); result.Append(entry.Namespace); result.Append(">"); } } else if(!entry.IsRecordset) { string fName = entry.Namespace; IBinaryDataListItem val = entry.FetchScalar(); if(val != null) { result.Append("<"); result.Append(fName); result.Append(">"); try { result.Append(tu.FullCleanForEmit(val.TheValue)); } // ReSharper disable EmptyGeneralCatchClause catch(Exception) // ReSharper restore EmptyGeneralCatchClause { } result.Append("</"); result.Append(fName); result.Append(">"); } } } } result.Append("</" + RootTag + ">"); DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString()); return tmp; }