创建自定义个性化规则的问题

时间:2017-01-10 08:45:22

标签: c# sitecore sitecore8

以下是我的自定义个性化规则代码:

using MyDll.Custom_Classes.Analytics.Facets;
using Sitecore.Analytics;
using Sitecore.Diagnostics;
using Sitecore.Rules;
using Sitecore.Rules.Conditions;
using System.Linq;

namespace MyDll.Custom_Classes.Personalization_Rules
{
    public class AnonymousUserInterestsCondition<T> : StringOperatorCondition<T> where T : RuleContext
    {
        public string Value { get; set; }

        protected override bool Execute(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            Assert.IsNotNull(Tracker.Current, "Tracker.Current is not initialized");
            Assert.IsNotNull(Tracker.Current.Session, "Tracker.Current.Session is not initialized");
            Assert.IsNotNull(Tracker.Current.Session.Interaction, "Tracker.Current.Session.Interaction is not initialized");

            var currentAnonymousUserInterest = string.Empty;
            if (Tracker.Current.Contact != null)
            {
                var interestsFacet = Tracker.Current.Contact.GetFacet<IInterestFacet>(InterestFacet._FACET_NAME);
                if (!interestsFacet.Interests.Any())
                {
                    currentAnonymousUserInterest = interestsFacet.Interests[0].InterestedIn;
                }
            }

            return Compare(currentAnonymousUserInterest, Value);
        }
    }
}

我在sitecore类型字段中引用它,如下所示:

MyDll.Custom_Classes.Personalization_Rules.AnonymousUserInterestsCondition,MYDLL

请参考以下屏幕截图:

Personalization Rule - Sitecore error for Type field

Sitecore在“类型”字段中显示错误,错误消息为“字段类型包含对不存在类型的引用MyDll.Custom_Classes.Personalization_Rules.AnonymousUserInterestsCondition,MyDll”

我做错了什么或有办法解决这个问题吗?

0 个答案:

没有答案