-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f64e4c5
commit 7ed6528
Showing
22 changed files
with
1,244 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25123.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{4B5CC991-628B-4559-A040-804E517E5C15}") = "Sitecore.Support.129513", "Sitecore.Support.129513\Sitecore.Support.129513.csproj", "{82E3C87F-7DA4-4F8F-B779-A8F0EB751547}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{82E3C87F-7DA4-4F8F-B779-A8F0EB751547}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{82E3C87F-7DA4-4F8F-B779-A8F0EB751547}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{82E3C87F-7DA4-4F8F-B779-A8F0EB751547}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{82E3C87F-7DA4-4F8F-B779-A8F0EB751547}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
108 changes: 108 additions & 0 deletions
108
...s/Outcome/Rules/Conditions/OutcomeWasRegisteredDuringPastOrCurrentInteractionCondition.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using Sitecore.Analytics; | ||
using Sitecore.Analytics.Outcome.Model; | ||
using Sitecore.Analytics.Tracking; | ||
using Sitecore.Data; | ||
using Sitecore.Diagnostics; | ||
using Sitecore.Rules; | ||
using Sitecore.Support.Analytics.Rules.Conditions; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Sitecore.Support.Analytics.Outcome.Rules.Conditions | ||
{ | ||
public class OutcomeWasRegisteredDuringPastOrCurrentInteractionCondition<T> : HasEventOccurredCondition<T> where T : RuleContext | ||
{ | ||
private Guid? outcomeGuid; | ||
|
||
private bool outcomeGuidInitialized; | ||
|
||
public string OutcomeId { get; set; } | ||
|
||
private Guid? OutcomeGuid | ||
{ | ||
get | ||
{ | ||
if (this.outcomeGuidInitialized) | ||
{ | ||
return this.outcomeGuid; | ||
} | ||
|
||
try | ||
{ | ||
this.outcomeGuid = new Guid(this.OutcomeId); | ||
} | ||
catch | ||
{ | ||
Log.Warn(string.Format("Could not convert value to guid: {0}", this.OutcomeId), (object)base.GetType()); | ||
} | ||
|
||
this.outcomeGuidInitialized = true; | ||
return this.outcomeGuid; | ||
} | ||
} | ||
|
||
public OutcomeWasRegisteredDuringPastOrCurrentInteractionCondition() | ||
: base(false) | ||
{ | ||
} | ||
|
||
protected OutcomeWasRegisteredDuringPastOrCurrentInteractionCondition(bool filterByCustomData) | ||
: base(filterByCustomData) | ||
{ | ||
} | ||
|
||
protected override bool Execute(T ruleContext) | ||
{ | ||
Assert.ArgumentNotNull((object)ruleContext, "ruleContext"); | ||
Assert.IsNotNull((object)Tracker.Current, "Tracker.Current is not initialized"); | ||
Assert.IsNotNull((object)Tracker.Current.Session, "Tracker.Current.Session is not initialized"); | ||
Assert.IsNotNull((object)Tracker.Current.Session.Interaction, "Tracker.Current.Session.Interaction is not initialized"); | ||
if (!this.OutcomeGuid.HasValue) | ||
{ | ||
return false; | ||
} | ||
|
||
if (this.HasEventOccurredInInteraction(Tracker.Current.Session.Interaction)) | ||
{ | ||
return true; | ||
} | ||
|
||
Assert.IsNotNull((object)Tracker.Current.Contact, "Tracker.Current.Contact is not initialized"); | ||
KeyBehaviorCache keyBehaviorCache = ContactKeyBehaviorCacheExtension.GetKeyBehaviorCache(Tracker.Current.Contact); | ||
|
||
return Enumerable.Any<KeyBehaviorCacheEntry>(this.FilterKeyBehaviorCacheEntries(keyBehaviorCache), (Func<KeyBehaviorCacheEntry, bool>)delegate (KeyBehaviorCacheEntry entry) | ||
{ | ||
|
||
Guid id = entry.Id; | ||
Guid? b = this.OutcomeGuid; | ||
return (Guid?)id == b; | ||
}); | ||
} | ||
|
||
protected override IEnumerable<KeyBehaviorCacheEntry> GetKeyBehaviorCacheEntries(KeyBehaviorCache keyBehaviorCache) | ||
{ | ||
Assert.ArgumentNotNull((object)keyBehaviorCache, "keyBehaviorCache"); | ||
return keyBehaviorCache.Outcomes; | ||
} | ||
|
||
protected override bool HasEventOccurredInInteraction(IInteractionData interaction) | ||
{ | ||
Assert.ArgumentNotNull((object)interaction, "interaction"); | ||
Assert.IsNotNull((object)Tracker.Current, "Tracker.Current is not initialized"); | ||
Assert.IsNotNull((object)Tracker.Current.Contact, "Tracker.Current.Contact is not initialized"); | ||
|
||
return Enumerable.Any<IOutcome>(Enumerable.Select<KeyValuePair<ID, IOutcome>, IOutcome>((IEnumerable<KeyValuePair<ID, IOutcome>>)TrackerExtensions.GetContactOutcomes(Tracker.Current.Session), (Func<KeyValuePair<ID, IOutcome>, IOutcome>)((KeyValuePair<ID, IOutcome> keyValuePair) => keyValuePair.Value)), (Func<IOutcome, bool>)delegate (IOutcome outcome) | ||
{ | ||
if (!outcome.InteractionId.IsNull && outcome.InteractionId.Guid == interaction.InteractionId) | ||
{ | ||
Guid guid = outcome.DefinitionId.Guid; | ||
Guid? b = this.OutcomeGuid; | ||
return (Guid?)guid == b; | ||
} | ||
|
||
return false; | ||
}); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...s/Conditions/OutcomeWithCustomDataWasRegisteredDuringPastOrCurrentInteractionCondition.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sitecore.Rules; | ||
|
||
namespace Sitecore.Support.Analytics.Outcome.Rules.Conditions | ||
{ | ||
public class OutcomeWithCustomDataWasRegisteredDuringPastOrCurrentInteractionCondition<T> : OutcomeWasRegisteredDuringPastOrCurrentInteractionCondition<T> where T : RuleContext | ||
{ | ||
public OutcomeWithCustomDataWasRegisteredDuringPastOrCurrentInteractionCondition() | ||
: base(true) | ||
{ | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Sitecore.Support.129513/Analytics/Outcome/Rules/Conditions/TrackerExtensions.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Sitecore.Analytics.Outcome.Model; | ||
using Sitecore.Analytics.Tracking; | ||
using Sitecore.Common; | ||
using Sitecore.Data; | ||
using Sitecore.Diagnostics; | ||
using System.Collections.Generic; | ||
|
||
namespace Sitecore.Support.Analytics.Outcome.Rules.Conditions | ||
{ | ||
public static class TrackerExtensions | ||
{ | ||
internal static Dictionary<ID, IOutcome> GetContactOutcomes(Session session) | ||
{ | ||
Dictionary<ID, IOutcome> dictionary; | ||
if (session.CustomData.ContainsKey("Sitecore.Analytics.Outcome#Outcomes")) | ||
{ | ||
dictionary = (session.CustomData["Sitecore.Analytics.Outcome#Outcomes"] as Dictionary<ID, IOutcome>); | ||
string text = string.Format("Outcome data in session for the contact {0} contained the key {1}, but the type of the object was not Dictionary<ID, IOutcome> as expected.", session.Contact.ContactId, "Sitecore.Analytics.Outcome#Outcomes"); | ||
Assert.IsNotNull((object)dictionary, text); | ||
foreach (IOutcome value in dictionary.Values) | ||
{ | ||
value.EntityId=(TypeExtensions.ToID(session.Contact.ContactId)); | ||
} | ||
|
||
return dictionary; | ||
} | ||
|
||
dictionary = new Dictionary<ID, IOutcome>(); | ||
session.CustomData["Sitecore.Analytics.Outcome#Outcomes"] = dictionary; | ||
return dictionary; | ||
} | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
...Analytics/Rules/Conditions/CampaignWasTriggeredDuringPastOrCurrentInteractionCondition.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Sitecore.Analytics; | ||
using Sitecore.Analytics.Tracking; | ||
using Sitecore.Diagnostics; | ||
using Sitecore.Rules; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Sitecore.Support.Analytics.Rules.Conditions | ||
{ | ||
public class CampaignWasTriggeredDuringPastOrCurrentInteractionCondition<T> : HasEventOccurredCondition<T> where T : RuleContext | ||
{ | ||
private Guid? campaignGuid; | ||
|
||
private bool campaignGuidInitialized; | ||
|
||
private bool filterByCustomData; | ||
|
||
public string CampaignId { get; set; } | ||
|
||
private Guid? CampaignGuid | ||
{ | ||
get | ||
{ | ||
if (this.campaignGuidInitialized) | ||
{ | ||
return this.campaignGuid; | ||
} | ||
|
||
try | ||
{ | ||
this.campaignGuid = new Guid(this.CampaignId); | ||
} | ||
catch | ||
{ | ||
Log.Warn(string.Format("Could not convert value to guid: {0}", this.CampaignId), (object)base.GetType()); | ||
} | ||
|
||
this.campaignGuidInitialized = true; | ||
return this.campaignGuid; | ||
} | ||
} | ||
|
||
public CampaignWasTriggeredDuringPastOrCurrentInteractionCondition() | ||
: base(false) | ||
{ | ||
} | ||
|
||
protected CampaignWasTriggeredDuringPastOrCurrentInteractionCondition(bool filterByCustomData) | ||
: base(filterByCustomData) | ||
{ | ||
this.filterByCustomData = filterByCustomData; | ||
} | ||
|
||
protected override bool Execute(T ruleContext) | ||
{ | ||
Assert.ArgumentNotNull((object)ruleContext, "ruleContext"); | ||
Assert.IsNotNull((object)Tracker.Current, "Tracker.Current is not initialized"); | ||
Assert.IsNotNull((object)Tracker.Current.Session, "Tracker.Current.Session is not initialized"); | ||
Assert.IsNotNull((object)Tracker.Current.Session.Interaction, "Tracker.Current.Session.Interaction is not initialized"); | ||
if (!this.CampaignGuid.HasValue) | ||
{ | ||
return false; | ||
} | ||
|
||
if (this.HasEventOccurredInInteraction(Tracker.Current.Session.Interaction)) | ||
{ | ||
return true; | ||
} | ||
|
||
Assert.IsNotNull((object)Tracker.Current.Contact, "Tracker.Current.Contact is not initialized"); | ||
KeyBehaviorCache keyBehaviorCache = ContactKeyBehaviorCacheExtension.GetKeyBehaviorCache(Tracker.Current.Contact); | ||
|
||
return Enumerable.Any<KeyBehaviorCacheEntry>(this.FilterKeyBehaviorCacheEntries(keyBehaviorCache), (Func<KeyBehaviorCacheEntry, bool>)delegate (KeyBehaviorCacheEntry entry) | ||
{ | ||
Guid id = entry.Id; | ||
Guid? b = this.CampaignGuid; | ||
return (Guid?)id == b; | ||
}); | ||
} | ||
|
||
protected override IEnumerable<KeyBehaviorCacheEntry> GetKeyBehaviorCacheEntries(KeyBehaviorCache keyBehaviorCache) | ||
{ | ||
Assert.ArgumentNotNull((object)keyBehaviorCache, "keyBehaviorCache"); | ||
return keyBehaviorCache.Campaigns; | ||
} | ||
|
||
protected override bool HasEventOccurredInInteraction(IInteractionData interaction) | ||
{ | ||
Assert.ArgumentNotNull((object)interaction, "interaction"); | ||
if (interaction.CampaignId.HasValue) | ||
{ | ||
Guid value = interaction.CampaignId.Value; | ||
Guid? b = this.CampaignGuid; | ||
return (Guid?)value == b; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...s/Conditions/CampaignWithCustomDataWasTriggeredDuringPastOrCurrentInteractionCondition.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Sitecore.Rules; | ||
|
||
namespace Sitecore.Support.Analytics.Rules.Conditions | ||
{ | ||
public class CampaignWithCustomDataWasTriggeredDuringPastOrCurrentInteractionCondition<T> : CampaignWasTriggeredDuringPastOrCurrentInteractionCondition<T> where T : RuleContext | ||
{ | ||
public CampaignWithCustomDataWasTriggeredDuringPastOrCurrentInteractionCondition() | ||
: base(true) | ||
{ | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...e.Support.129513/Analytics/Rules/Conditions/ChannelOfPastOrCurrentInteractionCondition.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using Sitecore.Analytics; | ||
using Sitecore.Analytics.Tracking; | ||
using Sitecore.Diagnostics; | ||
using Sitecore.Rules; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Sitecore.Support.Analytics.Rules.Conditions | ||
{ | ||
public class ChannelOfPastOrCurrentInteractionCondition<T> : HasEventOccurredCondition<T> where T : RuleContext | ||
{ | ||
private Guid? channelGuid; | ||
|
||
private bool channelGuidInitialized; | ||
|
||
private bool filterByCustomData; | ||
|
||
public string ChannelId { get; set; } | ||
|
||
private Guid? ChannelGuid | ||
{ | ||
get | ||
{ | ||
if (this.channelGuidInitialized) | ||
{ | ||
return this.channelGuid; | ||
} | ||
|
||
try | ||
{ | ||
this.channelGuid = new Guid(this.ChannelId); | ||
} | ||
catch | ||
{ | ||
Log.Warn(string.Format("Could not convert value to guid: {0}", this.ChannelId), (object)base.GetType()); | ||
} | ||
|
||
this.channelGuidInitialized = true; | ||
return this.channelGuid; | ||
} | ||
} | ||
|
||
public ChannelOfPastOrCurrentInteractionCondition() | ||
: base(false) | ||
{ | ||
} | ||
|
||
protected ChannelOfPastOrCurrentInteractionCondition(bool filterByCustomData) | ||
: base(filterByCustomData) | ||
{ | ||
this.filterByCustomData = filterByCustomData; | ||
} | ||
|
||
protected override bool Execute(T ruleContext) | ||
{ | ||
Assert.ArgumentNotNull((object)ruleContext, "ruleContext"); | ||
Assert.IsNotNull((object)Tracker.Current, "Tracker.Current is not initialized"); | ||
Assert.IsNotNull((object)Tracker.Current.Session, "Tracker.Current.Session is not initialized"); | ||
Assert.IsNotNull((object)Tracker.Current.Session.Interaction, "Tracker.Current.Session.Interaction is not initialized"); | ||
if (!this.ChannelGuid.HasValue) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!this.HasEventOccurredInInteraction(Tracker.Current.Session.Interaction)) | ||
{ | ||
return false; | ||
} | ||
|
||
Assert.IsNotNull((object)Tracker.Current.Contact, "Tracker.Current.Contact is not initialized"); | ||
KeyBehaviorCache keyBehaviorCache = ContactKeyBehaviorCacheExtension.GetKeyBehaviorCache(Tracker.Current.Contact); | ||
|
||
return Enumerable.Any<KeyBehaviorCacheEntry>(this.FilterKeyBehaviorCacheEntries(keyBehaviorCache), (Func<KeyBehaviorCacheEntry, bool>)delegate (KeyBehaviorCacheEntry entry) | ||
{ | ||
Guid id = entry.Id; | ||
Guid? b = this.ChannelGuid; | ||
return (Guid?)id == b; | ||
}); | ||
} | ||
|
||
protected override IEnumerable<KeyBehaviorCacheEntry> GetKeyBehaviorCacheEntries(KeyBehaviorCache keyBehaviorCache) | ||
{ | ||
Assert.ArgumentNotNull((object)keyBehaviorCache, "keyBehaviorCache"); | ||
return keyBehaviorCache.Channels; | ||
} | ||
|
||
protected override bool HasEventOccurredInInteraction(IInteractionData interaction) | ||
{ | ||
Assert.ArgumentNotNull((object)interaction, "interaction"); | ||
Guid channelId = interaction.ChannelId; | ||
Guid? b = this.ChannelGuid; | ||
return (Guid?)channelId == b; | ||
} | ||
} | ||
} |
Oops, something went wrong.