Skip to content

Instantly share code, notes, and snippets.

@islaytitans

islaytitans/GetGoals.cs Secret

Last active May 30, 2016
Embed
What would you like to do?
Gets goals from the Sitecore xDB
public class GetGoals : ReportProcessorBase
{
private readonly QueryBuilder goalsQueryBuilder = new QueryBuilder()
{
collectionName = "Interactions",
QueryParms =
{
{
"ContactId", "@contactId"
},
{
"Pages.PageEvents.0", "{$exists:1}"
}
},
Fields =
{
"_id",
"ContactId",
"Pages_PageEvents_PageEventDefinitionId",
"Pages_PageEvents_DateTime",
"Pages_PageEvents_Data",
"Pages_Url_Path",
"Pages_Url_QueryString",
"Pages_PageEvents_Value",
"Pages_Item__id"
}
};
public override void Process(ReportProcessorArgs args)
{
DataTable goalsData = this.GetGoalsData(args.ReportParameters.ContactId);
args.QueryResult = goalsData;
}
private DataTable GetGoalsData(Guid contactId)
{
ReportDataProvider reportDataProvider = this.GetReportDataProvider();
Assert.IsNotNull((object)reportDataProvider, "provider should not be null");
return reportDataProvider.GetData("collection", new ReportDataQuery(this.goalsQueryBuilder.Build())
{
Parameters =
{
{
"@contactId", (object) contactId
}
}
}, new CachingPolicy()
{
NoCache = true
}).GetDataTable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment