/// <summary>
 /// Will create the columns needed to log the table described by the dtSourceSchema
 /// </summary>
 /// <param name="sSouceTable">The name of the table that will be logged from including the database name.</param>
 /// <param name="sDestinationTable">The name of the table that will be logged to including the database name.</param>
 /// <param name="dtSourceSchema">This is a datatable with the same schema that would be returned by the 'descrbe' command in MySql except with a NullToString Colum set to NULL OR NOT NULL based on the Null column from the describe command.</param>
 public DataLogger_LogTable(string sSouceTable, string sDestinationTable, string sSourceDBName, string sDestinationDBName,  DataTable dtSourceSchema)
 {
     this._SourceTableName = sSouceTable;
     this._DestinationTableName = sDestinationTable;
     this._SourceDBName = sSourceDBName;
     this._DestinationDBName = sDestinationDBName;
     this._DestinationColumns = new Dictionary<int, DataLogger_LogColumn>();
     this._SourceSchema = dtSourceSchema;
     DataLogger_LogColumn oLogColumn_old;
     DataLogger_LogColumn oLogColumn_new;
     int iCurrentColumnCount = 0;
     int iTotalNumberOfColumnsToLog = dtSourceSchema.Rows.Count;
     foreach (DataRow dr in dtSourceSchema.Rows)
     {
         oLogColumn_old = new DataLogger_LogColumn(dr["Field"].ToString(), dr["Type"].ToString() + " " + dr["NullToString"].ToString() + " ", LogColumn.LogType.Old);
         oLogColumn_new = new DataLogger_LogColumn(dr["Field"].ToString(), dr["Type"].ToString() + " " + dr["NullToString"].ToString() + " ", LogColumn.LogType.New);
         this._DestinationColumns.Add(iCurrentColumnCount, oLogColumn_old);
         this._DestinationColumns.Add(iCurrentColumnCount + iTotalNumberOfColumnsToLog, oLogColumn_new);//I want the old columns to be ordinally next to one naother in the db
         if (dr["Key"] != DBNull.Value)
         {
             if (dr["Key"].ToString().ToUpper().Equals("PRI"))
             {
                 this._SourceTablePrimaryKey = dr["Field"].ToString();
             }
         }
         iCurrentColumnCount++;
     }
 }
Пример #2
0
        /// <summary>
        /// Will create the columns needed to log the table described by the dtSourceSchema
        /// </summary>
        /// <param name="sSouceTable">The name of the table that will be logged from including the database name.</param>
        /// <param name="sDestinationTable">The name of the table that will be logged to including the database name.</param>
        /// <param name="dtSourceSchema">This is a datatable with the same schema that would be returned by the 'descrbe' command in MySql except with a NullToString Colum set to NULL OR NOT NULL based on the Null column from the describe command.</param>
        public DataLogger_LogTable(string sSouceTable, string sDestinationTable, string sSourceDBName, string sDestinationDBName, DataTable dtSourceSchema)
        {
            this._SourceTableName      = sSouceTable;
            this._DestinationTableName = sDestinationTable;
            this._SourceDBName         = sSourceDBName;
            this._DestinationDBName    = sDestinationDBName;
            this._DestinationColumns   = new Dictionary <int, DataLogger_LogColumn>();
            this._SourceSchema         = dtSourceSchema;
            DataLogger_LogColumn oLogColumn_old;
            DataLogger_LogColumn oLogColumn_new;
            int iCurrentColumnCount        = 0;
            int iTotalNumberOfColumnsToLog = dtSourceSchema.Rows.Count;

            foreach (DataRow dr in dtSourceSchema.Rows)
            {
                oLogColumn_old = new DataLogger_LogColumn(dr["Field"].ToString(), dr["Type"].ToString() + " " + dr["NullToString"].ToString() + " ", LogColumn.LogType.Old);
                oLogColumn_new = new DataLogger_LogColumn(dr["Field"].ToString(), dr["Type"].ToString() + " " + dr["NullToString"].ToString() + " ", LogColumn.LogType.New);
                this._DestinationColumns.Add(iCurrentColumnCount, oLogColumn_old);
                this._DestinationColumns.Add(iCurrentColumnCount + iTotalNumberOfColumnsToLog, oLogColumn_new);//I want the old columns to be ordinally next to one naother in the db
                if (dr["Key"] != DBNull.Value)
                {
                    if (dr["Key"].ToString().ToUpper().Equals("PRI"))
                    {
                        this._SourceTablePrimaryKey = dr["Field"].ToString();
                    }
                }
                iCurrentColumnCount++;
            }
        }