<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Samurai Programmer.com - Pivot</title>
    <link>http://www.samuraiprogrammer.com/blog/</link>
    <description>I know kung fu</description>
    <language>en-us</language>
    <copyright>Greg Varveris</copyright>
    <lastBuildDate>Mon, 11 Oct 2010 05:09:42 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>greg@samuraiprogrammer.com</managingEditor>
    <webMaster>greg@samuraiprogrammer.com</webMaster>
    <item>
      <trackback:ping>http://www.samuraiprogrammer.com/blog/Trackback.aspx?guid=d439bf53-49be-4b3d-aaec-02ab63e756f3</trackback:ping>
      <pingback:server>http://www.samuraiprogrammer.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.samuraiprogrammer.com/blog/PermaLink,guid,d439bf53-49be-4b3d-aaec-02ab63e756f3.aspx</pingback:target>
      <dc:creator>Greg Varveris</dc:creator>
      <wfw:comment>http://www.samuraiprogrammer.com/blog/CommentView,guid,d439bf53-49be-4b3d-aaec-02ab63e756f3.aspx</wfw:comment>
      <wfw:commentRss>http://www.samuraiprogrammer.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d439bf53-49be-4b3d-aaec-02ab63e756f3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx">In
my previous post</a>, I added to my series of entries on making sense of your ASP.NET
event log error messages.  Note that this is entry #4 in this series.  The
previous three entries can be found here:
</p>
        <ul>
          <li>
Part 1:  <a href="http://www.samuraiprogrammer.com/blog/ct.ashx?id=a7f8712d-020c-4cd3-acf3-8342ddc1e629&amp;url=http%3a%2f%2fwww.samuraiprogrammer.com%2fblog%2f2010%2f08%2f29%2fParsingASPNETEventLogErrorMessagesForFunAndProfit.aspx">Parsing
ASP.NET event log error messages for fun and profit</a></li>
          <li>
Part 2:  <a href="http://www.samuraiprogrammer.com/blog/ct.ashx?id=a7f8712d-020c-4cd3-acf3-8342ddc1e629&amp;url=http%3a%2f%2fwww.samuraiprogrammer.com%2fblog%2f2010%2f09%2f19%2fDontGuessWhenItComesToPerformanceaRegExStory.aspx">Don’t
guess when it comes to performance…</a></li>
          <li>
Part 3:  <a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx">Pivoting
your ASP.NET event log error messages</a></li>
        </ul>
        <p>
In that last post, I walked through the PAuthorLib.dll and showed you how to crawl
through your event log error messages and create a pivot collection.  The result
of that initial effort was a nice view into our events:
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/ct.ashx?id=a7f8712d-020c-4cd3-acf3-8342ddc1e629&amp;url=http%3a%2f%2fwww.samuraiprogrammer.com%2fblog%2fcontent%2fbinary%2fWindows-Live-Writer%2f01d5145cc9d9_135BB%2fimage_12.png">
            <img title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_5.png" width="487" height="377" />
          </a>
        </p>
        <p>
While this certainly got the job done and is a <strong>very </strong>powerful and
compelling view into our data, we need to realize that as our data grow, the amount
of entries in our linked collection is limited.  <a href="http://www.getpivot.com/developer-info/">From
the Developer Overview</a>, we see that the maximum number of items we should have
in a single collection is <strong>3,000</strong>:<strong></strong></p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_6.png">
            <img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_2.png" width="551" height="320" />
          </a>
        </p>
        <p>
So, while a simple collection will get the job done for your smaller amounts of data,
you will really run into some challenges with your larger datasets like our ASP.NET
event log error messages.  To combat this limitation you can create what’s called
a Linked Collection.  The idea is that it’s just a way for you to link together
related collections in order to provide a seamless experience for your users. 
In our case, a natural break for our collections will be based upon the exception
type with a summary collection and then a separate collection for each exception type. 
If I were to draw this out:  
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/PivotCollections_2.png">
            <img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PivotCollections" border="0" alt="PivotCollections" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/PivotCollections_thumb.png" width="541" height="204" />
          </a>
        </p>
        <h3>Event Log Header Collection Source
</h3>
        <p>
The idea behind this structure is that the Exception summary would simply link to
each of these exception collections.  First, we’ll create a colleciton source
for our exception summary.  <a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx">As
in our previous collection source (in my last blog post)</a>, we inherit from the
AbstractCollectionSource class and use the LoadHeaderData() method to add our facet
categories to the collection.  In this case, we’ll create two categories – the
number of Occurrences and the Urls where the exception occurred.  Another difference
is that we are going to pass the already parsed collection of messages into the constructor. 
The reason for that is so we don’t have to repeat the parsing of the event log messages
multiple times.
</p>
        <pre class="c#" name="code">class EventLogHeaderCollectionSource : AbstractCollectionSource<br />
{<br /><br />
private IEnumerable&lt;EventLogMessage&gt; m_messages = null;<br /><br />
public EventLogHeaderCollectionSource(IEnumerable&lt;EventLogMessage&gt; messages, 
<br />
string inputFile)<br />
: base(inputFile)<br />
{<br /><br />
m_messages = messages;<br /><br /><br />
}<br /><br />
#region Facets<br /><br />
private const string OCCURRENCES = "Occurrences";<br />
private const string URLS = "Urls";<br /><br />
#endregion<br /><br />
protected override void LoadHeaderData()<br />
{<br />
this.CachedCollectionData.FacetCategories.<br />
Add(new PivotFacetCategory(OCCURRENCES, PivotFacetType.Number));<br />
this.CachedCollectionData.FacetCategories.<br />
Add(new PivotFacetCategory(URLS, PivotFacetType.String));<br /><br />
this.CachedCollectionData.Name = 
<br />
"ASP.NET Error Messages - Summary";<br />
this.CachedCollectionData.Copyright = 
<br />
new PivotLink("Source", "http://www.samuraiprogrammer.com");<br /><br />
}<br />
}</pre>
        <p>
Then, in the LoadItems() method, we provide the logic to generate the PivotItem collection. 
The one key item to make note of is the use of the <strong>Href </strong>property
of the PivotItem object.  This is where we specify the collection we wish to
link to this item.  Since each of the PivotItems will be a summary of the number
of each exception type – we’ll name the sub-collections by its exception type. 
For example, NullReferenceException.cxml, SqlException.cxml, etc.
</p>
        <pre class="c#" name="code">protected override IEnumerable&lt;PivotItem&gt; LoadItems()<br />
{<br />
var results = from log in m_messages<br />
group log by log.Exceptiontype into l<br />
orderby l.Count() descending, l.Key<br />
select new<br />
{<br />
ExceptionType = l.Key,<br />
ExceptionCount = l.Count()<br />
};<br /><br /><br />
int index = 0;<br />
foreach (var result in results)<br />
{<br />
PivotItem item = new PivotItem(index.ToString(), this); 
<br />
item.Name = result.ExceptionType;<br />
item.Description = "# of Exceptions: " + result.ExceptionCount.ToString();<br />
item.AddFacetValues(OCCURRENCES, result.ExceptionCount);<br />
item.Href = result.ExceptionType + ".cxml";<br /><br />
... 
<br /><br />
index++;<br />
yield return item;<br />
}<br /><br />
yield break;<br />
}</pre>
        <h3>Event Log Collection Source Redux
