Exemplo n.º 1
0
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            if (e.ProductName != Constants.System.UmbracoMigrationName)
            {
                return;
            }

            var v730 = new Semver.SemVersion(new Version(7, 3, 0));

            var doMedia   = e.ConfiguredSemVersion < v730;
            var doContent = e.ConfiguredSemVersion < v730;

            if (doMedia)
            {
                var mediaService = (MediaService)ApplicationContext.Current.Services.MediaService;
                mediaService.RebuildXmlStructures();

                // note: not re-indexing medias?
            }

            if (doContent)
            {
                // rebuild Xml in database
                var contentService = (ContentService)ApplicationContext.Current.Services.ContentService;
                contentService.RebuildXmlStructures();

                // refresh the Xml cache
                content.Instance.RefreshContentFromDatabase();
            }
        }
Exemplo n.º 2
0
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            var target73 = new Version(7, 3, 0);

            if (e.ConfiguredVersion <= target73)
            {
                var tempCssFolder = IOHelper.MapPath("~/App_Data/TEMP/CssMigration/");
                var cssFolder     = IOHelper.MapPath("~/css");
                if (Directory.Exists(tempCssFolder))
                {
                    var files = Directory.GetFiles(tempCssFolder, "*.css", SearchOption.AllDirectories);
                    foreach (var file in files)
                    {
                        var relativePath = file.TrimStart(tempCssFolder).TrimStart("\\");
                        var cssFilePath  = Path.Combine(cssFolder, relativePath);
                        if (File.Exists(cssFilePath))
                        {
                            //backup
                            var targetPath = Path.Combine(tempCssFolder, relativePath.EnsureEndsWith(".bak"));
                            e.MigrationContext.Logger.Info <OverwriteStylesheetFilesFromTempFiles>("CSS file is being backed up from {0}, to {1} before being migrated to new format", () => cssFilePath, () => targetPath);
                            File.Copy(cssFilePath, targetPath, true);
                        }

                        //ensure the sub folder eixts
                        Directory.CreateDirectory(Path.GetDirectoryName(cssFilePath));
                        File.Copy(file, cssFilePath, true);
                    }
                }
            }
        }
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            if (e.ProductName != Constants.System.UmbracoMigrationName)
            {
                return;
            }

            var target = new Version(6, 0, 0);

            if (e.ConfiguredVersion < target)
            {
                var sql = new Sql();
                sql.Select("*")
                .From <DocumentDto>()
                .InnerJoin <ContentVersionDto>()
                .On <DocumentDto, ContentVersionDto>(left => left.VersionId, right => right.VersionId)
                .InnerJoin <ContentDto>()
                .On <ContentVersionDto, ContentDto>(left => left.NodeId, right => right.NodeId)
                .InnerJoin <NodeDto>()
                .On <ContentDto, NodeDto>(left => left.NodeId, right => right.NodeId)
                .Where <NodeDto>(x => x.NodeObjectType == new Guid(Constants.ObjectTypes.Document))
                .Where <NodeDto>(x => x.Path.StartsWith("-1"));

                var dtos         = e.MigrationContext.Database.Fetch <DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql);
                var toUpdate     = new List <DocumentDto>();
                var versionGroup = dtos.GroupBy(x => x.NodeId);
                foreach (var grp in versionGroup)
                {
                    var published = grp.FirstOrDefault(x => x.Published);
                    var newest    = grp.FirstOrDefault(x => x.Newest);

                    if (newest != null)
                    {
                        double timeDiff          = new TimeSpan(newest.UpdateDate.Ticks - newest.ContentVersionDto.VersionDate.Ticks).TotalMilliseconds;
                        var    hasPendingChanges = timeDiff > 2000;

                        if (hasPendingChanges == false && published != null)
                        {
                            published.Published = false;
                            toUpdate.Add(published);
                            newest.Published = true;
                            toUpdate.Add(newest);
                        }
                    }
                }

                //Commit the updated entries for the cmsDocument table
                using (var transaction = e.MigrationContext.Database.GetTransaction())
                {
                    //Loop through the toUpdate
                    foreach (var dto in toUpdate)
                    {
                        e.MigrationContext.Database.Update(dto);
                    }

                    transaction.Complete();
                }
            }
        }
