Esempio n. 1
0
        public void DeSerializeToXMLInputsOnlyFromBinary_ValidXML_Expect_Sucess()
        {
            IBinaryDataList   dl    = Dev2BinaryDataListFactory.CreateDataList();
            List <Dev2Column> cols1 = new List <Dev2Column>
            {
                DataListFactory.CreateDev2Column("f1", ""),
            };
            List <Dev2Column> cols2 = new List <Dev2Column>
            {
                DataListFactory.CreateDev2Column("f2", ""),
            };
            string        error;
            ErrorResultTO errors;


            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatInputsOnly);

            dl.TryCreateRecordsetTemplate("rs1", "", cols1, true, out error);
            dl.TryCreateRecordsetTemplate("rs2", "", cols2, true, true, enDev2ColumnArgumentDirection.Input, out error);
            dl.TryCreateScalarTemplate("", "scalar1", "", true, true, enDev2ColumnArgumentDirection.Input, out error);
            dl.TryCreateScalarTemplate("", "scalar2", "", true, true, enDev2ColumnArgumentDirection.Output, out error);
            dl.TryCreateScalarValue("scalar1Value", "scalar1", out error);
            dl.TryCreateScalarValue("scalar2Value", "scalar2", out error);
            dl.TryCreateRecordsetValue("rec1.f1.value", "f1", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec1.f2.value", "f2", "rs2", 1, out error);
            dl.TryCreateRecordsetValue("rec2.f1.value", "f1", "rs1", 2, out error);
            dl.TryCreateRecordsetValue("rec2.f2.value", "f2", "rs2", 2, out error);

            DataListTranslatedPayloadTO tmp = xmlConverter.ConvertFrom(dl, out errors);

            string result = tmp.FetchAsString().ToString();

            Assert.AreEqual("<DataList><scalar1>scalar1Value</scalar1></DataList>", result);
        }
Esempio n. 2
0
        /// <summary>
        ///     Converts a list of data list item view models to a binary data list.
        /// </summary>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        private IBinaryDataList ConvertIDataListItemModelsToIBinaryDataList(out string errorString)
        {
            errorString = string.Empty;
            IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList();

            IList <IDataListItemModel> filledScalars =
                ScalarCollection != null?ScalarCollection.Where(scalar => !scalar.IsBlank && !scalar.HasError).ToList() : new List <IDataListItemModel>();

            foreach (var scalar in filledScalars)
            {
                result.TryCreateScalarTemplate
                    (string.Empty, scalar.Name, scalar.Description
                    , true, scalar.IsEditable, scalar.ColumnIODirection, out errorString);
            }

            foreach (var recset in RecsetCollection ?? new OptomizedObservableCollection <IDataListItemModel>())
            {
                if (recset.IsBlank)
                {
                    continue;
                }
                IEnumerable <IDataListItemModel> filledRecordSets = recset.Children.Where(c => !c.IsBlank && !c.HasError);
                IList <Dev2Column> cols = filledRecordSets.Select(child => DataListFactory.CreateDev2Column(child.Name, child.Description, child.IsEditable, child.ColumnIODirection))
                                          .ToList();

                result.TryCreateRecordsetTemplate(recset.Name, recset.Description, cols, true, recset.IsEditable, recset.ColumnIODirection, out errorString);
            }

            return(result);
        }
Esempio n. 3
0
        public void XmlTranslator_ConvertAndFilter_WhenRecordsetWithGaps_ExpectRowAnnotations()
        {
            //------------Setup for test--------------------------
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormatWithoutSystemTags);
            IBinaryDataList     dl1          = Dev2BinaryDataListFactory.CreateDataList(GlobalConstants.NullDataListID);

            string error;
            var    cols = new List <Dev2Column> {
                DataListFactory.CreateDev2Column("val", string.Empty)
            };

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

            dl1.TryCreateRecordsetValue("1", "val", "rs", 1, out error);
            dl1.TryCreateRecordsetValue("3", "val", "rs", 3, out error);

            //------------Execute Test---------------------------
            ErrorResultTO errors;
            var           actual = xmlConverter.ConvertAndFilter(dl1, "<root><rs><val/></rs></root>".ToStringBuilder(), out errors);

            actual = actual.Replace("\r", "").Replace("\n", "");

            //------------Assert Results-------------------------
            const string expected = "<rs index=\"1\"><val>1</val></rs><rs index=\"3\"><val>3</val></rs>";

            StringAssert.Contains(actual.ToString(), expected, "rowID attribute not present");
        }