</h3>
        <p>
Previously, when we generated the pivot collections, we were outputting all of the
records into a single collection.  Now that we are generating a collection for
each exception type, we will need to put a filter in our exception collection and
then incorporate that filter into our item generation.  Other than that, the
code we wrote previously remains largely unchanged, so I left the majority of it out
and only included the snippets that we care about below.
</p>
        <pre class="c#" name="code">class EventLogCollectionSource : AbstractCollectionSource<br />
{<br />
private IEnumerable&lt;EventLogMessage&gt; m_messages = null;<br />
private string m_exceptionType = string.Empty;<br /><br />
public EventLogCollectionSource(<br />
IEnumerable&lt;EventLogMessage&gt; messages, 
<br />
string exceptionType, 
<br />
string path)<br />
: base(path)<br />
{<br />
m_messages = messages;<br />
m_exceptionType = exceptionType;<br />
}<br /><br />
protected override void LoadHeaderData()<br />
{<br />
...<br />
this.CachedCollectionData.Name = 
<br />
string.Format("{0} Error Messages", m_exceptionType);<br />
...<br />
}<br /><br />
protected override IEnumerable&lt;PivotItem&gt; LoadItems()<br />
{<br />
var results = (from message in m_messages<br />
where message.Exceptiontype == m_exceptionType<br />
select message);<br /><br />
int index = 0;<br />
foreach (EventLogMessage message in results)<br />
{<br />
PivotItem item = 
<br />
new PivotItem(index.ToString(), this);<br />
item.Name = message.Exceptiontype;<br />
item.Description = message.Exceptionmessage;<br /><br />
...<br /><br />
index++;<br />
yield return item;<br />
}<br />
yield break;<br />
}<br />
}</pre>
        <h3>Generate and test the collection
</h3>
        <p>
Then, the only thing we have left to do is generate and test our linked collections. 
I won’t go into a lengthy explanation of how we generate the collections because <a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx">I
did that in the last blog entry</a>.  I will show the broad strokes required
to tie this all together, though:
</p>
        <pre class="c#" name="code">// Load the raw messages into a collection<br />
IEnumerable&lt;EventLogMessage&gt; messages = 
<br />
LoadEventLogMessages(inputFile).ToList();<br /><br />
// Generate summary pivot collection<br />
EventLogHeaderCollectionSource sourceSummary = 
<br />
new EventLogHeaderCollectionSource(messages, inputFile);<br />
...<br />
summaryTargetFilter1.Write(sourceSummaryFilter1);<br /><br />
// Get the aggregate results so we know the filters<br />
// for our exception pivot collections<br />
var summaryResults = from log in messages<br />
group log by log.Exceptiontype into l<br />
orderby l.Count() descending, l.Key<br />
select new<br />
{<br />
ExceptionType = l.Key,<br />
ExceptionCount = l.Count()<br />
};<br /><br />
foreach (var resultItem in summaryResults)<br />
{<br />
// Generate pivots for each exception type<br />
EventLogCollectionSource source = 
<br />
new EventLogCollectionSource(messages, 
<br />
resultItem.ExceptionType, 
<br />
inputFile);<br />
...<br />
targetFilter1.Write(sourceFilter1);<br />
}</pre>
        <p>
Once we we have this code and everything has been generated, if we open the output
folder, we’ll see the following structure:
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_8.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_3.png" width="515" height="387" />
          </a>
        </p>
        <p>
We see our ExceptionSummary pivot collection and all of the deep zoom folders. 
So, when we open the Pivot tool, we’ll see a nice parent collection:
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_10.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_4.png" width="644" height="407" />
          </a>
        </p>
        <p>
This gives us a nice breakdown of the number of occurrences for each exception in
our source data.  Immediately we see an outlier (more on that later) between
the 6,000 and 7,000 item mark and when we select that tile, we see the following:
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_12.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_5.png" width="644" height="440" />
          </a>
        </p>
        <p>
We also see a green “Open” box (surrounded in a red rectangle, my emphasis) which
links to our NullReferenceException.cxml.  When we click that box, the tool will
immediately open that collection in the UI for our perusal – providing a very similar
look to what we saw in the last entry:
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_14.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_6.png" width="644" height="377" />
          </a>
        </p>
        <h3>Closing Thoughts
</h3>
        <p>
Now, you may have noticed a contradiction above.  I said that a collection should
have no more than 3,000 items and yet, with the NullReferenceException collection,
we saw in the summary that it had over 6,000 items.  That is a very good point
and will be a subject of a future blog post.  I wanted to illustrate the simple
collections and the linked collections before we got into that third type of collection
from above – the Dynamic Collection.  Stay tuned!
</p>
      </body>
      <title>Linking your pivot collections the fun and easy way</title>
      <guid isPermaLink="false">http://www.samuraiprogrammer.com/blog/PermaLink,guid,d439bf53-49be-4b3d-aaec-02ab63e756f3.aspx</guid>
      <link>http://www.samuraiprogrammer.com/blog/2010/10/11/LinkingYourPivotCollectionsTheFunAndEasyWay.aspx</link>
      <pubDate>Mon, 11 Oct 2010 05:09:42 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx"&gt;In
