BloggingAbout.NET
Thoughts of developers
BAM Aggregations: Time Dimension in Local Time

Overview: 

BAM tracks activity using UTC, the BAM Portal Activity Search displays datetime in local time, and BAM Aggregates are collected in UTC.  This means if a business user is using both the BAM Portal Activity Search page and the BAM Portal Aggregate view, there is a good chance they will get confused by this. 

Basics:

Some basics of how I understand BAM to be put together.  Note, of course, I am not a BAM expert and am basically bashing my way through BAM...  I suspect the described technique is particular to how I created my views and more complex views/activities will require more development.

When a BAM activity is deployed several tables are created in the BAMPrimaryImport database, namely, bam_MyActivity_Active, bam_MyActivity_ActiveRelationships, bam_MyActivity_Completed, bam_MyActivity_CompletedRelationships, and bam_MyActivity_Continuations.  In regards to this post, I am interested in the Active and Completed tables.

The bam_MyActivity_Active table will be inserted into when a new activity trace is started and the trace will be deleted at the end of the activity trace.  The bam_MyActivity_Completed will be inserted into when the trace ends.  The update of the created views is performed by triggers on these two tables. 

Solution:

I created a Function that takes in a UTC datetime and converts to localtime:

CREATE FUNCTION [dbo].[bam_ConvertDateFromUTC] ( @utcdate datetime ) RETURNS datetime AS
BEGIN
  DECLARE @TimeDifference int

  IF @utcdate is NULL
      RETURN NULL

  SELECT @TimeDifference = ROUND(DATEDIFF(mi, GetUTCDate(), GetDate()), -1)

  RETURN DATEADD(mi, @TimeDifference, @utcdate)
END

Then in the trigger associated with the bam_MyActivity_Active table that performs the update of the aggregation view (bam_MyActivityView_MyActivity_RTAActiveTrigger), perform a search and replace of all dimension related date fields to use the created function. 

For example, [deleted].[StartDate] -> [bam_ConvertDateFromUTC]([deleted].[StartDate])
                    [inserted].[StartDate] -> [bam_ConvertDateFromUTC]([inserted].[StartDate])

And finally in the trigger associated with the bam_MyActivity_Completed table that performs the update of the aggregation view (bam_MyActivityView_MyActivity_RTACompletedTrigger), perform a search and replace of all dimension related date fields to use the created function.

For example, [inserted].[StartDate] -> [bam_ConvertDateFromUTC]([inserted].[StartDate])

Comments:

The problem now is the BAM Portal, and unfortunately I do not have a bodge for this one.  In the generated aggregate view page, the text is displayed "* All Date/Time are expressed in Universal Time Coordinates (UTC). The offset from the web site time zone to UTC is 12:00:00.".  Now, how do you get rid of this?  Any ideas besides writing my own aggregate view page?


Posted Wed, Oct 3 2007 8:41 AM by chilberto
Filed under: ,

Comments

Jeffrey Chilberto wrote BAM Aggregation View: There must be a better way...
on Tue, Oct 2 2007 10:27 PM

As BAM tracks activity using UTC , I am trying to find a way to get my aggregate views with a progress

chilberto wrote re: BAM Aggregations: Time Dimension in Local Time
on Wed, Oct 3 2007 1:35 AM

In order to hide the "* All Date/Time are expressed..." message is to change the BAM Portal's SyleSheet.css:

td.timeZoneLabel {

   padding-top: 4px;

   color: white;

}

Thanks Slade for the idea.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Please add 1 and 5 and type the answer here:
Copyright © 2003-2010 BloggingAbout.NET