示例#1
0
        public void Process(HandleKeyPhrasesResponsePipelineArgs args)
        {
            if (args?.Collection?.Documents == null)
            {
                Log.Warn($"ScoreContentWithKeyPhrases skipped due to a null argument", this);
                return;
            }

            var database = _factory.GetDatabase("master"); // TODO: move this to config and inject

            foreach (var model in args.Collection.Documents)
            {
                if (!ID.TryParse(model.Id, out var id))
                {
                    continue;
                }

                var scoreContentArgs = new ScoreContentPipelineArgs()
                {
                    Item       = database.GetItem(id),
                    KeyPhrases = model.KeyPhrases
                };
                CorePipeline.Run("scoreContent", scoreContentArgs); // TODO: move this to config and inject
            }
        }
        public void Process(HandleKeyPhrasesResponsePipelineArgs args)
        {
            if (args?.Collection?.Documents == null)
            {
                Log.Warn($"UpdateItemsWithKeyPhrases skipped due to a null argument", this);
                return;
            }

            using (new BulkUpdateContext())
            {
                foreach (var document in args.Collection.Documents)
                {
                    // ReSharper disable once InconsistentNaming
                    var masterDB = _factory.GetDatabase("master"); // TODO: move to config and inject
                    var item     = masterDB.GetItem(new ID(document.Id));

                    using (new SecurityDisabler())
                        using (new EditContext(item))
                        {
                            item["Key Phrases"] = string.Join(",", document.KeyPhrases); // TODO: move field name to config and inject
                        }
                }
            }
        }