Esempio n. 4
0
        public void DeSerializeToXMLFromBinary_InvertedIndexInsert_ValidXML_Expect_Sucess()
        {
            IBinaryDataList   dl = Dev2BinaryDataListFactory.CreateDataList();
            string            error;
            List <Dev2Column> cols = new List <Dev2Column>();
            ErrorResultTO     errors;

            cols.Add(DataListFactory.CreateDev2Column("f1", ""));
            cols.Add(DataListFactory.CreateDev2Column("f2", ""));
            cols.Add(DataListFactory.CreateDev2Column("f3", ""));
            IDataListTranslator xmlConverter = Dls.GetTranslator(XmlFormat);


            dl.TryCreateRecordsetTemplate("rs1", "", cols, true, out error);
            dl.TryCreateScalarTemplate(string.Empty, "scalar1", "", true, out error);
            dl.TryCreateScalarValue("scalar1Value", "scalar1", out error);
            dl.TryCreateRecordsetValue("rec1.f2.vale", "f2", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec1.f1.vale", "f1", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec1.f3.vale", "f3", "rs1", 1, out error);
            dl.TryCreateRecordsetValue("rec2.f1.vale", "f1", "rs1", 2, out error);
            dl.TryCreateRecordsetValue("rec2.f2.vale", "f2", "rs1", 2, out error);
            dl.TryCreateRecordsetValue("rec2.f3.vale", "f3", "rs1", 2, out error);

            DataListTranslatedPayloadTO tmp = xmlConverter.ConvertFrom(dl, out errors);

            string result = tmp.FetchAsString().ToString();

            Assert.AreEqual("<DataList><rs1><f1>rec1.f1.vale</f1><f2>rec1.f2.vale</f2><f3>rec1.f3.vale</f3></rs1><rs1><f1>rec2.f1.vale</f1><f2>rec2.f2.vale</f2><f3>rec2.f3.vale</f3></rs1><scalar1>scalar1Value</scalar1></DataList>", result);
        }
        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);
        }
