OMS中的TriggerEvent不是DMS

时间:2012-07-09 21:22:53

标签: sitecore sitecore6 sitecore-dms

我一直在尝试替换在OMS for 6.4中使用的弃用方法,即“TriggerEvent”。我现在使用以下代码获得以下错误。在新的DMS 6.5中。我不确定什么是正确的新方法。

var tracker = Sitecore.Analytics.Tracker.Visitor.CurrentVisit.CurrentPage;
if (tracker != null)
{
    string dataXml = Review_Module.sitecore_modules.Review_module.Classes
         .AnalyticsHelper.FillDataField(new string[]
              {
                 "Title", title, "Description", description, "Rate", rate
              });

    PageEventData eventData = new PageEventData("Review");
    eventData.Data = dataXml;
    VisitorDataSet.PageEventsRow pageEventsRow = Sitecore.Analytics.Tracker.CurrentPage.Register(eventData);
    Sitecore.Analytics.Tracker.Submit();

错误

[PageEventDefinitionNotFoundException: The page event definition Review could not be found.]
   Sitecore.Analytics.Data.DataAccess.DataSets.PagesRow.Register(PageEventData data) +170
   Sitecore.Analytics.Data.DataAccess.DataSets.PagesRow.Register(String name, String text, String dataKey, String data) +127
   ReviewModule.Nicam_Modules.Review_module.Controls.Review.ReviewClicked(Object sender, EventArgs e) +808
   System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

6.4 OMS中的工作代码

 string dataXml = Review_Module.sitecore_modules.Review_module.Classes.AnalyticsHelper.FillDataField(new string[]
       {
          "Title", title, "Description", description, "Rate", rate
       });
       tracker.CurrentPage.TriggerEvent("Review", "Review: \"" + Sitecore.Context.Item.Name + "\"", string.Empty, dataXml);
       tracker.Submit();

2 个答案:

答案 0 :(得分:2)

好的,我终于有机会回到这里并更新这篇文章。我能够在6.5中使用它。不确定他们是否要更新模块或是否有计划。

首先, 我不得不删除对TriggerEvent方法的调用。同样,AnalyticsTracker不再存在。它现在使用PageEventData和Sitecore.Analytics.Tracker.CurrentPage;

var tracker = Sitecore.Analytics.AnalyticsTracker.Current;
if (tracker != null)

{

string dataXml = Review_Module.sitecore_modules.Review_module.Classes.AnalyticsHelper.FillDataField(new string[]

{"Title", title, "Description", description, "Rate", rate});

 tracker.CurrentPage.TriggerEvent("Review", "Review: \"" + Sitecore.Context.Item.Name + "\"", string.Empty, dataXml);
 tracker.Submit();

}

并将其替换为:

var tracker = Sitecore.Analytics.Tracker.CurrentPage;

if (tracker != null)

{

 string dataXml = Review_Module.sitecore_modules.Review_module.Classes.AnalyticsHelper.FillDataField(new string[]

{
 "Title", title, "Description", description, "Rate", rate
});

 PageEventData eventData = new PageEventData("Review");

 Guid Gu = new Guid();

 eventData.Text = "Review: \"" + Sitecore.Context.Item.Name + "\"";
 eventData.DataKey = String.Empty;
 eventData.Data = dataXml;
 eventData.ItemId = new Guid(Sitecore.Context.Item.ID.ToString());
 Tracker.CurrentPage.Register(eventData);
 Tracker.Submit();
}

此外,还必须更新为UI公开视图发布的评论的SQL。

自:

 //var sql = @"select {0}PageEvents{1}.Data from {0}PageEvents{1} inner join {0}Pages{1} on {0}PageEvents{1}.PageId = {0}Pages{1}.PageId
 //inner join {0}PageEventDefinitions{1} on {0}PageEventDefinitions{1}.PageEventDefinitionId = {0}PageEvents{1}.PageEventDefinitionId
 //where {0}Page{1}.ItemId = @itemId
 //and {0}PageEventDefinitions{1}.Name = 'Review'";

要:

 var sql = @"select {0}PageEvents{1}.Data from {0}PageEvents{1}
 where {0}PageEvents{1}.ItemId = @itemId
 and {0}PageEvents{1}.[Text] LIKE 'Review:%'";

希望这有帮助

答案 1 :(得分:0)

您可以在SDN上查看DMS的API。我认为你应该关注两个文档: