public void UpsertBuilder_AssignStyleAppend_Expect_10RecordSetEntries_And_Scalar()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();
            string error;

            tmp.Add("[[scalar]]", "myScalar");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset().f1]]", "field1_value1a");
            tmp.Add("[[recset().f2]]", "field2_value1a");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset(10).f1]]", "field1_value2a");
            tmp.Add("[[recset(10).f2]]", "field2_value2a");

            ErrorResultTO errors;
            Guid          id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), _adlData.ToStringBuilder(), new StringBuilder(_dlShape), out errors);


            _compiler.Upsert(id, tmp, out errors);
            IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors);

            // Else we good to go, normal asserts ;)
            IBinaryDataListEntry recset;

            bdl.TryGetEntry("recset", out recset, out error);
            IBinaryDataListEntry scalar;

            bdl.TryGetEntry("scalar", out scalar, out error);

            var res1 = scalar.FetchScalar().TheValue;
            var res2 = recset.FetchLastRecordsetIndex();

            // we have a single scalar
            Assert.AreEqual("myScalar", res1);
            Assert.AreEqual(10, res2);
        }
        public void GreaterThan_WithTextInMatchField_Expected_NoResults()
        {
            TestStartNode = new FlowStep
            {
                Action = new DsfFindRecordsActivity
                {
                    FieldsToSearch = "[[Recset().Field1]],[[Recset().Field2]],[[Recset().Field3]]",
                    SearchCriteria = "jimmy",
                    SearchType     = ">",
                    StartIndex     = "",
                    Result         = "[[Result().res]]"
                }
            };

            CurrentDl = "<DL><Recset><Field1/><Field2/><Field3/></Recset><Result><res/></Result></DL>";
            TestData  = "<root>" + ActivityStrings.FindRecords_PreDataList + "</root>";
            IDSFDataObject result = ExecuteProcess();

            string error;
            IBinaryDataListEntry entry;
            ErrorResultTO        errors;
            IBinaryDataList      bdl = Compiler.FetchBinaryDataList(result.DataListID, out errors);

            bdl.TryGetEntry("Result", out entry, out error);

            var res = entry.ItemCollectionSize();

            // remove test datalist ;)
            DataListRemoval(result.DataListID);

            Assert.AreEqual(1, res);
        }
示例#3
0
        public void SerializeToXML_ValidXML_Expect_Sucess()
        {
            ErrorResultTO       errors;
            string              error;
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);

            byte[]          data = (TestHelper.ConvertStringToByteArray(DataListWellformedData));
            IBinaryDataList obj  = xmlConverter.ConvertTo(data, _dataListWellformed, out errors);

            IBinaryDataListEntry entry;

            if (obj.TryGetEntry("rs1", out entry, out error))
            {
                IList <IBinaryDataListItem> cols = entry.FetchRecordAt(1, out error);
                int systemTagCount = Enum.GetValues(typeof(enSystemTag)).Length;

                var res1 = obj.FetchAllEntries().Count;
                var res2 = obj.FetchScalarEntries().Count;
                var res3 = obj.FetchRecordsetEntries().Count;
                var res4 = cols.Count;

                Assert.AreEqual(3 + systemTagCount, res1);
                Assert.AreEqual(2 + systemTagCount, res2);
                Assert.AreEqual(1, res3);
                Assert.AreEqual(2, res4);
            }
            else
            {
                Assert.Fail("Error");
            }
        }
        public void UpsertBuilder_AssignStyleAppend_Expect_Scalar_WithLastRecord()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder();

            tmp.Add("[[recset().f1]]", "field1_value1a");
            tmp.Add("[[recset().f2]]", "field2_value1a");
            tmp.FlushIterationFrame();
            tmp.Add("[[scalar]]", "[[recset(*).f1]]");
            tmp.FlushIterationFrame();

            ErrorResultTO errors;
            Guid          id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), _adlData.ToStringBuilder(), new StringBuilder(_dlShape), out errors);

            _compiler.Upsert(id, tmp, out errors);
            IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors);


            IBinaryDataListEntry scalar;
            string error;

            bdl.TryGetEntry("scalar", out scalar, out error);

            var res = scalar.FetchScalar().TheValue;

            // we have a single scalar
            Assert.AreEqual("field1_value1a", res);
        }
        public void TryFetchLastIndexedRecordsetUpsertPayload_ColumnName_FetchesForColumn()
        {
            //------------Setup for test--------------------------
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            IDev2DataListUpsertPayloadBuilder <List <string> > toUpsert = Dev2DataListBuilderFactory.CreateStringListDataListUpsertBuilder();

            toUpsert.Add("[[rec().f1]]", new List <string> {
                "test11", "test12"
            });
            toUpsert.Add("[[rec().f2]]", new List <string> {
                "test21", "test22"
            });
            IBinaryDataList dataList = Dev2BinaryDataListFactory.CreateDataList();
            string          creationError;

            dataList.TryCreateRecordsetTemplate("rec", "recset", new List <Dev2Column> {
                DataListFactory.CreateDev2Column("f1", "f1"), DataListFactory.CreateDev2Column("f2", "f2")
            }, true, out creationError);
            ErrorResultTO localErrors;

            compiler.PushBinaryDataList(dataList.UID, dataList, out localErrors);
            compiler.Upsert(dataList.UID, toUpsert, out _errors);
            IBinaryDataListEntry recEntry;
            string error;

            dataList.TryGetEntry("rec", out recEntry, out error);
            //------------Assert Preconditions-------------------
            Assert.IsNotNull(recEntry);
            //------------Execute Test---------------------------
            var listItem = recEntry.TryFetchLastIndexedRecordsetUpsertPayload(out error, "f2");

            //------------Assert Results-------------------------
            Assert.AreEqual("test22", listItem.TheValue);
        }
示例#6
0
        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);
        }