Esempio n. 6
0
        /// <summary>
        /// Converts a list of data list item view models to a binary data list.
        /// </summary>
        /// <param name="listToConvert">The list to convert.</param>
        /// <param name="errorString">The error string.</param>
        /// <returns></returns>
        private IBinaryDataList ConvertIDataListItemModelsToIBinaryDataList(out string errorString)
        {
            errorString = string.Empty;
            IBinaryDataList result = Dev2BinaryDataListFactory.CreateDataList();

            foreach (IDataListItemModel scalar in ScalarCollection)
            {
                if (!scalar.IsBlank && !scalar.HasError)
                {
                    result.TryCreateScalarTemplate(string.Empty, scalar.Name, scalar.Description, true, scalar.IsEditable, scalar.ColumnIODirection, out errorString);
                }
            }

            foreach (IDataListItemModel recset in RecsetCollection)
            {
                if (!recset.IsBlank && !recset.HasError)
                {
                    IList <Dev2Column> cols = new List <Dev2Column>();
                    foreach (IDataListItemModel child in recset.Children.Where(c => !c.IsBlank && !c.HasError))
                    {
                        cols.Add(DataListFactory.CreateDev2Column(child.Name, child.Description, child.IsEditable, child.ColumnIODirection));
                    }

                    result.TryCreateRecordsetTemplate(recset.Name, recset.Description, cols, true, recset.IsEditable, recset.ColumnIODirection, out errorString);
                }
            }
            return(result);
        }
        public void MyTestInitialize()
        {
            string error;

            var dataListCompiler = DataListFactory.CreateDataListCompiler();

            _dl1 = Dev2BinaryDataListFactory.CreateDataList();
            _dl1.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("[[otherScalar]]", "myScalar", out error);

            _dl1.TryCreateScalarTemplate(string.Empty, "otherScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("testRegion", "otherScalar", out error);

            _dl1.TryCreateScalarTemplate(string.Empty, "scalar1", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("foobar", "scalar1", out error);

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

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

            _dl1.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl1.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl1.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            // skip 3 ;)

            _dl1.TryCreateRecordsetValue("r4.f1.value", "f1", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f2.value", "f2", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f3.value", "f3", "recset", 4, out error);

            dataListCompiler.PushBinaryDataList(_dl1.UID, _dl1, out _errors);
            //_compiler.UpsertSystemTag(dl1.UID, enSystemTag.EvaluateIteration, "true", out errors);

            /*  list 2 */
            _dl2 = Dev2BinaryDataListFactory.CreateDataList();
            _dl2.TryCreateScalarTemplate(string.Empty, "idx", "A scalar", true, out error);
            _dl2.TryCreateScalarValue("1", "idx", out error);

            _dl2.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl2.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl2.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            dataListCompiler.PushBinaryDataList(_dl2.UID, _dl2, out _errors);
            //_compiler.UpsertSystemTag(dl2.UID, enSystemTag.EvaluateIteration, "true", out errors);
        }
        public void MyTestInitialize()
        {
            string error;

            var dataListCompiler = DataListFactory.CreateDataListCompiler();

            _dl1 = Dev2BinaryDataListFactory.CreateDataList();
            _dl1.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("[[otherScalar]]", "myScalar", out error);

            _dl1.TryCreateScalarTemplate(string.Empty, "otherScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("testRegion", "otherScalar", out error);

            _dl1.TryCreateScalarTemplate(string.Empty, "scalar1", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("foobar", "scalar1", out error);

            IList<Dev2Column> cols = new List<Dev2Column>();
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));

            _dl1.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl1.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl1.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            // skip 3 ;)

            _dl1.TryCreateRecordsetValue("r4.f1.value", "f1", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f2.value", "f2", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f3.value", "f3", "recset", 4, out error);

            dataListCompiler.PushBinaryDataList(_dl1.UID, _dl1, out _errors);
            //_compiler.UpsertSystemTag(dl1.UID, enSystemTag.EvaluateIteration, "true", out errors);

            /*  list 2 */
            _dl2 = Dev2BinaryDataListFactory.CreateDataList();
            _dl2.TryCreateScalarTemplate(string.Empty, "idx", "A scalar", true, out error);
            _dl2.TryCreateScalarValue("1", "idx", out error);

            _dl2.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl2.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl2.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            dataListCompiler.PushBinaryDataList(_dl2.UID, _dl2, out _errors);
            //_compiler.UpsertSystemTag(dl2.UID, enSystemTag.EvaluateIteration, "true", out errors);
        }
Esempio n. 9
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
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the wizard data list for a workflow.
        /// </summary>
        /// <param name="dataList"></param>
        /// <returns>
        /// The string for the data list
        /// </returns>
        /// <exception cref="System.Exception">
        /// </exception>
        public string GetWizardDataListForWorkflow(string dataList)
        {
            IBinaryDataList newDl = Dev2BinaryDataListFactory.CreateDataList();
            ErrorResultTO   errors;
            var             dataListStringBuilder = new StringBuilder(dataList);
            Guid            dlID = ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), dataListStringBuilder, dataListStringBuilder, out errors);

            if (!errors.HasErrors())
            {
                IBinaryDataList dl = FetchBinaryDataList(dlID, out errors);
                if (!errors.HasErrors())
                {
                    IList <IBinaryDataListEntry> entries = dl.FetchAllEntries();
                    foreach (IBinaryDataListEntry entry in entries)
                    {
                        if (entry.IsRecordset)
                        {
                            if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None)
                            {
                                string tmpError;
                                newDl.TryCreateRecordsetTemplate(entry.Namespace, entry.Description, entry.Columns, true, out tmpError);
                            }
                        }
                        else
                        {
                            if (entry.ColumnIODirection != enDev2ColumnArgumentDirection.None)
                            {
                                string tmpError;
                                IBinaryDataListItem scalar = entry.FetchScalar();
                                newDl.TryCreateScalarTemplate(string.Empty, scalar.FieldName, entry.Description, true, out tmpError);
                            }
                        }
                    }
                    Guid newDlId = PushBinaryDataList(newDl.UID, newDl, out errors);
                    dataList = ConvertFrom(newDlId, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), enTranslationDepth.Shape, out errors).ToString();
                }
                else
                {
                    throw new Exception(errors.MakeUserReady());
                }
            }
            else
            {
                throw new Exception(errors.MakeUserReady());
            }
            return(dataList);
        }
