<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.rightpoint.com/community/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Viewpoint : SharePoint, Silverlight</title><link>http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint/Silverlight/default.aspx</link><description>Tags: SharePoint, Silverlight</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Debug Build: 31106.3070)</generator><item><title>How to use Silverlight Pivot Viewer with SharePoint Lists</title><link>http://www.rightpoint.com/community/blogs/viewpoint/archive/2011/09/01/using-silverlight-pivot-viewer-with-sharepoint-lists.aspx</link><pubDate>Thu, 01 Sep 2011 20:20:00 GMT</pubDate><guid isPermaLink="false">f7450ba4-a08e-465a-831a-f9a15c21b696:2879</guid><dc:creator>Steve Samnadda</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.rightpoint.com/community/blogs/viewpoint/rsscomments.aspx?PostID=2879</wfw:commentRss><comments>http://www.rightpoint.com/community/blogs/viewpoint/archive/2011/09/01/using-silverlight-pivot-viewer-with-sharepoint-lists.aspx#comments</comments><description>&lt;p&gt;The Internet provides us with an ever-increasing amount of information.&amp;nbsp; Despite this fact, most people are still not very good at multi-tasking.&amp;nbsp; Unlike a computer, human context-switching&amp;nbsp;wastes a tremendous&amp;nbsp;amount of time and energy.&amp;nbsp; As a result we have become better at filtering out the information we choose to spend our time on.&amp;nbsp;&amp;nbsp;For instance,&amp;nbsp;a typical person only revisits about 6-7 websites on a daily basis.&amp;nbsp; And when browsing the web a typical user spends less than&amp;nbsp;one minute on each site.&lt;/p&gt;
&lt;p&gt;For that reason, when designing websites with large amounts of data it is necessary to present that information in such a way that users can quickly find and consume the items they are looking for.&amp;nbsp; (Remember you have less than 60 seconds!)&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.silverlight.net/learn/data-networking/pivot-viewer/pivotviewer-control"&gt;Microsoft&amp;#39;s Pivot Viewer Control&lt;/a&gt; uses Silverlight to provide faceted searches in a fluid and visually appealing manner.&amp;nbsp; This tool has tremondous potential for running searches of any kind.&amp;nbsp;Deep Zoom Image technology allows high-resolution images to represent each search item.&amp;nbsp; And faceted search items can be selected, sort, and reshaped in very quick, intuitive manner.&lt;/p&gt;
&lt;p&gt;There are several great examples on the web already using Microsoft Pivot Viewer (&lt;a target="_blank" href="http://netflixpivot.cloudapp.net/"&gt;Netflix&lt;/a&gt;, &lt;a target="_blank" href="http://www.hitched.co.uk/wedding-venues/visual-search.htm"&gt;Hitched&lt;/a&gt;, &lt;a target="_blank" href="http://memorabilia.hardrock.com/"&gt;Hard Rock&lt;/a&gt;, &lt;a target="_blank" href="http://visualize.sfmoma.org/EmbarkPivot/"&gt;SFMOMA&lt;/a&gt;).&amp;nbsp; Also, there are class libraries (&lt;a target="_blank" href="http://www.silverlight.net/archives/whitepapers/deep-zoom-tools"&gt;Deep Zoom Tools&lt;/a&gt;, &lt;a target="_blank" href="http://geekswithblogs.net/tkokke/archive/2010/08/17/runtime-pivotviewer-collection-creation.aspx"&gt;Pivot Server Tools&lt;/a&gt;) available to&amp;nbsp;dynamically generate the&amp;nbsp;images and supporting&amp;nbsp;xml needed to&amp;nbsp;feed this control.&amp;nbsp;&amp;nbsp;These tools run well on a computer or off an normal ASP.NET application with direct access to the hard drive.&amp;nbsp; But how easy would it be to integrate this control with Microsoft&amp;#39;s premier platform for business intelligence, document management, and collaboration: SharePoint.&amp;nbsp; The answer was not the easy, especially generating Deep Zoom Images from SharePoint.&amp;nbsp; Once we figured out how to map these files the result was &lt;span style="text-decoration:underline;"&gt;rock-solid&lt;/span&gt; search tool for our team sites.&lt;/p&gt;
&lt;p&gt;For our purposes, we wanted to use the Pivot Viewer to search team sites based on metadata associated with that site&amp;rsquo;s purpose.&amp;nbsp; Our metadata&amp;nbsp; was specific to the project: Country, Department, Created Date, Keywords.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Screenshots below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot2.jpg"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot2.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot1.jpg"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot1.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;There were four main components used to make the Pivot Viewer work with SharePoint&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Landing Page Site &amp;ndash; This site is the parent to each or our team sites. It contains the following lists and pages: 
&lt;ul&gt;
&lt;li&gt;&amp;ldquo;Sites&amp;rdquo; list &amp;ndash; This list is used to auto-create team sites and track metadata within them&lt;/li&gt;
&lt;li&gt;&amp;ldquo;Site Images&amp;rdquo; list &amp;ndash; Contains images associated with each team site&lt;/li&gt;
&lt;li&gt;&amp;ldquo;XAP library&amp;rdquo; &amp;ndash; Document library used to store PivotViewer.xap.&lt;/li&gt;
&lt;li&gt;Search.aspx -&amp;nbsp; Search page with a Content Editor with Silverlight &amp;lt;object&amp;gt; tag&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Sites.cxml &amp;ndash; This is an XML file is passed in as a parameter to PivotViewer.xap.&amp;nbsp; It is generated from the &amp;quot;Sites&amp;quot; list and contains a listing of all our team sites and the metadata or &amp;ldquo;facets&amp;rdquo; associated with each team site.&amp;nbsp; An event receiver is attached to the &amp;ldquo;Sites&amp;rdquo; list to generate this file any time a metadata column is updated.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;dzc_output.xml &amp;ndash; A catalog of all images uploaded to &amp;ldquo;Site Images&amp;rdquo; list.&amp;nbsp; Each image is assigned an id# that is referenced by an item inside Site.cxml.&lt;/li&gt;
&lt;li&gt;Deep Zoom Tiles &amp;ndash; Each image added to &amp;ldquo;Site Images&amp;rdquo; fires an event receiver to process the photo into Deep Zoom Tiles.&amp;nbsp; Deep zoom tiles allow for a quick initial load time and the ability to quickly zoom very deep into an image.&amp;nbsp; This is achieved by creating a &amp;lsquo;pyramid&amp;rsquo; of images where each level of the pyramid is written to a folder and contains successively more slices of the photos at higher zoom levels.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;So between the &amp;ldquo;Sites&amp;rdquo;&amp;nbsp;metadata&amp;nbsp;and &amp;ldquo;Site Images&amp;rdquo; lists and their respective event handlers there is everything needed to generate a Pivot View.&amp;nbsp; There is a specific folder structure that these files should be contained in (which is all &lt;a target="_blank" href="http://www.silverlight.net/learn/data-networking/pivot-viewer/pivotviewer-control"&gt;documented&lt;/a&gt;).&amp;nbsp; Instead of explaining that, I will go straight into the technical challenges involved in generating these files programmatically.&lt;/p&gt;
&lt;p&gt;Overview: Deep Zoom Tools (&lt;a target="_blank" href="http://www.silverlight.net/archives/whitepapers/deep-zoom-tools"&gt;documentation&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;DeepZoomTools handles writing dzc_output.xml and each corresponding image tile using the ImageCreator and CollectionCreator classes.&amp;nbsp; The biggest challenge was getting DeepZoomTools.dll to write file to an SPFile stream instead of to the hard drive.&amp;nbsp; The filenames would always correspond to local path while we wanted to write to a SharePoint folder.&amp;nbsp; Luckily, their are many events we can attach to before and after a file stream request is being made.&amp;nbsp; At this point we can supplant the filestream with a memorystream of our own making&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="text-decoration:underline;"&gt;First Issue - Switching the stream dz&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="text-decoration:underline;"&gt;c_output_images&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We overrode the OutputNeeded event to translate the filename, ensure the proper SharePoint folder/file exists, and create a MemoryStream to write.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot3.jpg"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot3.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Then overrode the OutputCompleted event to stuff the resulting file from the MemoryStream into a SPFile.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot4.jpg"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot4.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The magic happens with PrepFilename method which converts a local path file to the Sharepoint file we want:&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot5.jpg"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot5.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Examples&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;source&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a&gt;file:///c:/windows/system32/inetsrv/dzc_output_images/ourimage.xml&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;destination&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;/sites/Projects/DeepZoomImages/SiteImages/dzc_output_images/ourimage.xml &lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;source&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;c:\windows\system32\inetsrv\dzc_output_images\ourimage_files\0\0_0.png&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;destination&lt;/span&gt; &lt;/p&gt;
&lt;p&gt;/sites/sis/projects/deepzoomimages/projectimages/dzc_output_images/ourimage_files/0/0_0.png&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="text-decoration:underline;"&gt;Second Issue - Switching the stream dzc_output.xml&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The dzc_output.xml is a catalog of all the images created during the last step.&amp;nbsp; It was easy enough to tell it what to generate but when it actually came time to write it wasn&amp;#39;t as simple as the solution in the first issue.&amp;nbsp; This time the Collection Creator Wrapper was entirely disposing of the file before we had a chance to write to it.&amp;nbsp; To solve this issue we overrode the MemoryStream class, attached an event to the Dispose event and handled it in our code to get the contents of the XML.&amp;nbsp; Problem&amp;nbsp; solved!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot6.jpg"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/screenshot6.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;Third Issue - Creating the Faceted Search Collection&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Oh this wasn&amp;#39;t really an issue.&amp;nbsp; Thanks to &lt;a target="_blank" href="http://geekswithblogs.net/tkokke/archive/2010/08/17/runtime-pivotviewer-collection-creation.aspx"&gt;PivotServerTools&lt;/a&gt;, we just passed in the data and it did all the work for us.&amp;nbsp; OK, there may have been some more wiring needed, but we can&amp;#39;t give up all our secrets. ;)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.rightpoint.com/community/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/Screenshot7.jpg"&gt;&lt;img src="http://www.rightpoint.com/community/resized-image.ashx/__size/550x0/__key/CommunityServer.Blogs.Components.WeblogFiles/viewpoint/Screenshot7.jpg" border="0" alt="" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kidding!&amp;nbsp; If anyone would like some more details on implementation just shoot us an email!&lt;/p&gt;
&lt;p&gt;Cheers.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://www.rightpoint.com/community/aggbug.aspx?PostID=2879" width="1" height="1"&gt;</description><category domain="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/search/default.aspx">search</category><category domain="http://www.rightpoint.com/community/blogs/viewpoint/archive/tags/Silverlight/default.aspx">Silverlight</category></item></channel></rss>