示例#7
0
        private int FetchNumberOfExecutions(IIntellisenseResult part, IBinaryDataList bdl)
        {
            int result = 1;

            if (!part.Option.IsScalar)
            {
                // process the recordset...
                enRecordsetIndexType type = DataListUtil.GetRecordsetIndexType(part.Option.DisplayValue);
                if (type == enRecordsetIndexType.Star)
                {
                    // Fetch entry and find the last index
                    IBinaryDataListEntry entry;
                    string error;
                    if (bdl.TryGetEntry(part.Option.Recordset, out entry, out error))
                    {
                        result = entry.FetchLastRecordsetIndex();
                    }
                }
                else if (type == enRecordsetIndexType.Numeric)
                {
                    // Fetch index out
                    Int32.TryParse(part.Option.RecordsetIndex, out result);
                }
            }

            return(result);
        }
        public void UpsertBuilder_AssignStyleAppend_Expect_2RecordSetEntries_And_Scalar_AsDebug()
        {
            IDev2DataListUpsertPayloadBuilder <string> tmp = Dev2DataListBuilderFactory.CreateStringDataListUpsertBuilder(true);

            tmp.IsDebug = true;
            tmp.Add("[[scalar]]", "myScalar");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset().f1]]", "field1_value1");
            tmp.Add("[[recset().f2]]", "field2_value1");
            tmp.FlushIterationFrame();
            tmp.Add("[[recset().f1]]", "field1_value2");
            tmp.Add("[[recset().f2]]", "field2_value2");

            ErrorResultTO errors;
            Guid          id = _compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), string.Empty.ToStringBuilder(), new StringBuilder(_dlShape), out errors);

            _compiler.Upsert(id, tmp, out errors);
            IBinaryDataList bdl = _compiler.FetchBinaryDataList(id, out errors);

            // Else we good to go, normal asserts ;)
            IBinaryDataListEntry recset;
            string error;

            bdl.TryGetEntry("recset", out recset, out error);

            IBinaryDataListEntry scalar;

            bdl.TryGetEntry("scalar", out scalar, out error);

            var res1 = scalar.FetchScalar().TheValue;
            var res2 = recset.FetchLastRecordsetIndex();

            // we have a single scalar
            Assert.AreEqual("myScalar", res1);
            Assert.AreEqual(2, res2);

            Assert.IsNotNull(tmp.DebugOutputs);
            Assert.IsNotNull(tmp.DebugOutputs[0].LeftEntry);
            Assert.IsNotNull(tmp.DebugOutputs[0].RightEntry);
            Assert.IsNotNull(tmp.DebugOutputs[0].TargetEntry);
            Assert.IsNotNull(tmp.DebugOutputs[0].RightEntry.ComplexExpressionAuditor);
            Assert.IsNotNull(tmp.DebugOutputs[0].LeftEntry.ComplexExpressionAuditor);
            Assert.IsNotNull(tmp.DebugOutputs[0].TargetEntry.ComplexExpressionAuditor);
            Assert.AreEqual(1, tmp.DebugOutputs[0].RightEntry.ComplexExpressionAuditor.FetchAuditItems().Count);
            Assert.AreEqual(1, tmp.DebugOutputs[0].LeftEntry.ComplexExpressionAuditor.FetchAuditItems().Count);
            Assert.AreEqual(5, tmp.DebugOutputs[0].TargetEntry.ComplexExpressionAuditor.FetchAuditItems().Count);
        }
 public DataTable ConvertToDataTable(IBinaryDataList input, string recsetName, out ErrorResultTO errors, PopulateOptions populateOptions)
 {
     if(String.IsNullOrEmpty(recsetName))
     {
         throw new ArgumentNullException("recsetName");
     }
     if(input == null)
     {
         throw new ArgumentNullException("input");
     }
     var dbData = new DataTable();
     IBinaryDataListEntry entry;
     errors = null;
     string error;
     if(input.TryGetEntry(recsetName, out entry, out error))
     {
         if(entry.IsRecordset)
         {
             var cols = entry.Columns;
             var dataColumns = cols.ToList().ConvertAll(column => new DataColumn(column.ColumnName));
             dbData.Columns.AddRange(dataColumns.ToArray());
             var fetchRecordsetIndexes = entry.FetchRecordsetIndexes();
             while(fetchRecordsetIndexes.HasMore())
             {
                 var binaryDataListItems = entry.FetchRowAt(fetchRecordsetIndexes.FetchNextIndex(), out error);
                 if(populateOptions == PopulateOptions.IgnoreBlankRows && binaryDataListItems.All(item =>
                 {
                     string theValue;
                     try
                     {
                         theValue = item.TheValue;
                     }
                     catch(Exception)
                     {
                         theValue = null;
                     }
                     return String.IsNullOrEmpty(theValue);
                 }))
                 {
                     continue;
                 }
                 dbData.LoadDataRow(binaryDataListItems.Select(item =>
                 {
                     string theValue;
                     try
                     {
                         theValue = item.TheValue;
                     }
                     catch(Exception)
                     {
                         theValue = null;
                     }
                     return theValue as object;
                 }).ToArray(), LoadOption.OverwriteChanges);
             }
         }
     }
     return dbData;
 }
示例#10
0
        static string ExtractKeyValuePairs(NameValueCollection pairs)
        {
            IBinaryDataList bdl = Dev2BinaryDataListFactory.CreateDataList();

            // Extract request keys ;)
            foreach (var key in pairs.AllKeys)
            {
                if (key == "wid") //Don't add the Workspace ID to DataList
                {
                    continue;
                }
                if (key.IsXml())
                {
                    return(key); //We have a workspace id and XML DataList
                }
                string error;
                bdl.TryCreateScalarTemplate(string.Empty, key, string.Empty, true, out error);
                if (!string.IsNullOrEmpty(error))
                {
                    Dev2Logger.Log.Error(error);
                }

                IBinaryDataListEntry entry;
                if (bdl.TryGetEntry(key, out entry, out error))
                {
                    var item = Dev2BinaryDataListFactory.CreateBinaryItem(pairs[key], key);
                    entry.TryPutScalar(item, out error);
                    if (!string.IsNullOrEmpty(error))
                    {
                        Dev2Logger.Log.Error(error);
                    }
                }
                else
                {
                    Dev2Logger.Log.Error(error);
                }
            }

            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();
            ErrorResultTO     errors;
            Guid pushedId = compiler.PushBinaryDataList(bdl.UID, bdl, out errors);

            if (pushedId != Guid.Empty)
            {
                var result = compiler.ConvertFrom(pushedId, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors);
                if (errors.HasErrors())
                {
                    Dev2Logger.Log.Error(errors.MakeDisplayReady());
                }

                return(result.ToString());
            }

            Dev2Logger.Log.Error(errors.MakeDisplayReady());

            return(string.Empty);
        }
示例#11
0
        public void IntersectList_Expected_Merged_Shape()
        {
            ErrorResultTO errors;

            _dl1 = _dl1.Merge(_dl2, enDataListMergeTypes.Intersection, enTranslationDepth.Shape, false, out errors);
            Guid mergeID = _dl1.UID;

            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            string error;

            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);

            Assert.AreEqual("myValue", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r1.f1.value", (rs.FetchRecordAt(1, out error)[0]).TheValue);
            Assert.AreEqual(mergeID, _dl1.UID);
            Assert.IsFalse(errors.HasErrors());
        }
示例#12
0
        [TestMethod] // - ok
        public void UnionCloneList_Expected_NonExistRow_CausesAdd()
        {
            ErrorResultTO errors;

            _dl1 = _dl1.Merge(_dl2, enDataListMergeTypes.Union, enTranslationDepth.Data, false, out errors);


            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            string error;

            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);

            Assert.AreEqual("myValue2", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r2a.f1.value2", (rs.FetchRecordAt(2, out error)[0]).TheValue);
            Assert.AreEqual(4, rs.FetchLastRecordsetIndex());
            Assert.AreEqual(4, rs.ItemCollectionSize());
            Assert.IsFalse(errors.HasErrors());
        }
        /// <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);
        }