Esempio n. 11
0
        public void UpsertWhereListStringExpectUpsertCorrectlyMultipleRecordset()
        {
            //------------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);
            //------------Execute Test---------------------------
            compiler.Upsert(dataList.UID, toUpsert, out _errors);
            //------------Assert Results-------------------------
            IList <IBinaryDataListEntry> binaryDataListEntries = dataList.FetchRecordsetEntries();
            IBinaryDataListEntry         binaryDataListEntry   = binaryDataListEntries[0];
            string errString;
            IList <IBinaryDataListItem> binaryDataListItems = binaryDataListEntry.FetchRecordAt(1, out errString);
            IBinaryDataListItem         binaryDataListItem  = binaryDataListItems[0];
            IBinaryDataListItem         binaryDataListItem2 = binaryDataListItems[1];
            string theValue = binaryDataListItem.TheValue;

            Assert.AreEqual("test11", theValue);
            theValue = binaryDataListItem2.TheValue;
            Assert.AreEqual("test21", theValue);
            binaryDataListItems = binaryDataListEntry.FetchRecordAt(2, out errString);
            binaryDataListItem  = binaryDataListItems[0];
            binaryDataListItem2 = binaryDataListItems[1];
            theValue            = binaryDataListItem.TheValue;
            Assert.AreEqual("test12", theValue);
            theValue = binaryDataListItem2.TheValue;

            Assert.AreEqual("test22", theValue);
        }
Esempio n. 12
0
        public void LargeBDL_Create_1Mil_5Cols_Recordset_Entries()
        {
            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 runs = 10000;

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

            using (dl1)
            {
                DateTime start1 = DateTime.Now;
                for (int i = 0; i < runs; 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 end1 = DateTime.Now;

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

                Console.WriteLine(result1 + @" seconds for " + runs + @" with 5 cols");

                Assert.IsTrue(result1 <= 1500, "Expected 500 seconds but got " + result1 + " seconds"); // Given 0.75 WAS : 0.75
                // Since Windblow really sucks at resource allocation, I need to adjust these for when it is forced into a multi-user enviroment!!!!
            }
        }
Esempio n. 13
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);
        }
        private Guid CreateDataList(enDev2ColumnArgumentDirection dir)
        {
            DataListFactory.CreateDataListCompiler();
            string        error;
            ErrorResultTO errors;

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

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

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

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

            dl1.TryCreateScalarTemplate(string.Empty, "myScalar", string.Empty, true, true, dir, out error);
            // dl1.Dispose();
            return(_compiler.PushBinaryDataList(dl1.UID, dl1, out errors));
        }
