Beispiel #1
0
 public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition)
 {
     return(Initialize <ContentPickerFieldElasticEditorSettings>("ContentPickerFieldElasticEditorSettings_Edit", model =>
     {
         partFieldDefinition.PopulateSettings(model);
         model.Indices = _elasticIndexManager.ListIndexesAsync().GetAwaiter().GetResult().Select(x => x.Key).ToArray();
     }).Location("Editor"));
 }
        public override async Task PublishedAsync(PublishContentContext context)
        {
            // TODO: ignore if this index is not configured for the content type

            var buildIndexContext = new BuildIndexContext(new DocumentIndex(context.ContentItem.ContentItemId), context.ContentItem, new string[] { context.ContentItem.ContentType });
            // Lazy resolution to prevent cyclic dependency
            var contentItemIndexHandlers = _serviceProvider.GetServices <IContentItemIndexHandler>();
            await contentItemIndexHandlers.InvokeAsync(x => x.BuildIndexAsync(buildIndexContext), _logger);

            var indexes = await _elasticIndexManager.ListIndexesAsync();

            foreach (var index in indexes)// .List())
            {
                await _elasticIndexManager.DeleteDocumentsAsync(index.Key, new string[] { context.ContentItem.ContentItemId });

                await _elasticIndexManager.StoreDocumentsAsync(index.Key, new DocumentIndex[] { buildIndexContext.DocumentIndex });
            }
        }
        public override IDisplayResult Edit(ElasticQuery query, IUpdateModel updater)
        {
            return(Initialize <ElasticQueryViewModel>("ElasticQuery_Edit", model =>
            {
                model.Query = query.Template;
                model.Index = query.Index;
                model.ReturnContentItems = query.ReturnContentItems;
                model.Indices = _elasticIndexManager.ListIndexesAsync().GetAwaiter().GetResult().Select(x => x.Key).ToArray();//  List().ToArray();

                // Extract query from the query string if we come from the main query editor
                if (string.IsNullOrEmpty(query.Template))
                {
                    updater.TryUpdateModelAsync(model, "", m => m.Query);
                }
            }).Location("Content:5"));
        }