Exemplo n.º 1
0
        public virtual void Process(MigrateVersionPipelineArgs args)
        {
            if (args.Item == null ||
                args.Source == null)
            {
                return;
            }

            var source = args.Source;
            var item   = args.Item;

            // Confirm we are processing a Media Item
            if (!item.Paths.IsMediaItem || item.TemplateID == TemplateIDs.MediaFolder)
            {
                return;
            }

            // Is the original media item unversioned.
            var blobField = source.Fields.FirstOrDefault(x => x.Name == "Blob");

            if (blobField == null || !blobField.Shared)
            {
                return;
            }

            // This is an unversioned media item. Are any exceptions registered
            if (Exceptions.Contains(source.Language.ToLower()))
            {
                return;
            }

            // Do not process the media item
            args.AbortPipeline();
        }
        public virtual void Process(MigrateVersionPipelineArgs args)
        {
            if (args.Item == null ||
                args.Source == null)
            {
                return;
            }

            var item = args.Item;

            var languageName = (Overrides.ContainsKey(args.Source.Language)) ? Overrides[args.Source.Language] : args.Source.Language;

            // Ensure we are working with the correct language
            var language = LanguageManager.GetLanguage(languageName);

            item = (item.Language == language) ? item : item.Database.GetItem(item.ID, language);

            // Create version if it does not exist
            if (item.Versions.Count == 0)
            {
                var disableFiltering = Sitecore.Context.Site.DisableFiltering;
                try
                {
                    Sitecore.Context.Site.DisableFiltering = true;
                    item = item.Versions.AddVersion();
                }
                finally
                {
                    Sitecore.Context.Site.DisableFiltering = disableFiltering;
                }
            }

            args.Item = item;
        }
        public virtual void Process(MigrateVersionPipelineArgs args)
        {
            if (args.Source == null ||
                args.Item == null)
            {
                return;
            }

            foreach (var itemFieldModel in args.Source.Fields)
            {
                _migrateFieldPipeline.Run(itemFieldModel, args.Item);
            }
        }
Exemplo n.º 4
0
        public virtual void Process(MigrateVersionPipelineArgs args)
        {
            if (args.Source == null ||
                args.Item == null)
            {
                return;
            }

            var source = args.Source;
            var item   = args.Item;

            // Confirm we are processing a Media Item
            if (!item.Paths.IsMediaItem || item.TemplateID == TemplateIDs.MediaFolder)
            {
                return;
            }

            // Confirm the target is a versioned media item
            if (item.Template.FullName.Contains("Unversioned"))
            {
                return;
            }

            var media = MediaManager.GetMedia(item);

            var blobField = source.Fields.First(x => string.Equals(x.Name, "Blob", StringComparison.OrdinalIgnoreCase));

            if (string.IsNullOrEmpty(blobField.Value))
            {
                media.ReleaseStream();
            }
            else
            {
                // Grab extension
                var extensionField = source.Fields.FirstOrDefault(x => string.Equals(x.Name, "Extension", StringComparison.OrdinalIgnoreCase));
                if (extensionField == null)
                {
                    return;
                }

                _hardRockWebServiceProxy.SetContextLanguage(item.Language.Name);
                using (var stream = new MemoryStream(_hardRockWebServiceProxy.MediaDownloadAttachment(source.Item.Id)))
                {
                    media.SetStream(stream, extensionField.Value);
                }
            }
        }
Exemplo n.º 5
0
        public virtual void Process(MigrateVersionPipelineArgs args)
        {
            if (args.Source == null ||
                args.Item == null)
            {
                return;
            }

            var source = args.Source;
            var item   = args.Item;

            if (!(source.HasWorkflow && source.WorkflowState == WorkflowState.NonFinal))
            {
                var workflow = item.Database.WorkflowProvider.GetWorkflow(item);
                if (workflow != null)
                {
                    var states     = workflow.GetStates();
                    var finalState = states.First(x => x.FinalState);
                    item.Fields["__Workflow state"].Value = finalState.StateID;
                }
            }
        }
        public MigrateVersionPipelineArgs Run(VersionModel source, Item item)
        {
            var args = new MigrateVersionPipelineArgs {
                Source = source, Item = item
            };

            try
            {
                var stopWatch = new Stopwatch();
                stopWatch.Start();

                CorePipeline.Run("migrateVersion", args, "OneNorth.Migrator");

                stopWatch.Stop();

                Sitecore.Diagnostics.Log.Info(string.Format("[FieldMigrator] (MigrateVersionPipeline) Migrated: {0} in {1}", args.Item.Uri, stopWatch.Elapsed), this);
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(string.Format("[FieldMigrator] (MigrateVersionPipeline) {0}", args.Item.Uri), ex, this);
            }

            return(args);
        }