Ejemplo n.º 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Cursor.Current = Cursors.WaitCursor;

            DbMigrations.MigrationManager migrationManager = new DbMigrations.MigrationManager();

            if (!NHibernateHelper.DatabaseExists)
            {
                NHibernateHelper.CreateDatabaseDirectoryIfNotExist();
                if (MessageBox.Show("No Database Found. Click ok to Create new database. or cancel to exit.", GetTitle(), MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                migrationManager.MigrateToLastRevision();
            }
            else
            {
                if (migrationManager.hasDetectedNewMigrations())
                {
                    if (MessageBox.Show(String.Format(@"The database schema has changed.
Click OK to backup the existing database and upgrade to the newer version, or Cancel to exit.
NOTE: After the upgrade the database will no longer be accessible through previous versions of {0}", Application.ProductName),
                                        "Upgrade Database", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        NHibernateHelper.BackupDatabase();
                        migrationManager.MigrateToLastRevision();
                    }
                    else
                    {
                        return;
                    }
                }
                if (migrationManager.hasDetectedDatabaseWithNewerVersion())
                {
                    MessageBox.Show(String.Format(@"The database has been in use by a newer version of {0}.
Please upgrade {0}. The application will now exit", Application.ProductName),
                                    "Database from a newer version detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            Application.Run(new DashBoard());
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Cursor.Current = Cursors.WaitCursor;

            DbMigrations.MigrationManager migrationManager = new DbMigrations.MigrationManager();

            if (!NHibernateHelper.DatabaseExists)
            {
                NHibernateHelper.CreateDatabaseDirectoryIfNotExist();
                if (MessageBox.Show("No Database Found. Click ok to Create new database. or cancel to exit.", GetTitle(), MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                migrationManager.MigrateToLastRevision();
            }
            else
            {
                if (migrationManager.hasDetectedNewMigrations())
                {
                    if (MessageBox.Show(String.Format(@"The database schema has changed.
            Click OK to backup the existing database and upgrade to the newer version, or Cancel to exit.
            NOTE: After the upgrade the database will no longer be accessible through previous versions of {0}", Application.ProductName),
                    "Upgrade Database", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        NHibernateHelper.BackupDatabase();
                        migrationManager.MigrateToLastRevision();
                    }
                    else
                    {
                        return;
                    }
                }
                if (migrationManager.hasDetectedDatabaseWithNewerVersion())
                {
                    MessageBox.Show(String.Format(@"The database has been in use by a newer version of {0}.
            Please upgrade {0}. The application will now exit", Application.ProductName),
                    "Database from a newer version detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            Application.Run(new DashBoard());
        }