Esempio n. 1
0
        private static void BeginDatabaseUpgrade(AppArgs args)
        {
            var manifest = new UpgradeManifest(new FileInfo(args.ManifestPath));

            //manifest.Message += Console.WriteLine;

            if (args.TransactionTimeout.HasValue)
            {
                Console.WriteLine("Setting transaction timeout to {0}", args.TransactionTimeout);
                TransactionUtils.MaximumTransactionTimeout = args.TransactionTimeout.Value;
            }

            var dbu = new DatabaseUpgrade(manifest, args.GetConnectionString())
            {
                OptionRepair            = args.Repair,
                DisableTransactionScope = args.DisableTransactionScope
            };

            dbu.Message += PrintMessage;

            CancelUpgrade = new CancellationTokenSource();

            var upgrade = dbu.ExecuteAsync(CancelUpgrade.Token);

            upgrade.ContinueWith(UpgradeComplete);
            upgrade.Start();

            Tasks.Add(upgrade);
        }
Esempio n. 2
0
        public DatabaseUpgrade(UpgradeManifest manifest, string connectionString)
        {
            if (manifest == null)
            {
                throw new ArgumentNullException("manifest");
            }

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentOutOfRangeException("connectionString");
            }

            this.manifest         = manifest;
            this.connectionString = connectionString;

            // Load current version number
            var currentVersionString = QestlabDatabaseHelper.GetSystemValue(this.connectionString, "QestnetDatabaseVersion");

            if (!string.IsNullOrEmpty(currentVersionString))
            {
                if (!Version.TryParse(currentVersionString, out this.currentVersion))
                {
                    throw new Exception("The current QestnetDatabaseVersion in qestSystemValues is not a valid version number.");
                }
            }

            this.CheckVersion();
        }