Exemplo n.º 1
0
        protected override void ProcessRecord()
        {
            if (Yaml == null && Item == null)
            {
                throw new InvalidOperationException("Neither YAML strings or IItemDatas were passed in, cannot process.");
            }

            var console       = new PowershellProgressStatus(Host, "Deserialize Item");
            var consoleLogger = new WebConsoleLogger(console, MessageType.Debug);

            var yaml = CreateFormatter(CreateFieldFilter());

            // Ignoring BranchId should probably be controllable from the outside. For now it will just be wired to false.
            // See issue 283 in Unicorn. https://github.com/SitecoreUnicorn/Unicorn/issues/283
            // Unicorn default for this will be to ignore BranchId
            var deserializer = new DefaultDeserializer(false, new DefaultDeserializerLogger(consoleLogger), CreateFieldFilter());

            if (Yaml != null)
            {
                using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(Yaml)))
                {
                    var item = yaml.ReadSerializedItem(stream, "(from PowerShell)");

                    consoleLogger.Info(item.Path);
                    deserializer.Deserialize(item, null);
                }
            }

            if (Item != null)
            {
                consoleLogger.Info(Item.Path);
                deserializer.Deserialize(Item, null);
            }
        }
Exemplo n.º 2
0
        protected override void ProcessRecord()
        {
            var configurations = PipelineConfiguration != null ? new [] { PipelineConfiguration } : UnicornConfigurationManager.Configurations;

            if (!All.IsPresent && PipelineConfiguration == null)
            {
                if (Configurations == null || Configurations.Length == 0)
                {
                    throw new InvalidOperationException("-All was not specified, but neither was -Configurations.");
                }

                var includedConfigs = new HashSet <string>(Configurations, StringComparer.OrdinalIgnoreCase);

                configurations = configurations
                                 .Where(config => includedConfigs.Contains(config.Name))
                                 .ToArray();
            }

            var console = new PowershellProgressStatus(Host, "Reserialize Unicorn");

            bool success = _helper.ReserializeConfigurations(configurations, console, new WebConsoleLogger(console, MessageType.Debug));

            if (!success || console.HasErrors)
            {
                throw new InvalidOperationException("Reserialize failed. Review preceding logs for details.");
            }
        }
Exemplo n.º 3
0
        protected override void ProcessRecord()
        {
            if (Yaml == null && Item == null)
            {
                throw new InvalidOperationException("Neither YAML strings or IItemDatas were passed in, cannot process.");
            }

            var console       = new PowershellProgressStatus(Host, "Deserialize Item");
            var consoleLogger = new WebConsoleLogger(console, MessageType.Debug);

            var yaml = CreateFormatter(CreateFieldFilter());

            var deserializer = new DefaultDeserializer(new DefaultDeserializerLogger(consoleLogger), CreateFieldFilter());

            if (Yaml != null)
            {
                using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(Yaml)))
                {
                    var item = yaml.ReadSerializedItem(stream, "(from PowerShell)");

                    consoleLogger.Info(item.Path);
                    deserializer.Deserialize(item);
                }
            }

            if (Item != null)
            {
                consoleLogger.Info(Item.Path);
                deserializer.Deserialize(Item);
            }
        }
        protected override void EndProcessing()
        {
            var configurations = _configurations.ToArray();

            if (SkipTransparent.IsPresent)
            {
                configurations = configurations.SkipTransparentSync().ToArray();
            }

            var console = new PowershellProgressStatus(Host, "Sync Unicorn");

            bool success = _helper.SyncConfigurations(configurations, console, new WebConsoleLogger(console, LogLevel.ToString()));

            if (!success || console.HasErrors)
            {
                throw new InvalidOperationException("Sync failed. Review preceding logs for details.");
            }
        }