Last active
October 18, 2016 18:53
-
-
Save islaytitans/a5e9f58b24ae266ea494 to your computer and use it in GitHub Desktop.
Gets the SampleOrders from a xDB by interacting with the Facet in API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void PassContactElementIntoQueryResult(ReportProcessorArgs args) | |
{ | |
DataTable queryResultTable = new DataTable(); | |
queryResultTable.Columns.Add(new ViewField<string>("DecorId").ToColumn()); | |
queryResultTable.Columns.Add(new ViewField<string>("RangeId").ToColumn()); | |
var contactRepository = Sitecore.Configuration.Factory.CreateObject("tracking/contactRepository", true) as ContactRepository; | |
var contact = contactRepository.LoadContactReadOnly(args.ReportParameters.ContactId); | |
IKeyInteractionsFacet facet = contact.GetFacet<IKeyInteractionsFacet>(KeyInteractionsFacet.FacetName); | |
foreach (var sampleOrder in facet.SampleOrders) | |
{ | |
DataRow dataRow = queryResultTable.NewRow(); | |
dataRow["DecorId"] = sampleOrder.DecorId; | |
dataRow["RangeId"] = sampleOrder.RangeId; | |
queryResultTable.Rows.Add(dataRow); | |
} | |
args.QueryResult = queryResultTable; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment