Last active
August 29, 2015 14:06
-
-
Save chrismrgn/0b408d1d6d01637612cf to your computer and use it in GitHub Desktop.
HTTPModule to add claims to Ambient Data Framework (ADF) Claim Store
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
using Tridion.ContentDelivery.AmbientData; | |
namespace Tridion.ADF.Modules.DayOfWeek | |
{ | |
public class DayOfWeekModule : IHttpModule | |
{ | |
public DayOfWeekModule() { } | |
void IHttpModule.Dispose() { } | |
void IHttpModule.Init(HttpApplication context) | |
{ | |
context.PreRequestHandlerExecute += new EventHandler(Application_PreRequestHandlerExecute); | |
} | |
private void Application_PreRequestHandlerExecute(Object source, EventArgs e) | |
{ | |
HttpApplication application = (HttpApplication)source; | |
HttpContext context = application.Context; | |
if (AmbientDataContext.CurrentClaimStore != null && DateTime.Now.Minute % 2 == 0) | |
{ | |
if(!AmbientDataContext.CurrentClaimStore.Contains(new Uri("taf:claim:dayofweek:day"))) | |
{ | |
//Logic and Retreval of custom Claim value from CRM, Weather Provider etc... | |
//Add value to Claim Store | |
AmbientDataContext.CurrentClaimStore.Put(new Uri("taf:claim:dayofweek:day"), DateTime.Now.Day.ToString(), Tridion.ContentDelivery.AmbientData.Runtime.ClaimType.Normal); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment