Inheritance: MonoBehaviour
Example #1
0
        public bool Execute(string packageName, XElement xmlData)
        {
            var upgrader = new Upgrader(new FormStorageMigrationPlan());

            upgrader.Execute(scopeProvider, migrationBuilder, keyValueService, logger);
            return(true);
        }
Example #2
0
        /// <summary>
        /// Runs the all specified package migration plans and publishes a <see cref="MigrationPlansExecutedNotification"/>
        /// if all are successful.
        /// </summary>
        /// <param name="plansToRun"></param>
        /// <returns></returns>
        /// <exception cref="Exception">If any plan fails it will throw an exception.</exception>
        public IEnumerable <ExecutedMigrationPlan> RunPackagePlans(IEnumerable <string> plansToRun)
        {
            var results = new List <ExecutedMigrationPlan>();

            // Create an explicit scope around all package migrations so they are
            // all executed in a single transaction. If one package migration fails,
            // none of them will be committed. This is intended behavior so we can
            // ensure when we publish the success notification that is is done when they all succeed.
            using (ICoreScope scope = _scopeProvider.CreateCoreScope(autoComplete: true))
            {
                foreach (var migrationName in plansToRun)
                {
                    if (!_packageMigrationPlans.TryGetValue(migrationName, out PackageMigrationPlan? plan))
                    {
                        throw new InvalidOperationException("Cannot find package migration plan " + migrationName);
                    }

                    using (_profilingLogger.TraceDuration <PackageMigrationRunner>(
                               "Starting unattended package migration for " + migrationName,
                               "Unattended upgrade completed for " + migrationName))
                    {
                        var upgrader = new Upgrader(plan);
                        // This may throw, if so the transaction will be rolled back
                        results.Add(upgrader.Execute(_migrationPlanExecutor, _scopeProvider, _keyValueService));
                    }
                }
            }

            var executedPlansNotification = new MigrationPlansExecutedNotification(results);

            _eventAggregator.Publish(executedPlansNotification);

            return(results);
        }
        private void ExtractOptions()
        {
            var cfg      = UpgradeConfiguration;
            var upgrader = new Upgrader(cfg);

            upgrader.ExtractOptions();
        }
        public void CreateTableOfTDto()
        {
            IMigrationBuilder builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                if (t != typeof(CreateTableOfTDtoMigration))
                {
                    throw new NotSupportedException();
                }

                return(new CreateTableOfTDtoMigration(c));
            });

            using (IScope scope = ScopeProvider.CreateScope())
            {
                var upgrader = new Upgrader(
                    new MigrationPlan("test")
                    .From(string.Empty)
                    .To <CreateTableOfTDtoMigration>("done"));

                upgrader.Execute(MigrationPlanExecutor, ScopeProvider, Mock.Of <IKeyValueService>());

                var  helper = new DatabaseSchemaCreator(scope.Database, LoggerFactory.CreateLogger <DatabaseSchemaCreator>(), LoggerFactory, UmbracoVersion, EventAggregator, Mock.Of <IOptionsMonitor <InstallDefaultDataSettings> >());
                bool exists = helper.TableExists("umbracoUser");
                Assert.IsTrue(exists);

                scope.Complete();
            }
        }
        private void Window_Initialized(object sender, EventArgs e)
        {
            UpgradeConfiguration = new UpgradeConfiguration();
            var cfg = UpgradeConfiguration;

            cfg.UpdateByCommandLine();
            bool extractOptions = cfg.Options.ExtractOptions && cfg.SourcePath != null;

            if (extractOptions)
            {
                ExtractOptions();
                cfg.UpdateByCommandLine();
            }
            if (cfg.Options.Auto)
            {
                var upgrader = new Upgrader(cfg);
                upgrader.Process();
                Close();
//        if (Debugger.IsAttached)
//          Console.ReadLine();
            }
            else if (!extractOptions)
            {
                // Let's suggest these options by default in UI
                cfg.Options.AddImports    = true;
                cfg.Options.AddReferences = true;
            }
            Refresh();
        }
Example #6
0
        /// <summary>
        /// Upgrades the database schema and data by running migrations.
        /// </summary>
        /// <remarks>
        /// <para>This assumes that the database exists and the connection string is
        /// configured and it is possible to connect to the database.</para>
        /// <para>Runs whichever migrations need to run.</para>
        /// </remarks>
        public Result UpgradeSchemaAndData(MigrationPlan plan)
        {
            try
            {
                var readyForInstall = CheckReadyForInstall();
                if (readyForInstall.Success == false)
                {
                    return(readyForInstall.Result);
                }

                _logger.Info <DatabaseBuilder>("Database upgrade started");

                // upgrade
                var upgrader = new Upgrader(plan);
                upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);

                var message = "<p>Upgrade completed!</p>";

                //now that everything is done, we need to determine the version of SQL server that is executing

                _logger.Info <DatabaseBuilder>("Database configuration status: {DbConfigStatus}", message);

                return(new Result {
                    Message = message, Success = true, Percentage = "100"
                });
            }
            catch (Exception ex)
            {
                return(HandleInstallException(ex));
            }
        }
        public void DeleteKeysAndIndexesOfTDto()
        {
            var logger = new DebugDiagnosticsLogger();

            var builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                switch (t.Name)
                {
                case "CreateTableOfTDtoMigration":
                    return(new CreateTableOfTDtoMigration(c));

                case "DeleteKeysAndIndexesMigration":
                    return(new DeleteKeysAndIndexesMigration(c));

                default:
                    throw new NotSupportedException();
                }
            });

            using (var scope = ScopeProvider.CreateScope())
            {
                var upgrader = new Upgrader(
                    new MigrationPlan("test")
                    .From(string.Empty)
                    .To <CreateTableOfTDtoMigration>("a")
                    .To <DeleteKeysAndIndexesMigration>("done"));

                upgrader.Execute(ScopeProvider, builder, Mock.Of <IKeyValueService>(), logger);
                scope.Complete();
            }
        }
Example #8
0
        public void CreateTableOfTDto()
        {
            IMigrationBuilder builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                if (t != typeof(CreateTableOfTDtoMigration))
                {
                    throw new NotSupportedException();
                }

                return(new CreateTableOfTDtoMigration(c));
            });

            using (ScopeProvider.CreateScope(autoComplete: true))
            {
                var upgrader = new Upgrader(
                    new MigrationPlan("test")
                    .From(string.Empty)
                    .To <CreateTableOfTDtoMigration>("done"));

                upgrader.Execute(MigrationPlanExecutor, ScopeProvider, Mock.Of <IKeyValueService>());

                var db     = ScopeAccessor.AmbientScope.Database;
                var exists = ScopeAccessor.AmbientScope.SqlContext.SqlSyntax.DoesTableExist(db, "umbracoUser");

                Assert.IsTrue(exists);
            }
        }
        public void CreateTableOfTDto()
        {
            var logger = new DebugDiagnosticsLogger();

            var builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                if (t != typeof(CreateTableOfTDtoMigration))
                {
                    throw new NotSupportedException();
                }
                return(new CreateTableOfTDtoMigration(c));
            });

            using (var scope = ScopeProvider.CreateScope())
            {
                var upgrader = new Upgrader(
                    new MigrationPlan("test")
                    .From(string.Empty)
                    .To <CreateTableOfTDtoMigration>("done"));

                upgrader.Execute(ScopeProvider, builder, Mock.Of <IKeyValueService>(), logger);

                var helper = new DatabaseSchemaCreator(scope.Database, logger);
                var exists = helper.TableExists("umbracoUser");
                Assert.IsTrue(exists);

                scope.Complete();
            }
        }
        public void CreateColumn()
        {
            IMigrationBuilder builder = Mock.Of <IMigrationBuilder>();

            Mock.Get(builder)
            .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
            .Returns <Type, IMigrationContext>((t, c) =>
            {
                switch (t.Name)
                {
                case "CreateTableOfTDtoMigration":
                    return(new CreateTableOfTDtoMigration(c));

                case "CreateColumnMigration":
                    return(new CreateColumnMigration(c));

                default:
                    throw new NotSupportedException();
                }
            });

            using (IScope scope = ScopeProvider.CreateScope())
            {
                var upgrader = new Upgrader(
                    new MigrationPlan("test")
                    .From(string.Empty)
                    .To <CreateTableOfTDtoMigration>("a")
                    .To <CreateColumnMigration>("done"));

                upgrader.Execute(MigrationPlanExecutor, ScopeProvider, Mock.Of <IKeyValueService>());
                scope.Complete();
            }
        }
