Ejemplo n.º 1
0
        protected override void Process(IProgressStatus progress)
        {
            var configurations = ResolveConfigurations();

            foreach (var configuration in configurations)
            {
                var logger = configuration.Resolve <ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Sync: Processing Unicorn configuration " + configuration.Name);

                        var beginArgs = new UnicornSyncBeginPipelineArgs(configuration);
                        CorePipeline.Run("unicornSyncBegin", beginArgs);

                        if (beginArgs.Aborted)
                        {
                            logger.Error("Unicorn Sync Begin pipeline was aborted. Not executing sync for this configuration.");
                            continue;
                        }

                        if (beginArgs.SyncIsHandled)
                        {
                            logger.Info("Unicorn Sync Begin pipeline signalled that it handled the sync for this configuration.");
                            continue;
                        }

                        var pathResolver       = configuration.Resolve <PredicateRootPathResolver>();
                        var retryer            = configuration.Resolve <IDeserializeFailureRetryer>();
                        var consistencyChecker = configuration.Resolve <IConsistencyChecker>();
                        var loader             = configuration.Resolve <SerializationLoader>();

                        var roots = pathResolver.GetRootSerializedItems();

                        var index = 0;

                        loader.LoadAll(roots, retryer, consistencyChecker, item =>
                        {
                            progress.Report((int)(((index + 1) / (double)roots.Length) * 100));
                            index++;
                        });

                        CorePipeline.Run("unicornSyncComplete", new UnicornSyncCompletePipelineArgs(configuration));

                        logger.Info("Control Panel Sync: Completed syncing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }

            CorePipeline.Run("unicornSyncEnd", new UnicornSyncEndPipelineArgs(configurations));
        }
Ejemplo n.º 2
0
        protected virtual void ProcessInternal(IProgressStatus progress)
        {
            // this bad-ass ASCII art is from http://www.ascii-art.de/ascii/uvw/unicorn.txt - original credit to 'sk'
            const string unicorn = @"<pre>
                        /
                      .7
           \       , //
           |\.--._/|//
          /\ ) ) ).'/
         /(  \  // /       _   _ _   _ ___ ____ ___  ____  _   _ 
        /(   J`((_/ \     | | | | \ | |_ _/ ___/ _ \|  _ \| \ | |
       / ) | _\     /     | | | |  \| || | |  | | | | |_) |  \| |
      /|)  \  eJ    L     | |_| | |\  || | |__| |_| |  _ <| |\  |
     |  \ L \   L   L      \___/|_| \_|___\____\___/|_| \_\_| \_|
    /  \  J  `. J   L
    |  )   L   \/   \
   /  \    J   (\   /
  |  \      \   \```
</pre>";

            // note: these logs are intentionally to progress and not loggingConsole as we don't need them in the Sitecore logs
            progress.ReportStatus(unicorn, MessageType.Warning);
            progress.ReportTransientStatus("Executing.");

            var heartbeat = new Timer(3000);
            var startTime = DateTime.Now;

            heartbeat.AutoReset = true;
            heartbeat.Elapsed  += (sender, args) =>
            {
                var elapsed = Math.Round((args.SignalTime - startTime).TotalSeconds);

                progress.ReportTransientStatus("Executing for {0} sec.", elapsed.ToString(CultureInfo.InvariantCulture));
            };

            heartbeat.Start();

            try
            {
                using (new SecurityDisabler())
                {
                    using (new ItemFilterDisabler())                     // disable all item filtering (if we're running in live mode we need this to get unadulterated items)
                    {
                        Process(progress);
                    }
                }
            }
            finally
            {
                heartbeat.Stop();
            }

            progress.Report(100);
            progress.ReportTransientStatus("Completed.");
            progress.ReportStatus(_isAutomatedTool ? "\r\n" : "<br>");
            progress.ReportStatus("Completed. Want to <a href=\"?verb=\">return to the control panel?</a>");
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Sets the progress of the whole based on the progress within a percentage range of the main progress (e.g. 0-100% of a task within the global range of 0-20%)
		/// </summary>
		/// <param name="progress"></param>
		/// <param name="startPercentage">The percentage the task began at</param>
		/// <param name="endPercentage">The percentage the task ends at</param>
		/// <param name="taskPercent">The percentage complete of the sub-task (0-100)</param>
		private static void SetRangeTaskProgress(IProgressStatus progress, int startPercentage, int endPercentage, int taskPercent)
		{
			int range = endPercentage - startPercentage;

			if (range <= 0) throw new ArgumentException("endPercentage must be greater than startPercentage");

			int offset = (int)Math.Round(range * (taskPercent / 100d));

			progress.Report(Math.Min(startPercentage + offset, 100));
		}
        protected override void ProcessInternal(IProgressStatus progress)
        {
            if (_headingService != null && !_isAutomatedTool)
            {
                progress.ReportStatus(_headingService.GetHeadingHtml());
            }

            // note: these logs are intentionally to progress and not loggingConsole as we don't need them in the Sitecore logs

            progress.ReportTransientStatus("Executing.");

            var heartbeat = new Timer(3000);

            var timer = new Stopwatch();

            timer.Start();

            heartbeat.AutoReset = true;
            heartbeat.Elapsed  += (sender, args) =>
            {
                var elapsed = Math.Round(timer.ElapsedMilliseconds / 1000d);

                try
                {
                    progress.ReportTransientStatus("Executing for {0} sec.", elapsed.ToString(CultureInfo.InvariantCulture));
                }
                catch
                {
                    // e.g. HTTP connection disconnected - prevent infinite looping
                    heartbeat.Stop();
                }
            };

            heartbeat.Start();

            try
            {
                using (new SecurityDisabler())
                {
                    _processAction(progress);
                }
            }
            finally
            {
                heartbeat.Stop();
            }

            timer.Stop();

            progress.Report(100);
            progress.ReportTransientStatus("Operation completed.");
            progress.ReportStatus(_isAutomatedTool ? "\r\n" : "<br>");
            progress.ReportStatus(_isAutomatedTool ? $"Completed in {timer.ElapsedMilliseconds}ms." : $"Operation completed in {timer.ElapsedMilliseconds}ms. Want to <a href=\"?verb=\">return to the control panel?</a>");
        }
Ejemplo n.º 5
0
        protected virtual void ProcessInternal(IProgressStatus progress)
        {
            if (_headingService != null && !_isAutomatedTool)
            {
                progress.ReportStatus(_headingService.GetHeadingHtml());
            }

            // note: these logs are intentionally to progress and not loggingConsole as we don't need them in the Sitecore logs

            progress.ReportTransientStatus("Executing.");

            var heartbeat = new Timer(3000);
            var startTime = DateTime.Now;

            heartbeat.AutoReset = true;
            heartbeat.Elapsed  += (sender, args) =>
            {
                var elapsed = Math.Round((args.SignalTime - startTime).TotalSeconds);

                try
                {
                    progress.ReportTransientStatus("Executing for {0} sec.", elapsed.ToString(CultureInfo.InvariantCulture));
                }
                catch
                {
                    // e.g. HTTP connection disconnected - prevent infinite looping
                    heartbeat.Stop();
                }
            };

            heartbeat.Start();

            try
            {
                using (new SecurityDisabler())
                {
                    using (new ItemFilterDisabler())                     // disable all item filtering (if we're running in live mode we need this to get unadulterated items)
                    {
                        Process(progress);
                    }
                }
            }
            finally
            {
                heartbeat.Stop();
            }

            progress.Report(100);
            progress.ReportTransientStatus("Completed.");
            progress.ReportStatus(_isAutomatedTool ? "\r\n" : "<br>");
            progress.ReportStatus("Completed. Want to <a href=\"?verb=\">return to the control panel?</a>");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sets the progress of the whole based on the progress within a percentage range of the main progress (e.g. 0-100% of a task within the global range of 0-20%)
        /// </summary>
        /// <param name="progress"></param>
        /// <param name="startPercentage">The percentage the task began at</param>
        /// <param name="endPercentage">The percentage the task ends at</param>
        /// <param name="taskPercent">The percentage complete of the sub-task (0-100)</param>
        private static void SetRangeTaskProgress(IProgressStatus progress, int startPercentage, int endPercentage, int taskPercent)
        {
            int range = endPercentage - startPercentage;

            if (range <= 0)
            {
                throw new ArgumentException("endPercentage must be greater than startPercentage");
            }

            int offset = (int)Math.Round(range * (taskPercent / 100d));

            progress.Report(Math.Min(startPercentage + offset, 100));
        }
        /// <summary>
        /// Sets the progress of the whole based on the progress within a percentage range of the main progress (e.g. 0-100% of a task within the global range of 0-20%)
        /// </summary>
        /// <param name="startPercentage">The percentage the task began at</param>
        /// <param name="endPercentage">The percentage the task ends at</param>
        /// <param name="taskPercent">The percentage complete of the sub-task (0-100)</param>
        protected virtual void SetRangeTaskProgress(int startPercentage, int endPercentage, int taskPercent)
        {
            int range = endPercentage - startPercentage;

            if (range <= 0)
            {
                throw new ArgumentException("endPercentage must be greater than startPercentage");
            }

            int offset = (int)Math.Round(range * (taskPercent / 100d));

            _mainTask.Report(Math.Min(startPercentage + offset, 100));
        }
Ejemplo n.º 8
0
        protected override void Process(IProgressStatus progress)
        {
            foreach (var configuration in ResolveConfigurations())
            {
                var logger = configuration.Resolve<ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        var timer = new Stopwatch();
                        timer.Start();

                        logger.Info(configuration.Name + " is being reserialized");

                        using (new TransparentSyncDisabler())
                        {
                            var targetDataStore = configuration.Resolve<ITargetDataStore>();
                            var helper = configuration.Resolve<SerializationHelper>();

                            // nuke any existing items in the store before we begin. This is a full reserialize so we want to
                            // get rid of any existing stuff even if it's not part of existing configs
                            logger.Warn("[D] Clearing existing items from {0}".FormatWith(targetDataStore.FriendlyName));
                            targetDataStore.Clear();

                            var roots = configuration.Resolve<PredicateRootPathResolver>().GetRootSourceItems();

                            int index = 1;
                            foreach (var root in roots)
                            {
                                helper.DumpTree(root, configuration);
                                progress.Report((int) ((index/(double) roots.Length)*100));
                                index++;
                            }
                        }

                        timer.Stop();

                        logger.Info("{0} reserialization complete in {1}ms".FormatWith(configuration.Name, timer.ElapsedMilliseconds));
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 9
0
        protected override void Process(IProgressStatus progress)
        {
            foreach (var configuration in ResolveConfigurations())
            {
                var logger = configuration.Resolve<ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Reserialize: Processing Unicorn configuration " + configuration.Name);

                        var predicate = configuration.Resolve<IPredicate>();
                        var serializationProvider = configuration.Resolve<ISerializationProvider>();

                        var roots = configuration.Resolve<PredicateRootPathResolver>().GetRootSourceItems();

                        int index = 1;
                        foreach (var root in roots)
                        {
                            var rootReference = serializationProvider.GetReference(root);
                            if (rootReference != null)
                            {
                                logger.Warn("[D] existing serialized items under {0}".FormatWith(rootReference.DisplayIdentifier));
                                // TODO: this doesn't really account for excluded children - it just nukes everything.
                                // ideally it would leave excluded serialized items alone.
                                rootReference.Delete();
                            }

                            logger.Info("[U] Serializing included items under root {0}".FormatWith(root.DisplayIdentifier));
                            Serialize(root, predicate, serializationProvider, logger);
                            progress.Report((int) ((index/(double) roots.Length)*100));
                            index++;
                        }

                        logger.Info("Control Panel Reserialize: Finished reserializing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        protected override void Process(IProgressStatus progress)
        {
            foreach (var configuration in ResolveConfigurations())
            {
                var logger = configuration.Resolve <ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Reserialize: Processing Unicorn configuration " + configuration.Name);

                        var predicate             = configuration.Resolve <IPredicate>();
                        var serializationProvider = configuration.Resolve <ISerializationProvider>();

                        var roots = configuration.Resolve <PredicateRootPathResolver>().GetRootSourceItems();

                        int index = 1;
                        foreach (var root in roots)
                        {
                            var rootReference = serializationProvider.GetReference(root);
                            if (rootReference != null)
                            {
                                logger.Warn("[D] existing serialized items under {0}".FormatWith(rootReference.DisplayIdentifier));
                                // TODO: this doesn't really account for excluded children - it just nukes everything.
                                // ideally it would leave excluded serialized items alone.
                                rootReference.Delete();
                            }

                            logger.Info("[U] Serializing included items under root {0}".FormatWith(root.DisplayIdentifier));
                            Serialize(root, predicate, serializationProvider, logger);
                            progress.Report((int)((index / (double)roots.Length) * 100));
                            index++;
                        }

                        logger.Info("Control Panel Reserialize: Finished reserializing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 11
0
		protected override void Process(IProgressStatus progress)
		{
			progress.ReportStatus("Starting WebForms demonstration...");

			for (int i = 0; i <= 100; i++)
			{
				// slight delay to see loading time
				System.Threading.Thread.Sleep(50);

				// advance the progress bar status (you can use x % as well as x of y total items)
				progress.Report(i);

				// demonstrate setting a substatus of the progress bar (e.g. "making database backup")
				if (i % 10 == 0) progress.ReportTransientStatus(string.Format("{0}/{1}", i, 100));

				// write some stuff to the console to demonstrate detailed output
				progress.ReportStatus("At {0}", MessageType.Info, i);
				if (i == 90) progress.ReportStatus("Oops, fake error", MessageType.Error);
				if (i == 91) progress.ReportStatus("Warning: this can be harmful if misused.", MessageType.Warning);
				if (i == 92)
				{
					progress.ReportStatus("You can also {0} {1}", MessageType.Debug, "use", "string formatting");
				}

				if (i == 95)
				{
					progress.ReportStatus("I'm about to throw an exception and write its data to the console!");

					// code that can throw an exception should have it caught and written to the console
					// normally you might wrap the whole processing in a try-catch block
					try
					{
						throw new Exception("I'm giving it all she's got Jim!", new Exception("Warp core breach"));
					}
					catch(Exception ex)
					{
						progress.ReportException(ex);
					}
				}
			}

			progress.ReportStatus("WebForms demo complete. See the <a href=\"Tasks.aspx\">tasks demo</a> and the <a href=\"customized.aspx\">customization demo</a>");
		}	
Ejemplo n.º 12
0
        protected override void Process(IProgressStatus progress)
        {
            var configurations = ResolveConfigurations();

            foreach (var configuration in configurations)
            {
                var logger = configuration.Resolve<ILogger>();
                var helper = configuration.Resolve<SerializationHelper>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Sync: Processing Unicorn configuration " + configuration.Name);

                        using (new TransparentSyncDisabler())
                        {
                            var pathResolver = configuration.Resolve<PredicateRootPathResolver>();

                            var roots = pathResolver.GetRootSerializedItems();

                            var index = 0;

                            helper.SyncTree(configuration, item =>
                            {
                                progress.Report((int) (((index + 1)/(double) roots.Length)*100));
                                index++;
                            }, roots);
                        }

                        logger.Info("Control Panel Sync: Completed syncing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }

            CorePipeline.Run("unicornSyncEnd", new UnicornSyncEndPipelineArgs(configurations));
        }
Ejemplo n.º 13
0
        protected override void Process(IProgressStatus progress)
        {
            var configurations = ResolveConfigurations();

            foreach (var configuration in configurations)
            {
                var logger = configuration.Resolve <ILogger>();
                var helper = configuration.Resolve <SerializationHelper>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Sync: Processing Unicorn configuration " + configuration.Name);

                        using (new TransparentSyncDisabler())
                        {
                            var pathResolver = configuration.Resolve <PredicateRootPathResolver>();

                            var roots = pathResolver.GetRootSerializedItems();

                            var index = 0;

                            helper.SyncTree(configuration, item =>
                            {
                                progress.Report((int)(((index + 1) / (double)roots.Length) * 100));
                                index++;
                            }, roots);
                        }

                        logger.Info("Control Panel Sync: Completed syncing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }

            CorePipeline.Run("unicornSyncEnd", new UnicornSyncEndPipelineArgs(configurations));
        }
Ejemplo n.º 14
0
		protected void ExecuteTask(IProgressStatus progress)
		{
			for (int i = 0; i <= 100; i++)
			{
				// slight delay to see loading time
				Thread.Sleep(10);

				// demonstrate setting a substatus of the progress bar (e.g. "making database backup")
				if (i % 10 == 0)
				{
					progress.ReportTransientStatus(string.Format("{0}/{1}", i, 100));

					// write some stuff to the console to demonstrate detailed output
					progress.ReportStatus("Task percent {0}", MessageType.Info, i);
				}

				// advance the progress bar status (you can use x % as well as x of y total items)
				progress.Report(i);
			}
		}
Ejemplo n.º 15
0
        protected override void Process(IProgressStatus progress)
        {
            foreach (var configuration in ResolveConfigurations())
            {
                var logger = configuration.Resolve <ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Sync: Processing Unicorn configuration " + configuration.Name);

                        var pathResolver       = configuration.Resolve <PredicateRootPathResolver>();
                        var retryer            = configuration.Resolve <IDeserializeFailureRetryer>();
                        var consistencyChecker = configuration.Resolve <IConsistencyChecker>();
                        var loader             = configuration.Resolve <SerializationLoader>();

                        var roots = pathResolver.GetRootSerializedItems();

                        var index = 0;

                        loader.LoadAll(roots, retryer, consistencyChecker, item =>
                        {
                            progress.Report((int)(((index + 1) / (double)roots.Length) * 100));
                            index++;
                        });

                        logger.Info("Control Panel Sync: Completed syncing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 16
0
        protected override void Process(IProgressStatus progress)
        {
            foreach (var configuration in ResolveConfigurations())
            {
                var logger = configuration.Resolve<ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Reserialize: Processing Unicorn configuration " + configuration.Name);

                        using (new TransparentSyncDisabler())
                        {
                            var helper = configuration.Resolve<SerializationHelper>();

                            var roots = configuration.Resolve<PredicateRootPathResolver>().GetRootSourceItems();

                            int index = 1;
                            foreach (var root in roots)
                            {
                                helper.DumpTree(root);
                                progress.Report((int) ((index/(double) roots.Length)*100));
                                index++;
                            }
                        }

                        logger.Info("Control Panel Reserialize: Finished reserializing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 17
0
        protected override void Process(IProgressStatus progress)
        {
            foreach (var configuration in ResolveConfigurations())
            {
                var logger = configuration.Resolve<ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Sync: Processing Unicorn configuration " + configuration.Name);

                        var pathResolver = configuration.Resolve<PredicateRootPathResolver>();
                        var retryer = configuration.Resolve<IDeserializeFailureRetryer>();
                        var consistencyChecker = configuration.Resolve<IConsistencyChecker>();
                        var loader = configuration.Resolve<SerializationLoader>();

                        var roots = pathResolver.GetRootSerializedItems();

                        for (int index = 0; index < roots.Length; index++)
                        {
                            // note: this would be simpler if we used loader.LoadAll() here
                            // however, we wouldn't be able to track progress.
                            loader.LoadTree(roots[index], retryer, consistencyChecker);
                            progress.Report((int)(((index + 1) / (double)roots.Length) * 100));
                        }

                        logger.Info("Control Panel Sync: Completed syncing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 18
0
        protected override void Process(IProgressStatus progress)
        {
            foreach (var configuration in ResolveConfigurations())
            {
                var logger = configuration.Resolve <ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Reserialize: Processing Unicorn configuration " + configuration.Name);

                        using (new TransparentSyncDisabler())
                        {
                            var helper = configuration.Resolve <SerializationHelper>();

                            var roots = configuration.Resolve <PredicateRootPathResolver>().GetRootSourceItems();

                            int index = 1;
                            foreach (var root in roots)
                            {
                                helper.DumpTree(root);
                                progress.Report((int)((index / (double)roots.Length) * 100));
                                index++;
                            }
                        }

                        logger.Info("Control Panel Reserialize: Finished reserializing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 19
0
        protected override void Process(IProgressStatus progress)
        {
            var configurations = ResolveConfigurations();

            foreach (var configuration in configurations)
            {
                var logger = configuration.Resolve<ILogger>();

                using (new LoggingContext(new WebConsoleLogger(progress), configuration))
                {
                    try
                    {
                        logger.Info("Control Panel Sync: Processing Unicorn configuration " + configuration.Name);

                        var beginArgs = new UnicornSyncBeginPipelineArgs(configuration);
                        CorePipeline.Run("unicornSyncBegin", beginArgs);

                        if (beginArgs.Aborted)
                        {
                            logger.Error("Unicorn Sync Begin pipeline was aborted. Not executing sync for this configuration.");
                            continue;
                        }

                        if (beginArgs.SyncIsHandled)
                        {
                            logger.Info("Unicorn Sync Begin pipeline signalled that it handled the sync for this configuration.");
                            continue;
                        }

                        var pathResolver = configuration.Resolve<PredicateRootPathResolver>();
                        var retryer = configuration.Resolve<IDeserializeFailureRetryer>();
                        var consistencyChecker = configuration.Resolve<IConsistencyChecker>();
                        var loader = configuration.Resolve<SerializationLoader>();

                        var roots = pathResolver.GetRootSerializedItems();

                        var index = 0;

                        loader.LoadAll(roots, retryer, consistencyChecker, item =>
                        {
                            progress.Report((int)(((index + 1) / (double)roots.Length) * 100));
                            index++;
                        });

                        CorePipeline.Run("unicornSyncComplete", new UnicornSyncCompletePipelineArgs(configuration));

                        logger.Info("Control Panel Sync: Completed syncing Unicorn configuration " + configuration.Name);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex);
                        break;
                    }
                }
            }

            CorePipeline.Run("unicornSyncEnd", new UnicornSyncEndPipelineArgs(configurations));
        }
Ejemplo n.º 20
0
        protected virtual void ProcessInternal(IProgressStatus progress)
        {
            if (_headingService != null && !_isAutomatedTool)
            {
                progress.ReportStatus(_headingService.GetHeadingHtml());
            }

            // note: these logs are intentionally to progress and not loggingConsole as we don't need them in the Sitecore logs

            progress.ReportTransientStatus("Executing.");

            var heartbeat = new Timer(3000);
            var startTime = DateTime.Now;
            heartbeat.AutoReset = true;
            heartbeat.Elapsed += (sender, args) =>
            {
                var elapsed = Math.Round((args.SignalTime - startTime).TotalSeconds);

                try
                {
                    progress.ReportTransientStatus("Executing for {0} sec.", elapsed.ToString(CultureInfo.InvariantCulture));
                }
                catch
                {
                    // e.g. HTTP connection disconnected - prevent infinite looping
                    heartbeat.Stop();
                }
            };

            heartbeat.Start();

            try
            {
                using (new SecurityDisabler())
                {
                    using (new ItemFilterDisabler()) // disable all item filtering (if we're running in live mode we need this to get unadulterated items)
                    {
                        Process(progress);
                    }
                }
            }
            finally
            {
                heartbeat.Stop();
            }

            progress.Report(100);
            progress.ReportTransientStatus("Completed.");
            progress.ReportStatus(_isAutomatedTool ? "\r\n" : "<br>");
            progress.ReportStatus("Completed. Want to <a href=\"?verb=\">return to the control panel?</a>");
        }
Ejemplo n.º 21
0
        protected virtual void ProcessInternal(IProgressStatus progress)
        {
            // this bad-ass ASCII art is from http://www.ascii-art.de/ascii/uvw/unicorn.txt - original credit to 'sk'
            const string unicorn = @"<pre>
                        /
                      .7
               \       , //
               |\.--._/|//
              /\ ) ) ).'/
             /(  \  // /       _   _ _   _ ___ ____ ___  ____  _   _
            /(   J`((_/ \     | | | | \ | |_ _/ ___/ _ \|  _ \| \ | |
               / ) | _\     /     | | | |  \| || | |  | | | | |_) |  \| |
              /|)  \  eJ    L     | |_| | |\  || | |__| |_| |  _ <| |\  |
             |  \ L \   L   L      \___/|_| \_|___\____\___/|_| \_\_| \_|
            /  \  J  `. J   L
            |  )   L   \/   \
               /  \    J   (\   /
              |  \      \   \```
            </pre>";

            // note: these logs are intentionally to progress and not loggingConsole as we don't need them in the Sitecore logs
            progress.ReportStatus(unicorn, MessageType.Warning);
            progress.ReportTransientStatus("Executing.");

            var heartbeat = new Timer(3000);
            var startTime = DateTime.Now;
            heartbeat.AutoReset = true;
            heartbeat.Elapsed += (sender, args) =>
            {
                var elapsed = Math.Round((args.SignalTime - startTime).TotalSeconds);

                progress.ReportTransientStatus("Executing for {0} sec.", elapsed.ToString(CultureInfo.InvariantCulture));
            };

            heartbeat.Start();

            try
            {
                using (new SecurityDisabler())
                {
                    using (new ItemFilterDisabler()) // disable all item filtering (if we're running in live mode we need this to get unadulterated items)
                    {
                        Process(progress);
                    }
                }
            }
            finally
            {
                heartbeat.Stop();
            }

            progress.Report(100);
            progress.ReportTransientStatus("Completed.");
            progress.ReportStatus(_isAutomatedTool ? "\r\n" : "<br>");
            progress.ReportStatus("Completed. Want to <a href=\"?verb=\">return to the control panel?</a>");
        }