Skip to content

Instantly share code, notes, and snippets.

@chrismrgn
Last active August 29, 2015 14:06
Show Gist options
  • Save chrismrgn/0b408d1d6d01637612cf to your computer and use it in GitHub Desktop.
Save chrismrgn/0b408d1d6d01637612cf to your computer and use it in GitHub Desktop.
HTTPModule to add claims to Ambient Data Framework (ADF) Claim Store
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