Example #11
0
 void Start()
 {
     lib       = GetComponent <Library>();
     inv       = GetComponent <Inventary>();
     upgrade   = GetComponent <Upgrader>();
     MouseItem = GetComponent <MouseItem>();
 }
        public void Initialize()
        {
            // Create a migration plan for a specific project/feature
            // We can then track that latest migration state/step for this project/feature
            var migrationPlan = new MigrationPlan("identityAuthTokens");

            // This is the steps we need to take
            // Each step in the migration adds a unique value
            migrationPlan.From(string.Empty)
            .To <AddUmbracoAuthTokenTable>("identityAuthTokens-db");

            // Go and upgrade our site (Will check if it needs to do the work or not)
            // Based on the current/latest step
            var upgrader = new Upgrader(migrationPlan);

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);

            //Add event to saving/chaning pasword on Umbraco backoffice user
            UserService.SavingUser += UserService_SavingUser;

            //Add event to saving/chaning pasword on Umbraco member
            MemberService.Saving += MemberService_Saving;

            //ContentService.Saving += this.ContentService_Saving;
        }
        public void Initialize()
        {
            // register and run our migration plan
            var upgrader = new Upgrader(new DoStuffMigrationPlan());

            upgrader.Execute(scopeProvider, migrationBuilder, keyValueService, logger);
        }
    public void Initialize()
    {
        // perform any upgrades (as needed)
        var upgrader = new Upgrader(new MigrationPlan01());

        upgrader.Execute(scopeProvider, migrationBuilder, keyValueService, logger);
    }
Example #15
0
    public void MigrationCanAddPostMigration()
    {
        var builder = Mock.Of <IMigrationBuilder>();

        Mock.Get(builder)
        .Setup(x => x.Build(It.IsAny <Type>(), It.IsAny <IMigrationContext>()))
        .Returns <Type, IMigrationContext>((t, c) =>
        {
            switch (t.Name)
            {
            case nameof(NoopMigration):
                return(new NoopMigration(c));

            case nameof(TestMigration):
                return(new TestMigration(c));

            case nameof(TestPostMigration):
                return(new TestPostMigration(c));

            default:
                throw new NotSupportedException();
            }
        });

        var database = new TestDatabase();
        var scope    = Mock.Of <IScope>(x => x.Notifications == Mock.Of <IScopedNotificationPublisher>());

        Mock.Get(scope)
        .Setup(x => x.Database)
        .Returns(database);

        var sqlContext = new SqlContext(
            new SqlServerSyntaxProvider(Options.Create(new GlobalSettings())),
            DatabaseType.SQLCe,
            Mock.Of <IPocoDataFactory>());
        var scopeProvider = new MigrationTests.TestScopeProvider(scope)
        {
            SqlContext = sqlContext
        };

        var plan = new MigrationPlan("Test")
                   .From(string.Empty).To <TestMigration>("done");

        TestMigration.MigrateCount     = 0;
        TestPostMigration.MigrateCount = 0;

        new MigrationContext(plan, database, s_loggerFactory.CreateLogger <MigrationContext>());

        var upgrader = new Upgrader(plan);
        var executor = GetMigrationPlanExecutor(scopeProvider, scopeProvider, builder);

        upgrader.Execute(
            executor,
            scopeProvider,
            Mock.Of <IKeyValueService>());

        Assert.AreEqual(1, TestMigration.MigrateCount);
        Assert.AreEqual(1, TestPostMigration.MigrateCount);
    }
