//******************************************************************************************************// Schema.cs - Gbtc//// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.//// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See// the NOTICE file distributed with this work for additional information regarding copyright ownership.// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may// not use this file except in compliance with the License. You may obtain a copy of the License at://// http://www.opensource.org/licenses/MIT//// Unless agreed to in writing, the subject software distributed under the License is distributed on an// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the// License for the specific language governing permissions and limitations.//// Code Modification History:// ----------------------------------------------------------------------------------------------------// 06/28/2010 - J. Ritchie Carroll// Generated original version of source code.// 08/15/2008 - Mihir Brahmbhatt// Converted to C# extensions.// 09/27/2010 - Mihir Brahmbhatt// Edited code comments.// 12/07/2010 - Mihir Brahmbhatt// Changed SqlEncoded method to check proper numeric conversion value// 12/20/2012 - Starlynn Danyelle Gilliam// Modified Header.////****************************************************************************************************** using System;using System.Collections;using System.Collections.Generic;using System.Data;using System.Data.OleDb;using System.Globalization;using System.IO;using System.Text;using GSF;using GSF.Data;using GSF.IO;using SerializationFormat = GSF.SerializationFormat; namespace DataMigrationUtility{ // James Ritchie Carroll - 2003 #region [ Enumerations ] /// <summary> /// Specifies the type of object in database /// </summary> [Flags] [Serializable] public enum TableType { /// <summary> /// Database object is DataTable /// </summary> Table = 1, /// <summary> /// Database object is View /// </summary> View = 2, /// <summary> /// Database object is System Defined Table /// </summary> SystemTable = 4, /// <summary> /// Database object is System Defined View /// </summary> SystemView = 8, /// <summary> /// Database object is Alias /// </summary> Alias = 16, /// <summary> /// Database object is Synonym /// </summary> Synonym = 32, /// <summary> /// Database object is Global Temp /// </summary> GlobalTemp = 64, /// <summary> /// Database object is local Temp /// </summary> LocalTemp = 128, /// <summary> /// Database object is Link /// </summary> Link = 256, /// <summary> /// Database object is not defined /// </summary> Undetermined = 512 } /// <summary> /// Specified the type of referential action on database object/Tables /// </summary> [Serializable] public enum ReferentialAction { /// <summary> /// Action Type is cascade /// </summary> Cascade, /// <summary> /// Action Type is to set null /// </summary> SetNull, /// <summary> /// Action Type is to set default /// </summary> SetDefault, /// <summary> /// No Action /// </summary> NoAction } #endregion /// <summary> /// Represents a database field. /// </summary> [Serializable] public class Field : IComparable { #region [ Members ] //Fields private readonly Fields m_parent; private readonly string m_name; private readonly OleDbType m_dataType; private int m_ordinal; private bool m_allowsNulls; private bool m_autoIncrement; private int m_autoIncrementSeed; private int m_autoIncrementStep; private bool m_hasDefault; private object m_defaultValue; private int m_maxLength; private int m_numericPrecision; private int m_numericScale; private int m_dateTimePrecision; private bool m_readOnly; private bool m_unique; private string m_description; private Hashtable m_autoIncrementTranslations; private object m_value; private bool m_isPrimaryKey; private int m_primaryKeyOrdinal; private string m_primaryKeyName; private ForeignKeyFields m_foreignKeys; private Field m_referencedBy; #endregion #region [ Constructors ] internal Field(Fields Parent, string Name, OleDbType Type) { // We only allow internal creation of this object m_parent = Parent; m_name = Name; m_dataType = Type; ForeignKeys = new ForeignKeyFields(this); } #endregion #region [ Properties ] /// <summary> /// Get Field Name /// </summary> public string Name { get { return m_name; } } /// <summary> /// Get SQL escaped name of <see cref="Table"/> /// </summary> public string SQLEscapedName { get { return m_parent.Parent.Parent.Parent.SQLEscapeName(m_name); } } /// <summary> /// Get <see cref="OleDbType"/> Type /// </summary> public OleDbType Type { get { return m_dataType; } } /// <summary> /// Get or set file ordinal /// </summary> public int Ordinal { get { return m_ordinal; } internal set { m_ordinal = value; } } /// <summary> /// Get or set Allow Null flag /// </summary> public bool AllowsNulls { get { return m_allowsNulls; } internal set { m_allowsNulls = value; } } /// <summary> /// Get or set Auto increment flag /// </summary> public bool AutoIncrement { get { return m_autoIncrement; } internal set { m_autoIncrement = value; } } /// <summary> /// Get or set Auto increment seed /// </summary> public int AutoIncrementSeed { get { return m_autoIncrementSeed; } internal set { m_autoIncrementSeed = value; } } /// <summary> /// Get or set Auto increment step /// </summary> public int AutoIncrementStep { get { return m_autoIncrementStep; } internal set { m_autoIncrementStep = value; } } /// <summary> /// Get or set has default value flag /// </summary> public bool HasDefault { get { return m_hasDefault; } internal set { m_hasDefault = value; } } /// <summary> /// Get or set default value /// </summary> public object DefaultValue { get { return m_defaultValue; } internal set { m_defaultValue = value; } } /// <summary> /// Get or set maximum length of field /// </summary> public int MaxLength { get { return m_maxLength; } internal set { m_maxLength = value; } } /// <summary> /// Get or set numeric precision /// </summary> public int NumericPrecision { get { return m_numericPrecision; } internal set { m_numericPrecision = value; } } /// <summary> /// Get or set Numeric scale /// </summary> public int NumericScale { get { return m_numericScale; } internal set { m_numericScale = value; } } /// <summary> /// Get or set date time precision /// </summary> public int DateTimePrecision { get { return m_dateTimePrecision; } internal set { m_dateTimePrecision = value; } } /// <summary> /// Get or set read-only flag /// </summary> public bool ReadOnly { get { return m_readOnly; } internal set { m_readOnly = value; } } /// <summary> /// Get or set for unique /// </summary> public bool Unique { get { return m_unique; } internal set { m_unique = value; } } /// <summary> /// Get or set description /// </summary> public string Description { get { return m_description; } internal set { m_description = value; } } /// <summary> /// Get or set auto increment translation /// </summary> internal Hashtable AutoIncrementTranslations { get { return m_autoIncrementTranslations; } set { m_autoIncrementTranslations = value; } } /// <summary> /// Get or set value of <see cref="Field"/> /// </summary> public object Value { get { return m_value; } set { m_value = value; } } /// <summary> /// Get or set flag to check <see cref="Field"/> is primary key or not /// </summary> public bool IsPrimaryKey { get { return m_isPrimaryKey; } set { m_isPrimaryKey = value; } } /// <summary> /// Get or set ordinal for Primary key field /// </summary> public int PrimaryKeyOrdinal { get { return m_primaryKeyOrdinal; } set { m_primaryKeyOrdinal = value; } } /// <summary> /// Get or set primary key name /// </summary> public string PrimaryKeyName { get { return m_primaryKeyName; } set { m_primaryKeyName = value; }Lines 1–500 of 2949. Load more
//****************************************************************************************************** // Schema.cs - Gbtc // // Copyright © 2012, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 06/28/2010 - J. Ritchie Carroll // Generated original version of source code. // 08/15/2008 - Mihir Brahmbhatt // Converted to C# extensions. // 09/27/2010 - Mihir Brahmbhatt // Edited code comments. // 12/07/2010 - Mihir Brahmbhatt // Changed SqlEncoded method to check proper numeric conversion value // 12/20/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using System.Globalization; using System.IO; using System.Text; using GSF; using GSF.Data; using GSF.IO; using SerializationFormat = GSF.SerializationFormat; namespace DataMigrationUtility { // James Ritchie Carroll - 2003 #region [ Enumerations ] /// <summary> /// Specifies the type of object in database /// </summary> [Flags] [Serializable] public enum TableType { /// <summary> /// Database object is DataTable /// </summary> Table = 1, /// <summary> /// Database object is View /// </summary> View = 2, /// <summary> /// Database object is System Defined Table /// </summary> SystemTable = 4, /// <summary> /// Database object is System Defined View /// </summary> SystemView = 8, /// <summary> /// Database object is Alias /// </summary> Alias = 16, /// <summary> /// Database object is Synonym /// </summary> Synonym = 32, /// <summary> /// Database object is Global Temp /// </summary> GlobalTemp = 64, /// <summary> /// Database object is local Temp /// </summary> LocalTemp = 128, /// <summary> /// Database object is Link /// </summary> Link = 256, /// <summary> /// Database object is not defined /// </summary> Undetermined = 512 } /// <summary> /// Specified the type of referential action on database object/Tables /// </summary> [Serializable] public enum ReferentialAction { /// <summary> /// Action Type is cascade /// </summary> Cascade, /// <summary> /// Action Type is to set null /// </summary> SetNull, /// <summary> /// Action Type is to set default /// </summary> SetDefault, /// <summary> /// No Action /// </summary> NoAction } #endregion /// <summary> /// Represents a database field. /// </summary> [Serializable] public class Field : IComparable { #region [ Members ] //Fields private readonly Fields m_parent; private readonly string m_name; private readonly OleDbType m_dataType; private int m_ordinal; private bool m_allowsNulls; private bool m_autoIncrement; private int m_autoIncrementSeed; private int m_autoIncrementStep; private bool m_hasDefault; private object m_defaultValue; private int m_maxLength; private int m_numericPrecision; private int m_numericScale; private int m_dateTimePrecision; private bool m_readOnly; private bool m_unique; private string m_description; private Hashtable m_autoIncrementTranslations; private object m_value; private bool m_isPrimaryKey; private int m_primaryKeyOrdinal; private string m_primaryKeyName; private ForeignKeyFields m_foreignKeys; private Field m_referencedBy; #endregion #region [ Constructors ] internal Field(Fields Parent, string Name, OleDbType Type) { // We only allow internal creation of this object m_parent = Parent; m_name = Name; m_dataType = Type; ForeignKeys = new ForeignKeyFields(this); } #endregion #region [ Properties ] /// <summary> /// Get Field Name /// </summary> public string Name { get { return m_name; } } /// <summary> /// Get SQL escaped name of <see cref="Table"/> /// </summary> public string SQLEscapedName { get { return m_parent.Parent.Parent.Parent.SQLEscapeName(m_name); } } /// <summary> /// Get <see cref="OleDbType"/> Type /// </summary> public OleDbType Type { get { return m_dataType; } } /// <summary> /// Get or set file ordinal /// </summary> public int Ordinal { get { return m_ordinal; } internal set { m_ordinal = value; } } /// <summary> /// Get or set Allow Null flag /// </summary> public bool AllowsNulls { get { return m_allowsNulls; } internal set { m_allowsNulls = value; } } /// <summary> /// Get or set Auto increment flag /// </summary> public bool AutoIncrement { get { return m_autoIncrement; } internal set { m_autoIncrement = value; } } /// <summary> /// Get or set Auto increment seed /// </summary> public int AutoIncrementSeed { get { return m_autoIncrementSeed; } internal set { m_autoIncrementSeed = value; } } /// <summary> /// Get or set Auto increment step /// </summary> public int AutoIncrementStep { get { return m_autoIncrementStep; } internal set { m_autoIncrementStep = value; } } /// <summary> /// Get or set has default value flag /// </summary> public bool HasDefault { get { return m_hasDefault; } internal set { m_hasDefault = value; } } /// <summary> /// Get or set default value /// </summary> public object DefaultValue { get { return m_defaultValue; } internal set { m_defaultValue = value; } } /// <summary> /// Get or set maximum length of field /// </summary> public int MaxLength { get { return m_maxLength; } internal set { m_maxLength = value; } } /// <summary> /// Get or set numeric precision /// </summary> public int NumericPrecision { get { return m_numericPrecision; } internal set { m_numericPrecision = value; } } /// <summary> /// Get or set Numeric scale /// </summary> public int NumericScale { get { return m_numericScale; } internal set { m_numericScale = value; } } /// <summary> /// Get or set date time precision /// </summary> public int DateTimePrecision { get { return m_dateTimePrecision; } internal set { m_dateTimePrecision = value; } } /// <summary> /// Get or set read-only flag /// </summary> public bool ReadOnly { get { return m_readOnly; } internal set { m_readOnly = value; } } /// <summary> /// Get or set for unique /// </summary> public bool Unique { get { return m_unique; } internal set { m_unique = value; } } /// <summary> /// Get or set description /// </summary> public string Description { get { return m_description; } internal set { m_description = value; } } /// <summary> /// Get or set auto increment translation /// </summary> internal Hashtable AutoIncrementTranslations { get { return m_autoIncrementTranslations; } set { m_autoIncrementTranslations = value; } } /// <summary> /// Get or set value of <see cref="Field"/> /// </summary> public object Value { get { return m_value; } set { m_value = value; } } /// <summary> /// Get or set flag to check <see cref="Field"/> is primary key or not /// </summary> public bool IsPrimaryKey { get { return m_isPrimaryKey; } set { m_isPrimaryKey = value; } } /// <summary> /// Get or set ordinal for Primary key field /// </summary> public int PrimaryKeyOrdinal { get { return m_primaryKeyOrdinal; } set { m_primaryKeyOrdinal = value; } } /// <summary> /// Get or set primary key name /// </summary> public string PrimaryKeyName { get { return m_primaryKeyName; } set { m_primaryKeyName = value; }