Exemplo n.º 4
0
 protected void DataMigrationService_DataMigrationStop(object sender, MigrationEventArgs e)
 {
     if (e.status)
     {
         //log.Debug("Stopping service");
         StopDataMigrationThread(sender as IDataMigrator);
     }
 }
Exemplo n.º 5
0
        private void OnStepExecuting(MigrationEventArgs e)
        {
            EventHandler <MigrationEventArgs> tmp = StepExecuting;

            if (tmp != null)
            {
                tmp(this, e);
            }
        }
Exemplo n.º 6
0
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            var target720 = new Version(7, 2, 0);

            if (e.ConfiguredVersion <= target720)
            {
                EnsureListViewDataTypeCreated(e);
            }
        }
Exemplo n.º 7
0
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            var target70 = new Version(7, 0, 0);

            if (e.ConfiguredVersion <= target70)
            {
                var mediasvc = (MediaService)ApplicationContext.Current.Services.MediaService;
                mediasvc.RebuildXmlStructures();
            }
        }
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            var http = new HttpContextWrapper(HttpContext.Current);

            http.ExpireCookie(AngularAntiForgeryHelper.AngularCookieName);
            http.ExpireCookie(AngularAntiForgeryHelper.CsrfValidationCookieName);
        }
Exemplo n.º 9
0
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            if (e.ProductName != GlobalSettings.UmbracoMigrationName)
            {
                return;
            }

            var target720 = new Version(7, 2, 0);

            if (e.ConfiguredVersion <= target720)
            {
                EnsureListViewDataTypeCreated(e);
            }
        }
        protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
        {
            var target70 = new Version(7, 0, 0);

            if (e.ConfiguredVersion <= target70)
            {
                //This query is structured to work with MySql, SQLCE and SqlServer:
                // http://issues.umbraco.org/issue/U4-3876

                var sql = @"DELETE FROM cmsContentXml WHERE nodeId IN
    (SELECT nodeId FROM (SELECT DISTINCT cmsContentXml.nodeId FROM cmsContentXml 
    INNER JOIN umbracoNode ON cmsContentXml.nodeId = umbracoNode.id
    WHERE nodeObjectType = '" + Constants.ObjectTypes.Media + "' AND " + SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName("path") + " LIKE '%-21%') x)";

                var count = e.MigrationContext.Database.Execute(sql);

                LogHelper.Info <ClearMediaXmlCacheForDeletedItemsAfterUpgrade>("Cleared " + count + " items from the media xml cache that were trashed and not meant to be there");
            }
        }
 protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
 {
     _changed.CountExecuted++;
 }
