tag:blogger.com,1999:blog-17050517210301161102024-02-20T18:31:26.225-08:00Development HoleDigging into Microsoft Office SharePoint Server 2007 (MOSS 2007), Windows SharePoint Services (WSS) v3.0, Windows Workflow Foundation (WF), Microsoft Dynamics CRM, and InfoPath 2007.txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-1705051721030116110.post-92096488800788005602010-02-07T13:31:00.000-08:002010-02-11T13:16:11.607-08:00A custom rendering template for the Calendar View controlQ: How do I create a custom rendering template that only affects one calendar view on the site?<br /><br />A: In Microsoft Office SharePoint Server 2007 and WSS 3.0 it is possible to use a custom view style with the SPCalendarView control, so that additional views or replacements for the default views (Day, Week, Month) can be rendered by a custom RenderingTemplate.<br /><br />This functionality is provided by using the undocumented SPCustomViewElement element definition, which may be used to create a custom view feature at the web level, that it turn points to the custom rendering template, e.g.:<br /><br /><div class="code"><DIV STYLE="text-align:Left;font-family:Tahoma;font-style:normal;font-weight:normal;font-size:11;color:#000000;"><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#008080;background-color:#FFFFFF;"><SPAN><?xml version="1.0" encoding="utf-8"?></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>Solution</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> xmlns:xsi</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>http://www.w3.org/2001/XMLSchema-instance</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> xmlns:xsd</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>http://www.w3.org/2001/XMLSchema</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> SolutionId</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>453b1767-713e-4ca2-80bb-33aa0b40348e</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> xmlns</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>http://schemas.microsoft.com/sharepoint/</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>FeatureManifests</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>FeatureManifest</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Location</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>HubKey.SharePoint\feature.xml</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>FeatureManifests</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Calibri;font-size:14.666666666666666;margin:0 0 14 0;"><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#800000;background-color:#FFFFFF;"><SPAN>Solution</SPAN></SPAN><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#008080;background-color:#FFFFFF;"><SPAN><?xml version="1.0" encoding="utf-8" ?></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>Feature</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Id</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>EE647B50-1408-4ac7-9B8F-27D86A2E8985</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Title</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>HubKey Calendar View Feature</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Description</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Adds calendar custom view.</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN>Version</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>1.0.0.0</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Creator</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>http://www.hubkey.com</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN>ActivateOnDefault</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>True</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Scope</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Web</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> xmlns</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>http://schemas.microsoft.com/sharepoint/</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>Properties</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>Property</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Key</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>GloballyAvailable</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Value</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>true</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>Properties</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>ElementManifests</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>ElementManifest</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Location</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>elements.xml</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>ElementManifests</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>Feature</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P /><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#008080;background-color:#FFFFFF;"><SPAN><?xml version="1.0" encoding="utf-8" ?></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>Elements</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> xmlns</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>http://schemas.microsoft.com/sharepoint/</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>CustomView</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Title</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Work Week</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>workweek</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> ListType</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Events</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> ListViewType</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CALENDAR</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>0</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> AccessKey</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>w</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> </SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> ImageHeight</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>15</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> ImageWidth</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>15</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> ImageName</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>week.gif</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> ViewChromeTemplateId</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CustomCalendarViewweekChrome</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>CustomView</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Calibri;font-size:14.666666666666666;margin:0 0 14 0;"><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#800000;background-color:#FFFFFF;"><SPAN>Elements</SPAN></SPAN><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P /></DIV></div><br /><br />Although this functionality is native to MOSS and WSS 3.0, the definition for SPCustomViewElement may have been omitted from the wss.xsd schema. If this type is missing from the TEMPLATE\XML\wss.xsd file, the addition of a solution with the CustomView element will fail when verified against the schema. To avoid this scenario, the following type definition (highlighted in turquqoise) must be included in the wss schema file. Please note that editing the wss schema file cannot be recommended, please contact your Microsoft representative for more information.<br /><br /><div class="code"><DIV STYLE="text-align:Left;font-family:Tahoma;font-style:normal;font-weight:normal;font-size:11;color:#000000;"><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:complexType</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ElementDefinitionCollection</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:choice</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> minOccurs</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>0</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> maxOccurs</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>unbounded</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ContentType</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ContentTypeDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ContentTypeBinding</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ContentTypeBindingDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>DocumentConverter</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>DocumentConverterDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>FeatureSiteTemplateAssociation</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>FeatureSiteTemplateAssociationDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Field</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>SharedFieldDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CustomAction</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CustomActionDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CustomActionGroup</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CustomActionGroupDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>HideCustomAction</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>HideCustomActionDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Module</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ModuleDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ListInstance</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ListInstanceDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ListTemplate</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ListTemplateDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Control</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>DelegateControlDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Receivers</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>ReceiverDefinitionCollection</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Workflow</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>WorkflowDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>UserMigrator</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>UserMigratorDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:element</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>CustomView</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>CustomViewDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:choice</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Id</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>UniqueIdentifier</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>xs:complexType</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:complexType</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>CustomViewDefinition</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> mixed</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>true</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>ViewChromeTemplateId</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>ImageName</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>ImageWidth</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>ImageHeight</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>AccessKey</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>Sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>Sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>ListViewType</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>ListType</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>Type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>xs:string</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:attribute</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> name</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>Title</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN> type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#00FFFF;"><SPAN>LocalizableString</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>"/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#00FFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#00FFFF;"><SPAN>xs:complexType</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>></SPAN></SPAN></P></DIV></div><br /><br />The custom rendering template shown below is copied from the CalendarViewweekChrome template. Use DefaultTabsEnabled=false (highlighted in turquqoise) to replace the default calendar view tabs.<br /><br /><div class="code"><DIV STYLE="text-align:Left;font-family:Tahoma;font-style:normal;font-weight:normal;font-size:11;color:#000000;"><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>SharePoint</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>:</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>RenderingTemplate</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ID</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="CustomCalendarViewweekChrome"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>runat</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="server"></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>Template</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>div</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>id</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=CustomWeeklyViewDefault_CalendarView</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>style</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="display:block; overflow:auto; width:</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"ChromeWidth",""))</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>; height:</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"ChromeHeight",""))</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>;"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>dir</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"Direction","")</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>table</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>border</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=0</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>width</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=300</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>id</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="CalViewTable1"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>style</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="border-collapse: collapse"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>cellpadding</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=0></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>class</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="ms-calheader"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>IMG</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>SRC</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="/_layouts/images/blank.gif"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>width</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=742</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>height</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=1</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>alt</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=""></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>class</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="ms-calheader"></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>table</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>border</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="0"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>width</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="100%"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>cellspacing</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="1"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>cellpadding</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="0"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>id</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="CalViewTable12"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>style</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="border-collapse: collapse"></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>nowrap</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>div</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>class</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="ms-cal-navheader"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>nowrap</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>a</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>href</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="javascript:MoveToDate('</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"PreviousDate","") </SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>');"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>tabindex</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=1</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>style</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="visibility:</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"PreviousDateVisible","")</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>accesskey</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="<SharePoint:EncodedLiteral runat='server' text='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN>$Resources:wss,calendar_prev_AK</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>' EncodeMethod='HtmlEncode'/>"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>img</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>border</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="0"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>src</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="/_layouts/images/prevbutton</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"Direction","")</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>.gif"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>width</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="15"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>height</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="15"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>alt</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="<SharePoint:EncodedLiteral runat='server' text='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN>$Resources:wss,calendar_prevweek</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>' EncodeMethod='HtmlEncode'/>"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>a</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>a</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>href</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="javascript:MoveToDate('</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"NextDate","") </SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>');"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>tabindex</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=1</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>style</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="visibility:</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"NextDateVisible","")</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>accesskey</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="<SharePoint:EncodedLiteral runat='server' text='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN>$Resources:wss,calendar_next_AK</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>' EncodeMethod='HtmlEncode'/>"></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>img</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>border</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="0"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>src</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="/_layouts/images/nextbutton</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"Direction","")</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>.gif"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>width</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="15"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>height</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="15"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>alt</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="<SharePoint:EncodedLiteral runat='server' text='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN>$Resources:wss,calendar_nextweek</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>' EncodeMethod='HtmlEncode'/>"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>a</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>&nbsp;</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>#</SPAN></SPAN><SPAN><SPAN> DataBinder.Eval(Container,"HeaderDate","") </SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>&nbsp;</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>div</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>&nbsp;</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>class</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="ms-cal-nav-buttons</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"Direction","")</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>"></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>Sharepoint</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>:</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>SPCalendarTabs</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ID</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="SPCalendarTabs1"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>runat</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="server"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#00FFFF;"><SPAN>DefaultTabsEnabled</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#00FFFF;"><SPAN>=false</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>SelectedViewTab</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"ViewType","")) </SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>'</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ListName</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"ListName","")) </SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>'</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ViewGuid</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># SPHttpUtility.HtmlEncode(DataBinder.Eval(Container,"ViewName","")) </SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>'</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>Sharepoint</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>:</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>SPCalendarTabs</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>table</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>Sharepoint</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>:</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>WeeklyCalendarView</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ID</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="WeeklyCalendarView1"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>runat</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="server"</SPAN></SPAN><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>IsWorkWeek</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=true</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>SelectedDate</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN><%</SPAN></SPAN><SPAN><SPAN># DataBinder.Eval(Container,"SelectedDate","") </SPAN></SPAN><SPAN STYLE="background-color:#FFFF00;"><SPAN>%></SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>'</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ItemTemplateName</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="CalendarViewWeekItemTemplate"</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ItemAllDayTemplateName</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="CalendarViewWeekItemAllDayTemplate"</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>ItemMultiDayTemplateName</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>="CalendarViewWeekItemMultiDayTemplate"</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#FF0000;"><SPAN>TabIndex</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>=2</SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>Sharepoint</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>:</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>WeeklyCalendarView</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>td</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>tr</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>table</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>div</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>Template</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Courier New;font-size:13.333333333333332;margin:0 0 14 0;"><SPAN STYLE="color:#0000FF;"><SPAN></</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>SharePoint</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>:</SPAN></SPAN><SPAN STYLE="color:#A31515;"><SPAN>RenderingTemplate</SPAN></SPAN><SPAN STYLE="color:#0000FF;"><SPAN>></SPAN></SPAN></P><P /></DIV></div><br /><br />The CalendarViewStyles element in the view’s Schema Xml can be used to set the default view, e.g.:<br /><br /><div class="code"><DIV STYLE="text-align:Left;font-family:Tahoma;font-style:normal;font-weight:normal;font-size:11;color:#000000;"><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>CalendarViewStyles</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>CalendarViewStyle</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Title</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN> Work Week</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>workweek</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Template</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CustomCalendarViewweekChrome</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>0</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Default</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>TRUE</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>CalendarViewStyle</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Title</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Day</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>day</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Template</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CalendarViewdayChrome</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>1</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Default</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>FALSE</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>CalendarViewStyle</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Title</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Week</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>week</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Template</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CalendarViewweekChrome</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>2</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Default</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>FALSE</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'/></SPAN></SPAN></P><P STYLE="font-family:Arial;font-size:13.333333333333332;margin:0 0 0 0;"><SPAN STYLE="background-color:#FFFFFF;"><SPAN> </SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN><</SPAN></SPAN><SPAN STYLE="color:#800000;background-color:#FFFFFF;"><SPAN>CalendarViewStyle</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Title</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>Month</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Type</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>month</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Template</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>CalendarViewmonthChrome</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Sequence</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>3</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'</SPAN></SPAN><SPAN STYLE="color:#FF0000;background-color:#FFFFFF;"><SPAN> Default</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>='</SPAN></SPAN><SPAN STYLE="background-color:#FFFFFF;"><SPAN>FALSE</SPAN></SPAN><SPAN STYLE="color:#0000FF;background-color:#FFFFFF;"><SPAN>'/></SPAN></SPAN></P><P STYLE="font-family:Calibri;font-size:14.666666666666666;margin:0 0 14 0;"><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#0000FF;background-color:#FFFFFF;"><SPAN></</SPAN></SPAN><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#800000;background-color:#FFFFFF;"><SPAN>CalendarViewStyles</SPAN></SPAN><SPAN STYLE="font-family:Arial;font-size:13.333333333333332;color:#0000FF;background-color:#FFFFFF;"><SPAN>></SPAN></SPAN></P><P /></DIV></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com4tag:blogger.com,1999:blog-1705051721030116110.post-5004647487468032252009-06-30T20:00:00.000-07:002009-09-15T16:32:28.794-07:00Twitter Greasemonkey Following ScriptToday Twitter rolled out some <a href="http://www.techcrunch.com/2009/06/30/twitter-rolls-ui-changes-to-simplify-your-social-connections/">changes</a> to the user interface on the “Following” and “Followers” sections of their website.<br /><br />The following code is a Firefox <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a> script for the new UI that identifies on the "Following" section, whether Twitter users you follow are following you in return.<br /><br />For example, in the screen capture below it's easy to see that <a href="http://twitter.com/lancearmstrong">@lancearmstrong</a> isn't following me yet.<br /><br /><image src="http://www.hubkey.com/images/twitterfriends.gif" alt="Twitter friends" /><br /><br />Click <a href="http://www.hubkey.com/downloads/twitterfriendsfollowing.user.js">here</a> to install the script (on Firefox with the Greasemonkey add-on installed), or save the code below as a text file named "twitterfriendsfollowing.user.js", and then drag the file onto your Firefox browser.<br /><br /><span style="COLOR: red; ">Update:</span> Twitter updated the class name 'direct-message-able' to 'direct-messageable', which has been changed in the code below and downloadable script (above).<br /><br /><div class="code"><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"><span style="color: green;">// ==UserScript==</span></pre><pre style="margin: 0px;"><span style="color: green;">// @name Twitter Friends Following</span></pre><pre style="margin: 0px;"><span style="color: green;">// @namespace greasemonkey.hubkey.com</span></pre><pre style="margin: 0px;"><span style="color: green;">// @description Identifies whether Twitter users you follow are following you in return.</span></pre><pre style="margin: 0px;"><span style="color: green;">// @include http://twitter.com/*following*</span></pre><pre style="margin: 0px;"><span style="color: green;">// @include https://twitter.com/*following*</span></pre><pre style="margin: 0px;"><span style="color: green;">// @include http://twitter.com/*friends*</span></pre><pre style="margin: 0px;"><span style="color: green;">// @include https://twitter.com/*friends*</span></pre><pre style="margin: 0px;"><span style="color: green;">// ==/UserScript==</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;">twitter_friends_following = {</pre><pre style="margin: 0px;"> count: 0,</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> identify: function() {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> afollowers = document.getElementsByClassName(<span style="color: #a31515;">'direct-messageable'</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (var i = 0; i < afollowers.length; i++) {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> avcard = afollowers[i].getElementsByClassName(<span style="color: #a31515;">'about vcard'</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (avcard.length != 1)</pre><pre style="margin: 0px;"> <span style="color: blue;">continue</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> node = document.createElement(<span style="color: #a31515;">'span'</span>);</pre><pre style="margin: 0px;"> node.setAttribute(<span style="color: #a31515;">'class'</span>, <span style="color: #a31515;">'is-following'</span>);</pre><pre style="margin: 0px;"> node.innerHTML = <span style="color: #a31515;">'<i></i><strong>Following</strong>'</span>;</pre><pre style="margin: 0px;"> avcard[0].appendChild(node);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">try</span> {</pre><pre style="margin: 0px;"> twitter_friends_following.count = document.getElementsByClassName(<span style="color: #a31515;">'direct-messageable'</span>).length;</pre><pre style="margin: 0px;"> } <span style="color: blue;">catch</span> (e) {</pre><pre style="margin: 0px;"> twitter_friends_following.count = 0;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> },</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> monitor: function() {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (document.getElementsByClassName(<span style="color: #a31515;">'direct-messageable'</span>).length != twitter_friends_following.count)</pre><pre style="margin: 0px;"> twitter_friends_following.identify();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> setTimeout(twitter_friends_following.monitor, 200);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">};</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;">setTimeout(twitter_friends_following.monitor, 200);</pre></div></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com1tag:blogger.com,1999:blog-1705051721030116110.post-78010288864072542722009-05-19T12:48:00.000-07:002009-05-19T14:03:20.115-07:00NAICS Code Lookup - SIC Code Finder for Dynamics CRM 4.0We've been getting quite a few similar requests from our Microsoft Dynamics CRM clients, many of whom have expressed at an interest in improving the entry of NAICS and SIC codes for business users.<br /><br />The solution we developed with was to generate custom entities that use picklists to simplify finding the correct codes. It works well - each custom entity contains all the current codes and is easily updatable when new codes are released. The entities write the codes or industry descriptions back to the parent entity (e.g. leads and accounts) for use in reporting and are of great help in developing targeted marketing lists. Each entity uses dependent picklists to narrow the code selection from macro sector to the full category code, making even the most specific ID easy to find. The picker is activated by the user double-clicking the code or code description. You can see the NACIS code lookup entity in action below. If you’d like to install this for your CRM organization, you can purchase the HK-NCP 2009 add-on directly from our web store (contact <a href="http://www.hubkey.com/contact.aspx">HubKey</a> if you'd like more information). Alternatively, you could give it a bash yourself - comments section open below for anyone who gets stuck!<br /><br /><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,28;" WIDTH=665 HEIGHT=527><PARAM NAME=movie VALUE="http://www.hubkey.com/media/naics_toolbar.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE="#FFFFFF"><param name="allowFullScreen" value="true" ><param name="flashVars" value="showToolbar=true&topToolbar=true&showFullScreen=true¬ScaleInFullScreen=false&autoHide=false&showAutoHide=true&showTimer=true&showTimeline=true&showNextButton=true&showPrevButton=true&showFBLogo=false&showVolumeBar=false&fps=10&fileName=http%3a%2f%2fwww.hubkey.com%2fmedia%2fnaics.swf&previewMode=2&previewFilename=http%3a%2f%2fwww.hubkey.com%2fmedia%2fnaics_preview.swf&str1=Created%20with%20BB%20FlashBack&str2=Visit%20www.bbflashback.com&str3=Hide&showPausedOverlay=true&pauseByClickingOnMovie=true&startingPlaybackMode=0&preloadPercent=0" ><EMBED src="http://www.hubkey.com/media/naics_toolbar.swf" allowfullscreen="true" flashVars="showToolbar=true&topToolbar=true&showFullScreen=true¬ScaleInFullScreen=false&autoHide=false&showAutoHide=true&showTimer=true&showTimeline=true&showNextButton=true&showPrevButton=true&showFBLogo=false&showVolumeBar=false&fps=10&fileName=http%3a%2f%2fwww.hubkey.com%2fmedia%2fnaics.swf&previewMode=2&previewFilename=http%3a%2f%2fwww.hubkey.com%2fmedia%2fnaics_preview.swf&str1=Created%20with%20BB%20FlashBack&str2=Visit%20www.bbflashback.com&str3=Hide&showPausedOverlay=true&pauseByClickingOnMovie=true&startingPlaybackMode=0&preloadPercent=0" quality=high bgcolor="#FFFFFF" WIDTH=665 HEIGHT=527 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com0tag:blogger.com,1999:blog-1705051721030116110.post-90794304910274186152009-02-06T16:14:00.000-08:002009-02-06T16:35:15.194-08:00Rounding to the nearest 1000 in C#Working on that <a href="http://geek.hubkey.com/2009/02/sharepoint-api-client-side-object-model.html">demo app</a>, this came up - I wanted a number rounded to the nearest 1000. This is easy enough in Excel - the ROUND function takes negative values, so that =ROUND(2009,-3) will give you 2000. The Math.Round function in System.dll doesn't offer this functionality however - you have to implement that yourself. Here's an example of one way to do this: <br /><br /><div class="code"><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">double</span> d = (<span style="color: blue;">double</span>)<span style="color: blue;">new</span> <span style="color: #2b91af;">Random</span>().Next();</pre><pre style="margin: 0px;"> <span style="color: green;">// round to the nearest 1000</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"{0} rounded to the nearest thousand is {1}"</span>, d, Round(d, -3));</pre><pre style="margin: 0px;"> <span style="color: green;">// round to the nearest 100 etc</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"{0} rounded to the nearest hundred is {1}"</span>, d, Round(d, -2));</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">double</span> Round(<span style="color: blue;">double</span> value, <span style="color: blue;">int</span> digits)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> ((digits < -15) || (digits > 15))</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">ArgumentOutOfRangeException</span>(<span style="color: #a31515;">"digits"</span>, <span style="color: #a31515;">"Rounding digits must be between -15 and 15, inclusive."</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (digits >= 0)</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: #2b91af;">Math</span>.Round(value, digits);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">double</span> n = <span style="color: #2b91af;">Math</span>.Pow(10, -digits);</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: #2b91af;">Math</span>.Round(value / n, 0) * n;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">decimal</span> Round(<span style="color: blue;">decimal</span> d, <span style="color: blue;">int</span> decimals)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> ((decimals < -28) || (decimals > 28))</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">ArgumentOutOfRangeException</span>(<span style="color: #a31515;">"decimals"</span>, <span style="color: #a31515;">"Rounding decimals must be between -28 and 28, inclusive."</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (decimals >= 0)</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">decimal</span>.Round(d, decimals);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">decimal</span> n = (<span style="color: blue;">decimal</span>)<span style="color: #2b91af;">Math</span>.Pow(10, -decimals);</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">decimal</span>.Round(d / n, 0) * n;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com4tag:blogger.com,1999:blog-1705051721030116110.post-20396880909651276032009-02-06T16:03:00.000-08:002009-07-16T16:15:00.069-07:00SharePoint API: A Client-side Object Model - Demo ApplicationBack in <a href="http://geek.hubkey.com/2008/11/sharepoint-api-client-side-object-model.html">November</a> we released HubKey's Client-side API for SharePoint. This API wraps many of SharePoint Server 2007's Web Services (Lists Web Service, Webs Web Service, etc.) to provide a familiar object model that can be used on remote client machines without having to process XML requests and responses.<br /><br />We've recently made a few updates and have included a demonstration application which is shown running in the screen capture below. This demo app creates a new list on a remote test site with a quick launch link, creates a "test person" list scoped content type, adds a number of randomly generated people records, and then adds a new default view with a custom query returning people below age 65. This list data is then browsable and editable by a DataGridView hosted in a Windows form. In addition, paging is demonstrated by using the SPListItemCollectionPosition object.<br /><br />You can download a demo copy of the API - click <a href="http://www.hubkey.com/sharepointapi.aspx">here</a> for details. <br /><br /><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,28;" WIDTH=665 HEIGHT=527><PARAM NAME=movie VALUE="http://www.hubkey.com/media/apiDemoApp_toolbar.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE="#FFFFFF"><param name="allowFullScreen" value="true" ><param name="flashVars" value="showToolbar=true&topToolbar=true&showFullScreen=true¬ScaleInFullScreen=false&autoHide=false&showAutoHide=true&showTimer=true&showTimeline=true&showNextButton=true&showPrevButton=true&showFBLogo=false&showVolumeBar=false&fps=10&fileName=http%3a%2f%2fwww.hubkey.com%2fmedia%2fapiDemoApp.swf&previewMode=2&previewFilename=http%3a%2f%2fwww.hubkey.com%2fmedia%2fapiDemoApp_preview.swf&str1=Created%20with%20BB%20FlashBack&str2=Visit%20www.bbflashback.com&str3=Hide&showPausedOverlay=true&pauseByClickingOnMovie=true&startingPlaybackMode=0&preloadPercent=0" ><EMBED src="http://www.hubkey.com/media/apiDemoApp_toolbar.swf" allowfullscreen="true" flashVars="showToolbar=true&topToolbar=true&showFullScreen=true¬ScaleInFullScreen=false&autoHide=false&showAutoHide=true&showTimer=true&showTimeline=true&showNextButton=true&showPrevButton=true&showFBLogo=false&showVolumeBar=false&fps=10&fileName=http%3a%2f%2fwww.hubkey.com%2fmedia%2fapiDemoApp.swf&previewMode=2&previewFilename=http%3a%2f%2fwww.hubkey.com%2fmedia%2fapiDemoApp_preview.swf&str1=Created%20with%20BB%20FlashBack&str2=Visit%20www.bbflashback.com&str3=Hide&showPausedOverlay=true&pauseByClickingOnMovie=true&startingPlaybackMode=0&preloadPercent=0" quality=high bgcolor="#FFFFFF" WIDTH=665 HEIGHT=527 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com0tag:blogger.com,1999:blog-1705051721030116110.post-38154550642647201832009-02-06T15:48:00.000-08:002009-07-17T14:08:15.038-07:00MS Dynamics CRM 4.0 Record Counter / Page Count AddonOne feature commonly requested by users of Microsoft Dynamics CRM is a total of the number of records in a view or advanced find. <br /><br />Out-of-the-box, MS CRM 4.0 displays both a count of the number of records selected on the page, and the total number of records on the page, both of which are visible in the status bar at the bottom of the results grid for the view. A count of the number of records in total is missing however, as is the total number of pages available.<br /><br /><a href="http://www.hubkey.com">HubKey</a>'s new Record Count Add-on for Microsoft Dynamics CRM 4.0 meets this feature request by including both the current page number, the total pages, and the total records in the status bar along side the record selection count.<br /><br /><img src="http://www.hubkey.com/media/recordCount.gif" alt="Record count in status bar"><br /><br />This add-on is simple to install, can be configured to exclude certain entities, and supports configurable multiple user interface languages. The totals are calculated for quick and advanced finds, lookup views, and both private and public views.<br /><br />A demonstration of the installation and use of the add-in is shown in the screen capture below:<br /><br /><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,28;" WIDTH=665 HEIGHT=527><PARAM NAME=movie VALUE="http://www.hubkey.com/media/recordcount_toolbar.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE="#FFFFFF"><param name="allowFullScreen" value="true" ><param name="flashVars" value="showToolbar=true&topToolbar=true&showFullScreen=true¬ScaleInFullScreen=false&autoHide=false&showAutoHide=true&showTimer=true&showTimeline=true&showNextButton=true&showPrevButton=true&showFBLogo=false&showVolumeBar=false&fps=10&fileName=http%3a%2f%2fwww.hubkey.com%2fmedia%2frecordcount.swf&previewMode=2&previewFilename=http%3a%2f%2fwww.hubkey.com%2fmedia%2frecordcount_preview.swf&str1=Created%20with%20BB%20FlashBack&str2=Visit%20www.bbflashback.com&str3=Hide&showPausedOverlay=true&pauseByClickingOnMovie=true&startingPlaybackMode=0&preloadPercent=0" ><EMBED src="http://www.hubkey.com/media/recordcount_toolbar.swf" allowfullscreen="true" flashVars="showToolbar=true&topToolbar=true&showFullScreen=true¬ScaleInFullScreen=false&autoHide=false&showAutoHide=true&showTimer=true&showTimeline=true&showNextButton=true&showPrevButton=true&showFBLogo=false&showVolumeBar=false&fps=10&fileName=http%3a%2f%2fwww.hubkey.com%2fmedia%2frecordcount.swf&previewMode=2&previewFilename=http%3a%2f%2fwww.hubkey.com%2fmedia%2frecordcount_preview.swf&str1=Created%20with%20BB%20FlashBack&str2=Visit%20www.bbflashback.com&str3=Hide&showPausedOverlay=true&pauseByClickingOnMovie=true&startingPlaybackMode=0&preloadPercent=0" quality=high bgcolor="#FFFFFF" WIDTH=665 HEIGHT=527 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT><br /><br />To download a free trial version of the software and get a 30 day license key, click <a href="http://www.hubkey.com/DynamicsCRM.aspx">here</a>.<br /><br />To purchase a full retail server license key for $350 (per CRM organization), please use HubKey's application web store on this page or <a href="http://www.hubkey.com/Contact.aspx">contact us</a> at HubKey for more information.txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com2tag:blogger.com,1999:blog-1705051721030116110.post-81082735418920789752009-01-14T09:17:00.000-08:002009-01-14T10:16:05.299-08:00Copy and Paste CRM Picklist Values - Part IIIFollowing on from <a href="http://geek.hubkey.com/2009/01/copy-and-paste-crm-picklist-values-part_09.html">Part II</a> which went over setting up a Visual Studio project to customize the out-of-the-box edit attribute form in Microsoft Dynamics CRM 4.0, here's the last installment in this series - the code you'll need to make it work.<br /><br />Open the editAll.aspx file you created in Step II and paste in the following markup:<br /><br />(By the way if the carriage returns don't paste when you copy this into Visual Studio, copy and paste into and out of WordPad or MS Word first).<br /><br /><div class="code"><pre style="margin: 0px;"><span style="background: #ffee62;"><%</span><span style="color: blue;">@</span> <span style="color: #a31515;">Assembly</span> <span style="color: red;">Name</span><span style="color: blue;">="HubKey.Crm.Web.Tools.SystemCustomization.Attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=PUBLICKEYGOESHERE"</span> <span style="background: #ffee62;">%></span></pre><pre style="margin: 0px;"><span style="background: #ffee62;"><%</span><span style="color: blue;">@</span> <span style="color: #a31515;">Page</span> <span style="color: red;">language</span><span style="color: blue;">="c#"</span> <span style="color: red;">Inherits</span><span style="color: blue;">="HubKey.Crm.Web.Tools.SystemCustomization.Attributes.EditAllPage"</span> <span style="background: #ffee62;">%></span></pre><pre style="margin: 0px;"><span style="background: #ffee62;"><%</span><span style="color: blue;">@</span> <span style="color: #a31515;">Register</span> <span style="color: red;">TagPrefix</span><span style="color: blue;">="frm"</span> <span style="color: red;">Namespace</span><span style="color: blue;">="Microsoft.Crm.Application.Forms"</span> <span style="color: red;">Assembly</span><span style="color: blue;">="Microsoft.Crm.Application.Components.Application"</span> <span style="background: #ffee62;">%></span></pre><pre style="margin: 0px;"><span style="background: #ffee62;"><%</span><span style="color: blue;">@</span> <span style="color: #a31515;">Register</span> <span style="color: red;">TagPrefix</span><span style="color: blue;">="cnt"</span> <span style="color: red;">Namespace</span><span style="color: blue;">="Microsoft.Crm.Application.Controls"</span> <span style="color: red;">Assembly</span><span style="color: blue;">="Microsoft.Crm.Application.Components.Application"</span> <span style="background: #ffee62;">%></span></pre><pre style="margin: 0px;"><span style="background: #ffee62;"><%</span><span style="color: blue;">@</span> <span style="color: #a31515;">Register</span> <span style="color: red;">TagPrefix</span><span style="color: blue;">="ui"</span> <span style="color: red;">Namespace</span><span style="color: blue;">="Microsoft.Crm.Application.Components.UI"</span> <span style="color: red;">Assembly</span><span style="color: blue;">="Microsoft.Crm.Application.Components.UI"</span> <span style="background: #ffee62;">%></span></pre><pre style="margin: 0px;"><span style="background: #ffee62;"><%</span><span style="color: blue;">@</span> <span style="color: #a31515;">Register</span> <span style="color: red;">TagPrefix</span><span style="color: blue;">="loc"</span> <span style="color: red;">Namespace</span><span style="color: blue;">="Microsoft.Crm.Application.Controls.Localization"</span> <span style="color: red;">Assembly</span><span style="color: blue;">="Microsoft.Crm.Application.Components.Application"</span> <span style="background: #ffee62;">%></span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">html</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #a31515;">cnt</span><span style="color: blue;">:</span><span style="color: #a31515;">AppHeader</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">id</span><span style="color: blue;">="crmHeader"/></span></pre><pre style="margin: 0px;"><span style="color: blue;"></</span><span style="color: #a31515;">head</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">frm</span><span style="color: blue;">:</span><span style="color: #a31515;">DialogForm</span> <span style="color: red;">id</span><span style="color: blue;">="crmForm"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span></pre><pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #a31515;">table</span> <span style="color: red;">cellpadding</span><span style="color: blue;">="0"</span> <span style="color: red;">cellspacing</span><span style="color: blue;">="5"</span> <span style="color: red;">width</span><span style="color: blue;">="100%"</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">table-layout</span>: <span style="color: blue;">fixed</span>;<span style="color: blue;">"></span></pre><pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #a31515;">col</span> <span style="color: red;">width</span><span style="color: blue;">="100"><</span><span style="color: #a31515;">col</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #a31515;">td</span> <span style="color: red;">class</span><span style="color: blue;">="ms-crm-Field-Required"><</span><span style="color: #a31515;">label</span> <span style="color: red;">for</span><span style="color: blue;">="txtLabel"></span><span style="background: #ffee62;"><%</span><span style="color: blue;">=</span>HubKey.Crm.Web.Tools.SystemCustomization.Attributes.Globals.LOCID_EDIT_ALL_VALUE_LABEL_PAIRS<span style="background: #ffee62;">%></span><span style="color: blue;"><</span><span style="color: #a31515;">img</span> <span style="color: red;">src</span><span style="color: blue;">="/_imgs/frm_required.gif"</span> <span style="color: red;">alt</span><span style="color: blue;">="<loc:Text Encoding='HtmlAttribute' ResourceId='Forms.Required.AltTag' runat='server'/>"/></</span><span style="color: #a31515;">label</span><span style="color: blue;">></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> <span style="color: blue;"><</span><span style="color: #a31515;">td</span><span style="color: blue;">><</span><span style="color: #a31515;">ui</span><span style="color: blue;">:</span><span style="color: #a31515;">TextArea</span> <span style="color: red;">id</span><span style="color: blue;">="txtLabel"</span> <span style="color: red;">Height</span><span style="color: blue;">="270px"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"/></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> <span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> <span style="color: blue;"></</span><span style="color: #a31515;">table</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"></</span><span style="color: #a31515;">frm</span><span style="color: blue;">:</span><span style="color: #a31515;">DialogForm</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"></</span><span style="color: #a31515;">body</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"></</span><span style="color: #a31515;">html</span><span style="color: blue;">></span></pre></div><br /><br />You'll also need to make a change to the manageAttribute.aspx page. At the top of the page, add the following markup to register an "hk" tag prefix:<br /><br /><div class="code"><pre style="margin: 0px;"><span style="background: #ffee62;"><%</span><span style="color: blue;">@</span> <span style="color: #a31515;">Register</span> <span style="color: red;">TagPrefix</span><span style="color: blue;">="hk"</span> <span style="color: red;">Namespace</span><span style="color: blue;">="HubKey.Crm.Web.Tools.SystemCustomization.Attributes"</span> <span style="color: red;">Assembly</span><span style="color: blue;">="HubKey.Crm.Web.Tools.SystemCustomization.Attributes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=PUBLICKEYGOESHERE"</span> <span style="background: #ffee62;">%></span></pre></div><br /><br />Next, search for the following element id: "ledtPicklistValues". Insert a new table row / table data cell above the tr container for this element and paste in a new element: <br /><br /><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">hk</span><span style="color: blue;">:</span><span style="color: #a31515;">AppListEditAll</span> <span style="color: red;">id</span><span style="color: blue;">="appListEditAll"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"/></span></pre></div><br /><br />The enclosing table markup should now look like the following:<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">table</span> <span style="color: red;">width</span><span style="color: blue;">="100%"</span> <span style="color: red;">cellspacing</span><span style="color: blue;">="0"</span> <span style="color: red;">cellpadding</span><span style="color: blue;">="0"></span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">tr</span> <span style="color: red;">class</span><span style="color: blue;">="param"></span></pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">td</span><span style="color: blue;">><</span><span style="color: #a31515;">hk</span><span style="color: blue;">:</span><span style="color: #a31515;">AppListEditAll</span> <span style="color: red;">id</span><span style="color: blue;">="appListEditAll"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"/></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">tr</span> <span style="color: red;">class</span><span style="color: blue;">="param"></span></pre><pre style="margin: 0px;"><span style="color: blue;"><</span><span style="color: #a31515;">td</span><span style="color: blue;">><</span><span style="color: #a31515;">app</span><span style="color: blue;">:</span><span style="color: #a31515;">AppListEdit</span> <span style="color: red;">id</span><span style="color: blue;">="ledtPicklistValues"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"/></</span><span style="color: #a31515;">td</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"><span style="color: blue;"></</span><span style="color: #a31515;">tr</span><span style="color: blue;">></span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"></</span><span style="color: #a31515;">table</span><span style="color: blue;">></span></pre></div><br /><br />The code in the EditAll.cs file is as follows:<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Web.UI;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.IO;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Globalization;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.Crm;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.Crm.Application.Controls;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.Crm.Application.Forms;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.Crm.Application.Components.UI;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> HubKey.Crm.Web.Tools.SystemCustomization.Attributes</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Globals</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> LOCID_EDIT_ALL_BUTTON_TEXT;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> LOCID_EDIT_ALL_DIALOG_TITLE;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> LOCID_EDIT_ALL_DIALOG_DESC;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> LOCID_EDIT_ALL_VALUE_LABEL_PAIRS;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> LOCID_EDIT_ONLY_ONE_DEFAULT_ALLOWED;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> EDIT_ALL_JS_PATH;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> LOCID_NUMBER_RANGE_VALUE_MASK;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">string</span> LOCID_VALUE_NOT_UNIQUE;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> <span style="color: blue;">char</span> DEFAULT_ITEM_CHAR;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> Globals()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">//TODO: Localize as needed.</span></pre><pre style="margin: 0px;"> DEFAULT_ITEM_CHAR = <span style="color: #a31515;">'*'</span>;</pre><pre style="margin: 0px;"> LOCID_EDIT_ALL_BUTTON_TEXT = <span style="color: #a31515;">"Edit All"</span>;</pre><pre style="margin: 0px;"> LOCID_EDIT_ALL_VALUE_LABEL_PAIRS = <span style="color: #a31515;">"Value / Label Pairs"</span>;</pre><pre style="margin: 0px;"> LOCID_EDIT_ALL_DIALOG_TITLE = <span style="color: #a31515;">"Modify List Values"</span>;</pre><pre style="margin: 0px;"> LOCID_EDIT_ALL_DIALOG_DESC = <span style="color: #a31515;">"Modify all the values and labels in this picklist. Place each value / label pair on a new line separated by a carriage return. Separate values and labels with a tab. "</span>;</pre><pre style="margin: 0px;"> LOCID_EDIT_ALL_DIALOG_DESC += <span style="color: #a31515;">"If you don't include a value on each line (just the label) a value will be automatically created and incremented. "</span>;</pre><pre style="margin: 0px;"> LOCID_EDIT_ALL_DIALOG_DESC += <span style="color: #a31515;">"*** Warning: if any records use values that you are modifying, you must update those records to use the modified value before you do so here. ***"</span>;</pre><pre style="margin: 0px;"> LOCID_EDIT_ONLY_ONE_DEFAULT_ALLOWED = <span style="color: #a31515;">"Only one value can be default. (Value = '{0}')."</span>;</pre><pre style="margin: 0px;"> LOCID_NUMBER_RANGE_VALUE_MASK = <span style="color: #a31515;">"You must enter a whole number between {0} and {1}. (Value = '{2}')."</span>;</pre><pre style="margin: 0px;"> LOCID_VALUE_NOT_UNIQUE = <span style="color: #a31515;">"Option values must be unique. The value {0} is already being used by option '{1}'."</span>;</pre><pre style="margin: 0px;"> EDIT_ALL_JS_PATH = <span style="color: #a31515;">"/_static/tools/systemcustomization/attributes/scripts/editall.js"</span>;</pre><pre style="margin: 0px;"><span style="color: blue;">#if</span> (DEBUG)</pre><pre style="margin: 0px;"> EDIT_ALL_JS_PATH += <span style="color: #a31515;">"?"</span> + <span style="color: #2b91af;">Guid</span>.NewGuid().ToString();</pre><pre style="margin: 0px;"><span style="color: blue;">#endif</span></pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">EditAllPage</span> : <span style="color: #2b91af;">AppPage</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">protected</span> <span style="color: #2b91af;">TextArea</span> txtLabel;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> ConfigureForm()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">DialogForm</span> currentForm = <span style="color: blue;">base</span>.CurrentForm <span style="color: blue;">as</span> <span style="color: #2b91af;">DialogForm</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> currentForm.DialogTitle = <span style="color: #2b91af;">Globals</span>.LOCID_EDIT_ALL_DIALOG_TITLE;</pre><pre style="margin: 0px;"> currentForm.DialogDescription = <span style="color: #2b91af;">Globals</span>.LOCID_EDIT_ALL_DIALOG_DESC;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> ConfigurePage()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">base</span>.CurrentHeader.SetScriptFile(<span style="color: #2b91af;">Globals</span>.EDIT_ALL_JS_PATH);</pre><pre style="margin: 0px;"> <span style="color: blue;">base</span>.CurrentHeader.SetResource(<span style="color: #a31515;">"LOCID_NUMBER_RANGE_VALUE_MASK"</span>, <span style="color: #2b91af;">Globals</span>.LOCID_NUMBER_RANGE_VALUE_MASK);</pre><pre style="margin: 0px;"> <span style="color: blue;">base</span>.CurrentHeader.SetResource(<span style="color: #a31515;">"LOCID_VALUE_NOT_UNIQUE"</span>, <span style="color: #2b91af;">Globals</span>.LOCID_VALUE_NOT_UNIQUE);</pre><pre style="margin: 0px;"> <span style="color: blue;">base</span>.CurrentHeader.SetResource(<span style="color: #a31515;">"LOCID_EDIT_ONLY_ONE_DEFAULT_ALLOWED"</span>, <span style="color: #2b91af;">Globals</span>.LOCID_EDIT_ONLY_ONE_DEFAULT_ALLOWED);</pre><pre style="margin: 0px;"> <span style="color: blue;">base</span>.CurrentHeader.SetResource(<span style="color: #a31515;">"DEFAULT_ITEM_CHAR"</span>, <span style="color: #2b91af;">Globals</span>.DEFAULT_ITEM_CHAR.ToString());</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">AppListEditAll</span> : <span style="color: #2b91af;">CrmUIControl</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">AppListEdit</span> _listEdit;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> AppListEditAll() { }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> ConfigureHeader()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">base</span>.ConfigureHeader();</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">CrmUIControlBase</span>.CurrentHeader.SetScriptFile(<span style="color: #2b91af;">Globals</span>.EDIT_ALL_JS_PATH);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">CrmUIControlBase</span>.CurrentHeader.SetClientVar(<span style="color: #a31515;">"_minValueForCustomPicklists"</span>, 1);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">CrmUIControlBase</span>.CurrentHeader.SetClientVar(<span style="color: #a31515;">"_maxValueForPicklists"</span>, 2147483646);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">CrmUIControlBase</span>.CurrentHeader.SetClientVar(<span style="color: #a31515;">"_minValueForSystemPicklists"</span>, 200000);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">CrmUIControlBase</span>.CurrentHeader.SetResource(<span style="color: #a31515;">"DEFAULT_ITEM_CHAR"</span>, <span style="color: #2b91af;">Globals</span>.DEFAULT_ITEM_CHAR.ToString());</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> _listEdit = <span style="color: blue;">this</span>.Page.FindControl(<span style="color: #a31515;">"ledtPicklistValues"</span>) <span style="color: blue;">as</span> <span style="color: #2b91af;">AppListEdit</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (_listEdit != <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">this</span>.Disabled = _listEdit.Disabled;</pre><pre style="margin: 0px;"> <span style="color: blue;">this</span>.ReadOnly = _listEdit.ReadOnly;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> Render(<span style="color: #2b91af;">HtmlTextWriter</span> output)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">TextWriter</span> innerWriter = output.InnerWriter;</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<div id=\"{0}\" {1}>"</span>, <span style="color: #2b91af;">CrmEncodeDecode</span>.CrmHtmlAttributeEncode(<span style="color: blue;">this</span>.ID), (<span style="color: blue;">this</span>.ReadOnly || <span style="color: blue;">this</span>.Disabled) ? <span style="color: #a31515;">"disabled"</span> : <span style="color: blue;">string</span>.Empty);</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>"</span>);</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<tr class=\"listEdit_vspacer\"><td></td></tr>"</span>);</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<table width=\"100%\" style=\"table-layout:fixed;\" cellspacing=\"0\" cellpadding=\"0\">"</span>);</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<tr height=\"100%\"><td></td>"</span>);</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<td class=\"listEdit_hspacer\"></td>"</span>);</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<td class=\"listEdit_buttons\">"</span>);</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">"</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">this</span>.RenderButton(output, <span style="color: #a31515;">"btnEditAll"</span>, (<span style="color: blue;">this</span>.Disabled || <span style="color: blue;">this</span>.ReadOnly)? <span style="color: #a31515;">""</span>: <span style="color: #a31515;">"editAll();"</span>, <span style="color: #2b91af;">Globals</span>.LOCID_EDIT_ALL_BUTTON_TEXT);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"</table></td></tr></table></td></tr></table></div>"</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span> RenderButton(<span style="color: #2b91af;">HtmlTextWriter</span> output, <span style="color: blue;">string</span> id, <span style="color: blue;">string</span> onClick, <span style="color: blue;">string</span> text)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">TextWriter</span> innerWriter = output.InnerWriter;</pre><pre style="margin: 0px;"> innerWriter.Write(<span style="color: #a31515;">"<tr><td nowrap style=\"padding-right:5px;\">"</span>);</pre><pre style="margin: 0px;"> id = <span style="color: blue;">string</span>.Format(<span style="color: #2b91af;">CultureInfo</span>.InvariantCulture, <span style="color: #a31515;">"{0}_{1}"</span>, <span style="color: #2b91af;">CrmEncodeDecode</span>.CrmHtmlAttributeEncode(<span style="color: blue;">this</span>.ID), <span style="color: #2b91af;">CrmEncodeDecode</span>.CrmHtmlAttributeEncode(id));</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Button</span> button = <span style="color: blue;">new</span> <span style="color: #2b91af;">Button</span>(id, <span style="color: blue;">string</span>.Empty, onClick, <span style="color: blue;">false</span>, <span style="color: #a31515;">"listEdit_button"</span>);</pre><pre style="margin: 0px;"> button.InnerHtml = <span style="color: #a31515;">"<span class=\"autoellipsis\">"</span> + text + <span style="color: #a31515;">"</span>"</span>;</pre><pre style="margin: 0px;"> button.Text = text;</pre><pre style="margin: 0px;"> button.Width = 205;</pre><pre style="margin: 0px;"> button.RenderControl(output);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div><br /><br />The last piece is the client side script - editAll.js. Paste the following code into that file:<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">var</span> _nDefault, _aHiddenValues, _aSystemValues, _iMin, _iMax, _nMax;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> cancel()</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> window.close();</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> applychanges()</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oResult = <span style="color: blue;">new</span> Object();</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> oResult.sText = serializeValues(txtLabel.DataValue)</pre><pre style="margin: 0px;"> window.returnValue = oResult;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> window.close();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> (e)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> alertAndThrow(sMessage)</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> alert(sMessage);</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> Error(101, sMessage);</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> appendValues(oXmlDoc, oValues, aValues, bEditable)</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> sMessage;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> iDefault = 0;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> aDupVals = <span style="color: blue;">new</span> Array();</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> aLabels = <span style="color: blue;">new</span> Array();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> oValues.setAttribute(<span style="color: #a31515;">"default"</span>, -2147483648);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i < aValues.length; i+=2)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oValue = oXmlDoc.createElement(<span style="color: #a31515;">"value"</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> n;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (bEditable)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> s = Trim(aValues[i]);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (s.charAt(0) == DEFAULT_ITEM_CHAR)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> s = s.substr(1);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (++iDefault > 1)</pre><pre style="margin: 0px;"> alertAndThrow(formatString(LOCID_EDIT_ONLY_ONE_DEFAULT_ALLOWED, s));</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> n = LocStringToInt(s);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (isNaN(n) || n > _iMax || (n < _iMin && !_aSystemValues.contains(n)))</pre><pre style="margin: 0px;"> alertAndThrow(formatString(LOCID_NUMBER_RANGE_VALUE_MASK, AddFormatting(_iMin, 0), AddFormatting(_iMax, 0), s));</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (iDefault == 1)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> oValues.setAttribute(<span style="color: #a31515;">"default"</span>, n);</pre><pre style="margin: 0px;"> iDefault++;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> n = Number(aValues[i]);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> j = i + 1;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> sLabel = (j >= aValues.length ? <span style="color: #a31515;">""</span> : Trim(aValues[j]));</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (sLabel != <span style="color: #a31515;">""</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (bEditable)</pre><pre style="margin: 0px;"> _nMax = Math.max(_nMax, n);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> aDupVals.push(n);</pre><pre style="margin: 0px;"> aLabels.push(sLabel);</pre><pre style="margin: 0px;"> oValue.setAttribute(<span style="color: #a31515;">"value"</span>, n);</pre><pre style="margin: 0px;"> oValue.setAttribute(<span style="color: #a31515;">"label"</span>, sLabel);</pre><pre style="margin: 0px;"> oValue.setAttribute(<span style="color: #a31515;">"editable"</span>, bEditable? <span style="color: #a31515;">"1"</span> : <span style="color: #a31515;">"0"</span>);</pre><pre style="margin: 0px;"> oValues.appendChild(oValue);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> iDup = aDupVals.indexOfDuplicate();</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (iDup > -1)</pre><pre style="margin: 0px;"> alertAndThrow(formatString(LOCID_VALUE_NOT_UNIQUE, aDupVals[iDup], aLabels[iDup]));</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> serializeValues(sXml)</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oXmlDoc = CreateXmlDocument();</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oValues = oXmlDoc.createElement(<span style="color: #a31515;">"values"</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> rRegEx = /[\n|\t]/;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> aValues = _aHiddenValues.join(<span style="color: #a31515;">""</span>).split(rRegEx);</pre><pre style="margin: 0px;"> _nMax = 0;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> oXmlDoc.documentElement = oValues;</pre><pre style="margin: 0px;"> appendValues(oXmlDoc, oValues, aValues, <span style="color: blue;">false</span>);</pre><pre style="margin: 0px;"> aValues = getTabbedValues(sXml);</pre><pre style="margin: 0px;"> appendValues(oXmlDoc, oValues, aValues, <span style="color: blue;">true</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (++_nMax > _iMin)</pre><pre style="margin: 0px;"> oValues.setAttribute(<span style="color: #a31515;">"next"</span>, _nMax);</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> oValues.setAttribute(<span style="color: #a31515;">"next"</span>, _iMin);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> oValues.xml;</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> getTabbedValues(sXml)</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> aValues = <span style="color: blue;">new</span> Array();</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (sXml == <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> aValues;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> aLines = sXml.split(/\n/);</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> iVal = _iMin - 1;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> iUserVal = iVal;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = 0; i < aLines.length; i++)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> label = Trim(aLines[i]);</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> bDefault = <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (label.charAt(0) == DEFAULT_ITEM_CHAR)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> label = label.substr(1);</pre><pre style="margin: 0px;"> bDefault = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> aPairs = label.split(/\t/);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (aPairs != <span style="color: blue;">null</span> && aPairs.length > 1)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> iVal = LocStringToInt(aPairs[0]);</pre><pre style="margin: 0px;"> label = aPairs[1];</pre><pre style="margin: 0px;"> iUserVal = Math.max(iVal, iUserVal);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> iVal = Math.max(++iUserVal, ++iVal);</pre><pre style="margin: 0px;"> aValues.push((bDefault ? DEFAULT_ITEM_CHAR : <span style="color: #a31515;">""</span>) + iVal);</pre><pre style="margin: 0px;"> aValues.push(label);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> aValues;</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> deserializeValues(oDataXml)</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oValuesNode = oDataXml.documentElement;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> iValueNode, oValueNode, oValueNodeList;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oValue, aTarget, oAttributes;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> aValues = <span style="color: blue;">new</span> Array();</pre><pre style="margin: 0px;"> _aHiddenValues = <span style="color: blue;">new</span> Array();</pre><pre style="margin: 0px;"> _aSystemValues = <span style="color: blue;">new</span> Array();</pre><pre style="margin: 0px;"> oValueNodeList = oValuesNode.selectNodes(<span style="color: #a31515;">"value"</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oDefault = oValuesNode.attributes.getNamedItem(<span style="color: #a31515;">"default"</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (!IsNull(oDefault))</pre><pre style="margin: 0px;"> _nDefault = Number(oDefault.value);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (iValueNode = 0; iValueNode < oValueNodeList.length; iValueNode++)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> oValueNode = oValueNodeList.item(iValueNode);</pre><pre style="margin: 0px;"> oAttributes = oValueNode.attributes;</pre><pre style="margin: 0px;"> target = (oAttributes.getNamedItem(<span style="color: #a31515;">"editable"</span>).value == <span style="color: #a31515;">'1'</span> ? aValues : _aHiddenValues);</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> n = Number(oAttributes.getNamedItem(<span style="color: #a31515;">"value"</span>).value);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (target == aValues && n < _iMin)</pre><pre style="margin: 0px;"> _aSystemValues.push(n);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (target == aValues && n == _nDefault)</pre><pre style="margin: 0px;"> target.push(DEFAULT_ITEM_CHAR); </pre><pre style="margin: 0px;"> target.push(n);</pre><pre style="margin: 0px;"> target.push(<span style="color: #a31515;">"\t"</span>);</pre><pre style="margin: 0px;"> target.push(oAttributes.getNamedItem(<span style="color: #a31515;">"label"</span>).value);</pre><pre style="margin: 0px;"> target.push(<span style="color: #a31515;">"\n"</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> result = aValues.join(<span style="color: #a31515;">""</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> result;</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> editAllWindowOnLoad()</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (<span style="color: blue;">typeof</span>(txtLabel) != <span style="color: #a31515;">"undefined"</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> Array.prototype.indexOfDuplicate = <span style="color: blue;">function</span>() {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> n = <span style="color: blue;">this</span>.length;</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i=0; i<n; i++)</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">var</span> j=i+1; j<n; j++)</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (<span style="color: blue;">this</span>[i]==<span style="color: blue;">this</span>[j]) <span style="color: blue;">return</span> i;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> -1;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> Array.prototype.contains = <span style="color: blue;">function</span>( value ) {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> n = <span style="color: blue;">this</span>.length;</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i=0; i<n; i++)</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (<span style="color: blue;">this</span>[i]==value) <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oArgs = window.dialogArguments;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> txtLabel.DataValue = oArgs.sText;</pre><pre style="margin: 0px;"> _iMin = oArgs._iMin;</pre><pre style="margin: 0px;"> _iMax = oArgs._iMax;</pre><pre style="margin: 0px;"> _aHiddenValues = oArgs._aHiddenValues;</pre><pre style="margin: 0px;"> _aSystemValues = <span style="color: blue;">new</span> Array();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">for</span>(<span style="color: blue;">var</span> i=0; i<oArgs._aSystemValues.length; i++)</pre><pre style="margin: 0px;"> _aSystemValues.push(oArgs._aSystemValues[i]);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> txtLabel.attachEvent(<span style="color: #a31515;">'onkeydown'</span>, txtLabelOnKeyDown);</pre><pre style="margin: 0px;"> txtLabel.SetFocus();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> txtLabelOnKeyDown()</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (event.keyCode == 9)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (event.srcElement)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> event.srcElement.selection = document.selection.createRange();</pre><pre style="margin: 0px;"> event.srcElement.selection.text = <span style="color: #a31515;">"\t"</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;">window.attachEvent(<span style="color: #a31515;">'onload'</span>, editAllWindowOnLoad);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">function</span> editAll()</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oArgs, oResult;</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> oXmlDoc = CreateXmlDocument(<span style="color: blue;">false</span>);</pre><pre style="margin: 0px;"> oArgs = <span style="color: blue;">new</span> Object();</pre><pre style="margin: 0px;"> oXmlDoc.loadXML(ledtPicklistValues.DataXml);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> _iMin = ((_bIsCustomAttribute + <span style="color: #a31515;">""</span>).toLowerCase() == <span style="color: #a31515;">"true"</span> ? _minValueForCustomPicklists: _minValueForSystemPicklists);</pre><pre style="margin: 0px;"> oArgs.sText = deserializeValues(oXmlDoc);</pre><pre style="margin: 0px;"> oArgs._iMin = _iMin;</pre><pre style="margin: 0px;"> oArgs._iMax = _maxValueForPicklists;</pre><pre style="margin: 0px;"> oArgs._aHiddenValues = _aHiddenValues;</pre><pre style="margin: 0px;"> oArgs._aSystemValues = _aSystemValues;</pre><pre style="margin: 0px;"> oResult = openStdDlg(prependOrgName(<span style="color: #a31515;">"/tools/systemcustomization/attributes/editAll.aspx"</span>), oArgs, 500, 450);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (oResult == <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> ledtPicklistValues.DataXml = oResult.sText;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span>(e)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div><br /><br />The only thing left to do is find the public key token for your assembly. There are various ways to do this, but if you build your assembly now, the post-build events you copied in earlier will publish the assembly to the GAC. If you browse to the GAC folder after you build the solution with windows explorer and find the published assembly, (e.g. C:\WINDOWS\assembly\HubKey.Crm.Web.Tools.SystemCustomization.Attributes), you'll see the public key token there (you can copy this by viewing the properties of the assembly).<br /><br />Back in Visual Studio there are two places you'll need to paste in the key token. Do a search and replace in all files for PUBLICKEYGOESHERE and replace that string with the token string.<br /><br />Build the assembly once more to automatically copy these changes to the right file locations, and you should now see a functioning "Edit All" button on the edit attribute form when you choose picklist as the type from the dropdown. If the build fails because of the the post-build events, try building it one more time (there may be a locked file).<br /><br />To back out the changes you've made, replace the modified manageAttribute.aspx page with the original page that you copied. Remove the assembly, editAll.js file, and editAll.aspx page from the file locations specified in the post-build events.<br /><br />Hopefully this helps to save some time for your entity customizing users. If you have any questions or comments, please post them here.txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com0tag:blogger.com,1999:blog-1705051721030116110.post-11163799084775002062009-01-09T03:48:00.000-08:002009-01-09T04:29:25.649-08:00Copy and Paste CRM Picklist Values - Part IIIn <a href="http://geek.hubkey.com/2009/01/copy-and-paste-crm-picklist-values-part.html">Part I</a>, I posted a screen capture demonstrating customization of the out-of-the-box edit attribute form in Microsoft Dynamics CRM 4.0. A custom "Edit All" button is displayed when a picklist type is selected which enables the editing of multiple picklist value / label pairs at once. The allows copying and pasting of lists from other data sources when setting up picklists - which can be a time saver - especially when setting up many, or large, picklists.<br /><br />In this post I'm going to go over setting up the project that you'll need in order to enable this customization. I'm going to assume familiarity with Visual Studio 20005, C#, ASP.NET, and JavaScript. If you're not comfortable with these technologies, I would recommend either using existing workarounds, for example the online XML generator mentioned <a href="http://blog.customereffective.com/blog/2008/05/large-picklists.html">here</a>, or hiring a CRM consulting firm like <a href="http://www.hubkey.com">HubKey</a> to assist you.<br /><br />To begin, on your CRM development machine, in Visual Studio, create a new C# class library project and call it AttributesPicklistEditAll. You'll need to add references to the following four Microsoft Dynamics CRM DLLs from your server root folder (e.g. C:\Program Files\Microsoft Dynamics CRM Server) - all paths below will be relative to this root:<br /><br />\Tools\Microsoft.Crm.dll<br />\CRMWeb\bin\Microsoft.Crm.Application.Components.Application.dll<br />\CRMWeb\bin\Microsoft.Crm.Application.Components.UI.dll<br />\CRMWeb\bin\Microsoft.Crm.Application.Pages.dll<br /><br />Add a fifth reference to System.Web. (You won't be needing the reference to System.Xml or System.Data).<br /><br />We're going to be making a change to the default manageAttribute.aspx page so that a new Edit All button is rendered for picklist types. Make a backup of that file, which is in the following location:<br /><br />\CRMWeb\Tools\SystemCustomization\Attributes\manageAttribute.aspx<br /><br />and then add the file as an existing item to your project in Visual Studio.<br /><br />Once you've added it in Visual Studio, copy it and rename the copy to editAll.aspx<br />This will be the popup dialog that opens when the Edit All button is clicked. Open the renamed file (editAll.aspx) and remove all of the text.<br /><br />Rename the default project file class1.cs to EditAll.cs<br /><br />Add a new item to your project - a JScript file called editAll.js<br /><br />In the project properties / signing tab, make sure that the assembly to be generated is signed by a strong name key file (e.g. key(.snk)). On the application tab, change the assembly name and default namespace to HubKey.Crm.Web.Tools.SystemCustomization.Attributes<br /><br />On the project properties / build events tab add the following post-build event commands (assuming here that your server root is "C:\Program Files\Microsoft Dynamics CRM Server") - these commands reset IIS, make a copy of your original manageAttribute.aspx if you haven't already done so, copy (overwriting) the aspx pages and js file to the necessary locations, and then copy the assembly to the GAC:<br /><br /><div class="code">call iisreset<br /><br />if not exist "C:\Program Files\Microsoft Dynamics CRM Server\CRMWeb\Tools\SystemCustomization\Attributes\manageAttribute.aspx.orig" copy "C:\Program Files\Microsoft Dynamics CRM Server\CRMWeb\Tools\SystemCustomization\Attributes\manageAttribute.aspx" "C:\Program Files\Microsoft Dynamics CRM Server\CRMWeb\Tools\SystemCustomization\Attributes\manageAttribute.aspx.orig" <br /><br />xcopy "$(ProjectDir)*.aspx" "C:\Program Files\Microsoft Dynamics CRM Server\CRMWeb\Tools\SystemCustomization\Attributes" /D /I /Y<br />xcopy "$(ProjectDir)*.js" "C:\Program Files\Microsoft Dynamics CRM Server\CRMWeb\_static\Tools\SystemCustomization\attributes\scripts" /D /I /Y<br /><br />"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /U "$(TargetPath)"<br />"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /F /I "$(TargetPath)"<br /></div><br /><br />You should end up with a solution window that looks like the following:<br /><br /><img src="http://www.hubkey.com/images/editAllSolution.jpg" alt="Long Running Job Status Page"><br /><br />In Part III I'll go over the code that you'll need to support this project.txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com1tag:blogger.com,1999:blog-1705051721030116110.post-22477071436918471152009-01-05T10:02:00.000-08:002009-01-05T10:07:10.614-08:00Copy and Paste CRM Picklist Values - Part IThe web based GUI for MS CRM 4.0 offers essentially the same user interface to edit picklist attribute values as version 3. There's a tidy web form with all the buttons you'd expect in order to manage individual values (add, edit, delete, etc.), but if you want to add a range of values, say copy and paste them from an Excel spreadsheet, you'll be forced either to add them one-at-a-time, or to use one of the tools out there to generate xml to paste into the right place in your entity definition. <br /><br />There is a very nice web based <a href="http://www.beatnik.at/picklist_for_mscrm.php">tool</a> to help you do just that, but unfortunately anyone creating new entities or customizing existing ones will have to be comfortable manually editing those xml entity files - not something everyone may be happy to do. <br /><br />The screen capture below demonstrates an alternative: customizing the edit attribute form to add an "edit all" button that allows multiple picklist value / label pairs to be edited and copied at once. In this example, I'm setting up an entity to manage NAICS codes. Rather than having to enter the 20 economic sector codes one-by-one, I can simply copy and paste the value / labels pairs from a spreadsheet.<br /><br />In follow up posts to this one, I'll go over the details of how to set this up. This will involve creating a new aspx page and writing code to do the behind the scenes work.<br /><br /><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash /swflash.cab#version=6,0,29,0" width="665" height="499"><br /><param name="movie" value="http://www.hubkey.com/media/editallsm.swf"><br /><param name="quality" value="high"><br /><embed src="http://www.hubkey.com/media/editallsm.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="665" height="499"></embed></object>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com2tag:blogger.com,1999:blog-1705051721030116110.post-33353368513348746822008-12-22T13:35:00.000-08:002008-12-24T06:00:39.309-08:00Get Distinct Lookup ValuesHere's another code example using <a href="http://geek.hubkey.com/2008/11/sharepoint-api-client-side-object-model.html">HubKey's Client-side API for SharePoint</a>. In this case 2 lists are created, a document library and a generic list. A lookup field (Subject) is added to the document library which looks up values in the Title column on the second list. The example also demonstrates getting distinct rows (in this case lookup values) by using the <a href="http://msdn.microsoft.com/en-us/library/a8ycds2f.aspx">DataView.ToTable()</a> method.<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Text;</pre><pre style="margin: 0px;"><span style="color: green;">// using HubKey's Remote SharePoint API instead of the native object model so we can update a remote server</span></pre><pre style="margin: 0px;"><span style="color: blue;">using</span> HubKey.Web.Services.SharePoint;</pre><pre style="margin: 0px;"><span style="color: green;">//using Microsoft.SharePoint;</span></pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Data;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> DevHoleDemo</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">//always use a test server and site with this beta API</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPWeb</span> web = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPSite</span>(<span style="color: #a31515;">"http://remoteserver/testsite001/"</span>).OpenWeb();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Guid</span> subjectsListId = web.Lists.Add(<span style="color: #a31515;">"HubKey Subjects"</span>, <span style="color: #a31515;">"A temporary list."</span>, <span style="color: #2b91af;">SPListTemplateType</span>.GenericList);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPList</span> subjectsList = web.Lists[subjectsListId];</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// note that using the SPList.Items property here with the HubKey API returns all the items in the list</span></pre><pre style="margin: 0px;"> <span style="color: green;">// which can be expensive if the list contains many items already. See the following code example for a </span></pre><pre style="margin: 0px;"> <span style="color: green;">// better way to add items to a list specific to the HubKey API:</span></pre><pre style="margin: 0px;"> <span style="color: green;">// http://www.hubkey.com/Documents/HubKeySPAPI/html/60759825-9963-20e4-c31e-ae93ea608330.htm</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPListItemCollection</span> subjects = subjectsList.Items;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPListItem</span> item1 = subjects.Add();</pre><pre style="margin: 0px;"> item1[<span style="color: #a31515;">"Title"</span>] = <span style="color: #a31515;">"SharePoint"</span>;</pre><pre style="margin: 0px;"> item1.Update();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPListItem</span> item2 = subjects.Add();</pre><pre style="margin: 0px;"> item2[<span style="color: #a31515;">"Title"</span>] = <span style="color: #a31515;">"Microsoft CRM"</span>;</pre><pre style="margin: 0px;"> item2.Update();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPListItem</span> item3 = subjects.Add();</pre><pre style="margin: 0px;"> item3[<span style="color: #a31515;">"Title"</span>] = <span style="color: #a31515;">"Microsoft CRM"</span>;</pre><pre style="margin: 0px;"> item3.Update();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Guid</span> booksDocLibId = web.Lists.Add(<span style="color: #a31515;">"HubKey Books"</span>, <span style="color: #a31515;">"A temporary document library."</span>, <span style="color: #2b91af;">SPListTemplateType</span>.DocumentLibrary);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPList</span> booksDocLib = web.Lists[booksDocLibId];</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> booksDocLib.Fields.AddLookup(<span style="color: #a31515;">"Subject"</span>, subjectsListId, <span style="color: blue;">false</span>);</pre><pre style="margin: 0px;"> booksDocLib.Update();</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFieldLookup</span> subjectLookup = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPFieldLookup</span>(booksDocLib.Fields, <span style="color: #a31515;">"Subject"</span>);</pre><pre style="margin: 0px;"> subjectLookup.LookupField = <span style="color: #a31515;">"Title"</span>;</pre><pre style="margin: 0px;"> subjectLookup.Update();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// build the query to get a list of subjects</span></pre><pre style="margin: 0px;"> <span style="color: green;">// (pretend we are starting from scratch)</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFieldLookup</span> subjectLookup2 = (<span style="color: #2b91af;">SPFieldLookup</span>)booksDocLib.Fields[<span style="color: #a31515;">"Subject"</span>];</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPList</span> subjectsList2 = web.Lists[<span style="color: blue;">new</span> <span style="color: #2b91af;">Guid</span>(subjectLookup2.LookupList)];</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPQuery</span> query = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPQuery</span>();</pre><pre style="margin: 0px;"> query.ViewFields = <span style="color: #a31515;">"<FieldRef Name='"</span> + subjectLookup2.LookupField + <span style="color: #a31515;">"'/>"</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// here we use a data table so that we can get distinct titles (subjects)</span></pre><pre style="margin: 0px;"> <span style="color: green;">// if you're not woried about distinct values you could ignore this, but it's</span></pre><pre style="margin: 0px;"> <span style="color: green;">// also a convenient way to query the list items (e.g. see the RowFilter below)</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">DataTable</span> subjectsTable = subjectsList2.GetItems(query).GetDataTable();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">DataView</span> dataView = <span style="color: blue;">new</span> <span style="color: #2b91af;">DataView</span>(subjectsTable);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">DataTable</span> groupedSubjectsTable = dataView.ToTable(<span style="color: blue;">true</span>, <span style="color: #a31515;">"Title"</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFieldLookupValue</span> lookupValue = <span style="color: blue;">null</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// here we're looping through 2 distinct title rows ('SharePoint' and 'Microsoft CRM')</span></pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">DataRow</span> row <span style="color: blue;">in</span> groupedSubjectsTable.Rows)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> title = (<span style="color: blue;">string</span>)row[0];</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// get the ID of the first row that matches the title</span></pre><pre style="margin: 0px;"> dataView.RowFilter = <span style="color: #a31515;">"Title = '"</span> + title + <span style="color: #a31515;">"'"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">int</span> firstId = (<span style="color: blue;">int</span>)dataView.ToTable(<span style="color: blue;">true</span>, <span style="color: #a31515;">"ID"</span>).Rows[0][0];</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// create a new lookup value (we'll use the 2nd row's lookupValue below)</span></pre><pre style="margin: 0px;"> lookupValue = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPFieldLookupValue</span>(<span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"{0};#{1}"</span>, firstId, title));</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFile</span> file = booksDocLib.RootFolder.Files.Add(<span style="color: #a31515;">"test.txt"</span>, <span style="color: #2b91af;">Encoding</span>.ASCII.GetBytes(<span style="color: #a31515;">"A test document."</span>));</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// update the subject with the 2nd lookup value;</span></pre><pre style="margin: 0px;"> file.Item[<span style="color: #a31515;">"Subject"</span>] = lookupValue;</pre><pre style="margin: 0px;"> file.Item.Update();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// clean up - pause here if you want to view the results on the server.</span></pre><pre style="margin: 0px;"> subjectsList.Delete();</pre><pre style="margin: 0px;"> booksDocLib.Delete();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com0tag:blogger.com,1999:blog-1705051721030116110.post-3479569495090610002008-11-26T09:17:00.000-08:002010-06-14T12:57:27.795-07:00SharePoint API: A Client-side Object ModelOne <a href="http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/5834679b-482b-4924-b881-fa2146840d05/">common issue</a> (see question #2) that developers using Microsoft's SharePoint platform are faced with is that the SharePoint object model can only be used when the application is run on a server in the SharePoint farm.<br /><br />The following is code that demonstrates using HubKey's <a href="http://www.hubkey.com/hubkeyspapi.aspx">Client-side API for SharePoint</a>. This API wraps many of SharePoint Server 2007's <a href="http://msdn.microsoft.com/en-us/library/cc752745.aspx">Web Services</a> (Lists Web Service, Webs Web Service, etc.) to provide a familiar object model that can be used on remote client machines without having to process XML requests and responses. In this case the code from the MSDN article <a href="http://msdn.microsoft.com/en-us/library/ms454491.aspx">How to: Upload a File to a SharePoint Site from a Local Folder</a> was copied verbatim, and it compiles and runs successfully on a client computer, even though the SharePoint DLLs are not referenced or installed.<br /><br /><span style="COLOR: red; ">Update:</span> You can download a demo copy of the API - click <a href="http://www.hubkey.com/sharepointapi.aspx">here</a> for information. <br /><br /><span style="COLOR: red; ">Update II:</span> The API now includes a demo application - see <a href="http://geek.hubkey.com/2009/02/sharepoint-api-client-side-object-model.html">this</a> post for details.<br /><br /><br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.IO;</pre><pre style="margin: 0px;"><span style="color: green;">// Using HubKey.Web.Services.SharePoint in place of Microsoft.SharePoint</span></pre><pre style="margin: 0px;"><span style="color: blue;">using</span> HubKey.Web.Services.SharePoint;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> HubKey.DevelopmentHole</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Program</span> program = <span style="color: blue;">new</span> <span style="color: #2b91af;">Program</span>();</pre><pre style="margin: 0px;"> program.RunDemo();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> RunDemo()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> webUrl = <span style="color: #a31515;">"http://remoteserver"</span>;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPSite</span> site = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPSite</span>(webUrl);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPWeb</span> web = site.OpenWeb();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//create a new document library</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Guid</span> id = web.Lists.Add(<span style="color: #a31515;">"Temp Doc Lib"</span>, <span style="color: #a31515;">"A temp document library."</span>, <span style="color: #2b91af;">SPListTemplateType</span>.DocumentLibrary);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPList</span> list = web.Lists[id];</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//add a field</span></pre><pre style="margin: 0px;"> list.Fields.Add(<span style="color: #a31515;">"Upload Source"</span>, <span style="color: #2b91af;">SPFieldType</span>.Text, <span style="color: blue;">false</span>);</pre><pre style="margin: 0px;"> list.Update();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> fileUrl = webUrl + <span style="color: #a31515;">"/Temp Doc Lib/New Folder/test.txt"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> localFileName = <span style="color: #a31515;">@"D:\Temp\test.txt"</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> localFileContents = <span style="color: #a31515;">"A temp file uploaded by HubKey's SharePoint client-side API."</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">File</span>.WriteAllText(localFileName, localFileContents);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//Upload the file using the API code from 'How to: Upload a File to a SharePoint Site from a Local Folder'</span></pre><pre style="margin: 0px;"> <span style="color: green;">//see http://msdn.microsoft.com/en-us/library/ms454491.aspx</span></pre><pre style="margin: 0px;"> UploadFile(localFileName, fileUrl);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//Check out</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFile</span> file = web.GetFile(fileUrl);</pre><pre style="margin: 0px;"> file.CheckOut();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//update the title and new upload source field by using the file's SPListItem property...</span></pre><pre style="margin: 0px;"> file.Item[<span style="color: #a31515;">"Title"</span>] = <span style="color: #a31515;">"A temp title"</span>;</pre><pre style="margin: 0px;"> file.Item[<span style="color: #a31515;">"Upload Source"</span>] = <span style="color: #a31515;">"HubKey's SharePoint client-side API."</span>;</pre><pre style="margin: 0px;"> file.Item.Update();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//Check in</span></pre><pre style="margin: 0px;"> file.CheckIn(<span style="color: #a31515;">"Checked in by HubKey's SharePoint client-side API"</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//Get the file contents</span></pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> serverFileContents = web.GetFileAsString(fileUrl);</pre><pre style="margin: 0px;"> System.Diagnostics.<span style="color: #2b91af;">Debug</span>.Assert(<span style="color: blue;">string</span>.Equals(localFileContents, serverFileContents));</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//Tidy up</span></pre><pre style="margin: 0px;"> list.Delete();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> UploadFile(<span style="color: blue;">string</span> srcUrl, <span style="color: blue;">string</span> destUrl)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (!<span style="color: #2b91af;">File</span>.Exists(srcUrl))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">ArgumentException</span>(<span style="color: #2b91af;">String</span>.Format(<span style="color: #a31515;">"{0} does not exist"</span>,</pre><pre style="margin: 0px;"> srcUrl), <span style="color: #a31515;">"srcUrl"</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPWeb</span> site = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPSite</span>(destUrl).OpenWeb();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">FileStream</span> fStream = <span style="color: #2b91af;">File</span>.OpenRead(srcUrl);</pre><pre style="margin: 0px;"> <span style="color: blue;">byte</span>[] contents = <span style="color: blue;">new</span> <span style="color: blue;">byte</span>[fStream.Length];</pre><pre style="margin: 0px;"> fStream.Read(contents, 0, (<span style="color: blue;">int</span>)fStream.Length);</pre><pre style="margin: 0px;"> fStream.Close();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> EnsureParentFolder(site, destUrl);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFile</span> file = site.Files.Add(destUrl, contents);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFolder</span> folder = file.ParentFolder;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> EnsureParentFolder(<span style="color: #2b91af;">SPWeb</span> parentSite, <span style="color: blue;">string</span> destinUrl)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> destinUrl = parentSite.GetFile(destinUrl).Url;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">int</span> index = destinUrl.LastIndexOf(<span style="color: #a31515;">"/"</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> parentFolderUrl = <span style="color: blue;">string</span>.Empty;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (index > -1)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> parentFolderUrl = destinUrl.Substring(0, index);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFolder</span> parentFolder</pre><pre style="margin: 0px;"> = parentSite.GetFolder(parentFolderUrl);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (!parentFolder.Exists)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFolder</span> currentFolder = parentSite.RootFolder;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> folder <span style="color: blue;">in</span> parentFolderUrl.Split(<span style="color: #a31515;">'/'</span>))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> currentFolder = currentFolder.SubFolders.Add(folder);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> parentFolderUrl;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com12tag:blogger.com,1999:blog-1705051721030116110.post-18138275777147535252008-11-18T09:16:00.000-08:002009-01-02T16:04:18.958-08:00Get a Valid SharePoint File Or Folder NameIf you're programatically uploading files to a SharePoint document library or creating folders, the file or folder name must not contain certain invalid characters. If it does, you'll get an error, for example:<br /><br /><i>The file or folder name ".." contains invalid characters. Please use a different name. Invalid characters include the following: ~ " # % & * : < > ? / \ { | }. The name cannot begin or end with dot and cannot contains consecutive dots.</i><br /><br />File or folder names must also be less than or equal to 128 characters in length. In addition, the total unescaped URL length (less the length of the URI authority e.g. http://localhost:2008/) must not exceed 260 characters.<br /><br />The following code uses a regular expression to validate a file or folder name before it is uploaded or created (without checking the total URL length):<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Web;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Text.RegularExpressions;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> DevHoleDemo</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: #2b91af;">Regex</span> illegalPathChars = <span style="color: blue;">new</span> <span style="color: #2b91af;">Regex</span>(<span style="color: #a31515;">@"^\.|[\x00-\x1F,\x7B-\x9F,"",#,%,&,*,/,:,<,>,?,\\]+|(\.\.)+|\.$"</span>, <span style="color: #2b91af;">RegexOptions</span>.Compiled);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> fileName = <span style="color: #a31515;">"/new%20file.txt"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> validFileName = fileName;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (GetValidFileOrFolderName(<span style="color: blue;">ref</span> validFileName))</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"A valid file or folder name for '{0}' is '{1}'."</span>, fileName, validFileName);</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"Could not get a valid file or folder name."</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> GetValidFileOrFolderName(<span style="color: blue;">ref</span> <span style="color: blue;">string</span> path)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> GetValidFileOrFolderName(<span style="color: blue;">ref</span> path, <span style="color: #a31515;">'_'</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> GetValidFileOrFolderName(<span style="color: blue;">ref</span> <span style="color: blue;">string</span> path, <span style="color: blue;">char</span> replacementChar)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (path == <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> path = illegalPathChars.Replace(HttpUtility.UrlDecode(path.Trim()), replacementChar.ToString());</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (path.Length > 128)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> path = path.Substring(0, 128);</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> GetValidFileOrFolderName(<span style="color: blue;">ref</span> path, replacementChar);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> path.Length > 0;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com2tag:blogger.com,1999:blog-1705051721030116110.post-89858923053817163062008-07-03T00:10:00.000-07:002009-05-20T10:19:24.607-07:00Programatically Manage Remote Documents with the FrontPage RPC LibraryWe've rolled up some of the ideas in previous <a href="http://geek.hubkey.com/2008/02/delete-sharepoint-document-library.html">posts</a> about FrontPage Server Extensions RPC methods into a free <a href="http://creativecommons.org/licenses/by-nc-sa/3.0">CC</a> licensed c# code library. <br /><br />You can download the source code along with a demo copy of HubKey's <a href="http://geek.hubkey.com/2008/11/sharepoint-api-client-side-object-model.html">SharePoint Client API</a> from HubKey's website - click <a href="http://www.hubkey.com/sharepointapi.aspx">here</a> for details. <br /><br />Documentation about the members exposed through the HubKey.Net.FrontPageRPC.WebClient class can be found online <a href="http://www.hubkey.com/frontpagerpcdocs.aspx">here.</a><br /><br />Features of the class include:<br /><br /><ul><br /><li>Upload or download many documents in one web request using the 'get documents' and 'put documents' methods.</li><br /><li>True file streaming (without pre-loading to memory) for faster uploads.</li><br /><li>Asynchronous methods including an asynchronous MoveDocuments method.</li><br /><li>Auto detection of FrontPage dll paths and versions.</li><br /></ul><br /><br />The following FrontPage Server Extensions RPC Methods are included in the library:<br /><br /><ul><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms439083.aspx">checkin document method</a> - remotely check-in a document to source control.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms437509.aspx">checkout document method</a> - remotely check-out a document from source control.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms457496.aspx">getDocsMetaInfo method</a> - download document metadata to a client machine.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms442345.aspx">get document method</a> - remotely download a document with metadata from a web folder or SharePoint document library. Includes an asynchronous method.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms454100.aspx">get documents method</a> - programatically download documents with metadata from a web folder or SharePoint document library in one web request. Includes an asynchronous method.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms442283.aspx">list documents method</a> - obtains a list of files and folders on the web or SharePoint server. Sorts the results into a tree structure to allow for use in a TreeView control.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms457549.aspx">list versions method</a> - retrieves metadata for all the versions of the specified document.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms440627.aspx">move document method</a> - programatically move (rename) or copy a file or folder. Allows for moves between webs or even servers by downloading and then uploading the file.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms446353.aspx">open service method</a> - list service meta information.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms479623.aspx">put document method</a> - programatically upload a file to a SharePoint document library or web server with meta info. Includes an asynchronous method.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms443219.aspx">put documents method</a> - remotely upload files to a SharePoint document library or web server with meta info. Includes a method to asynchronously upload large files. Allows true streaming (without loading into memory first) for large file uploads.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms428863.aspx">remove documents method</a> - delete files or folders from a SharePoint document library or web server.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms468563.aspx">setDocsMetaInfo method</a> - update document meta data from a client computer.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms438029.aspx">uncheckout document method</a> - revert a document to the version before it was checked out.</li><br /><li><a href="http://msdn.microsoft.com/en-us/library/ms460544.aspx">url to web url method</a> - break a url into its web and web relative components.</li><br /></ul><br /><br />A very brief code example follows - we'll cover an in depth sample application in a future post:<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Text;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> HubKey.Net.FrontPageRPC</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WebClient</span> webClient = <span style="color: blue;">new</span> <span style="color: #2b91af;">WebClient</span>();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//upload a document and check it in</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">MetaInfoCollection</span> meta = <span style="color: blue;">new</span> <span style="color: #2b91af;">MetaInfoCollection</span>();</pre><pre style="margin: 0px;"> meta.Add(<span style="color: #a31515;">"vti_title"</span>, <span style="color: #a31515;">"My Title"</span>);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">UploadDocumentResponse</span> uploadDocumentResponse = webClient.UploadDocument(<span style="color: #a31515;">"https://localhost/Docs1/test.txt"</span>, <span style="color: #a31515;">@"C:\test.txt"</span>, meta);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (uploadDocumentResponse.Document.IsCheckedOut)</pre><pre style="margin: 0px;"> webClient.CheckInDocument(uploadDocumentResponse.Document, <span style="color: #a31515;">"uploaded via RPC"</span>);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">//move a document between servers</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">MoveDocumentResponse</span> moveDocumentResponse = webClient.MoveDocument(<span style="color: #a31515;">"http://localhost/Docs2/test.txt"</span>, <span style="color: #a31515;">"https://remoteserver/Docs2/test.txt"</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com38tag:blogger.com,1999:blog-1705051721030116110.post-67792255810653222322008-05-21T09:40:00.000-07:002009-01-02T16:05:57.851-08:00Logging Workflow Errors in the Workflow History ListBy overriding the HandleFault method and using the SPWorkflowActivationProperties.Workflow.CreateHistoryEvent method, it's possible to write unhandled exceptions (without much coding overhead) to the history log to assist in debugging long running workflows. <br /><br />The code at the bottom of this post demonstrates the idea. A potential issue is that the description field of the workflow history view displayed at the bottom of the workflow status page will be truncated if it's longer that 255 characters - making it not ideal to show long exception messages and/or stack traces. One solution is to modify the code the WrkStat.aspx page to display a link to the workflow history list item, for example by adding the following code to override the ViewFields used by the idHistoryView ListViewByQuery (near the very bottom of the page), so that a link to the item (in this case a DocIcon field) is displayed. Alternatively, you could code a url into the description, but that would require information about the workflow history item (ID, etc) that's not available by using the CreateHistoryEvent method.<br /><br /><font size="2"> <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="BACKGROUND: yellow"><%</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> if (this.idHistoryView.Visible == true)</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> this.idHistoryView.Query.ViewFields = "<FieldRef Name=\"Occurred\" /><FieldRef Name=\"Event\" /><FieldRef Name=\"User\" /><FieldRef Name=\"DocIcon\" /><FieldRef Name=\"Description\" /><FieldRef Name=\"Outcome\" />";</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="BACKGROUND: yellow">%></span></span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue"><</span><span style="COLOR: #a31515">SharePoint</span><span style="COLOR: blue">:</span><span style="COLOR: #a31515">ListViewByQuery</span> <br /><span style="COLOR: red">runat</span><span style="COLOR: blue">="server"</span> <span style="COLOR: red">DisableSort</span><span style="COLOR: blue">="true"</span> <span style="COLOR: red">DisableFilter</span><span style="COLOR: blue">="true"</span> <span style="COLOR: red">ID</span><span style="COLOR: blue">="idHistoryView"</span> <span style="COLOR: blue">/></span><font face="Calibri"> </font></span></span></font><br /><br />...<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Text;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Text.RegularExpressions;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Workflow.Activities;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Workflow.ComponentModel;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.SharePoint.Workflow;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> HubKey.DevelopmentHole</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">sealed</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MyWorkflow</span>: <span style="color: #2b91af;">SequentialWorkflowActivity</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">//assign workflowProperties in the OnWorkflowActivated activity</span></pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">SPWorkflowActivationProperties</span> workflowProperties = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPWorkflowActivationProperties</span>();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: #2b91af;">ActivityExecutionStatus</span> HandleFault(<span style="color: #2b91af;">ActivityExecutionContext</span> executionContext, <span style="color: #2b91af;">Exception</span> exception)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> workflowProperties.Workflow.CreateHistoryEvent(</pre><pre style="margin: 0px;"> (<span style="color: blue;">int</span>)<span style="color: #2b91af;">SPWorkflowHistoryEventType</span>.WorkflowError,</pre><pre style="margin: 0px;"> 0,</pre><pre style="margin: 0px;"> workflowProperties.OriginatorUser,</pre><pre style="margin: 0px;"> <span style="color: #a31515;">"Nothing good"</span>,</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"An exception occured during activity {0}. Check the item data for more information."</span>, executionContext.Activity.Name),</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Misc</span>.FormatException(exception));</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> { }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">base</span>.HandleFault(executionContext, exception);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Misc</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: #2b91af;">Regex</span> stackRegex = <span style="color: blue;">new</span> <span style="color: #2b91af;">Regex</span>(<span style="color: #a31515;">@"\r\n at "</span>, <span style="color: #2b91af;">RegexOptions</span>.Compiled);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> FormatException(<span style="color: #2b91af;">Exception</span> ex)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> FormatException(ex, <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>(), 0);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> FormatException(<span style="color: #2b91af;">Exception</span> ex, <span style="color: #2b91af;">StringBuilder</span> sb, <span style="color: blue;">int</span> tab)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (ex == <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> sb.ToString();</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> sTab = <span style="color: blue;">new</span> <span style="color: blue;">string</span>(<span style="color: #a31515;">'\t'</span>, tab);</pre><pre style="margin: 0px;"> sb.AppendFormat(<span style="color: #a31515;">"{0}Source: {1}\r\n"</span>, sTab, ex.Source);</pre><pre style="margin: 0px;"> sb.AppendFormat(<span style="color: #a31515;">"{0}Message: {1}\r\n"</span>, sTab, ex.Message);</pre><pre style="margin: 0px;"> sb.AppendFormat(<span style="color: #a31515;">"{0}StackTrace: {1}\r\n"</span>, sTab, FormatStackTrace(ex, sTab));</pre><pre style="margin: 0px;"> sb.AppendLine();</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> FormatException(ex.InnerException, sb, ++tab);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> FormatStackTrace(<span style="color: #2b91af;">Exception</span> ex, <span style="color: blue;">string</span> sTab)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> stack = ex.StackTrace;</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (stack == <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">null</span>;</pre><pre style="margin: 0px;"> stack = stackRegex.Replace(ex.StackTrace, <span style="color: blue;">delegate</span>(<span style="color: #2b91af;">Match</span> m)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"\r\n{0} at "</span>, sTab);</pre><pre style="margin: 0px;"> });</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> stack;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com3tag:blogger.com,1999:blog-1705051721030116110.post-15211829699411818852008-03-17T10:13:00.000-07:002009-01-02T16:07:43.294-08:00Provide Status Updates for Long Running Operation Jobs - Part IIFollowing on from <a href="http://geek.hubkey.com/2007/11/provide-status-updates-for-long-running.html">Part I</a> that showed a simple way to give users some feedback on the progress status of long running jobs - here is the same code, this time running in an .aspx page. To run ASP.NET server side code you'll need to add a PageParserPath node to your web.config as covered <a href="http://weblogs.asp.net/soever/archive/2006/07/27/SharePoint-2007_3A00_-using-ASP.NET-server-side-code-in-your-pages.aspx">here</a>.<br /><br />As <a href="http://geek.hubkey.com/2007/11/provide-status-updates-for-long-running.html">before</a>, make sure that your site collection includes a list named 'Long Running Operation Status' at the root web. This list is created when you install the Office SharePoint Server Publishing Infrastructure feature at the Site Collection Features level.<br /><br /><div class="code"><br /><span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'"><%</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">@</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #a31515">Page</span> <span style="COLOR: red">language</span><span style="COLOR: blue">="C#"</span> <span style="COLOR: red">MasterPageFile</span><span style="COLOR: blue">="~masterurl/default.master"</span> <span style="COLOR: red">Inherits</span><span style="COLOR: blue">="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"</span> <span style="COLOR: #a31515">meta</span><span style="COLOR: blue">:</span><span style="COLOR: red">progid</span><span style="COLOR: blue">="SharePoint.WebPartPage.Document"</span> <span style="BACKGROUND: yellow">%></span><br /><span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'"><%</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">@</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #a31515">Assembly</span> <span style="COLOR: red">Name</span><span style="COLOR: blue">="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"</span><span style="BACKGROUND: yellow">%></span><br /><span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'"><%</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">@</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #a31515">Import</span> <span style="COLOR: red">Namespace</span><span style="COLOR: blue">="Microsoft.SharePoint"</span> <span style="BACKGROUND: yellow">%></span> </span><br /><span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'"><%</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">@</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #a31515">Import</span> <span style="COLOR: red">Namespace</span><span style="COLOR: blue">="Microsoft.SharePoint.Publishing"</span> <span style="BACKGROUND: yellow">%></span> </span><br /><span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'"><%</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">@</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #a31515">Import</span> <span style="COLOR: red">Namespace</span><span style="COLOR: blue">="Microsoft.SharePoint.Publishing.Internal"</span> <span style="BACKGROUND: yellow">%></span> </span><br /><span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'"><%</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">@</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #a31515">Import</span> <span style="COLOR: red">Namespace</span><span style="COLOR: blue">="Microsoft.SharePoint.Utilities"</span> <span style="BACKGROUND: yellow">%></span> </span><br /><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"><</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">script</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: red">runat</span><span style="COLOR: blue">="server"></span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">const</span> <span style="COLOR: blue">string</span> PROGRESS_PAGE_URL = <span style="COLOR: #a31515">"/_layouts/LongRunningOperationProgress.aspx"</span>;</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> </span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">public</span> <span style="COLOR: blue">void</span> StartJob(<span style="COLOR: blue">object</span> sender, System.<span style="COLOR: #2b91af">EventArgs</span> e)</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #2b91af">SPWeb</span> web = <span style="COLOR: #2b91af">SPContext</span>.GetContext(<span style="COLOR: blue">this</span>.Context).Web;</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #2b91af">LongRunningJob</span> longRunningJob = <span style="COLOR: blue">new</span> <span style="COLOR: #2b91af">LongRunningJob</span>();</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> longRunningJob.Title = <span style="COLOR: #a31515">"Demo Long Running Job"</span>;</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> longRunningJob.TotalOperationsToBePerformed = 15;</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> longRunningJob.RedirectWhenFinished = <span style="COLOR: blue">true</span>;</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> longRunningJob.NavigateWhenDoneUrl = <span style="COLOR: #2b91af">SPContext</span>.GetContext(<span style="COLOR: blue">this</span>.Context).List.RootFolder.ServerRelativeUrl;</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> longRunningJob.Start(web);</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">string</span> url = <span style="COLOR: blue">string</span>.Format(<span style="COLOR: #a31515">"{0}{1}?JobId={2}"</span>, web.Url, PROGRESS_PAGE_URL, longRunningJob.JobId);</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: #2b91af">SPUtility</span>.Redirect(url, <span style="COLOR: #2b91af">SPRedirectFlags</span>.Default, <span style="COLOR: blue">this</span>.Context);</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> </span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">class</span> <span style="COLOR: #2b91af">LongRunningJob</span> : <span style="COLOR: #2b91af">LongRunningOperationJob</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">public</span> <span style="COLOR: blue">override</span> <span style="COLOR: blue">void</span> DoWork()</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">for</span> (<span style="COLOR: blue">this</span>.OperationsPerformed = 0; <span style="COLOR: blue">this</span>.OperationsPerformed < <span style="COLOR: blue">this</span>.TotalOperationsToBePerformed; <span style="COLOR: blue">this</span>.OperationsPerformed++)</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> {</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: green">//Do your work here</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">this</span>.StatusDescription = <span style="COLOR: blue">string</span>.Format(<span style="COLOR: #a31515">"im in ur long running job, doing ur work {0} of {1}..."</span>, <span style="COLOR: blue">this</span>.OperationsPerformed, <span style="COLOR: blue">this</span>.TotalOperationsToBePerformed);</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: blue">this</span>.UpdateStatus();</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> System.Threading.<span style="COLOR: #2b91af">Thread</span>.Sleep(1000);</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span><br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> }</span><br /><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"></</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">script</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">></span><br /><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"><</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">asp</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">:</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Content</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: red">ID</span><span style="COLOR: blue">="Content1"</span> <span style="COLOR: red">ContentPlaceHolderId</span><span style="COLOR: blue">="PlaceHolderMain"</span> <span style="COLOR: red">runat</span><span style="COLOR: blue">="server"></span><br /><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"><</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">asp</span><span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">:</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">Button</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> <span style="COLOR: red">runat</span><span style="COLOR: blue">="server"</span> <span style="COLOR: red">OnClick</span><span style="COLOR: blue">="StartJob"</span> <span style="COLOR: red">Text</span><span style="COLOR: blue">="Start Job"</span> <span style="COLOR: red">id</span><span style="COLOR: blue">="Button1"/></span><p><span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'"></</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'">asp</span><span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'">:</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'">Content</span><span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'">></span> </span></span></span></span></span></span></span><br /></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com6tag:blogger.com,1999:blog-1705051721030116110.post-23508608422905838742008-02-28T08:38:00.000-08:002009-01-02T16:09:29.877-08:00Impersonating a Built-in Service Account in a Console ApplicationHere's a quick way to impersonate a built-in service account (NT AUTHORITY\NETWORK SERVICE or NT AUTHORITY\LOCAL SERVICE) or for that matter the Local System account (NT AUTHORITY\SYSTEM) in a console application. This might be useful for debugging or testing permissions etc. - the default application pool identity for SharePoint virtual servers is the Network Service account.<br /><br />The trick is to run your code as Local System and from there you can impersonate the service accounts by using the appropriate username with no password. One way to run your code as the Local System account is to create a command line shell by using the technique shown below (taken from <a href="http://blogs.msdn.com/adioltean/articles/271063.aspx">this</a> orginal post), and execute your assembly from there. Calling System.Diagnostics.Debugger.Break() in your code allows you to debug.<br /><br />To create a command-line shell that runs under the local system account, open a new command line window and enter:<br /><br /><div style="font-family: Courier New;">c:\sc create testsvc binpath= "cmd /K start" type= own type= interact</div><br /><br />followed by:<br /><br /><div style="font-family: Courier New;">c:\sc start testsvc</div><br /><br />A new command window should have opened up. In that window run your application.exe - you'll see that you're now running as the built-in System user account. After you've finished testing, you can delete the test service you created by entering:<br /><br /><div style="font-family: Courier New;">c:\sc delete testsvc</div><br /><br />Some sample impersonation code that includes an impersonation class modified slightly from the code in <a href="http://born2code.net/?page_id=45">this</a> post follows:<br /><br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Diagnostics;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Security.Principal;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Runtime.InteropServices;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.ComponentModel;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> DevHoleDemo</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Debugger</span>.Break();</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #2b91af;">WindowsIdentity</span>.GetCurrent().Name);</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">Impersonation</span> imp = <span style="color: blue;">new</span> <span style="color: #2b91af;">Impersonation</span>(<span style="color: #2b91af;">BuiltinUser</span>.NetworkService))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #2b91af;">WindowsIdentity</span>.GetCurrent().Name);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> An impersonation class (modified from http://born2code.net/?page_id=45) that supports LocalService and NetworkService logons.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Note: To use these built-in logons the code must be running under the local system account.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Impersonation</span> : <span style="color: #2b91af;">IDisposable</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"> #region</span> Dll Imports</pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Closes an open object handle.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="hObject"></span><span style="color: green;">A handle to an open object.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><returns><c></span><span style="color: green;">True</span><span style="color: gray;"></c></span><span style="color: green;"> when succeeded; otherwise </span><span style="color: gray;"><c></span><span style="color: green;">false</span><span style="color: gray;"></c></span><span style="color: green;">.</span><span style="color: gray;"></returns></span></pre><pre style="margin: 0px;"> [<span style="color: #2b91af;">DllImport</span>(<span style="color: #a31515;">"kernel32.dll"</span>)]</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">extern</span> <span style="color: #2b91af;">Boolean</span> CloseHandle(<span style="color: #2b91af;">IntPtr</span> hObject);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Attempts to log a user on to the local computer.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="username"></span><span style="color: green;">This is the name of the user account to log on to. </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> If you use the user principal name (UPN) format, user@DNSdomainname, the </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> domain parameter must be </span><span style="color: gray;"><c></span><span style="color: green;">null</span><span style="color: gray;"></c></span><span style="color: green;">.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="domain"></span><span style="color: green;">Specifies the name of the domain or server whose </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> account database contains the lpszUsername account. If this parameter </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> is </span><span style="color: gray;"><c></span><span style="color: green;">null</span><span style="color: gray;"></c></span><span style="color: green;">, the user name must be specified in UPN format. If this </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> parameter is ".", the function validates the account by using only the </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> local account database.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="password"></span><span style="color: green;">The password</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="logonType"></span><span style="color: green;">The logon type</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="logonProvider"></span><span style="color: green;">The logon provides</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="userToken"></span><span style="color: green;">The out parameter that will contain the user </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> token when method succeeds.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><returns><c></span><span style="color: green;">True</span><span style="color: gray;"></c></span><span style="color: green;"> when succeeded; otherwise </span><span style="color: gray;"><c></span><span style="color: green;">false</span><span style="color: gray;"></c></span><span style="color: green;">.</span><span style="color: gray;"></returns></span></pre><pre style="margin: 0px;"> [<span style="color: #2b91af;">DllImport</span>(<span style="color: #a31515;">"advapi32.dll"</span>, CharSet = <span style="color: #2b91af;">CharSet</span>.Auto, SetLastError = <span style="color: blue;">true</span>)]</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">extern</span> <span style="color: blue;">bool</span> LogonUser(<span style="color: blue;">string</span> username, <span style="color: blue;">string</span> domain,</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> password, <span style="color: #2b91af;">LogonType</span> logonType,</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">LogonProvider</span> logonProvider,</pre><pre style="margin: 0px;"> <span style="color: blue;">out</span> <span style="color: #2b91af;">IntPtr</span> userToken);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Creates a new access token that duplicates one already in existence.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="token"></span><span style="color: green;">Handle to an access token.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="impersonationLevel"></span><span style="color: green;">The impersonation level.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="duplication"></span><span style="color: green;">Reference to the token to duplicate.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><returns></returns></span></pre><pre style="margin: 0px;"> [<span style="color: #2b91af;">DllImport</span>(<span style="color: #a31515;">"advapi32.dll"</span>, CharSet = <span style="color: #2b91af;">CharSet</span>.Auto, SetLastError = <span style="color: blue;">true</span>)]</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">extern</span> <span style="color: blue;">bool</span> DuplicateToken(<span style="color: #2b91af;">IntPtr</span> token, <span style="color: blue;">int</span> impersonationLevel,</pre><pre style="margin: 0px;"> <span style="color: blue;">ref</span> <span style="color: #2b91af;">IntPtr</span> duplication);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> The ImpersonateLoggedOnUser function lets the calling thread impersonate the </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> security context of a logged-on user. The user is represented by a token handle.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="userToken"></span><span style="color: green;">Handle to a primary or impersonation access token that represents a logged-on user.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><returns></span><span style="color: green;">If the function succeeds, the return value is nonzero.</span><span style="color: gray;"></returns></span></pre><pre style="margin: 0px;"> [<span style="color: #2b91af;">DllImport</span>(<span style="color: #a31515;">"advapi32.dll"</span>, SetLastError = <span style="color: blue;">true</span>)]</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">extern</span> <span style="color: blue;">bool</span> ImpersonateLoggedOnUser(<span style="color: #2b91af;">IntPtr</span> userToken);</pre><pre style="margin: 0px;"><span style="color: blue;"> #endregion</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"> #region</span> Private members</pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><c></span><span style="color: green;">true</span><span style="color: gray;"></c></span><span style="color: green;"> if disposed; otherwise, </span><span style="color: gray;"><c></span><span style="color: green;">false</span><span style="color: gray;"></c></span><span style="color: green;">.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">bool</span> _disposed;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Holds the created impersonation context and will be used</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> for reverting to previous user.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: #2b91af;">WindowsImpersonationContext</span> _impersonationContext;</pre><pre style="margin: 0px;"><span style="color: blue;"> #endregion</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"> #region</span> Ctor & Dtor</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Initializes a new instance of the </span><span style="color: gray;"><see cref="Impersonation"/></span><span style="color: green;"> class and</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> impersonates as a built in service account.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="builtinUser"></span><span style="color: green;">The built in user to impersonate - either</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Local Service or Network Service. These users can only be impersonated</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> by code running as System.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> Impersonation(<span style="color: #2b91af;">BuiltinUser</span> builtinUser)</pre><pre style="margin: 0px;"> : <span style="color: blue;">this</span>(<span style="color: #2b91af;">String</span>.Empty, <span style="color: #a31515;">"NT AUTHORITY"</span>, <span style="color: #2b91af;">String</span>.Empty, <span style="color: #2b91af;">LogonType</span>.Service, builtinUser)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Initializes a new instance of the </span><span style="color: gray;"><see cref="Impersonation"/></span><span style="color: green;"> class and</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> impersonates with the specified credentials.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="username"></span><span style="color: green;">his is the name of the user account to log on </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> to. If you use the user principal name (UPN) format, </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> user@DNS_domain_name, the lpszDomain parameter must be </span><span style="color: gray;"><c></span><span style="color: green;">null</span><span style="color: gray;"></c></span><span style="color: green;">.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="domain"></span><span style="color: green;">The name of the domain or server whose account </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> database contains the lpszUsername account. If this parameter is </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><c></span><span style="color: green;">null</span><span style="color: gray;"></c></span><span style="color: green;">, the user name must be specified in UPN format. If this </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> parameter is ".", the function validates the account by using only the </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> local account database.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="password"></span><span style="color: green;">The plaintext password for the user account.</span><span style="color: gray;"></param></span></pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> Impersonation(<span style="color: #2b91af;">String</span> username, <span style="color: #2b91af;">String</span> domain, <span style="color: #2b91af;">String</span> password)</pre><pre style="margin: 0px;"> : <span style="color: blue;">this</span>(username, domain, password, <span style="color: #2b91af;">LogonType</span>.Interactive, <span style="color: #2b91af;">BuiltinUser</span>.None)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> Impersonation(<span style="color: #2b91af;">String</span> username, <span style="color: #2b91af;">String</span> domain, <span style="color: #2b91af;">String</span> password, <span style="color: #2b91af;">LogonType</span> logonType, <span style="color: #2b91af;">BuiltinUser</span> builtinUser)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">switch</span> (builtinUser)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">BuiltinUser</span>.None: <span style="color: blue;">if</span> (<span style="color: #2b91af;">String</span>.IsNullOrEmpty(username)) <span style="color: blue;">return</span>; <span style="color: blue;">break</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">BuiltinUser</span>.LocalService: username = <span style="color: #a31515;">"LOCAL SERVICE"</span>; <span style="color: blue;">break</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">BuiltinUser</span>.NetworkService: username = <span style="color: #a31515;">"NETWORK SERVICE"</span>; <span style="color: blue;">break</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: #2b91af;">IntPtr</span> userToken = <span style="color: #2b91af;">IntPtr</span>.Zero;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">IntPtr</span> userTokenDuplication = <span style="color: #2b91af;">IntPtr</span>.Zero;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// Logon with user and get token.</span></pre><pre style="margin: 0px;"> <span style="color: blue;">bool</span> loggedOn = LogonUser(username, domain, password,</pre><pre style="margin: 0px;"> logonType, <span style="color: #2b91af;">LogonProvider</span>.Default,</pre><pre style="margin: 0px;"> <span style="color: blue;">out</span> userToken);</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (loggedOn)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Create a duplication of the usertoken, this is a solution</span></pre><pre style="margin: 0px;"> <span style="color: green;">// for the known bug that is published under KB article Q319615.</span></pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (DuplicateToken(userToken, 2, <span style="color: blue;">ref</span> userTokenDuplication))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Create windows identity from the token and impersonate the user.</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WindowsIdentity</span> identity = <span style="color: blue;">new</span> <span style="color: #2b91af;">WindowsIdentity</span>(userTokenDuplication);</pre><pre style="margin: 0px;"> _impersonationContext = identity.Impersonate();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Token duplication failed!</span></pre><pre style="margin: 0px;"> <span style="color: green;">// Use the default ctor overload</span></pre><pre style="margin: 0px;"> <span style="color: green;">// that will use Mashal.GetLastWin32Error();</span></pre><pre style="margin: 0px;"> <span style="color: green;">// to create the exceptions details.</span></pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Win32Exception</span>();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">finally</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Close usertoken handle duplication when created.</span></pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (!userTokenDuplication.Equals(<span style="color: #2b91af;">IntPtr</span>.Zero))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Closes the handle of the user.</span></pre><pre style="margin: 0px;"> CloseHandle(userTokenDuplication);</pre><pre style="margin: 0px;"> userTokenDuplication = <span style="color: #2b91af;">IntPtr</span>.Zero;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: green;">// Close usertoken handle when created.</span></pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (!userToken.Equals(<span style="color: #2b91af;">IntPtr</span>.Zero))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Closes the handle of the user.</span></pre><pre style="margin: 0px;"> CloseHandle(userToken);</pre><pre style="margin: 0px;"> userToken = <span style="color: #2b91af;">IntPtr</span>.Zero;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Logon failed!</span></pre><pre style="margin: 0px;"> <span style="color: green;">// Use the default ctor overload that </span></pre><pre style="margin: 0px;"> <span style="color: green;">// will use Mashal.GetLastWin32Error();</span></pre><pre style="margin: 0px;"> <span style="color: green;">// to create the exceptions details.</span></pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Win32Exception</span>();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Releases unmanaged resources and performs other cleanup operations before the</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><see cref="Born2Code.Net.Impersonation"/></span><span style="color: green;"> is reclaimed by garbage collection.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> ~Impersonation()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> Dispose(<span style="color: blue;">false</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"><span style="color: blue;"> #endregion</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"> #region</span> Public methods</pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Reverts to the previous user.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> Revert()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (_impersonationContext != <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: green;">// Revert to previour user.</span></pre><pre style="margin: 0px;"> _impersonationContext.Undo();</pre><pre style="margin: 0px;"> _impersonationContext = <span style="color: blue;">null</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"><span style="color: blue;"> #endregion</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"> #region</span> IDisposable implementation.</pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Performs application-defined tasks associated with freeing, releasing, or</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> resetting unmanaged resources and will revent to the previous user when</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> the impersonation still exists.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> Dispose()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> Dispose(<span style="color: blue;">true</span>);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">GC</span>.SuppressFinalize(<span style="color: blue;">this</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Performs application-defined tasks associated with freeing, releasing, or</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> resetting unmanaged resources and will revent to the previous user when</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> the impersonation still exists.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><param name="disposing"></span><span style="color: green;">Specify </span><span style="color: gray;"><c></span><span style="color: green;">true</span><span style="color: gray;"></c></span><span style="color: green;"> when calling the method directly</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> or indirectly by a user’s code; Otherwise </span><span style="color: gray;"><c></span><span style="color: green;">false</span><span style="color: gray;"></c></span><span style="color: green;">.</span></pre><pre style="margin: 0px;"> <span style="color: blue;">protected</span> <span style="color: blue;">virtual</span> <span style="color: blue;">void</span> Dispose(<span style="color: blue;">bool</span> disposing)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (!_disposed)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> Revert();</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> _disposed = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"><span style="color: blue;"> #endregion</span></pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"> #region</span> Enums</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">enum</span> <span style="color: #2b91af;">LogonType</span> : <span style="color: blue;">int</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type is intended for users who will be interactively using the computer, such as a user being logged on </span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> by a terminal server, remote shell, or similar process.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type has the additional expense of caching logon information for disconnected operations;</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> therefore, it is inappropriate for some client/server applications,</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> such as a mail server.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> Interactive = 2,</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type is intended for high performance servers to authenticate plaintext passwords.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> The LogonUser function does not cache credentials for this logon type.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> Network = 3,</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type is intended for batch servers, where processes may be executing on behalf of a user without</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> their direct intervention. This type is also for higher performance servers that process many plaintext</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> authentication attempts at a time, such as mail or Web servers.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> The LogonUser function does not cache credentials for this logon type.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> Batch = 4,</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Indicates a service-type logon. The account provided must have the service privilege enabled.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> Service = 5,</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type is for GINA DLLs that log on users who will be interactively using the computer.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type can generate a unique audit record that shows when the workstation was unlocked.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> Unlock = 7,</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type preserves the name and password in the authentication package, which allows the server to make</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> connections to other network servers while impersonating the client. A server can accept plaintext credentials</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> from a client, call LogonUser, verify that the user can access the system across the network, and still</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> communicate with other servers.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> NOTE: Windows NT: This value is not supported.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> NetworkCleartText = 8,</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> This logon type allows the caller to clone its current token and specify new credentials for outbound connections.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> The new logon session has the same local identifier but uses different credentials for other network connections.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> NOTE: This logon type is supported only by the LOGON32_PROVIDER_WINNT50 logon provider.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> NOTE: Windows NT: This value is not supported.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> NewCredentials = 9,</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">enum</span> <span style="color: #2b91af;">LogonProvider</span> : <span style="color: blue;">int</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"><summary></span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> Use the standard logon provider for the system.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> The default security provider is negotiate, unless you pass NULL for the domain name and the user name</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> is not in UPN format. In this case, the default provider is NTLM.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> NOTE: Windows 2000/NT: The default security provider is NTLM.</span></pre><pre style="margin: 0px;"> <span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;"></summary></span></pre><pre style="margin: 0px;"> Default = 0,</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">enum</span> <span style="color: #2b91af;">BuiltinUser</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> None,</pre><pre style="margin: 0px;"> LocalService,</pre><pre style="margin: 0px;"> NetworkService</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;"> #endregion</span></pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com12tag:blogger.com,1999:blog-1705051721030116110.post-58736431083016671262008-02-22T08:53:00.000-08:002008-03-16T10:26:57.439-07:00Recommended ReadingHere's a <a href="http://www.andrewconnell.com/blog/articles/RecommendedReading.aspx">list</a> of recommended reading by a well known MOSS MVP. For help rationalizing poor decision making, I recommend <a type="amzn" asin="0151010986">Mistakes Were Made (But Not by Me)</a>.txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com0tag:blogger.com,1999:blog-1705051721030116110.post-5732645294945188132008-02-21T08:00:00.000-08:002009-01-02T16:09:49.284-08:00Delete SharePoint Document Library Files ProgrammaticallyFollowing on from <a href="http://geek.hubkey.com/2007/12/move-sharepoint-document-library-files.html">this post</a> on moving or copying SharePoint files with FrontPage Remote Procedure Calls (RPC), and <a href="http://geek.hubkey.com/2007/11/upload-file-to-sharepoint-document.html">this older post</a> on remotely saving files to a SharePoint document library, the code below demonstrates how to remove files programmatically from a remote document library without using the SharePoint API. Documentation about the move method can be found <a href="http://msdn2.microsoft.com/en-us/library/ms428863.aspx">here</a>. The EscapeVectorChars method can be found in the original post. Obviously because this RPC method will remove documents from your site (potentially deleting them permanently), please use with appropriate caution!<br /><br /><span style="COLOR: red; ">Update:</span> You can download a comprehensive c# class library to automate RPC calls - including removing files. See <a href="http://geek.hubkey.com/2008/07/programatically-manage-remote-documents.html">this</a> blog post for more information.<br /><br /><div class="code"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> Remove(<span style="color: blue;">string</span> webUrl, <span style="color: blue;">out</span> <span style="color: blue;">string</span> result, <span style="color: blue;">params</span> <span style="color: blue;">string</span>[] webRelativeUrls)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> method = <span style="color: #a31515;">"method=remove+documents%3a12.0.4518.1016&service_name=%2f&url_list=[{0}]"</span>;</pre><pre style="margin: 0px;"> method = <span style="color: #2b91af;">String</span>.Format(method, GetStringVector(webRelativeUrls));</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">WebClient</span> webClient = <span style="color: blue;">new</span> <span style="color: #2b91af;">WebClient</span>())</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> webClient.Credentials = <span style="color: #2b91af;">CredentialCache</span>.DefaultCredentials;</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"X-Vermeer-Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> result = <span style="color: #2b91af;">Encoding</span>.UTF8.GetString(webClient.UploadData(webUrl + <span style="color: #a31515;">"/_vti_bin/_vti_aut/author.dll"</span>, <span style="color: #a31515;">"POST"</span>, <span style="color: #2b91af;">Encoding</span>.UTF8.GetBytes(method)));</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (result.IndexOf(<span style="color: #a31515;">"\n<p>message=successfully"</span>) < 0) <span style="color: green;">//note: will show success even if document(s) did not exist on the server</span></pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>(result);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> ex)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> result = ex.Message;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">string</span> GetStringVector(<span style="color: blue;">string</span>[] strings)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">StringBuilder</span> sb = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();</pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> s <span style="color: blue;">in</span> strings)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> sb.Append(EscapeVectorChars(s));</pre><pre style="margin: 0px;"> sb.Append(<span style="color: #a31515;">";"</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> sb.ToString().TrimEnd(<span style="color: #a31515;">';'</span>);</pre><pre style="margin: 0px;"> }</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com5tag:blogger.com,1999:blog-1705051721030116110.post-2039379967854054712008-01-28T08:32:00.000-08:002009-01-02T16:14:58.559-08:00Searching for Users or Groups Using SPUtility.ResolvePrincipalIt's sometimes handy to know that the Person or Group SharePoint column data type is stored internally as a SPFieldUserValue. This in turn is derived from SPFieldLookupValue which is serialized as "ID;#VALUE" in the content database, e.g.:<br /><br /><div class="code"><pre style="margin: 0px;"> <span style="color: #2b91af;">SPListItem</span> item = web.Lists[<span style="color: #a31515;">"Docs"</span>].Items[0];</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> fieldValue = item[<span style="color: #a31515;">"Contact"</span>].ToString(); <span style="color: green;">// Contact is the name of Person or Group column and in this case has a value "1;#Test User"</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPFieldUserValue</span> user = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPFieldUserValue</span>(web, fieldValue);</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> name = user.LookupValue; <span style="color: green;">// Test User</span></pre></div><br /><br />The LookupId for this field type is the ID property of the SPPrincipal class.<br /><br />Sometimes you might need to determine what this Lookup ID is for a particular user name (you can even search for a user by email address), and that's where the SPUtility.ResolvePrincipal method is helpful, e.g.:<br /><br /><div class="code"><pre style="margin: 0px;"> <span style="color: blue;">using</span> Microsoft.SharePoint.Utilities;</pre><pre style="margin: 0px;"> ...</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">SPPrincipalInfo</span> userInfo = <span style="color: #2b91af;">SPUtility</span>.ResolvePrincipal(web, <span style="color: #a31515;">"Test User"</span>, <span style="color: #2b91af;">SPPrincipalType</span>.All, <span style="color: #2b91af;">SPPrincipalSource</span>.All, <span style="color: blue;">null</span>, <span style="color: blue;">false</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (userInfo != <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> item[<span style="color: #a31515;">"Contact"</span>] = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPFieldUserValue</span>(web, userInfo.PrincipalId, userInfo.DisplayName);</pre><pre style="margin: 0px;"> item.Update();</pre><pre style="margin: 0px;"> }</pre></div><br /><br />A good example of using this method can be found <a href="http://blogs.charteris.com/blogs/edwardw/archive/2007/08/06/sharepoint-how-to-determine-if-a-user-has-access-to-your-site-spweb-or-list.aspx">here</a> which demonstrates using this method to find out if a user has access to your site or list.<br /><br />A second SPUtility method - SPUtility.SearchPrincipals - returns a list of principals much like the list returned by the "Select People and Groups" picker dialog box, e.g:<br /><br /><div class="code"><pre style="margin: 0px;"> <span style="color: blue;">bool</span> reachedMaxCount = <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">IList</span><<span style="color: #2b91af;">SPPrincipalInfo</span>> users = <span style="color: #2b91af;">SPUtility</span>.SearchPrincipals(web, <span style="color: #a31515;">"T"</span>, <span style="color: #2b91af;">SPPrincipalType</span>.All, <span style="color: #2b91af;">SPPrincipalSource</span>.All, <span style="color: blue;">null</span>, 100, <span style="color: blue;">out</span> reachedMaxCount);</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com2tag:blogger.com,1999:blog-1705051721030116110.post-39499390224186799412007-12-06T11:22:00.000-08:002009-01-02T16:16:01.917-08:00Move or Copy SharePoint Document Library Files ProgrammaticallyIn <a href="http://geek.hubkey.com/2007/11/upload-file-to-sharepoint-document.html">this post</a> I published some code that took a look at using FrontPage Server Extentions to upload a file to a document library where the requirement was to be able to save metadata along with the document and not use the API. Here are a few more static methods that can be inserted into that code to provide simple file moving or copying functionality from a remote client. Documentation about the move RPC method can be found <a href="http://msdn2.microsoft.com/en-us/library/ms440627.aspx">here</a>. To copy rather than move the file, change the doCopy flag to true. An alternative method for remotely moving a file from one document library to another location is to use the copy web service which is documented on MSDN <a href="http://msdn2.microsoft.com/en-us/library/copy.aspx">here</a>. For local SharePoint calls, the appropriate API method is <a href="http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.copyto.aspx">SPListItem.CopyTo</a> or <a href="http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spfile.moveto.aspx">SPFile.MoveTo</a>.<br /><br /><span style="COLOR: red; ">Update:</span> You can download a comprehensive c# class library to automate RPC calls - including moving files (even between web sites or servers). See <a href="http://geek.hubkey.com/2008/07/programatically-manage-remote-documents.html">this</a> blog post for more information.<br /><br /><div class="code"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> Move(<span style="color: blue;">string</span> oldUrl, <span style="color: blue;">string</span> newUrl)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> result = <span style="color: #a31515;">""</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> webUrl = GetWebURL(oldUrl);</pre><pre style="margin: 0px;"> oldUrl = oldUrl.Substring(webUrl.Length + 1);</pre><pre style="margin: 0px;"> newUrl = newUrl.Substring(webUrl.Length + 1);</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> Move(webUrl, oldUrl, newUrl, <span style="color: blue;">out</span> result);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> Move(<span style="color: blue;">string</span> webUrl, <span style="color: blue;">string</span> oldUrl, <span style="color: blue;">string</span> newUrl, <span style="color: blue;">out</span> <span style="color: blue;">string</span> result)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> EnsureFolders(webUrl, newUrl);</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> renameOption = <span style="color: #a31515;">"findbacklinks"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> putOption = <span style="color: #a31515;">"overwrite,createdir,migrationsemantics"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">bool</span> doCopy = <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> method = <span style="color: #a31515;">"method=move+document%3a12.0.4518.1016&service_name=%2f&oldUrl={0}&newUrl={1}&url_list=[]&rename_option={2}&put_option={3}&docopy={4}"</span>;</pre><pre style="margin: 0px;"> method = <span style="color: #2b91af;">String</span>.Format(method, oldUrl, newUrl, renameOption, putOption, doCopy.ToString().ToLower());</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">WebClient</span> webClient = <span style="color: blue;">new</span> <span style="color: #2b91af;">WebClient</span>())</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> webClient.Credentials = <span style="color: #2b91af;">CredentialCache</span>.DefaultCredentials;</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"X-Vermeer-Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> result = <span style="color: #2b91af;">Encoding</span>.UTF8.GetString(webClient.UploadData(webUrl + <span style="color: #a31515;">"/_vti_bin/_vti_aut/author.dll"</span>, <span style="color: #a31515;">"POST"</span>, <span style="color: #2b91af;">Encoding</span>.UTF8.GetBytes(method)));</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (result.IndexOf(<span style="color: #a31515;">"\n<p>message=successfully"</span>) < 0)</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>(result);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> ex)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> result = ex.Message;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> EnsureFolders(<span style="color: blue;">string</span> rootUrl, <span style="color: blue;">string</span> folderUrl)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">StringBuilder</span> sb = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>(rootUrl.TrimEnd(<span style="color: #a31515;">'/'</span>));</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span>[] segments = folderUrl.Split(<span style="color: #a31515;">'/'</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i < segments.Length - 1; i++)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> sb.Append(<span style="color: #a31515;">"/"</span>);</pre><pre style="margin: 0px;"> sb.Append(segments[i]);</pre><pre style="margin: 0px;"> CreateFolder(sb.ToString());</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> CreateFolder(<span style="color: blue;">string</span> folderURL)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WebRequest</span> request = <span style="color: #2b91af;">WebRequest</span>.Create(folderURL);</pre><pre style="margin: 0px;"> request.Credentials = <span style="color: #2b91af;">CredentialCache</span>.DefaultCredentials;</pre><pre style="margin: 0px;"> request.Method = <span style="color: #a31515;">"MKCOL"</span>;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WebResponse</span> response = request.GetResponse();</pre><pre style="margin: 0px;"> response.Close();</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">WebException</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com21tag:blogger.com,1999:blog-1705051721030116110.post-20673993695615854242007-12-04T15:10:00.000-08:002007-12-04T15:57:59.959-08:00Redirecting to an Error PageThe <a href="http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.transfertoerrorpage.aspx">SPUtility.TransferToErrorPage</a> method is a convenient way to redirect users to an error page in the event that an unhandled exception occurs. <a href="http://zac.provoke.co.nz/archive/2007/04/30/programming-in-wss-use-sputility.aspx">This post</a> (from Wellington no less!) covers this method and a few other static methods from the SPUtility class well. One thing worth pointing out is the use of the second overload to the TransferToErrorPage method. This allows a link to appear in the message so that users can be redirected to another page (for example to a long running job status list item for more information on the error). To use this override, pass the link text and link url and then include a '{0}' (like the <a href="http://msdn2.microsoft.com/en-us/library/txafckwd.aspx">composite format</a> syntax) in your message where you need the link to appear.txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com0tag:blogger.com,1999:blog-1705051721030116110.post-92014721966765110062007-11-14T12:55:00.000-08:002009-01-02T16:19:38.808-08:00Upload a File to a SharePoint Document Library - Part IIIn <a href="http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html">Part I</a> I posted code that used the SharePoint lists service to help in uploading files with meta data to a sharepoint document library. Here is another variation, this time using FrontPage Server Extensions and RPC. Note that this code won't create more than one new folder - if this is a problem you may want to ensure the full folder path with code like that from the first article.<br /><br /><span style="COLOR: red; ">Update:</span> You can download a comprehensive c# class library to automate RPC calls - including uploading files to a SharePoint document library. See <a href="http://geek.hubkey.com/2008/07/programatically-manage-remote-documents.html">this</a> blog post for more information.<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Text;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.IO;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Net;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Web;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> DevHoleDemo</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> properties = <span style="color: blue;">new</span> <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>>();</pre><pre style="margin: 0px;"> properties.Add(<span style="color: #a31515;">"Title"</span>, <span style="color: #a31515;">"Test Title"</span>);</pre><pre style="margin: 0px;"> <span style="color: green;">//Create or overwrite text file test.txt in 'Docs' document library creating folder 'Test Folder' as required.</span></pre><pre style="margin: 0px;"> <span style="color: #2b91af;">DocLibHelper</span>.Upload(<span style="color: #a31515;">"http://localhost/Docs/Test Folder/test.txt"</span>, System.Text.<span style="color: #2b91af;">Encoding</span>.ASCII.GetBytes(<span style="color: #a31515;">"Test text."</span>), properties);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">DocLibHelper</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">string</span> EncodeMetaInfo(<span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> metaInfo)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (metaInfo == <span style="color: blue;">null</span>) <span style="color: blue;">return</span> <span style="color: #a31515;">""</span>;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">StringBuilder</span> sb = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();</pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">KeyValuePair</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> kvp <span style="color: blue;">in</span> metaInfo)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (kvp.Value != <span style="color: blue;">null</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> fieldName = kvp.Key; <span style="color: green;">// note: field names are case sensitive</span></pre><pre style="margin: 0px;"> <span style="color: blue;">switch</span> (fieldName)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">"Title"</span>:</pre><pre style="margin: 0px;"> fieldName = <span style="color: #a31515;">"vti_title"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">break</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> data = EscapeVectorChars(kvp.Value.ToString());</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> dataTypeCode = <span style="color: #a31515;">"S"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">switch</span> (kvp.Value.GetType().FullName)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">"System.Boolean"</span>:</pre><pre style="margin: 0px;"> dataTypeCode = <span style="color: #a31515;">"B"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">break</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">"System.DateTime"</span>:</pre><pre style="margin: 0px;"> data = ((<span style="color: #2b91af;">DateTime</span>)kvp.Value).ToString(<span style="color: #a31515;">"s"</span>) + <span style="color: #a31515;">"Z"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">break</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> sb.AppendFormat(<span style="color: #a31515;">"{0};{1}W|{2};"</span>, fieldName, dataTypeCode, data);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: #2b91af;">HttpUtility</span>.UrlEncode(sb.ToString().TrimEnd(<span style="color: #a31515;">';'</span>));</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">string</span> EscapeVectorChars(<span style="color: blue;">string</span> value)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">StringBuilder</span> sb = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();</pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">char</span> c <span style="color: blue;">in</span> value)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">switch</span> (c)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">';'</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">'|'</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">'['</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">']'</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">'\\'</span>:</pre><pre style="margin: 0px;"> sb.Append(<span style="color: #a31515;">"\\"</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">break</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> sb.Append(c);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> sb.ToString();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> GetWebURL(<span style="color: blue;">string</span> url)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> url = url.Substring(0, url.LastIndexOf(<span style="color: #a31515;">"/"</span>));</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">WebClient</span> webClient = <span style="color: blue;">new</span> <span style="color: #2b91af;">WebClient</span>())</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> webClient.Credentials = <span style="color: #2b91af;">CredentialCache</span>.DefaultCredentials;</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"X-Vermeer-Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">byte</span>[] data = <span style="color: #2b91af;">Encoding</span>.UTF8.GetBytes(<span style="color: #a31515;">"method=open+service%3a12.0.4518.1016&service_name=%2f"</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> result = <span style="color: #2b91af;">Encoding</span>.UTF8.GetString(webClient.UploadData(url + <span style="color: #a31515;">"/_vti_bin/_vti_aut/author.dll"</span>, <span style="color: #a31515;">"POST"</span>, data));</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (result.IndexOf(<span style="color: #a31515;">"\n<li>status=327684"</span>) == -1)</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> url;</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> GetWebURL(url);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">null</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> Upload(<span style="color: blue;">string</span> destinationUrl, <span style="color: blue;">byte</span>[] bytes, <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> metaInfo)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> result = <span style="color: #a31515;">""</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> webUrl = GetWebURL(destinationUrl);</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> documentName = destinationUrl.Substring(webUrl.Length + 1);</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> Upload(webUrl, documentName, bytes, metaInfo, <span style="color: blue;">out</span> result);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">bool</span> Upload(<span style="color: blue;">string</span> webUrl, <span style="color: blue;">string</span> documentName, <span style="color: blue;">byte</span>[] bytes, <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> metaInfo, <span style="color: blue;">out</span> <span style="color: blue;">string</span> result)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> putOption = <span style="color: #a31515;">"overwrite,createdir,migrationsemantics"</span>; <span style="color: green;">// see http://msdn2.microsoft.com/en-us/library/ms455325.aspx</span></pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> comment = <span style="color: blue;">null</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">bool</span> keepCheckedOut = <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> method = <span style="color: #a31515;">"method=put+document%3a12.0.4518.1016&service_name=%2f&document=[document_name={0};meta_info=[{1}]]&put_option={2}&comment={3}&keep_checked_out={4}\n"</span>;</pre><pre style="margin: 0px;"> method = <span style="color: #2b91af;">String</span>.Format(method, documentName, EncodeMetaInfo(metaInfo), putOption, <span style="color: #2b91af;">HttpUtility</span>.UrlEncode(comment), keepCheckedOut.ToString().ToLower());</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">List</span><<span style="color: blue;">byte</span>> data = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: blue;">byte</span>>();</pre><pre style="margin: 0px;"> data.AddRange(<span style="color: #2b91af;">Encoding</span>.UTF8.GetBytes(method));</pre><pre style="margin: 0px;"> data.AddRange(bytes);</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">WebClient</span> webClient = <span style="color: blue;">new</span> <span style="color: #2b91af;">WebClient</span>())</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> webClient.Credentials = <span style="color: #2b91af;">CredentialCache</span>.DefaultCredentials;</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> webClient.Headers.Add(<span style="color: #a31515;">"X-Vermeer-Content-Type"</span>, <span style="color: #a31515;">"application/x-vermeer-urlencoded"</span>);</pre><pre style="margin: 0px;"> result = <span style="color: #2b91af;">Encoding</span>.UTF8.GetString(webClient.UploadData(webUrl + <span style="color: #a31515;">"/_vti_bin/_vti_aut/author.dll"</span>, <span style="color: #a31515;">"POST"</span>, data.ToArray()));</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (result.IndexOf(<span style="color: #a31515;">"\n<p>message=successfully"</span>) < 0)</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>(result);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> ex)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> result = ex.Message;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre><pre style="margin: 0px;"> </pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com48tag:blogger.com,1999:blog-1705051721030116110.post-6867592594654498152007-11-05T09:11:00.000-08:002009-01-02T16:26:33.879-08:00Provide Status Updates for Long Running Operation JobsA simple way to give users some feedback on the progress status of long running jobs is provided by the Microsoft.SharePoint.Publishing assembly. When a class that inherits from the LongRunningOperationJob class has its start method invoked, a list item is added to the Long Running Operation Status list in the root web. Providing a link to the LongRunningOperationProgress.aspx page along with the guid of this list item will display an update page with a progress bar similar to that shown below:<br /><br /><img src="http://www.hubkey.com/images/longrunningjob.gif" alt="Long Running Job Status Page"><br /><br />A LongRunningOperationJob might not necessary be designed to run as a SPJobDefinition timer job, although there's no reason you couldn't combine the two to provide more granular information than the _admin/ServiceRunningJobs.aspx page provides.<br /><br />Some example code follows. Before running it, make sure that your site collection includes a list named 'Long Running Operation Status' at the root web. This list is created when you install the Office SharePoint Server Publishing Infrastructure feature at the Site Collection Features level. The list apparently isn't removed when this feature is uninstalled so it's not necessary to have the Publishing Infrastructure feature activated if you don't want it to be - just activate then deactivate it.<br /><br />The Microsoft.SharePoint.Publishing assembly can be found here: <br />%Program Files%\Microsoft Office Servers\12.0\Bin\Microsoft.SharePoint.Publishing.dll<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Diagnostics;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Threading;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.SharePoint;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.SharePoint.Publishing;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> Microsoft.SharePoint.Publishing.Internal;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> DevHoleDemo</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">const</span> <span style="color: blue;">string</span> STATUS_LIST_NAME = <span style="color: #a31515;">"Long Running Operation Status"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">const</span> <span style="color: blue;">string</span> PROGRESS_PAGE_URL = <span style="color: #a31515;">"/_layouts/LongRunningOperationProgress.aspx"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> webURL = <span style="color: #a31515;">"http://localhost/"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">SPSite</span> site = <span style="color: blue;">new</span> <span style="color: #2b91af;">SPSite</span>(webURL))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">SPWeb</span> web = site.RootWeb)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">LongRunningJob</span> longRunningJob = <span style="color: blue;">new</span> <span style="color: #2b91af;">LongRunningJob</span>();</pre><pre style="margin: 0px;"> longRunningJob.Title = <span style="color: #a31515;">"Demo Long Running Job"</span>;</pre><pre style="margin: 0px;"> longRunningJob.TotalOperationsToBePerformed = 30;</pre><pre style="margin: 0px;"> longRunningJob.RedirectWhenFinished = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> longRunningJob.NavigateWhenDoneUrl = web.Url + <span style="color: #a31515;">"/"</span> + STATUS_LIST_NAME;</pre><pre style="margin: 0px;"> longRunningJob.Start(web);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Process</span>.Start(<span style="color: #a31515;">"iexplore.exe"</span>, <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"{0}{1}?JobId={2}"</span>, web.Url, PROGRESS_PAGE_URL, longRunningJob.JobId));</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">LongRunningOperationStatus</span> jobStatus;</pre><pre style="margin: 0px;"> <span style="color: blue;">do</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> jobStatus = <span style="color: #2b91af;">LongRunningOperationStatus</span>.GetJob(site, longRunningJob.JobId);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Console</span>.WriteLine(jobStatus.StatusDescription);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Thread</span>.Sleep(1000);</pre><pre style="margin: 0px;"> } <span style="color: blue;">while</span> (jobStatus.Status != <span style="color: #2b91af;">LongRunningOperationJob</span>.<span style="color: #2b91af;">OperationStatus</span>.Successful);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">LongRunningJob</span> : <span style="color: #2b91af;">LongRunningOperationJob</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> DoWork()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">this</span>.OperationsPerformed = 0; <span style="color: blue;">this</span>.OperationsPerformed < <span style="color: blue;">this</span>.TotalOperationsToBePerformed; <span style="color: blue;">this</span>.OperationsPerformed++)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">this</span>.StatusDescription = <span style="color: blue;">string</span>.Format(<span style="color: #a31515;">"im in ur long running job, doing ur work {0} of {1}..."</span>, <span style="color: blue;">this</span>.OperationsPerformed, <span style="color: blue;">this</span>.TotalOperationsToBePerformed);</pre><pre style="margin: 0px;"> <span style="color: blue;">this</span>.UpdateStatus();</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Thread</span>.Sleep(1000);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com2tag:blogger.com,1999:blog-1705051721030116110.post-1056260803398299052007-10-23T09:54:00.000-07:002009-01-02T16:42:03.683-08:00Upload a File to a SharePoint Document Library - Part IThe following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.<br /><br />To use this code add a reference to the SharePoint Lists service (/_vti_bin/Lists.asmx) and name it ‘ListsService’. The code was written against MOSS 2007.<br /><br />To download files use the GetItem method of the SharePoint Copy service (/_vti_bin/Copy.asmx). While it’s possible to upload files using the CopyIntoItems method of this service, it won’t create folders as needed, and you’d probably want to remove the copy link that is created.<br /><br />It's also possible to use Front Page Server Extensions and RPC calls to upload files with meta data - the code for which is a bit more efficient as it doesn't require web service calls. Using RPC calls is covered in <a href="http://geek.hubkey.com/2007/11/upload-file-to-sharepoint-document.html">Part II</a>.<br /><br /><span style="COLOR: red; ">Update:</span> You can download a comprehensive c# class library to automate RPC calls - including uploading files to a SharePoint document library. See <a href="http://geek.hubkey.com/2008/07/programatically-manage-remote-documents.html">this</a> blog post for more information.<br /><br /><div class="code"><pre style="margin: 0px;"><span style="color: blue;">using</span> System;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Collections;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Collections.Generic;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Text;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Net;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.IO;</pre><pre style="margin: 0px;"><span style="color: blue;">using</span> System.Xml;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"><span style="color: blue;">namespace</span> DevHoleDemo</pre><pre style="margin: 0px;">{</pre><pre style="margin: 0px;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">DocLibHelper</span> docLibHelper = <span style="color: blue;">new</span> <span style="color: #2b91af;">DocLibHelper</span>();</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> properties = <span style="color: blue;">new</span> <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>>();</pre><pre style="margin: 0px;"> properties.Add(<span style="color: #a31515;">"Title"</span>, <span style="color: #a31515;">"Test Title"</span>);</pre><pre style="margin: 0px;"> <span style="color: green;">//Create or overwrite text file test.txt in 'Docs' document library creating folder 'Test Folder' as required.</span></pre><pre style="margin: 0px;"> docLibHelper.Upload(<span style="color: #a31515;">"http://localhost/Docs/Test Folder/test.txt"</span>, System.Text.<span style="color: #2b91af;">Encoding</span>.ASCII.GetBytes(<span style="color: #a31515;">"Test text."</span>), properties);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">DocLibHelper</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> ListsService.Lists m_listService;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">ICredentials</span> m_credentials;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">ListInfoCollection</span> m_lists;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> DocLibHelper()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> m_credentials = <span style="color: #2b91af;">CredentialCache</span>.DefaultCredentials;</pre><pre style="margin: 0px;"> m_listService = <span style="color: blue;">new</span> ListsService.Lists();</pre><pre style="margin: 0px;"> m_listService.Credentials = m_credentials;</pre><pre style="margin: 0px;"> m_lists = <span style="color: blue;">new</span> <span style="color: #2b91af;">ListInfoCollection</span>(m_listService);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ListInfo</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> m_rootFolder;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> m_listName;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> m_version;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> m_webUrl;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> ListInfo(<span style="color: #2b91af;">XmlNode</span> listResponse)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> m_rootFolder = listResponse.Attributes[<span style="color: #a31515;">"RootFolder"</span>].Value + <span style="color: #a31515;">"/"</span>;</pre><pre style="margin: 0px;"> m_listName = listResponse.Attributes[<span style="color: #a31515;">"ID"</span>].Value;</pre><pre style="margin: 0px;"> m_version = listResponse.Attributes[<span style="color: #a31515;">"Version"</span>].Value;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">bool</span> IsMatch(<span style="color: blue;">string</span> url)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> url += <span style="color: #a31515;">"/"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> url.Substring(0, m_rootFolder.Length) == m_rootFolder;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> { }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ListInfoCollection</span> : <span style="color: #2b91af;">IEnumerable</span><<span style="color: #2b91af;">ListInfo</span>></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> ListsService.Lists m_listService;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: #2b91af;">ListInfo</span>> m_lists = <span style="color: blue;">new</span> <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: #2b91af;">ListInfo</span>>();</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> ListInfoCollection(ListsService.Lists listService)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> m_listService = listService;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">IEnumerator</span><<span style="color: #2b91af;">ListInfo</span>> GetEnumerator()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> m_lists.Values.GetEnumerator();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">IEnumerator</span> <span style="color: #2b91af;">IEnumerable</span>.GetEnumerator()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">this</span>.GetEnumerator();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ListInfo</span> Find(<span style="color: #2b91af;">FileInfo</span> fileInfo)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (m_lists.ContainsKey(fileInfo.LookupName))</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> m_lists[fileInfo.LookupName];</pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">ListInfo</span> li <span style="color: blue;">in</span> m_lists.Values)</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (li.IsMatch(fileInfo.LookupName)) <span style="color: blue;">return</span> li;</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> webUrl = fileInfo.m_URL;</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (fileInfo.m_listInfo != <span style="color: blue;">null</span> && !<span style="color: blue;">string</span>.IsNullOrEmpty(fileInfo.m_listInfo.m_listName))</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">ListInfo</span> listInfo = <span style="color: blue;">new</span> <span style="color: #2b91af;">ListInfo</span>(CallService(<span style="color: blue;">ref</span> webUrl, <span style="color: blue;">delegate</span> { <span style="color: blue;">return</span> m_listService.GetList(fileInfo.LookupName); }));</pre><pre style="margin: 0px;"> listInfo.m_webUrl = webUrl;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> listInfo;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">else</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">XmlNode</span> lists = CallService(<span style="color: blue;">ref</span> webUrl, <span style="color: blue;">delegate</span> { <span style="color: blue;">return</span> m_listService.GetListCollection(); });</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (lists == <span style="color: blue;">null</span>) <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>(<span style="color: #a31515;">"Could not find web."</span>);</pre><pre style="margin: 0px;"> <span style="color: green;">//Find list by RootFolder (which doesn't seem to be populated in GetListCollection response so must iterate GetList response)</span></pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">XmlNode</span> list <span style="color: blue;">in</span> lists.ChildNodes)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">ListInfo</span> listInfo = <span style="color: blue;">new</span> <span style="color: #2b91af;">ListInfo</span>(m_listService.GetList(list.Attributes[<span style="color: #a31515;">"Name"</span>].Value));</pre><pre style="margin: 0px;"> listInfo.m_webUrl = webUrl;</pre><pre style="margin: 0px;"> m_lists.Add(listInfo.m_listName, listInfo);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (listInfo.IsMatch(fileInfo.LookupName))</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> listInfo;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>(<span style="color: #a31515;">"Could not find list."</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">delegate</span> <span style="color: #2b91af;">XmlNode</span> <span style="color: #2b91af;">ServiceOperation</span>();</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: #2b91af;">XmlNode</span> CallService(<span style="color: blue;">ref</span> <span style="color: blue;">string</span> webURL, <span style="color: #2b91af;">ServiceOperation</span> serviceOperation)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> webURL = webURL.Substring(0, webURL.LastIndexOf(<span style="color: #a31515;">"/"</span>));</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> m_listService.Url = webURL + <span style="color: #a31515;">"/_vti_bin/Lists.asmx"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> serviceOperation();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> CallService(<span style="color: blue;">ref</span> webURL, serviceOperation);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> webURL = <span style="color: blue;">null</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">null</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">FileInfo</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> m_URL;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">byte</span>[] m_bytes;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> m_properties;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ListInfo</span> m_listInfo;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">bool</span> m_ensureFolders = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: #2b91af;">Uri</span> m_uri;</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">bool</span> HasProperties</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> m_properties != <span style="color: blue;">null</span> && m_properties.Count > 0; }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> RelativeFilePath</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> m_URL.Substring(m_URL.IndexOf(m_listInfo.m_rootFolder) + 1); }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">Uri</span> URI</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (m_uri == <span style="color: blue;">null</span>) m_uri = <span style="color: blue;">new</span> <span style="color: #2b91af;">Uri</span>(m_URL);</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> m_uri;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> LookupName</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (m_listInfo != <span style="color: blue;">null</span> && !<span style="color: blue;">string</span>.IsNullOrEmpty(m_listInfo.m_listName))</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> m_listInfo.m_listName;</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> URI.LocalPath;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> FileInfo(<span style="color: blue;">string</span> url, <span style="color: blue;">byte</span>[] bytes, <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> properties)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> m_URL = url.Replace(<span style="color: #a31515;">"%20"</span>, <span style="color: #a31515;">" "</span>);</pre><pre style="margin: 0px;"> m_bytes = bytes;</pre><pre style="margin: 0px;"> m_properties = properties;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Upload(<span style="color: blue;">string</span> destinationUrl, <span style="color: blue;">byte</span>[] bytes, <span style="color: #2b91af;">Dictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> properties)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> Upload(<span style="color: blue;">new</span> <span style="color: #2b91af;">FileInfo</span>(destinationUrl, bytes, properties));</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">bool</span> Upload(<span style="color: #2b91af;">FileInfo</span> fileInfo)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (fileInfo.HasProperties)</pre><pre style="margin: 0px;"> fileInfo.m_listInfo = m_lists.Find(fileInfo);</pre><pre style="margin: 0px;"> <span style="color: blue;">bool</span> result = TryToUpload(fileInfo);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (!result && fileInfo.m_ensureFolders)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">string</span> root = fileInfo.URI.AbsoluteUri.Replace(fileInfo.URI.AbsolutePath, <span style="color: #a31515;">""</span>);</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i < fileInfo.URI.Segments.Length - 1; i++)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> root += fileInfo.URI.Segments[i];</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (i > 1) CreateFolder(root);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> result = TryToUpload(fileInfo);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> result;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">bool</span> TryToUpload(<span style="color: #2b91af;">FileInfo</span> fileInfo)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WebRequest</span> request = <span style="color: #2b91af;">WebRequest</span>.Create(fileInfo.m_URL);</pre><pre style="margin: 0px;"> request.Credentials = m_credentials;</pre><pre style="margin: 0px;"> request.Method = <span style="color: #a31515;">"PUT"</span>;</pre><pre style="margin: 0px;"> <span style="color: blue;">byte</span>[] buffer = <span style="color: blue;">new</span> <span style="color: blue;">byte</span>[1024];</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">Stream</span> stream = request.GetRequestStream())</pre><pre style="margin: 0px;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">MemoryStream</span> ms = <span style="color: blue;">new</span> <span style="color: #2b91af;">MemoryStream</span>(fileInfo.m_bytes))</pre><pre style="margin: 0px;"> <span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = ms.Read(buffer, 0, buffer.Length); i > 0; i = ms.Read(buffer, 0, buffer.Length))</pre><pre style="margin: 0px;"> stream.Write(buffer, 0, i);</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WebResponse</span> response = request.GetResponse();</pre><pre style="margin: 0px;"> response.Close();</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (fileInfo.HasProperties)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">StringBuilder</span> sb = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();</pre><pre style="margin: 0px;"> sb.Append(<span style="color: #a31515;">"<Method ID='1' Cmd='Update'><Field Name='ID'/>"</span>);</pre><pre style="margin: 0px;"> sb.AppendFormat(<span style="color: #a31515;">"<Field Name='FileRef'>{0}</Field>"</span>, fileInfo.m_URL);</pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">KeyValuePair</span><<span style="color: blue;">string</span>, <span style="color: blue;">object</span>> property <span style="color: blue;">in</span> fileInfo.m_properties)</pre><pre style="margin: 0px;"> sb.AppendFormat(<span style="color: #a31515;">"<Field Name='{0}'>{1}</Field>"</span>, property.Key, property.Value);</pre><pre style="margin: 0px;"> sb.Append(<span style="color: #a31515;">"</Method>"</span>);</pre><pre style="margin: 0px;"> System.Xml.<span style="color: #2b91af;">XmlElement</span> updates = (<span style="color: blue;">new</span> System.Xml.<span style="color: #2b91af;">XmlDocument</span>()).CreateElement(<span style="color: #a31515;">"Batch"</span>);</pre><pre style="margin: 0px;"> updates.SetAttribute(<span style="color: #a31515;">"OnError"</span>, <span style="color: #a31515;">"Continue"</span>);</pre><pre style="margin: 0px;"> updates.SetAttribute(<span style="color: #a31515;">"ListVersion"</span>, fileInfo.m_listInfo.m_version);</pre><pre style="margin: 0px;"> updates.SetAttribute(<span style="color: #a31515;">"PreCalc"</span>, <span style="color: #a31515;">"TRUE"</span>);</pre><pre style="margin: 0px;"> updates.InnerXml = sb.ToString();</pre><pre style="margin: 0px;"> m_listService.Url = fileInfo.m_listInfo.m_webUrl + <span style="color: #a31515;">"/_vti_bin/Lists.asmx"</span>;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">XmlNode</span> updatesResponse = m_listService.UpdateListItems(fileInfo.m_listInfo.m_listName, updates);</pre><pre style="margin: 0px;"> <span style="color: blue;">if</span> (updatesResponse.FirstChild.FirstChild.InnerText != <span style="color: #a31515;">"0x00000000"</span>)</pre><pre style="margin: 0px;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">Exception</span>(<span style="color: #a31515;">"Could not update properties."</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">WebException</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">bool</span> CreateFolder(<span style="color: blue;">string</span> folderURL)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">try</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WebRequest</span> request = <span style="color: #2b91af;">WebRequest</span>.Create(folderURL);</pre><pre style="margin: 0px;"> request.Credentials = m_credentials;</pre><pre style="margin: 0px;"> request.Method = <span style="color: #a31515;">"MKCOL"</span>;</pre><pre style="margin: 0px;"> <span style="color: #2b91af;">WebResponse</span> response = request.GetResponse();</pre><pre style="margin: 0px;"> response.Close();</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">WebException</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;">}</pre></div>txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com69tag:blogger.com,1999:blog-1705051721030116110.post-76640910490366467452007-10-18T07:30:00.000-07:002007-11-19T08:44:36.396-08:00The Multi-line Text Box and its Malcontents - Part IIIIn <a href="http://geek.hubkey.com/2007/10/multi-line-text-box-and-its-malcontents.html">Part I</a> and <a href="http://geek.hubkey.com/2007/10/multi-line-text-box-and-its-malcontents_12.html">Part II</a> I posted about the problem caused by the static size of the InfoPath Forms Services multi-line text box. Generally the workaround is to use the rich text control, and in fact this is the workaround suggested by Microsoft for a separate issue - <a href="http://support.microsoft.com/kb/931426">KB931426</a> - whereby the malformed content of a multi-line text box (actually just any old words that include a space) can cause Forms Services to lose it when the form has been designed to be submitted via email. <br /><br />You'll know something's up when you get the message "There has been an error while processing the form." returned to the browser, along with "Exception Message: Reference to undeclared entity 'nbsp'" or "System.Xml.XmlException: Reference to undeclared entity 'nbsp'" in the diagnostic log.<br /><br />So the suggested workaround is to change your schema and use the rich edit control. If you'd really rather not do this, there is actually an alternative method. If the text box doesn't contain spaces - no issue, so the workaround is to strip the text box of spaces, replace it with something that looks like a space (ASCII 160 - the code for the HTML non-breaking space character '&nbsp;'), submit the form using your email data connection, then reverse out the character replacement. <br /><br />Easy enough. You can even do all this through rules. <a href="http://blogs.msdn.com/infopath/archive/2005/03/04/385577.aspx">This post</a> on the InfoPath Team Blog demonstrates a method for using a secondary data source to reference non printable characters (in this case to insert carriage return / line feed characters). First up, you'll want to add a resource file with the following content (the only attribute that you'll actually be using is the nbsp - the others are just for fun)...<br /><p style="LINE-HEIGHT: normal"><span style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: 'Courier New'"><?</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">xml</span> <span style="FONT-SIZE: 10pt; COLOR: #ff0000; FONT-FAMILY: 'Courier New'">version</span><span style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: 'Courier New'">=</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<span style="COLOR: #0000ff">1.0</span>" <span style="COLOR: #ff0000">encoding</span><span style="COLOR: #0000ff">=</span>"<span style="COLOR: #0000ff">UTF-8</span>"<span style="COLOR: #0000ff">?></span><br /><p style="LINE-HEIGHT: normal"><span style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: 'Courier<br />New'"><</span><span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'">characters</span> <span style="FONT-SIZE: 10pt; COLOR: #ff0000; FONT-FAMILY: 'Courier New'">cr</span><span style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: 'Courier New'">=</span><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<span style="COLOR: #ff0000">&#xD;</span>" <span style="COLOR: #ff0000">lf</span><span style="COLOR: #0000ff">=</span>"<span style="COLOR: #ff0000">&#xA;</span>" <span style="COLOR: #ff0000">crlf</span><span style="COLOR: #0000ff">=</span>"<span style="COLOR: #ff0000">&#xD;&#xA;</span>" <span style="COLOR: #ff0000">nbsp</span><span style="COLOR: #0000ff">=</span>"<span style="COLOR: #ff0000">&#xA0;</span>"<span style="COLOR: #0000ff"> /></span></span></p><br /></span></p><br />Next, edit the form's submit options to submit using custom rules and add a rule that has a series of actions that first strips the spaces, e.g. set each multi-line text box field's value with a formula like the following, using the technique from the Team Blog post: <br /><br />translate(<span style="TEXT-DECORATION: underline">address</span>, " ", <span style="TEXT-DECORATION: underline">@nbsp</span>) <br /><br />Follow these actions with an action that submits the form.<br /><br />Lastly, add however many "Set a field's value" actions as required to reverse out the character replacement, e.g. using a formula like: <br /><br />translate(<span style="TEXT-DECORATION: underline">address</span>, <span style="TEXT-DECORATION: underline">@nbsp</span>, " ")txs8311http://www.blogger.com/profile/07046898420109468604noreply@blogger.com3