<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5495217247354866797</id><updated>2024-11-01T11:49:47.685+01:00</updated><category term="SharePoint 2007"/><category term="List"/><category term="MOSS 2007"/><category term="sharepoint"/><category term="workflow"/><category term="InfoPath"/><title type='text'>Antoine.MOSS2007</title><subtitle type='html'>Le blog pédagogique sur SharePoint 2007 (MOSS et Services)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-1438131321598778350</id><published>2009-11-06T14:50:00.001+01:00</published><updated>2009-11-06T14:56:52.551+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharepoint"/><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>How To Delete an “Orphan” Content Type?</title><content type='html'>&lt;h4&gt;Problem&lt;/h4&gt;  &lt;p&gt;I created a set of content types from a feature and after the installation, activation of this feature, I used (in list or document libraries) all content types contained in this feature but one, called CT1 for instance&lt;/p&gt;  &lt;p&gt;After a while, I wanted to remove the never used content type, so I modified the feature, removed the content type CT1 from it, reinstalled the feature.&lt;/p&gt;  &lt;p&gt;The content type CT1 was still in the content types list! Ok, no problem, from the UI I click on delete this content type, and…&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1CHkcK1LUq4fgGBPEpOfgGosfr6AsBsjEA74moePw99IXjpFn3alIWodEYZoXyw3XWS9379RIt4_9hYMG9yePLXAuN43MeBLv2-tqPp7Ejcmi-Ll4KinLxEPakdFgE9KlSooZTb5o2Q/s1600-h/image%5B13%5D.png&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidXfchbowsZxl0BjTJgElwA_6JoIzjWancuK2q0fNzjOJzhkYFgSn11Cy_SxIRUGZV0rK55A7WgA5A__Dc1pmEW-lZ0uJFyiVIepoP_HUBosDInlOaCS_swYlceVUJTDACnfm1XWQdxw/?imgmax=800&quot; width=&quot;640&quot; height=&quot;171&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;strong&gt;The content type &amp;quot;CT1&amp;quot; is part of an application feature.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;What a message! I removed it from the feature, but still, I have this error. I googled a lot and with the help of &lt;a href=&quot;http://blog.thekid.me.uk/archive/2008/11/03/a-tip-when-looking-at-the-sharepoint-content-db.aspx&quot; target=&quot;_blank&quot;&gt;Vincent Rothwell&lt;/a&gt; I finally found a solution, not Microsoft allowed, but efficient!&lt;/p&gt;  &lt;h4&gt;Solution&lt;/h4&gt;  &lt;p&gt;First, I checked if the content type was not used somewhere in a site (see &lt;a href=&quot;http://blog.thekid.me.uk/archive/2008/11/03/a-tip-when-looking-at-the-sharepoint-content-db.aspx&quot; target=&quot;_blank&quot;&gt;Vincent Rothwell&lt;/a&gt; article)&lt;/p&gt;  &lt;p&gt;Then I went to the DB and in the ContentTypes table, you can filter the CT you want with:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;   &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;     &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; [SiteId]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[&lt;span style=&quot;color: #0000ff&quot;&gt;Class&lt;/span&gt;]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[&lt;span style=&quot;color: #0000ff&quot;&gt;Scope&lt;/span&gt;]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,sys.fn_varbintohexstr([ContentTypeId]) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; CT&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[Version]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[NextChildByte]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[&lt;span style=&quot;color: #0000ff&quot;&gt;Size&lt;/span&gt;]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[Definition]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[ResourceDir]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;      ,[IsFromFeature]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;  &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; [SharePoint - 27235].[dbo].[ContentTypes]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;where&lt;/span&gt; (sys.fn_varbintohexstr(ContentTypeId) &lt;span style=&quot;color: #0000ff&quot;&gt;LIKE&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&#39;0x0101EF0201%&#39;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Because I defined the CT, I knew the ContentTypeId. And I used &lt;em&gt;sys.fn_varbintohexstr()&lt;/em&gt; because the &lt;em&gt;ContentTypeId&lt;/em&gt; is of type &lt;em&gt;tContentTypeId&lt;/em&gt; which is a &lt;em&gt;varbinary(512)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the result, you can see the column &lt;em&gt;IsFromFeature&lt;/em&gt; set to &lt;strong&gt;1&lt;/strong&gt;. This means your CT belongs to a feature

  &lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLvJFhnQyffmZyjF-aJ4XmuXQlWY_xnw14b8XgASMlrwL7f68ARIj4ju39-LTCaICl-JAaKLPm7yQQ0E9rPixCgp49B3Y8d25wyxTHsRTcIekNu0o-Havrq_PIakhhkl5uT2Nno-xx0w/s1600-h/image%5B8%5D.png&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy8SwEwekhuiRaPeKEwzSmVxOdjMIDS-hFYBSbuVd-kSIRGi_8aEq41I8GpuKQPqnU2ryp2YA4IOSIvhGP0KT-u33_Q8K-ina68lk_Kr-HkagM0kOyR0wTtVD3gumQq2LeOb_P6d99TQ/?imgmax=800&quot; width=&quot;483&quot; height=&quot;173&quot; /&gt;&lt;/a&gt; So one solution was to change the value of &lt;em&gt;IsFromFeature&lt;/em&gt; to &lt;strong&gt;0&lt;/strong&gt;, in order to “fake” SharePoint. &lt;/p&gt;

&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;
  &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;
    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;Update&lt;/span&gt; [SharePoint - 27235].[dbo].[ContentTypes] &lt;span style=&quot;color: #0000ff&quot;&gt;set&lt;/span&gt; [IsFromFeature] = 0 &lt;span style=&quot;color: #0000ff&quot;&gt;where&lt;/span&gt; (sys.fn_varbintohexstr(ContentTypeId) &lt;span style=&quot;color: #0000ff&quot;&gt;LIKE&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&#39;0x0101EF0201%&#39;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Then I could delete the content type CT1 directly from the UI!&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/1438131321598778350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/1438131321598778350' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1438131321598778350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1438131321598778350'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2009/11/how-to-delete-orphan-content-type.html' title='How To Delete an “Orphan” Content Type?'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidXfchbowsZxl0BjTJgElwA_6JoIzjWancuK2q0fNzjOJzhkYFgSn11Cy_SxIRUGZV0rK55A7WgA5A__Dc1pmEW-lZ0uJFyiVIepoP_HUBosDInlOaCS_swYlceVUJTDACnfm1XWQdxw/s72-c?imgmax=800" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-7531665781993814120</id><published>2009-01-05T15:48:00.000+01:00</published><updated>2009-07-23T16:49:22.083+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>How do I manage a Farm level counter in SharePoint?</title><content type='html'>&lt;p&gt;Recently, I had to add a counter into a metadata for each document added in all documents libraries in a SharePoint farm. This counter is composed of several text identifiers plus a number (a chrono). This number is incremented automatically each time a new document is added.    &lt;br /&gt;For instance, a generated code is 2-45-IT-TXT-0110000 and the next one will be 2-45-IT-TXT-0110001 or 2-C-IT-TXT-0110001. So the number is incremented, which wouldn’t be a big deal with the help of an Event Receiver in every document library.&lt;/p&gt;  &lt;p&gt;But, &lt;strong&gt;where&lt;/strong&gt; to store this number?&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;It must be accessible by every document library &lt;/li&gt;    &lt;li&gt;It must be accessible by every site and site collection &lt;/li&gt;    &lt;li&gt;It must be accessible by every web application in the farm. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So, one solution could be to store it directly in the database, but I’m not fond of creating a database and a table for one field!&lt;/p&gt;  &lt;p&gt;Not a good idea! Can’t we store this information directly in SharePoint, at a farm level? I googled a bit (a lot :-)) and found this interesting &lt;a href=&quot;http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=271&quot; target=&quot;_blank&quot;&gt;article&lt;/a&gt; from &lt;a href=&quot;http://www.bluedoglimited.com/SharePointThoughts/default.aspx&quot; target=&quot;_blank&quot;&gt;Maurice Prather&lt;/a&gt;. And I read a little bit more with &lt;a href=&quot;http://community.zevenseas.com/Blogs/Robin/archive/2008/09/10/i%E2%80%99d-wish-i-knew-about-the-sppersistedobject-a-bit-earlier-.aspx&quot; target=&quot;_blank&quot;&gt;Robin Meure&lt;/a&gt;. Obviously I went also to msdn for the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.sppersistedobject.properties.aspx&quot; target=&quot;_blank&quot;&gt;SPPersistedObject&lt;/a&gt; definition. So you can read all of this for understanding the mechanism. I prefer to focus this blog on &lt;em&gt;how did I put everything in place?&lt;/em&gt; :-)&lt;/p&gt;  &lt;h3&gt;After the theory… the code!&lt;/h3&gt;  &lt;p&gt;I have created a form in the SCAW where I can set the first value of the chrono and the datacenter it belongs to. In my architecture, a datacenter is a farm. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEice42ruwNk17f23m1KwMUWkuo4gZSu_kS-LZ4m1BtmW84E4w4iIVKFJUuNgdpTzmxMZPW4_AxIYdr1kWsqfxck_tpzUk3TP5NgJ03kNySGthhcfyRVuUO7Ptm1gONC15T-3JkHaXArKw/s1600-h/image8.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgi-xSXcG-d_uMKfxHBM0qdja_H6XhhgBtAOX8DKJAH7KKqIJbuMHfE-38yiS1f2nVA4n0pXJURSp_iwnVzrU-YePfpx0U9nE4A6hGIw7_NxZxF5ZNk4at29S54iNoZl4veGPnaWT0Hw/?imgmax=800&quot; width=&quot;493&quot; height=&quot;144&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;div&gt;The chrono value and the datacenter value are stored in a Chrono object&lt;/div&gt;  &lt;div&gt;&lt;/div&gt;  &lt;div class=&quot;csharpcode&quot;&gt;&lt;/div&gt; &lt;style type=&quot;text/css&quot;&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, &quot;Courier New&quot;, courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div id=&quot;codeSnippetWrapper&quot;&gt;   &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;     &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Administration;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum6&quot;&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum7&quot;&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum8&quot;&gt;   8:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;namespace&lt;/span&gt; apichot.SharePoint.Administration&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum9&quot;&gt;   9:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum10&quot;&gt;  10:&lt;/span&gt;     [System.Runtime.InteropServices.GuidAttribute(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;BECCB1FC-3B63-45b5-937C-EB5324E6D9BB&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum11&quot;&gt;  11:&lt;/span&gt;     &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; Chrono : SPPersistedObject&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum12&quot;&gt;  12:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum13&quot;&gt;  13:&lt;/span&gt;         [Persisted]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum14&quot;&gt;  14:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; _currentChrono = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum15&quot;&gt;  15:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum16&quot;&gt;  16:&lt;/span&gt;         [Persisted]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum17&quot;&gt;  17:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; _dataCenter = 0;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum18&quot;&gt;  18:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum19&quot;&gt;  19:&lt;/span&gt;         &lt;span style=&quot;color: #008000&quot;&gt;//Two constructors for the serialization&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum20&quot;&gt;  20:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; Chrono()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum21&quot;&gt;  21:&lt;/span&gt;         { ;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum22&quot;&gt;  22:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum23&quot;&gt;  23:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; Chrono(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; name, SPPersistedObject parent, Guid guid)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum24&quot;&gt;  24:&lt;/span&gt;             : &lt;span style=&quot;color: #0000ff&quot;&gt;base&lt;/span&gt;(name, parent, guid)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum25&quot;&gt;  25:&lt;/span&gt;         { ;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum26&quot;&gt;  26:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum27&quot;&gt;  27:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; DisplayName&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum28&quot;&gt;  28:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum29&quot;&gt;  29:&lt;/span&gt;             get&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum30&quot;&gt;  30:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum31&quot;&gt;  31:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Format(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ReferenceCode Chrono (DC{0})&amp;quot;&lt;/span&gt;,_dataCenter);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum32&quot;&gt;  32:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum33&quot;&gt;  33:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum34&quot;&gt;  34:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum35&quot;&gt;  35:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; CurrentChrono&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum36&quot;&gt;  36:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum37&quot;&gt;  37:&lt;/span&gt;             get&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum38&quot;&gt;  38:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum39&quot;&gt;  39:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; _currentChrono;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum40&quot;&gt;  40:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum41&quot;&gt;  41:&lt;/span&gt;             set&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum42&quot;&gt;  42:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum43&quot;&gt;  43:&lt;/span&gt;                 _currentChrono = &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum44&quot;&gt;  44:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum45&quot;&gt;  45:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum46&quot;&gt;  46:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; DataCenter&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum47&quot;&gt;  47:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum48&quot;&gt;  48:&lt;/span&gt;             get&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum49&quot;&gt;  49:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum50&quot;&gt;  50:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; _dataCenter;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum51&quot;&gt;  51:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum52&quot;&gt;  52:&lt;/span&gt;             set&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum53&quot;&gt;  53:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum54&quot;&gt;  54:&lt;/span&gt;                 _dataCenter = &lt;span style=&quot;color: #0000ff&quot;&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum55&quot;&gt;  55:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.Name = &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Format(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ReferenceCodeChronoDC{0}&amp;quot;&lt;/span&gt;,_dataCenter);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum56&quot;&gt;  56:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum57&quot;&gt;  57:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum58&quot;&gt;  58:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum59&quot;&gt;  59:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This class inherit from SPPersistedObject and properties are set as “Persisted” in order to be stored in the SPFarm.Properties property bag. &lt;/p&gt;

&lt;p&gt;I also created a static class for managing the chrono:&lt;/p&gt;