Exemplo n.º 12
0
        private void EnsureListViewDataTypeCreated(MigrationEventArgs e)
        {
            using (var transaction = e.MigrationContext.Database.GetTransaction())
            {
                try
                {
                    //Turn on identity insert if db provider is not mysql
                    if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
                    {
                        e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("umbracoNode"))));
                    }

                    if (e.MigrationContext.Database.Exists <NodeDto>(Constants.System.DefaultContentListViewDataTypeId))
                    {
                        //If this already exists then just exit
                        return;
                    }

                    e.MigrationContext.Database.Insert("umbracoNode", "id", false, new NodeDto {
                        NodeId = Constants.System.DefaultContentListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-95", SortOrder = 2, UniqueId = new Guid("C0808DD3-8133-4E4B-8CE8-E2BEA84A96A4"), Text = Constants.Conventions.DataTypes.ListViewPrefix + "Content", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now
                    });
                    e.MigrationContext.Database.Insert("umbracoNode", "id", false, new NodeDto {
                        NodeId = Constants.System.DefaultMediaListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-96", SortOrder = 2, UniqueId = new Guid("3A0156C4-3B8C-4803-BDC1-6871FAA83FFF"), Text = Constants.Conventions.DataTypes.ListViewPrefix + "Media", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now
                    });
                    e.MigrationContext.Database.Insert("umbracoNode", "id", false, new NodeDto {
                        NodeId = Constants.System.DefaultMembersListViewDataTypeId, Trashed = false, ParentId = -1, UserId = 0, Level = 1, Path = "-1,-97", SortOrder = 2, UniqueId = new Guid("AA2C52A0-CE87-4E65-A47C-7DF09358585D"), Text = Constants.Conventions.DataTypes.ListViewPrefix + "Members", NodeObjectType = new Guid(Constants.ObjectTypes.DataType), CreateDate = DateTime.Now
                    });
                }
                finally
                {
                    //Turn off identity insert if db provider is not mysql
                    if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
                    {
                        e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("umbracoNode"))));
                    }
                }


                try
                {
                    //Turn on identity insert if db provider is not mysql
                    if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
                    {
                        e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataType"))));
                    }

                    e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto {
                        PrimaryKey = -26, DataTypeId = Constants.System.DefaultContentListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar"
                    });
                    e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto {
                        PrimaryKey = -27, DataTypeId = Constants.System.DefaultMediaListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar"
                    });
                    e.MigrationContext.Database.Insert("cmsDataType", "pk", false, new DataTypeDto {
                        PrimaryKey = -28, DataTypeId = Constants.System.DefaultMembersListViewDataTypeId, PropertyEditorAlias = Constants.PropertyEditors.ListViewAlias, DbType = "Nvarchar"
                    });
                }
                finally
                {
                    //Turn off identity insert if db provider is not mysql
                    if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
                    {
                        e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataType"))));
                    }
                }



                try
                {
                    //Turn on identity insert if db provider is not mysql
                    if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
                    {
                        e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataTypePreValues"))));
                    }

                    //defaults for the member list
                    e.MigrationContext.Database.Insert("cmsDataTypePreValues", "id", false, new DataTypePreValueDto {
                        Id = -1, Alias = "pageSize", SortOrder = 1, DataTypeNodeId = Constants.System.DefaultMembersListViewDataTypeId, Value = "10"
                    });
                    e.MigrationContext.Database.Insert("cmsDataTypePreValues", "id", false, new DataTypePreValueDto {
                        Id = -2, Alias = "orderBy", SortOrder = 2, DataTypeNodeId = Constants.System.DefaultMembersListViewDataTypeId, Value = "Name"
                    });
                    e.MigrationContext.Database.Insert("cmsDataTypePreValues", "id", false, new DataTypePreValueDto {
                        Id = -3, Alias = "orderDirection", SortOrder = 3, DataTypeNodeId = Constants.System.DefaultMembersListViewDataTypeId, Value = "asc"
                    });
                    e.MigrationContext.Database.Insert("cmsDataTypePreValues", "id", false, new DataTypePreValueDto {
                        Id = -4, Alias = "includeProperties", SortOrder = 4, DataTypeNodeId = Constants.System.DefaultMembersListViewDataTypeId, Value = "[{\"alias\":\"email\",\"isSystem\":1},{\"alias\":\"username\",\"isSystem\":1},{\"alias\":\"updateDate\",\"header\":\"Last edited\",\"isSystem\":1}]"
                    });
                }
                finally
                {
                    //Turn off identity insert if db provider is not mysql
                    if (SqlSyntaxContext.SqlSyntaxProvider.SupportsIdentityInsert())
                    {
                        e.MigrationContext.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName("cmsDataTypePreValues"))));
                    }
                }



                transaction.Complete();
            }
        }
Exemplo n.º 13
0
 private void OnStepExecuting(MigrationEventArgs e)
 {
     EventHandler<MigrationEventArgs> tmp = StepExecuting;
     if (tmp != null) tmp(this, e);
 }
 private void InvokeMigrating(MigrationEventArgs args)
 {
     MigrationEventHandler migratingHandler = Migrating;
     if(migratingHandler != null) 
         migratingHandler(this, args);
 }