my previous post&lt;/a&gt;, I added to my series of entries on making sense of your ASP.NET
event log error messages.&amp;#160; Note that this is entry #4 in this series.&amp;#160; The
previous three entries can be found here:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Part 1:&amp;#160; &lt;a href="http://www.samuraiprogrammer.com/blog/ct.ashx?id=a7f8712d-020c-4cd3-acf3-8342ddc1e629&amp;amp;url=http%3a%2f%2fwww.samuraiprogrammer.com%2fblog%2f2010%2f08%2f29%2fParsingASPNETEventLogErrorMessagesForFunAndProfit.aspx"&gt;Parsing
ASP.NET event log error messages for fun and profit&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
Part 2:&amp;#160; &lt;a href="http://www.samuraiprogrammer.com/blog/ct.ashx?id=a7f8712d-020c-4cd3-acf3-8342ddc1e629&amp;amp;url=http%3a%2f%2fwww.samuraiprogrammer.com%2fblog%2f2010%2f09%2f19%2fDontGuessWhenItComesToPerformanceaRegExStory.aspx"&gt;Don’t
guess when it comes to performance…&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
Part 3:&amp;#160; &lt;a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx"&gt;Pivoting
your ASP.NET event log error messages&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In that last post, I walked through the PAuthorLib.dll and showed you how to crawl
through your event log error messages and create a pivot collection.&amp;#160; The result
of that initial effort was a nice view into our events:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/ct.ashx?id=a7f8712d-020c-4cd3-acf3-8342ddc1e629&amp;amp;url=http%3a%2f%2fwww.samuraiprogrammer.com%2fblog%2fcontent%2fbinary%2fWindows-Live-Writer%2f01d5145cc9d9_135BB%2fimage_12.png"&gt;&lt;img title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_5.png" width="487" height="377" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
While this certainly got the job done and is a &lt;strong&gt;very &lt;/strong&gt;powerful and
compelling view into our data, we need to realize that as our data grow, the amount
of entries in our linked collection is limited.&amp;#160; &lt;a href="http://www.getpivot.com/developer-info/"&gt;From
the Developer Overview&lt;/a&gt;, we see that the maximum number of items we should have
in a single collection is &lt;strong&gt;3,000&lt;/strong&gt;:&lt;strong&gt; &lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_2.png" width="551" height="320" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
So, while a simple collection will get the job done for your smaller amounts of data,
you will really run into some challenges with your larger datasets like our ASP.NET
event log error messages.&amp;#160; To combat this limitation you can create what’s called
a Linked Collection.&amp;#160; The idea is that it’s just a way for you to link together
related collections in order to provide a seamless experience for your users.&amp;#160;
In our case, a natural break for our collections will be based upon the exception
type with a summary collection and then a separate collection for each exception type.&amp;#160;
If I were to draw this out:&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/PivotCollections_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PivotCollections" border="0" alt="PivotCollections" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/PivotCollections_thumb.png" width="541" height="204" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;Event Log Header Collection Source
&lt;/h3&gt;
&lt;p&gt;
The idea behind this structure is that the Exception summary would simply link to
each of these exception collections.&amp;#160; First, we’ll create a colleciton source
for our exception summary.&amp;#160; &lt;a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx"&gt;As
in our previous collection source (in my last blog post)&lt;/a&gt;, we inherit from the
AbstractCollectionSource class and use the LoadHeaderData() method to add our facet
categories to the collection.&amp;#160; In this case, we’ll create two categories – the
number of Occurrences and the Urls where the exception occurred.&amp;#160; Another difference
is that we are going to pass the already parsed collection of messages into the constructor.&amp;#160;
The reason for that is so we don’t have to repeat the parsing of the event log messages
multiple times.
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;class EventLogHeaderCollectionSource : AbstractCollectionSource&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
private IEnumerable&amp;lt;EventLogMessage&amp;gt; m_messages = null;&lt;br /&gt;
&lt;br /&gt;
public EventLogHeaderCollectionSource(IEnumerable&amp;lt;EventLogMessage&amp;gt; messages, 
&lt;br /&gt;
string inputFile)&lt;br /&gt;
: base(inputFile)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
m_messages = messages;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#region Facets&lt;br /&gt;
&lt;br /&gt;
private const string OCCURRENCES = &amp;quot;Occurrences&amp;quot;;&lt;br /&gt;
private const string URLS = &amp;quot;Urls&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
#endregion&lt;br /&gt;
&lt;br /&gt;
protected override void LoadHeaderData()&lt;br /&gt;
{&lt;br /&gt;
this.CachedCollectionData.FacetCategories.&lt;br /&gt;
Add(new PivotFacetCategory(OCCURRENCES, PivotFacetType.Number));&lt;br /&gt;
this.CachedCollectionData.FacetCategories.&lt;br /&gt;
Add(new PivotFacetCategory(URLS, PivotFacetType.String));&lt;br /&gt;
&lt;br /&gt;
this.CachedCollectionData.Name = 
&lt;br /&gt;
&amp;quot;ASP.NET Error Messages - Summary&amp;quot;;&lt;br /&gt;
this.CachedCollectionData.Copyright = 
&lt;br /&gt;
new PivotLink(&amp;quot;Source&amp;quot;, &amp;quot;http://www.samuraiprogrammer.com&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;/pre&gt;
&lt;p&gt;
Then, in the LoadItems() method, we provide the logic to generate the PivotItem collection.&amp;#160;
The one key item to make note of is the use of the &lt;strong&gt;Href &lt;/strong&gt;property
of the PivotItem object.&amp;#160; This is where we specify the collection we wish to
link to this item.&amp;#160; Since each of the PivotItems will be a summary of the number
of each exception type – we’ll name the sub-collections by its exception type.&amp;#160;
For example, NullReferenceException.cxml, SqlException.cxml, etc.
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;protected override IEnumerable&amp;lt;PivotItem&amp;gt; LoadItems()&lt;br /&gt;
{&lt;br /&gt;
var results = from log in m_messages&lt;br /&gt;
group log by log.Exceptiontype into l&lt;br /&gt;
orderby l.Count() descending, l.Key&lt;br /&gt;
select new&lt;br /&gt;
{&lt;br /&gt;
ExceptionType = l.Key,&lt;br /&gt;
ExceptionCount = l.Count()&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int index = 0;&lt;br /&gt;
foreach (var result in results)&lt;br /&gt;
{&lt;br /&gt;
PivotItem item = new PivotItem(index.ToString(), this); 
&lt;br /&gt;
item.Name = result.ExceptionType;&lt;br /&gt;
item.Description = &amp;quot;# of Exceptions: &amp;quot; + result.ExceptionCount.ToString();&lt;br /&gt;
item.AddFacetValues(OCCURRENCES, result.ExceptionCount);&lt;br /&gt;
item.Href = result.ExceptionType + &amp;quot;.cxml&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
... 
&lt;br /&gt;
&lt;br /&gt;
index++;&lt;br /&gt;
yield return item;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
yield break;&lt;br /&gt;
}&lt;/pre&gt;
&lt;h3&gt;Event Log Collection Source Redux
&lt;/h3&gt;
&lt;p&gt;
Previously, when we generated the pivot collections, we were outputting all of the
records into a single collection.&amp;#160; Now that we are generating a collection for
each exception type, we will need to put a filter in our exception collection and
then incorporate that filter into our item generation.&amp;#160; Other than that, the
code we wrote previously remains largely unchanged, so I left the majority of it out
and only included the snippets that we care about below.
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;class EventLogCollectionSource : AbstractCollectionSource&lt;br /&gt;
{&lt;br /&gt;
private IEnumerable&amp;lt;EventLogMessage&amp;gt; m_messages = null;&lt;br /&gt;
private string m_exceptionType = string.Empty;&lt;br /&gt;
&lt;br /&gt;
public EventLogCollectionSource(&lt;br /&gt;
IEnumerable&amp;lt;EventLogMessage&amp;gt; messages, 
&lt;br /&gt;
string exceptionType, 
&lt;br /&gt;
string path)&lt;br /&gt;
: base(path)&lt;br /&gt;
{&lt;br /&gt;
m_messages = messages;&lt;br /&gt;
m_exceptionType = exceptionType;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
protected override void LoadHeaderData()&lt;br /&gt;
{&lt;br /&gt;
...&lt;br /&gt;
this.CachedCollectionData.Name = 
&lt;br /&gt;
string.Format(&amp;quot;{0} Error Messages&amp;quot;, m_exceptionType);&lt;br /&gt;
...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
protected override IEnumerable&amp;lt;PivotItem&amp;gt; LoadItems()&lt;br /&gt;
{&lt;br /&gt;
var results = (from message in m_messages&lt;br /&gt;
where message.Exceptiontype == m_exceptionType&lt;br /&gt;
select message);&lt;br /&gt;
&lt;br /&gt;
int index = 0;&lt;br /&gt;
foreach (EventLogMessage message in results)&lt;br /&gt;
{&lt;br /&gt;
PivotItem item = 
&lt;br /&gt;
new PivotItem(index.ToString(), this);&lt;br /&gt;
item.Name = message.Exceptiontype;&lt;br /&gt;
item.Description = message.Exceptionmessage;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
index++;&lt;br /&gt;
yield return item;&lt;br /&gt;
}&lt;br /&gt;
yield break;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/pre&gt;
&lt;h3&gt;Generate and test the collection
&lt;/h3&gt;
&lt;p&gt;
Then, the only thing we have left to do is generate and test our linked collections.&amp;#160;
I won’t go into a lengthy explanation of how we generate the collections because &lt;a href="http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx"&gt;I
did that in the last blog entry&lt;/a&gt;.&amp;#160; I will show the broad strokes required
to tie this all together, though:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;// Load the raw messages into a collection&lt;br /&gt;
IEnumerable&amp;lt;EventLogMessage&amp;gt; messages = 
&lt;br /&gt;
LoadEventLogMessages(inputFile).ToList();&lt;br /&gt;
&lt;br /&gt;
// Generate summary pivot collection&lt;br /&gt;
EventLogHeaderCollectionSource sourceSummary = 
&lt;br /&gt;
new EventLogHeaderCollectionSource(messages, inputFile);&lt;br /&gt;
...&lt;br /&gt;
summaryTargetFilter1.Write(sourceSummaryFilter1);&lt;br /&gt;
&lt;br /&gt;
// Get the aggregate results so we know the filters&lt;br /&gt;
// for our exception pivot collections&lt;br /&gt;
var summaryResults = from log in messages&lt;br /&gt;
group log by log.Exceptiontype into l&lt;br /&gt;
orderby l.Count() descending, l.Key&lt;br /&gt;
select new&lt;br /&gt;
{&lt;br /&gt;
ExceptionType = l.Key,&lt;br /&gt;
ExceptionCount = l.Count()&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
foreach (var resultItem in summaryResults)&lt;br /&gt;
{&lt;br /&gt;
// Generate pivots for each exception type&lt;br /&gt;
EventLogCollectionSource source = 
&lt;br /&gt;
new EventLogCollectionSource(messages, 
&lt;br /&gt;
resultItem.ExceptionType, 
&lt;br /&gt;
inputFile);&lt;br /&gt;
...&lt;br /&gt;
targetFilter1.Write(sourceFilter1);&lt;br /&gt;
}&lt;/pre&gt;
&lt;p&gt;
Once we we have this code and everything has been generated, if we open the output
folder, we’ll see the following structure:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_8.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_3.png" width="515" height="387" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We see our ExceptionSummary pivot collection and all of the deep zoom folders.&amp;#160;
So, when we open the Pivot tool, we’ll see a nice parent collection:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_10.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_4.png" width="644" height="407" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
This gives us a nice breakdown of the number of occurrences for each exception in
our source data.&amp;#160; Immediately we see an outlier (more on that later) between
the 6,000 and 7,000 item mark and when we select that tile, we see the following:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_12.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_5.png" width="644" height="440" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We also see a green “Open” box (surrounded in a red rectangle, my emphasis) which
links to our NullReferenceException.cxml.&amp;#160; When we click that box, the tool will
immediately open that collection in the UI for our perusal – providing a very similar
look to what we saw in the last entry:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_14.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/Pivoting-ASP.NET_A224/image_thumb_6.png" width="644" height="377" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;Closing Thoughts
&lt;/h3&gt;
&lt;p&gt;
Now, you may have noticed a contradiction above.&amp;#160; I said that a collection should
have no more than 3,000 items and yet, with the NullReferenceException collection,
we saw in the summary that it had over 6,000 items.&amp;#160; That is a very good point
and will be a subject of a future blog post.&amp;#160; I wanted to illustrate the simple
collections and the linked collections before we got into that third type of collection
from above – the Dynamic Collection.&amp;#160; Stay tuned!
&lt;/p&gt;</description>
      <comments>http://www.samuraiprogrammer.com/blog/CommentView,guid,d439bf53-49be-4b3d-aaec-02ab63e756f3.aspx</comments>
      <category>ASP.NET</category>
      <category>Development</category>
      <category>Pivot</category>
    </item>
    <item>
      <trackback:ping>http://www.samuraiprogrammer.com/blog/Trackback.aspx?guid=a7f8712d-020c-4cd3-acf3-8342ddc1e629</trackback:ping>
      <pingback:server>http://www.samuraiprogrammer.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.samuraiprogrammer.com/blog/PermaLink,guid,a7f8712d-020c-4cd3-acf3-8342ddc1e629.aspx</pingback:target>
      <dc:creator>Greg Varveris</dc:creator>
      <wfw:comment>http://www.samuraiprogrammer.com/blog/CommentView,guid,a7f8712d-020c-4cd3-acf3-8342ddc1e629.aspx</wfw:comment>
      <wfw:commentRss>http://www.samuraiprogrammer.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a7f8712d-020c-4cd3-acf3-8342ddc1e629</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/logo-pivot_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="logo-pivot" border="0" alt="logo-pivot" align="left" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/logo-pivot_thumb.png" width="191" height="80" />
          </a>Unless
you’ve been hiding under the proverbial rock, you’ve probably seen the recent <a href="http://www.getpivot.com/">Pivot
hoopla</a>.  If you’re not familiar with it, it’s a way to visualize a large
amount of data in a nice filterable format.  The nice thing about it is that
it’s really easy to put together a pivot collection and there are a ton of tools available
for just this purpose.  Just do a search on CodePlex for Pivot and you’ll get
about 40’ish good results for tools you can use to create a Pivot Collection.  
</p>
        <p>
So, I was putting together a proof-of-concept for an internal project and thought
I would continue on with my series of blog posts on ASP.NET Error Message event logs
with a post on how to visualize this data using a pivot.  You may wish to read
parts 1 and 2 here:
</p>
        <ul>
          <li>
Part 1:  <a href="http://www.samuraiprogrammer.com/blog/2010/08/29/ParsingASPNETEventLogErrorMessagesForFunAndProfit.aspx">Parsing
ASP.NET event log error messages for fun and profit</a></li>
          <li>
Part 2:  <a href="http://www.samuraiprogrammer.com/blog/2010/09/19/DontGuessWhenItComesToPerformanceaRegExStory.aspx">Don’t
guess when it comes to performance…</a></li>
        </ul>
        <p>
So, when I put together my pivot, I worked out a 3 step process:
</p>
        <ol>
          <li>
Figure out what you want to Pivot</li>
          <li>
Find an API and convert the data</li>
          <li>
Generate and Test the collection</li>
        </ol>
        <p>
Let’s begin, shall we.
</p>
        <h3>
        </h3>
        <h3>Figure out what you want to Pivot
</h3>
        <p>
The structure for the Pivot Collection is deceptively simple - 
</p>
        <pre class="xml" name="code">&lt;?xml version="1.0"?&gt; 
<br />
&lt;Collection Name="Hello World Collection" …&gt;<br />
&lt;FacetCategories&gt; 
<br />
&lt;FacetCategory Name="Hello World Facet Category One" Type="String"/&gt; 
<br />
&lt;/FacetCategories&gt; 
<br />
&lt;Items ImgBase="helloworld.dzc"&gt; 
<br />
&lt;Item Img="#0" Id="0" Href="http://www.getpivot.com"
Name="Hello World!"&gt; 
<br />
&lt;Description&gt; This is the only item in the collection.&lt;/Description&gt; 
<br />
&lt;Facets&gt; 
<br />
&lt;Facet Name="Hello World Facet Category One"&gt; 
<br />
&lt;String Value="Hello World Facet Value"/&gt; 
<br />
&lt;/Facet&gt; 
<br />
&lt;/Facets&gt; 
<br />
&lt;/Item&gt; 
<br />
&lt;/Items&gt; 
<br />
&lt;/Collection&gt;</pre>
        <p>
The way that I think about the Items in the Collection are in the same way that you
might think about an object.  For example, a Car object might have the following
properties:
</p>
        <ul>
          <li>
Advertising blurb</li>
          <li>
Car and Driver Reviews</li>
          <li>
Color</li>
          <li>
Make</li>
          <li>
Model</li>
          <li>
Engine</li>
          <li>
0-60mph time</li>
          <li>
Max Speed</li>
        </ul>
        <p>
The common values like the Color, Make, Model, 0-60mph time and max speed become the
facets or attributes that describe your object in relation to other instances of objects. 
Things like the advertising blurbs and car and driver reviews or descriptions belong
instead as properties of your Item directly in the Description element.
</p>
        <p>
For our data, namely ASP.NET exceptions, we’re going to define an exception as the
following:
</p>
        <ul>
          <li>
Item</li>
          <ul>
            <li>
Name = Exception Type</li>
            <li>
Description = Exception Message</li>
            <li>
Facets</li>
            <ul>
              <li>
Request Path</li>
              <li>
Stack Trace</li>
              <li>
Event Time</li>
              <li>
Top Method of Stack Trace</li>
              <li>
Top My Code Method of Stack Trace</li>
            </ul>
          </ul>
        </ul>
        <p>
This should allow us to group and drill through the common properties that might link
exceptions together and still provide detailed error information when necessary.
</p>
        <h3>Find an API and code it
</h3>
        <p>
The second step here is to find some code/API/tool that we can enhance for our purposes. 
There are some great tools published by the Live Labs team – for example:
</p>
        <ul>
          <li>
            <a href="http://www.getpivot.com/developer-info/download-cmd-tools.aspx">Pivot Collection
Tool for the Command Line</a>
          </li>
          <li>
            <a href="http://www.getpivot.com/developer-info/download-excel-tools.aspx">Pivot Collection
Tool for Microsoft Excel</a>
          </li>
        </ul>
        <p>
While both tools could be used in this instance, in part 2 we found that some of our
Event Logs we were parsing contained more than 10,000 items and I wanted a bit more
control over how I converted the data.  “No touching” is the phrase of the day.  <a href="http://pauthor.codeplex.com/">Fortunately,
the command line tool was published on CodePlex with an API we can use</a>. 
Once you download the product you see that it contains 3 assemblies:
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_2.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb.png" width="468" height="121" />
          </a>
        </p>
        <p>
The last item there is the PauthorLib.dll which encapsulates many of the extension
points within this great tool.  In-fact, it exposes about 7 different namespaces
for our purposes:
</p>
        <p>
          <a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_4.png">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_1.png" width="301" height="148" />
          </a>
        </p>
        <p>
For our purposes, we are going to focus on the Streaming set of namespaces. 
Why?  Well, this is namely because we are going to be dealing with a lot of data
and I didn’t want to load everything into memory before writing it to disk. 
If you look at the contents of the Streaming namespace, you’ll see a great class called
“AbstractCollectionSource”.  This looks fairly promising because it exposes two
main methods:
</p>
        <pre class="c#" name="code">class EventLogExceptionCollectionSource : AbstractCollectionSource<br />
{<br />
protected override void LoadHeaderData()<br />
{<br />
throw new NotImplementedException();<br />
}<br /><br />
protected override IEnumerable&lt;PivotItem&gt; LoadItems()<br />
{<br />
throw new NotImplementedException();<br />
}<br />
}</pre>
        <p>
Before we do anything, though, we need a constructor.  The constructor will be
responsible for taking a string representing the path to our data and passing it to
our base class’s constructor.
</p>
        <pre class="c#" name="code">public EventLogExceptionCollectionSource(string filePath)<br />
: base(filePath)<br />
{<br /><br />
// Do nothing else.<br /><br />
}</pre>
Then, the first method, LoadHeaderData, is where we define our facets – Request Path,
Stack Trace, etc.  - as well as the data types that each facet will be. 
So, our code will be fairly simple and straight-forward: <pre class="c#" name="code">protected override void LoadHeaderData()<br />
{<br /><br />
this.CachedCollectionData.FacetCategories.Add(<br />
new PivotFacetCategory(STACKTRACE, 
<br />
PivotFacetType.LongString));<br />
this.CachedCollectionData.FacetCategories.Add(<br />
new PivotFacetCategory(REQUESTPATH, 
<br />
PivotFacetType.String));<br />
this.CachedCollectionData.FacetCategories.Add(<br />
new PivotFacetCategory(EVENTTIME, 
<br />
PivotFacetType.DateTime));<br />
this.CachedCollectionData.FacetCategories.Add(<br />
new PivotFacetCategory(TOPMETHOD, 
<br />
PivotFacetType.String));<br />
this.CachedCollectionData.FacetCategories.Add(<br />
new PivotFacetCategory(TOPAPPMETHOD, 
<br />
PivotFacetType.String));<br /><br />
this.CachedCollectionData.Name = "Event Log Error Messages";<br /><br /><br />
}</pre><p>
The second method, LoadItems(), is responsible for doing exactly what it suggests
– this is where we load the data from whichever source we care about and then convert
it into our PivotItem collection.  For our purposes, we’re going to load the
XML file we defined in <a href="http://www.samuraiprogrammer.com/blog/2010/08/29/ParsingASPNETEventLogErrorMessagesForFunAndProfit.aspx">Part
1</a> of this series into a list of EventLogMessage objects and then convert those
EventLogMessage objects into PivotItem objects:
</p><pre class="c#" name="code">protected override IEnumerable&lt;PivotItem&gt; LoadItems()<br />
{<br />
// Load XML file<br />
XDocument document = XDocument.Load(this.BasePath);<br /><br />
// Populate collection of EventLogMessage objects<br />
var messages = from message in document.Descendants("Message")<br />
select EventLogMessage.Load(message.Value);<br /><br />
int index = 0;<br />
foreach (EventLogMessage message in messages)<br />
{<br /><br />
PivotItem item = new PivotItem(index.ToString(), this);<br />
item.Name = message.Exceptiontype;<br />
item.Description = message.Exceptionmessage;<br />
item.AddFacetValues(REQUESTPATH, message.Requestpath);<br />
item.AddFacetValues(STACKTRACE, message.Stacktrace);<br />
item.AddFacetValues(EVENTTIME, message.Eventtime);<br />
item.AddFacetValues(TOPMETHOD, message.StackTraceFrames[0].Method);<br />
item.AddFacetValues(TOPAPPMETHOD, GetFirstNonMicrosoftMethod(message.StackTraceFrames));<br /><br />
index++;<br />
yield return item;<br /><br />
}<br />
}</pre><p>
The key method calls from above are the AddFacetValues(…) method calls.  This
method essentially sets the attributes we wish to have our data pivot upon. 
This, by itself, isn’t enough to generate our great pivot calls – we need to call
our code from somewhere.  Since this is a simple app, we’re going to make it
a console app.  For our Collection to get generated we need to use a few other
objects included in this API:
</p><ul><li><strong>EventLogExceptionCollectionSource</strong> – The class we created above.</li><li><strong>HtmlImageCreationSourceFilter</strong> – This class will generate the tile
in the Pivot based upon some HTML template we specify.</li><li><strong>LocalCxmlCollectionTarget</strong> – Generates the Collection XML file at
the path we specify.</li><li><strong>DeepZoomTargetFilter</strong> – Generates the deep zoom files to support our
collection XML file and also enables all of our fancy transitions.</li></ul><p>
In practice, the code is pretty simple and straight forward and I applaud the people
who wrote this library:
</p><pre class="c#" name="code">private static void GenerateExceptionPivot(string inputFile, string outputFolder)<br />
{<br />
string collectionName = Path.Combine(outputFolder, "MyExceptions.cxml");<br /><br />
EventLogExceptionCollectionSource source = 
<br />
new EventLogExceptionCollectionSource(inputFile);<br />
HtmlImageCreationSourceFilter sourceFilter1 = 
<br />
new HtmlImageCreationSourceFilter(source);<br />
sourceFilter1.HtmlTemplate = 
<br />
"&lt;html&gt;&lt;body&gt;&lt;h1&gt;{name}&lt;/h1&gt;{description}&lt;/body&gt;&lt;/html&gt;";<br />
sourceFilter1.Width = 600;<br />
sourceFilter1.Height = 600;<br /><br />
LocalCxmlCollectionTarget target = 
<br />
new LocalCxmlCollectionTarget(collectionName);<br />
DeepZoomTargetFilter targetFilter1 = 
<br />
new DeepZoomTargetFilter(target);<br />
targetFilter1.Write(sourceFilter1);<br /><br />
}</pre><p>
That last statement, targetFilter1.Write(…) is what will actually execute everything
and write our resultant files to disk.
</p><h3>Generate and Test the collection
</h3><p>
So, now if we run our console application and call that GenerateExceptionPivot(…)
method, we’ll get some great output.
</p><p><a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_2.png" width="644" height="361" /></a></p><p>
What’s nice about the Library is that it provides progress as it iterates through
your data (in the red rectangle) and also in the blue rectangle, we need that it’s
multi-threaded by default.  This is primarily for the most intensive part of
the operation – the creation of the deep zoom artifacts.  If you have one of
those new fangled machines with 2+ cores, you can tweak the number of threads that
it will spawn for this operation by setting the ThreadCount property of the DeepZoomTargetFilter
object.  This may or may not improve your performance but it’s nice that the
option is available.
</p><pre class="c#" name="code">...<br />
DeepZoomTargetFilter targetFilter1 = 
<br />
new DeepZoomTargetFilter(target);<br /><br /><font color="#ff0000"><strong>targetFilter1.ThreadCount = 100;<br /></strong></font>targetFilter1.Write(sourceFilter1);<br />
...</pre><p>
Once our collection has been generated, we can browse it in an explorer.exe window
just to get an idea of what our code has wrought:
</p><p><a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_10.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_4.png" width="640" height="218" /></a></p><p>
And then to test it, you can just point the Live Labs Pivot application at our “MyExceptions.cxml”
file and view the wonderful data.  For example, you can look at the Event Time
in the histogram view to see how your exceptions broke down over time.  You can
also filter your data by things like the RequestPath (the page that threw the exception)
or the Method that was at the top of the callstack.
</p><p><a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_5.png" width="626" height="484" /></a></p><p>
Then, you can zoom in on a specific time slice you care about:
</p><p><a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_14.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_6.png" width="544" height="484" /></a></p><p>
Then, if you want to view the details for a specific instance, just click the corresponding
tile.  Then, a new side bar will appear on the right hand side with all of the
details we stored in this record:
</p><p><a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_16.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_7.png" width="281" height="429" /></a></p><p>
We generated a single collection in this blog post.  One thing to keep in mind
is that each collection should have no more than 3,000 items.  For collections
in which you want to have more than 3,000 items, you should look at potentially creating
a Linked Collection.  That will be the subject of an upcoming blog post.  
</p><p>
Until next time!
</p></body>
      <title>Pivoting ASP.NET event log error messages</title>
      <guid isPermaLink="false">http://www.samuraiprogrammer.com/blog/PermaLink,guid,a7f8712d-020c-4cd3-acf3-8342ddc1e629.aspx</guid>
      <link>http://www.samuraiprogrammer.com/blog/2010/10/04/PivotingASPNETEventLogErrorMessages.aspx</link>
      <pubDate>Mon, 04 Oct 2010 15:43:49 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/logo-pivot_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 10px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top: 0px; border-right: 0px; padding-top: 0px" title="logo-pivot" border="0" alt="logo-pivot" align="left" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/logo-pivot_thumb.png" width="191" height="80" /&gt;&lt;/a&gt;Unless
you’ve been hiding under the proverbial rock, you’ve probably seen the recent &lt;a href="http://www.getpivot.com/"&gt;Pivot
hoopla&lt;/a&gt;.&amp;#160; If you’re not familiar with it, it’s a way to visualize a large
amount of data in a nice filterable format.&amp;#160; The nice thing about it is that
it’s really easy to put together a pivot collection and there are a ton of tools available
for just this purpose.&amp;#160; Just do a search on CodePlex for Pivot and you’ll get
about 40’ish good results for tools you can use to create a Pivot Collection.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
So, I was putting together a proof-of-concept for an internal project and thought
I would continue on with my series of blog posts on ASP.NET Error Message event logs
with a post on how to visualize this data using a pivot.&amp;#160; You may wish to read
parts 1 and 2 here:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Part 1:&amp;#160; &lt;a href="http://www.samuraiprogrammer.com/blog/2010/08/29/ParsingASPNETEventLogErrorMessagesForFunAndProfit.aspx"&gt;Parsing
ASP.NET event log error messages for fun and profit&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
Part 2:&amp;#160; &lt;a href="http://www.samuraiprogrammer.com/blog/2010/09/19/DontGuessWhenItComesToPerformanceaRegExStory.aspx"&gt;Don’t
guess when it comes to performance…&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
So, when I put together my pivot, I worked out a 3 step process:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Figure out what you want to Pivot&lt;/li&gt;
&lt;li&gt;
Find an API and convert the data&lt;/li&gt;
&lt;li&gt;
Generate and Test the collection&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Let’s begin, shall we.
&lt;/p&gt;
&lt;h3&gt;
&lt;/h3&gt;
&lt;h3&gt;Figure out what you want to Pivot
&lt;/h3&gt;
&lt;p&gt;
The structure for the Pivot Collection is deceptively simple - 
&lt;/p&gt;
&lt;pre class="xml" name="code"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt; 
&lt;br /&gt;
&amp;lt;Collection Name=&amp;quot;Hello World Collection&amp;quot; …&amp;gt;&lt;br /&gt;
&amp;lt;FacetCategories&amp;gt; 
&lt;br /&gt;
&amp;lt;FacetCategory Name=&amp;quot;Hello World Facet Category One&amp;quot; Type=&amp;quot;String&amp;quot;/&amp;gt; 
&lt;br /&gt;
&amp;lt;/FacetCategories&amp;gt; 
&lt;br /&gt;
&amp;lt;Items ImgBase=&amp;quot;helloworld.dzc&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;lt;Item Img=&amp;quot;#0&amp;quot; Id=&amp;quot;0&amp;quot; Href=&amp;quot;http://www.getpivot.com&amp;quot;
Name=&amp;quot;Hello World!&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;lt;Description&amp;gt; This is the only item in the collection.&amp;lt;/Description&amp;gt; 
&lt;br /&gt;
&amp;lt;Facets&amp;gt; 
&lt;br /&gt;
&amp;lt;Facet Name=&amp;quot;Hello World Facet Category One&amp;quot;&amp;gt; 
&lt;br /&gt;
&amp;lt;String Value=&amp;quot;Hello World Facet Value&amp;quot;/&amp;gt; 
&lt;br /&gt;
&amp;lt;/Facet&amp;gt; 
&lt;br /&gt;
&amp;lt;/Facets&amp;gt; 
&lt;br /&gt;
&amp;lt;/Item&amp;gt; 
&lt;br /&gt;
&amp;lt;/Items&amp;gt; 
&lt;br /&gt;
&amp;lt;/Collection&amp;gt;&lt;/pre&gt;
&lt;p&gt;
The way that I think about the Items in the Collection are in the same way that you
might think about an object.&amp;#160; For example, a Car object might have the following
properties:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Advertising blurb&lt;/li&gt;
&lt;li&gt;
Car and Driver Reviews&lt;/li&gt;
&lt;li&gt;
Color&lt;/li&gt;
&lt;li&gt;
Make&lt;/li&gt;
&lt;li&gt;
Model&lt;/li&gt;
&lt;li&gt;
Engine&lt;/li&gt;
&lt;li&gt;
0-60mph time&lt;/li&gt;
&lt;li&gt;
Max Speed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The common values like the Color, Make, Model, 0-60mph time and max speed become the
facets or attributes that describe your object in relation to other instances of objects.&amp;#160;
Things like the advertising blurbs and car and driver reviews or descriptions belong
instead as properties of your Item directly in the Description element.
&lt;/p&gt;
&lt;p&gt;
For our data, namely ASP.NET exceptions, we’re going to define an exception as the
following:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Item&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
Name = Exception Type&lt;/li&gt;
&lt;li&gt;
Description = Exception Message&lt;/li&gt;
&lt;li&gt;
Facets&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
Request Path&lt;/li&gt;
&lt;li&gt;
Stack Trace&lt;/li&gt;
&lt;li&gt;
Event Time&lt;/li&gt;
&lt;li&gt;
Top Method of Stack Trace&lt;/li&gt;
&lt;li&gt;
Top My Code Method of Stack Trace&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;
This should allow us to group and drill through the common properties that might link
exceptions together and still provide detailed error information when necessary.
&lt;/p&gt;
&lt;h3&gt;Find an API and code it
&lt;/h3&gt;
&lt;p&gt;
The second step here is to find some code/API/tool that we can enhance for our purposes.&amp;#160;
There are some great tools published by the Live Labs team – for example:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.getpivot.com/developer-info/download-cmd-tools.aspx"&gt;Pivot Collection
Tool for the Command Line&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.getpivot.com/developer-info/download-excel-tools.aspx"&gt;Pivot Collection
Tool for Microsoft Excel&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
While both tools could be used in this instance, in part 2 we found that some of our
Event Logs we were parsing contained more than 10,000 items and I wanted a bit more
control over how I converted the data.&amp;#160; “No touching” is the phrase of the day.&amp;#160; &lt;a href="http://pauthor.codeplex.com/"&gt;Fortunately,
the command line tool was published on CodePlex with an API we can use&lt;/a&gt;.&amp;#160;
Once you download the product you see that it contains 3 assemblies:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_2.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb.png" width="468" height="121" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The last item there is the PauthorLib.dll which encapsulates many of the extension
points within this great tool.&amp;#160; In-fact, it exposes about 7 different namespaces
for our purposes:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_4.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_1.png" width="301" height="148" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
For our purposes, we are going to focus on the Streaming set of namespaces.&amp;#160;
Why?&amp;#160; Well, this is namely because we are going to be dealing with a lot of data
and I didn’t want to load everything into memory before writing it to disk.&amp;#160;
If you look at the contents of the Streaming namespace, you’ll see a great class called
“AbstractCollectionSource”.&amp;#160; This looks fairly promising because it exposes two
main methods:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;class EventLogExceptionCollectionSource : AbstractCollectionSource&lt;br /&gt;
{&lt;br /&gt;
protected override void LoadHeaderData()&lt;br /&gt;
{&lt;br /&gt;
throw new NotImplementedException();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
protected override IEnumerable&amp;lt;PivotItem&amp;gt; LoadItems()&lt;br /&gt;
{&lt;br /&gt;
throw new NotImplementedException();&lt;br /&gt;
}&lt;br /&gt;
}&lt;/pre&gt;
&lt;p&gt;
Before we do anything, though, we need a constructor.&amp;#160; The constructor will be
responsible for taking a string representing the path to our data and passing it to
our base class’s constructor.
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;public EventLogExceptionCollectionSource(string filePath)&lt;br /&gt;
: base(filePath)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
// Do nothing else.&lt;br /&gt;
&lt;br /&gt;
}&lt;/pre&gt;
Then, the first method, LoadHeaderData, is where we define our facets – Request Path,
Stack Trace, etc.&amp;#160; - as well as the data types that each facet will be.&amp;#160;
So, our code will be fairly simple and straight-forward: &lt;pre class="c#" name="code"&gt;protected override void LoadHeaderData()&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
this.CachedCollectionData.FacetCategories.Add(&lt;br /&gt;
new PivotFacetCategory(STACKTRACE, 
&lt;br /&gt;
PivotFacetType.LongString));&lt;br /&gt;
this.CachedCollectionData.FacetCategories.Add(&lt;br /&gt;
new PivotFacetCategory(REQUESTPATH, 
&lt;br /&gt;
PivotFacetType.String));&lt;br /&gt;
this.CachedCollectionData.FacetCategories.Add(&lt;br /&gt;
new PivotFacetCategory(EVENTTIME, 
&lt;br /&gt;
PivotFacetType.DateTime));&lt;br /&gt;
this.CachedCollectionData.FacetCategories.Add(&lt;br /&gt;
new PivotFacetCategory(TOPMETHOD, 
&lt;br /&gt;
PivotFacetType.String));&lt;br /&gt;
this.CachedCollectionData.FacetCategories.Add(&lt;br /&gt;
new PivotFacetCategory(TOPAPPMETHOD, 
&lt;br /&gt;
PivotFacetType.String));&lt;br /&gt;
&lt;br /&gt;
this.CachedCollectionData.Name = &amp;quot;Event Log Error Messages&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;/pre&gt;
&lt;p&gt;
The second method, LoadItems(), is responsible for doing exactly what it suggests
– this is where we load the data from whichever source we care about and then convert
it into our PivotItem collection.&amp;#160; For our purposes, we’re going to load the
XML file we defined in &lt;a href="http://www.samuraiprogrammer.com/blog/2010/08/29/ParsingASPNETEventLogErrorMessagesForFunAndProfit.aspx"&gt;Part
1&lt;/a&gt; of this series into a list of EventLogMessage objects and then convert those
EventLogMessage objects into PivotItem objects:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;protected override IEnumerable&amp;lt;PivotItem&amp;gt; LoadItems()&lt;br /&gt;
{&lt;br /&gt;
// Load XML file&lt;br /&gt;
XDocument document = XDocument.Load(this.BasePath);&lt;br /&gt;
&lt;br /&gt;
// Populate collection of EventLogMessage objects&lt;br /&gt;
var messages = from message in document.Descendants(&amp;quot;Message&amp;quot;)&lt;br /&gt;
select EventLogMessage.Load(message.Value);&lt;br /&gt;
&lt;br /&gt;
int index = 0;&lt;br /&gt;
foreach (EventLogMessage message in messages)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
PivotItem item = new PivotItem(index.ToString(), this);&lt;br /&gt;
item.Name = message.Exceptiontype;&lt;br /&gt;
item.Description = message.Exceptionmessage;&lt;br /&gt;
item.AddFacetValues(REQUESTPATH, message.Requestpath);&lt;br /&gt;
item.AddFacetValues(STACKTRACE, message.Stacktrace);&lt;br /&gt;
item.AddFacetValues(EVENTTIME, message.Eventtime);&lt;br /&gt;
item.AddFacetValues(TOPMETHOD, message.StackTraceFrames[0].Method);&lt;br /&gt;
item.AddFacetValues(TOPAPPMETHOD, GetFirstNonMicrosoftMethod(message.StackTraceFrames));&lt;br /&gt;
&lt;br /&gt;
index++;&lt;br /&gt;
yield return item;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;/pre&gt;
&lt;p&gt;
The key method calls from above are the AddFacetValues(…) method calls.&amp;#160; This
method essentially sets the attributes we wish to have our data pivot upon.&amp;#160;
This, by itself, isn’t enough to generate our great pivot calls – we need to call
our code from somewhere.&amp;#160; Since this is a simple app, we’re going to make it
a console app.&amp;#160; For our Collection to get generated we need to use a few other
objects included in this API:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;EventLogExceptionCollectionSource&lt;/strong&gt; – The class we created above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HtmlImageCreationSourceFilter&lt;/strong&gt; – This class will generate the tile
in the Pivot based upon some HTML template we specify.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LocalCxmlCollectionTarget&lt;/strong&gt; – Generates the Collection XML file at
the path we specify.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DeepZoomTargetFilter&lt;/strong&gt; – Generates the deep zoom files to support our
collection XML file and also enables all of our fancy transitions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In practice, the code is pretty simple and straight forward and I applaud the people
who wrote this library:
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;private static void GenerateExceptionPivot(string inputFile, string outputFolder)&lt;br /&gt;
{&lt;br /&gt;
string collectionName = Path.Combine(outputFolder, &amp;quot;MyExceptions.cxml&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
EventLogExceptionCollectionSource source = 
&lt;br /&gt;
new EventLogExceptionCollectionSource(inputFile);&lt;br /&gt;
HtmlImageCreationSourceFilter sourceFilter1 = 
&lt;br /&gt;
new HtmlImageCreationSourceFilter(source);&lt;br /&gt;
sourceFilter1.HtmlTemplate = 
&lt;br /&gt;
&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;{name}&amp;lt;/h1&amp;gt;{description}&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;;&lt;br /&gt;
sourceFilter1.Width = 600;&lt;br /&gt;
sourceFilter1.Height = 600;&lt;br /&gt;
&lt;br /&gt;
LocalCxmlCollectionTarget target = 
&lt;br /&gt;
new LocalCxmlCollectionTarget(collectionName);&lt;br /&gt;
DeepZoomTargetFilter targetFilter1 = 
&lt;br /&gt;
new DeepZoomTargetFilter(target);&lt;br /&gt;
targetFilter1.Write(sourceFilter1);&lt;br /&gt;
&lt;br /&gt;
}&lt;/pre&gt;
&lt;p&gt;
That last statement, targetFilter1.Write(…) is what will actually execute everything
and write our resultant files to disk.
&lt;/p&gt;
&lt;h3&gt;Generate and Test the collection
&lt;/h3&gt;
&lt;p&gt;
So, now if we run our console application and call that GenerateExceptionPivot(…)
method, we’ll get some great output.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_6.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_2.png" width="644" height="361" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
What’s nice about the Library is that it provides progress as it iterates through
your data (in the red rectangle) and also in the blue rectangle, we need that it’s
multi-threaded by default.&amp;#160; This is primarily for the most intensive part of
the operation – the creation of the deep zoom artifacts.&amp;#160; If you have one of
those new fangled machines with 2+ cores, you can tweak the number of threads that
it will spawn for this operation by setting the ThreadCount property of the DeepZoomTargetFilter
object.&amp;#160; This may or may not improve your performance but it’s nice that the
option is available.
&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;...&lt;br /&gt;
DeepZoomTargetFilter targetFilter1 = 
&lt;br /&gt;
new DeepZoomTargetFilter(target);&lt;br /&gt;
&lt;br /&gt;
&lt;font color="#ff0000"&gt;&lt;strong&gt;targetFilter1.ThreadCount = 100;&lt;br /&gt;
&lt;/strong&gt;&lt;/font&gt;targetFilter1.Write(sourceFilter1);&lt;br /&gt;
...&lt;/pre&gt;
&lt;p&gt;
Once our collection has been generated, we can browse it in an explorer.exe window
just to get an idea of what our code has wrought:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_10.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_4.png" width="640" height="218" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
And then to test it, you can just point the Live Labs Pivot application at our “MyExceptions.cxml”
file and view the wonderful data.&amp;#160; For example, you can look at the Event Time
in the histogram view to see how your exceptions broke down over time.&amp;#160; You can
also filter your data by things like the RequestPath (the page that threw the exception)
or the Method that was at the top of the callstack.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_12.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_5.png" width="626" height="484" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Then, you can zoom in on a specific time slice you care about:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_14.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_6.png" width="544" height="484" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Then, if you want to view the details for a specific instance, just click the corresponding
tile.&amp;#160; Then, a new side bar will appear on the right hand side with all of the
details we stored in this record:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_16.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.samuraiprogrammer.com/blog/content/binary/Windows-Live-Writer/01d5145cc9d9_135BB/image_thumb_7.png" width="281" height="429" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We generated a single collection in this blog post.&amp;#160; One thing to keep in mind
is that each collection should have no more than 3,000 items.&amp;#160; For collections
in which you want to have more than 3,000 items, you should look at potentially creating
a Linked Collection.&amp;#160; That will be the subject of an upcoming blog post.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
Until next time!
&lt;/p&gt;</description>
      <comments>http://www.samuraiprogrammer.com/blog/CommentView,guid,a7f8712d-020c-4cd3-acf3-8342ddc1e629.aspx</comments>
      <category>ASP.NET</category>
      <category>Development</category>
      <category>Pivot</category>
    </item>
  </channel>
</rss>