Example #16
0
        public void Initialize()
        {
            // Go and upgrade our site (Will check if it needs to do the work or not)
            // Based on the current/latest step
            var upgrader = new Upgrader(new StoolballDataMigrationPlan());

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
Example #17
0
        public void Initialize()
        {
            var upgrader = new Upgrader(new ContentmentPlan());

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);

            ServerVariablesParser.Parsing += ServerVariablesParser_Parsing;
        }
        public void Initialize()
        {
            var migrationPlan = new MigrationPlan("UsomeTagManagerMigrationv1");

            migrationPlan.From(string.Empty).To <InstallHelper>("UsomeTagManagerMigrationv1-db");
            var upGrader = new Upgrader(migrationPlan);

            upGrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
Example #19
0
        static void CreateWindow()
        {
            var upgrader = new Upgrader();

            upgrader.Upgrade();
            var win = EditorWindow.GetWindow <SettingsWindow>("Settings");

            win.minSize = new Vector2(400, 200);
            win.Show();
        }
Example #20
0
    public SetupYobaDbFactory(ILoggerFactory loggerFactory, UpgraderOptions options)
        : base(loggerFactory.CreateLogger <YobaDb>(), Options.Create(new Config
    {
        ConnectionString = options.ConnectionString,
    }))
    {
        var upgrader = new Upgrader(loggerFactory, options);

        upgrader.Upgrade();
    }
Example #21
0
        static void Main()
        {
            IDataWorker worker = new DataWorker();

            Upgrader.AutoUpgrade();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(worker.Accounts.GetAll()));
        }
        public void Initialize()
        {
            var migrationPlan = new MigrationPlan("EnterspeedJobs");

            migrationPlan.From(string.Empty)
            .To <EnterspeedJobsTableMigration>("enterspeedjobs-db");

            var upgrader = new Upgrader(migrationPlan);

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
Example #23
0
        public void TestUpgrader_CleanseTrack_FixesWithSlightMismatch()
        {
            var dbTrack     = GetTestDbTrack02();
            var rippedTrack = GetTestRippedTrack02();

            var upgrader = new Upgrader();

            upgrader.CleanseTrack(rippedTrack, dbTrack);

            AssertTracksMatch(dbTrack, rippedTrack);
        }
Example #24
0
        public void Initialize()
        {
            var plan = new MigrationPlan("uBay");

            plan.From(string.Empty)
            .To <TableCreation>("state-1");

            var upgrader = new Upgrader(plan);

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
Example #25
0
            public void Initialize()
            {
                var migrationPlan = new MigrationPlan("TinifierMigrations");

                migrationPlan.From(string.Empty)
                .To <MigrationCreateTables>("tinifier-migration2");

                Upgrader upgrader = new Upgrader(migrationPlan);

                upgrader.Execute(scopeProvider, migrationBuilder, keyValueService, logger);
            }
        public void Initialize()
        {
            var plan = new MigrationPlan("Skybrud.Umbraco.Redirects");

            plan.From(string.Empty)
            .To <CreateTable>("2.0.0-alpha001");

            var upgrader = new Upgrader(plan);

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
        public void Initialize()
        {
            var plan = new MigrationPlan("UIOMatic");

            plan.From(string.Empty)
            .To <AddAllowedSectionToAdmins>("state-3.0.0");

            var upgrader = new Upgrader(plan);

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
        /// <summary>
        /// Runs the inital migration.
        /// </summary>
        public void Initialize()
        {
            var plan = new MigrationPlan("Formulate");

            plan.From(string.Empty)
            .To <CreateSubmissionsTable>("state-1");

            var upgrader = new Upgrader(plan);

            upgrader.Execute(ScopeProvider, MigrationBuilder, KeyValueService, Logger);
        }
        public void Initialize()
        {
            var migrationPlan = new MigrationPlan("U8SKContentNodeIcons");

            migrationPlan.From(string.Empty)
            .To <AddContentNodeIconsTable>("contentNodeIcons-db");

            var upgrader = new Upgrader(migrationPlan);

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
Example #30
0
        public void Initialize()
        {
            var migrationPlan = new MigrationPlan("BlogPostComments");

            migrationPlan.From(string.Empty)
            .To <BlogPostCommentsTable>("Create-BlogPostCommentsTable")
            .To <BlogPostCommentInfoView>("Create-BlogPostCommentInfoView")
            .To <AddBlogCommentDateColumn>("Add-BlogPostCommentedOnColumn");
            var upgrader = new Upgrader(migrationPlan);

            upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger);
        }
Example #31
0
    public void savePlayerPrefsMenu(float r, float g, float b)
    {
        upgrades = GameObject.Find("Upgrader").GetComponent<Upgrader>();
        PlayerPrefs.SetFloat("BaseRed", r);
        PlayerPrefs.SetFloat("BaseGreen", g);
        PlayerPrefs.SetFloat("BaseBlue", b);

        PlayerPrefs.SetInt("total_points", upgrades.points);

        PlayerPrefs.SetInt("GunAmmo", upgrades.gunAmmo);
        PlayerPrefs.SetInt("GunDmg", upgrades.gunDmg);

        PlayerPrefs.SetInt("ShotgunAmmo", upgrades.shotgunAmmo);
        PlayerPrefs.SetInt("ShotgunDmg", upgrades.shotgunDmg);

        PlayerPrefs.SetInt("KnifeDmg", upgrades.knifeDmg);

        PlayerPrefs.SetInt("CrowbarDmg", upgrades.crowbarDmg);

        PlayerPrefs.SetFloat("TurretRate", upgrades.turretRate);
        PlayerPrefs.SetInt("TurretDmg", upgrades.turretDmg);

        Debug.Log(upgrades.points);
    }
Example #32
0
        private void callback( 
			vdFtpWorkUnit unit,
			vdFtpTPStatus status, 
			vdFtpFolder folder, 
			vdFtpItem item, 
			object data )
        {
            if ( this.InvokeRequired )
            {
                this.Invoke( _tp, unit, status, folder, item, data );
                return;
            }

            try
            {
                switch ( status )
                {
                    case vdFtpTPStatus.GetFolder_Complete:
                        if ( _strFtgFolder.CompareTo( folder.Name ) == 0 )
                            photographerFolderComplete( folder );
                        else if ( "_uppdateringar".CompareTo( folder.Name ) == 0 )
                            upgradeFolderComplete( folder );
                        else
                            standbylistFolderComplete( folder );
                        break;

                    case vdFtpTPStatus.DownloadFile_Complete:
                        if ( item.Name.StartsWith( "order_" ) )
                        {
                            _coof = new ContentOfOrderFile();
                            _coof.loadFromZipFile( data as MemoryStream );
                            _downloadStatus = _coof.getFileWithType( ContentOfOrderFile.FileType.OrderXml ) != null ?
                                DownloadStatus.Complete : DownloadStatus.Failed;
                        }
                        else if ( item.Name.StartsWith( "plata_" ) )
                        {
                            _upgrader = new Upgrader( data as MemoryStream );
                            _downloadStatus = DownloadStatus.Complete;
                        }
                        else if ( item.Name.EndsWith( ".pdf" ) )
                        {
                            string s =Path.Combine( Global.GetTempPath(), item.Name );
                            using ( Stream stream = new FileStream( s, FileMode.Create ) )
                                (data as MemoryStream).WriteTo( stream );
                        }
                        break;

                    case vdFtpTPStatus.DownloadFile_Begin:
                    case vdFtpTPStatus.DownloadFile_Progress:
                        txtProgress.Text = string.Format( "Hämtar... {0}%", 100*(int)data/item.Size );
                        break;

                    case vdFtpTPStatus.Error:
                        setMessage( data.ToString() );
                        _downloadStatus = DownloadStatus.Failed;
                        break;

                }
            }
            catch ( Exception ex )
            {
                setMessage( ex.ToString() );
                _downloadStatus = DownloadStatus.Failed;
            }
        }