コード例 #1
0
 private void DrFillSongObj(OleDbDataReader dr, MigrationSong mgo)
 {
     mgo.autoNumber     = dr.GetInt32(0);
     mgo.number         = dr.GetInt32(1);
     mgo.title          = dr.GetString(2);
     mgo.chorus         = dr.GetString(3);
     mgo.location       = dr.GetString(4);
     mgo.displayDefault = dr.GetBoolean(5);
     mgo.imageId        = dr.GetInt32(6);
     mgo.overlay        = dr.GetInt32(7);
     mgo.copyright      = dr.GetString(8);
 }
コード例 #2
0
 public bool Compare(MigrationSong v1, MigrationSong v2)
 {
     return(v1.autoNumber == v2.autoNumber &&
            v1.number == v2.number &&
            v1.title == v2.title &&
            v1.chorus == v2.chorus &&
            v1.location == v2.location &&
            v1.displayDefault == v2.displayDefault &&
            v1.imageId == v2.imageId &&
            v1.overlay == v2.overlay &&
            v1.copyright == v2.copyright);
 }
コード例 #3
0
        private bool GetDifSongs(string oldRoot, Dictionary <int, MigrationSong> mSongs)
        {
            using (FBirdTask told = new FBirdTask())
                using (JetTask tnew = new JetTask())
                {
                    // Set old connection string
                    string path2olddb   = Path.Combine(oldRoot, "bibdata.fdb");
                    string oldConstring = "ServerType=1;Database=" + path2olddb + ";User=SYSDBA;Password=masterkey;Charset=WIN1251";
                    told.Connection = new FbConnection(oldConstring);

                    string fbQuery = "SELECT  " +
                                     "\"Songs\".\"AutoNumber\", " +
                                     "\"Songs\".\"Number\", " +
                                     "\"Songs\".\"Title\", " +
                                     "\"Songs\".\"Chorus\", " +
                                     "\"Songs\".\"Location\", " +
                                     "\"Songs\".\"DisplayDefault\", " +
                                     "\"Songs\".\"ImageId\", " +
                                     "\"Songs\".\"Overlay\", " +
                                     "\"Songs\".\"Copyright\" " +
                                     "FROM \"Songs\" " +
                                     "ORDER BY \"AutoNumber\"";

                    string jtQuery = "SELECT  " +
                                     "[Songs].[AutoNumber], " +
                                     "[Songs].[Number], " +
                                     "[Songs].[Title], " +
                                     "[Songs].[Chorus], " +
                                     "[Songs].[Location], " +
                                     "[Songs].[DisplayDefault], " +
                                     "[Songs].[ImageId], " +
                                     "[Songs].[Overlay], " +
                                     "[Songs].[Copyright] " +
                                     "FROM [Songs] " +
                                     "ORDER BY [AutoNumber]";

                    told.CommandText = fbQuery;
                    tnew.CommandText = jtQuery;
                    told.ExecuteReader();
                    tnew.ExecuteReader();
                    if (told.DR == null || tnew.DR == null)
                    {
                        this.TopMost = false;
                        MessageBox.Show(this, "Migration failed to migrate song data", "Error");
                        return(false);
                    }

                    bool oldAvailable = true;
                    bool newAvailable = true;
                    while (oldAvailable || newAvailable)
                    {
                        oldAvailable = told.DR.Read();
                        newAvailable = tnew.DR.Read();

                        // Old data
                        if (oldAvailable)
                        {
                            MigrationSong mgo = new MigrationSong();
                            DrFillSongObj(told.DR, mgo);
                            mgo.foundInOld = true;

                            // Check if image got changed
                            if (mgo.imageId == 4)
                            {
                                mgo.imageId = -2;
                                mgo.overlay = 777;
                            }

                            if (mSongs.ContainsKey(mgo.autoNumber))
                            {
                                MigrationSong v2 = mSongs[mgo.autoNumber];
                                v2.foundInOld = true;

                                // Drop if the two are the same
                                if (v2.Compare(mgo, v2))
                                {
                                    mSongs.Remove(mgo.autoNumber);
                                }
                            }
                            else
                            {
                                mSongs[mgo.autoNumber] = mgo;
                            }
                        }

                        // New data
                        if (newAvailable)
                        {
                            MigrationSong mgn = new MigrationSong();
                            DrFillSongObj(tnew.DR, mgn);
                            mgn.foundInNew = true;

                            if (mSongs.ContainsKey(mgn.autoNumber))
                            {
                                MigrationSong v2 = mSongs[mgn.autoNumber];
                                v2.foundInNew = true;

                                // Drop if the two are the same
                                if (v2.Compare(mgn, v2))
                                {
                                    mSongs.Remove(mgn.autoNumber);
                                }
                            }
                            else
                            {
                                mSongs[mgn.autoNumber] = mgn;
                            }
                        }
                    }
                }
            return(true);
        }