public IWeKnowTreeNode TrackingContactNode(Sitecore.Analytics.Tracking.Contact trackingContact, XConnectClient xConnectClient) { WeKnowTreeNode toReturn = null; if (trackingContact != null && TreeOptions.IncludeTrackingContact) { toReturn = new WeKnowTreeNode("Tracking Contact", TreeOptions); toReturn.AddNode(new WeKnowTreeNode("Is New", trackingContact.IsNew.ToString(), TreeOptions)); toReturn.AddNode(new WeKnowTreeNode("Contact Id", trackingContact.ContactId.ToString(), TreeOptions)); toReturn.AddNode(new WeKnowTreeNode("Identification Level", trackingContact.IdentificationLevel.ToString(), TreeOptions)); var ContractResolver = new XdbJsonContractResolver(xConnectClient.Model, true, true); var serializerSettings = new JsonSerializerSettings { ContractResolver = ContractResolver, DateTimeZoneHandling = DateTimeZoneHandling.Utc, DefaultValueHandling = DefaultValueHandling.Ignore, Formatting = Formatting.Indented }; var serialized = JsonConvert.SerializeObject(trackingContact, serializerSettings); toReturn.AddRawNode(serialized); } return(toReturn); }
public IWeKnowTreeNode InteractionsNode(Sitecore.XConnect.Contact xConnectContact, XConnectClient xConnectClient) { WeKnowTreeNode toReturn = null; if (TreeOptions.Interactions.IncludeInteractions) { toReturn = new WeKnowTreeNode("Interactions", TreeOptions); var interactionHelper = new InteractionsNodeBuilder(TreeOptions); toReturn.AddNode(interactionHelper.Something(xConnectContact, xConnectClient)); //var knownInteractions = interactionHelper.GetKnownInteractions(xConnectContact, xConnectClient); //if (knownInteractions != null && knownInteractions.Any()) //{ // foreach (var knownInteraction in knownInteractions) // { // var treeNode = new WeKnowTreeNode(knownInteraction.ChannelName, TreeOptions); // treeNode.AddNode(EventsNode(knownInteraction.EventsB)); // toReturn.AddNode(treeNode); // } //} } return(toReturn); }
public WeKnowTreeNode Something(Contact xconnectContact, XConnectClient xConnectClient) { WeKnowTreeNode toReturn = null; if (xconnectContact?.Interactions != null) { var interactions = xconnectContact.Interactions.OrderByDescending(x => x.LastModified); if (interactions != null && interactions.Any()) { toReturn = new WeKnowTreeNode("Interactions", TreeOptions); var objectToTreeNode = new ObjectToTreeNode(TreeOptions, xConnectClient); foreach (var interaction in interactions) { var nodeName = "Interaction"; if (interaction.Id != null) { nodeName = GetDisplayName((Guid)interaction.ChannelId); } var interactionNode = objectToTreeNode.MakeTreeNodeFromObject(interaction, "Channel: " + nodeName); if (interactionNode != null) { interactionNode.AddRawNode(objectToTreeNode.SerializeObject(interaction)); } toReturn.AddNode(interactionNode); } } } return(toReturn); }
public IWeKnowTreeNode EventsNode(List <xConnectHelper.Proxies.EventRecordProxy> events) { WeKnowTreeNode toReturn = null; if (events != null && events.Any() && TreeOptions.Interactions.IncludeInteractionEvents) { toReturn = new WeKnowTreeNode("Events", TreeOptions); foreach (var eventProxy in events) { var eventNode = new WeKnowTreeNode(eventProxy.ItemDisplayName, TreeOptions); eventNode.AddNode(new WeKnowTreeNode(eventProxy.TimeStamp.ToString(), TreeOptions)); eventNode.AddNode(new WeKnowTreeNode("Duration", eventProxy.Duration.ToString(), TreeOptions)); } } return(toReturn); }
public IWeKnowTreeNode FacetsNode(XConnectClient xConnectClient) { Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "s) FacetsNode"); WeKnowTreeNode toReturn = null; if (TreeOptions.IncludeFacets) { toReturn = new WeKnowTreeNode("Facets", TreeOptions); var FacetTreeHelper = new FacetsNodeBuilder(xConnectClient, XConnectFacets, TreeOptions); if (XConnectFacets != null) { // Emails //Personal //Addresses //ListSubscriptions //AutomationPlanExit //AutomationPlanEnrollmentCache //KeyBehaviorCache //EngagementMeasures //CinemaVisitorInfo TreeOptions.TargetedFacetKeys.Add("ListSubscriptions"); TreeOptions.TargetedFacetKeys.Add("AutomationPlanExit"); TreeOptions.TargetedFacetKeys.Add("AutomationPlanEnrollmentCache"); TreeOptions.TargetedFacetKeys.Add("KeyBehaviorCache"); TreeOptions.TargetedFacetKeys.Add("EngagementMeasures"); foreach (var targetFacetKey in TreeOptions.TargetedFacetKeys) { toReturn.AddNode(FacetTreeHelper.BuildFacetsNode(targetFacetKey)); } } toReturn.AddNode(FacetTreeHelper.FoundFacetKeys()); Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "e) FacetsNode"); } return(toReturn); }
public IWeKnowTreeNode FoundFacetKeys() { var toReturn = new WeKnowTreeNode("Found Facet Keys", TreeOptions); if (XConnectFacets?.Facets != null) { foreach (KeyValuePair <string, Sitecore.XConnect.Facet> facetPair in XConnectFacets.Facets) { toReturn.AddNode(new WeKnowTreeNode(facetPair.Key, TreeOptions)); } } return(toReturn); }
public IWeKnowTreeNode IdentifiersNode(List <Sitecore.Analytics.Model.Entities.ContactIdentifier> contactIdentifiers) { WeKnowTreeNode toReturn = null; if (contactIdentifiers != null && contactIdentifiers.Any() && TreeOptions.IncludeIdentifiers) { toReturn = new WeKnowTreeNode("Identifiers", TreeOptions); foreach (var contactIdentifier in contactIdentifiers) { toReturn.AddNode(new WeKnowTreeNode(contactIdentifier.Source, contactIdentifier.Identifier, TreeOptions)); } } return(toReturn); }
public IWeKnowTreeNode MakeTreeNodeFromObject(object targetObject, string nodeTitle, int depth = 0) { Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "s) MakeTreeNodeFromObject: " + nodeTitle); var toReturn = new WeKnowTreeNode(nodeTitle, TreeOptions); PropertyInfo[] objectProperties = targetObject.GetType().GetProperties(); if (objectProperties != null && objectProperties.Any()) { foreach (var property in objectProperties) { if (property != null) { try { var candidate = PropertyToTreeNode(property, targetObject, depth + 1); if (candidate != null) { toReturn.AddNode(candidate); } } catch (Exception ex) { Sitecore.Diagnostics.Log.Error(ProjConstants.Logger.Prefix, ex, this); } } } } else { Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "No object properties"); } Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "e) MakeTreeNodeFromObject: " + nodeTitle); return(toReturn); }
//private IWhatWeKnowTreeNode AddAutoBRecursive(object facetPart, int depth) //{ // WeKnowTreeNode toReturn = null; // try // { // if (depth < MaxDepth && facetPart != null) // { // if (facetPart != null) // { // var partType = facetPart.GetType(); // if (partType.Equals(typeof(string))) // { // toReturn = new WeKnowTreeNode(facetPart as String); // } // else // { // toReturn = new WeKnowTreeNode(partType.Name); // PropertyInfo[] propertyInfo = facetPart.GetType().GetProperties(); // foreach (var property in propertyInfo) // { // toReturn.AddNode(PropertyToTreeNode(property, facetPart, depth++));// AddAutoBRecursive(property, depth++)); private IWeKnowTreeNode PropertyToTreeNode(PropertyInfo property, object ownerObject, int depth) { Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "s) PropertyToTreeNode: " + property.Name + " depth: " + depth); IWeKnowTreeNode toReturn = null; if (depth < MaxDepth) { object propValue = property.GetValue(ownerObject, null); if (propValue == null) { if (TreeOptions.IncludeNullAndEmptyValueLeaves) { toReturn = new WeKnowTreeNode(property.Name, TreeOptions) { Value = "{null}" }; } } else { var valueType = propValue.GetType(); if (!TypesToIgnore.Contains(valueType) && !PropertyNamesToIgnore.Contains(property.Name)) { Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "value type: " + valueType.Name); if (SingleValueTypes.Contains(valueType) || valueType.IsEnum) { var nodeValue = HandlePropertyValueOfTypeLeaf(valueType, propValue); if (!string.IsNullOrEmpty(nodeValue) || TreeOptions.IncludeNullAndEmptyValueLeaves) { toReturn = new WeKnowTreeNode(property.Name, TreeOptions) { Value = HandlePropertyValueOfTypeLeaf(valueType, propValue) }; } } else { if (IsList(propValue) || IsEnumerable(propValue)) { if (IsDictionary(propValue)) { var asEnumberable = propValue as IEnumerable; } else { toReturn = new WeKnowTreeNode(property.Name, TreeOptions); foreach (var listItem in propValue as IEnumerable) { var listItemType = listItem.GetType(); if (SingleValueTypes.Contains(listItemType)) { var nodeValue = HandlePropertyValueOfTypeLeaf(listItemType, listItem); if (!string.IsNullOrEmpty(nodeValue) || TreeOptions.IncludeNullAndEmptyValueLeaves ) { toReturn.AddNode(new WeKnowTreeNode(nodeValue, TreeOptions)); } } else { toReturn.AddNode(MakeTreeNodeFromObject(listItem, listItemType.Name, depth + 1)); } } } } else { toReturn = MakeTreeNodeFromObject(propValue, property.Name, depth + 1);// HandlePropertyValueOfTypeBranch(valueType, propValue, depth)) ; } } } } } Sitecore.Diagnostics.Log.Debug(ProjConstants.Logger.Prefix + "e) PropertyToTreeNode: " + property.Name); return(toReturn); }