示例#14
0
        [TestMethod] // - ok
        public void IntersectVarList_Expected_Merged_Data_Missing_recset2()
        {
            ErrorResultTO errors;

            _dl1 = _dl1.Merge(_dl4, enDataListMergeTypes.Intersection, enTranslationDepth.Data, false, out errors);

            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            IBinaryDataListEntry rs2;
            string error;

            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);
            _dl1.TryGetEntry("recset2", out rs2, out error);

            Assert.AreEqual("myValue4", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r1.f1.value", (rs.FetchRecordAt(1, out error)[0]).TheValue);
            Assert.IsTrue(rs2 == null);
            Assert.IsTrue(errors.HasErrors());
            Assert.AreEqual("Missing DataList item [ recset ] ", errors.FetchErrors()[0]);
        }
示例#15
0
        [TestMethod] // - ok
        public void IntersectList_DifferentShape_Expected_Errors()
        {
            ErrorResultTO errors;

            _dl1 = _dl1.Merge(_dl3, enDataListMergeTypes.Intersection, enTranslationDepth.Shape, false, out errors);

            IBinaryDataListEntry scalar;
            IBinaryDataListEntry scalar2;
            IBinaryDataListEntry rs;
            IBinaryDataListEntry rs2;
            string error;

            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("theScalar", out scalar2, out error);
            _dl1.TryGetEntry("recset", out rs, out error);
            _dl1.TryGetEntry("recset2", out rs2, out error);

            Assert.IsTrue(errors.HasErrors());
            Assert.AreEqual("Missing DataList item [ myScalar ] ", errors.FetchErrors()[0]);
            Assert.AreEqual("Missing DataList item [ recset ] ", errors.FetchErrors()[1]);
        }
示例#16
0
        public void Clone_50EntryRS_1kTimes_AtDepth()
        {
            string error;

            IBinaryDataList dl1 = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f4"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f5"));

            const int r    = 50;
            const int runs = 1000;

            dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error);


            for (int i = 0; i < r; i++)
            {
                dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.valuer1.f3.value", "f3", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.value", "f4", "recset", (i + 1), out error);
                dl1.TryCreateRecordsetValue("r1.f3.value r1.f3.value v r1.f3.value r1.f3.value", "f5", "recset", (i + 1), out error);
            }

            DateTime             start1 = DateTime.Now;
            string               er;
            IBinaryDataListEntry val;
            bool tryGetEntry = dl1.TryGetEntry("recset", out val, out er);

            for (int q = 0; q < runs; q++)
            {
                if (tryGetEntry)
                {
                    val.Clone(enTranslationDepth.Data, dl1.UID, out er);
                }
            }


            DateTime end1 = DateTime.Now;

            long   ticks   = (end1.Ticks - start1.Ticks);
            double result1 = (ticks / _ticksPerSec);

            Console.WriteLine(result1 + @" seconds for " + runs + @" to clone ");

            Assert.IsTrue(result1 <= 10.5); // Given .01 buffer ;) WAS : 0.065
        }
示例#17
0
        [TestMethod] // - ok
        public void UnionCloneList_Expected_Merged_Data_In_New_Object()
        {
            ErrorResultTO errors;

            Guid mergeID = _dl1.UID;

            _dl1 = _dl1.Merge(_dl2, enDataListMergeTypes.Union, enTranslationDepth.Data, true, out errors);


            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            string error;

            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);

            Assert.AreEqual("myValue2", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r3a.f1.value2", (rs.FetchRecordAt(3, out error)[0]).TheValue);
            Assert.AreNotEqual(mergeID, _dl1.UID);
            Assert.AreEqual(4, rs.FetchLastRecordsetIndex());
            Assert.IsFalse(errors.HasErrors());
        }
        /// <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 void Iteration_Evaluation_Expect_Evaluation_For_1_Iteration()
        {
            // Iteration evaluation is tested via the shape method ;)
            var          compiler = DataListFactory.CreateDataListCompiler();
            const string defs     = @"<Inputs><Input Name=""scalar1"" Source=""[[myScalar]]"" /></Inputs>";
            Guid         id       = compiler.Shape(_dl1.UID, enDev2ArgumentType.Input, defs, out _errors);

            IBinaryDataList bdl = compiler.FetchBinaryDataList(id, out _errors);

            bdl.TryGetEntry("scalar1", out _entry, out _error);

            var res = _entry.FetchScalar().TheValue;

            Assert.AreEqual("[[otherScalar]]", res);
        }
        static void ValidateScalar(IBinaryDataList dataList, string name, string expectedValue)
        {
            string error;
            IBinaryDataListEntry entry;

            dataList.TryGetEntry(name, out entry, out error);
            if (!string.IsNullOrEmpty(error))
            {
                Assert.Fail("Error fetching scalar '{0}' from Binary DataList", name);
            }
            else
            {
                var scalar = entry.FetchScalar();
                Assert.AreEqual(expectedValue, scalar.TheValue);
            }
        }
        /// <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;
        }
示例#22
0
        [TestMethod] // - ok
        public void UnionDataWithBlankOverwrite_Expect_BlankScalar()
        {
            ErrorResultTO errors;
            Guid          mergeID = _dlWithPopulatedScalar.UID;

            _dlWithPopulatedScalar = _dlWithPopulatedScalar.Merge(_dlWithBankScalar, enDataListMergeTypes.Union, enTranslationDepth.Data_With_Blank_OverWrite, false, out errors);


            IBinaryDataListEntry scalar;
            string error;

            _dlWithPopulatedScalar.TryGetEntry("myScalar", out scalar, out error);

            Assert.AreEqual(string.Empty, scalar.FetchScalar().TheValue);
            Assert.AreEqual(mergeID, _dlWithPopulatedScalar.UID);
            Assert.IsFalse(errors.HasErrors());
        }
        public void BaseConvertRecsetWithStarIndexToBinaryExpectedOutputToCorrectRecords()
        {
            SetupArguments(
                @"<root></root>"
                , ActivityStrings.BaseConvert_DLShape.Replace("<ADL>", "<ADL><setup/>")
                , new List <BaseConvertTO> {
                new BaseConvertTO("", "Text", "Binary", "[[setup]]", 1)
            }
                );
            IDSFDataObject  result = ExecuteProcess();
            ErrorResultTO   errorResult;
            IBinaryDataList bdl = Compiler.FetchBinaryDataList(result.DataListID, out errorResult);

            IBinaryDataListItem isolatedRecord = Dev2BinaryDataListFactory.CreateBinaryItem("CONVERT THIS TO BINARY", "Field");
            string error;
            IBinaryDataListEntry entry;

            bdl.TryGetEntry("Recset", out entry, out error);
            entry.TryPutRecordItemAtIndex(isolatedRecord, 5, out error);

            IList <BaseConvertTO> convertCollection = new List <BaseConvertTO> {
                new BaseConvertTO("[[Recset(*).Field]]", "Text", "Binary", "[[Recset(*).Field]]", 1)
            };

            TestStartNode = new FlowStep
            {
                Action = new DsfBaseConvertActivity {
                    ConvertCollection = convertCollection
                }
            };
            result = ExecuteProcess();

            IList <IBinaryDataListEntry> actual = bdl.FetchRecordsetEntries();
            var index       = actual[0].FetchRecordAt(5, out error)[0].ItemCollectionIndex;
            var count       = actual.Count();
            var actualValue = actual[0].FetchRecordAt(5, out error)[0].TheValue;

            // remove test datalist ;)
            DataListRemoval(result.DataListID);

            Assert.AreEqual("01000011010011110100111001010110010001010101001001010100001000000101010001001000010010010101001100100000010101000100111100100000010000100100100101001110010000010101001001011001", actualValue);
            Assert.AreEqual(1, count); // still only one record
            Assert.AreEqual(5, index); // and that record has not moved
        }
示例#24
0
        public StringBuilder ConvertAndFilter(IBinaryDataList payload, StringBuilder filterShape, out ErrorResultTO errors)
        {
            if (payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");

            errors = new ErrorResultTO();
            string error;

            IBinaryDataList targetDl = BuildTargetShape(filterShape, out error);

            IList <string> itemKeys = targetDl.FetchAllKeys();

            foreach (string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                IBinaryDataListEntry tmpEntry;
                if (payload.TryGetEntry(key, out entry, out error) && targetDl.TryGetEntry(key, out tmpEntry, out error))
                {
                    if (entry.IsRecordset)
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        string fName            = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if (val != null)
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }
            }

            result.Append("</" + RootTag + ">");

            return(result);
        }
示例#25
0
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if (payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");

            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach (var key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if (payload.TryGetEntry(key, out entry, out error))
                {
                    if (entry.IsRecordset && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        var fName = entry.Namespace;
                        var val   = entry.FetchScalar();
                        if (val != null && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }
            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return(tmp);
        }
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach(var key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error))
                {
                    if(entry.IsRecordset && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        var fName = entry.Namespace;
                        var val = entry.FetchScalar();
                        if(val != null && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }
示例#27
0
        public void CloneWhereHasComplexExpressionAuditorExpectIsOnClonedObject()
        {
            //------------Setup for test--------------------------
            string             error;
            IBinaryDataList    dl1  = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);
            IList <Dev2Column> cols = new List <Dev2Column>();

            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            dl1.TryCreateRecordsetTemplate("recset", string.Empty, cols, true, out error);
            dl1.TryCreateRecordsetValue("r1.f1.value r1.f1.value r1.f1.valuer1.f1.valuer1.f1.value", "f1", "recset", 1, out error);
            string er;
            IBinaryDataListEntry val;

            dl1.TryGetEntry("recset", out val, out er);
            val.ComplexExpressionAuditor = new ComplexExpressionAuditor();
            //------------Execute Test---------------------------
            IBinaryDataListEntry res = val.Clone(enTranslationDepth.Data, dl1.UID, out er);

            //------------Assert Results-------------------------
            Assert.IsNotNull(res.ComplexExpressionAuditor);
        }
示例#28
0
        public bool GetRecordSetFieldValueFromDataList(Guid dataListId, string recordSet, string fieldNameToRetrieve, out IList <IBinaryDataListItem> result, out string error)
        {
            IList <IBinaryDataListItem> dLItems = new List <IBinaryDataListItem>();
            ErrorResultTO        errorResult;
            IBinaryDataListEntry entry;
            bool            isCool = true;
            IBinaryDataList bdl    = Compiler.FetchBinaryDataList(dataListId, out errorResult);

            bdl.TryGetEntry(recordSet, out entry, out error);

            if (entry == null)
            {
                result = dLItems;
                return(false);
            }
            if (entry.IsEmpty())
            {
                result = dLItems;
                return(true);
            }

            IIndexIterator idxItr = entry.FetchRecordsetIndexes();

            while (idxItr.HasMore())
            {
                var fetchNextIndex = idxItr.FetchNextIndex();
                dLItems.Add(entry.TryFetchRecordsetColumnAtIndex(fieldNameToRetrieve, fetchNextIndex, out error).Clone());
            }

            result = dLItems;

            if (!string.IsNullOrEmpty(error))
            {
                isCool = false;
            }

            return(isCool);
        }
        [TestMethod] // - ok
        public void IntersectVarList_Expected_Merged_Data_Missing_recset2()
        {
            ErrorResultTO errors;

            _dl1 = _dl1.Merge(_dl4, enDataListMergeTypes.Intersection, enTranslationDepth.Data, false, out errors);

            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            IBinaryDataListEntry rs2;
            string error;
            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);
            _dl1.TryGetEntry("recset2", out rs2, out error);

            Assert.AreEqual("myValue4", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r1.f1.value", (rs.FetchRecordAt(1, out error)[0]).TheValue);
            Assert.IsTrue(rs2 == null);
            Assert.IsTrue(errors.HasErrors());
            Assert.AreEqual("Missing DataList item [ recset ] ", errors.FetchErrors()[0]);

        }
        public void IntersectList_Expected_Merged_Shape()
        {
            ErrorResultTO errors;

            _dl1 = _dl1.Merge(_dl2, enDataListMergeTypes.Intersection, enTranslationDepth.Shape, false, out errors);
            Guid mergeID = _dl1.UID;

            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            string error;
            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);

            Assert.AreEqual("myValue", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r1.f1.value", (rs.FetchRecordAt(1, out error)[0]).TheValue);
            Assert.AreEqual(mergeID, _dl1.UID);
            Assert.IsFalse(errors.HasErrors());

        }
        [TestMethod]  // - ok
        public void UnionCloneList_VarList_Expected_Merged_Data_In_New_Object()
        {
            ErrorResultTO errors;

            Guid mergeID = _dl1.UID;
            _dl1 = _dl1.Merge(_dl4, enDataListMergeTypes.Union, enTranslationDepth.Data, true, out errors);


            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            IBinaryDataListEntry rs2;
            string error;
            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);
            _dl1.TryGetEntry("recset2", out rs2, out error);

            Assert.AreEqual("myValue4", scalar.FetchScalar().TheValue);
            Assert.AreNotEqual(mergeID, _dl1.UID);
            Assert.AreEqual(4, rs.FetchLastRecordsetIndex());
            Assert.AreEqual(3, rs2.FetchLastRecordsetIndex());
            Assert.IsFalse(errors.HasErrors());

        }
        [TestMethod] // - ok
        public void UnionCloneList_Expected_NonExistRow_CausesAdd()
        {
            ErrorResultTO errors;

            _dl1 = _dl1.Merge(_dl2, enDataListMergeTypes.Union, enTranslationDepth.Data, false, out errors);


            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            string error;
            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);

            Assert.AreEqual("myValue2", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r2a.f1.value2", (rs.FetchRecordAt(2, out error)[0]).TheValue);
            Assert.AreEqual(4, rs.FetchLastRecordsetIndex());
            Assert.AreEqual(4, rs.ItemCollectionSize());
            Assert.IsFalse(errors.HasErrors());

        }
        [TestMethod] // - ok
        public void UnionCloneList_Expected_Merged_Data()
        {
            ErrorResultTO errors;

            Guid mergeID = _dl1.UID;
            _dl1 = _dl1.Merge(_dl2, enDataListMergeTypes.Union, enTranslationDepth.Data, false, out errors);


            IBinaryDataListEntry scalar;
            IBinaryDataListEntry rs;
            string error;
            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("recset", out rs, out error);

            Assert.AreEqual("myValue2", scalar.FetchScalar().TheValue);
            Assert.AreEqual("r3a.f1.value2", (rs.FetchRecordAt(3, out error)[0]).TheValue);
            Assert.AreEqual(mergeID, _dl1.UID);
            Assert.AreEqual(4, rs.FetchLastRecordsetIndex());
            Assert.IsFalse(errors.HasErrors());

        }
        [TestMethod] // - ok
        public void UnionDataWithBlankOverwrite_Expect_BlankScalar()
        {

            ErrorResultTO errors;
            Guid mergeID = _dlWithPopulatedScalar.UID;
            _dlWithPopulatedScalar = _dlWithPopulatedScalar.Merge(_dlWithBankScalar, enDataListMergeTypes.Union, enTranslationDepth.Data_With_Blank_OverWrite, false, out errors);


            IBinaryDataListEntry scalar;
            string error;
            _dlWithPopulatedScalar.TryGetEntry("myScalar", out scalar, out error);

            Assert.AreEqual(string.Empty, scalar.FetchScalar().TheValue);
            Assert.AreEqual(mergeID, _dlWithPopulatedScalar.UID);
            Assert.IsFalse(errors.HasErrors());

        }
        // ReSharper restore RedundantOverridenMember


        protected override void OnExecute(NativeActivityContext context)
        {
            _debugInputs  = new List <DebugItem>();
            _debugOutputs = new List <DebugItem>();
            IDataListCompiler compiler   = DataListFactory.CreateDataListCompiler();
            IDSFDataObject    dataObject = context.GetExtension <IDSFDataObject>();
            ErrorResultTO     errors;
            ErrorResultTO     allErrors = new ErrorResultTO();
            Guid executionId            = DataListExecutionID.Get(context);

            InitializeDebug(dataObject);

            try
            {
                string rawRecsetName = RetrieveItemForEvaluation(enIntellisensePartType.RecordsetsOnly, SortField);
                string sortField     = RetrieveItemForEvaluation(enIntellisensePartType.RecordsetFields, SortField);

                bool descOrder = String.IsNullOrEmpty(SelectedSort) || SelectedSort.Equals("Backwards");

                // Travis.Frisinger : New Stuff....
                if (!string.IsNullOrEmpty(rawRecsetName))
                {
                    IBinaryDataList      bdl = compiler.FetchBinaryDataList(executionId, out errors);
                    IBinaryDataListEntry rsData;
                    string error;
                    bdl.TryGetEntry(rawRecsetName, out rsData, out error);
                    if (dataObject.IsDebugMode())
                    {
                        AddDebugInputItem(SortField, "Sort Field", rsData, executionId);
                    }

                    allErrors.AddError(error);
                    IsSingleRecordSetRule rule = new IsSingleRecordSetRule(() => SortField);
                    var single = rule.Check();
                    if (single != null)
                    {
                        allErrors.AddError(single.Message);
                    }

                    // Check for fields
                    if (rsData != null && rsData.HasField(sortField))
                    {
                        rsData.Sort(sortField, descOrder, out error);
                        errors.AddError(error);

                        // Push back against the datalist
                        compiler.PushBinaryDataList(executionId, bdl, out errors);
                        allErrors.MergeErrors(errors);
                        if (dataObject.IsDebugMode())
                        {
                            bdl.TryGetEntry(rawRecsetName, out rsData, out error);
                            //Added for Bug 9479
                            string tmpExpression = SortField;
                            if (tmpExpression.Contains("()."))
                            {
                                tmpExpression = tmpExpression.Replace("().", "(*).");
                            }
                            AddDebugOutputItem(new DebugItemVariableParams(tmpExpression, "", rsData, executionId));
                        }
                    }
                }
                else
                {
                    allErrors.AddError("No recordset given");
                }
            }
            finally
            {
                if (allErrors.HasErrors())
                {
                    DisplayAndWriteError("DsfSortRecordsActivity", allErrors);
                    compiler.UpsertSystemTag(dataObject.DataListID, enSystemTag.Dev2Error, allErrors.MakeDataListReady(), out errors);
                }
                if (dataObject.IsDebugMode())
                {
                    DispatchDebugState(context, StateType.Before);
                    DispatchDebugState(context, StateType.After);
                }
            }

            // End Travis.Frisinger New Stuff
        }
        public StringBuilder ConvertAndFilter(IBinaryDataList payload, StringBuilder filterShape, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            ErrorResultTO invokeErrors;
            TranslatorUtils tu = new TranslatorUtils();

            IBinaryDataList targetDl = _tu.TranslateShapeToObject(filterShape, false, out invokeErrors);
            errors.MergeErrors(invokeErrors);

            IList<string> itemKeys = targetDl.FetchAllKeys();

            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)
                    {
                        var idxItr = entry.FetchRecordsetIndexes();

                        while(idxItr.HasMore())
                        {
                            var i = idxItr.FetchNextIndex();

                            IList<IBinaryDataListItem> rowData = entry.FetchRecordAt(i, out error);
                            if(error != string.Empty)
                            {
                                errors.AddError(error);
                            }

                            result.Append("<");
                            result.Append(entry.Namespace);
                            result.Append(" ");
                            result.Append(GlobalConstants.RowAnnotation);
                            result.Append("=");
                            result.Append("\"" + i + "\"");
                            result.Append(">");

                            foreach(IBinaryDataListItem col in rowData)
                            {
                                IBinaryDataListItem col1 = col;
                                if(tmpEntry.Columns.Any((c => c.ColumnName == col1.FieldName)))
                                {
                                    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
                    {
                        string fName = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();

                        if(val != null)
                        {
                            result.Append("<");
                            result.Append(fName);
                            result.Append(">");
                            try
                            {
                                result.Append(entry.Namespace != GlobalConstants.ManagementServicePayload ? tu.FullCleanForEmit(val.TheValue) : val.TheValue);
                            }
                            // ReSharper disable EmptyGeneralCatchClause
                            catch
                            // ReSharper restore EmptyGeneralCatchClause
                            {
                            }
                            result.Append("</");
                            result.Append(fName);
                            result.Append(">");
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            return result;
        }
示例#37
0
        internal static IBinaryDataList BuildBinaryDataList(byte[] input, StringBuilder targetShape, ErrorResultTO errors, string payload)
        {
            IBinaryDataList result = null;

            // build shape
            if (targetShape == null)
            {
                errors.AddError("Null payload or shape");
            }
            else
            {
                string error;
                result = BuildTargetShape(targetShape, out error);
                errors.AddError(error);

                // populate the shape
                if (payload != String.Empty)
                {
                    try
                    {
                        var         toLoad = payload;
                        XmlDocument xDoc   = new XmlDocument();
                        try
                        {
                            xDoc.LoadXml(toLoad);
                        }
                        catch
                        {
                            // Append new root tags ;)
                            toLoad = "<root>" + toLoad + "</root>";
                            xDoc.LoadXml(toLoad);
                        }

                        if (!String.IsNullOrEmpty(toLoad))
                        {
                            if (xDoc.DocumentElement != null)
                            {
                                XmlNodeList children = xDoc.DocumentElement.ChildNodes;

                                IDictionary <string, int> indexCache = new Dictionary <string, int>();

                                // spin through each element in the XML
                                foreach (XmlNode c in children)
                                {
                                    var hasCorrectIoDirection = true;
                                    if (c.Attributes != null)
                                    {
                                        var columnIoDirectionAttribute = c.Attributes["ColumnIODirection"];
                                        if (columnIoDirectionAttribute != null)
                                        {
                                            var columnIoDirectionValue             = columnIoDirectionAttribute.Value;
                                            var hasCorrectIoDirectionFromAttribute = columnIoDirectionValue == enDev2ColumnArgumentDirection.Output.ToString() || columnIoDirectionValue == enDev2ColumnArgumentDirection.Both.ToString();
                                            hasCorrectIoDirection = hasCorrectIoDirectionFromAttribute;
                                        }
                                    }

                                    if (DataListUtil.IsSystemTag(c.Name) && !hasCorrectIoDirection)
                                    {
                                        continue;
                                    }
                                    // scalars and recordset fetch
                                    IBinaryDataListEntry entry;
                                    if (result.TryGetEntry(c.Name, out entry, out error))
                                    {
                                        if (entry.IsRecordset)
                                        {
                                            // fetch recordset index
                                            int fetchIdx;
                                            int idx = indexCache.TryGetValue(c.Name, out fetchIdx) ? fetchIdx : 1; // recset index
                                            // process recordset
                                            XmlNodeList nl = c.ChildNodes;
                                            foreach (XmlNode subc in nl)
                                            {
                                                entry.TryPutRecordItemAtIndex(Dev2BinaryDataListFactory.CreateBinaryItem(subc.InnerXml, c.Name, subc.Name, (idx + "")), idx, out error);
                                                errors.AddError(error);
                                            }
                                            // update this recordset index
                                            indexCache[c.Name] = ++idx;
                                        }
                                        else
                                        {
                                            // process scalar
                                            entry.TryPutScalar(Dev2BinaryDataListFactory.CreateBinaryItem(c.InnerXml, c.Name), out error);
                                            errors.AddError(error);
                                        }
                                    }
                                    else
                                    {
                                        errors.AddError(error);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        // if use passed in empty input they only wanted the shape ;)
                        if (input.Length > 0)
                        {
                            errors.AddError(e.Message);
                        }
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Translates the shape automatic object.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="includeSysTags">Includes the system tags when building the DataList</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public IBinaryDataList TranslateShapeToObject(StringBuilder shape, bool includeSysTags, out ErrorResultTO errors)
        {
            IBinaryDataList result = null;

            errors = new ErrorResultTO();

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(shape.ToString());
                string error;
                if (xDoc.DocumentElement != null)
                {
                    XmlNodeList      children           = xDoc.DocumentElement.ChildNodes;
                    HashSet <string> procssesNamespaces = new HashSet <string>();

                    result = Dev2BinaryDataListFactory.CreateDataList();

                    foreach (XmlNode c in children)
                    {
                        XmlAttribute descAttribute = null;
                        XmlAttribute ioDirection   = null;

                        if (!DataListUtil.IsSystemTag(c.Name))
                        {
                            if (c.HasChildNodes)
                            {
                                IList <Dev2Column> cols = new List <Dev2Column>();
                                //recordset
                                // build template
                                if (!procssesNamespaces.Contains(c.Name))
                                {
                                    procssesNamespaces.Add(c.Name);

                                    // build columns
                                    foreach (XmlNode subc in c.ChildNodes)
                                    {
                                        if (subc.Attributes != null)
                                        {
                                            descAttribute = subc.Attributes["Description"];
                                            ioDirection   = subc.Attributes["ColumnIODirection"];
                                        }

                                        // set column io direction
                                        enDev2ColumnArgumentDirection dirCol = enDev2ColumnArgumentDirection.None;
                                        if (ioDirection != null)
                                        {
                                            Enum.TryParse(ioDirection.Value, out dirCol);
                                        }


                                        if (descAttribute != null)
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name, descAttribute.Value, true, dirCol));
                                        }
                                        else
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name, String.Empty, true, dirCol));
                                        }
                                    }
                                    string myError;

                                    if (c.Attributes != null)
                                    {
                                        descAttribute = c.Attributes["Description"];
                                        ioDirection   = c.Attributes["ColumnIODirection"];
                                    }


                                    // set column io direction
                                    enDev2ColumnArgumentDirection dir = enDev2ColumnArgumentDirection.None;
                                    if (ioDirection != null)
                                    {
                                        Enum.TryParse(ioDirection.Value, out dir);
                                    }


                                    if (descAttribute != null)
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name, descAttribute.Value, cols, true, true, dir, out myError))
                                        {
                                            errors.AddError(myError);
                                        }
                                    }
                                    else
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name, String.Empty, cols, true, true, dir, out myError))
                                        {
                                            errors.AddError(myError);
                                        }
                                    }
                                }
                                else
                                {
                                    // it is a duplicate we need to handle this correctly ;)
                                    // build columns

                                    IBinaryDataListEntry amendEntry;
                                    result.TryGetEntry(c.Name, out amendEntry, out error);
                                    errors.AddError(error);

                                    if (amendEntry != null)
                                    {
                                        cols = amendEntry.Columns;

                                        foreach (XmlNode subc in c.ChildNodes)
                                        {
                                            if (subc.Attributes != null)
                                            {
                                                descAttribute = subc.Attributes["Description"];
                                                ioDirection   = subc.Attributes["ColumnIODirection"];
                                            }

                                            // set column io direction
                                            enDev2ColumnArgumentDirection dir = enDev2ColumnArgumentDirection.None;
                                            if (ioDirection != null)
                                            {
                                                Enum.TryParse(ioDirection.Value, out dir);
                                            }


                                            if (descAttribute != null)
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, descAttribute.Value, true, dir));
                                            }
                                            else
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, String.Empty, true, dir));
                                            }
                                        }

                                        // now re-insert the entry ;)
                                        if (!result.TryCreateRecordsetTemplate(c.Name, String.Empty, cols, true, out error))
                                        {
                                            errors.AddError(error);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //scalar
                                if (c.Attributes != null)
                                {
                                    descAttribute = c.Attributes["Description"];
                                    ioDirection   = c.Attributes["ColumnIODirection"];
                                }

                                // get column direction
                                enDev2ColumnArgumentDirection dir = enDev2ColumnArgumentDirection.None;
                                if (ioDirection != null)
                                {
                                    Enum.TryParse(ioDirection.Value, out dir);
                                }

                                if (descAttribute != null)
                                {
                                    result.TryCreateScalarTemplate(String.Empty, c.Name, descAttribute.Value, true, true, dir, out error);
                                }
                                else
                                {
                                    result.TryCreateScalarTemplate(String.Empty, c.Name, String.Empty, true, true, dir, out error);
                                }
                            }
                        }
                    }
                }


                if (includeSysTags)
                {
                    // Build System Tag Shape ;)
                    for (int i = 0; i < TranslationConstants.systemTags.Length; i++)
                    {
                        if (result != null)
                        {
                            result.TryCreateScalarTemplate(GlobalConstants.SystemTagNamespace,
                                                           TranslationConstants.systemTags.GetValue(i).ToString(),
                                                           String.Empty,
                                                           true,
                                                           out error);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                errors.AddError(e.Message);
            }

            return(result);
        }
        static void ValidateRecordSet(IBinaryDataList dataList, string name, KeyValuePair <string, string[]>[] expectedValues)
        {
            string error;
            IBinaryDataListEntry entry;

            dataList.TryGetEntry(name, out entry, out error);
            if (!string.IsNullOrEmpty(error))
            {
                Assert.Fail("Error fetching RecordSet '{0}' from Binary DataList", name);
            }
            else
            {
                IIndexIterator idxItr = entry.FetchRecordsetIndexes();
                while (idxItr.HasMore())
                {
                    var fields = entry.FetchRecordAt(idxItr.FetchNextIndex(), out error);
                    if (!string.IsNullOrEmpty(error))
                    {
                        Assert.Fail("Error fetching RecordSet '{0}' fields", name);
                    }
                    else
                    {
                        var foundCount = 0;
                        // ReSharper disable LoopCanBeConvertedToQuery
                        foreach (var field in fields)
                        // ReSharper restore LoopCanBeConvertedToQuery
                        {
                            // ReSharper disable LoopCanBeConvertedToQuery
                            foreach (var expectedValue in expectedValues)
                            // ReSharper restore LoopCanBeConvertedToQuery
                            {
                                if (field.FieldName == expectedValue.Key && expectedValue.Value.Contains(field.TheValue))
                                {
                                    foundCount++;
                                }
                            }
                        }
                        Assert.AreEqual(expectedValues.Length, foundCount);
                    }
                }

                //foreach(var index in entry.FetchRecordsetIndexes())
                //{
                //    var fields = entry.FetchRecordAt(index, out error);
                //    if (!string.IsNullOrEmpty(error))
                //    {
                //        Assert.Fail("Error fetching RecordSet '{0}' fields", name);
                //    }
                //    else
                //    {
                //        var foundCount = 0;
                //        foreach (var field in fields)
                //        {
                //            foreach (var expectedValue in expectedValues)
                //            {
                //                if (field.FieldName == expectedValue.Key && expectedValue.Value.Contains(field.TheValue))
                //                {
                //                    foundCount++;
                //                }
                //            }
                //        }
                //        Assert.AreEqual(expectedValues.Length, foundCount);
                //    }
                //}
            }
        }
        [TestMethod] // - ok
        public void IntersectList_DifferentShape_Expected_Errors()
        {

            ErrorResultTO errors;
            _dl1 = _dl1.Merge(_dl3, enDataListMergeTypes.Intersection, enTranslationDepth.Shape, false, out errors);

            IBinaryDataListEntry scalar;
            IBinaryDataListEntry scalar2;
            IBinaryDataListEntry rs;
            IBinaryDataListEntry rs2;
            string error;
            _dl1.TryGetEntry("myScalar", out scalar, out error);
            _dl1.TryGetEntry("theScalar", out scalar2, out error);
            _dl1.TryGetEntry("recset", out rs, out error);
            _dl1.TryGetEntry("recset2", out rs2, out error);

            Assert.IsTrue(errors.HasErrors());
            Assert.AreEqual("Missing DataList item [ myScalar ] ", errors.FetchErrors()[0]);
            Assert.AreEqual("Missing DataList item [ recset ] ", errors.FetchErrors()[1]);

        }
        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();

            var itemKeys = payload.FetchAllKeys();

            foreach(string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error))
                {

                    if(entry.IsRecordset)
                    {
                        var idxItr = entry.FetchRecordsetIndexes();

                        while(idxItr.HasMore() && !entry.IsEmpty())
                        {

                            while(idxItr.HasMore())
                            {

                                int 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(">");

                                    // Travis.Frisinger 04.02.2013
                                    if(!col.IsDeferredRead)
                                    {
                                        try
                                        {
                                            result.Append(tu.CleanForEmit(col.TheValue));
                                        }
                                        catch(Exception e)
                                        {
                                            Dev2Logger.Log.Error(e);
                                        }
                                    }
                                    else
                                    {
                                        // deferred read, just print the location
                                        result.Append(!string.IsNullOrEmpty(col.TheValue) ? col.FetchDeferredLocation() : string.Empty);
                                    }
                                    result.Append("</");
                                    result.Append(fName);
                                    result.Append(">");
                                }

                                result.Append("</");
                                result.Append(entry.Namespace);
                                result.Append(">");
                            }
                        }
                    }
                    else
                    {
                        string fName = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if(val != null)
                        {
                            result.Append("<");
                            result.Append(fName);
                            result.Append(">");
                            // Travis.Frisinger 04.02.2013
                            if(!val.IsDeferredRead)
                            {
                                // Dev2System.FormView is our html region, pass it by ;)
                                try
                                {
                                    result.Append(!entry.IsManagmentServicePayload ? tu.CleanForEmit(val.TheValue) : val.TheValue);
                                }
                                catch(Exception e)
                                {
                                    Dev2Logger.Log.Error(e);
                                }

                            }
                            else
                            {
                                // deferred read, just print the location
                                result.Append(val.FetchDeferredLocation());
                            }
                            result.Append("</");
                            result.Append(fName);
                            result.Append(">");
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }
示例#42
0
        public IBinaryDataList ConvertTo(byte[] input, StringBuilder targetShape, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            var payload = Encoding.UTF8.GetString(input);

            IBinaryDataList result = null;

            // build shape
            if (String.IsNullOrEmpty(targetShape.ToString()))
            {
                errors.AddError("Null payload shape");
            }
            else
            {
                string error;
                result = BuildTargetShape(targetShape, out error);
                if (!string.IsNullOrEmpty(error))
                {
                    errors.AddError(error);
                }

                // populate the shape
                if (payload != string.Empty)
                {
                    try
                    {
                        XmlDocument xDoc = new XmlDocument();
                        xDoc.LoadXml(payload);
                        if (xDoc.DocumentElement != null)
                        {
                            var children = xDoc.DocumentElement.ChildNodes;

                            IDictionary <string, int> indexCache = new Dictionary <string, int>();

                            {
                                // spin through each element in the XML
                                foreach (XmlNode c in children)
                                {
                                    if (!DataListUtil.IsSystemTag(c.Name))
                                    {
                                        // scalars and recordset fetch
                                        IBinaryDataListEntry entry;
                                        if (result.TryGetEntry(c.Name, out entry, out error))
                                        {
                                            if (entry.IsRecordset)
                                            {
                                                // fetch recordset index
                                                int fetchIdx;
                                                int idx; // recset index
                                                if (indexCache.TryGetValue(c.Name, out fetchIdx))
                                                {
                                                    idx = fetchIdx;
                                                }
                                                else
                                                {
                                                    // 28-02-2013 - Sashen.Naidoo
                                                    // BUG 9144
                                                    // A cache miss does not necessary mean there is nothing in the record set,
                                                    // it just means the value isn't in the record set.
                                                    idx = indexCache.Count == 0 ? 1 : indexCache.Count;
                                                }
                                                // process recordset
                                                var nl = c.ChildNodes;
                                                foreach (XmlNode subc in nl)
                                                {
                                                    entry.TryPutRecordItemAtIndex(Dev2BinaryDataListFactory.CreateBinaryItem(subc.InnerXml, c.Name, subc.Name, idx), idx, out error);

                                                    if (!string.IsNullOrEmpty(error))
                                                    {
                                                        errors.AddError(error);
                                                    }
                                                    // update this recordset index
                                                }
                                                indexCache[c.Name] = ++idx;
                                            }
                                            else
                                            {
                                                // process scalar
                                                entry.TryPutScalar(Dev2BinaryDataListFactory.CreateBinaryItem(c.InnerXml, c.Name), out error);

                                                if (!string.IsNullOrEmpty(error))
                                                {
                                                    errors.AddError(error);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            errors.AddError(error);
                                        }
                                    }
                                }
                            }
                        }

                        // Transfer System Tags
                        for (var i = 0; i < TranslationConstants.systemTags.Length; i++)
                        {
                            var key   = TranslationConstants.systemTags.GetValue(i).ToString();
                            var query = String.Concat("//", key);
                            var n     = xDoc.SelectSingleNode(query);

                            if (n != null && !string.IsNullOrEmpty(n.InnerXml))
                            {
                                var bkey = GlobalConstants.SystemTagNamespace + "." + key;
                                IBinaryDataListEntry sysEntry;
                                if (result.TryGetEntry(bkey, out sysEntry, out error))
                                {
                                    sysEntry.TryPutScalar(Dev2BinaryDataListFactory.CreateBinaryItem(n.InnerXml, bkey), out error);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        // if use passed in empty input they only wanted the shape ;)
                        if (input.Length > 0)
                        {
                            errors.AddError(e.Message);
                        }
                    }
                }
            }

            return(result);
        }
        // BUG 9626 - 2013.06.11 - TWR: refactored for recursion
        static void TryConvert(XmlNodeList children, IBinaryDataList result, IDictionary<string, int> indexCache, ErrorResultTO errors, bool onlyMapInputs, int level = 0)
        {
            // spin through each element in the XML
            foreach(XmlNode c in children)
            {
                if(!DataListUtil.IsSystemTag(c.Name) && c.Name != GlobalConstants.NaughtyTextNode)
                {
                    // scalars and recordset fetch
                    IBinaryDataListEntry entry;
                    string error;
                    if(result.TryGetEntry(c.Name, out entry, out error))
                    {
                        if(entry.IsRecordset)
                        {
                            // fetch recordset index
                            int fetchIdx;
                            var idx = indexCache.TryGetValue(c.Name, out fetchIdx) ? fetchIdx : 1;
                            // process recordset
                            var nl = c.ChildNodes;
                            foreach(XmlNode subc in nl)
                            {
                                // Extract column being mapped to ;)
                                var theCol = entry.Columns.FirstOrDefault(col => col.ColumnName == subc.Name);
                                var dir = enDev2ColumnArgumentDirection.None;
                                if(theCol != null)
                                {
                                    dir = theCol.ColumnIODirection;
                                }

                                if(CanMapValue(onlyMapInputs, dir))
                                {
                                    entry.TryPutRecordItemAtIndex(Dev2BinaryDataListFactory.CreateBinaryItem(subc.InnerXml, c.Name, subc.Name, idx), idx, out error);
                                }

                                errors.AddError(error);
                            }
                            // update this recordset index
                            indexCache[c.Name] = ++idx;
                        }
                        else if(CanMapValue(onlyMapInputs, entry.ColumnIODirection))
                        {
                            // process scalar
                            entry.TryPutScalar(Dev2BinaryDataListFactory.CreateBinaryItem(c.InnerXml, c.Name), out error);

                            if(!string.IsNullOrEmpty(error))
                            {
                                errors.AddError(error);
                            }
                        }
                    }
                    else
                    {
                        if(level == 0)
                        {
                            // Only recurse if we're at the first level!!
                            TryConvert(c.ChildNodes, result, indexCache, errors, onlyMapInputs, ++level);
                        }
                        else
                        {
                            errors.AddError(error);
                        }
                    }
                }
            }
        }
        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;
        }
        /// <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;
        }
        public StringBuilder ConvertAndFilter(IBinaryDataList payload, StringBuilder filterShape, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();
            string error;

            IBinaryDataList targetDl = BuildTargetShape(filterShape, out error);

            IList<string> itemKeys = targetDl.FetchAllKeys();

            foreach(string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                IBinaryDataListEntry tmpEntry;
                if(payload.TryGetEntry(key, out entry, out error) && targetDl.TryGetEntry(key, out tmpEntry, out error))
                {

                    if(entry.IsRecordset)
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        string fName = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if(val != null)
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            return result;
        }