&lt;div id=&quot;codeSnippetWrapper&quot;&gt;
  &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;
    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Administration;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum6&quot;&gt;   6:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum7&quot;&gt;   7:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Security.Principal;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum8&quot;&gt;   8:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Configuration;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum9&quot;&gt;   9:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Threading;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum10&quot;&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum11&quot;&gt;  11:&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;namespace&lt;/span&gt; apichot.SharePoint.Administration&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum12&quot;&gt;  12:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum13&quot;&gt;  13:&lt;/span&gt;     &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; ManageChrono&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum14&quot;&gt;  14:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum15&quot;&gt;  15:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; CHRONO_GUID = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;BECCB1FC-3B63-45b5-937C-EB5324E6D9BB&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum16&quot;&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum17&quot;&gt;  17:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; Chrono InitChrono(SPSite currentSite)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum18&quot;&gt;  18:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum19&quot;&gt;  19:&lt;/span&gt;             Chrono _chrono = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum20&quot;&gt;  20:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum21&quot;&gt;  21:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum22&quot;&gt;  22:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (currentSite == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum23&quot;&gt;  23:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum24&quot;&gt;  24:&lt;/span&gt;                     &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Exception(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Please initialize the site before&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum25&quot;&gt;  25:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum26&quot;&gt;  26:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (_chrono == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum27&quot;&gt;  27:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum28&quot;&gt;  28:&lt;/span&gt;                     SPFarm farm = currentSite.WebApplication.Farm;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum29&quot;&gt;  29:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum30&quot;&gt;  30:&lt;/span&gt;                     _chrono = farm.GetChild&amp;lt;Chrono&amp;gt;(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ReferenceCodeChronoDC1&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum31&quot;&gt;  31:&lt;/span&gt;                     &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (_chrono == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum32&quot;&gt;  32:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum33&quot;&gt;  33:&lt;/span&gt;                         _chrono = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Chrono(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ReferenceCodeChronoDC1&amp;quot;&lt;/span&gt;, farm, &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Guid(CHRONO_GUID));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum34&quot;&gt;  34:&lt;/span&gt;                         _chrono.Update();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum35&quot;&gt;  35:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum36&quot;&gt;  36:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum37&quot;&gt;  37:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum38&quot;&gt;  38:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum39&quot;&gt;  39:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum40&quot;&gt;  40:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; SPException(ex.Message);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum41&quot;&gt;  41:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum42&quot;&gt;  42:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; _chrono;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum43&quot;&gt;  43:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum44&quot;&gt;  44:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum45&quot;&gt;  45:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; GetChronoCode(SPSite currentSite)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum46&quot;&gt;  46:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum47&quot;&gt;  47:&lt;/span&gt;             Chrono _chrono = InitChrono(currentSite);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum48&quot;&gt;  48:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; formatCode(_chrono.DataCenter, _chrono.CurrentChrono);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum49&quot;&gt;  49:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum50&quot;&gt;  50:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; GetChronoIncremented(SPSite currentSite)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum51&quot;&gt;  51:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum52&quot;&gt;  52:&lt;/span&gt;             Impersonator user = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum53&quot;&gt;  53:&lt;/span&gt;             Chrono _chrono = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum54&quot;&gt;  54:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum55&quot;&gt;  55:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum56&quot;&gt;  56:&lt;/span&gt;                 user = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Impersonator(ConfigurationSettings.AppSettings[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Impersonator User&amp;quot;&lt;/span&gt;], ConfigurationSettings.AppSettings[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Impersonator Domain&amp;quot;&lt;/span&gt;], ConfigurationSettings.AppSettings[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Impersonator Pwd&amp;quot;&lt;/span&gt;]);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum57&quot;&gt;  57:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; i = 0; i &amp;lt; 5; i++)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum58&quot;&gt;  58:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum59&quot;&gt;  59:&lt;/span&gt;                     &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum60&quot;&gt;  60:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum61&quot;&gt;  61:&lt;/span&gt;                         user.Impersonate();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum62&quot;&gt;  62:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum63&quot;&gt;  63:&lt;/span&gt;                     &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception ex)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum64&quot;&gt;  64:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum65&quot;&gt;  65:&lt;/span&gt;                         Thread.Sleep(100);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum66&quot;&gt;  66:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum67&quot;&gt;  67:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum68&quot;&gt;  68:&lt;/span&gt;                 &lt;span style=&quot;color: #008000&quot;&gt;// Thread is now impersonating&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum69&quot;&gt;  69:&lt;/span&gt;                 _chrono = InitChrono(currentSite);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum70&quot;&gt;  70:&lt;/span&gt;                 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum71&quot;&gt;  71:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (_chrono != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum72&quot;&gt;  72:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum73&quot;&gt;  73:&lt;/span&gt;                     _chrono.CurrentChrono++;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum74&quot;&gt;  74:&lt;/span&gt;                     _chrono.Update(&lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum75&quot;&gt;  75:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum76&quot;&gt;  76:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum77&quot;&gt;  77:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum78&quot;&gt;  78:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum79&quot;&gt;  79:&lt;/span&gt;                 &lt;span style=&quot;color: #008000&quot;&gt;// Prevent exceptions propagating.&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum80&quot;&gt;  80:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum81&quot;&gt;  81:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;finally&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum82&quot;&gt;  82:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum83&quot;&gt;  83:&lt;/span&gt;                 &lt;span style=&quot;color: #008000&quot;&gt;// Ensure impersonation is reverted&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum84&quot;&gt;  84:&lt;/span&gt;                 &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (user != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum85&quot;&gt;  85:&lt;/span&gt;                     user.Undo();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum86&quot;&gt;  86:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum87&quot;&gt;  87:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; formatCode(_chrono.DataCenter, _chrono.CurrentChrono);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum88&quot;&gt;  88:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum89&quot;&gt;  89:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; Chrono GetChronoObject(SPSite currentSite)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum90&quot;&gt;  90:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum91&quot;&gt;  91:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; InitChrono(currentSite);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum92&quot;&gt;  92:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum93&quot;&gt;  93:&lt;/span&gt;         &lt;span style=&quot;color: #0000ff&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; formatCode(&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; dc, &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; counter)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum94&quot;&gt;  94:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum95&quot;&gt;  95:&lt;/span&gt;             &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Format(&lt;span style=&quot;color: #006080&quot;&gt;@&amp;quot;{0:00}{1:00000}&amp;quot;&lt;/span&gt;, dc, counter);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum96&quot;&gt;  96:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum97&quot;&gt;  97:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum98&quot;&gt;  98:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;u&gt;&lt;em&gt;Line 17&lt;/em&gt;&lt;/u&gt;: &lt;strong&gt;InitChrono&lt;/strong&gt; makes all the work. It gets the &lt;strong&gt;SPSite&lt;/strong&gt; as a parameter, and from it, retrieves the &lt;strong&gt;SPFarm&lt;/strong&gt; it belongs to. Then I get the &lt;strong&gt;chrono&lt;/strong&gt; (if it exists) under the “ReferenceCodeChronoDC1” tag. In my case, this method is called only from the administration page. So I don’t need to take care of access rights here.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;em&gt;Line 50&lt;/em&gt;&lt;/u&gt;: &lt;strong&gt;GetChronoIncremented&lt;/strong&gt;. This part is accessible by every user able to add a new document in a document library. And because I don’t want to give access to the SCAW to all users !-(, I impersonate the connection. I use the “Impersonator” from &lt;a href=&quot;http://www.15seconds.com/Issue/040511.htm&quot; target=&quot;_blank&quot;&gt;Jay Nathan&lt;/a&gt; because it works fine :-) Certainly better than &lt;strong&gt;SPSecurity.RunWithElevatedPrivileges&lt;/strong&gt; ! Don’t forget that we have to read &lt;u&gt;and&lt;/u&gt; write the &lt;strong&gt;Chrono&lt;/strong&gt; object inside the &lt;strong&gt;SPFarm&lt;/strong&gt; properties 

  &lt;br /&gt;Because sometimes (rarely) in my architecture the impersonation can’t be done the first time, I made this little loop (line 57)&lt;/p&gt;

&lt;p&gt;Line 69: I get the &lt;strong&gt;Chrono&lt;/strong&gt; object retrieved from the &lt;strong&gt;SPFarm&lt;/strong&gt; properties&lt;/p&gt;

&lt;p&gt;Line 73: I increment the &lt;strong&gt;Chrono&lt;/strong&gt; and save it&lt;/p&gt;

&lt;p&gt;Line 87: returns the chrono string in a good format (Datacenter + number)&lt;/p&gt;

&lt;p&gt;From the &lt;strong&gt;ItemAdded&lt;/strong&gt; event receiver in a document library I use this &lt;strong&gt;Chrono&lt;/strong&gt; like this:&lt;/p&gt;

&lt;div id=&quot;codeSnippetWrapper&quot;&gt;
  &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._RefCode += &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt; + ManageChrono.GetChronoIncremented(properties.ListItem.ParentList.ParentWeb.Site);&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception ex)&lt;br /&gt;{&lt;br /&gt;    SPEventLog.Write(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;CHRONO: &amp;quot;&lt;/span&gt; + ex.ToString());&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;By using the &lt;strong&gt;SPPersistedObject&lt;/strong&gt;, it is easy (:-)) to store properties accessible by all components of a &lt;strong&gt;SPFarm&lt;/strong&gt; without using external tricks.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/7531665781993814120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/7531665781993814120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/7531665781993814120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/7531665781993814120'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2009/07/how-do-i-manage-farm-level-counter-in.html' title='How do I manage a Farm level counter in SharePoint?'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgi-xSXcG-d_uMKfxHBM0qdja_H6XhhgBtAOX8DKJAH7KKqIJbuMHfE-38yiS1f2nVA4n0pXJURSp_iwnVzrU-YePfpx0U9nE4A6hGIw7_NxZxF5ZNk4at29S54iNoZl4veGPnaWT0Hw/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-6145753985655104298</id><published>2008-05-08T13:44:00.001+02:00</published><updated>2008-05-08T13:44:21.841+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="List"/><category scheme="http://www.blogger.com/atom/ns#" term="MOSS 2007"/><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>Sharepoint Item Update is a NIGHTMARE!</title><content type='html'>&lt;p&gt;What a strange statement!&lt;/p&gt;  &lt;p&gt;Why? &lt;/p&gt;  &lt;p&gt;Actually, using item updates is easy and you get what you want, your item updated. Right.    &lt;br /&gt;Let&#39;s try an example:     &lt;br /&gt;You have to create several items, in several content types, in several folders. Let&#39;s assume you want to have a kind of hierarchy like:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Folder 1 with a specific content type      &lt;ul&gt;       &lt;li&gt;Items with a specific content type inside this folder &lt;/li&gt;        &lt;li&gt;A new folder structure with a specific content type          &lt;ul&gt;           &lt;li&gt;Items inside this folder &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Logically, you use a code like the following for the folder:&lt;/p&gt;  &lt;div&gt;   &lt;pre class=&quot;csharpcode&quot;&gt;SPFolder ArchiveFolder = MonthFolder.SubFolders.Add(&lt;span class=&quot;kwrd&quot;&gt;&amp;quot;Folder 1&amp;quot;&lt;/span&gt;);
ArchiveFolder.UniqueContentTypeOrder = contentTypes;
ArchiveFolder.Update();

&lt;span class=&quot;rem&quot;&gt;//Process all about the folder item&lt;/span&gt;
ArchiveFolder.Item[&lt;span class=&quot;str&quot;&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;._PONumber;
ArchiveFolder.Item[&lt;span class=&quot;str&quot;&gt;&amp;quot;PONumber&amp;quot;&lt;/span&gt;] = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;._PONumber;
ArchiveFolder.Item[&lt;span class=&quot;str&quot;&gt;&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;] = ePOFolder.Id.ToString(); &lt;span class=&quot;rem&quot;&gt;// Fix the content type for the folder&lt;/span&gt;
ArchiveFolder.Item.Update();&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;And the following code for a document:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;SPFile &lt;/span&gt;fileH = HistoryFolder.Files.Add(&lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;.getUniqueFileName(), &lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;._docSize);
fileH.Update();
&lt;span style=&quot;color: green&quot;&gt;//Getthe item and fill it with history data, plus the content type id
&lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;SPListItem &lt;/span&gt;itemH = fileH.Item;
itemH[&amp;quot;Title&amp;quot;] = &amp;quot;TITRE&amp;quot;;
itemH[&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;] = historyCT.Id.ToString();
itemH.UpdateOverwriteVersion();&lt;/pre&gt;
&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;

&lt;p&gt;But all of this works fine if you have only a small number of items, ie less than let&#39;s say 50000 records in your list (not only in your container)&lt;/p&gt;

&lt;p&gt;If you are above this number of records, things start to be less fancy. One update takes 1 second, then 2 seconds, then 4 seconds, etc... I had the case with more than 120 000 records, and one update could take 1 or 2 minutes! Unbelievable.&lt;/p&gt;

&lt;p&gt;After googling and looking at my own experience (see &lt;a href=&quot;http://apichot.blogspot.com/2007/05/sharepoint-2007-upload-dun-document.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;) I&#39;ve solved one aspect, uploading documents with meta-data :&lt;/p&gt;

&lt;p&gt;First, store your item data into a Hashtable:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;Hashtable &lt;/span&gt;result = &lt;span style=&quot;color: blue&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;Hashtable&lt;/span&gt;();
result.Add(&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;,_PONumber); 
result.Add(&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;HistoryDescription&amp;quot;&lt;/span&gt;,_historyDescription);
result.Add(&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;HistoryOutcome&amp;quot;&lt;/span&gt;,_historyOutcome);
result.Add(&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;, CT_Id);&lt;/pre&gt;

&lt;p&gt;then use the corresponding overload of SPFiles.Add():&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;SPFile &lt;/span&gt;fileH = HistoryFolder.Files.Add(&lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;.getUniqueFileName(), &lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;._docSize, result);&lt;/pre&gt;
&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;

&lt;p&gt;And that&#39;s all! You don&#39;t need any update! It&#39;s automatically done! Great. It was not so obvious but there is an overload for this method.&lt;/p&gt;

&lt;p&gt;Now, what about folders. If you try SPFolders.Add()... you don&#39;t see any overload like with SPFiles. So you may think there is no way to use the same technic in order to avoid at least one Update (on item)?&lt;/p&gt;

&lt;p&gt;Well, have a look on the bad (un)documented property &amp;quot;Properties&amp;quot; of SPFolder: it is a Hashtable! So you can use the add method to add your items properties, then you only need one update, instead of two. Here is the previous code modifed:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;ArchiveFolder = MonthFolder.SubFolders.Add(&lt;span style=&quot;color: blue&quot;&gt;&amp;quot;Folder 1&amp;quot;&lt;/span&gt;);
ArchiveFolder.UniqueContentTypeOrder = contentTypes;
&lt;span style=&quot;color: green&quot;&gt;//Process all about the folder item
&lt;/span&gt;ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;._PONumber);
ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;PONumber&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;._PONumber);
ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #a31515&quot;&gt;&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;, ePOFolder.Id.ToString()); &lt;span style=&quot;color: green&quot;&gt;// Fix the content type for the folder
&lt;/span&gt;ArchiveFolder.Update();&lt;/pre&gt;
&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;

&lt;p&gt;Be aware of one thing: in &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.properties.aspx&quot; target=&quot;_blank&quot;&gt;Properties&lt;/a&gt; you can only add basic data type, like DateTime, String, Int... but no Double for instance. So be careful if you numeric data.&lt;/p&gt;

&lt;p&gt;Summary:&lt;/p&gt;

&lt;p&gt;We have now only one update for each folder and no more updates for documents. With my set of 120 000 rows, actually more than 500 000, it takes less than one second to add 2 folders and 12 documents. In one minute now I can process 70 times more documents and folders than before!&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;  </content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/6145753985655104298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/6145753985655104298' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/6145753985655104298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/6145753985655104298'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2008/05/sharepoint-item-update-is-nightmare.html' title='Sharepoint Item Update is a NIGHTMARE!'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-3271500386152890209</id><published>2008-04-16T15:24:00.000+02:00</published><updated>2008-05-09T15:26:37.928+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="List"/><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>SharePoint Folder, Sub-Folder and Content Type (part 2)</title><content type='html'>&lt;p&gt;In the previous &lt;a href=&quot;http://apichot.blogspot.com/2008/03/sharepoint-folder-sub-folder-and.html&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt; we saw how to make a folder hierarchy with there own content type, their own view and their own &amp;quot;New&amp;quot; menu from the user interface. The interesting part of this method is it is easy to implement with only a few clics. But the bad side of this method is we have to do this Folder/New Button implementation everytime we create a folder.&lt;/p&gt;  &lt;p&gt;One answer would be to make this implementation automatically each time we create a folder. It is possible with &lt;span style=&quot;color: #2b91af&quot;&gt;SPItemEventReceiver&lt;/span&gt;. But let&#39;s focus more on how to make this association from the SharePoint object model ?&lt;/p&gt;  &lt;p&gt;Let&#39;s say I want to have this kind of structure:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Year-Month folder      &lt;ul&gt;       &lt;li&gt;Archive Folder (with meta-data)          &lt;ul&gt;           &lt;li&gt;Document (with meta-data) &lt;/li&gt;            &lt;li&gt;History folder              &lt;ul&gt;               &lt;li&gt;List of history rows (with meta-data) &lt;/li&gt;             &lt;/ul&gt;           &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For example:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;2008-04      &lt;ul&gt;       &lt;li&gt;PO12345684          &lt;ul&gt;           &lt;li&gt;12345678.pdf &lt;/li&gt;            &lt;li&gt;History as of 2008-04-01              &lt;ul&gt;               &lt;li&gt;history row 1 &lt;/li&gt;                &lt;li&gt;history row 2 &lt;/li&gt;                &lt;li&gt;history row 3 &lt;/li&gt;             &lt;/ul&gt;           &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;2008-03      &lt;ul&gt;       &lt;li&gt;PO10000684          &lt;ul&gt;           &lt;li&gt;10000684.pdf &lt;/li&gt;            &lt;li&gt;History as of 2008-03-01              &lt;ul&gt;               &lt;li&gt;history row 1 &lt;/li&gt;                &lt;li&gt;history row 2 &lt;/li&gt;                &lt;li&gt;history row 3 &lt;/li&gt;             &lt;/ul&gt;           &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I have an Archive List where I&#39;ll store all these data. Each folder or document will have its own set of meta-data. We will use a Content Type for each of them. These CT are supposed to be implemented and attached to the Archive list.. The archive folder name will be the Purchase Order Number (PONumber). The PO will be copied from another list, Purchase Orders.&lt;/p&gt;  &lt;p&gt;Here is the code:&lt;/p&gt;  &lt;div&gt;   &lt;div class=&quot;csharpcode&quot;&gt;     &lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 400px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4&quot;&gt;       &lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System;
&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections;
&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Text;
&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; System.Diagnostics;
&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint;
&lt;span style=&quot;color: #0000ff&quot;&gt;using&lt;/span&gt; Microsoft.SharePoint.Workflow;

&lt;span style=&quot;color: #0000ff&quot;&gt;namespace&lt;/span&gt; APichot.Services
{

    &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; ArchiveData
    {
        &lt;span style=&quot;color: #008000&quot;&gt;//List and Content type names&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;//These names will be used to retrieve the content type in the Archive List&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _ArchiveList = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Archive&amp;quot;&lt;/span&gt;; &lt;span style=&quot;color: #008000&quot;&gt;//Name of the archive list&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _FolderYM = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Year-Month Folder&amp;quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _FolderCT = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Archive Folder&amp;quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _FolderHCT = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;History Folder&amp;quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _HistoryCT = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;History Data&amp;quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _purchOrderCT = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Purchase Order Archive&amp;quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _docCT = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Document&amp;quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #008000&quot;&gt;//Helper for various processes&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; HelperClass hc;

        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; SPListItem _item;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _PONumber = &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Empty;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; SPList _LstArchive;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; _RecordingDate = &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Empty;

        &lt;span style=&quot;color: #008000&quot;&gt;//Size of the fake document for history&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;byte&lt;/span&gt;[] _docSize = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;byte&lt;/span&gt;[1];
        &lt;span style=&quot;color: #008000&quot;&gt;//Name of the fake document&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; Guid _guid = Guid.NewGuid();
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt; _increment = 0;

        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// Get the current item to be moved to the archive list&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;param name=&amp;quot;item&amp;quot;&amp;gt;PO Item&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; ArchiveData(SPListItem item) {
            &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (item == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) {
                    &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; ArgumentNullException(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;item&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;This value cannot be null&amp;quot;&lt;/span&gt;);
                }
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item = item;
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item.Web.Lists[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._ArchiveList]; &lt;span style=&quot;color: #008000&quot;&gt;//this._item.Web.Lists[this._ArchiveList];&lt;/span&gt;
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;PONumber&amp;quot;&lt;/span&gt;].ToString();
                &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.IsNullOrEmpty(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber)) {
                    &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Exception(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;PONumber cannot be null or empty&amp;quot;&lt;/span&gt;);
                }
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception x) {
                Utilities.logMessage(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Event Source&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Archive Data&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Constructor&amp;quot;&lt;/span&gt;, x.ToString(), EventLogEntryType.Error, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber);
            }
        }
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// Main method to save data to archive&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// Run the savePO() and saveHistory() methods&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;param name=&amp;quot;wp&amp;quot;&amp;gt;Current Workflow properties&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;param name=&amp;quot;hd&amp;quot;&amp;gt;All history data&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; saveToArchive(HelperClass hc) {
            &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (hc == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) {
                &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; ArgumentNullException(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;hc&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;This value cannot be null&amp;quot;&lt;/span&gt;);
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc = hc;
                SPFolder ArchiveFolder = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.savePO();
                &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (ArchiveFolder != &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; ArchiveFolder &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; SPFolder) {
                    &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.saveHistory(ArchiveFolder);
                }
                &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; {
                    &lt;span style=&quot;color: #0000ff&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; Exception(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ArchiveFolder is null or is not an SPFolder&amp;quot;&lt;/span&gt;);
                }
                &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;true&lt;/span&gt;;
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception x) {
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc.logMessage(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;saveToArchive&amp;quot;&lt;/span&gt;, x.ToString(), EventLogEntryType.Error);
                &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;false&lt;/span&gt;;
            }
        }
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// Save the PO to the Archive list&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #008000&quot;&gt;/// &amp;lt;returns&amp;gt;Return the archive folder generated to be used by the history folder as a parent folder&amp;lt;/returns&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; SPFolder savePO() {
            &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; whereIAm = &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Empty;
            &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                &lt;span style=&quot;color: #008000&quot;&gt;//Specify the content type to be attached to a folder&lt;/span&gt;
                SPContentType FolderYM = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._FolderYM];
                SPContentType Folder = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._FolderCT];
                SPContentType FolderH = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._FolderHCT];
                SPContentType eMailFolder = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._eMailFolderCT];
                SPContentType purchOrder = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._purchOrderCT];
                SPContentType doc = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._docCT];

                List&amp;lt;SPContentType&amp;gt; contentTypes = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; List&amp;lt;SPContentType&amp;gt;();

                &lt;span style=&quot;color: #008000&quot;&gt;//Get the item creation date, wich will become the Year/Month folder&lt;/span&gt;
                &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; currentMonthFolder = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.buildMonthFolderName();
                SPFolder MonthFolder;
                &lt;span style=&quot;color: #008000&quot;&gt;//If the folder already exists, get it, else create it&lt;/span&gt;
                whereIAm = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Month Folder&amp;quot;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                    MonthFolder = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.RootFolder.SubFolders[currentMonthFolder];
                }
                &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; {
                    &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc.logMessage(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;savMonthFolder&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Month folder creation (&amp;quot;&lt;/span&gt; + currentMonthFolder + &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;)&amp;quot;&lt;/span&gt;, EventLogEntryType.Information);
                    &lt;span style=&quot;color: #008000&quot;&gt;//Create the folder&lt;/span&gt;
                    MonthFolder = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.RootFolder.SubFolders.Add(currentMonthFolder);
                    &lt;span style=&quot;color: #008000&quot;&gt;//What goes into the New menu&lt;/span&gt;
                    contentTypes.Add(Folder);
                    &lt;span style=&quot;color: #008000&quot;&gt;//Associate the content type to the folder&lt;/span&gt;
                    MonthFolder.UniqueContentTypeOrder = contentTypes;
                    &lt;span style=&quot;color: #008000&quot;&gt;//Use the Properties Hashtable to store folder&#39;s meta-data &lt;/span&gt;
                    MonthFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;, currentMonthFolder);
                    MonthFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;, FolderYM.Id.ToString()); &lt;span style=&quot;color: #008000&quot;&gt;// Fix the content type for the folder&lt;/span&gt;
                    whereIAm = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Month Folder Update&amp;quot;&lt;/span&gt;;
                    MonthFolder.Item.Update();
                }

                SPFolder ArchiveFolder;
                whereIAm = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Archive Folder&amp;quot;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                    &lt;span style=&quot;color: #008000&quot;&gt;//If the folder doesn&#39;t exists, then go to Catch&lt;/span&gt;
                    ArchiveFolder = MonthFolder.SubFolders[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber];
                    &lt;span style=&quot;color: #008000&quot;&gt;//Because of international settings (french), the comma is interpreted as a thousand separator by the hastable.&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//We have to convert it to a period.&lt;/span&gt;
                    &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; poAmount = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POAmount&amp;quot;&lt;/span&gt;].ToString().Replace(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;.&amp;quot;&lt;/span&gt;);
                    ArchiveFolder.Properties[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POAmount&amp;quot;&lt;/span&gt;] =  (&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POAmount&amp;quot;&lt;/span&gt;] == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) ? &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt; : poAmount;
                    ArchiveFolder.Properties[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;VendorName&amp;quot;&lt;/span&gt;] =  (&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;VendorName&amp;quot;&lt;/span&gt;] == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) ? &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Empty : &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;VendorName&amp;quot;&lt;/span&gt;].ToString();
                    ArchiveFolder.Properties[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POStatus&amp;quot;&lt;/span&gt;] =  &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POStatus&amp;quot;&lt;/span&gt;].ToString();
                    &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc.logMessage(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;savArchive Folder&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Archive folder updated&amp;quot;&lt;/span&gt;, EventLogEntryType.Information);
                }
                &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; {
                    &lt;span style=&quot;color: #008000&quot;&gt;//Folder &lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//Process all about the folder&lt;/span&gt;
                    contentTypes = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; List&amp;lt;SPContentType&amp;gt;();
                    &lt;span style=&quot;color: #008000&quot;&gt;//What goes into the new menu&lt;/span&gt;
                    contentTypes.Add(purchOrder);
                    contentTypes.Add(doc);
                    contentTypes.Add(FolderH);
                    contentTypes.Add(eMailFolder);

                    ArchiveFolder = MonthFolder.SubFolders.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber);

                    ArchiveFolder.UniqueContentTypeOrder = contentTypes;
                    &lt;span style=&quot;color: #008000&quot;&gt;//Process all about the folder item&lt;/span&gt;
                    ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber);
                    ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;PONumber&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber);
                    &lt;span style=&quot;color: #008000&quot;&gt;//Because Properties accepts only int, string and date, and not Double, we must change PO Amount to a string&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//And transform the comma (decimal) into a period&lt;/span&gt;
                    &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; poAmount = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POAmount&amp;quot;&lt;/span&gt;].ToString().Replace(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;.&amp;quot;&lt;/span&gt;);
                    ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POAmount&amp;quot;&lt;/span&gt;, (&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POAmount&amp;quot;&lt;/span&gt;] == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) ? &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;0&amp;quot;&lt;/span&gt; : poAmount);
                    ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;VendorName&amp;quot;&lt;/span&gt;, (&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;VendorName&amp;quot;&lt;/span&gt;] == &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;) ? &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Empty : &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;VendorName&amp;quot;&lt;/span&gt;].ToString());
                    ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POStatus&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;POStatus&amp;quot;&lt;/span&gt;].ToString());
                    ArchiveFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;, Folder.Id.ToString()); &lt;span style=&quot;color: #008000&quot;&gt;// Fix the content type for the folder&lt;/span&gt;
                }
                whereIAm = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Archive Folder Update&amp;quot;&lt;/span&gt;;
                ArchiveFolder.Update();
                &lt;span style=&quot;color: #008000&quot;&gt;//Store a recording date for the History folder name&lt;/span&gt;
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._RecordingDate = DateTime.Now.ToShortDateString().Replace(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt;) + &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; + DateTime.Now.ToShortTimeString().Replace(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;:&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;h&amp;quot;&lt;/span&gt;);
                &lt;span style=&quot;color: #008000&quot;&gt;//Copy the PO into the new folder&lt;/span&gt;
                whereIAm = &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Copy file&amp;quot;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; destUrl = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item.Web.Site.Url + &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ParentWebUrl + ArchiveFolder.Url + &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt; + &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.buildName(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;PO&amp;quot;&lt;/span&gt;) + &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;.pdf&amp;quot;&lt;/span&gt;;
                &lt;span style=&quot;color: #008000&quot;&gt;//Copy the document from Purchase Order list to the Archive list, with meta-data&lt;/span&gt;
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item.File.CopyTo(destUrl);
                &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; ArchiveFolder;
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception x) {
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc.logMessage(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;savePO&amp;quot;&lt;/span&gt; + whereIAm, x.ToString(), EventLogEntryType.Error);
                &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;
            }
        }
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; saveHistory(SPFolder ArchiveFolder) {
            &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                &lt;span style=&quot;color: #008000&quot;&gt;//Create History Folder&lt;/span&gt;
                &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; hFolderName = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.buildName(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;History&amp;quot;&lt;/span&gt;); 
                SPFolder HistoryFolder = ArchiveFolder.SubFolders.Add(hFolderName);
                List&amp;lt;SPContentType&amp;gt; contentTypes = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; List&amp;lt;SPContentType&amp;gt;();
                &lt;span style=&quot;color: #008000&quot;&gt;//CT for the folder&lt;/span&gt;
                SPContentType historyFolderCT = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._FolderHCT];
                &lt;span style=&quot;color: #008000&quot;&gt;//CT for the files inside the folder&lt;/span&gt;
                SPContentType historyCT = &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._LstArchive.ContentTypes[&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._HistoryCT];
                &lt;span style=&quot;color: #008000&quot;&gt;//In this folder, we will be able to create only History Data&lt;/span&gt;
                contentTypes.Add(historyCT);

                HistoryFolder.UniqueContentTypeOrder = contentTypes;
                HistoryFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Title&amp;quot;&lt;/span&gt;, hFolderName);
                HistoryFolder.Properties.Add(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;ContentTypeId&amp;quot;&lt;/span&gt;, historyFolderCT.Id.ToString());
                HistoryFolder.Update();

                historyFolderCT = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;
                &lt;span style=&quot;color: #008000&quot;&gt;//Store history rows&lt;/span&gt;
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.storeHistoryRows(HistoryFolder, historyCT);
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception x) {
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc.logMessage(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;saveHistory&amp;quot;&lt;/span&gt;, x.ToString(), EventLogEntryType.Error);
            }
        }
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;void&lt;/span&gt; storeHistoryRows(SPFolder HistoryFolder, SPContentType historyCT) {
            &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                &lt;span style=&quot;color: #008000&quot;&gt;//Reset the increment number for the UniqueFileName&lt;/span&gt;
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._increment = 0;
                &lt;span style=&quot;color: #0000ff&quot;&gt;foreach&lt;/span&gt; (historyData hdata &lt;span style=&quot;color: #0000ff&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc.HistoryDataCollection.ListOfHistoryData) {
                    &lt;span style=&quot;color: #008000&quot;&gt;//Prepare a fake file for storing each history line as in a custom list. Manadatory for a docLib&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//hData.FillItem methos is:&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;// public Hashtable FillItem(string CT_Id) {&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    Hashtable result = new Hashtable();&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    result.Add(&amp;quot;Title&amp;quot;,_PONumber); &lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    result.Add(&amp;quot;PONumber&amp;quot;,_PONumber);&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    result.Add(&amp;quot;HistoryDescription&amp;quot;,_historyDescription);&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    result.Add(&amp;quot;HistoryOutcome&amp;quot;,_historyOutcome);&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    result.Add(&amp;quot;WFStart&amp;quot;,_eventDate);&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    result.Add(&amp;quot;ApproversName&amp;quot;,_approver);&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    result.Add(&amp;quot;ContentTypeId&amp;quot;, CT_Id);&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//    return result;&lt;/span&gt;
                    &lt;span style=&quot;color: #008000&quot;&gt;//}&lt;/span&gt;
                    SPFile fileH = HistoryFolder.Files.Add(&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.getUniqueFileName(), &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._docSize, hdata.FillItem(historyCT.Id.ToString()));
                    fileH = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;
                }
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception x) {
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;.hc.logMessage(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;storeHistoryRows&amp;quot;&lt;/span&gt;, x.ToString(), EventLogEntryType.Error);
            }
        }

        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; buildName(&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; s) {
            &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._PONumber + &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; + s.Trim() + &lt;span style=&quot;color: #006080&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; + &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._RecordingDate;
        }
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; getUniqueFileName() {
            &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._increment == 0) {
                &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._guid = Guid.NewGuid();
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._increment++;
            &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Format(&lt;span style=&quot;color: #006080&quot;&gt;@&amp;quot;{0}-{1:00}.txt&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._guid.ToString(), &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._increment);
        }
        &lt;span style=&quot;color: #0000ff&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; buildMonthFolderName() {
            &lt;span style=&quot;color: #008000&quot;&gt;//Get the item creation date, wich will become the Year/Month folder&lt;/span&gt;
            DateTime itemCreate = (DateTime) &lt;span style=&quot;color: #0000ff&quot;&gt;this&lt;/span&gt;._item[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Created&amp;quot;&lt;/span&gt;];
            &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Format(&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;{0} - {1:00}&amp;quot;&lt;/span&gt;, itemCreate.Year, itemCreate.Month);
        }
    }
}&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt; As you can see there are some tricky things:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;For the New button, you have to prepare a List&amp;lt;&amp;gt; with &lt;span style=&quot;color: #2b91af&quot;&gt;SPContentType &lt;/span&gt;and add this list to the folder&#39;s UniqueContentTypeOrder property.&lt;/li&gt;

  &lt;li&gt;For setting meta-data to a folder it is actually worth to use the Folder&#39;s Properties property (see &lt;a href=&quot;http://apichot.blogspot.com/2008/05/sharepoint-item-update-is-nightmare.html&quot; target=&quot;_blank&quot;&gt;this post&lt;/a&gt;)&lt;/li&gt;

  &lt;li&gt;For inserting a file, it is actually worth to use a Hastable for meta-data associated with SPFile object (see &lt;a href=&quot;http://apichot.blogspot.com/2008/05/sharepoint-item-update-is-nightmare.html&quot; target=&quot;_blank&quot;&gt;this post&lt;/a&gt; again)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try to avoid as possible the number of updates you make in order to insert data faster. I&#39;ve explained it in this &lt;a href=&quot;http://apichot.blogspot.com/2008/05/sharepoint-item-update-is-nightmare.html&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I&#39;ve spent some time with this, I hope this helps.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/3271500386152890209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/3271500386152890209' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/3271500386152890209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/3271500386152890209'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2008/04/sharepoint-folder-sub-folder-and.html' title='SharePoint Folder, Sub-Folder and Content Type (part 2)'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-1912831224948499700</id><published>2008-03-21T16:40:00.000+01:00</published><updated>2008-03-22T16:41:20.624+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>Accélerez SharePoint: Purgez les logs !</title><content type='html'>&lt;p&gt;Lorsqu&#39;on utilise une configuration standard de SQL Server, les fichiers logs ne sont pas param&amp;#233;tr&amp;#233;s au mieux. Ceci &amp;#224; des incidences non n&amp;#233;gligeables sur les performances &amp;#224; venir de SharePoint. En effet, on peut noter que le fichier log de configuration (Config) de SharePoint &amp;#224; tendance &amp;#224; prendre de l&#39;embonpoint au fur et &amp;#224; mesure de son utlisation. Et bien entendu, les logs associ&amp;#233;s &amp;#224; votre ou vos ContentDB.&lt;/p&gt;  &lt;p&gt;Alors si cette gestion des logs n&#39;est pas optimis&amp;#233;e, voici une astuce qui permettra de faire un peu de place et de gagner en rapidit&amp;#233;. Cette astuce peut de toute fa&amp;#231;on &amp;#234;tre utilis&amp;#233;e, m&amp;#234;me si la gestion des logs est bien faite, cela n&#39;emp&amp;#234;che pas! Une bonne cure de printemps, c&#39;est le moment.&lt;/p&gt;  &lt;h4&gt;Comment faire ?&lt;/h4&gt;  &lt;p&gt;Tout d&#39;abord, il vaut mieux arr&amp;#234;ter quelques services, comme le timer et le search :&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NET STOP SPTIMERV3&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NET STOP OSEARCH&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;IISRESET&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Puis, personnellement, je pr&amp;#233;f&amp;#232;re faire comme si je voulais d&amp;#233;placer la base. Pour &amp;#233;viter que SharePoint se m&amp;#233;lange les pinceaux, et inonde l&#39;Event Viewer de messages pas tr&amp;#232;s catholiques, je fais un preparetomove :&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;stsadm -o preparetomove -contentdb SQLSERVERNAME:CONTENTDBNAME -site &lt;/strong&gt;&lt;a href=&quot;http://SITENAME&quot;&gt;&lt;strong&gt;http://SITENAME&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Ensuite, je vais dans SQL Server Management Studio pour d&amp;#233;tacher la base &lt;strong&gt;CONTENTDBNAME. &lt;/strong&gt;Assurez-vous que personne n&#39;est connect&amp;#233;.     &lt;br /&gt;Puis je retourne dans le file system pour renommer le fichier CONTENTDBNAME.LDF en... ce que vous voulez, mais il ne faut pas l&#39;effacer (pas encore)     &lt;br /&gt;Retour &amp;#224; nouveau dans SQL Server Management Studio pour attacher (Attach) la base CONTENTDBNAME, et, dans la fen&amp;#234;tre de confirmation qui appara&amp;#238;t, il faut mettre en surbrillance le nom du fichier log &amp;quot;Not Found&amp;quot; et cliquer sur le bouton Remove.     &lt;br /&gt;Ceci fait, cliquez sur Ok et la base est de retour.     &lt;br /&gt;Dans les propri&amp;#233;t&amp;#233;s de la base, vous pouvez maintenant voir que le fichier log est d&#39;environ 1Mo (cela varie selon la configuration de la DB) et vous pouvez ajuster sont incr&amp;#233;ment ainsi que sa limite maxi.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NET START SPTIMERV3&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NET START OSEARCH&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Ensuite, retourner sur votre site et... tout doit fonctionner correctement ! Si ce n&#39;est pas le cas, alors vous avez encore la possibilit&amp;#233; de renommer &amp;#224; nouveau l&#39;ancien log. Mais si tout fonctionne, alors vous pouvez supprimer les logs renomm&amp;#233;s.    &lt;br /&gt;Pour ma part, j&#39;ai fait cette op&amp;#233;ration chez un client qui avait deux logs de plus de 50Go pour des DB de 10Go. Et bien, &amp;#231;a a fait de la place, et il y a surtout eu un gain en rapidit&amp;#233; en lecture et &amp;#233;criture.     &lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/1912831224948499700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/1912831224948499700' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1912831224948499700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1912831224948499700'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2008/03/acclerez-sharepoint-purgez-les-logs.html' title='Accélerez SharePoint: Purgez les logs !'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-1161180067219276074</id><published>2008-03-20T13:04:00.002+01:00</published><updated>2008-03-20T13:13:05.913+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="List"/><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>Sharepoint: Accessing a List with it&amp;#39;s Internal Name</title><content type='html'>&lt;p&gt;Le probl&amp;#232;me pour acc&amp;#233;der aux listes SharePoint est qu&#39;on doit utiliser le nom &amp;quot;public&amp;quot; de la liste, le Title, et non le nom interne:&lt;/p&gt;  &lt;p&gt;Si je cr&amp;#233;e une liste en lui donnant le nom &amp;quot;MaListe&amp;quot;&amp;#160; puis je renomme cette liste en &amp;quot;Ma Liste&amp;quot;, alors la liste a deux noms:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Le nom interne, &lt;strong&gt;MaListe&lt;/strong&gt; (le premier cr&amp;#233;&amp;#233;) &lt;/li&gt;    &lt;li&gt;Le nom public, &lt;strong&gt;Ma Liste&lt;/strong&gt;, suite au renommage. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Si je veux acc&amp;#233;der &amp;#224; la liste par programme, je vais utiliser:&lt;/p&gt;  &lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: #2b91af&quot;&gt;SPList &lt;/span&gt;list = web.Lists[&amp;quot;Ma Liste&amp;quot;];&lt;/pre&gt;

&lt;p&gt;car la string demand&amp;#233;e par la &lt;strong&gt;Lists&lt;/strong&gt; correspond au champs &lt;strong&gt;Title&lt;/strong&gt; de la liste&lt;/p&gt;

&lt;p&gt;Mais si on consid&amp;#232;re que toute liste est un folder, alors on peut contourner le probl&amp;#232;me en passant par le SPFolder: 
&lt;/p&gt;

  &lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;enum&lt;/span&gt; ListType { CustomList, Document };&lt;/pre&gt;

  &lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; SPList GetListName(SPWeb web, ListType type, &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; InternalName) {
            &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt; {
                SPFolder folder = &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff&quot;&gt;switch&lt;/span&gt; (type) {
                    &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; ListType.CustomList:
                        folder = web.Folders[&lt;span style=&quot;color: #006080&quot;&gt;&amp;quot;Lists&amp;quot;&lt;/span&gt;].SubFolders[InternalName];
                        &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;
                    &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; ListType.Document:
                        folder = web.Folders[InternalName];
                        &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;
                    &lt;span style=&quot;color: #0000ff&quot;&gt;default&lt;/span&gt;:
                        &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;
                }
                SPList realList = web.Lists[folder.ParentListId];
                &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; realList;
            }
            &lt;span style=&quot;color: #0000ff&quot;&gt;catch&lt;/span&gt; (Exception x) {
                &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;null&lt;/span&gt;;
            }
        }&lt;/pre&gt;

&lt;p&gt;Lorsque vous cr&amp;#233;ez une liste, le premier nom que vous donnez devient le nom du folder et donc le nom interne qui ne changera plus. Ensuite, vous pouvez modifier le nom de la liste, mais c&#39;est le champ Title qui est affect&amp;#233;.&lt;/p&gt;

&lt;p&gt;J&#39;ai ici mis en avant l&#39;acc&amp;#232;s aux listes de type &amp;quot;Custom List&amp;quot;, qui sont des sous-folder de &amp;quot;Lists&amp;quot;, et des listes de type &amp;quot;Document&amp;quot;, dont le folder est directement en web root. 
  &lt;br /&gt;Une fois qu&#39;on a le folder, il suffit de r&amp;#233;cup&amp;#233;rer son ParentListId pour obtenir la liste associ&amp;#233;e.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/1161180067219276074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/1161180067219276074' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1161180067219276074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1161180067219276074'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2008/03/sharepoint-search-list-with-it-internal.html' title='Sharepoint: Accessing a List with it&amp;#39;s Internal Name'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-3429578141633951873</id><published>2008-03-13T17:13:00.002+01:00</published><updated>2009-01-16T18:23:14.464+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>SharePoint Folder, Sub-Folder and Content Type (part 1)</title><content type='html'>&lt;p&gt;Aujourd&#39;hui, je vais décrypter la façon dont on peut travailler avec les Folder et sous-folders dans SharePoint, tout en leur associant des Content Type.  
J&#39;ai partagé ce blog en deux : &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Partie 1 : comment faire via l&#39;interface utilisateur &lt;/li&gt;    &lt;li&gt;Partie 2 : comment utiliser ceci par programme &lt;/li&gt; &lt;/ul&gt;
Voici l&#39;énoncé du problème :   &lt;ul&gt;   &lt;li&gt;Dans une Document Library, je veux avoir des folders qui ont leurs propres meta données (appelons ces folder &quot;Folder Niveau 1&quot;) &lt;/li&gt;    &lt;li&gt;Au niveau root, je ne veux qu&#39;avoir la possiblité de créer des &quot;Folder Niveau 1&quot; &lt;/li&gt;    &lt;li&gt;Au niveau Root je veux avoir une seule vue qui me montre ces meta données &lt;/li&gt;    &lt;li&gt;En entrant dans un &quot;Folder Niveau 1&quot;, je veux avoir la possibilité de créer des Documents de type contrat et des &quot;Folder Niveau 2&quot; de type Folder &lt;/li&gt;    &lt;li&gt;Dans un &quot;Folder Niveau 1&quot;, je veux avoir une seule vue qui montre les meta données de Document &lt;/li&gt;    &lt;li&gt;Dans &quot;Folder Niveau 2&quot; je veux avoir une seule vue qui montre les meta données de Document &lt;/li&gt;    &lt;li&gt;Comment gérer ces folders par programmation &lt;em&gt;(partie 2)&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Résolution par l&#39;interface utilisateur&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Tout d&#39;abord, il faut créer les content type (CT). Un content type que l&#39;on crée via l&#39;IU va hériter de propriétés d&#39;un parent. Habituellement ce parent est un document, mais rien n&#39;empêche de prendre un Folder comme parent (après tout, c&#39;est aussi un content type)&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HbcNMxXI/AAAAAAAAAIw/zGu4dGV4nm8/s1600-h/CTCreation%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;CTCreation&quot; src=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HcMNMxYI/AAAAAAAAAI4/K0ixMN7JUws/CTCreation_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;128&quot; /&gt;&lt;/a&gt; 
Dans le site settings on trouve la gallerie des CT&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HcsNMxZI/AAAAAAAAAJA/sU9IYLbebGU/s1600-h/CTFolderNiv1%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;CTFolderNiv1&quot; src=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HdMNMxaI/AAAAAAAAAJI/LrxbP5QAmCw/CTFolderNiv1_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;221&quot; height=&quot;244&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Et on crée le premier CT, Folder Niveau 1. Il faut bien noter que le parent de ce CT est bien le Folder. Je mets le tout dans un group &quot;Folder Group&quot; (pas très inspiré aujourd&#39;hui...) &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HdsNMxbI/AAAAAAAAAJQ/Ik-Dv9jFcj8/s1600-h/CTFolderNiv1Cols%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;CTFolderNiv1Cols&quot; src=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HeMNMxcI/AAAAAAAAAJY/je3ybStyUXo/CTFolderNiv1Cols_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;136&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Ensuite, on rajoute quelques colonnes. Pour l&#39;exemple, je les ai prises dans les colonnes existantes.  
Il faut faire de même pour le CT &quot;Folder Niveau 2&quot;, mais cette fois je n&#39;ai pas pris de colonnes supplémentaires.   
Ensuite, il y a le CT pour le document de type contrat &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/Antoine.MOSS2007/SB1He8NMxdI/AAAAAAAAAJg/raJogZPW940/s1600-h/DocContract%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;DocContract&quot; src=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HfcNMxeI/AAAAAAAAAJo/anJ0SpqePXc/DocContract_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;218&quot; height=&quot;244&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Et les colonnes, prises aussi dans les colonnes existantes.  
&lt;a href=&quot;http://lh5.ggpht.com/Antoine.MOSS2007/SB1Hf8NMxfI/AAAAAAAAAJw/xPpy7YfsPKI/s1600-h/DocContractCols%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;DocContractCols&quot; src=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HgcNMxgI/AAAAAAAAAJ4/x3MOv9WCTjM/DocContractCols_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;151&quot; /&gt;&lt;/a&gt;   
Maintenant, il faut retourner dans la Document Library Settings (advanced), autoriser les Content Type,   
&lt;a href=&quot;http://lh5.ggpht.com/Antoine.MOSS2007/SB1Hg8NMxhI/AAAAAAAAAKA/rijA-j18U94/s1600-h/AuthoriseCT%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;AuthoriseCT&quot; src=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HhcNMxiI/AAAAAAAAAKI/vEpWkqBBzsM/AuthoriseCT_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;68&quot; /&gt;&lt;/a&gt;   
Et empêcher la création de Folder standard (si on le souhaite bien sûr)   
&lt;a href=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HhsNMxjI/AAAAAAAAAKQ/1vqGjXvooEk/s1600-h/PasFolder%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;PasFolder&quot; src=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HiMNMxkI/AAAAAAAAAKY/CAbAiepRc34/PasFolder_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;56&quot; /&gt;&lt;/a&gt;   
Ensuite, il faut choisir les CT qui nous intéressent   
&lt;a href=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HisNMxlI/AAAAAAAAAKg/d-Rcyxm-U7g/s1600-h/AjoutCT%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;AjoutCT&quot; src=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HjMNMxmI/AAAAAAAAAKo/_m3G9kbnXsw/AjoutCT_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;93&quot; /&gt;&lt;/a&gt;   
&lt;a href=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HjsNMxnI/AAAAAAAAAKw/2F4kS1mnHp0/s1600-h/AllCT%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;AllCT&quot; src=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HkcNMxoI/AAAAAAAAAK4/Ch6lTimlhPA/AllCT_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;158&quot; /&gt;&lt;/a&gt; 
&lt;a href=&quot;http://2.bp.blogspot.com/_44OccV1-Pks/R75IQdsQacI/AAAAAAAAAEU/DR4VUx0pn58/s1600-h/AllCT.jpg&quot;&gt;&lt;/a&gt;   
Puis, pour n&#39;avoir que &quot;Folder Niveau 1&quot; dans le menu &quot;New&quot;, il faut enlever les CT qui ne nous intéressent pas. Attention, cela ne veut pas dire qu&#39;ils ne seront plus accessibles. En fait, il sont toujours attachés à la liste, mais il ne seront simplement pas visible. Vous allez voir qu&#39;on va jouer là-dessus pour filtrer le contenu du menu &quot;New&quot; dans les sous-folder.   
&lt;a href=&quot;http://lh5.ggpht.com/Antoine.MOSS2007/SB1Hk8NMxpI/AAAAAAAAALA/0dxmb2C430Y/s1600-h/ChangeDefault%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;ChangeDefault&quot; src=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HlcNMxqI/AAAAAAAAALI/6Ql3EKowy-s/ChangeDefault_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;118&quot; /&gt;&lt;/a&gt; 
&lt;a href=&quot;http://lh5.ggpht.com/Antoine.MOSS2007/SB1Hl8NMxrI/AAAAAAAAALQ/_wpoGkKKu6I/s1600-h/ChangeMenuFolder%5B3%5D.jpg&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HmcNMxsI/AAAAAAAAALY/dDroU8fyXUU/s1600-h/Alldocview1%5B2%5D.jpg&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HnMNMxtI/AAAAAAAAALg/45LzV4I8JqE/s1600-h/ChooseOnlyFn1%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;ChooseOnlyFn1&quot; src=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HnsNMxuI/AAAAAAAAALo/WhHFCTXY1js/ChooseOnlyFn1_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;133&quot; /&gt;&lt;/a&gt;  
Ceci fait, on note dans le menu new qu&#39;il n&#39;y a plus grand chose, hormis la possibilité de créer un &quot;Folder Niveau 1&quot;   
&lt;a href=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HoMNMxvI/AAAAAAAAALw/_jHZBwffvYk/s1600-h/ChangeMenuFolder2%5B4%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;ChangeMenuFolder2&quot; src=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HosNMxwI/AAAAAAAAAL4/lXkQfeJnVs0/ChangeMenuFolder2_thumb%5B1%5D.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;120&quot; /&gt;&lt;/a&gt;   
Avant de créer un &quot;Folder Niveau 1&quot;, il faut faire un tour du coté de la vue &quot;All Documents&quot;. Cette vue affiche des données standard, et nous sommes plutôt intéressés pour voir les données du CT &quot;Folder Niveau 1&quot;. La première étape consiste à modifier cette vue en sélectionnant les bonnes colonnes   
&lt;a href=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HpcNMxxI/AAAAAAAAAMA/_kg9FYseWE4/s1600-h/Alldocview1%5B5%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;Alldocview1&quot; src=&quot;http://lh5.ggpht.com/Antoine.MOSS2007/SB1Hp8NMxyI/AAAAAAAAAMI/zdjBtAPMI9Y/Alldocview1_thumb%5B1%5D.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;148&quot; /&gt;&lt;/a&gt;   
puis, petite astuce, il faut aller tout en bas à la rubrique Folders pour dire que cette vue ne sera valable que lorsqu&#39;on est dans le root folder. Cette possibilité est très intéressante car elle va justement nous permettre de sélectionner les vue que l&#39;on souhaite en fonction du niveau de folder dans le quel on est.   
&lt;a href=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HqcNMxzI/AAAAAAAAAMQ/LHf9rKch1Ok/s1600-h/Alldocview2%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;Alldocview2&quot; src=&quot;http://lh5.ggpht.com/Antoine.MOSS2007/SB1Hq8NMx0I/AAAAAAAAAMY/N5p9sCgl6eA/Alldocview2_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;144&quot; /&gt;&lt;/a&gt;   
Ceci fait, on va créer un &quot;Folder Niveau 1&quot;. Faites New / Folder Niveau 1 et vous constatez qu&#39;il y a bien un formulaire d&#39;édition qui nous demande d&#39;entrer les meta données que l&#39;on a associé au folder   
&lt;a href=&quot;http://lh3.ggpht.com/Antoine.MOSS2007/SB1HrcNMx1I/AAAAAAAAAMg/GZAujlPtI3g/s1600-h/NewFolderNiv1Edit%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;NewFolderNiv1Edit&quot; src=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HrsNMx2I/AAAAAAAAAMo/zA6TQN72go0/NewFolderNiv1Edit_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;76&quot; /&gt;&lt;/a&gt;   
Et après avoir cliqué sur OK, on a bien dans la liste un folder avec ses meta données   
&lt;a href=&quot;http://lh6.ggpht.com/Antoine.MOSS2007/SB1HsMNMx3I/AAAAAAAAAMw/i-bRr3FGO2M/s1600-h/NewFolderNiv1Display%5B2%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ;&quot; alt=&quot;NewFolderNiv1Display&quot; src=&quot;http://lh4.ggpht.com/Antoine.MOSS2007/SB1HssNMx4I/AAAAAAAAAM4/PoXMj1mOIzY/NewFolderNiv1Display_thumb.jpg?imgmax=800&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;25&quot; /&gt;&lt;/a&gt;   
Maintenant, nous allons modifier les paramètres ce folder pour personnaliser son menu New. Il ne devra permettre que la création des &quot;Folder Niveau 2&quot; et des Contrats. C&#39;est le même principe que sur la liste: dans le menu associé au nom du folder, on trouve l&#39;option &quot;Change New Button Order&quot;   
&lt;a href=&quot;http://lh3.google.com/Antoine.MOSS2007/R9_r3quJ9ZI/AAAAAAAAAGg/ElX_SPBGTvs/ChangeMenuFolder%5B2%5D&quot;&gt;&lt;img style=&quot;border-width: 0px;&quot; alt=&quot;ChangeMenuFolder&quot; src=&quot;http://lh5.google.com/Antoine.MOSS2007/R9_r4KuJ9aI/AAAAAAAAAGo/SKqpgNoD0dk/ChangeMenuFolder_thumb&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;101&quot; /&gt;&lt;/a&gt;
qui va permettre de sélectionner les éléments que l&#39;on souhaite voir s&#39;afficher dans le menu New de ce folder (Folder Niveau 2 et Contrats)   
&lt;a href=&quot;http://lh3.google.com/Antoine.MOSS2007/R9_r4quJ9bI/AAAAAAAAAGw/TgW2yUbTikM/ChangeMenuFolder1%5B2%5D&quot;&gt;&lt;img style=&quot;border-width: 0px;&quot; alt=&quot;ChangeMenuFolder1&quot; src=&quot;http://lh5.google.com/Antoine.MOSS2007/R9_r5KuJ9cI/AAAAAAAAAG4/m58JyXxvnhU/ChangeMenuFolder1_thumb&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;126&quot; /&gt;&lt;/a&gt;   
Le menu est bien, mais la vue n&#39;est pas bonne   
&lt;a href=&quot;http://lh3.google.com/Antoine.MOSS2007/R9_r5quJ9dI/AAAAAAAAAHA/WKWry8l1xU4/ChangeMenuFolder2%5B2%5D&quot;&gt;&lt;img style=&quot;border-width: 0px;&quot; alt=&quot;ChangeMenuFolder2&quot; src=&quot;http://lh5.google.com/Antoine.MOSS2007/R9_r6KuJ9eI/AAAAAAAAAHI/DwwcnStSc7s/ChangeMenuFolder2_thumb&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;120&quot; /&gt;&lt;/a&gt;
En effet, on ne voit pas les meta data spécifiques aux documents contenus dans ce folder. Nous allons créer une vue qui va permettre cela.   
Cette vue aura un nom, sera une vue par défaut, avec des colonnes appropriées, et surtout, elle sera associée au CT &quot;Folder Niveau 1&quot;.   
Cela devient donc la vue par défaut pour ce folder   
&lt;a href=&quot;http://lh3.google.com/Antoine.MOSS2007/R9_r6quJ9fI/AAAAAAAAAHQ/QxrxupQwfkE/FolderView1%5B2%5D&quot;&gt;&lt;img style=&quot;border-width: 0px;&quot; alt=&quot;FolderView1&quot; src=&quot;http://lh5.google.com/Antoine.MOSS2007/R9_r7KuJ9gI/AAAAAAAAAHY/NXrE2VnF8UU/FolderView1_thumb&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;241&quot; /&gt;&lt;/a&gt;   
&lt;a href=&quot;http://lh6.google.com/Antoine.MOSS2007/R9_r7auJ9hI/AAAAAAAAAHg/bJAwh9VVUCI/FolderView2%5B2%5D&quot;&gt;&lt;img style=&quot;border-width: 0px;&quot; alt=&quot;FolderView2&quot; src=&quot;http://lh4.google.com/Antoine.MOSS2007/R9_r76uJ9iI/AAAAAAAAAHo/F5uNedz25jc/FolderView2_thumb&quot; border=&quot;0&quot; width=&quot;244&quot; height=&quot;116&quot; /&gt;&lt;/a&gt;   
Et maintenant, en entrant dans ce Folder Niveau 1 la vue précédente apparaîtra. Ce qui fait qu&#39;on maintenant deux vue par défaut, une pour le niveau Root, et une pour le niveau Folder Niveau 1.&lt;/p&gt;  &lt;p&gt;Bien sûr, pour le Folder Niveau 2 il faut faire de même, ce qui permet d&#39;avoir une hiérarchie de folder et de vue très intéressante.  
Mais l&#39;inconvénient majeur de ce système, c&#39;est qu&#39;il faut faire la démarche de sélectionner le &quot;New Button Order&quot; pour chaque nouveau folder créé. Heureusement il existe une méthode par programmation. C&#39;est ce que nous verrons dans la &lt;a href=&quot;http://apichot.blogspot.com/2008/04/sharepoint-folder-sub-folder-and.html&quot;&gt;partie 2 &lt;/a&gt;de ce post.     &lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/3429578141633951873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/3429578141633951873' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/3429578141633951873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/3429578141633951873'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2008/03/sharepoint-folder-sub-folder-and.html' title='SharePoint Folder, Sub-Folder and Content Type (part 1)'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/Antoine.MOSS2007/SB1HcMNMxYI/AAAAAAAAAI4/K0ixMN7JUws/s72-c/CTCreation_thumb.jpg?imgmax=800" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-50557505254080673</id><published>2007-11-30T16:10:00.000+01:00</published><updated>2007-12-07T16:31:27.662+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>SharePoint 2007 : How To Run STSADM Command From Your Code</title><content type='html'>Today, I&#39;ve discovered something very interesting I want to share with you:
How to run stsadm command inside my code.
It&#39;s really easy, if you look at the following code, I specify to search from a membership provider only:
&lt;div class=&quot;comment-code&quot;&gt;
string prgFilePath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles);
string stsadmPath = prgFilePath + @&quot;\Microsoft Shared\web server extensions\12\BIN\stsadm.exe&quot;;
System.Diagnostics.Process proc = new System.Diagnostics.Process(); &lt;/div&gt;&lt;div class=&quot;comment-code&quot;&gt;//Wait for the end of the process&lt;/div&gt;&lt;div class=&quot;comment-code&quot;&gt;proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = stsadmPath;
proc.StartInfo.Arguments = &quot;-o setproperty -url &lt;a href=&quot;http://dcmoss:50020/&quot;&gt;http://dcmoss:50020/&lt;/a&gt; -pn &quot;peoplepicker-nowindowsaccountsfornonwindowsauthenticationmode&quot; -pv yes&quot;;
proc.Start(); &lt;/div&gt;&lt;div class=&quot;comment-code&quot;&gt;//Wait&lt;/div&gt;&lt;div class=&quot;comment-code&quot;&gt;proc.WaitForExit();&lt;/div&gt;&lt;div class=&quot;comment-code&quot;&gt;&lt;/div&gt;&lt;div class=&quot;comment-code&quot;&gt;&lt;/div&gt;
With this method you can dynamically activate or deactivate feature, make some maintenance operation, change properties...</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/50557505254080673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/50557505254080673' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/50557505254080673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/50557505254080673'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/11/sharepoint-2007-how-to-run-stsadm.html' title='SharePoint 2007 : How To Run STSADM Command From Your Code'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-5419412019389693376</id><published>2007-11-22T09:40:00.000+01:00</published><updated>2007-11-22T09:46:34.358+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>Sharepoint 2007: SPBuiltInFieldId a Class You Must Know</title><content type='html'>A short comment today about a class I&#39;ve just discovered:

&lt;strong&gt;SPBuiltInFieldId&lt;/strong&gt;

With this class you have access to all built-in fields, even the hidden one&#39;s
Example:
&lt;div class=&quot;comment-code&quot;&gt;
SPBuiltInFieldId.WorkflowListId
SPBuiltInFieldId.WorkflowItemId
SPBuiltInFieldId.WorkflowVersion
SPBuiltInFieldId._CopySource
SPBuiltInFieldId._RightsManagement
&lt;/div&gt;
Link:
&lt;a href=&quot;http://msdn2.microsoft.com/En-US/library/microsoft.sharepoint.spbuiltinfieldid_members.aspx&quot;&gt;http://msdn2.microsoft.com/En-US/library/microsoft.sharepoint.spbuiltinfieldid_members.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/5419412019389693376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/5419412019389693376' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/5419412019389693376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/5419412019389693376'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/11/sharepoint-2007-spbuiltinfieldid-class.html' title='Sharepoint 2007: SPBuiltInFieldId a Class You Must Know'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-1389804186355619933</id><published>2007-11-21T17:25:00.000+01:00</published><updated>2007-12-13T17:01:42.817+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>SharePoint 2007 - Create field lookup and associated list as a feature</title><content type='html'>Je suis désolé pour les francophones, mais je dois maintenant m&#39;exprimer en anglais car j&#39;ai mis le code sur &lt;a href=&quot;http://www.codeplex.com/FieldLookupBuilder&quot; target=&quot;_blank&quot;&gt;Codeplex&lt;/a&gt;

This feature is an extension of the one from Chris O&#39;Brien (&lt;a class=&quot;externalLink&quot; href=&quot;http://www.codeplex.com/SP2007LookupFields&quot; target=&quot;_blank&quot;&gt;SharePoint 2007 - create lookup fields as a feature&lt;/a&gt;), but offer you the ability to define one or more fields and the associated lists within one xml file.Moreover you&#39;ll can use these fields in one or more content type. When you&#39;ll activate the feature, everything will be build !

Let me explain a bit:

First, if you want to have a full explanation of managing lookup column dynamically, you can start with a look on the blog of Chris O&#39;Brien : &lt;a href=&quot;http://sharepointnutsandbolts.blogspot.com/2007/04/creating-list-based-site-columns-as.html&quot;&gt;http://sharepointnutsandbolts.blogspot.com/2007/04/creating-list-based-site-columns-as.html&lt;/a&gt;

For summarizing, a lookup field is like a choice field but the content comes from a list in the site collection. The main difficulty is that the link between the field and the list is a GUID coming from the &lt;strong&gt;instance&lt;/strong&gt; of the list. This means the &lt;strong&gt;GUID&lt;/strong&gt; is only known when the list has been created. So you can&#39;t fix the link in your site column definition.
ie:


&lt;div class=&quot;comment-code&quot;&gt;
&amp;lt;Field Type=&quot;Lookup&quot;
&lt;strong&gt;List=&quot;{A77FA6BC-8915-458a-914A-92BDDC375726}&quot;&lt;/strong&gt;
ID=&quot;{E918A3F4-9E34-4bd2-A621-5F353B4529E2}&quot;
Name=&quot;KeywordLookup&quot;
/&amp;gt; &lt;/div&gt;


is not possible because you don&#39;t know the list GUID. Well, of course you can cheat a bit if you define a list in your site and you retrieve the actual GUID of the instance. But what about moving a site from a test environment to a production environement ? Or from a site collection to another...? The GUID change each time !

The solution proposed by Chris is great. But you must still define a list before activating the feature. And because I&#39;m a little bit lazy, I&#39;ve tried to improve his solution to one more generic.
Let&#39;s suppose you want to have a lookup field which contain a list of keywords. These keywords come from a SharePoint list, so you can extend it as you want.

Create a new XML file and insert the following code inside. Of course you can have more than one field into this XML file, but I&#39;ll use only one for the demo.


&lt;div class=&quot;comment-code&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;gt;&amp;lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&amp;gt;

&amp;lt;Field
Type=&quot;Lookup&quot;
DisplayName=&quot;Mots-clés&quot;
Mult=&quot;TRUE&quot;
Required=&quot;FALSE&quot;
&lt;strong&gt;List=&quot;Keywords;Mots-Clés&quot; &lt;/strong&gt;
ShowField=&quot;Title&quot;
UnlimitedLengthInDocumentLibrary=&quot;FALSE&quot;
Group=&quot;TEST&quot;
ID=&quot;{E918A3F4-9E34-4bd2-A621-5F353B4529E2}&quot;
SourceID=&quot;http://schemas.microsoft.com/sharepoint/v3&quot; StaticName=&quot;KeywordLookup&quot;
&lt;strong&gt;Name=&quot;KeywordLookup&quot;&lt;/strong&gt;
/&amp;gt;

&amp;lt;/Elements&amp;gt;
&lt;/div&gt;
As you can, this is a classic field definition. Except for one attribute: &lt;strong&gt;List&lt;/strong&gt;. This attribute has two words, &lt;em&gt;Keyword&lt;/em&gt; and &lt;em&gt;Mots-Clés&lt;/em&gt;. The first one is the internal name of the list template, the second one is the name of the list we&#39;ll see in the site. In our case, we gonna create a list named &lt;em&gt;Mots-Clés&lt;/em&gt; based on the template internal name &lt;em&gt;Keyword&lt;/em&gt;. For a standard Customlist, the internal name is &lt;em&gt;custlist&lt;/em&gt; (have a look on &lt;em&gt;12\TEMPLATE\FEATURES\CustomList\ListTemplates&lt;/em&gt;)
Why all of this?
Because when the feature will be activated, a program will search for a list named &lt;em&gt;Mots-Clés&lt;/em&gt; in the site collection. If this list doesn&#39;t exist, then the program creates it, based on the list template and the list name you define in the &lt;strong&gt;List&lt;/strong&gt; attribute.
Here is the Feature.xml file:

&lt;div class=&quot;comment-code&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;gt;
&amp;lt;Feature Title=&quot;Site Column Lookup Initialization&quot;
Id=&quot;498CB08B-1786-4e34-AD09-F61009A0C6AB&quot;
Description=&quot;This feature create site columns lookup related to lists&quot;
Version=&quot;1.0.0.0&quot;
Scope=&quot;Site&quot;
Hidden=&quot;FALSE&quot;
DefaultResourceFile=&quot;TEST&quot;
xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;
&lt;strong&gt;ReceiverAssembly=&quot;Tls.Moss, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5&quot;
ReceiverClass=&quot;MossSolution.Receivers.LookupFeatureReceiver&quot;&amp;gt;
&lt;/strong&gt;&amp;lt;ActivationDependencies&amp;gt;
&amp;lt;ActivationDependency FeatureId=&quot;bfda08d3-c7a8-4ade-99d5-86de4ce0ac26&quot;/&amp;gt;
&amp;lt;/ActivationDependencies&amp;gt;
&amp;lt;ElementManifests&amp;gt;
&lt;strong&gt;&amp;lt;ElementFile Location=&quot;LookupFields.xml&quot;/&amp;gt;
&lt;/strong&gt;&amp;lt;/ElementManifests&amp;gt;
&amp;lt;Properties&amp;gt;
&lt;strong&gt;&amp;lt;Property Key=&quot;ColumnDefinitionPath&quot; Value=&quot;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\SiteLookupFields\LookupFields.xml&quot; /&amp;gt;
&lt;/strong&gt;&amp;lt;/Properties&amp;gt;
&amp;lt;/Feature&amp;gt;
&lt;/div&gt;
In this feature, adapt the event receiver with the name of your assembly. The LookupFields.xml is the file where I put all lookup columns definitions.
You can notice one particular property: &lt;strong&gt;ColumnDefinitionPath&lt;/strong&gt;. This is the path where the lookup columns definitions is located. This path will used in the code to retrieve the XML data.
I&#39;ve also added a dependency, because the list template feature must be activated before activating this lookup feature.

The tips here is because you defined properly a field, with all the usual behaviors (DisplayName, Show where you want, Readonly...) and a GUID, you can use these fields inside a ContentType!
Good news, you have now the opportunity to have a content type with usual field types, PLUS one or more lookup type!

The code is available on &lt;a href=&quot;http://www.codeplex.com/FieldLookupBuilder&quot; target=&quot;_blank&quot;&gt;Codeplex: SharePoint 2007 - Create field lookup and associated list as a feature&lt;/a&gt;.
There is a folder named &lt;em&gt;Solution&lt;/em&gt; which contains the wsp
Now, you have to add the solution with &lt;strong&gt;stsadm -o addsolution -filename lookupsolution.wsp&lt;/strong&gt;
Then, go to &lt;em&gt;Central Admin / Operation /Solution Management&lt;/em&gt; and deploy the solution to the site(s) you want.
Then, go to your site settings for activating the collection features, first &lt;strong&gt;TEST Keywords&lt;/strong&gt; then &lt;strong&gt;Site Column Lookup Initialization&lt;/strong&gt;

The source code is in &lt;em&gt;_App_code/Receivers&lt;/em&gt;.

Hope this helps you.</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/1389804186355619933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/1389804186355619933' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1389804186355619933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/1389804186355619933'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/11/sharepoint-2007-create-field-lookup-and.html' title='SharePoint 2007 - Create field lookup and associated list as a feature'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-2287974167567243863</id><published>2007-07-30T16:04:00.001+02:00</published><updated>2008-12-12T02:04:52.341+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="InfoPath"/><category scheme="http://www.blogger.com/atom/ns#" term="MOSS 2007"/><category scheme="http://www.blogger.com/atom/ns#" term="workflow"/><title type='text'>SharePoint 2007 : Workflow et Association Form avec InfoPath 2007</title><content type='html'>Aujourd&#39;hui je vais m&#39;intéresser à la création d&#39;un &lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;formulaire d&#39;association &lt;/span&gt;pour un &lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Workflow&lt;/span&gt;.

&lt;div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRvQWjtfaJ2pzU7JwfK6NxOILDwzZcdbbpGywu9ALNodZaEL62w60VHaCs8NrhTlRAe4JpTsQOQfeok00BXWt8u7hj6xS9YiCqfPBybyai8DSYIdgg-UlcL2SR7oMXuZeLogwHy8tgnw/s1600-h/WF_Blog_POWF1.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5092995190074677874&quot; style=&quot;FLOAT: left; MARGIN: 0pt 10px 10px 0pt; CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRvQWjtfaJ2pzU7JwfK6NxOILDwzZcdbbpGywu9ALNodZaEL62w60VHaCs8NrhTlRAe4JpTsQOQfeok00BXWt8u7hj6xS9YiCqfPBybyai8DSYIdgg-UlcL2SR7oMXuZeLogwHy8tgnw/s320/WF_Blog_POWF1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;Un formulaire d&#39;association est une page qui apparaît lorsqu&#39;on crée une instance de Workflow : on choisit tout d&#39;abord le modèle de Workflow, puis la Task list qui sera associée, puis l&#39;History List, et enfin le mode d&#39;activation du Workflow (Automatique, manuel...)&lt;/div&gt;

&lt;div&gt;
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSje4bV78AMDD9b5MeQ3A7rvllDH-hF1S-aPXBzICU0HeFti5Cw_F_lSy-lZCVzwv_K_cujZpYQDs8q1HfcKAp7ZWGG4Jm19JgAKBvoxU4n-JcXr4R6TgLW1N-GLR68vveUHtK_eqTjA/s1600-h/WF_Blog_POWF2.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5092995671111015042&quot; style=&quot;FLOAT: left; MARGIN: 0pt 10px 10px 0pt; CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSje4bV78AMDD9b5MeQ3A7rvllDH-hF1S-aPXBzICU0HeFti5Cw_F_lSy-lZCVzwv_K_cujZpYQDs8q1HfcKAp7ZWGG4Jm19JgAKBvoxU4n-JcXr4R6TgLW1N-GLR68vveUHtK_eqTjA/s320/WF_Blog_POWF2.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;En cliquant sur le bouton &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Next&lt;/span&gt;, j&#39;obtiens mon propre formulaire qui me permet de récupérer des informations complémentaires dés l&#39;instanciation du Workflow. En l&#39;occurrence, un flag qui m&#39;indique si un mail doit être envoyé au &quot;Supplier&quot;, puis un commentaire à insérer dans la description de tâche. Ainsi ce texte se retrouvera dans chaque tâche.

Pour créer un tel formulaire, et l&#39;associer au workflow, il est préférable d&#39;utiliser InfoPath 2007 qui offre beaucoup d&#39;avantages par rapport aux pages ASPX. Voici en quelques étapes comment faire pour construire l&#39;écran précédent et l&#39;intégrer dans le workflow.

&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Principe :&lt;/span&gt;

Un formulaire InfoPath est est un fichier XML associé à un Schéma XSD. Il y a une partie mise en forme et une partie données. L&#39;astuce principale est de transformer le shéma en une classe C# (.cs) pour disposer facilement des propriétés (Data Source) au sein du Workflow. Les propriétés seront, entre autre, des champs de saisie dans l&#39;écran InfoPath.

&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Préliminaires&lt;/span&gt;

Il faut avoir créer un projet de type Workflow sous Visual Studio, puis avoir créé une arborescence prête à accueillir les fichier d&#39;installation

&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Q70CSJK6qbxcXiRAdMGmFdf0a20EHVcO2NGs3VOmDLFr7nV3nbsjWAtD4WyMNm3F387ZncYOJ8InB9grSwwDkihhyphenhyphenNz5WXejft4iCNf7kXNyJyruN6ABx5eVyTsRW6dQbVuX8QAQRw/s1600-h/WF_Blog_arbo.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5142643524496831826&quot; style=&quot;CURSOR: hand&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Q70CSJK6qbxcXiRAdMGmFdf0a20EHVcO2NGs3VOmDLFr7nV3nbsjWAtD4WyMNm3F387ZncYOJ8InB9grSwwDkihhyphenhyphenNz5WXejft4iCNf7kXNyJyruN6ABx5eVyTsRW6dQbVuX8QAQRw/s320/WF_Blog_arbo.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;

&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGdi1XoBTQAD5X0Dvq07OJj8Bten45Q4whiUwEmJqd6VaPZqWBL02OqB9TyC5g8M0vdPHcU7B1h5gdfTAcwBxQ8GytuCBhWeogC8p4WGBi9pUHvIGTRi1H0miU5IQzqXJeFkMd_kCJSg/s1600-h/WF_Blog_arbo.jpg&quot;&gt;&lt;/a&gt;

&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Etape 1 : créer l&#39;écran&lt;/span&gt;

&lt;ol&gt;

&lt;li&gt;Ouvrir InfoPath et créer un nouveau Template.
&lt;/li&gt;
&lt;li&gt;Il faut ensuite créer une &quot;Data Source&quot; (Design Tasks / Data Source), ensemble de variables qui mémoriserons les données entrées. C&#39;est grâce à ces Data Source que l&#39;on va pouvoir dialoguer avec le formulaire. Une bonne pratique pour créer la Data Source est de lui donner un nom explicite. Par ailleurs, ce nom sera plus tard le nom de la classe qui sera générée pour être utilisée dans le Workflow.
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXaf22B4V4aP40VBBr9HBOzqdUJjk_xfuZvNvXGZeLQxrU1UCBE1i4Eix4OleGwypbPViP8rGNo6d2rFXpJvA9Jj9JXi01PqbXuH4ONGKCXxNW5NjdAgmwlPb9F03f5kldXS-8I-zIRQ/s1600-h/WF_Blog_DataSource.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093000795006999186&quot; style=&quot;FLOAT: left; MARGIN: 0pt 10px 10px 0pt; CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXaf22B4V4aP40VBBr9HBOzqdUJjk_xfuZvNvXGZeLQxrU1UCBE1i4Eix4OleGwypbPViP8rGNo6d2rFXpJvA9Jj9JXi01PqbXuH4ONGKCXxNW5NjdAgmwlPb9F03f5kldXS-8I-zIRQ/s320/WF_Blog_DataSource.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;Dans mon exemple, j&#39;ai pris comme nom de &quot;Data Source&quot; &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;AssocData&lt;/span&gt; et j&#39;ai créé deux champs, l&#39;un booleen, l&#39;autre de type texte mutillignes
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0g1vp83S6J1uISfI0-qliOM_GCSY1mdJkR3iDzWBK8dl-gHEX2sTnTgkt0UTHmHCJWxEAXUzBFgQcPBJ-3KyeXxvxxxDltASsrtLldHslMbqYizkTOtX5s0mrAp3E8kJlT0G61U2Nlw/s1600-h/WF_Blog_DataSourceDetail.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093001422072224418&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0g1vp83S6J1uISfI0-qliOM_GCSY1mdJkR3iDzWBK8dl-gHEX2sTnTgkt0UTHmHCJWxEAXUzBFgQcPBJ-3KyeXxvxxxDltASsrtLldHslMbqYizkTOtX5s0mrAp3E8kJlT0G61U2Nlw/s320/WF_Blog_DataSourceDetail.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/li&gt;


&lt;li&gt;Mise en forme du formulaire : une fois les champs créés, il faut, dans le menu Design Tasks / Layout faire la mise en forme. Sélectionnez un tableau à deux colonnes, puis retournez dans Design Tasks / Data Source pour faire un Drag &amp;amp; Drop des champs aux bons emplacements. Ajoutez ensuite un bouton (Design Tasks / Controls)
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5IKY05tXH_Z2nRc-BCJg8POc92u0sf-kDC5OHPjj3DFZYOeZ7ha_-FVSwD4W9-GuKHUI6ibwGRRuSn08pw-UwLUlQxc3ZY-9492BiaC0iK6jaXhcOr7tvAkm8Olrjzywv7Y-a8Qdfjw/s1600-h/WF_Blog_Layout.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093002757807053490&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5IKY05tXH_Z2nRc-BCJg8POc92u0sf-kDC5OHPjj3DFZYOeZ7ha_-FVSwD4W9-GuKHUI6ibwGRRuSn08pw-UwLUlQxc3ZY-9492BiaC0iK6jaXhcOr7tvAkm8Olrjzywv7Y-a8Qdfjw/s320/WF_Blog_Layout.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
&lt;/li&gt;


&lt;li&gt;Il faut ensuite paramétrer le bouton pour que le formulaire soit envoyé à SharePoint (à l&#39;instance de workflow en cours), puis que le formulaire soit fermé. Pour cela, il faut faire un click doit sur le bouton et aller dans &quot;Button Properties&quot;...
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPoqB958XdzLp5_dVwJBGjYOK_m2BGa__R0PJ4W_QVvKA9-4j9srcEaxNFV3PybMsyFDoDIBT85-mCIxY34MxM1Jt5bYkR1HRAurOVxifFTtFJ0mz4XEbOwHxmS06EGtHRLIbUrGCTJw/s1600-h/WF_Blog_DoneButton1.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093005562420697794&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPoqB958XdzLp5_dVwJBGjYOK_m2BGa__R0PJ4W_QVvKA9-4j9srcEaxNFV3PybMsyFDoDIBT85-mCIxY34MxM1Jt5bYkR1HRAurOVxifFTtFJ0mz4XEbOwHxmS06EGtHRLIbUrGCTJw/s320/WF_Blog_DoneButton1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
... et mettre le label (ici &quot;Done&quot;), puis cliquer sur Rules...
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmH5ryt7pRmoyXi0fi8r4XgiAk4wkruHh7bhZzTc5_BVWrLZoK3j6RCJ7G7cWqdEgLJ1hv4YQN4Lm10UwnhvBhIXDJ2Igwogy5GTe_NETE3unrH1hHWq_TK2axhw2s3MkqjpykIjOvow/s1600-h/WF_Blog_Rules.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093005897428146898&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmH5ryt7pRmoyXi0fi8r4XgiAk4wkruHh7bhZzTc5_BVWrLZoK3j6RCJ7G7cWqdEgLJ1hv4YQN4Lm10UwnhvBhIXDJ2Igwogy5GTe_NETE3unrH1hHWq_TK2axhw2s3MkqjpykIjOvow/s320/WF_Blog_Rules.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/li&gt;


&lt;li&gt;A partir de là, il va falloir créer une Data Connexion pour se connecter au Host (SharePoint) et renvoyer les données. Cliquez sur Add Actions
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-DXhRIhax3828G0zEimQ8dzqdcEpNWo1fe52CGTjyFLmhAxzXHNrQXYvVg_pT4Xg6BMVovRCsxv9MSkpmbDOWVhpeWAwDhPG-kLS0ruQTk64OczrpSqfuaADYaB6f6xyb90b25QXPNw/s1600-h/WF_Blog_DataConnection0.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093006344104745698&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-DXhRIhax3828G0zEimQ8dzqdcEpNWo1fe52CGTjyFLmhAxzXHNrQXYvVg_pT4Xg6BMVovRCsxv9MSkpmbDOWVhpeWAwDhPG-kLS0ruQTk64OczrpSqfuaADYaB6f6xyb90b25QXPNw/s320/WF_Blog_DataConnection0.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
puis Add... pour ajouter une Data Connexion
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtG_y9uRLsUxwkjekqx0OaLW9DSNgWBsGpj7AxRUc4d60If8HkPd1XTEL9geMLu345bk6IiCddVVgTile6QsNSWn8j5OkwDVAMWeXZP2zqway_TJG4EJ8gRhLGpe5UIxdYF5xl90YzGg/s1600-h/WF_Blog_DataConnection1.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093006554558143218&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtG_y9uRLsUxwkjekqx0OaLW9DSNgWBsGpj7AxRUc4d60If8HkPd1XTEL9geMLu345bk6IiCddVVgTile6QsNSWn8j5OkwDVAMWeXZP2zqway_TJG4EJ8gRhLGpe5UIxdYF5xl90YzGg/s320/WF_Blog_DataConnection1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
Utilisez les mêmes paramètres (on veut faire une soumission de formulaire) et cliquez sur &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Next&lt;/span&gt;...
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcP-bnHuJo2r3MznvAFu2AWm8Ml82Ps8pRoUQl32Fg2nFKp61nBaw07TZInPUtMPOnEnXNf-k4V6hQnOOlbqnjjAo_L-Z5S9Kh5msfacRPFN_UJ31CX5RocVmQeN_KkA9p3q7EacZ6CA/s1600-h/WF_Blog_DataConnection2.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093006885270625026&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcP-bnHuJo2r3MznvAFu2AWm8Ml82Ps8pRoUQl32Fg2nFKp61nBaw07TZInPUtMPOnEnXNf-k4V6hQnOOlbqnjjAo_L-Z5S9Kh5msfacRPFN_UJ31CX5RocVmQeN_KkA9p3q7EacZ6CA/s320/WF_Blog_DataConnection2.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
et selectionnez le &quot;Hosting Environment&quot;.
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNkLydHyN3il6GskGpjy5cFytRW86plkTDDw79tl_5C93yZEgTZUJWQueefsFWEGf1SmiqVaK-1to_9-p4xVDsTJrHp8LbxFmIiA5I3Q9VHldhgI8b63-DAN-mx7T6WtxiXjpC5DlPRA/s1600-h/WF_Blog_DataConnection3.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093007185918335762&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNkLydHyN3il6GskGpjy5cFytRW86plkTDDw79tl_5C93yZEgTZUJWQueefsFWEGf1SmiqVaK-1to_9-p4xVDsTJrHp8LbxFmIiA5I3Q9VHldhgI8b63-DAN-mx7T6WtxiXjpC5DlPRA/s320/WF_Blog_DataConnection3.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
Puis donnez un nom explicite à cette Connexion.&lt;/li&gt;


&lt;li&gt;Il faut ensuite ajouter une action (Add Action) pour fermer le formulaire (choisissez cette option dans la liste)
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmH5ryt7pRmoyXi0fi8r4XgiAk4wkruHh7bhZzTc5_BVWrLZoK3j6RCJ7G7cWqdEgLJ1hv4YQN4Lm10UwnhvBhIXDJ2Igwogy5GTe_NETE3unrH1hHWq_TK2axhw2s3MkqjpykIjOvow/s1600-h/WF_Blog_Rules.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093005897428146898&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmH5ryt7pRmoyXi0fi8r4XgiAk4wkruHh7bhZzTc5_BVWrLZoK3j6RCJ7G7cWqdEgLJ1hv4YQN4Lm10UwnhvBhIXDJ2Igwogy5GTe_NETE3unrH1hHWq_TK2axhw2s3MkqjpykIjOvow/s320/WF_Blog_Rules.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
&lt;/li&gt;&lt;/ol&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Etape 2 : Publication&lt;/span&gt;



&lt;ol&gt;


&lt;li&gt;Voilà, le formulaire est prêt. Maintenant il faut (1) le publier, (2) récupérer le schéma.
(1) &lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Publication &lt;/span&gt;: le mécanisme de publication, dans notre cas, consiste à publier le formulaire dans notre répertoire d&#39;installation de la feature Workflow. Tout d&#39;abord, il faut enregistrer le formulaire quelque part où vous le retrouverez (&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;My Document/Forms&lt;/span&gt; par exemple). Puis cliquez sur &quot;Publish Form Template...&quot;
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd11rcOJ1mwyafJxVNBoh5BqNCFOnWw_QI4sW2EYQ_qaclEsBjdj3YEebg9RPm0osAJJK9YjzX_1m5nmDEP9x3FdpDHbnYGq3jLCvpilkzd8gR7B6PNuyefBeDB2sLkbrW_FIa2d6VXA/s1600-h/WF_Blog_Publish1.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093008620437412642&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhd11rcOJ1mwyafJxVNBoh5BqNCFOnWw_QI4sW2EYQ_qaclEsBjdj3YEebg9RPm0osAJJK9YjzX_1m5nmDEP9x3FdpDHbnYGq3jLCvpilkzd8gR7B6PNuyefBeDB2sLkbrW_FIa2d6VXA/s320/WF_Blog_Publish1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
et choisir une &quot;Network Location&quot; puis &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;Next
&lt;/span&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFVtsD8ta3WUqZRAvQl3UNeHuxWjG2olCMfnUBvaXY16aDmoFx7R2iQFoIimNjg0NIYB8hQ8i7tJ8OAWNaZn4OB794810hyphenhyphenekUBWILwoooI2uqSo2O_XPn2cvwPM_be1qgejeo13fO0w/s1600-h/WF_Blog_Publish2.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093009019869371186&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFVtsD8ta3WUqZRAvQl3UNeHuxWjG2olCMfnUBvaXY16aDmoFx7R2iQFoIimNjg0NIYB8hQ8i7tJ8OAWNaZn4OB794810hyphenhyphenekUBWILwoooI2uqSo2O_XPn2cvwPM_be1qgejeo13fO0w/s320/WF_Blog_Publish2.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
Enregistrer le formulaire dans votre répertoire de projet Visual Studio dans le sous-répertoire concerné par la feature Workflow (dans mon cas, &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;GYPOWorkflow&lt;/span&gt;) et donnez lui un nom explicite (celui de votre sauvegarde pourra faire l&#39;affaire)
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuOPiiPHzA-nIgh7K3AdGoArbZXEOXHHJZLkpZHhEKtKZLBSWb02T_xfHOGf4QFjFqIg9yQX3lIY0mGGblzO8rcNx9PmVAYKishOxE9G5S92EeVhPNZ-esziFQp24ddpUZe_rplowLyA/s1600-h/WF_Blog_Publish3.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093010188100475714&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuOPiiPHzA-nIgh7K3AdGoArbZXEOXHHJZLkpZHhEKtKZLBSWb02T_xfHOGf4QFjFqIg9yQX3lIY0mGGblzO8rcNx9PmVAYKishOxE9G5S92EeVhPNZ-esziFQp24ddpUZe_rplowLyA/s320/WF_Blog_Publish3.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
Ne mettez rien dans cette form
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKwLKP2cXnm4mwimVUvaP_j8rje52UF804l7DmPCMzxxKI38uv4BnzfpL4XhUtvvPw6TW8KF5Z1Sd7Q8xp5HiP6Rqfl470q_wXypoN08RBYCYldV70A4XilbFBz6avXDsiAltbkMVmDw/s1600-h/WF_Blog_Publish4.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093010355604200274&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKwLKP2cXnm4mwimVUvaP_j8rje52UF804l7DmPCMzxxKI38uv4BnzfpL4XhUtvvPw6TW8KF5Z1Sd7Q8xp5HiP6Rqfl470q_wXypoN08RBYCYldV70A4XilbFBz6avXDsiAltbkMVmDw/s320/WF_Blog_Publish4.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
et ignorez l&#39;avertissement.
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi50HL4ANQNdcQKKgWuOjjOmoicpqK1Xyvi5Ytj3adKso68CzmezZQoz9y4diebRO4PFKlIzgQ9NesiB9zzqCg3xNPCy2e-ZOIUeb4PN0TFn8nxZL_xItawXQdANjKAZ0PVc_KCEhAWMQ/s1600-h/WF_Blog_Publish5.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093010548877728610&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi50HL4ANQNdcQKKgWuOjjOmoicpqK1Xyvi5Ytj3adKso68CzmezZQoz9y4diebRO4PFKlIzgQ9NesiB9zzqCg3xNPCy2e-ZOIUeb4PN0TFn8nxZL_xItawXQdANjKAZ0PVc_KCEhAWMQ/s320/WF_Blog_Publish5.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
Publiez, c&#39;est fait.&lt;/li&gt;


&lt;li&gt;Un fois que c&#39;est publié, il faut encore se faciliter le travail en créant une classe C# à partir du schéma du formulaire. Cette classe aura comme propriété les champs du formulaire. Pour se faire, il faut enregistrer le code source du formulaire dans un répertoire
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH5wO-VJ2Q2BivUfUVzrx-F4LX25TubJR2nH1yxJClVLXitKhnwpaulLuPg893_DVff44DhFBvQ4EJ0zTfs8xXq4RDA7hp6ut1-O2w4cXBTAP4-ZGOAGd_tfCMYhM81AjAwnELYIFd6g/s1600-h/WF_Blog_SaveAs.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093011334856743810&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH5wO-VJ2Q2BivUfUVzrx-F4LX25TubJR2nH1yxJClVLXitKhnwpaulLuPg893_DVff44DhFBvQ4EJ0zTfs8xXq4RDA7hp6ut1-O2w4cXBTAP4-ZGOAGd_tfCMYhM81AjAwnELYIFd6g/s320/WF_Blog_SaveAs.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
InfoPath va générer un lot de fichier dont seul &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;myschema.xsd&lt;/span&gt; nous intéresse
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmMlNmBl5BBw5xVSKJlTOFN5ldzypc5lY2m4XAtaB7NA0qphYhquXw600TDn_fwvzxO7MBFEKlcoJZNMjwtqmlQ2tDizHCT_RYK6pg3VlGHWI53MbQx9HgJJqmZExcmbtz_x7ecDqGbA/s1600-h/WF_Blog_XSDSources.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093011223187594098&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmMlNmBl5BBw5xVSKJlTOFN5ldzypc5lY2m4XAtaB7NA0qphYhquXw600TDn_fwvzxO7MBFEKlcoJZNMjwtqmlQ2tDizHCT_RYK6pg3VlGHWI53MbQx9HgJJqmZExcmbtz_x7ecDqGbA/s320/WF_Blog_XSDSources.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
Nous allons utiliser le programme XSD.EXE fournit avec VSStudio pour générer une classe C#. Le nom du fichier &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;cs&lt;/span&gt; généré portera le nom du fichier &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;xsd&lt;/span&gt; (&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;myschema &lt;/span&gt;actuellement) mais la classe elle-même portera le nom de notre Data Source (&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;AssocData &lt;/span&gt;pour l&#39;exemple). Par conséquent je vous conseille de renommer &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;myschema.xsd&lt;/span&gt; en &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;AssocData.xsd&lt;/span&gt; pour être cohérent. Ensuite, ouvrez une fenêtre DOS, allez dans le répertoire où est situé votre shéma (&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;My Document\XSD_Sources&lt;/span&gt; dans mon cas) puis tapez l&#39;instruction suivante : &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;xsd myschema.xsd /c&lt;/span&gt;
&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGFVeL6A6UmckFDM65YPGPIOB3aWCxP7jB3bDRC4lqWQicwMWz6VHnNACZlTiVCIz6rAQZYGFVs5-dfoSVwFohfQcjnLdyPrSyBuxEnIQ0mgSBg2ZMvcFVJStuZEpOotR-tDZ11qFECQ/s1600-h/WF_Blog_XSD_CS.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093013216052419474&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGFVeL6A6UmckFDM65YPGPIOB3aWCxP7jB3bDRC4lqWQicwMWz6VHnNACZlTiVCIz6rAQZYGFVs5-dfoSVwFohfQcjnLdyPrSyBuxEnIQ0mgSBg2ZMvcFVJStuZEpOotR-tDZ11qFECQ/s320/WF_Blog_XSD_CS.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
Vous aurez ensuite un fichier portant le nom&lt;span style=&quot;FONT-STYLE: italic&quot;&gt; myschema.cs &lt;/span&gt;(ou &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;AssocData.cs&lt;/span&gt; si vous avez renommé le fichier) qui contient une structure particulière et les accesseurs nécessaires pour retrouver les données du formulaire.&lt;/li&gt;


&lt;li&gt;Ceci étant fait, retournez sous VS et ajoutez cette classe à votre projet.&lt;/li&gt;


&lt;li&gt;Dans l&#39;événement OnWorkflowActivated1_Invoked, ajoutez les lignes de code suivantes:
&lt;span style=&quot;font-family:courier new;&quot;&gt;//Get the info about sending email to supplier from the association form&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;//Part 1&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;XmlSerializer serializer = new XmlSerializer(typeof(AssocData));&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(workflowProperties.AssociationData));&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;//Part 2&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;AssocData AssocForm = (AssocData)serializer.Deserialize(reader);&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;//Internal variables&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;eMailToSupplier = (bool)AssocForm.eMailToSupplier;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;reviewComments = AssocForm.reviewComment;&lt;/span&gt;

La première partie du code récupère le fichier xml InfoPath sérialisé qui est stocké dans une propriété (AssociationData) du Workflow.
La deuxième partie désérialise le XML en faisant un Cast sur l&#39;objet AssocData.
Ceci permet ensuite d&#39;utiliser les propriétés de l&#39;objet pour récupérer les données et les stocker dans des variables locales au Workflow pour un usage ultérieur.&lt;/li&gt;&lt;/ol&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Etape 3 : Paramétrage de la feature&lt;/span&gt;

&lt;ol&gt;
&lt;li&gt;une fois que le code est écrit et compilé, jeté dans le GAC, il faut créer une feature qui va se charger d&#39;assembler tout ceci en quelque chose de cohérent. Dans un répertoire, il vous faudra avoir un fichier feature.xml, un fichier workflow.xml et votre formulaire,&lt;span style=&quot;FONT-STYLE: italic&quot;&gt; GYWFPOAssocForm.xsn&lt;/span&gt; dans mon cas.
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh2GABmqNCJApF9yhIAbmoK0rp7kgVRDQ6BT41daiKA1FpQRfYvbSPtRc0hMmu9Cz0jE0ijxTpobhG57zWvLsjYWECmzrK0nregRwm8bvanMASeb6Bn285fY4zgf4Zt-skMFIEIuqMWQ/s1600-h/WF_Blog_Deploy1.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5142645706340218210&quot; style=&quot;CURSOR: hand&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh2GABmqNCJApF9yhIAbmoK0rp7kgVRDQ6BT41daiKA1FpQRfYvbSPtRc0hMmu9Cz0jE0ijxTpobhG57zWvLsjYWECmzrK0nregRwm8bvanMASeb6Bn285fY4zgf4Zt-skMFIEIuqMWQ/s320/WF_Blog_Deploy1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
(ne vous occupez pas pour l&#39;instant du quatrième fichier, qui fera l&#39;objet d&#39;un autre article)
Le fichier feature.xml se présente de la façon suivante :

&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;

&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Feature Id=&quot;B72AA389-51B8-4d7b-8730-F5A2885F9E93&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;Title=&quot;Purchase Order Workflow&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;Description=&quot;Purchase Order workflow, automated review process&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;Version=&quot;12.0.0.0&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;Scope=&quot;Site&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;ReceiverAssembly=&quot;Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;ReceiverClass=&quot;Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;ElementManifests&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;ElementManifest Location=&quot;workflow.xml&quot; /&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;/ElementManifests&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Properties&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Property Key=&quot;GloballyAvailable&quot; Value=&quot;true&quot; /&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Property Key=&quot;RegisterForms&quot; Value=&quot;*.xsn&quot; /&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;/Properties&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;/Feature&amp;gt;&lt;/span&gt;
Puis le fichier workflow.xml :
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;gt;&lt;/span&gt;

&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Workflow&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;Name=&quot;Purchase Order Workflow&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;Description=&quot;Puchase Order Workflow, automated review process&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;Id=&quot;869774CD-6710-4583-938B-5B691903CCBF&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;CodeBesideClass=&quot;MyWorkflow.WFPO&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;CodeBesideAssembly=&quot;MyWorkflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=53941405af02689c&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;TaskListContentTypeId=&quot;0x01080100C9C9515DE4E24001905074F980F93160&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;AssociationUrl=&quot;_layouts/CstWrkflIP.aspx&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;ModificationUrl=&quot;_layouts/ModWrkflIP.aspx&quot;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;StatusUrl=&quot;_layouts/WrkStat.aspx&quot;&amp;gt;&lt;/span&gt;

&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Categories/&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;!-- Tags to specify InfoPath forms for the workflow; delete tags for forms that you do not have --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;MetaData&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;Association_FormURN&amp;gt;urn:schemas-microsoft-com:office:infopath:GYWFPOAssocForm:-myXSD-2007-05-14T07-58-42&amp;lt;/Association_FormURN&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;AssociateOnActivation&amp;gt;false&amp;lt;/AssociateOnActivation&amp;gt;&lt;/span&gt;

&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;/MetaData&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;/Workflow&amp;gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;&amp;lt;/Elements&amp;gt;&lt;/span&gt;

Pour obtenir l&#39;URN du formulaire InfoPath, il faut charger le formulaire dans InfoPath (design Template), puis aller dans File / Properties et copier/coller l&#39;urn entre les tags &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;&lt;association_formurn&gt;
&lt;/association_formurn&gt;&lt;/span&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMo7odip-JoLaWnreWiRT7ecSnxE3TGP0bO4z8W7TEbydlgWb7zFLNd8XU_7n0AfmrkLhhj9JiX1Xzc2bevCs9qFUtrB2QKq2-lWJh9oJcEtFnSynEs8y0-rHLIDLM_1SZMjS88O5o_A/s1600-h/WF_Blog_URN.jpg&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5093023030052690866&quot; style=&quot;CURSOR: pointer&quot; alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMo7odip-JoLaWnreWiRT7ecSnxE3TGP0bO4z8W7TEbydlgWb7zFLNd8XU_7n0AfmrkLhhj9JiX1Xzc2bevCs9qFUtrB2QKq2-lWJh9oJcEtFnSynEs8y0-rHLIDLM_1SZMjS88O5o_A/s320/WF_Blog_URN.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;CodeBesideClass &lt;/span&gt;et &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;CodeBesideAssembly &lt;/span&gt;correspondent à la DLL et la classe de votre workflow.
&lt;/li&gt;


&lt;li&gt;Ceci fait, il faut copier le répertoire d&#39;installation (GYPOWorkflow) dans le répertoire &lt;span style=&quot;FONT-STYLE: italic&quot;&gt;&quot;12\Template\Feature&quot;&lt;/span&gt; et il vous faut installer (&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;stsadm -o install feature GYPOWorkflow\feature.xml&lt;/span&gt;) et activer (&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;stsadm -o activatefeature -filename &quot;&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;GYPOWorkflow&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;\feature.xml&quot; -url http://dcmoss:50010/&lt;/span&gt;) la feature.
&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;Voilà, c&#39;est tout, normalement cela doit marcher. C&#39;est un peu laborieux, mais une fois que le formulaire est enregistré, il est très simple de le modifier. Et c&#39;est très joli !




&lt;div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/2287974167567243863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/2287974167567243863' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/2287974167567243863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/2287974167567243863'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/07/sharepoint-2007-workflow-et-association.html' title='SharePoint 2007 : Workflow et Association Form avec InfoPath 2007'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRvQWjtfaJ2pzU7JwfK6NxOILDwzZcdbbpGywu9ALNodZaEL62w60VHaCs8NrhTlRAe4JpTsQOQfeok00BXWt8u7hj6xS9YiCqfPBybyai8DSYIdgg-UlcL2SR7oMXuZeLogwHy8tgnw/s72-c/WF_Blog_POWF1.jpg" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-4465597448503329358</id><published>2007-07-18T18:45:00.000+02:00</published><updated>2007-07-18T19:12:12.193+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MOSS 2007"/><title type='text'>Champs type Lookup et type People (update) et type Link</title><content type='html'>Je reviens rapidemment sur les deux champs à saisie simple et multiple, les champs Lookup et People
Comme je le précise dans mon &lt;a href=&quot;http://apichot.blogspot.com/2007/06/sharepoint-2007-champs-lookup-et-people.html&quot;&gt;article précédent&lt;/a&gt;, ils renvoient une chaîne de caractères bizarres composés d&#39;un couple ID/Libellé ( &quot;#1;#data1#;#2#data2#;&quot;)
Pour pouvoir accéder facilement aux données, il faut réussir à utiliser au final un type &lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue&lt;/span&gt; qui a deux propriétés utiles:
- &lt;span style=&quot;font-family:courier new;&quot;&gt;LookupId&lt;/span&gt; : pour récupérer l&#39;Id de l&#39;item de la liste liée dans le lookup
- &lt;span style=&quot;font-family:courier new;&quot;&gt;LookupValue &lt;/span&gt;: pour récupérer le libellé (ce qu&#39;on voit dans la liste)

Dans le cas d&#39;une sélection multiple, on doit utiliser le constructeur de &lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValueCollection&lt;/span&gt; avec en paramètre la chaîne de caractère à traiter :
&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValueCollection spcol = new SPFieldLookupValueCollection(&lt;em&gt;string_from_field&lt;/em&gt;)&lt;/span&gt;
&lt;span style=&quot;font-family:arial;&quot;&gt;Ce qui retournera une collection de &lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue&lt;/span&gt;
&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;Par contre, si c&#39;est une sélection unique, deux cas se présentent :&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;Cas 1 : c&#39;est un champ de type Lookup, alors on peut utiliser le contructeur de &lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue&lt;/span&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; :&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue spfield = new SPFieldLookupValue(&lt;em&gt;string_from_field)&lt;/em&gt;&lt;/span&gt;

&lt;span style=&quot;font-family:arial;&quot;&gt;Cas 2 : c&#39;est un champ de type People, alors ce champs renvoit un Integer qui est l&#39;Id du SPUser :&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;SPUser user = web.AllUsers.GetByID(&lt;em&gt;userId&lt;/em&gt;);&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;strong&gt;Le champs de type Link&lt;/strong&gt;&lt;/span&gt;
&lt;strong&gt;&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;&lt;/strong&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;Le champ de type Link a besoin de deux informations :&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;- l&#39;URL&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;- La description&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;Pour adresser un tel champs, il faut utiliser l&#39;objet &lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldUrlValue&lt;/span&gt; et renseigner les deux propriétés &lt;span style=&quot;font-family:courier new;&quot;&gt;Description&lt;/span&gt; et &lt;span style=&quot;font-family:courier new;&quot;&gt;Url &lt;/span&gt;:&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldUrlValue linkURL = new SPFieldUrlValue();&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;linkURL.Description = &lt;em&gt;description&lt;/em&gt;;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;linkURL.Url = &lt;em&gt;link&lt;/em&gt;; &lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;La description représente le libellé qui apparaîtra dans la colonne. Ce libellé sera un lien vers &lt;/span&gt;&lt;span style=&quot;font-family:courier new;&quot;&gt;Url&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;Voilà trois champs que l&#39;on rencontre très souvent et qui sont un petit peu pénible à utiliser.&lt;/span&gt;
&lt;span style=&quot;font-family:Arial;&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/4465597448503329358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/4465597448503329358' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/4465597448503329358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/4465597448503329358'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/07/champs-type-lookup-et-type-people.html' title='Champs type Lookup et type People (update) et type Link'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-8641747040167449081</id><published>2007-06-05T11:32:00.000+02:00</published><updated>2007-06-05T11:59:38.127+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint 2007"/><title type='text'>SharePoint 2007 : Champs Lookup et People</title><content type='html'>Je me suis arraché les cheveux pour répondre à ce qui me semble être une incohérence :
&lt;em&gt;Cas 1&lt;/em&gt;: si on utilise un champ &lt;strong&gt;lookup ou People&lt;/strong&gt; dans une liste, les données sont renvoyées sous forme d&#39;une chaîne de caractères &quot;#1#;data1#;&quot;.
&lt;em&gt;Cas 2&lt;/em&gt;: Si on utilise un champ &lt;strong&gt;lookup ou&lt;/strong&gt; &lt;strong&gt;people&lt;/strong&gt; dans une liste avec sélection multiple, les données sont renvoyées sous forme d&#39;une chaîne de caractères &quot;#1#;data1#;#2#data2#;&quot;.

Il existe un objet &lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValueCollection&lt;/span&gt; qui contient des &lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue&lt;/span&gt; qui a deux propriétés intéressantes :

- &lt;span style=&quot;font-family:courier new;&quot;&gt;LookupId&lt;/span&gt; : pour récupérer l&#39;Id de l&#39;item de la liste liée dans le lookup
- &lt;span style=&quot;font-family:courier new;&quot;&gt;LookupValue&lt;/span&gt; : pour récupérer le libellé (ce qu&#39;on voit dans la liste)

Dans le &lt;em&gt;Cas 2&lt;/em&gt;, on peut &quot;caster&quot; cette chaîne à l&#39;aide de :

&lt;span style=&quot;font-family:courier new;&quot;&gt;SPListitem relation;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValueCollection temp = (SPFieldLookupValueCollection)relation[&quot;&lt;em&gt;columnName&lt;/em&gt;&quot;];&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;&quot;&gt;&lt;/span&gt;
&lt;em&gt;columnName&lt;/em&gt; est une colonne de type lookup ou people à sélection multiple et &lt;em&gt;relation&lt;/em&gt; est un élément de la liste

Mais cela ne marche pas dans le &lt;em&gt;Cas 1&lt;/em&gt; : SharePoint génère une erreur. Une première approche serait de caster avec &lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue&lt;/span&gt; :

&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue tempValue = (SPFieldLookupValue)relation[&quot;columnName&quot;];&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;&quot;&gt;&lt;/span&gt;
&lt;span &gt;Mais non, ça ne marche toujours pas !&lt;/span&gt;

Ce qu&#39;il faut faire, avant de chercher un super algorithme de parsing de la chaîne de caractères, c&#39;est d&#39;utiliser un paramètre du constructeur :

&lt;span style=&quot;font-family:courier new;&quot;&gt;SPFieldLookupValue tempValue =  new SPFieldLookupValue(relation[&quot;columnName&quot;].ToString());&lt;/span&gt;

Dans ce cas on obtient bien un objet SPFieldLookupValue avec les propriétés &lt;span style=&quot;font-family:courier new;&quot;&gt;LookupId&lt;/span&gt; et &lt;span style=&quot;font-family:courier new;&quot;&gt;LookupValue&lt;/span&gt; qui sont vraiment bien pratiques.

Pourquoi ne pas avoir une seule façon de &quot;caster&quot; ??</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/8641747040167449081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/8641747040167449081' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/8641747040167449081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/8641747040167449081'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/06/sharepoint-2007-champs-lookup-et-people.html' title='SharePoint 2007 : Champs Lookup et People'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-4573659541288627873</id><published>2007-05-29T09:48:00.000+02:00</published><updated>2007-05-29T12:18:09.006+02:00</updated><title type='text'>Sharepoint 2007: upload d&#39;un document avec ses meta-data</title><content type='html'>J&#39;ai dû récemment faire l&#39;application suivante:
Des documents étaient générés automatiquement par une application externe. Le but du programme était de récupérer ces documents pour les mettre dans une document list, avec leurs meta-data. Puis de lancer un workflow pour approbation avec différents paramètres.

Dans cet article, je vais m&#39;attacher à l&#39;importation des fichiers dans la liste. Je ferai un autre article pour le workflow.

Le premier réflexe est bien entendu de télécharger le document dans la liste puis de faire une correspondance entre les colonnes de la liste et des meta-data. Mais étant donné que je gère les versions dans cette liste, cette façon de faire risque d&#39;incrémenter un numéro de version pour rien, suite à deux updates (un pour le document, un pour les meta-données)

Mais en cherchant un peu, j&#39;ai trouvé un overload bien pratique...

La première chose est de considérer la liste comme un folder, et de récupérer dans ce folder la collection des fichiers existants.
Le folder se récupère en utilisant le nom interne de la liste. Je spécifie bien le nom interne, c&#39;est à dire le nom qui a été utilisé la première fois lors de la création de la liste (si elle a été créée via l&#39;UI). On trouve ce nom en regardant dans l&#39;url de la liste. Par exemple :
&lt;a href=&quot;http://dcmoss:50010/testgy/PurchaseOrder&quot;&gt;http://dcmoss:50010/testgy/&lt;em&gt;PurchaseOrder&lt;/em&gt;&lt;/a&gt;
&lt;em&gt;PurchaseOder&lt;/em&gt; est bien le nom du folder, même si la liste s&#39;appelle &quot;&lt;em&gt;Purchase Order&lt;/em&gt;&quot;.

SPFolder folder = _web.GetFolder(&quot;&lt;em&gt;nom interne de la liste&lt;/em&gt;&quot;);
SPFileCollection files = folder.Files;

Puis je récupère le fichier lui-même, en le stockant dans un stream mémoire

FileStream fStream = File.OpenRead(&quot;&lt;em&gt;fileName&lt;/em&gt;&quot;);

Pour terminer je crée l&#39;URL du fichier, avec son nom:

string url = &quot;&lt;em&gt;url Site web&lt;/em&gt;&quot; + &quot;&lt;em&gt;nom interne de la liste&lt;/em&gt;&quot; + &quot;/&quot; + Path.GetFileName(&quot;&lt;em&gt;fileName&lt;/em&gt;&quot;);

Maintenant, les meta-data doivent être stockée dans une HashTable:

HashTable MetaDataTable = new HashTable();
MetaDataTable.Add(&quot;&lt;em&gt;nom de colonne&lt;/em&gt;&quot;, &quot;&lt;em&gt;valeur&lt;/em&gt;&quot;);
En réalité j&#39;ai une classe qui parse le fichier texte et qui me renvoit une hashtable.

Enfin, je l&#39;ajoute le tout à la collection de fichier de la liste:

SPFile currentFile = files.Add(url, fStream, MetaDataTable, true);

Le flag &lt;em&gt;True&lt;/em&gt; permet d&#39;écraser un fichier s&#39;il est déjà présent.

En une ligne, on ajoute un fichier avec ses meta-données. Pas mal, non ?


Voici un exemple de code pour uploader un document avec les meta-données:

&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;//Using required, especially System.IO&lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;using System.Collections.Generic;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;using System.Collections;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;using System.Text;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;using Microsoft.SharePoint;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;using System.IO;&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;namespace DocImport&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;{    &lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;public class DocManagement    {        &lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;//Some variables&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;private string _DestUrlPath  = string.Empty;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;private string _DestFolder   = string.Empty;
 &lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;private SPSite _site = null;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;private SPWeb  _web  = null;&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;public DocManagment(string DestUrl, string DestFolder) {&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;  _DestUrlPath = DestUrl;&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;  _DestFolder = DestFolder;&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;  _site = new SPSite(_DestUrlPath);&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;  _web = _site.OpenWeb();&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;private bool _uploadDocument(string pdfFile, string txtFile) {            &lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;  try {&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    //This is mandatory for avoiding an error&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    _web.AllowUnsafeUpdates = true;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    //Use the list as a folder&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    SPFolder folder = _web.GetFolder(_DestFolder);&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    SPFileCollection files = folder.Files;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    //Get the file&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    FileStream fStream = File.OpenRead(pdfFile);&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    HashTable MetaDataTable = new HashTable();&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    MetaDataTable.Add(&quot;nom de colonne&quot;, &quot;valeur&quot;);&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    &lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    //Set the destination url for SharePoint&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    string url = _DestUrlPath + _DestFolder + &quot;/&quot; + Path.GetFileName(pdfFile);&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    //Add document to the list with metadata, and overwrite an existing document&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;with the same name&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    SPFile currentFile = files.Add(url, fStream, MetaDataTable, true);&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    fStream.Close();&lt;/span&gt;
&lt;span style=&quot;font-family:Courier New;font-size:85%;&quot;&gt;    return true;&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;  } catch (Exception x) {&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;    throw new Exception(x.Message);&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;  }           &lt;/span&gt;&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt; &lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;font-family:courier new;font-size:85%;&quot;&gt;}&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/4573659541288627873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/4573659541288627873' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/4573659541288627873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/4573659541288627873'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/05/sharepoint-2007-upload-dun-document.html' title='Sharepoint 2007: upload d&#39;un document avec ses meta-data'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5495217247354866797.post-8266772026367590708</id><published>2007-05-23T11:48:00.001+02:00</published><updated>2007-05-23T11:55:30.365+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sharepoint"/><category scheme="http://www.blogger.com/atom/ns#" term="workflow"/><title type='text'>Sharepoint 2007 Workflow Update Item</title><content type='html'>Dans un workflow déclenché par une modification de l&#39;item d&#39;une liste, il est souvent nécessaire de mettre à jour une meta-donnée de cet item.
Le principe est simple en utilisant par exemple :

workflowProperties.Item[&quot;Status&quot;] = &quot;Archived&quot;;

Mais que ce passe-t-il lorsqu&#39;on met à jour ?
Le fait de faire workflowProperties.Item.update(); déclenche l&#39;événement de mise à jour, et donc redéclenche le workflow, donc une erreur car une instance du même workflow est déjà active sur cet item.

La réponse est dans l&#39;instruction suivante :

workflowProperties.Item.SystemUpdate();

Cette méthode permet d&#39;écrire directement dans la base, sans déclencher les événements sur l&#39;item. D&#39;autre part, il est possible de spécifier un flag (true/false) pour incrémenter ou non la version.</content><link rel='replies' type='application/atom+xml' href='http://apichot.blogspot.com/feeds/8266772026367590708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5495217247354866797/8266772026367590708' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/8266772026367590708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5495217247354866797/posts/default/8266772026367590708'/><link rel='alternate' type='text/html' href='http://apichot.blogspot.com/2007/05/sharepoint-2007-workflow-update-item.html' title='Sharepoint 2007 Workflow Update Item'/><author><name>Antoine Pichot</name><uri>http://www.blogger.com/profile/15190228901796083769</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>