Ejemplo n.º 1
0
        public static bool PublishQueuedItems(Item triggerItem, Database[] targets, IProgressStatus progress = null)
        {
            if (ManuallyAddedCandidates.Count == 0)
            {
                return(false);
            }

            foreach (var database in targets)
            {
                if (progress != null)
                {
                    progress.ReportStatus("> Publishing {0} synced item{2} in queue to {1}", MessageType.Debug, ManuallyAddedCandidates.Count, database.Name, ManuallyAddedCandidates.Count == 1 ? string.Empty : "s");
                }

                var publishOptions = new PublishOptions(triggerItem.Database, database, PublishMode.SingleItem, triggerItem.Language, DateTime.UtcNow)
                {
                    RootItem = triggerItem
                };

                var result = new Publisher(publishOptions).PublishWithResult();

                if (progress != null)
                {
                    progress.ReportStatus("> Published synced items to {0} (New: {1}, Updated: {2}, Deleted: {3} Skipped: {4})", MessageType.Debug, database.Name, result.Statistics.Created, result.Statistics.Updated, result.Statistics.Deleted, result.Statistics.Skipped);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static bool PublishQueuedItems(Item triggerItem, Database[] targets, IProgressStatus progress = null)
        {
            if (ManuallyAddedCandidates.Count == 0)
            {
                return(false);
            }

            foreach (var database in targets)
            {
                progress?.ReportStatus("> Publishing {0} synced item{2} in queue to {1}", MessageType.Debug, ManuallyAddedCandidates.Count, database.Name, ManuallyAddedCandidates.Count == 1 ? string.Empty : "s");

                var publishOptions = new PublishOptions(triggerItem.Database, database, PublishMode.SingleItem, triggerItem.Language, DateTime.UtcNow)
                {
                    RootItem = triggerItem, CompareRevisions = false, RepublishAll = true
                };

                var result = new Publisher(publishOptions, triggerItem.Database.Languages).PublishWithResult();

                progress?.ReportStatus("> Published synced items to {0} (New: {1}, Updated: {2}, Deleted: {3} Skipped: {4})", MessageType.Debug, database.Name, result.Statistics.Created, result.Statistics.Updated, result.Statistics.Deleted, result.Statistics.Skipped);
            }

            // clear the queue after we publish
            while (ManuallyAddedCandidates.Count > 0)
            {
                ID fake;
                ManuallyAddedCandidates.TryDequeue(out fake);
            }

            return(true);
        }
Ejemplo n.º 3
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>");
        }
        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
        private IList<IncludeEntry> GetPresetName(IProgressStatus progress)
        {
            string presetName = Request.QueryString["preset"] ?? "default";

            progress.ReportStatus("Using preset name {0}", MessageType.Info, presetName);

            return SerializationUtility.GetPreset(presetName);
        }
Ejemplo n.º 7
0
		public static bool PublishQueuedItems(Item triggerItem, Database[] targets, IProgressStatus progress = null)
		{
			if (ManuallyAddedCandidates.Count == 0) return false;

			foreach (var database in targets)
			{
				if (progress != null) progress.ReportStatus("> Publishing {0} synced item{2} in queue to {1}", MessageType.Debug, ManuallyAddedCandidates.Count, database.Name, ManuallyAddedCandidates.Count == 1 ? string.Empty : "s");

				var publishOptions = new PublishOptions(triggerItem.Database, database, PublishMode.SingleItem, triggerItem.Language, DateTime.UtcNow) { RootItem = triggerItem };

				var result = new Publisher(publishOptions).PublishWithResult();

				if (progress != null) progress.ReportStatus("> Published synced items to {0} (New: {1}, Updated: {2}, Deleted: {3} Skipped: {4})", MessageType.Debug, database.Name, result.Statistics.Created, result.Statistics.Updated, result.Statistics.Deleted, result.Statistics.Skipped);
			}

			return true;
		}
Ejemplo n.º 8
0
        private IList <IncludeEntry> GetPresetName(IProgressStatus progress)
        {
            string presetName = Request.QueryString["preset"] ?? "default";

            progress.ReportStatus("Using preset name {0}", MessageType.Info, presetName);

            return(SerializationUtility.GetPreset(presetName));
        }
Ejemplo n.º 9
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.º 10
0
        public void Info(string message)
        {
            if (Quiet)
            {
                return;
            }

            _progress.ReportStatus(message, MessageType.Info);
        }
Ejemplo n.º 11
0
		protected override void Process(IProgressStatus progress)
		{
			progress.ReportStatus("Starting WebForms tasks demonstration...");

			const int subtasks = 3;
			for (int i = 1; i <= subtasks; i++)
			{
				using (var subtask = new SubtaskProgressStatus("Demonstration sub-task #" + i.ToString(CultureInfo.InvariantCulture), progress, i, subtasks + 1, false))
				{
					ExecuteTask(subtask);
				}
				progress.ReportStatus("Sub-task {0}/{1} done. Waiting a sec.", i, subtasks);
				Thread.Sleep(1000);
			}

			progress.ReportStatus("Demonstrating nested sub-tasks...");
			
			// you can also nest subtasks 
			// many times this might be used if a method that accepts an IProgressStatus itself calls sub-methods that also take an IProgressStatus
			// methods that accept an IProgressStatus should *ALWAYS* presume that their progress should be reported as 0-100 (ie that they are running in a subtask)

			using (var subtask = new SubtaskProgressStatus("Demonstration parent sub-task", progress, subtasks+1, subtasks + 1))
			{
				using (var innerSubtask = new SubtaskProgressStatus("Inner task 1", subtask, 1, 2))
				{
					ExecuteTask(innerSubtask);
				}

				using (var innerSubtask2 = new SubtaskProgressStatus("Inner task 2", subtask, 2, 2))
				{
					ExecuteTask(innerSubtask2);
				}
			}

			progress.ReportStatus("WebForms tasks demo complete.");
			progress.ReportStatus("Done.");
		}
Ejemplo n.º 12
0
        public void Info(string message)
        {
            if (_logLevel == MessageType.Warning || _logLevel == MessageType.Error)
            {
                return;
            }

            _progress.ReportStatus(message, MessageType.Info);
        }
Ejemplo n.º 13
0
        protected override void Process(IProgressStatus progress)
        {
            // load the requested (or default) preset
            var presets = GetPresetName(progress);
            if (presets == null)
            {
                progress.ReportStatus("Preset did not exist in configuration.", MessageType.Error);
                return;
            }

            for (int i = 0; i < presets.Count; i++)
            {
                using (var subtask = new SubtaskProgressStatus("Syncing preset path " + new ItemReference(presets[i].Database, presets[i].Path), progress, i+1, presets.Count))
                {
                    ProcessPreset(presets[i], subtask);
                }
            }
        }
Ejemplo n.º 14
0
        protected override void Process(IProgressStatus progress)
        {
            // load the requested (or default) preset
            var presets = GetPresetName(progress);

            if (presets == null)
            {
                progress.ReportStatus("Preset did not exist in configuration.", MessageType.Error);
                return;
            }

            for (int i = 0; i < presets.Count; i++)
            {
                using (var subtask = new SubtaskProgressStatus("Syncing preset path " + new ItemReference(presets[i].Database, presets[i].Path), progress, i + 1, presets.Count))
                {
                    ProcessPreset(presets[i], subtask);
                }
            }
        }
Ejemplo n.º 15
0
        private void Receive(IProgressStatus progress)
        {
            _socket.BeginReceiveFrom(state.buffer, 0, bufSize, SocketFlags.None, ref epFrom, recv = (ar) =>
            {
                if (_stopLogging)
                {
                    _socket.Shutdown(SocketShutdown.Send);
                    _socket.Close();
                    return;
                }

                State so  = (State)ar.AsyncState;
                int bytes = _socket.EndReceiveFrom(ar, ref epFrom);
                _socket.BeginReceiveFrom(so.buffer, 0, bufSize, SocketFlags.None, ref epFrom, recv, so);

                var message     = Encoding.ASCII.GetString(so.buffer, 0, bytes);
                var messageType = MessageType.Info;

                if (message.Contains("level=\"DEBUG\""))
                {
                    messageType = MessageType.Debug;
                }
                else if (message.Contains("level=\"WARN\""))
                {
                    messageType = MessageType.Warning;
                }
                else if (message.Contains("level=\"ERROR\""))
                {
                    messageType = MessageType.Error;
                }

                //progress.ReportStatus($"RECV: {epFrom.ToString()}: {bytes}, {message}", messageType);
                var level     = GetPropertyValue(message, "level");
                var timestamp = GetPropertyValue(message, "timestamp");
                var logger    = GetPropertyValue(message, "logger");

                DateTime dt;
                DateTime.TryParse(timestamp, out dt);

                progress.ReportStatus($"{level} {dt.ToLocalTime()} {logger} | {message}", messageType);
            }, state);
        }
Ejemplo n.º 16
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.º 17
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.º 18
0
        /// <summary>
        /// Deletes an item from Sitecore
        /// </summary>
        /// <returns>true if the item's database should have its template engine reloaded, false otherwise</returns>
        private bool DeleteItem(Item item, IProgressStatus progress)
        {
            bool     resetFromChild = DeleteItems(item.Children, progress);
            Database db             = item.Database;
            ID       id             = item.ID;
            string   path           = item.Paths.Path;

            item.Recycle();

            if (EventDisabler.IsActive)
            {
                db.Caches.ItemCache.RemoveItem(id);
                db.Caches.DataCache.RemoveItemInformation(id);
            }

            progress.ReportStatus("[DELETED] {0}:{1} because it did not exist on disk".FormatWith(db.Name, path), MessageType.Warning);

            if (!resetFromChild && item.Database.Engines.TemplateEngine.IsTemplatePart(item))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 19
0
 public void Info(string message)
 {
     _progress.ReportStatus(message, MessageType.Info);
 }
Ejemplo n.º 20
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.º 21
0
        /// <summary>
        /// Checks to see if we should force an item to be written from the serialized version.
        /// This changes the rules slightly from the default deserializer by forcing if the dates are
        /// different instead of only if they are newer on disk.
        /// </summary>
        private bool ShouldForceUpdate(SyncItem syncItem, IProgressStatus progress)
        {
            Database db = Factory.GetDatabase(syncItem.DatabaseName);

            Assert.IsNotNull(db, "Database was null");

            Item target = db.GetItem(syncItem.ID);

            if (target == null) return true; // target item doesn't exist - must force

            // see if the modified date is different in any version (because disk is master, ANY changes we want to force overwrite)
            return syncItem.Versions.Any(version =>
                {
                    Item targetVersion = target.Database.GetItem(target.ID, Language.Parse(version.Language), Sitecore.Data.Version.Parse(version.Version));
                    var serializedModified = version.Values[FieldIDs.Updated.ToString()];
                    var itemModified = targetVersion[FieldIDs.Updated.ToString()];

                    if (!string.IsNullOrEmpty(serializedModified))
                    {
                        var result = string.Compare(serializedModified, itemModified, StringComparison.InvariantCulture) != 0;

                        if (result)
                            progress.ReportStatus(
                                string.Format("{0} ({1} #{2}): Disk modified {3}, Item modified {4}", syncItem.ItemPath, version.Language,
                                            version.Version, serializedModified, itemModified), MessageType.Debug);

                        return result;
                    }

                    // ocasionally a version will not have a modified date, only a revision so we compare those as a backup
                    var serializedRevision = version.Values[FieldIDs.Revision.ToString()];
                    var itemRevision = targetVersion.Statistics.Revision;

                    if (!string.IsNullOrEmpty(serializedRevision))
                    {
                        var result = string.Compare(serializedRevision, itemRevision, StringComparison.InvariantCulture) != 0;

                        if (result)
                            progress.ReportStatus(
                                string.Format("{0} ({1} #{2}): Disk revision {3}, Item revision {4}", syncItem.ItemPath, version.Language,
                                            version.Version, serializedRevision, itemRevision), MessageType.Debug);

                        return result;
                    }

                    // if we get here we have no valid updated or revision to compare. Let's ignore the item as if it was a real item it'd have one of these.
                    if(!syncItem.ItemPath.StartsWith("/sitecore/templates/System") && !syncItem.ItemPath.StartsWith("/sitecore/templates/Sitecore Client")) // this occurs a lot in stock system templates - we ignore warnings for those as it's expected.
                        progress.ReportStatus(string.Format("{0} ({1} #{2}): Serialized version had no modified or revision field to check for update.", syncItem.ItemPath, version.Language, version.Version), MessageType.Warning);

                    return false;
                });
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Deletes an item from Sitecore
        /// </summary>
        /// <returns>true if the item's database should have its template engine reloaded, false otherwise</returns>
        private bool DeleteItem(Item item, IProgressStatus progress)
        {
            bool resetFromChild = DeleteItems(item.Children, progress);
            Database db = item.Database;
            ID id = item.ID;
            string path = item.Paths.Path;

            item.Recycle();

            if (EventDisabler.IsActive)
            {
                db.Caches.ItemCache.RemoveItem(id);
                db.Caches.DataCache.RemoveItemInformation(id);
            }

            progress.ReportStatus("[DELETED] {0}:{1} because it did not exist on disk".FormatWith(db.Name, path), MessageType.Warning);

            if (!resetFromChild && item.Database.Engines.TemplateEngine.IsTemplatePart(item))
            {
                return true;
            }

            return false;
        }
Ejemplo n.º 23
0
 public void Debug(string message)
 {
     _progress.ReportStatus(message, MessageType.Debug);
     LogData.AppendLine($"Debug: {message}");
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Checks to see if we should force an item to be written from the serialized version.
        /// This changes the rules slightly from the default deserializer by forcing if the dates are
        /// different instead of only if they are newer on disk.
        /// </summary>
        private bool ShouldForceUpdate(SyncItem syncItem, IProgressStatus progress)
        {
            Database db = Factory.GetDatabase(syncItem.DatabaseName);

            Assert.IsNotNull(db, "Database was null");

            Item target = db.GetItem(syncItem.ID);

            if (target == null)
            {
                return(true);                            // target item doesn't exist - must force
            }
            // see if the modified date is different in any version (because disk is master, ANY changes we want to force overwrite)
            return(syncItem.Versions.Any(version =>
            {
                Item targetVersion = target.Database.GetItem(target.ID, Language.Parse(version.Language), Sitecore.Data.Version.Parse(version.Version));
                var serializedModified = version.Values[FieldIDs.Updated.ToString()];
                var itemModified = targetVersion[FieldIDs.Updated.ToString()];

                if (!string.IsNullOrEmpty(serializedModified))
                {
                    var result = string.Compare(serializedModified, itemModified, StringComparison.InvariantCulture) != 0;


                    if (result)
                    {
                        progress.ReportStatus(
                            string.Format("{0} ({1} #{2}): Disk modified {3}, Item modified {4}", syncItem.ItemPath, version.Language,
                                          version.Version, serializedModified, itemModified), MessageType.Debug);
                    }

                    return result;
                }

                // ocasionally a version will not have a modified date, only a revision so we compare those as a backup
                var serializedRevision = version.Values[FieldIDs.Revision.ToString()];
                var itemRevision = targetVersion.Statistics.Revision;

                if (!string.IsNullOrEmpty(serializedRevision))
                {
                    var result = string.Compare(serializedRevision, itemRevision, StringComparison.InvariantCulture) != 0;

                    if (result)
                    {
                        progress.ReportStatus(
                            string.Format("{0} ({1} #{2}): Disk revision {3}, Item revision {4}", syncItem.ItemPath, version.Language,
                                          version.Version, serializedRevision, itemRevision), MessageType.Debug);
                    }

                    return result;
                }

                // if we get here we have no valid updated or revision to compare. Let's ignore the item as if it was a real item it'd have one of these.
                if (!syncItem.ItemPath.StartsWith("/sitecore/templates/System") && !syncItem.ItemPath.StartsWith("/sitecore/templates/Sitecore Client"))                        // this occurs a lot in stock system templates - we ignore warnings for those as it's expected.
                {
                    progress.ReportStatus(string.Format("{0} ({1} #{2}): Serialized version had no modified or revision field to check for update.", syncItem.ItemPath, version.Language, version.Version), MessageType.Warning);
                }

                return false;
            }));
        }
 public virtual void Report(int percent, string statusMessage, MessageType type, params object[] formatParameters)
 {
     SetProgress(percent);
     _mainTask.ReportStatus(statusMessage, type, formatParameters);
 }