0

我一直在尝试替换 6.4 的 OMS 中已弃用的方法,即“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();
4

2 回答 2

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:%'";

希望这可以帮助

于 2012-07-18T14:28:59.333 回答
0

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

于 2012-07-11T15:59:10.130 回答