private async Task ProcessItem(PullItemModel args, IItemData localData, IItemData remoteData, Item localItem) { _allowedItems.Remove(remoteData.Id); if (args.Preview) { if (localData != null) { var results = _comparer.Compare(remoteData, localData); if (results.AreEqual) { _logger.BeginEvent(remoteData, "Skipped", _sitecore.GetItemIconSrc(localData), false); } else if (results.IsMoved) { _logger.BeginEvent(remoteData, "Moved", _sitecore.GetItemIconSrc(localData), false); } else if (results.IsRenamed) { _logger.BeginEvent(remoteData, "Renamed", _sitecore.GetItemIconSrc(localData), false); } else if (results.IsTemplateChanged) { _logger.BeginEvent(remoteData, "Template Change", _sitecore.GetItemIconSrc(localData), false); } else if (args.Overwrite) { _logger.BeginEvent(remoteData, "Changed", _sitecore.GetItemIconSrc(localData), false); } else { _logger.BeginEvent(remoteData, "Skipped", _sitecore.GetItemIconSrc(localData), false); } } else { _logger.BeginEvent(remoteData, "Created", "", false); } } else { bool skip = false; if (!args.Overwrite && localData != null) { _logger.BeginEvent(remoteData, "Skipped", _sitecore.GetItemIconSrc(localData), false); skip = true; } if (!skip && localData != null) { var results = _comparer.Compare(remoteData, localData); if (results.AreEqual) { _logger.BeginEvent(remoteData, "Skipped", _sitecore.GetItemIconSrc(localData), false); skip = true; } } else if (!skip) { while (_currentlyProcessing.Contains(remoteData.ParentId)) { if (_errors.Contains(remoteData.ParentId)) { _errors.Add(remoteData.Id); skip = true; break; } await Task.Delay(50); } } if (!skip) { try { if (localData != null) { _logger.BeginEvent(remoteData, "Changed", _logger.GetSrc(ThemeManager.GetIconImage(localItem, 32, 32, "", "")), true); } _scDatastore.Save(remoteData); } catch (TemplateMissingFieldException tm) { _logger.BeginEvent(new ErrorItemData() { Name = remoteData.Name, Path = tm.ToString() }, "Warning", "", false); } catch (ParentItemNotFoundException) { _logger.BeginEvent(remoteData, "Skipped parent error", "", false); _errors.Add(remoteData.Id); } catch (Exception e) { _errors.Add(remoteData.Id); _logger.BeginEvent(new ErrorItemData() { Name = remoteData?.Name ?? "Unknown item", Path = e.ToString() }, "Error", "", false); } if (localData != null) { if (_logger.LinesSupport[localData.Id.ToString()].Events.Count != 0) { _logger.CompleteEvent(localData.Id.ToString()); } else { _logger.BeginEvent(localData, "Skipped", _logger.GetSrc(ThemeManager.GetIconImage(localItem, 32, 32, "", "")), false); } } } } }