protected override void ActOnItem(WorkQueueItem item) { // We need to know if the target still exist. Use the default entity flag, rather than proxy. var target = PersistenceScope.CurrentContext.Load <Entity>(MergeWorkQueueItem.GetTargetRef(item), EntityLoadFlags.None); if (target == null) { throw new TargetAlreadyDeletedException(); // target has already been deleted somewhere else. Nothing to act on. } var handler = CollectionUtils.SelectFirst <IMergeHandler>( new MergeHandlerExtensionPoint().CreateExtensions(), h => h.SupportsTarget(target)); if (handler == null) { throw new NotSupportedException( string.Format("No extension found that supports merging entities of class {0}.", target.GetClass().FullName)); } var stage = GetStage(item); Platform.Log(LogLevel.Info, "Starting merge step on target {0} (stage {1})...", target.GetRef(), stage); var nextStage = handler.Merge(target, stage, PersistenceScope.CurrentContext); Platform.Log(LogLevel.Info, "Completed merge step on target {0} (stage {1}, next stage is {2}).", target.GetRef(), stage, nextStage); // update the work item with the new stage value item.ExtendedProperties[StageProperty] = nextStage.ToString(); }
private void RestartItemAtStageZero(WorkQueueItem item) { var nextStage = 0; Platform.Log(LogLevel.Info, "Failed to complete merge step on target {0} (stage {1}). Restarting at stage {2}.", MergeWorkQueueItem.GetTargetRef(item), GetStage(item), nextStage); // update the work item with the new stage value item.ExtendedProperties[StageProperty] = nextStage.ToString(); }
private void ConsiderItemCompletedSuccessfully(WorkQueueItem item) { var nextStage = -1; Platform.Log(LogLevel.Info, "Failed to complete merge step on target {0} (stage {1}) because target has already been deleted. Setting to stage {2}.", MergeWorkQueueItem.GetTargetRef(item), GetStage(item), nextStage); item.Complete(); item.ExtendedProperties[StageProperty] = nextStage.ToString(); }