/// <summary> /// Executes the tests (main method of this executable!). /// </summary> public static void RunTest() { XmlNode startNode; XmlNode curGroup; Thread groupThread; TestGroup myGroup; String testcase; new TAppSettingsManager(true); testcase = TAppSettingsManager.GetValue("testcase"); Global.StartClientID = TAppSettingsManager.GetInt16("startclientid"); rnd = new System.Random(DateTime.Now.Millisecond); // Init try { parser = new TXMLParser(TAppSettingsManager.GetValue("testscript"), false); startNode = parser.GetDocument().DocumentElement; } catch (Exception E) { System.Console.WriteLine("{0}: trouble in RunTest", DateTime.Now.ToLongTimeString()); System.Console.WriteLine("{0}: {1}", DateTime.Now.ToLongTimeString(), E.Message); return; } new TLogging(@"..\..\log\PetraMultiStart.log"); // TheConnector = new Ict.Petra.ServerAdmin.App.Core.Connector.TConnector(); // TheConnector.GetServerConnection(TAppSettingsManager.ConfigFileName, out TRemote); TRemote = new TMServerAdminNamespace().WebConnectors; CreateTestUsers(); if (startNode.Name.ToLower() == "tests") { startNode = startNode.FirstChild; while ((startNode != null) && (startNode.Name.ToLower() == "test") && (TXMLParser.GetAttribute(startNode, "name") != testcase)) { startNode = startNode.NextSibling; } } if (startNode == null) { Console.WriteLine("{0}: cannot find testcase {1}", DateTime.Now.ToLongTimeString(), testcase); return; } while (true) { // restart the whole test scenario if (startNode.Name.ToLower() == "test") { Global.Filename = TXMLParser.GetAttribute(startNode, "app"); // kill instances of previous test KillAllProcesses(Global.Filename.Substring(0, Global.Filename.IndexOf('.'))); Global.Configfile = TXMLParser.GetAttribute(startNode, "config"); curGroup = startNode.FirstChild; while ((curGroup != null) && (curGroup.Name == "clientgroup")) { if (TXMLParser.GetBoolAttribute(curGroup, "active", true) != false) { myGroup = new TestGroup(curGroup); groupThread = new Thread(myGroup.Run); groupThread.Start(); } curGroup = curGroup.NextSibling; } } Thread.CurrentThread.Join(); System.Console.WriteLine("{0}: All threads have stopped", DateTime.Now.ToLongTimeString()); if (TXMLParser.GetBoolAttribute(startNode, "loop", true) == false) { return; } Thread.Sleep(5 * 60 * 1000); // wait for 5 minutes before restarting } }
/// <summary> /// Read the parameters from a text file (xml format); /// used for loading settings /// </summary> /// <param name="filename">relative or absolute filename /// </param> /// <returns>void</returns> public void Load(String filename) { XmlNode startNode; XmlNode node; TXMLParser myDoc; String level; String column; int levelNr; int columnNr; int subreport; myDoc = new TXMLParser(filename, false); try { startNode = myDoc.GetDocument().DocumentElement; if (startNode.Name.ToLower() == "parameters") { node = startNode.FirstChild; while (node != null) { if (node.Name == "Parameter") { column = TXMLParser.GetAttribute(node, "column"); level = TXMLParser.GetAttribute(node, "level"); subreport = TXMLParser.GetIntAttribute(node, "subreport"); columnNr = -1; levelNr = -1; if (column.Length != 0) { columnNr = (int)StringHelper.StrToInt(column); } if (level.Length != 0) { levelNr = (int)StringHelper.StrToInt(level); } Add(TXMLParser.GetAttribute(node, "id"), TVariant.DecodeFromString(TXMLParser.GetAttribute(node, "value")), columnNr, levelNr, subreport); } node = node.NextSibling; } } } catch (Exception E) { throw new Exception(E.Message); } }
/// <summary> /// Reads the binary data of the image and returns it as a formatted Base64 string /// which then can be used in a .resx file. /// It seems for bitmaps for buttons and toolbars and menuitems, we need gif bitmaps /// but for window icons we need ico files /// </summary> /// <param name="AImageFileName">Full file name of the image</param> /// <param name="AImageOrIcon">is this an icon or bitmap</param> /// <returns>the formatted Base64 representation of the image</returns> private string Image2Base64(string AImageFileName, string AImageOrIcon) { if (!File.Exists(AImageFileName)) { return ""; } // AlanP added this retry loop after getting fed up with generating the solution and finding that // access to go.gif.resx is denied. The assumption is that multi-threaded code generation // wants to access a well-used image file in multiple places. The resx file is only a temporary // file. A few lines down we delete it, which is probably why it fails to open. // If that is not the cause the code shouldn't do any harm. int nTries = 0; int nTriesLimit = 4; // 4 tries over 2 seconds should be enough! string exceptionMsg = String.Empty; TXMLParser parser = null; while (nTries < nTriesLimit) { try { System.Resources.ResXResourceWriter w = new System.Resources.ResXResourceWriter(AImageFileName + ".resx"); if (AImageOrIcon == "Icon") { w.AddResource(AImageFileName, new Icon(AImageFileName)); } else if ((AImageOrIcon == "Bitmap") && (Path.GetExtension(AImageFileName) == ".ico")) { w.AddResource(AImageFileName, (new Icon(AImageFileName)).ToBitmap()); } else { w.AddResource(AImageFileName, new Bitmap(AImageFileName)); } w.Close(); parser = new TXMLParser(AImageFileName + ".resx", false); File.Delete(AImageFileName + ".resx"); nTries = 999; // success! } catch (Exception ex) // probably an IO exception { nTries++; parser = null; exceptionMsg = ex.Message; Application.DoEvents(); System.Threading.Thread.Sleep(500); } } if ((nTries == nTriesLimit) || (parser == null)) { throw new IOException(String.Format( "The system had {0} attempts to create, parse and delete the file {1}.resx as a resource but the following IO exception was raised: {2}", nTries, AImageFileName, exceptionMsg)); } XmlDocument doc = parser.GetDocument(); XmlNode child = doc.DocumentElement.FirstChild; while (child != null) { if ((child.Name == "data") && (TYml2Xml.GetAttribute(child, "name") == AImageFileName)) { return child.InnerText; } child = child.NextSibling; } return string.Empty; }
/// <summary> /// code for generating typed datasets /// </summary> /// <param name="AInputXmlfile"></param> /// <param name="AOutputPath"></param> /// <param name="ANameSpace"></param> /// <param name="store"></param> /// <param name="groups"></param> /// <param name="AFilename"></param> public static void CreateTypedDataSets(String AInputXmlfile, String AOutputPath, String ANameSpace, TDataDefinitionStore store, string[] groups, string AFilename) { Console.WriteLine("processing dataset " + ANameSpace); string templateDir = TAppSettingsManager.GetValue("TemplateDir", true); ProcessTemplate Template = new ProcessTemplate(templateDir + Path.DirectorySeparatorChar + "ORM" + Path.DirectorySeparatorChar + "DataSet.cs"); Template.AddSnippetsFromOtherFile(templateDir + Path.DirectorySeparatorChar + "ORM" + Path.DirectorySeparatorChar + "DataTable.cs"); DataSetTableIdCounter = Convert.ToInt16(TAppSettingsManager.GetValue("StartTableId")); // load default header with license and copyright Template.SetCodelet("GPLFILEHEADER", ProcessTemplate.LoadEmptyFileComment(templateDir)); Template.SetCodelet("NAMESPACE", ANameSpace); // if no dataset is defined yet in the xml file, the following variables can be empty Template.AddToCodelet("USINGNAMESPACES", ""); Template.AddToCodelet("CONTENTDATASETSANDTABLESANDROWS", ""); TXMLParser parserDataSet = new TXMLParser(AInputXmlfile, false); XmlDocument myDoc = parserDataSet.GetDocument(); XmlNode startNode = myDoc.DocumentElement; if (startNode.Name.ToLower() == "petradatasets") { XmlNode cur = TXMLParser.NextNotBlank(startNode.FirstChild); while ((cur != null) && (cur.Name.ToLower() == "importunit")) { Template.AddToCodelet("USINGNAMESPACES", "using " + TXMLParser.GetAttribute(cur, "name") + ";" + Environment.NewLine); cur = TXMLParser.GetNextEntity(cur); } while ((cur != null) && (cur.Name.ToLower() == "dataset")) { ProcessTemplate snippetDataset = Template.GetSnippet("TYPEDDATASET"); string datasetname = TXMLParser.GetAttribute(cur, "name"); snippetDataset.SetCodelet("DATASETNAME", datasetname); // INITCONSTRAINTS and INITRELATIONS can be empty snippetDataset.AddToCodelet("INITCONSTRAINTS", ""); snippetDataset.AddToCodelet("INITRELATIONS", ""); SortedList <string, TDataSetTable>tables = new SortedList <string, TDataSetTable>(); XmlNode curChild = cur.FirstChild; while (curChild != null) { if ((curChild.Name.ToLower() == "table") && TXMLParser.HasAttribute(curChild, "sqltable")) { bool OverloadTable = false; string tabletype = TTable.NiceTableName(TXMLParser.GetAttribute(curChild, "sqltable")); string variablename = (TXMLParser.HasAttribute(curChild, "name") ? TXMLParser.GetAttribute(curChild, "name") : tabletype); TDataSetTable table = new TDataSetTable( TXMLParser.GetAttribute(curChild, "sqltable"), tabletype, variablename, store.GetTable(tabletype)); XmlNode tableNodes = curChild.FirstChild; while (tableNodes != null) { if (tableNodes.Name.ToLower() == "customfield") { // eg. BestAddress in PartnerEditTDS.PPartnerLocation TTableField customField = new TTableField(); customField.strName = TXMLParser.GetAttribute(tableNodes, "name"); customField.strTypeDotNet = TXMLParser.GetAttribute(tableNodes, "type"); customField.strDescription = TXMLParser.GetAttribute(tableNodes, "comment"); customField.strDefault = TXMLParser.GetAttribute(tableNodes, "initial"); table.grpTableField.Add(customField); OverloadTable = true; } if (tableNodes.Name.ToLower() == "field") { // eg. UnitName in PartnerEditTDS.PPerson TTableField field = new TTableField(store.GetTable(TXMLParser.GetAttribute(tableNodes, "sqltable")). GetField(TXMLParser.GetAttribute(tableNodes, "sqlfield"))); if (TXMLParser.HasAttribute(tableNodes, "name")) { field.strNameDotNet = TXMLParser.GetAttribute(tableNodes, "name"); } if (TXMLParser.HasAttribute(tableNodes, "comment")) { field.strDescription = TXMLParser.GetAttribute(tableNodes, "comment"); } table.grpTableField.Add(field); OverloadTable = true; } if (tableNodes.Name.ToLower() == "primarykey") { TConstraint primKeyConstraint = table.GetPrimaryKey(); primKeyConstraint.strThisFields = StringHelper.StrSplit(TXMLParser.GetAttribute(tableNodes, "thisFields"), ","); OverloadTable = true; } tableNodes = tableNodes.NextSibling; } if (OverloadTable) { tabletype = datasetname + TTable.NiceTableName(table.strName); if (TXMLParser.HasAttribute(curChild, "name")) { tabletype = datasetname + TXMLParser.GetAttribute(curChild, "name"); } table.strDotNetName = tabletype; table.strVariableNameInDataset = variablename; // set tableid table.iOrder = DataSetTableIdCounter++; // TODO: can we derive from the base table, and just overload a few functions? CodeGenerationTable.InsertTableDefinition(snippetDataset, table, store.GetTable(table.tableorig), "TABLELOOP"); CodeGenerationTable.InsertRowDefinition(snippetDataset, table, store.GetTable(table.tableorig), "TABLELOOP"); } tables.Add(variablename, table); AddTableToDataset(tabletype, variablename, snippetDataset); } else if ((curChild.Name.ToLower() == "table") && TXMLParser.HasAttribute(curChild, "customtable")) { // this refers to a custom table of another dataset, eg. BestAddressTDSLocation // for the moment, such a table cannot have additional fields if (curChild.HasChildNodes) { throw new Exception( String.Format( "CreateTypedDataSets(): At the moment, a custom table referenced from another dataset cannot have additional fields. Dataset: {0}, Table: {1}", datasetname, TXMLParser.HasAttribute(curChild, "customtable"))); } // customtable has to contain the name of the dataset, eg. BestAddressTDSLocation string tabletype = TXMLParser.GetAttribute(curChild, "customtable"); string variablename = (TXMLParser.HasAttribute(curChild, "name") ? TXMLParser.GetAttribute(curChild, "name") : tabletype); AddTableToDataset(tabletype, variablename, snippetDataset); } if (curChild.Name.ToLower() == "customrelation") { ProcessTemplate tempSnippet = Template.GetSnippet("INITRELATIONS"); tempSnippet.SetCodelet("RELATIONNAME", TXMLParser.GetAttribute(curChild, "name")); tempSnippet.SetCodelet("TABLEVARIABLENAMEPARENT", TXMLParser.GetAttribute(curChild, "parentTable")); tempSnippet.SetCodelet("TABLEVARIABLENAMECHILD", TXMLParser.GetAttribute(curChild, "childTable")); tempSnippet.SetCodelet("COLUMNNAMESPARENT", StringCollectionToValuesFormattedForArray(tables, TXMLParser.GetAttribute(curChild, "parentTable"), StringHelper.StrSplit(TXMLParser.GetAttribute(curChild, "parentFields"), ","))); tempSnippet.SetCodelet("COLUMNNAMESCHILD", StringCollectionToValuesFormattedForArray(tables, TXMLParser.GetAttribute(curChild, "childTable"), StringHelper.StrSplit(TXMLParser.GetAttribute(curChild, "childFields"), ","))); tempSnippet.SetCodelet("CREATECONSTRAINTS", TXMLParser.GetBoolAttribute(curChild, "createConstraints") ? "true" : "false"); snippetDataset.InsertSnippet("INITRELATIONS", tempSnippet); } if (curChild.Name.ToLower() == "customtable") { string variablename = TXMLParser.GetAttribute(curChild, "name"); string tabletype = datasetname + TXMLParser.GetAttribute(curChild, "name"); XmlNode customTableNodes = curChild.FirstChild; TDataSetTable customTable = new TDataSetTable( tabletype, tabletype, variablename, null); // set TableId customTable.iOrder = DataSetTableIdCounter++; customTable.strDescription = TXMLParser.GetAttribute(curChild, "comment"); customTable.strName = tabletype; customTable.strDotNetName = tabletype; customTable.strVariableNameInDataset = variablename; while (customTableNodes != null) { if (customTableNodes.Name.ToLower() == "customfield") { TTableField customField = new TTableField(); customField.strName = TXMLParser.GetAttribute(customTableNodes, "name"); customField.strTypeDotNet = TXMLParser.GetAttribute(customTableNodes, "type"); customField.strDescription = TXMLParser.GetAttribute(customTableNodes, "comment"); customField.strDefault = TXMLParser.GetAttribute(customTableNodes, "initial"); customTable.grpTableField.Add(customField); } if (customTableNodes.Name.ToLower() == "field") { // eg. SelectedSiteKey in PartnerEditTDS.MiscellaneousData TTableField field = new TTableField(store.GetTable(TXMLParser.GetAttribute(customTableNodes, "sqltable")). GetField(TXMLParser.GetAttribute(customTableNodes, "sqlfield"))); if (TXMLParser.HasAttribute(customTableNodes, "name")) { field.strNameDotNet = TXMLParser.GetAttribute(customTableNodes, "name"); } if (TXMLParser.HasAttribute(customTableNodes, "comment")) { field.strDescription = TXMLParser.GetAttribute(customTableNodes, "comment"); } customTable.grpTableField.Add(field); } if (customTableNodes.Name.ToLower() == "primarykey") { TConstraint primKeyConstraint = new TConstraint(); primKeyConstraint.strName = "PK"; primKeyConstraint.strType = "primarykey"; primKeyConstraint.strThisFields = StringHelper.StrSplit(TXMLParser.GetAttribute(customTableNodes, "thisFields"), ","); customTable.grpConstraint.Add(primKeyConstraint); } customTableNodes = customTableNodes.NextSibling; } tables.Add(tabletype, customTable); AddTableToDataset(tabletype, variablename, snippetDataset); CodeGenerationTable.InsertTableDefinition(snippetDataset, customTable, null, "TABLELOOP"); CodeGenerationTable.InsertRowDefinition(snippetDataset, customTable, null, "TABLELOOP"); } curChild = curChild.NextSibling; } foreach (TDataSetTable table in tables.Values) { // todo? also other constraints, not only from original table? foreach (TConstraint constraint in table.grpConstraint) { if ((constraint.strType == "foreignkey") && tables.ContainsKey(constraint.strOtherTable)) { TDataSetTable otherTable = (TDataSetTable)tables[constraint.strOtherTable]; ProcessTemplate tempSnippet = Template.GetSnippet("INITCONSTRAINTS"); tempSnippet.SetCodelet("TABLEVARIABLENAME1", table.tablealias); tempSnippet.SetCodelet("TABLEVARIABLENAME2", otherTable.tablealias); tempSnippet.SetCodelet("CONSTRAINTNAME", TTable.NiceKeyName(constraint)); tempSnippet.SetCodelet("COLUMNNAMES1", StringCollectionToValuesFormattedForArray(constraint.strThisFields)); tempSnippet.SetCodelet("COLUMNNAMES2", StringCollectionToValuesFormattedForArray(constraint.strOtherFields)); snippetDataset.InsertSnippet("INITCONSTRAINTS", tempSnippet); } } } Template.InsertSnippet("CONTENTDATASETSANDTABLESANDROWS", snippetDataset); cur = TXMLParser.GetNextEntity(cur); } } Template.FinishWriting(AOutputPath + Path.DirectorySeparatorChar + AFilename + "-generated.cs", ".cs", true); }
/// <summary> /// main function for generating access methods for typed data sets /// </summary> /// <param name="AInputXmlfile"></param> /// <param name="AOutputPath"></param> /// <param name="ANameSpace"></param> /// <param name="store"></param> /// <param name="groups"></param> /// <param name="AFilename"></param> public static void CreateTypedDataSets(String AInputXmlfile, String AOutputPath, String ANameSpace, TDataDefinitionStore store, string[] groups, string AFilename) { Console.WriteLine("processing dataset " + ANameSpace); string templateDir = TAppSettingsManager.GetValue("TemplateDir", true); ProcessTemplate Template = new ProcessTemplate(templateDir + Path.DirectorySeparatorChar + "ORM" + Path.DirectorySeparatorChar + "DataSetAccess.cs"); // load default header with license and copyright Template.SetCodelet("GPLFILEHEADER", ProcessTemplate.LoadEmptyFileComment(templateDir)); Template.SetCodelet("NAMESPACE", ANameSpace); // if no dataset is defined yet in the xml file, the following variables can be empty Template.AddToCodelet("USINGNAMESPACES", ""); Template.AddToCodelet("CONTENTDATASETSANDTABLESANDROWS", ""); Template.AddToCodelet("USINGNAMESPACES", "using " + ANameSpace.Replace(".Server.", ".Shared.") + ";" + Environment.NewLine, false); TXMLParser parserDataSet = new TXMLParser(AInputXmlfile, false); XmlDocument myDoc = parserDataSet.GetDocument(); XmlNode startNode = myDoc.DocumentElement; if (startNode.Name.ToLower() == "petradatasets") { XmlNode cur = TXMLParser.NextNotBlank(startNode.FirstChild); while ((cur != null) && (cur.Name.ToLower() == "importunit")) { Template.AddToCodelet("USINGNAMESPACES", "using " + TXMLParser.GetAttribute(cur, "name") + ";" + Environment.NewLine, false); Template.AddToCodelet("USINGNAMESPACES", "using " + TXMLParser.GetAttribute(cur, "name").Replace(".Shared.", ".Server.") + ".Access;" + Environment.NewLine, false); cur = TXMLParser.GetNextEntity(cur); } while ((cur != null) && (cur.Name.ToLower() == "dataset")) { ProcessTemplate snippetDataset = Template.GetSnippet("TYPEDDATASET"); string datasetname = TXMLParser.GetAttribute(cur, "name"); snippetDataset.SetCodelet("DATASETNAME", datasetname); ProcessTemplate snippetSubmitChanges = snippetDataset.GetSnippet("SUBMITCHANGESFUNCTION"); snippetSubmitChanges.AddToCodelet("DATASETNAME", datasetname); List <TDataSetTable>tables = new List <TDataSetTable>(); XmlNode curChild = cur.FirstChild; // first collect the tables while (curChild != null) { if (curChild.Name.ToLower() == "table") { string tabletype = TTable.NiceTableName(TXMLParser.GetAttribute(curChild, "sqltable")); string variablename = (TXMLParser.HasAttribute(curChild, "name") ? TXMLParser.GetAttribute(curChild, "name") : tabletype); TDataSetTable table = new TDataSetTable( TXMLParser.GetAttribute(curChild, "sqltable"), tabletype, variablename, store.GetTable(tabletype)); tables.Add(table); } curChild = curChild.NextSibling; } foreach (TDataSetTable table in tables) { AddTableToDataset(tables, store.GetTable(table.tableorig), table.tablename, table.tablealias, snippetDataset, snippetSubmitChanges); } // there is one codelet for the dataset name. // only add the full submitchanges function if there are any table to submit if (snippetSubmitChanges.FCodelets.Count > 1) { snippetDataset.InsertSnippet("SUBMITCHANGESFUNCTION", snippetSubmitChanges); } else { snippetDataset.AddToCodelet("SUBMITCHANGESFUNCTION", ""); } Template.InsertSnippet("CONTENTDATASETSANDTABLESANDROWS", snippetDataset); cur = TXMLParser.GetNextEntity(cur); } } Template.FinishWriting(AOutputPath + Path.DirectorySeparatorChar + AFilename + "-generated.cs", ".cs", true); }
/// <summary> /// load the dataset tables /// </summary> public static SortedList <string, TTable>LoadDatasetTables(string AICTPath, string ADataSetTypeWithNamespace, TCodeStorage ACodeStorage, string APluginPath) { if (FDatasetTables == null) { FDatasetTables = new SortedList <string, SortedList <string, TTable>>(); } FCodeStorage = ACodeStorage; if (!ADataSetTypeWithNamespace.StartsWith("Ict.Petra.Shared") && !ADataSetTypeWithNamespace.StartsWith("Ict.Petra.Plugins")) { throw new Exception("the DatasetType must contain the full namespace, starting with Ict.Petra.Shared or Ict.Petra.Plugins"); } if (FDatasetTables.ContainsKey(ADataSetTypeWithNamespace)) { FCurrentDataset = FDatasetTables[ADataSetTypeWithNamespace]; return FCurrentDataset; } string[] datasetTypeSplit = ADataSetTypeWithNamespace.Split(new char[] { '.' }); string module = datasetTypeSplit[3]; string datasetName = datasetTypeSplit[datasetTypeSplit.Length - 1]; // find the correct xml file for the dataset. // look in Ict/Petra/Shared/lib/MODULE/data string dataPath = AICTPath + "/Petra/Shared/lib/" + module + "/data/"; if (ADataSetTypeWithNamespace.StartsWith("Ict.Petra.Plugins")) { int start = "Ict.Petra.Plugins.".Length; int end = ADataSetTypeWithNamespace.IndexOf(".", start); string PluginName = ADataSetTypeWithNamespace.Substring(start, end - start); dataPath = AICTPath + "/Petra/Plugins/" + PluginName + "/data/"; } DirectoryInfo directory = new DirectoryInfo(dataPath); FileInfo[] xmlFiles = directory.GetFiles("*.xml"); XmlNode datasetNode = null; foreach (FileInfo fileinfo in xmlFiles) { if (datasetNode == null) { TXMLParser parser = new TXMLParser(dataPath + "/" + fileinfo.Name, false); datasetNode = parser.GetDocument().SelectSingleNode(String.Format("//DataSet[@name='{0}']", datasetName)); } } if ((datasetNode == null) && File.Exists(APluginPath)) { // also check the plugin directory of the yaml file, for plugins can have a file TypedDataSets.xml TXMLParser parser = new TXMLParser(APluginPath, false); datasetNode = parser.GetDocument().SelectSingleNode(String.Format("//DataSet[@name='{0}']", datasetName)); } if (datasetNode == null) { throw new Exception("cannot find the xml file for dataset " + ADataSetTypeWithNamespace); } SortedList <string, TTable>result = new SortedList <string, TTable>(); XmlNodeList tables = datasetNode.SelectNodes("Table|CustomTable"); foreach (XmlNode tableNode in tables) { TTable table = new TTable(); string tablename; if ((tableNode.Name == "Table") && TXMLParser.HasAttribute(tableNode, "sqltable")) { tablename = TTable.NiceTableName(tableNode.Attributes["sqltable"].Value); table.Assign(FPetraXMLStore.GetTable(tablename)); table.strVariableNameInDataset = TXMLParser.HasAttribute(tableNode, "name") ? tableNode.Attributes["name"].Value : tablename; if ((tableNode.SelectNodes("CustomField").Count > 0) || (tableNode.SelectNodes("Field").Count > 0)) { table.strDotNetName = datasetName + tablename; } } else if ((tableNode.Name == "Table") && TXMLParser.HasAttribute(tableNode, "customtable")) { table = new TTable(); tablename = tableNode.Attributes["customtable"].Value; table.strName = tablename; table.strDotNetName = tablename; table.strVariableNameInDataset = TXMLParser.HasAttribute(tableNode, "name") ? tableNode.Attributes["name"].Value : tablename; } else { table = new TTable(); tablename = tableNode.Attributes["name"].Value; table.strName = tablename; table.strDotNetName = datasetName + tablename; table.strVariableNameInDataset = tablename; } // add the custom fields if there are any XmlNodeList customFields = tableNode.SelectNodes("CustomField"); foreach (XmlNode customField in customFields) { TTableField newField = new TTableField(); newField.strName = customField.Attributes["name"].Value; newField.strNameDotNet = newField.strName; newField.strType = customField.Attributes["type"].Value; newField.strTypeDotNet = customField.Attributes["type"].Value; newField.strTableName = tablename; newField.strDescription = ""; newField.bNotNull = TXMLParser.HasAttribute(customField, "notnull") && TXMLParser.GetAttribute(customField, "notnull").ToLower() == "true"; table.grpTableField.Add(newField); } // add other fields from other tables that are defined in petra.xml XmlNodeList otherFields = tableNode.SelectNodes("Field"); foreach (XmlNode otherField in otherFields) { TTable otherTable = FPetraXMLStore.GetTable(otherField.Attributes["sqltable"].Value); TTableField newField = new TTableField(otherTable.GetField(otherField.Attributes["sqlfield"].Value)); if (TXMLParser.HasAttribute(otherField, "name")) { newField.strNameDotNet = otherField.Attributes["name"].Value; } newField.strTableName = tablename; table.grpTableField.Add(newField); } result.Add(table.strVariableNameInDataset, table); } FDatasetTables.Add(ADataSetTypeWithNamespace, result); FCurrentDataset = result; return result; }