Exemplo n.º 1
0
        private void Refresh(ClientPipelineArgs args)
        {
            // this.JobHandle = Context.Job.Handle;
            Item itemByUri = GetItemByUri(args.Parameters["itemUri"]);

            if (itemByUri == null)
            {
                return;
            }

            if (!this.indexingService.ItemShouldBeIndexed(itemByUri))
            {
                return;
            }

            var queueItem = new IndexingQueueItem(itemByUri);

            this.indexingService.IndexPageItemAsync(queueItem).Wait();

            // Job job = JobManager.GetJob(this.JobHandle);
            if (Context.Job != null)
            {
                Context.Job.Status.Messages.Add("Item indexed");
            }
        }
Exemplo n.º 2
0
        public async Task IndexPageItemAsync(IndexingQueueItem queueItem)
        {
            Index index = this.Client.InitIndex(this.GetPagesIndexName(queueItem.Language));

            if (!queueItem.Deleted)
            {
                Item item = this.database.GetItem(ID.Parse(queueItem.Id), Language.Parse(queueItem.Language));

                await index.AddObjectAsync(this.crawler.GetJsonForItem(item));
            }
            else
            {
                await index.DeleteObjectAsync(this.crawler.GetObjectId(queueItem.Id));
            }
        }