예제 #1
0
        /// <summary>
        /// Retrieves the table schema of an injected database
        /// </summary>
        /// <param name="TableData">The table data this should be stored into</param>
        public void PopulateTableStructure(ref GlobalDS.Table TableData)
        {
            int FieldCount;

            FieldCount = GetFieldCount(TableData.ObjectID);

            for (int i = 0; i < FieldCount; i++)
            {
                TableData.AddField(GetFieldData(TableData.ObjectID, i));
            }
        }
예제 #2
0
        private void DeserializeSchemaXml(XmlNode TargetNode)
        {
            // Init member vars
            _Username = ""; _AllTablesRetrieved = true;

            if (TargetNode.Attributes["username"] != null)
            {
                _Username = TargetNode.Attributes["username"].InnerText;
            }

            if (TargetNode.Attributes["tablesfinished"] != null)
            {
                _AllTablesRetrieved = bool.Parse(TargetNode.Attributes["tablesfinished"].InnerText);
            }

            XmlNodeList Tables = TargetNode.SelectNodes("table");

            if (Tables.Count > 0)
            {
                List <GlobalDS.Table> TableList = new List <GlobalDS.Table>();

                foreach (XmlNode ExtractedTable in Tables)
                {
                    GlobalDS.Table ThisTable = new GlobalDS.Table();

                    if (ExtractedTable.Attributes["name"] != null && ExtractedTable.Attributes["id"] != null)
                    {
                        ThisTable.Name     = ExtractedTable.Attributes["name"].InnerText;
                        ThisTable.ObjectID = System.Int32.Parse(ExtractedTable.Attributes["id"].InnerText);

                        if (ExtractedTable.Attributes["recordcount"] != null)
                        {
                            ThisTable.RecordCount = System.Int64.Parse(ExtractedTable.Attributes["recordcount"].InnerText);
                        }

                        XmlNodeList Fields = ExtractedTable.SelectNodes("field");
                        foreach (XmlNode ExtractedField in Fields)
                        {
                            GlobalDS.Field ThisField = new GlobalDS.Field();

                            if (ExtractedField.Attributes["name"] != null)
                            {
                                ThisField.FieldName = ExtractedField.Attributes["name"].InnerText;
                            }

                            if (ExtractedField.Attributes["datatype"] != null)
                            {
                                ThisField.DataType = (System.Data.SqlDbType)System.Enum.Parse(typeof(System.Data.SqlDbType), ExtractedField.Attributes["datatype"].InnerText);
                            }

                            if (ExtractedField.Attributes["primary"] != null)
                            {
                                try
                                {
                                    ThisField.IsPrimary = bool.Parse(ExtractedField.Attributes["primary"].InnerText);
                                }
                                catch (System.FormatException)
                                {
                                    ThisField.IsPrimary = false;
                                }
                            }

                            ThisTable.AddField(ThisField);
                        }

                        TableList.Add(ThisTable);
                    }
                }
                _DBTables = TableList.ToArray();
            }
        }
예제 #3
0
		private void DeserializeSchemaXml(XmlNode TargetNode)
		{
			// Init member vars
			_Username = "";_AllTablesRetrieved = true;

			if (TargetNode.Attributes["username"] != null)
			{
				_Username = TargetNode.Attributes["username"].InnerText;
			}

			if (TargetNode.Attributes["tablesfinished"] != null)
			{
				_AllTablesRetrieved = bool.Parse(TargetNode.Attributes["tablesfinished"].InnerText);
			}

			XmlNodeList Tables = TargetNode.SelectNodes("table");

			if (Tables.Count > 0)
			{
				List<GlobalDS.Table> TableList = new List<GlobalDS.Table>();
				
				foreach (XmlNode ExtractedTable in Tables)
				{
					GlobalDS.Table ThisTable = new GlobalDS.Table();

					if (ExtractedTable.Attributes["name"] != null && ExtractedTable.Attributes["id"] != null)
					{
						ThisTable.Name = ExtractedTable.Attributes["name"].InnerText;
						ThisTable.ObjectID = System.Int32.Parse(ExtractedTable.Attributes["id"].InnerText);

						if (ExtractedTable.Attributes["recordcount"] != null)
						{
							ThisTable.RecordCount = System.Int64.Parse(ExtractedTable.Attributes["recordcount"].InnerText);
						}

						XmlNodeList Fields = ExtractedTable.SelectNodes("field");
						foreach (XmlNode ExtractedField in Fields)
						{
							GlobalDS.Field ThisField = new GlobalDS.Field();

							if (ExtractedField.Attributes["name"] != null)
							{
								ThisField.FieldName = ExtractedField.Attributes["name"].InnerText;
							}

							if (ExtractedField.Attributes["datatype"] != null)
							{
								ThisField.DataType = (System.Data.SqlDbType) System.Enum.Parse(typeof(System.Data.SqlDbType),ExtractedField.Attributes["datatype"].InnerText);
							}

							if (ExtractedField.Attributes["primary"] != null)
							{
								try
								{
									ThisField.IsPrimary = bool.Parse(ExtractedField.Attributes["primary"].InnerText);
								}
								catch (System.FormatException)
								{
									ThisField.IsPrimary = false;
								}
							}

							ThisTable.AddField(ThisField);
						}

						TableList.Add(ThisTable);
					}
				}
				_DBTables = TableList.ToArray();                    
			}
		}