Esempio n. 15
0
        public void LargeBDL_Persist_1M_5Cols_Recordset_Entries()
        {
            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 runs = 10000; //1000000;

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


            DateTime start1 = DateTime.Now;

            for (int i = 0; i < runs; 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 end1 = DateTime.Now;

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

            Console.WriteLine(result1 + @" seconds for " + runs + @" with 5 cols");

            Assert.IsTrue(result1 <= 2600, "Expected 600 seconds but got " + result1 + " seconds"); // create speed
        }
        /// <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);
        }
        /*
         * There are plenty of test in the DynamicServicesEndPointTest that appear to test this functionality ;)
         */

        /// <summary>
        /// Build the template based upon the sent shape
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="error"></param>
        public static IBinaryDataList BuildTargetShape(string shape, out string error)
        {
            IBinaryDataList result = null;

            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(shape);
                XmlNodeList children = xDoc.DocumentElement.ChildNodes;
                error = string.Empty;

                HashSet <string> procssesNamespaces = new HashSet <string>();

                if (children != null)
                {
                    result = Dev2BinaryDataListFactory.CreateDataList();

                    foreach (XmlNode c in children)
                    {
                        XmlAttribute descAttribute     = null;
                        XmlAttribute columnIoDirection = null;
                        if (!DataListUtil.IsSystemTag(c.Name))
                        {
                            if (c.HasChildNodes)
                            {
                                IList <Dev2Column> cols = new List <Dev2Column>();
                                //recordset
                                if (c.ChildNodes != null)
                                {
                                    // build template
                                    if (!procssesNamespaces.Contains(c.Name))
                                    {
                                        // build columns
                                        foreach (XmlNode subc in c.ChildNodes)
                                        {
                                            // It is possible for the .Attributes property to be null, a check should be added
                                            if (subc.Attributes != null)
                                            {
                                                descAttribute = subc.Attributes["Description"];
                                            }
                                            if (descAttribute != null)
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, descAttribute.Value));
                                            }
                                            else
                                            {
                                                cols.Add(DataListFactory.CreateDev2Column(subc.Name, string.Empty));
                                            }
                                        }
                                        string myError = string.Empty;
                                        // It is possible for the .Attributes property to be null, a check should be added
                                        if (c.Attributes != null)
                                        {
                                            descAttribute     = c.Attributes["Description"];
                                            columnIoDirection = c.Attributes["ColumnIODirection"];
                                        }
                                        if (descAttribute != null)
                                        {
                                            var columnDirection = enDev2ColumnArgumentDirection.None;
                                            if (columnIoDirection != null)
                                            {
                                                Enum.TryParse(columnIoDirection.Value, true, out columnDirection);
                                            }
                                            if (!result.TryCreateRecordsetTemplate(c.Name, descAttribute.Value, cols, true, false, columnDirection, out myError))
                                            {
                                                error = myError;
                                            }
                                        }
                                        else
                                        {
                                            if (!result.TryCreateRecordsetTemplate(c.Name, string.Empty, cols, true, out myError))
                                            {
                                                error = myError;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //scalar
                                // It is possible for the .Attributes property to be null, a check should be added
                                if (c.Attributes != null)
                                {
                                    descAttribute     = c.Attributes["Description"];
                                    columnIoDirection = c.Attributes["ColumnIODirection"];
                                }
                                if (descAttribute != null)
                                {
                                    var columnDirection = enDev2ColumnArgumentDirection.None;
                                    if (columnIoDirection != null)
                                    {
                                        Enum.TryParse(columnIoDirection.Value, true, out columnDirection);
                                    }
                                    result.TryCreateScalarTemplate(string.Empty, c.Name, descAttribute.Value, true, false, columnDirection, out error);
                                }
                                else
                                {
                                    result.TryCreateScalarTemplate(string.Empty, c.Name, string.Empty, true, out error);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }

            return(result);
        }
Esempio n. 18
0
        public void MyTestInitialize()
        {
            string error;

            _dl1 = Dev2BinaryDataListFactory.CreateDataList();
            _dl1.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("myValue", "myScalar", out error);

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

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

            _dl1.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl1.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl1.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            // skip 3 ;)

            _dl1.TryCreateRecordsetValue("r4.f1.value", "f1", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f2.value", "f2", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f3.value", "f3", "recset", 4, out error);

            // create 2nd obj
            _dl2 = Dev2BinaryDataListFactory.CreateDataList();
            _dl2.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl2.TryCreateScalarValue("myValue2", "myScalar", out error);

            cols = new List <Dev2Column> {
                Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3")
            };

            _dl2.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl2.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset", 1, out error);

            _dl2.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset", 2, out error);

            _dl2.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset", 3, out error);
            _dl2.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset", 3, out error);
            _dl2.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset", 3, out error);

            // create 3rd obj
            _dl3 = Dev2BinaryDataListFactory.CreateDataList();
            _dl3.TryCreateScalarTemplate(string.Empty, "theScalar", "A scalar", true, out error);
            _dl3.TryCreateScalarValue("theValue", "theScalar", out error);

            cols = new List <Dev2Column> {
                Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3")
            };

            _dl3.TryCreateRecordsetTemplate("recset2", "a recordset", cols, true, out error);

            _dl3.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset2", 1, out error);
            _dl3.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset2", 1, out error);
            _dl3.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset2", 1, out error);

            _dl3.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset2", 2, out error);
            _dl3.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset2", 2, out error);
            _dl3.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset2", 2, out error);

            _dl3.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset2", 3, out error);
            _dl3.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset2", 3, out error);
            _dl3.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset2", 3, out error);

            // create 4th obj
            _dl4 = Dev2BinaryDataListFactory.CreateDataList();
            _dl4.TryCreateScalarTemplate(string.Empty, "theScalar", "A scalar", true, out error);
            _dl4.TryCreateScalarValue("theValue4", "theScalar", out error);
            _dl4.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl4.TryCreateScalarValue("myValue4", "myScalar", out error);

            cols = new List <Dev2Column> {
                Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3")
            };

            _dl4.TryCreateRecordsetTemplate("recset2", "a recordset", cols, true, out error);

            _dl4.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset2", 1, out error);
            _dl4.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset2", 1, out error);
            _dl4.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset2", 1, out error);

            _dl4.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset2", 2, out error);
            _dl4.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset2", 2, out error);
            _dl4.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset2", 2, out error);

            _dl4.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset2", 3, out error);
            _dl4.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset2", 3, out error);
            _dl4.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset2", 3, out error);



            // create 5th obj
            _dlWithBankScalar = Dev2BinaryDataListFactory.CreateDataList();
            _dlWithBankScalar.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dlWithBankScalar.TryCreateScalarValue("", "myScalar", out error);

            _dlWithPopulatedScalar = Dev2BinaryDataListFactory.CreateDataList();
            _dlWithPopulatedScalar.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dlWithPopulatedScalar.TryCreateScalarValue("CAKE!", "myScalar", out error);
        }
        public void MyTestInitialize()
        {
            string error;

            _dl1 = Dev2BinaryDataListFactory.CreateDataList();
            _dl1.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl1.TryCreateScalarValue("myValue", "myScalar", out error);

            IList<Dev2Column> cols = new List<Dev2Column>();
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f1"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f2"));
            cols.Add(Dev2BinaryDataListFactory.CreateColumn("f3"));

            _dl1.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl1.TryCreateRecordsetValue("r1.f1.value", "f1", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f2.value", "f2", "recset", 1, out error);
            _dl1.TryCreateRecordsetValue("r1.f3.value", "f3", "recset", 1, out error);

            _dl1.TryCreateRecordsetValue("r2.f1.value", "f1", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f2.value", "f2", "recset", 2, out error);
            _dl1.TryCreateRecordsetValue("r2.f3.value", "f3", "recset", 2, out error);

            // skip 3 ;)

            _dl1.TryCreateRecordsetValue("r4.f1.value", "f1", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f2.value", "f2", "recset", 4, out error);
            _dl1.TryCreateRecordsetValue("r4.f3.value", "f3", "recset", 4, out error);

            // create 2nd obj
            _dl2 = Dev2BinaryDataListFactory.CreateDataList();
            _dl2.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl2.TryCreateScalarValue("myValue2", "myScalar", out error);

            cols = new List<Dev2Column> { Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3") };

            _dl2.TryCreateRecordsetTemplate("recset", "a recordset", cols, true, out error);

            _dl2.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset", 1, out error);
            _dl2.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset", 1, out error);

            _dl2.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset", 2, out error);
            _dl2.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset", 2, out error);

            _dl2.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset", 3, out error);
            _dl2.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset", 3, out error);
            _dl2.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset", 3, out error);

            // create 3rd obj
            _dl3 = Dev2BinaryDataListFactory.CreateDataList();
            _dl3.TryCreateScalarTemplate(string.Empty, "theScalar", "A scalar", true, out error);
            _dl3.TryCreateScalarValue("theValue", "theScalar", out error);

            cols = new List<Dev2Column> { Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3") };

            _dl3.TryCreateRecordsetTemplate("recset2", "a recordset", cols, true, out error);

            _dl3.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset2", 1, out error);
            _dl3.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset2", 1, out error);
            _dl3.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset2", 1, out error);

            _dl3.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset2", 2, out error);
            _dl3.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset2", 2, out error);
            _dl3.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset2", 2, out error);

            _dl3.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset2", 3, out error);
            _dl3.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset2", 3, out error);
            _dl3.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset2", 3, out error);

            // create 4th obj
            _dl4 = Dev2BinaryDataListFactory.CreateDataList();
            _dl4.TryCreateScalarTemplate(string.Empty, "theScalar", "A scalar", true, out error);
            _dl4.TryCreateScalarValue("theValue4", "theScalar", out error);
            _dl4.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dl4.TryCreateScalarValue("myValue4", "myScalar", out error);

            cols = new List<Dev2Column> { Dev2BinaryDataListFactory.CreateColumn("f1"), Dev2BinaryDataListFactory.CreateColumn("f2"), Dev2BinaryDataListFactory.CreateColumn("f3") };

            _dl4.TryCreateRecordsetTemplate("recset2", "a recordset", cols, true, out error);

            _dl4.TryCreateRecordsetValue("r1a.f1.value2", "f1", "recset2", 1, out error);
            _dl4.TryCreateRecordsetValue("r1a.f2.value2", "f2", "recset2", 1, out error);
            _dl4.TryCreateRecordsetValue("r1a.f3.value2", "f3", "recset2", 1, out error);

            _dl4.TryCreateRecordsetValue("r2a.f1.value2", "f1", "recset2", 2, out error);
            _dl4.TryCreateRecordsetValue("r2a.f2.value2", "f2", "recset2", 2, out error);
            _dl4.TryCreateRecordsetValue("r2a.f3.value2", "f3", "recset2", 2, out error);

            _dl4.TryCreateRecordsetValue("r3a.f1.value2", "f1", "recset2", 3, out error);
            _dl4.TryCreateRecordsetValue("r3a.f2.value2", "f2", "recset2", 3, out error);
            _dl4.TryCreateRecordsetValue("r3a.f3.value2", "f3", "recset2", 3, out error);



            // create 5th obj
            _dlWithBankScalar = Dev2BinaryDataListFactory.CreateDataList();
            _dlWithBankScalar.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dlWithBankScalar.TryCreateScalarValue("", "myScalar", out error);

            _dlWithPopulatedScalar = Dev2BinaryDataListFactory.CreateDataList();
            _dlWithPopulatedScalar.TryCreateScalarTemplate(string.Empty, "myScalar", "A scalar", true, out error);
            _dlWithPopulatedScalar.TryCreateScalarValue("CAKE!", "myScalar", out error);
        }
Esempio n. 20
0
        /// <summary>
        /// Build the template based upon the sent shape
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="error"></param>
        private IBinaryDataList BuildTargetShape(StringBuilder shape, out string error)
        {
            IBinaryDataList result = null;

            error = null;
            try
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(shape.ToString());
                if (xDoc.DocumentElement != null)
                {
                    var children = xDoc.DocumentElement.ChildNodes;
                    error = string.Empty;

                    HashSet <string> procssesNamespaces = new HashSet <string>();

                    result = Dev2BinaryDataListFactory.CreateDataList();

                    foreach (XmlNode c in children)
                    {
                        if (!DataListUtil.IsSystemTag(c.Name))
                        {
                            if (c.HasChildNodes)
                            {
                                IList <Dev2Column> cols = new List <Dev2Column>();
                                // build template for Recordset
                                if (!procssesNamespaces.Contains(c.Name))
                                {
                                    // build columns
                                    foreach (XmlNode subc in c.ChildNodes)
                                    {
                                        // It is possible for the .Attributes property to be null, a check should be added
                                        if (subc.Attributes != null)
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name,
                                                                                      ParseDescription(subc.Attributes[Description]),
                                                                                      ParseIsEditable(subc.Attributes[IsEditable]),
                                                                                      ParseColumnIODirection(subc.Attributes[GlobalConstants.DataListIoColDirection])));
                                        }
                                        else
                                        {
                                            cols.Add(DataListFactory.CreateDev2Column(subc.Name,
                                                                                      ParseDescription(null),
                                                                                      ParseIsEditable(null),
                                                                                      ParseColumnIODirection(null)));
                                        }
                                    }

                                    string myError;

                                    if (c.Attributes != null)
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name,
                                                                               ParseDescription(c.Attributes[Description]),
                                                                               cols,
                                                                               true,
                                                                               ParseIsEditable(c.Attributes[IsEditable]),
                                                                               ParseColumnIODirection(c.Attributes[GlobalConstants.DataListIoColDirection]),
                                                                               out myError))
                                        {
                                            error = myError;
                                        }
                                    }
                                    else
                                    {
                                        if (!result.TryCreateRecordsetTemplate(c.Name,
                                                                               ParseDescription(null),
                                                                               cols,
                                                                               true,
                                                                               ParseIsEditable(null),
                                                                               ParseColumnIODirection(null),
                                                                               out myError))
                                        {
                                            error = myError;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //scalar
                                if (c.Attributes != null)
                                {
                                    result.TryCreateScalarTemplate(string.Empty,
                                                                   c.Name,
                                                                   ParseDescription(c.Attributes[Description]),
                                                                   true,
                                                                   ParseIsEditable(c.Attributes[IsEditable]),
                                                                   ParseColumnIODirection(c.Attributes[GlobalConstants.DataListIoColDirection]),
                                                                   out error);
                                }
                                else
                                {
                                    result.TryCreateScalarTemplate(string.Empty,
                                                                   c.Name,
                                                                   ParseDescription(null),
                                                                   true,
                                                                   ParseIsEditable(null),
                                                                   ParseColumnIODirection(null),
                                                                   out error);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(result);
        }