public MigrateFieldPipelineArgs Run(FieldModel source, Item item)
        {
            var args = new MigrateFieldPipelineArgs {
                Source = source, Item = item
            };

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

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

                stopWatch.Stop();

                if (args.Field == null)
                {
                    Sitecore.Diagnostics.Log.Debug(string.Format("[FieldMigrator] (MigrateFieldPipeline) Did not migrate: {0} {1} in {2}", args.Item.Uri, source.Name, stopWatch.Elapsed), this);
                }
                else
                {
                    Sitecore.Diagnostics.Log.Debug(string.Format("[FieldMigrator] (MigrateFieldPipeline) Migrated: {0} {1} in {2}", args.Item.Uri, args.Field.Name, stopWatch.Elapsed), this);
                }
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(string.Format("[FieldMigrator] (MigrateFieldPipeline) {0} {1}", args.Item.Uri, source.Name), ex, this);
            }

            return(args);
        }
Exemplo n.º 2
0
        public virtual void Process(MigrateFieldPipelineArgs args)
        {
            if (args.Source == null)
            {
                return;
            }

            var source = args.Source;

            if (Fields.Contains(source.Name) || Fields.Contains(source.Id.ToString()))
            {
                args.AbortPipeline();
            }
        }
        public virtual void Process(MigrateFieldPipelineArgs args)
        {
            if (args.Source == null)
            {
                return;
            }

            var source = args.Source;

            if (string.IsNullOrEmpty(source.Name) ||
                (source.Name.StartsWith("__") &&
                 !Exceptions.Contains(source.Name, StringComparer.OrdinalIgnoreCase)))
            {
                args.AbortPipeline();
            }
        }
        public void Process(MigrateFieldPipelineArgs args)
        {
            if (args.Field == null)
            {
                return;
            }

            var field = args.Field;

            // Process Media
            var mediaIds = new List <ID>();

            if (field.Type == "File")
            {
                var fileField = (FileField)field;
                if (!ID.IsNullOrEmpty(fileField.MediaID))
                {
                    mediaIds.Add(fileField.MediaID);
                }
            }
            else if (field.Type == "Image")
            {
                var imageField = (ImageField)field;
                if (!ID.IsNullOrEmpty(imageField.MediaID))
                {
                    mediaIds.Add(imageField.MediaID);
                }
            }
            else if (field.Type == "Rich Text")
            {
                var matches = _mediaRegex.Matches(field.Value);
                foreach (Match match in matches)
                {
                    var value = match.Groups[1].Value;
                    mediaIds.Add(new ID(value));
                }
            }

            foreach (var id in mediaIds)
            {
                _migrationHelper.MigrateRoot(id.Guid);
            }
        }
        public virtual void Process(MigrateFieldPipelineArgs args)
        {
            if (args.Source == null ||
                args.Item == null)
            {
                return;
            }

            if (!args.Item.Paths.IsMediaItem || args.Item.TemplateID == TemplateIDs.MediaFolder)
            {
                return;
            }

            var source = args.Source;

            if (string.IsNullOrEmpty(source.Name) ||
                (!source.Name.StartsWith("__") &&
                 !Exceptions.Contains(source.Name, StringComparer.OrdinalIgnoreCase)))
            {
                args.AbortPipeline();
            }
        }
Exemplo n.º 6
0
        public void Process(MigrateFieldPipelineArgs args)
        {
            if (args.Source == null ||
                args.Item == null ||
                args.Field == null)
            {
                return;
            }

            var source = args.Source;
            var field  = args.Field;

            if (source.Value == null)
            {
                field.Reset();
            }
            else
            {
                field.Value = source.Value;
            }

            ProcessMedia(field);
        }
Exemplo n.º 7
0
        public void Process(MigrateFieldPipelineArgs args)
        {
            if (args.Source == null ||
                args.Item == null ||
                args.Field != null)
            {
                return;
            }

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

            var fieldOverride = Overrides.FirstOrDefault(x => x.SourceFieldId == source.Id && (!x.SourceTemplateIds.Any() || x.SourceTemplateIds.Contains(source.Version.Item.TemplateId)));

            if (fieldOverride != null)
            {
                args.Field = item.Fields[new ID(fieldOverride.TargetFieldId)];
            }
            else
            {
                args.Field = item.Fields[source.Name];
            }
        }