public void Process(ScoreContentPipelineArgs args) { Assert.IsNotNull(args.Item, "args.Item != null"); Assert.IsNotNull(args.ProfileKeyScores, "args.ProfileKeyScores != null"); var profileKeyElements = string.Join( string.Empty, args.ProfileKeyScores .Select(profileEntry => { var profileItem = args.Item.Database.GetItem(profileEntry.Key); var profileKeys = string.Join( string.Empty, profileEntry.Value .Select(profileKeyEntry => { var profileKeyItem = args.Item.Database.GetItem(profileKeyEntry.Key); var profileKeyName = profileKeyItem["Name"]; return($"<key name=\"{profileKeyName}\" value=\"{profileKeyEntry.Value}\" />"); })); return ($"<profile id=\"{profileItem.ID.Guid.ToString().ToLowerInvariant()}\" name=\"{profileItem.Name}\">{profileKeys}</profile>"); })); var trackingFieldValue = $"<tracking>{profileKeyElements}</tracking>"; using (new SecurityDisabler()) using (new EditContext(args.Item)) { args.Item["__Tracking"] = trackingFieldValue; } }
public void Process(ScoreContentPipelineArgs args) { Assert.IsNotNull(args.Item, "args.Item != null"); Assert.IsNotNull(args.KeyPhrases, "args.KeyPhrases != null"); if (!ID.TryParse(RuleFolder, out var ruleFolderId)) { Log.Error($"DoctaCore.Feature.ContentScoring.RuleFolder setting value must be a valid Sitecore ID", this); return; } var ruleArgs = new ContentScoringRuleArgs() { KeyPhrases = args.KeyPhrases, ProfileKeyScores = new Dictionary <string, Dictionary <string, int> >() }; var context = new ContentScoringRuleContext(ruleArgs) { Item = args.Item }; RuleManager.RunRules(context, ruleFolderId); args.ProfileKeyScores = ruleArgs.ProfileKeyScores; }