private async Task SyncToPreviewGraph(ContentItem contentItem) { // sonar can't see that the set value could be used in the event of an exception #pragma warning disable S1854 AllowSyncResult allowSyncResult = AllowSyncResult.Blocked; string message = $"Unable to sync '{contentItem.DisplayText}' Page to {GraphReplicaSetNames.Preview} graph(s)."; try { IMergeGraphSyncer mergeGraphSyncer = _serviceProvider.GetRequiredService <IMergeGraphSyncer>(); IContentManager contentManager = _serviceProvider.GetRequiredService <IContentManager>(); IAllowSync allowSync = await mergeGraphSyncer.SyncToGraphReplicaSetIfAllowed( _graphCluster.GetGraphReplicaSet(GraphReplicaSetNames.Preview), contentItem, contentManager); allowSyncResult = allowSync.Result; } catch (Exception exception) { _logger.LogError(exception, "Unable to sync '{ContentItemDisplayText}' Page to {GraphReplicaSetName} graph(s).", contentItem.DisplayText, GraphReplicaSetNames.Preview); } if (allowSyncResult == AllowSyncResult.Blocked) { _notifier.Add(NotifyType.Error, new LocalizedHtmlString(nameof(DefaultPageLocationsContentHandler), message)); } #pragma warning restore S1854 }
public async Task ResyncContentItems(string contentType) { var publishedGraphReplicaSet = _graphCluster.GetGraphReplicaSet(GraphReplicaSetNames.Published); var previewGraphReplicaSet = _graphCluster.GetGraphReplicaSet(GraphReplicaSetNames.Preview); var contentItems = await _contentItemsService.GetPublishedOnly(contentType); await Sync(contentItems, publishedGraphReplicaSet); await Sync(contentItems, previewGraphReplicaSet); contentItems = await _contentItemsService.GetPublishedWithDraftVersion(contentType); await Sync(contentItems, publishedGraphReplicaSet); contentItems = await _contentItemsService.GetDraft(contentType); await Sync(contentItems, previewGraphReplicaSet); }