Ejemplo n.º 1
0
        Tuple <bool, int> CompareTables(String tableName, DbInfo db)
        {
            var command = sqlconn.CreateCommand();

            command.CommandText = "SELECT * FROM '" + tableName + "'";
            using var reader    = command.ExecuteReader();
            var command2 = db.sqlconn.CreateCommand();

            command2.CommandText = "SELECT * FROM '" + tableName + "'";
            using var reader2    = command2.ExecuteReader();

            Object[] values  = new Object[reader.FieldCount];
            Object[] values2 = new Object[reader2.FieldCount];
            int      nRow    = 0;

            while (reader.Read())
            {
                reader2.Read();
                reader.GetValues(values);
                reader2.GetValues(values2);
                for (int nCol = 0; nCol < reader.FieldCount; ++nCol)
                {
                    if (!values[nCol].Equals(values2[nCol]))
                    {
                        return(new Tuple <bool, int>(false, nRow));
                    }
                }
                ++nRow;
            }
            return(new Tuple <bool, int>(true, 0));
        }
Ejemplo n.º 2
0
 void Rebuild()
 {
     try
     {
         var watch = Stopwatch.StartNew();
         db1 = new DbInfo(path1);
         db2 = new DbInfo(path2);
         UpdateView();
         watch.Stop();
         toolStripStatusLabel1.Text = String.Format("Processing time: {0} seconds", watch.Elapsed.TotalSeconds);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
         db1 = null;
         db2 = null;
     }
 }
Ejemplo n.º 3
0
 public bool Compare(DbInfo db, ref List <TableInfo> tablesIn1, ref List <TableInfo> tablesIn2,
                     ref List <Tuple <TableInfo, TableInfo> > tablesMatched, ref List <Tuple <TableInfo, TableInfo, int> > tablesUnmatched)
 {
     foreach (var table in tables)
     {
         if (db.tables.ContainsKey(table.Key))
         {
             var tableInfo = db.tables[table.Key];
             if (table.Value.Compare(tableInfo))
             {
                 if (tableInfo.NumRows < 1000)
                 {
                     var result = CompareTables(table.Key, db);
                     if (result.Item1)
                     {
                         tablesMatched.Add(new Tuple <TableInfo, TableInfo>(table.Value, tableInfo));
                     }
                     else
                     {
                         tablesUnmatched.Add(new Tuple <TableInfo, TableInfo, int>(table.Value, tableInfo, result.Item2));
                     }
                 }
             }
             else
             {
                 tablesUnmatched.Add(new Tuple <TableInfo, TableInfo, int>(table.Value, tableInfo, -1));
             }
         }
         else
         {
             tablesIn1.Add(table.Value);
         }
     }
     foreach (var table in db.tables)
     {
         if (!tables.ContainsKey(table.Key))
         {
             tablesIn2.Add(table.Value);
         }
     }
     return((tablesIn1.Count == 0) && (tablesIn2.Count == 0) && (tablesUnmatched.Count == 0));
 }