<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Miguel Isidoro</title><link>http://weblogs.pontonetpt.com/miguelisidoro/</link><description>Blog sobre .NET, Sharepoint e tecnologia em geral.</description><dc:language>pt-PT</dc:language><generator>RSS Generated by Dottext 0.94</generator><item><dc:creator>Miguel Isidoro</dc:creator><title>InfoPath 2007 - Conditional SUM</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/28037.aspx</link><pubDate>Sat, 02 Aug 2008 15:52:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/28037.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/28037.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/28037.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/28037.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=28037</trackback:ping><description>&lt;p&gt;This blog post will show you how to create an expression box in an InfoPath 2007 form whose value is based on the result of an conditional sum. Consider the following InfoPath form template:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/328442040.jpg" /&gt; &lt;/p&gt;  &lt;p&gt;The previous image shows a simple expense report. To support the introduction of the expense information, a Repeating Table control is used with three columns: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Expense&lt;/strong&gt; - Expense Description. A simple Text Box control;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Value&lt;/strong&gt; - Expense value. A simple Text Box control;&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Expense Type&lt;/strong&gt; - Drop-down List Box control that allows 4 expense types: Food, Land Travel, Air Travel and Parking.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Below the repeating table there are 5 expression boxes that show the total amount of the expense report and the total amount for each expense type. The total amount expression box is based on a simple sum expression and each of the expense type expression boxes are based on conditional sums filtered by the value of the expense type Drop-down List Box control. The expressions used for each expense type are the following:&lt;/p&gt;  &lt;div align="center"&gt;   &lt;table cellspacing="0" cellpadding="2" width="530" align="center" border="1"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td valign="top" width="176"&gt;&lt;strong&gt;Expression Box&lt;/strong&gt;&lt;/td&gt;          &lt;td valign="top" width="176"&gt;&lt;strong&gt;Expression&lt;/strong&gt;&lt;/td&gt;          &lt;td valign="top" width="176"&gt;&lt;strong&gt;XPath Expression&lt;/strong&gt;&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="176"&gt;Expense Total&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(expensevalue)&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(my:accounting/my:expensevalue)&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="176"&gt;Food Expense Total&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(accounting[expensetype = "Food"]/expensevalue)&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(my:accounting[my:expensetype = "Food"]/my:expensevalue)&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="176"&gt;Land Travel Expense Total&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(accounting[expensetype = "Land Travel"]/expensevalue)&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(my:accounting[my:expensetype = "Land Travel"]/my:expensevalue)&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="176"&gt;Air Travel Expense Total&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(accounting[expensetype = "Air Travel"]/expensevalue)&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(my:accounting[my:expensetype = "Air Travel"]/my:expensevalue)&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td valign="top" width="176"&gt;Parking Expense Total&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(accounting[expensetype = "Parking"]/expensevalue)&lt;/td&gt;          &lt;td valign="top" width="176"&gt;sum(my:accounting[my:expensetype = "Parking"]/my:expensevalue)&lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt;  &lt;p&gt;As the previous table shows, the conditional sum expressions for each expense type are relatively simple and pretty straightforward for those who are familiarized with XPath, since XPath syntax is used for each expression. This comes as no surprise since the underlying data of the InfoPath form is stored in XML. The following image shows an expense report example filled with some sample values:&lt;/p&gt;  &lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/328442036.jpg" /&gt;&lt;/p&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>This blog post will show you how to create an expression box in an InfoPath 2007 form whose value is based on the result of an conditional sum. Consider the following InfoPath form template:</p>  <p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/328442040.jpg" /> </p>  <p>The previous image shows a simple expense report. To support the introduction of the expense information, a Repeating Table control is used with three columns: </p>  <ul>   <li><strong>Expense</strong> - Expense Description. A simple Text Box control;</li>    <li><strong>Value</strong> - Expense value. A simple Text Box control;</li>    <li><strong>Expense Type</strong> - Drop-down List Box control that allows 4 expense types: Food, Land Travel, Air Travel and Parking.</li> </ul>  <p>Below the repeating table there are 5 expression boxes that show the total amount of the expense report and the total amount for each expense type. The total amount expression box is based on a simple sum expression and each of the expense type expression boxes are based on conditional sums filtered by the value of the expense type Drop-down List Box control. The expressions used for each expense type are the following:</p>  <div align="center">   <table cellspacing="0" cellpadding="2" width="530" align="center" border="1"><tbody>       <tr>         <td valign="top" width="176"><strong>Expression Box</strong></td>          <td valign="top" width="176"><strong>Expression</strong></td>          <td valign="top" width="176"><strong>XPath Expression</strong></td>       </tr>        <tr>         <td valign="top" width="176">Expense Total</td>          <td valign="top" width="176">sum(expensevalue)</td>          <td valign="top" width="176">sum(my:accounting/my:expensevalue)</td>       </tr>        <tr>         <td valign="top" width="176">Food Expense Total</td>          <td valign="top" width="176">sum(accounting[expensetype = "Food"]/expensevalue)</td>          <td valign="top" width="176">sum(my:accounting[my:expensetype = "Food"]/my:expensevalue)</td>       </tr>        <tr>         <td valign="top" width="176">Land Travel Expense Total</td>          <td valign="top" width="176">sum(accounting[expensetype = "Land Travel"]/expensevalue)</td>          <td valign="top" width="176">sum(my:accounting[my:expensetype = "Land Travel"]/my:expensevalue)</td>       </tr>        <tr>         <td valign="top" width="176">Air Travel Expense Total</td>          <td valign="top" width="176">sum(accounting[expensetype = "Air Travel"]/expensevalue)</td>          <td valign="top" width="176">sum(my:accounting[my:expensetype = "Air Travel"]/my:expensevalue)</td>       </tr>        <tr>         <td valign="top" width="176">Parking Expense Total</td>          <td valign="top" width="176">sum(accounting[expensetype = "Parking"]/expensevalue)</td>          <td valign="top" width="176">sum(my:accounting[my:expensetype = "Parking"]/my:expensevalue)</td>       </tr>     </tbody></table> </div>  <p>As the previous table shows, the conditional sum expressions for each expense type are relatively simple and pretty straightforward for those who are familiarized with XPath, since XPath syntax is used for each expression. This comes as no surprise since the underlying data of the InfoPath form is stored in XML. The following image shows an expense report example filled with some sample values:</p>  <p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/328442036.jpg" /></p></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>SharePoint 2007 - New instances of this workflow template are currently disallowed</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/27781.aspx</link><pubDate>Sat, 12 Jul 2008 11:29:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/27781.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/27781.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/27781.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/27781.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=27781</trackback:ping><description>&lt;p&gt;When creating a new custom workflow project using Visual Studio 2008, a strong key file (.snk) file is automatically included in the project to sign the workflow assembly. A few days ago, I started developing a SharePoint 2007 Sequential Workflow project. After finishing developing the workflow, I deployed it and started testing it by associating the workflow to a content type (Site Settings &amp;gt; Site Content Type Gallery &amp;gt; Site Content Type &amp;gt; Workflow settings). I then noticed that the strong key file that was being used to sign the workflow assembly wasn't the one I usually use and modified the project settings so that it started using it. After recompiling the project and redeploying the workflow, I started to get an error message: "New instances of this workflow template are currently disallowed". The reason for this message to appear is that a new version version of the workflow had been deployed (same assembly with a different public key token due to the change in the strong key file used to sign the assembly). In these situations, the existing workflow associations made from older versions of the workflow are automatically set to "No New Instances", meaning that new instances of the workflow for those workflow associations are not allowed. The image below shows the Remove Workflow page with my custom workflow association set to "No New Instances". To access this page, go to Site Settings &amp;gt; Site Content Type Gallery &amp;gt; Site Content Type &amp;gt; Workflow settings &amp;gt; Remove Workflows if the workflow is associated with a content type.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/325207336.jpg" /&gt; &lt;/p&gt;  &lt;p&gt;To solve the problem, all you have to do is to set the workflow association to "Allow" and new instances of the workflow can again be created.&lt;/p&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>When creating a new custom workflow project using Visual Studio 2008, a strong key file (.snk) file is automatically included in the project to sign the workflow assembly. A few days ago, I started developing a SharePoint 2007 Sequential Workflow project. After finishing developing the workflow, I deployed it and started testing it by associating the workflow to a content type (Site Settings &gt; Site Content Type Gallery &gt; Site Content Type &gt; Workflow settings). I then noticed that the strong key file that was being used to sign the workflow assembly wasn't the one I usually use and modified the project settings so that it started using it. After recompiling the project and redeploying the workflow, I started to get an error message: "New instances of this workflow template are currently disallowed". The reason for this message to appear is that a new version version of the workflow had been deployed (same assembly with a different public key token due to the change in the strong key file used to sign the assembly). In these situations, the existing workflow associations made from older versions of the workflow are automatically set to "No New Instances", meaning that new instances of the workflow for those workflow associations are not allowed. The image below shows the Remove Workflow page with my custom workflow association set to "No New Instances". To access this page, go to Site Settings &gt; Site Content Type Gallery &gt; Site Content Type &gt; Workflow settings &gt; Remove Workflows if the workflow is associated with a content type.</p>  <p> </p>  <p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/325207336.jpg" /> </p>  <p>To solve the problem, all you have to do is to set the workflow association to "Allow" and new instances of the workflow can again be created.</p></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>SharePoint 2007 - Start a Workflow Programmatically</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/27738.aspx</link><pubDate>Sat, 05 Jul 2008 09:27:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/27738.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/27738.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/27738.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/27738.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=27738</trackback:ping><description>&lt;h5&gt;Introduction&lt;/h5&gt;  &lt;p&gt;This blog post will show you how to start a workflow programmatically every time an item is updated in a SharePoint list. For those who don’t know, Windows Workflow Foundation (WF) is the new engine for building custom workflows (you can find more information about WF on the &lt;a href="http://msdn.microsoft.com/winfx/technologies/workflow/default.aspx"&gt;official web site&lt;/a&gt;). It was released as part of the .NET Framework 3.0 along with &lt;a href="http://msdn2.microsoft.com/en-us/netframework/aa663326.aspx"&gt;Windows Presentation Foundation (WPF)&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx"&gt;Windows Communication Foundation (WCF)&lt;/a&gt;. In the SharePoint world, workflows can be associated both to a list and to a content type. Both options are valid and the choice for one or the other option depends on your needs:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;If you want to run a workflow in a list, independently of the content type of each list item, you should associate the workflow to a list. If you have more than one content type associated to the list, care should be taken in the workflow implementation since each content type can have different columns that may not be present in the other content types;&lt;/li&gt;    &lt;li&gt;If you want to run the workflow on all items of a specific content type, you should associate the workflow to a content type. The workflow will be associated to all list items from that content type in all lists across a site or the whole site collection (depending on the scope of the workflow, typically defined in its deployment feature) that are associated with the content type.&lt;/li&gt; &lt;/ul&gt;  &lt;h5&gt;Example&lt;/h5&gt;  &lt;p&gt;The following example shows how both options can be addressed. This example uses an event handler and starts a workflow every time an item is updated in a SharePoint list.&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ProgrammaticWorkflowInitiationEventReceiver &lt;/span&gt;: SPItemEventReceiver
{
    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Event handler for item updated event.
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="properties"&amp;gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;public override void &lt;/span&gt;ItemUpdated(SPItemEventProperties properties)
    {
        &lt;span style="color: green"&gt;//use this method if the workflow is associated to a list
        &lt;/span&gt;StartListWorkflow(properties);

        &lt;span style="color: green"&gt;//use this method if the workflow is associated to a content type
        &lt;/span&gt;StartContentTypeWorkflow(properties);
    }

    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Starts a workflow associated to a list programmatically.
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="properties"&amp;gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;StartListWorkflow(SPItemEventProperties properties)
    {
        &lt;span style="color: green"&gt;//get list item from event handler properties
        &lt;/span&gt;SPListItem listItem = properties.ListItem;

        &lt;span style="color: blue"&gt;using &lt;/span&gt;(SPWeb web = listItem.Web)
        {
            &lt;span style="color: blue"&gt;using &lt;/span&gt;(SPSite site = web.Site)
            {
                &lt;span style="color: green"&gt;//obtain an instance of SPWorkflowManager 
                //which will be later used to start the workflow
                &lt;/span&gt;SPWorkflowManager manager = site.WorkflowManager;
                &lt;span style="color: green"&gt;//get item's parent list
                &lt;/span&gt;SPList parentList = listItem.ParentList;
                &lt;span style="color: green"&gt;//get all workflows that are associated with the list
                &lt;/span&gt;SPWorkflowAssociationCollection associationCollection = 
                    parentList.WorkflowAssociations;
                &lt;span style="color: green"&gt;//lookup and start the worflow
                &lt;/span&gt;LookupAndStartWorkflow(listItem, manager, 
                    associationCollection, &lt;span style="color: #a31515"&gt;"MyListWorkflow"&lt;/span&gt;);
            }
        }
    }

    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Starts a workflow associated to a content type programmatically.
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="properties"&amp;gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;StartContentTypeWorkflow(SPItemEventProperties properties)
    {
        &lt;span style="color: green"&gt;//get list item from event handler properties
        &lt;/span&gt;SPListItem listItem = properties.ListItem;

        &lt;span style="color: blue"&gt;using &lt;/span&gt;(SPWeb web = listItem.Web)
        {
            &lt;span style="color: blue"&gt;using &lt;/span&gt;(SPSite site = web.Site)
            {
                &lt;span style="color: green"&gt;//obtain an instance of SPWorkflowManager 
                //which will be later used to start the workflow
                &lt;/span&gt;SPWorkflowManager manager = site.WorkflowManager;
                &lt;span style="color: green"&gt;//get item's content type
                &lt;/span&gt;SPContentType contentType = listItem.ContentType;
                &lt;span style="color: green"&gt;//get all workflows that are associated with the content type
                &lt;/span&gt;SPWorkflowAssociationCollection associationCollection = 
                    contentType.WorkflowAssociations;
                &lt;span style="color: green"&gt;//lookup and start the worflow
                &lt;/span&gt;LookupAndStartWorkflow(listItem, manager, 
                    associationCollection, &lt;span style="color: #a31515"&gt;"MyContentTypeWorkflow"&lt;/span&gt;);
            }
        }
    }

    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Lookup and start the workflow.
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="manager"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;param name="associationCollection"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;param name="workflowInstanceName"&amp;gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private static void &lt;/span&gt;LookupAndStartWorkflow(SPListItem listItem, 
        SPWorkflowManager manager, 
        SPWorkflowAssociationCollection associationCollection, 
        &lt;span style="color: blue"&gt;string &lt;/span&gt;workflowInstanceName)
    {
        &lt;span style="color: green"&gt;//iterate workflow associations and lookup the workflow to be started
        &lt;/span&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(SPWorkflowAssociation association &lt;span style="color: blue"&gt;in &lt;/span&gt;associationCollection)
        {
            &lt;span style="color: green"&gt;//if the workflow association matches the workflow we are looking for,
            //get its association data and start the workflow
            &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(association.Name.ToLower().Equals(workflowInstanceName))
            {
                &lt;span style="color: green"&gt;//get workflow association data
                &lt;/span&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;data = association.AssociationData;

                &lt;span style="color: green"&gt;//start workflow
                &lt;/span&gt;SPWorkflow wf = manager.StartWorkflow(listItem, association, data);
            }
        }
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;In the previous example, the following actions are being performed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The ItemUpdated event in the event handler is being handled. For demonstration purposes, I am assuming that two workflow associations were created, one to the list (named "MyListWorkflow") and another to a content type (named "MyContentTypeWorkflow");&lt;/li&gt;

  &lt;li&gt;A call is made to the &lt;em&gt;StartListWorkflow&lt;/em&gt; method, which starts the workflow associated with a list;&lt;/li&gt;

  &lt;li&gt;A call is made to the &lt;em&gt;StartContentTypeWorkflow&lt;/em&gt; method, which starts the workflow associated with a content type.&lt;/li&gt;
&lt;/ul&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><h5>Introduction</h5>  <p>This blog post will show you how to start a workflow programmatically every time an item is updated in a SharePoint list. For those who don’t know, Windows Workflow Foundation (WF) is the new engine for building custom workflows (you can find more information about WF on the <a href="http://msdn.microsoft.com/winfx/technologies/workflow/default.aspx">official web site</a>). It was released as part of the .NET Framework 3.0 along with <a href="http://msdn2.microsoft.com/en-us/netframework/aa663326.aspx">Windows Presentation Foundation (WPF)</a> and <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx">Windows Communication Foundation (WCF)</a>. In the SharePoint world, workflows can be associated both to a list and to a content type. Both options are valid and the choice for one or the other option depends on your needs:</p>  <ul>   <li>If you want to run a workflow in a list, independently of the content type of each list item, you should associate the workflow to a list. If you have more than one content type associated to the list, care should be taken in the workflow implementation since each content type can have different columns that may not be present in the other content types;</li>    <li>If you want to run the workflow on all items of a specific content type, you should associate the workflow to a content type. The workflow will be associated to all list items from that content type in all lists across a site or the whole site collection (depending on the scope of the workflow, typically defined in its deployment feature) that are associated with the content type.</li> </ul>  <h5>Example</h5>  <p>The following example shows how both options can be addressed. This example uses an event handler and starts a workflow every time an item is updated in a SharePoint list.</p>  <pre class="code"><span style="color: blue">public class </span><span style="color: #2b91af">ProgrammaticWorkflowInitiationEventReceiver </span>: SPItemEventReceiver
{
    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Event handler for item updated event.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="properties"&gt;&lt;/param&gt;
    </span><span style="color: blue">public override void </span>ItemUpdated(SPItemEventProperties properties)
    {
        <span style="color: green">//use this method if the workflow is associated to a list
        </span>StartListWorkflow(properties);

        <span style="color: green">//use this method if the workflow is associated to a content type
        </span>StartContentTypeWorkflow(properties);
    }

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Starts a workflow associated to a list programmatically.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="properties"&gt;&lt;/param&gt;
    </span><span style="color: blue">private void </span>StartListWorkflow(SPItemEventProperties properties)
    {
        <span style="color: green">//get list item from event handler properties
        </span>SPListItem listItem = properties.ListItem;

        <span style="color: blue">using </span>(SPWeb web = listItem.Web)
        {
            <span style="color: blue">using </span>(SPSite site = web.Site)
            {
                <span style="color: green">//obtain an instance of SPWorkflowManager 
                //which will be later used to start the workflow
                </span>SPWorkflowManager manager = site.WorkflowManager;
                <span style="color: green">//get item's parent list
                </span>SPList parentList = listItem.ParentList;
                <span style="color: green">//get all workflows that are associated with the list
                </span>SPWorkflowAssociationCollection associationCollection = 
                    parentList.WorkflowAssociations;
                <span style="color: green">//lookup and start the worflow
                </span>LookupAndStartWorkflow(listItem, manager, 
                    associationCollection, <span style="color: #a31515">"MyListWorkflow"</span>);
            }
        }
    }

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Starts a workflow associated to a content type programmatically.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="properties"&gt;&lt;/param&gt;
    </span><span style="color: blue">private void </span>StartContentTypeWorkflow(SPItemEventProperties properties)
    {
        <span style="color: green">//get list item from event handler properties
        </span>SPListItem listItem = properties.ListItem;

        <span style="color: blue">using </span>(SPWeb web = listItem.Web)
        {
            <span style="color: blue">using </span>(SPSite site = web.Site)
            {
                <span style="color: green">//obtain an instance of SPWorkflowManager 
                //which will be later used to start the workflow
                </span>SPWorkflowManager manager = site.WorkflowManager;
                <span style="color: green">//get item's content type
                </span>SPContentType contentType = listItem.ContentType;
                <span style="color: green">//get all workflows that are associated with the content type
                </span>SPWorkflowAssociationCollection associationCollection = 
                    contentType.WorkflowAssociations;
                <span style="color: green">//lookup and start the worflow
                </span>LookupAndStartWorkflow(listItem, manager, 
                    associationCollection, <span style="color: #a31515">"MyContentTypeWorkflow"</span>);
            }
        }
    }

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Lookup and start the workflow.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="manager"&gt;&lt;/param&gt;
    /// &lt;param name="associationCollection"&gt;&lt;/param&gt;
    /// &lt;param name="workflowInstanceName"&gt;&lt;/param&gt;
    </span><span style="color: blue">private static void </span>LookupAndStartWorkflow(SPListItem listItem, 
        SPWorkflowManager manager, 
        SPWorkflowAssociationCollection associationCollection, 
        <span style="color: blue">string </span>workflowInstanceName)
    {
        <span style="color: green">//iterate workflow associations and lookup the workflow to be started
        </span><span style="color: blue">foreach </span>(SPWorkflowAssociation association <span style="color: blue">in </span>associationCollection)
        {
            <span style="color: green">//if the workflow association matches the workflow we are looking for,
            //get its association data and start the workflow
            </span><span style="color: blue">if </span>(association.Name.ToLower().Equals(workflowInstanceName))
            {
                <span style="color: green">//get workflow association data
                </span><span style="color: blue">string </span>data = association.AssociationData;

                <span style="color: green">//start workflow
                </span>SPWorkflow wf = manager.StartWorkflow(listItem, association, data);
            }
        }
    }
}</pre>
<a href="http://11011.net/software/vspaste"></a>

<p>In the previous example, the following actions are being performed:</p>

<ul>
  <li>The ItemUpdated event in the event handler is being handled. For demonstration purposes, I am assuming that two workflow associations were created, one to the list (named "MyListWorkflow") and another to a content type (named "MyContentTypeWorkflow");</li>

  <li>A call is made to the <em>StartListWorkflow</em> method, which starts the workflow associated with a list;</li>

  <li>A call is made to the <em>StartContentTypeWorkflow</em> method, which starts the workflow associated with a content type.</li>
</ul></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>SharePoint 2007 -  Getting an SPListItem by ID after a Search</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/27668.aspx</link><pubDate>Mon, 23 Jun 2008 18:09:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/27668.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/27668.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/27668.aspx#feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/27668.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=27668</trackback:ping><description>&lt;p&gt;After making a search to a SharePoint site, it isn't always easy to get a reference to each item returned in the search. This is because we don't know the Web and List where each item is located. The following example shows how this can be achieved:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SiteCollectionSearch
&lt;/span&gt;{
    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Search items by title
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="web"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private static &lt;/span&gt;DataTable Search(SPWeb web)
    {
        &lt;span style="color: green"&gt;//search items by title
        &lt;/span&gt;StringBuilder query = &lt;span style="color: blue"&gt;new &lt;/span&gt;StringBuilder();
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;Where&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;Contains&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;FieldRef Name='Title' /&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;Value Type='Text'&amp;gt;SharePoint&amp;lt;/Value&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;/Contains&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;/Where&amp;gt;"&lt;/span&gt;);
        query.RowLimit = 100;

        SPSiteDataQuery query = &lt;span style="color: blue"&gt;new &lt;/span&gt;SPSiteDataQuery();
        query.Webs = &lt;span style="color: #a31515"&gt;"&amp;lt;Webs Scope='SiteCollection' /&amp;gt;"&lt;/span&gt;;
        spQuery.Query = query.ToString();

        &lt;span style="color: green"&gt;//perform the search
        &lt;/span&gt;DataTable searchResults = web.GetSiteData(query);

        &lt;span style="color: green"&gt;//return results - since ViewFields property is not specified in
        //the query, WebId, ListId and Item Id are automatically returned
        &lt;/span&gt;&lt;span style="color: blue"&gt;return &lt;/span&gt;searchResults;
    }

    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;After a search, obtains each item by its Id.
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="list"&amp;gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private static void &lt;/span&gt;GetItemsByID()
    {
        SPSite site = &lt;span style="color: blue"&gt;new &lt;/span&gt;SPSite(&lt;span style="color: #a31515"&gt;"http://portal"&lt;/span&gt;);
        &lt;span style="color: blue"&gt;using &lt;/span&gt;(SPWeb web = site.OpenWeb())
        {
            &lt;span style="color: green"&gt;//search documents by title
            &lt;/span&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;(DataTable docs = Search(web))
            {
                &lt;span style="color: green"&gt;//iterate results
                &lt;/span&gt;&lt;span style="color: blue"&gt;foreach &lt;/span&gt;(DataRow row &lt;span style="color: blue"&gt;in &lt;/span&gt;docs.Rows)
                {
                    &lt;span style="color: green"&gt;//get webId of the current item
                    &lt;/span&gt;Guid webId = &lt;span style="color: blue"&gt;new &lt;/span&gt;Guid(Convert.ToString(row[&lt;span style="color: #a31515"&gt;"WebID"&lt;/span&gt;]));
                    &lt;span style="color: green"&gt;//get listId of the current item
                    &lt;/span&gt;Guid listId = &lt;span style="color: blue"&gt;new &lt;/span&gt;Guid(Convert.ToString(row[&lt;span style="color: #a31515"&gt;"ListID"&lt;/span&gt;]));
                    &lt;span style="color: green"&gt;//get id of the current item
                    &lt;/span&gt;&lt;span style="color: blue"&gt;int &lt;/span&gt;itemId = Convert.ToString(row[&lt;span style="color: #a31515"&gt;"ID"&lt;/span&gt;]);

                    &lt;span style="color: green"&gt;//get the web where the item is located
                    &lt;/span&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;(SPWeb itemWeb = site.AllWebs[webId])
                    {
                        &lt;span style="color: green"&gt;//get list using the list id
                        &lt;/span&gt;SPList list = itemWeb.Lists[listId];

                        SPListItem listItem = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
                        &lt;span style="color: blue"&gt;try
                        &lt;/span&gt;{
                            &lt;span style="color: green"&gt;//get item using its id
                            &lt;/span&gt;listItem = list.Items[itemId];
                        }
                        &lt;span style="color: blue"&gt;catch &lt;/span&gt;{ }
                        &lt;span style="color: blue"&gt;if &lt;/span&gt;(listItem != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
                        {
                            &lt;span style="color: green"&gt;//do something with the item. Example: 
                            //update the title
                            &lt;/span&gt;listItem[&lt;span style="color: #a31515"&gt;"Title"&lt;/span&gt;] = listItem[&lt;span style="color: #a31515"&gt;"Title"&lt;/span&gt;] 
                                + &lt;span style="color: #a31515"&gt;" Updated"&lt;/span&gt;;
                            listItem.Update();
                        }
                    }
                }
            }
        }
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;In the previous example, the following actions are being performed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A search is performed to entire site collection for documents containing the word "SharePoint". As a result of that search, a DataTable instance is returned containing the search results; &lt;/li&gt;

  &lt;li&gt;Each row of the search results is iterated. For each row, three important values are obtained: the item's ID, ListId and WebId. These are obtained automatically in the result of a SPSiteDataQuery when the ViewFields property is not set;&lt;/li&gt;

  &lt;li&gt;The SPWeb instance where the item is located is obtained using the previously obtained WebId;&lt;/li&gt;

  &lt;li&gt;The SPList instance where the item is located is obtained using the previously obtained ListId;&lt;/li&gt;

  &lt;li&gt;The SPListItem is obtained from the list using the item's ID;&lt;/li&gt;

  &lt;li&gt;Finally, something is done with the item. For example, updating its title.&lt;/li&gt;
&lt;/ul&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>After making a search to a SharePoint site, it isn't always easy to get a reference to each item returned in the search. This is because we don't know the Web and List where each item is located. The following example shows how this can be achieved:</p>  <pre class="code"><span style="color: blue">class </span><span style="color: #2b91af">SiteCollectionSearch
</span>{
    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Search items by title
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="web"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    </span><span style="color: blue">private static </span>DataTable Search(SPWeb web)
    {
        <span style="color: green">//search items by title
        </span>StringBuilder query = <span style="color: blue">new </span>StringBuilder();
        query.Append(<span style="color: #a31515">"&lt;Where&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;Contains&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;FieldRef Name='Title' /&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;Value Type='Text'&gt;SharePoint&lt;/Value&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;/Contains&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;/Where&gt;"</span>);
        query.RowLimit = 100;

        SPSiteDataQuery query = <span style="color: blue">new </span>SPSiteDataQuery();
        query.Webs = <span style="color: #a31515">"&lt;Webs Scope='SiteCollection' /&gt;"</span>;
        spQuery.Query = query.ToString();

        <span style="color: green">//perform the search
        </span>DataTable searchResults = web.GetSiteData(query);

        <span style="color: green">//return results - since ViewFields property is not specified in
        //the query, WebId, ListId and Item Id are automatically returned
        </span><span style="color: blue">return </span>searchResults;
    }

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">After a search, obtains each item by its Id.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="list"&gt;&lt;/param&gt;
    </span><span style="color: blue">private static void </span>GetItemsByID()
    {
        SPSite site = <span style="color: blue">new </span>SPSite(<span style="color: #a31515">"http://portal"</span>);
        <span style="color: blue">using </span>(SPWeb web = site.OpenWeb())
        {
            <span style="color: green">//search documents by title
            </span><span style="color: blue">using </span>(DataTable docs = Search(web))
            {
                <span style="color: green">//iterate results
                </span><span style="color: blue">foreach </span>(DataRow row <span style="color: blue">in </span>docs.Rows)
                {
                    <span style="color: green">//get webId of the current item
                    </span>Guid webId = <span style="color: blue">new </span>Guid(Convert.ToString(row[<span style="color: #a31515">"WebID"</span>]));
                    <span style="color: green">//get listId of the current item
                    </span>Guid listId = <span style="color: blue">new </span>Guid(Convert.ToString(row[<span style="color: #a31515">"ListID"</span>]));
                    <span style="color: green">//get id of the current item
                    </span><span style="color: blue">int </span>itemId = Convert.ToString(row[<span style="color: #a31515">"ID"</span>]);

                    <span style="color: green">//get the web where the item is located
                    </span><span style="color: blue">using </span>(SPWeb itemWeb = site.AllWebs[webId])
                    {
                        <span style="color: green">//get list using the list id
                        </span>SPList list = itemWeb.Lists[listId];

                        SPListItem listItem = <span style="color: blue">null</span>;
                        <span style="color: blue">try
                        </span>{
                            <span style="color: green">//get item using its id
                            </span>listItem = list.Items[itemId];
                        }
                        <span style="color: blue">catch </span>{ }
                        <span style="color: blue">if </span>(listItem != <span style="color: blue">null</span>)
                        {
                            <span style="color: green">//do something with the item. Example: 
                            //update the title
                            </span>listItem[<span style="color: #a31515">"Title"</span>] = listItem[<span style="color: #a31515">"Title"</span>] 
                                + <span style="color: #a31515">" Updated"</span>;
                            listItem.Update();
                        }
                    }
                }
            }
        }
    }
}</pre>
<a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a>

<p>In the previous example, the following actions are being performed:</p>

<ul>
  <li>A search is performed to entire site collection for documents containing the word "SharePoint". As a result of that search, a DataTable instance is returned containing the search results; </li>

  <li>Each row of the search results is iterated. For each row, three important values are obtained: the item's ID, ListId and WebId. These are obtained automatically in the result of a SPSiteDataQuery when the ViewFields property is not set;</li>

  <li>The SPWeb instance where the item is located is obtained using the previously obtained WebId;</li>

  <li>The SPList instance where the item is located is obtained using the previously obtained ListId;</li>

  <li>The SPListItem is obtained from the list using the item's ID;</li>

  <li>Finally, something is done with the item. For example, updating its title.</li>
</ul></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>SharePoint 2007 - &amp;quot;Value does not fall within the expected range&amp;quot; when updating an SPListItem in a Search</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/27621.aspx</link><pubDate>Sat, 07 Jun 2008 11:33:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/27621.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/27621.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/27621.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/27621.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=27621</trackback:ping><description>&lt;p&gt;A very common error message that appears when developing in the SharePoint platform is "Value does not all within the expected range" when trying to update an SPListItem that is the result of a query to a SharePoint list. Let's look at the following example:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SearchListItem
&lt;/span&gt;{
    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Search document by title
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="list"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private static &lt;/span&gt;SPListItem SearchDocument(SPList list)
    {
        &lt;span style="color: green"&gt;//get receipt by using a query
        &lt;/span&gt;StringBuilder query = &lt;span style="color: blue"&gt;new &lt;/span&gt;StringBuilder();
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;Where&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;Eq&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;FieldRef Name='Title' /&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;Value Type='Text'&amp;gt;My document&amp;lt;/Value&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;/Eq&amp;gt;"&lt;/span&gt;);
        query.Append(&lt;span style="color: #a31515"&gt;"&amp;lt;/Where&amp;gt;"&lt;/span&gt;);

        SPView queryView = list.Views[&lt;span style="color: #a31515"&gt;"All Documents"&lt;/span&gt;];
        SPQuery spQuery = &lt;span style="color: blue"&gt;new &lt;/span&gt;SPQuery(queryView);
        spQuery.Query = query.ToString();
        spQuery.ViewAttributes = &lt;span style="color: #a31515"&gt;"Scope=\"RecursiveAll\""&lt;/span&gt;;

        SPListItemCollection items = list.GetItems(spQuery);
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(items != &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp; items.Count &amp;gt; 0)
            &lt;span style="color: blue"&gt;return &lt;/span&gt;items[0];

        &lt;span style="color: blue"&gt;return null&lt;/span&gt;;
    }

    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Update document.
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="list"&amp;gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private static void &lt;/span&gt;UpdateDocumentError(SPList list)
    {
        &lt;span style="color: green"&gt;//search document by title
        &lt;/span&gt;SPListItem doc = SearchDocument(list);
        &lt;span style="color: green"&gt;//update item in list
        &lt;/span&gt;doc[&lt;span style="color: #a31515"&gt;"Title"&lt;/span&gt;] = &lt;span style="color: #a31515"&gt;"My document modified"&lt;/span&gt;;
        doc.Update(); &lt;span style="color: green"&gt;//error "Value does not fall 
        //within the expected range" is thrown&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;    &lt;/span&gt;}

    &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
    /// &lt;/span&gt;&lt;span style="color: green"&gt;Update document.
    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="list"&amp;gt;&amp;lt;/param&amp;gt;
    &lt;/span&gt;&lt;span style="color: blue"&gt;private static void &lt;/span&gt;UpdateDocumentSucess(SPList list)
    {
        &lt;span style="color: green"&gt;//search document by title
        &lt;/span&gt;SPListItem doc = SearchDocument(list);
        &lt;span style="color: green"&gt;//get SPListItem directly from list
        &lt;/span&gt;&lt;strong&gt;SPListItem item = doc.ParentList.GetItemById(doc.ID);&lt;/strong&gt;
        &lt;span style="color: green"&gt;//update item in list
        &lt;/span&gt;item[&lt;span style="color: #a31515"&gt;"Title"&lt;/span&gt;] = &lt;span style="color: #a31515"&gt;"My document modified"&lt;/span&gt;;
        item.Update(); &lt;span style="color: green"&gt;//item updated sucessfully
    &lt;/span&gt;}
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;In the previous example, the following actions are being performed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A search is performed within a list for a document named "My Document". As a result of that search, a SPListItem instance is returned containing the document information;&lt;/li&gt;

  &lt;li&gt;In the "UpdateDocumentError" method, after the search is performed, the returned item is modified and the list is updated. This action will cause the exception "Value does not fall within the expected range" to be raised;&lt;/li&gt;

  &lt;li&gt;In the "UpdateDocumentSucess" method, after the search is performed, we obtain the item directly from the list using the ID of the SPListItem returned from the search (the line &lt;strong&gt;"SPListItem item = doc.ParentList.GetItemById(doc.ID);"&lt;/strong&gt; was added, returning a new SPListItem instance). The new instance is then modified and used to update the item in the list. This way, the item is sucessfully updated.&lt;/li&gt;
&lt;/ul&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>A very common error message that appears when developing in the SharePoint platform is "Value does not all within the expected range" when trying to update an SPListItem that is the result of a query to a SharePoint list. Let's look at the following example:</p>  <pre class="code"><span style="color: blue">class </span><span style="color: #2b91af">SearchListItem
</span>{
    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Search document by title
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="list"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    </span><span style="color: blue">private static </span>SPListItem SearchDocument(SPList list)
    {
        <span style="color: green">//get receipt by using a query
        </span>StringBuilder query = <span style="color: blue">new </span>StringBuilder();
        query.Append(<span style="color: #a31515">"&lt;Where&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;Eq&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;FieldRef Name='Title' /&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;Value Type='Text'&gt;My document&lt;/Value&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;/Eq&gt;"</span>);
        query.Append(<span style="color: #a31515">"&lt;/Where&gt;"</span>);

        SPView queryView = list.Views[<span style="color: #a31515">"All Documents"</span>];
        SPQuery spQuery = <span style="color: blue">new </span>SPQuery(queryView);
        spQuery.Query = query.ToString();
        spQuery.ViewAttributes = <span style="color: #a31515">"Scope=\"RecursiveAll\""</span>;

        SPListItemCollection items = list.GetItems(spQuery);
        <span style="color: blue">if </span>(items != <span style="color: blue">null </span>&amp;&amp; items.Count &gt; 0)
            <span style="color: blue">return </span>items[0];

        <span style="color: blue">return null</span>;
    }

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Update document.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="list"&gt;&lt;/param&gt;
    </span><span style="color: blue">private static void </span>UpdateDocumentError(SPList list)
    {
        <span style="color: green">//search document by title
        </span>SPListItem doc = SearchDocument(list);
        <span style="color: green">//update item in list
        </span>doc[<span style="color: #a31515">"Title"</span>] = <span style="color: #a31515">"My document modified"</span>;
        doc.Update(); <span style="color: green">//error "Value does not fall 
        //within the expected range" is thrown</span></pre>
<a href="http://11011.net/software/vspaste"></a>

<pre class="code"><span style="color: green">    </span>}

    <span style="color: gray">/// &lt;summary&gt;
    /// </span><span style="color: green">Update document.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;param name="list"&gt;&lt;/param&gt;
    </span><span style="color: blue">private static void </span>UpdateDocumentSucess(SPList list)
    {
        <span style="color: green">//search document by title
        </span>SPListItem doc = SearchDocument(list);
        <span style="color: green">//get SPListItem directly from list
        </span><strong>SPListItem item = doc.ParentList.GetItemById(doc.ID);</strong>
        <span style="color: green">//update item in list
        </span>item[<span style="color: #a31515">"Title"</span>] = <span style="color: #a31515">"My document modified"</span>;
        item.Update(); <span style="color: green">//item updated sucessfully
    </span>}
}</pre>
<a href="http://11011.net/software/vspaste"></a>

<p>In the previous example, the following actions are being performed:</p>

<ul>
  <li>A search is performed within a list for a document named "My Document". As a result of that search, a SPListItem instance is returned containing the document information;</li>

  <li>In the "UpdateDocumentError" method, after the search is performed, the returned item is modified and the list is updated. This action will cause the exception "Value does not fall within the expected range" to be raised;</li>

  <li>In the "UpdateDocumentSucess" method, after the search is performed, we obtain the item directly from the list using the ID of the SPListItem returned from the search (the line <strong>"SPListItem item = doc.ParentList.GetItemById(doc.ID);"</strong> was added, returning a new SPListItem instance). The new instance is then modified and used to update the item in the list. This way, the item is sucessfully updated.</li>
</ul></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>SharePoint 2007 - Save Site As Template in Publishing Sites</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/27449.aspx</link><pubDate>Fri, 16 May 2008 06:10:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/27449.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/27449.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/27449.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/27449.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=27449</trackback:ping><description>&lt;p&gt;One situation that you may have experienced is the lack of the "Save site as template" link in the Site Settings page of a MOSS 2007 site even if you have administrative privileges on the site or site collection. This will happen if your site is a Publishing site (either a Publishing site, used primarily for public faced Internet web sites or a Collaboration Portal, used primarily for Intranet Portals). You can check if your site is a Publishing site by checking if you have the Office SharePoint Server Publishing Infrastructure feature activated if you are at the top level of your site collection or if Office SharePoint Server Publishing feature is activated if you are in a sub site. Microsoft has disabled the "Save site as template" for Publishing sites and it is not supported. If you still want to save your publishing site as a template, you can do it by appending  "/_layouts/savetmpl.aspx" to the URL of your site. If the URL of your site is &lt;/p&gt;  &lt;p&gt;&lt;a href="http://intranetportal/site"&gt;http://intranetportal/site&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;you just have to go to &lt;/p&gt;  &lt;p&gt;&lt;a href="http://intranet/teamsite/_layouts/savetmpl.aspx"&gt;http://intranetportal/site/_layouts/savetmpl.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;in order for you to save your site as a template. I have already successfully managed to save collaboration portal sites as templates but it might happen that you encounter some problems if you try to save a publishing site as template since this is not a supported procedure. For more information on this, please check &lt;a href="http://support.microsoft.com/kb/925189/en-us" target="_blank"&gt;this Microsoft Support article&lt;/a&gt;.&lt;/p&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>One situation that you may have experienced is the lack of the "Save site as template" link in the Site Settings page of a MOSS 2007 site even if you have administrative privileges on the site or site collection. This will happen if your site is a Publishing site (either a Publishing site, used primarily for public faced Internet web sites or a Collaboration Portal, used primarily for Intranet Portals). You can check if your site is a Publishing site by checking if you have the Office SharePoint Server Publishing Infrastructure feature activated if you are at the top level of your site collection or if Office SharePoint Server Publishing feature is activated if you are in a sub site. Microsoft has disabled the "Save site as template" for Publishing sites and it is not supported. If you still want to save your publishing site as a template, you can do it by appending  "/_layouts/savetmpl.aspx" to the URL of your site. If the URL of your site is </p>  <p><a href="http://intranetportal/site">http://intranetportal/site</a></p>  <p>you just have to go to </p>  <p><a href="http://intranet/teamsite/_layouts/savetmpl.aspx">http://intranetportal/site/_layouts/savetmpl.aspx</a></p>  <p>in order for you to save your site as a template. I have already successfully managed to save collaboration portal sites as templates but it might happen that you encounter some problems if you try to save a publishing site as template since this is not a supported procedure. For more information on this, please check <a href="http://support.microsoft.com/kb/925189/en-us" target="_blank">this Microsoft Support article</a>.</p></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>Windows Workflow - Using the HandleExternalEventActivity</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/27250.aspx</link><pubDate>Wed, 16 Apr 2008 11:10:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/27250.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/27250.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/27250.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/27250.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=27250</trackback:ping><description>&lt;h5&gt;Introduction&lt;/h5&gt;  &lt;p&gt;This is the first in a series of blog posts dedicated to Windows Workflow. For those who don’t know, Windows Workflow Foundation (WF) is the new engine for building custom workflows (you can find more information about WF on the &lt;a href="http://msdn.microsoft.com/winfx/technologies/workflow/default.aspx"&gt;official web site&lt;/a&gt;). It was released as part of the .NET Framework 3.0 along with &lt;a href="http://msdn2.microsoft.com/en-us/netframework/aa663326.aspx"&gt;Windows Presentation Foundation (WPF)&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx"&gt;Windows Communication Foundation (WCF)&lt;/a&gt;.&lt;/p&gt;  &lt;h5&gt;Local Service Communication&lt;/h5&gt;  &lt;p&gt;Workflows are not isolated entities and most of the times need to communicate with the outside world in order to perform some task. There are several ways of communicating with external entities/services, being one of them External Data Exchange and Local Service Communication. Local Service Communication basically allows workflows to communicate with an external service that resides within the workflow host. There are two main activities inside WF that allow communication between a workflow and an external service using Local Service Communication:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;CallExternalMethodActivity&lt;/strong&gt; – Allows a workflow to call a method from an external service. The workflow and the host establish a contract (using an interface) that defines the way they communicate with each other. Basically the workflow calls a method of a service residing within the host that implements the contract interface. For more details about this activity, click &lt;a href="http://msdn2.microsoft.com/en-us/library/ms734739(VS.85).aspx" target="_blank"&gt;here&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;b&gt;HandleExternalEventActivity&lt;/b&gt; – Besides allowing the workflow to call an external method, it is also possible for the host to send an event to the workflow in order for it to perform some task. This is achieved using the HandleExternalEventActivity that will put the workflow on an idle state until an external event is raised. Just as in CallExternalMethodActivity, the communication between the workflow and the external is based on a contract. &lt;/li&gt; &lt;/ul&gt;  &lt;h5&gt;&lt;/h5&gt;  &lt;h5&gt;Summary&lt;/h5&gt;  &lt;p&gt;To build a workflow that uses HandleExternalEventActivity to communicate with a service using Local Service Communication, you’ll need to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Define a contract (interface); &lt;/li&gt;    &lt;li&gt;Implement a service based on the defined contract; &lt;/li&gt;    &lt;li&gt;Develop a workflow that uses HandleExternalEventActivity; &lt;/li&gt;    &lt;li&gt;Develop a host for the workflow; &lt;/li&gt;    &lt;li&gt;Add the service to the workflow runtime in the host; &lt;/li&gt;    &lt;li&gt;Start the workflow and handle the workflow WorkflowIdled event in the host; &lt;/li&gt;    &lt;li&gt;Raise the event. &lt;/li&gt; &lt;/ul&gt;  &lt;h5&gt;&lt;/h5&gt;  &lt;h5&gt;Example&lt;/h5&gt;  &lt;p&gt;As already explained, the HandleExternalEventActivity allows communication between a workflow and an external service using Local Service Communication based on event notifications. Next, I will present a simple demo that will show a very basic usage of this activity. The demo is based on a simple Approval State Machine Workflow Console Application. The console application will ask the user if he/she wants to approve and based on the answer it will pass the corresponding answer to the workflow through the raise of an event. This is how the workflow looks like:&lt;/p&gt;  &lt;p&gt;  &lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/312016167.jpg" /&gt; &lt;/p&gt;  &lt;p&gt;This workflow will basically handle the external event inside the &lt;i&gt;StartState&lt;/i&gt; activity and set the approved or rejected state according to the information supplied by the host in the event. The interface of the service is defined like this:&lt;/p&gt;  &lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;ExternalDataExchange&lt;/span&gt;]
&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IApprovalEventService
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;void &lt;/span&gt;RaiseSetStateEvent(&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;instanceId, &lt;span style="color: blue"&gt;bool &lt;/span&gt;approve);

    &lt;span style="color: blue"&gt;event &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ApprovalExternalDataEventArgs&lt;/span&gt;&amp;gt; ExternalDataEvent;
    
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The interface uses the ExternalDataExchange attribute which allows the workflow to use it to communicate with the host using Local Service Communication. The interface defines the event, whose arguments are of type ApprovalExternalDataEventArgs, a type derived from ExternalEventArgs. It also defines a RaiseSetStateEvent method that will be used by the host to raise the event. This method defines an additional Boolean parameter named &lt;i&gt;approve&lt;/i&gt; in order to pass the approval information to the workflow. This is how the ApprovalExternalDataEventArgs class looks like:&lt;/p&gt;

&lt;pre class="code"&gt;[&lt;span style="color: #2b91af"&gt;Serializable&lt;/span&gt;]
&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ApprovalExternalDataEventArgs &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ExternalDataEventArgs
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;private bool &lt;/span&gt;_result;

    &lt;span style="color: blue"&gt;public bool &lt;/span&gt;Result {
        &lt;span style="color: blue"&gt;set &lt;/span&gt;{
            _result = &lt;span style="color: blue"&gt;value&lt;/span&gt;; 
        }
        &lt;span style="color: blue"&gt;get &lt;/span&gt;{
            &lt;span style="color: blue"&gt;return &lt;/span&gt;_result;
        }
    }

    &lt;span style="color: blue"&gt;public &lt;/span&gt;ApprovalExternalDataEventArgs(&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;instanceId, &lt;span style="color: blue"&gt;bool &lt;/span&gt;approve)
        : &lt;span style="color: blue"&gt;base&lt;/span&gt;(instanceId) {
        Result = approve;
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;In the constructor, a Boolean &lt;i&gt;approve&lt;/i&gt; parameter is used. This parameter is populated by the host when raising the event and is used to set the Result property that will be used later by the workflow. The other parameter used in the constructor is &lt;i&gt;instanceId&lt;/i&gt;, which is used to correlate the event with the right workflow instance.&lt;/p&gt;

&lt;p&gt;The HandleExternalEventActivity is defined inside the &lt;i&gt;StartState&lt;/i&gt; activity and is named &lt;i&gt;handleSetState&lt;/i&gt;. Here are the details of the &lt;i&gt;StartState&lt;/i&gt; activity:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/312016166.jpg" /&gt; &lt;/p&gt;

&lt;p&gt;As shown in the image above, the external event is handled by the HandleExternalEventActivity &lt;i&gt;handleSetState.&lt;/i&gt; Then, based on the value that was supplied by the host, approval or rejected activities will be executed (in this case a simple message will be written to the application console). The properties for the HandleExternalEventActivity &lt;i&gt;handleSetState&lt;/i&gt; look like this:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/313494752.jpg" /&gt; &lt;/p&gt;

&lt;p&gt;There are three properties worth mentioning here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;b&gt;e&lt;/b&gt; – It will hold the event arguments for the workflow instance. In this case it is set to &lt;i&gt;ExternalDataEvent&lt;/i&gt;, a public property in the workflow of type ApprovalExternalDataEventArgs. &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;EventName&lt;/b&gt; – name of the event that will be handled. Also set to &lt;i&gt;ExternalDataEvent.&lt;/i&gt;&lt;b&gt;&lt;/b&gt; &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;InterfaceType&lt;/b&gt; – name of the interface. Set to IApprovalEventService. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The IfElseActivity defined after the HandleExternalEventActivity will evaluate a code condition to determine whether to execute the Approve or Reject activities.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/312025688.jpg" /&gt; &lt;/p&gt;

&lt;p&gt;The code condition is based on a CheckState method that will verify the Result property of the workflow ExternalDataEvent property.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: green"&gt;// Code condition to evaluate whether to take the 1st branch, YesIfElseBranch
// Since it always returns true, the 1st branch is always taken.
&lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;CheckState(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;ConditionalEventArgs &lt;/span&gt;e) {
    e.Result = ExternalDataEvent.Result;
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The two remaining pieces of this demo are the service and the host console application. Here is the definition of the service:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ApprovalEventService &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;IApprovalEventService
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;#region &lt;/span&gt;IApprovalEventService Members

    &lt;span style="color: blue"&gt;public void &lt;/span&gt;RaiseSetStateEvent(&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;instanceId, &lt;span style="color: blue"&gt;bool &lt;/span&gt;approve)
    {
        &lt;span style="color: green"&gt;// create event
        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ApprovalExternalDataEventArgs&lt;/span&gt;&amp;gt; setStateEvent 
        = &lt;span style="color: blue"&gt;this&lt;/span&gt;.ExternalDataEvent;

        &lt;span style="color: green"&gt;// launch event
        &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(setStateEvent != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
            setStateEvent(&lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ApprovalExternalDataEventArgs
                &lt;/span&gt;(instanceId, approve));
    }

    &lt;span style="color: blue"&gt;public event &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EventHandler&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;ApprovalExternalDataEventArgs&lt;/span&gt;&amp;gt; 
        ExternalDataEvent;
   

    &lt;span style="color: blue"&gt;#endregion
&lt;/span&gt;}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;The console application code looks like this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private static &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ApprovalEventService &lt;/span&gt;service;
&lt;span style="color: blue"&gt;private static &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;instanceId; 

&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
/// &lt;/span&gt;&lt;span style="color: green"&gt;We've decorated the IEventService interface with the 
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;ExternalDataExchangeAttribute.
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;The event args class (ApprovalExternalDataEventArgs) 
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;derives from ExternalDataEventArgs.
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;The event args class (ApprovalExternalDataEventArgs) is serializable.
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;ApprovalEventService implements IEventService.
&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="args"&amp;gt;&amp;lt;/param&amp;gt;
&lt;/span&gt;&lt;span style="color: blue"&gt;static void &lt;/span&gt;Main(&lt;span style="color: blue"&gt;string&lt;/span&gt;[] args)
{
    &lt;span style="color: blue"&gt;using&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;WorkflowRuntime &lt;/span&gt;workflowRuntime = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;WorkflowRuntime&lt;/span&gt;())
    {
        &lt;span style="color: green"&gt;//add ApprovalEventService service to the workflow runtime
        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AutoResetEvent &lt;/span&gt;waitHandle = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;AutoResetEvent&lt;/span&gt;(&lt;span style="color: blue"&gt;false&lt;/span&gt;);
        &lt;span style="color: #2b91af"&gt;ExternalDataExchangeService &lt;/span&gt;dataExchange = 
        &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ExternalDataExchangeService&lt;/span&gt;();
        workflowRuntime.AddService(dataExchange);
        service = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ApprovalEventService&lt;/span&gt;();
        dataExchange.AddService(service);
        
        workflowRuntime.WorkflowCompleted += 
        &lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;WorkflowCompletedEventArgs &lt;/span&gt;e) 
        {
            &lt;span style="color: green"&gt;//display workflow completion message
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Workflow completed."&lt;/span&gt;);
            waitHandle.Set();
        };
        workflowRuntime.WorkflowTerminated += 
        &lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;WorkflowTerminatedEventArgs &lt;/span&gt;e)
        {
            &lt;span style="color: green"&gt;//display error message if an exception is raised
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(e.Exception.Message);
            waitHandle.Set();
        };
        workflowRuntime.WorkflowIdled += 
        &lt;span style="color: blue"&gt;delegate&lt;/span&gt;(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;WorkflowEventArgs &lt;/span&gt;e)
        {
            &lt;span style="color: green"&gt;//read the input from keyboard (yes/no) and raise 
            //the event passing the answer as a boolean parameter
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Workflow idled."&lt;/span&gt;);
            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.Write(&lt;span style="color: #a31515"&gt;"Do you want to approve? (Y/N) "&lt;/span&gt;);
            &lt;span style="color: blue"&gt;string &lt;/span&gt;key = &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.ReadLine();
            &lt;span style="color: blue"&gt;bool &lt;/span&gt;approved = key.ToLower() == &lt;span style="color: #a31515"&gt;"y" &lt;/span&gt;? &lt;span style="color: blue"&gt;true &lt;/span&gt;: &lt;span style="color: blue"&gt;false&lt;/span&gt;;
            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Sending event to workflow."&lt;/span&gt;);
            service.RaiseSetStateEvent(instanceId, approved);
        };

        &lt;span style="color: green"&gt;//start workflow
        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;WorkflowInstance &lt;/span&gt;instance = 
        workflowRuntime.CreateWorkflow(
        &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(StateMachineCommunicationDemo.&lt;span style="color: #2b91af"&gt;SimpleStateMachine&lt;/span&gt;));
        instanceId = instance.InstanceId;
        &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Starting workflow."&lt;/span&gt;);
        instance.Start();

        &lt;span style="color: green"&gt;//put workflow in an idle state
        &lt;/span&gt;waitHandle.WaitOne();

        &lt;span style="color: green"&gt;//stop runtime
        &lt;/span&gt;workflowRuntime.StopRuntime();

        &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Press any key."&lt;/span&gt;);
        &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.Read();
    }
}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;In the code above, the following actions are performed:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The service is added to the workflow runtime. In order for the service to be correctly added to runtime, two AddService methods must be executed and in the right order. First, an instance of ExternalDataExchangeService is added to the workflow runtime. Then, an instance of our service (ApprovalEventService) is added to the ExternalDataExchangeService instance. &lt;/li&gt;

  &lt;li&gt;The workflow is started &lt;/li&gt;

  &lt;li&gt;The workflow is placed in an idle state &lt;/li&gt;

  &lt;li&gt;Several delegate functions are defined to handle workflow events. The most important one is the event handler for the WorkflowIdled event. The event handler will be trigger once the workflow is placed in an idle state. Then, the user will be asked the approval question and the event is raised which will cause the HandleExternalEventActivity in the workflow to be executed. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the application’s output in case of approval:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/313495367.jpg" /&gt; &lt;/p&gt;

&lt;p&gt;And in case of rejection:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/313495369.jpg" /&gt;&lt;/p&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><h5>Introduction</h5>  <p>This is the first in a series of blog posts dedicated to Windows Workflow. For those who don’t know, Windows Workflow Foundation (WF) is the new engine for building custom workflows (you can find more information about WF on the <a href="http://msdn.microsoft.com/winfx/technologies/workflow/default.aspx">official web site</a>). It was released as part of the .NET Framework 3.0 along with <a href="http://msdn2.microsoft.com/en-us/netframework/aa663326.aspx">Windows Presentation Foundation (WPF)</a> and <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx">Windows Communication Foundation (WCF)</a>.</p>  <h5>Local Service Communication</h5>  <p>Workflows are not isolated entities and most of the times need to communicate with the outside world in order to perform some task. There are several ways of communicating with external entities/services, being one of them External Data Exchange and Local Service Communication. Local Service Communication basically allows workflows to communicate with an external service that resides within the workflow host. There are two main activities inside WF that allow communication between a workflow and an external service using Local Service Communication:</p>  <ul>   <li><strong>CallExternalMethodActivity</strong> – Allows a workflow to call a method from an external service. The workflow and the host establish a contract (using an interface) that defines the way they communicate with each other. Basically the workflow calls a method of a service residing within the host that implements the contract interface. For more details about this activity, click <a href="http://msdn2.microsoft.com/en-us/library/ms734739(VS.85).aspx" target="_blank">here</a>. </li>    <li><b>HandleExternalEventActivity</b> – Besides allowing the workflow to call an external method, it is also possible for the host to send an event to the workflow in order for it to perform some task. This is achieved using the HandleExternalEventActivity that will put the workflow on an idle state until an external event is raised. Just as in CallExternalMethodActivity, the communication between the workflow and the external is based on a contract. </li> </ul>  <h5></h5>  <h5>Summary</h5>  <p>To build a workflow that uses HandleExternalEventActivity to communicate with a service using Local Service Communication, you’ll need to:</p>  <ul>   <li>Define a contract (interface); </li>    <li>Implement a service based on the defined contract; </li>    <li>Develop a workflow that uses HandleExternalEventActivity; </li>    <li>Develop a host for the workflow; </li>    <li>Add the service to the workflow runtime in the host; </li>    <li>Start the workflow and handle the workflow WorkflowIdled event in the host; </li>    <li>Raise the event. </li> </ul>  <h5></h5>  <h5>Example</h5>  <p>As already explained, the HandleExternalEventActivity allows communication between a workflow and an external service using Local Service Communication based on event notifications. Next, I will present a simple demo that will show a very basic usage of this activity. The demo is based on a simple Approval State Machine Workflow Console Application. The console application will ask the user if he/she wants to approve and based on the answer it will pass the corresponding answer to the workflow through the raise of an event. This is how the workflow looks like:</p>  <p>  <img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/312016167.jpg" /> </p>  <p>This workflow will basically handle the external event inside the <i>StartState</i> activity and set the approved or rejected state according to the information supplied by the host in the event. The interface of the service is defined like this:</p>  <pre class="code">[<span style="color: #2b91af">ExternalDataExchange</span>]
<span style="color: blue">public interface </span><span style="color: #2b91af">IApprovalEventService
</span>{
    <span style="color: blue">void </span>RaiseSetStateEvent(<span style="color: #2b91af">Guid </span>instanceId, <span style="color: blue">bool </span>approve);

    <span style="color: blue">event </span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">ApprovalExternalDataEventArgs</span>&gt; ExternalDataEvent;
    
}</pre>
<a href="http://11011.net/software/vspaste"></a>

<p>The interface uses the ExternalDataExchange attribute which allows the workflow to use it to communicate with the host using Local Service Communication. The interface defines the event, whose arguments are of type ApprovalExternalDataEventArgs, a type derived from ExternalEventArgs. It also defines a RaiseSetStateEvent method that will be used by the host to raise the event. This method defines an additional Boolean parameter named <i>approve</i> in order to pass the approval information to the workflow. This is how the ApprovalExternalDataEventArgs class looks like:</p>

<pre class="code">[<span style="color: #2b91af">Serializable</span>]
<span style="color: blue">public class </span><span style="color: #2b91af">ApprovalExternalDataEventArgs </span>: <span style="color: #2b91af">ExternalDataEventArgs
</span>{
    <span style="color: blue">private bool </span>_result;

    <span style="color: blue">public bool </span>Result {
        <span style="color: blue">set </span>{
            _result = <span style="color: blue">value</span>; 
        }
        <span style="color: blue">get </span>{
            <span style="color: blue">return </span>_result;
        }
    }

    <span style="color: blue">public </span>ApprovalExternalDataEventArgs(<span style="color: #2b91af">Guid </span>instanceId, <span style="color: blue">bool </span>approve)
        : <span style="color: blue">base</span>(instanceId) {
        Result = approve;
    }
}</pre>
<a href="http://11011.net/software/vspaste"></a>

<p>In the constructor, a Boolean <i>approve</i> parameter is used. This parameter is populated by the host when raising the event and is used to set the Result property that will be used later by the workflow. The other parameter used in the constructor is <i>instanceId</i>, which is used to correlate the event with the right workflow instance.</p>

<p>The HandleExternalEventActivity is defined inside the <i>StartState</i> activity and is named <i>handleSetState</i>. Here are the details of the <i>StartState</i> activity:</p>

<p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/312016166.jpg" /> </p>

<p>As shown in the image above, the external event is handled by the HandleExternalEventActivity <i>handleSetState.</i> Then, based on the value that was supplied by the host, approval or rejected activities will be executed (in this case a simple message will be written to the application console). The properties for the HandleExternalEventActivity <i>handleSetState</i> look like this:</p>

<p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/313494752.jpg" /> </p>

<p>There are three properties worth mentioning here:</p>

<ul>
  <li><b>e</b> – It will hold the event arguments for the workflow instance. In this case it is set to <i>ExternalDataEvent</i>, a public property in the workflow of type ApprovalExternalDataEventArgs. </li>

  <li><b>EventName</b> – name of the event that will be handled. Also set to <i>ExternalDataEvent.</i><b></b> </li>

  <li><b>InterfaceType</b> – name of the interface. Set to IApprovalEventService. </li>
</ul>

<p>The IfElseActivity defined after the HandleExternalEventActivity will evaluate a code condition to determine whether to execute the Approve or Reject activities.</p>

<p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/312025688.jpg" /> </p>

<p>The code condition is based on a CheckState method that will verify the Result property of the workflow ExternalDataEvent property.</p>

<pre class="code"><span style="color: green">// Code condition to evaluate whether to take the 1st branch, YesIfElseBranch
// Since it always returns true, the 1st branch is always taken.
</span><span style="color: blue">private void </span>CheckState(<span style="color: blue">object </span>sender, <span style="color: #2b91af">ConditionalEventArgs </span>e) {
    e.Result = ExternalDataEvent.Result;
}</pre>
<a href="http://11011.net/software/vspaste"></a>

<p>The two remaining pieces of this demo are the service and the host console application. Here is the definition of the service:</p>

<pre class="code"><span style="color: blue">class </span><span style="color: #2b91af">ApprovalEventService </span>: <span style="color: #2b91af">IApprovalEventService
</span>{
    <span style="color: blue">#region </span>IApprovalEventService Members

    <span style="color: blue">public void </span>RaiseSetStateEvent(<span style="color: #2b91af">Guid </span>instanceId, <span style="color: blue">bool </span>approve)
    {
        <span style="color: green">// create event
        </span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">ApprovalExternalDataEventArgs</span>&gt; setStateEvent 
        = <span style="color: blue">this</span>.ExternalDataEvent;

        <span style="color: green">// launch event
        </span><span style="color: blue">if </span>(setStateEvent != <span style="color: blue">null</span>)
            setStateEvent(<span style="color: blue">null</span>, <span style="color: blue">new </span><span style="color: #2b91af">ApprovalExternalDataEventArgs
                </span>(instanceId, approve));
    }

    <span style="color: blue">public event </span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">ApprovalExternalDataEventArgs</span>&gt; 
        ExternalDataEvent;
   

    <span style="color: blue">#endregion
</span>}</pre>
<a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a>

<p>The console application code looks like this:</p>

<pre class="code"><span style="color: blue">private static </span><span style="color: #2b91af">ApprovalEventService </span>service;
<span style="color: blue">private static </span><span style="color: #2b91af">Guid </span>instanceId; 

<span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">We've decorated the IEventService interface with the 
</span><span style="color: gray">/// </span><span style="color: green">ExternalDataExchangeAttribute.
</span><span style="color: gray">/// </span><span style="color: green">The event args class (ApprovalExternalDataEventArgs) 
</span><span style="color: gray">/// </span><span style="color: green">derives from ExternalDataEventArgs.
</span><span style="color: gray">/// </span><span style="color: green">The event args class (ApprovalExternalDataEventArgs) is serializable.
</span><span style="color: gray">/// </span><span style="color: green">ApprovalEventService implements IEventService.
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name="args"&gt;&lt;/param&gt;
</span><span style="color: blue">static void </span>Main(<span style="color: blue">string</span>[] args)
{
    <span style="color: blue">using</span>(<span style="color: #2b91af">WorkflowRuntime </span>workflowRuntime = <span style="color: blue">new </span><span style="color: #2b91af">WorkflowRuntime</span>())
    {
        <span style="color: green">//add ApprovalEventService service to the workflow runtime
        </span><span style="color: #2b91af">AutoResetEvent </span>waitHandle = <span style="color: blue">new </span><span style="color: #2b91af">AutoResetEvent</span>(<span style="color: blue">false</span>);
        <span style="color: #2b91af">ExternalDataExchangeService </span>dataExchange = 
        <span style="color: blue">new </span><span style="color: #2b91af">ExternalDataExchangeService</span>();
        workflowRuntime.AddService(dataExchange);
        service = <span style="color: blue">new </span><span style="color: #2b91af">ApprovalEventService</span>();
        dataExchange.AddService(service);
        
        workflowRuntime.WorkflowCompleted += 
        <span style="color: blue">delegate</span>(<span style="color: blue">object </span>sender, <span style="color: #2b91af">WorkflowCompletedEventArgs </span>e) 
        {
            <span style="color: green">//display workflow completion message
            </span><span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">"Workflow completed."</span>);
            waitHandle.Set();
        };
        workflowRuntime.WorkflowTerminated += 
        <span style="color: blue">delegate</span>(<span style="color: blue">object </span>sender, <span style="color: #2b91af">WorkflowTerminatedEventArgs </span>e)
        {
            <span style="color: green">//display error message if an exception is raised
            </span><span style="color: #2b91af">Console</span>.WriteLine(e.Exception.Message);
            waitHandle.Set();
        };
        workflowRuntime.WorkflowIdled += 
        <span style="color: blue">delegate</span>(<span style="color: blue">object </span>sender, <span style="color: #2b91af">WorkflowEventArgs </span>e)
        {
            <span style="color: green">//read the input from keyboard (yes/no) and raise 
            //the event passing the answer as a boolean parameter
            </span><span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">"Workflow idled."</span>);
            <span style="color: #2b91af">Console</span>.Write(<span style="color: #a31515">"Do you want to approve? (Y/N) "</span>);
            <span style="color: blue">string </span>key = <span style="color: #2b91af">Console</span>.ReadLine();
            <span style="color: blue">bool </span>approved = key.ToLower() == <span style="color: #a31515">"y" </span>? <span style="color: blue">true </span>: <span style="color: blue">false</span>;
            <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">"Sending event to workflow."</span>);
            service.RaiseSetStateEvent(instanceId, approved);
        };

        <span style="color: green">//start workflow
        </span><span style="color: #2b91af">WorkflowInstance </span>instance = 
        workflowRuntime.CreateWorkflow(
        <span style="color: blue">typeof</span>(StateMachineCommunicationDemo.<span style="color: #2b91af">SimpleStateMachine</span>));
        instanceId = instance.InstanceId;
        <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">"Starting workflow."</span>);
        instance.Start();

        <span style="color: green">//put workflow in an idle state
        </span>waitHandle.WaitOne();

        <span style="color: green">//stop runtime
        </span>workflowRuntime.StopRuntime();

        <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">"Press any key."</span>);
        <span style="color: #2b91af">Console</span>.Read();
    }
}</pre>
<a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a>

<p>In the code above, the following actions are performed:</p>

<ul>
  <li>The service is added to the workflow runtime. In order for the service to be correctly added to runtime, two AddService methods must be executed and in the right order. First, an instance of ExternalDataExchangeService is added to the workflow runtime. Then, an instance of our service (ApprovalEventService) is added to the ExternalDataExchangeService instance. </li>

  <li>The workflow is started </li>

  <li>The workflow is placed in an idle state </li>

  <li>Several delegate functions are defined to handle workflow events. The most important one is the event handler for the WorkflowIdled event. The event handler will be trigger once the workflow is placed in an idle state. Then, the user will be asked the approval question and the event is raised which will cause the HandleExternalEventActivity in the workflow to be executed. </li>
</ul>

<p>Here is the application’s output in case of approval:</p>

<p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/313495367.jpg" /> </p>

<p>And in case of rejection:</p>

<p><img src="http://pic90.picturetrail.com/VOL2147/10903553/19399056/313495369.jpg" /></p></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>TechDays 2008 – 3º Dia</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/26902.aspx</link><pubDate>Mon, 17 Mar 2008 17:52:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/26902.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/26902.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/26902.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/26902.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=26902</trackback:ping><description>&lt;p&gt;Decorreu na passada semana entre os dias 12 e 14 de Março a edição deste ano do &lt;a href="http://www.techdays.pt/" target="_blank"&gt;TechDays&lt;/a&gt;, o maior evento de tecnologia do país. Este evento juntou mais de 2000 profissionais na área das TI, tendo sido dadas mais de 150 sessões técnicas por 120 oradores, tendo sido claramente a maior edição deste evento. De seguida, deixo o meu testemunho relativamente às sessões a que tive oportunidade de assistir no 3º dia.&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;COL10 - Como Criar Soluções/Aplicações Utilizando o Open XML &lt;/h4&gt;
&lt;p&gt;Oradores: Marcos Santos (Microsoft), Susana Guedes (Microsoft) e Bernardo Antunes (Devscope) &lt;/p&gt;
&lt;p&gt;Esta sessão abordou o tema do Open XML e de como este pode ser usado no desenvolvimento de aplicações. O Open XML pretende endereçar os seguintes problemas: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A informação é guardada em muitos formatos diferentes 
&lt;/li&gt;&lt;li&gt;Difícil trocar e guardar a informação 
&lt;/li&gt;&lt;li&gt;Diferentes aplicações usam formatos de documento de forma diferente &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;O objectivo passa por uniformizar o formato de documentos usado pelas aplicações de forma a facilitar a interoperabilidade na troca de documentos entre organizações. O Open XML é já o formato usado pelo Office 2007. Para quem não sabe, se renomear um ficheiro .docx como exemplo para .zip pode ver a estrutura interna do ficheiro, basicamente um conjunto de ficheiros xml. &lt;/p&gt;
&lt;p&gt;Mais informações e demos de utilização do OpenXML em: &lt;a href="http://openxmldeveloper.org"&gt;http://openxmldeveloper.org&lt;/a&gt; e &lt;a href="http://www.openxmlcommunity.org/"&gt;http://www.openxmlcommunity.org/&lt;/a&gt;. &lt;/p&gt;
&lt;h4&gt;ARC05 - Construção de Software+Services com a Plataforma Volta &lt;/h4&gt;
&lt;p&gt;Oradores: Daniel Fisher e Michael Willers, DevCoach &lt;/p&gt;
&lt;p&gt;O tema desta sessão foi muito interessante. "Volta" é o nome de código de um projecto ainda em desenvolvimento por parte da Microsoft cujo objectivo é o de uma forma transparente e sem qualquer esforço de desenvolvimento compilar código de assemblies .NET (em qualquer linguagem .NET compliant) em código Javascript compatível "cross-browser". Detalhando um pouco mais o conceito, a ideia é desenvolver uma aplicação (cliente, serviços) em .NET e por meio de atributos definir se o código corre no cliente ou no servidor (basta incluir o atributo ["RunAtOrigin"]). O "Volta" vai gerar código javascript para a camada de cliente, web services para a camada de servidor e todo o código de "plumbing" (comunicação, serialização, segurança, etc) entre as duas camadas. &lt;/p&gt;
&lt;p&gt;Basicamente, a ideia é desenvolver as aplicações em .NET do lado do servidor na nossa linguagem preferida e como output obter uma aplicação AJAX distribuída. &lt;/p&gt;
&lt;p&gt;Mais informação pode ser obtida em &lt;a href="http://labs.live.com/volta/"&gt;http://labs.live.com/volta/&lt;/a&gt;. &lt;/p&gt;
&lt;h4&gt;WEB05 - ASP.NET Futures - Dynamic Data Controls and Astoria Services &lt;/h4&gt;
&lt;p&gt;Orador: Matt Gibbs, Microsoft (Blog: &lt;a href="http://blogs.msdn.com/mattgi"&gt;http://blogs.msdn.com/mattgi&lt;/a&gt;) &lt;/p&gt;
&lt;p&gt;Esta sessão foi apresentada pelo Matt Gibbs que é Development Manager da equipa de ASP.NET da Microsoft e abordou algumas das novidades que irão estar presentes na próxima versão do ASP.NET. A sessão foi dividida em duas partes distintas: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dynamic Data Controls 
&lt;/li&gt;&lt;li&gt;Astoria Web Data Services &lt;/li&gt;&lt;/ul&gt;
&lt;h5&gt;&lt;strong&gt;Dynamic Data Controls &lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;Os Dynamic Data Controls permitem a obtenção de forma dinâmica da estrutura da base de dados em tempo real e adaptar a sua apresentação automaticamente de acordo com a mesma. Estes controlos irão estar integrados como extensões na próxima versão do ASP.NET e vêm alterar o ciclo de desenvolvimento de uma aplicação ASP.NET "data-bounded". Antes tínhamos: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Criação do modelo de BD 
&lt;/li&gt;&lt;li&gt;Criação das páginas 
&lt;/li&gt;&lt;li&gt;Adição dos controlos às páginas 
&lt;/li&gt;&lt;li&gt;Adição lógica de validação &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Com estes novos controlos e a com as novas templates de projectos existentes no Visual Studio 2008, teremos: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Criação do modelo de dados 
&lt;/li&gt;&lt;li&gt;Criação automática de um aplicação com base no modelo de dados 
&lt;/li&gt;&lt;li&gt;Customização da aplicação (alteração páginas .aspx e controlos .ascx base) &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Mais informação sobre Dynamic Data Controls: &lt;a href="http://quickstarts.asp.net/Futures/dynamicdatacontrols/default.aspx"&gt;http://quickstarts.asp.net/Futures/dynamicdatacontrols/default.aspx&lt;/a&gt;. &lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Astoria Web Data Services &lt;/strong&gt;&lt;/h5&gt;
&lt;p&gt;Ainda em fase de protótipo (será designado por "ADO.NET Data Services"), a principal ideia é simplificar o acesso a dados através do consumo de serviços com base em URIs (&lt;a href="http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ConsumingDataService.aspx"&gt;http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ConsumingDataService.aspx&lt;/a&gt;) e retornar os dados em formatos JSON (método de serialização mais simples para evitar o "overhead" do XML na troca de informação em web services - &lt;a href="http://www.json.org/"&gt;http://www.json.org/&lt;/a&gt; muito ligado ao Javascript e AJAX) ou XML. Os serviços poderão ser consumidos tanto por AJAX ou por qualquer outro cliente non-AJAX (serviço WCF, aplicação web, aplicação Windows-Forms, etc). &lt;/p&gt;
&lt;p&gt;Mais informação sobre Astoria Web Data Services em &lt;a href="http://astoria.mslivelabs.com/"&gt;http://astoria.mslivelabs.com/&lt;/a&gt; e &lt;a href="http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ADONETDataServicesFramework.aspx"&gt;http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ADONETDataServicesFramework.aspx&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;VST03 - Hardcore Debuging e Profiling de Aplicações .NET &lt;/h4&gt;
&lt;p&gt;Oradores: Filipe Prezado e João Loureiro, Microsoft &lt;/p&gt;
&lt;p&gt;Foi mais a curiosidade que me levou a assistir a esta sessão, tendo-se revelado uma sessão bastante interessante, embora com um certo nível de complexidade. Basicamente, foram apresentadas as técnicas usadas pela equipa de suporte técnico da Microsoft para resolução de problemas aplicacionais em produção, tanto em cenários em que detêm o acesso remoto ao servidor como em casos em que tal não sucede. Algumas das ferramentas apresentadas foram: Mdbg, WinDbg (a mais conhecida), SOSAssistant, Hawkeye. Com base nestas ferramentas, foram apresentadas técnicas que permitiram a identificação de "memory leaks", efectuar o memory dump para ficheiro (útil em cenários em que não existe acesso remoto ao servidor) para posterior análise, entre outras. Uma sessão diferente mas interessante. &lt;/p&gt;
&lt;h4&gt;WEB04: MVC Framework on Future ASP.NET &lt;/h4&gt;
&lt;p&gt;Orador: Matt Gibbs, Microsoft (Blog: &lt;a href="http://blogs.msdn.com/mattgi"&gt;http://blogs.msdn.com/mattgi&lt;/a&gt;) &lt;/p&gt;
&lt;p&gt;Esta foi a segunda sessão apresentada pelo Matt Gibbs sobre a futura versão do ASP.NET. Desta vez, foi apresentada a framework MVC para ASP.NET que é a implementação da Microsoft desta "pattern". Esta framework basicamente divide uma aplicação em 3 "roles": &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Model (Modelo) – representa os componentes da aplicação que são responsáveis pela manutenção do estado da aplicação (os dados). O caso mais típico é a persistência do estado numa base de dados (ex: uma classe Client que representa os dados de uma tabela Client numa base de dados SQL Server) 
&lt;/li&gt;&lt;li&gt;View (Vista) – representa os componentes responsáveis pela camada de apresentação da aplicação 
&lt;/li&gt;&lt;li&gt;Controller (Controlador) – representa os componentes responsáveis pela interacção com o utilizador, manipulação do modelo e selecção da vista a utilizar. É o controlador que fica encarregue pela interacção com o utilizador e não a vista, sendo esta apenas usada para apresentação da informação &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Um ponto importante a referir é que o MVC não vem substituir o modelo de desenvolvimento ASP.NET tradicional, apresentando-se antes como uma alternativa onde a ideia é haver uma maior separação de responsabilidades entre os componentes da aplicação. &lt;/p&gt;
&lt;p&gt;As demos apresentadas não foram tão bem conseguidas quanto estava à espera, tendo ficado por explicar como exemplo a forma como são obtidos ou como são editados/inseridos dados numa base de dados (tipicamente a lógica será colocada no componente "Model"). &lt;/p&gt;
&lt;p&gt;Mais informação sobre o MVC em &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx&lt;/a&gt; e &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Podem consultar as sessões do dia 1 &lt;a href="http://blogit.create.pt/blogs/miguelisidoro/archive/2008/03/17/TechDays-_1320_-1_BA00_-Dia.aspx"&gt;aqui&lt;/a&gt; e do dia 2 &lt;a href="http://blogit.create.pt/blogs/miguelisidoro/archive/2008/03/17/TechDays-_1320_-2_BA00_-Dia.aspx"&gt;aqui&lt;/a&gt;.&lt;/p&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>Decorreu na passada semana entre os dias 12 e 14 de Março a edição deste ano do <a href="http://www.techdays.pt/" target="_blank">TechDays</a>, o maior evento de tecnologia do país. Este evento juntou mais de 2000 profissionais na área das TI, tendo sido dadas mais de 150 sessões técnicas por 120 oradores, tendo sido claramente a maior edição deste evento. De seguida, deixo o meu testemunho relativamente às sessões a que tive oportunidade de assistir no 3º dia.<br /></p>
<h4>COL10 - Como Criar Soluções/Aplicações Utilizando o Open XML </h4>
<p>Oradores: Marcos Santos (Microsoft), Susana Guedes (Microsoft) e Bernardo Antunes (Devscope) </p>
<p>Esta sessão abordou o tema do Open XML e de como este pode ser usado no desenvolvimento de aplicações. O Open XML pretende endereçar os seguintes problemas: </p>
<ul>
<li>A informação é guardada em muitos formatos diferentes 
</li><li>Difícil trocar e guardar a informação 
</li><li>Diferentes aplicações usam formatos de documento de forma diferente </li></ul>
<p>O objectivo passa por uniformizar o formato de documentos usado pelas aplicações de forma a facilitar a interoperabilidade na troca de documentos entre organizações. O Open XML é já o formato usado pelo Office 2007. Para quem não sabe, se renomear um ficheiro .docx como exemplo para .zip pode ver a estrutura interna do ficheiro, basicamente um conjunto de ficheiros xml. </p>
<p>Mais informações e demos de utilização do OpenXML em: <a href="http://openxmldeveloper.org">http://openxmldeveloper.org</a> e <a href="http://www.openxmlcommunity.org/">http://www.openxmlcommunity.org/</a>. </p>
<h4>ARC05 - Construção de Software+Services com a Plataforma Volta </h4>
<p>Oradores: Daniel Fisher e Michael Willers, DevCoach </p>
<p>O tema desta sessão foi muito interessante. "Volta" é o nome de código de um projecto ainda em desenvolvimento por parte da Microsoft cujo objectivo é o de uma forma transparente e sem qualquer esforço de desenvolvimento compilar código de assemblies .NET (em qualquer linguagem .NET compliant) em código Javascript compatível "cross-browser". Detalhando um pouco mais o conceito, a ideia é desenvolver uma aplicação (cliente, serviços) em .NET e por meio de atributos definir se o código corre no cliente ou no servidor (basta incluir o atributo ["RunAtOrigin"]). O "Volta" vai gerar código javascript para a camada de cliente, web services para a camada de servidor e todo o código de "plumbing" (comunicação, serialização, segurança, etc) entre as duas camadas. </p>
<p>Basicamente, a ideia é desenvolver as aplicações em .NET do lado do servidor na nossa linguagem preferida e como output obter uma aplicação AJAX distribuída. </p>
<p>Mais informação pode ser obtida em <a href="http://labs.live.com/volta/">http://labs.live.com/volta/</a>. </p>
<h4>WEB05 - ASP.NET Futures - Dynamic Data Controls and Astoria Services </h4>
<p>Orador: Matt Gibbs, Microsoft (Blog: <a href="http://blogs.msdn.com/mattgi">http://blogs.msdn.com/mattgi</a>) </p>
<p>Esta sessão foi apresentada pelo Matt Gibbs que é Development Manager da equipa de ASP.NET da Microsoft e abordou algumas das novidades que irão estar presentes na próxima versão do ASP.NET. A sessão foi dividida em duas partes distintas: </p>
<ul>
<li>Dynamic Data Controls 
</li><li>Astoria Web Data Services </li></ul>
<h5><strong>Dynamic Data Controls </strong></h5>
<p>Os Dynamic Data Controls permitem a obtenção de forma dinâmica da estrutura da base de dados em tempo real e adaptar a sua apresentação automaticamente de acordo com a mesma. Estes controlos irão estar integrados como extensões na próxima versão do ASP.NET e vêm alterar o ciclo de desenvolvimento de uma aplicação ASP.NET "data-bounded". Antes tínhamos: </p>
<ul>
<li>Criação do modelo de BD 
</li><li>Criação das páginas 
</li><li>Adição dos controlos às páginas 
</li><li>Adição lógica de validação </li></ul>
<p>Com estes novos controlos e a com as novas templates de projectos existentes no Visual Studio 2008, teremos: </p>
<ul>
<li>Criação do modelo de dados 
</li><li>Criação automática de um aplicação com base no modelo de dados 
</li><li>Customização da aplicação (alteração páginas .aspx e controlos .ascx base) </li></ul>
<p>Mais informação sobre Dynamic Data Controls: <a href="http://quickstarts.asp.net/Futures/dynamicdatacontrols/default.aspx">http://quickstarts.asp.net/Futures/dynamicdatacontrols/default.aspx</a>. </p>
<h5><strong>Astoria Web Data Services </strong></h5>
<p>Ainda em fase de protótipo (será designado por "ADO.NET Data Services"), a principal ideia é simplificar o acesso a dados através do consumo de serviços com base em URIs (<a href="http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ConsumingDataService.aspx">http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ConsumingDataService.aspx</a>) e retornar os dados em formatos JSON (método de serialização mais simples para evitar o "overhead" do XML na troca de informação em web services - <a href="http://www.json.org/">http://www.json.org/</a> muito ligado ao Javascript e AJAX) ou XML. Os serviços poderão ser consumidos tanto por AJAX ou por qualquer outro cliente non-AJAX (serviço WCF, aplicação web, aplicação Windows-Forms, etc). </p>
<p>Mais informação sobre Astoria Web Data Services em <a href="http://astoria.mslivelabs.com/">http://astoria.mslivelabs.com/</a> e <a href="http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ADONETDataServicesFramework.aspx">http://quickstarts.asp.net/3-5-extensions/adonetdataservice/ADONETDataServicesFramework.aspx</a>. </p>
<p> </p>
<h4>VST03 - Hardcore Debuging e Profiling de Aplicações .NET </h4>
<p>Oradores: Filipe Prezado e João Loureiro, Microsoft </p>
<p>Foi mais a curiosidade que me levou a assistir a esta sessão, tendo-se revelado uma sessão bastante interessante, embora com um certo nível de complexidade. Basicamente, foram apresentadas as técnicas usadas pela equipa de suporte técnico da Microsoft para resolução de problemas aplicacionais em produção, tanto em cenários em que detêm o acesso remoto ao servidor como em casos em que tal não sucede. Algumas das ferramentas apresentadas foram: Mdbg, WinDbg (a mais conhecida), SOSAssistant, Hawkeye. Com base nestas ferramentas, foram apresentadas técnicas que permitiram a identificação de "memory leaks", efectuar o memory dump para ficheiro (útil em cenários em que não existe acesso remoto ao servidor) para posterior análise, entre outras. Uma sessão diferente mas interessante. </p>
<h4>WEB04: MVC Framework on Future ASP.NET </h4>
<p>Orador: Matt Gibbs, Microsoft (Blog: <a href="http://blogs.msdn.com/mattgi">http://blogs.msdn.com/mattgi</a>) </p>
<p>Esta foi a segunda sessão apresentada pelo Matt Gibbs sobre a futura versão do ASP.NET. Desta vez, foi apresentada a framework MVC para ASP.NET que é a implementação da Microsoft desta "pattern". Esta framework basicamente divide uma aplicação em 3 "roles": </p>
<ul>
<li>Model (Modelo) – representa os componentes da aplicação que são responsáveis pela manutenção do estado da aplicação (os dados). O caso mais típico é a persistência do estado numa base de dados (ex: uma classe Client que representa os dados de uma tabela Client numa base de dados SQL Server) 
</li><li>View (Vista) – representa os componentes responsáveis pela camada de apresentação da aplicação 
</li><li>Controller (Controlador) – representa os componentes responsáveis pela interacção com o utilizador, manipulação do modelo e selecção da vista a utilizar. É o controlador que fica encarregue pela interacção com o utilizador e não a vista, sendo esta apenas usada para apresentação da informação </li></ul>
<p>Um ponto importante a referir é que o MVC não vem substituir o modelo de desenvolvimento ASP.NET tradicional, apresentando-se antes como uma alternativa onde a ideia é haver uma maior separação de responsabilidades entre os componentes da aplicação. </p>
<p>As demos apresentadas não foram tão bem conseguidas quanto estava à espera, tendo ficado por explicar como exemplo a forma como são obtidos ou como são editados/inseridos dados numa base de dados (tipicamente a lógica será colocada no componente "Model"). </p>
<p>Mais informação sobre o MVC em <a href="http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx">http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx</a> e <a href="http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx">http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx</a>. </p>
<p> </p>
<p>Podem consultar as sessões do dia 1 <a href="http://blogit.create.pt/blogs/miguelisidoro/archive/2008/03/17/TechDays-_1320_-1_BA00_-Dia.aspx">aqui</a> e do dia 2 <a href="http://blogit.create.pt/blogs/miguelisidoro/archive/2008/03/17/TechDays-_1320_-2_BA00_-Dia.aspx">aqui</a>.</p></body></item><item><dc:creator>Miguel Isidoro</dc:creator><title>TechDays 2008 – 2º Dia</title><link>http://weblogs.pontonetpt.com/miguelisidoro/posts/26901.aspx</link><pubDate>Mon, 17 Mar 2008 17:49:00 GMT</pubDate><guid>http://weblogs.pontonetpt.com/miguelisidoro/posts/26901.aspx</guid><wfw:comment>http://weblogs.pontonetpt.com/miguelisidoro/comments/26901.aspx</wfw:comment><comments>http://weblogs.pontonetpt.com/miguelisidoro/posts/26901.aspx#feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.pontonetpt.com/miguelisidoro/comments/commentRss/26901.aspx</wfw:commentRss><trackback:ping>http://weblogs.pontonetpt.com/miguelisidoro/trackback.aspx?ID=26901</trackback:ping><description>&lt;p&gt;Decorreu na passada semana entre os dias 12 e 14 de Março a edição deste ano do &lt;a href="http://www.techdays.pt/" target="_blank"&gt;TechDays&lt;/a&gt;, o maior evento de tecnologia do país. Este evento juntou mais de 2000 profissionais na área das TI, tendo sido dadas mais de 150 sessões técnicas por 120 oradores, tendo sido claramente a maior edição deste evento. De seguida, deixo o meu testemunho relativamente às sessões a que tive oportunidade de assistir no 2º dia.&lt;br /&gt;&lt;/p&gt;
&lt;h4&gt;INT04 - Qual é o Contexto desta Conversação? Activando Conversações Longas em Serviços de Workflow. Serviços "Duráveis" &lt;/h4&gt;
&lt;p&gt;Orador: José António Silva, Microsoft &lt;/p&gt;
&lt;p&gt;Tendo em consideração a natureza dos workflows onde uma instância de workflow pode estar activa durante um período de tempo longo ("long running instance"), é necessário desenvolver os serviços WCF de forma a suportar este tipo de cliente. Esta sessão abordou o tema de serviços "duráveis". Estes são um novo tipo de serviço da .NET Framework 3.5 que permite simplificar a persistência de estado numa "conversação" entre um serviço WCF e um cliente (ex: um workflow). O modelo de persistência do estado de um serviço WCF é em tudo idêntico ao de WF, sendo possível guardar o estado em BD, files system, etc . De forma a tornar um serviço WCF "durável" basta usar o prefixo "Durable" nos atributos da classe do serviço. Exemplo: &lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;[Serializable] &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;[DurableService]&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;public class TextComposer : ITextComposer&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;{&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;    private string CurrentText ; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;strong&gt;[DurableOperation]&lt;/strong&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;    public string PowerOn(string text)&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;    {&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;        CurrentText = text;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;        return CurrentText;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;    } &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;}&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Mais informação sobre "Durable Services" em &lt;a href="http://weblogs.asp.net/gsusx/archive/2007/06/14/orcas-durable-services.aspx"&gt;http://weblogs.asp.net/gsusx/archive/2007/06/14/orcas-durable-services.aspx&lt;/a&gt; (post antigo mas com uma boa explicação) e em &lt;a href="http://www.microsoft.com/uk/msdn/nuggets/nugget/270/Durable-Services-with-WCF-V35.aspx"&gt;http://www.microsoft.com/uk/msdn/nuggets/nugget/270/Durable-Services-with-WCF-V35.aspx&lt;/a&gt; (screencast). &lt;/p&gt;
&lt;p&gt;Algumas tools interessantes para WCF referidas durante a sessão: &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Configuration Editor Tool&lt;/strong&gt; – aplicação que permite que permite a edição das configurações de serviços WCF com uma interface gráfica (Start&lt;span style="FONT-FAMILY: Wingdings"&gt;à&lt;/span&gt;Run&lt;span style="FONT-FAMILY: Wingdings"&gt;à&lt;/span&gt; SvcConfigEditor). Mais informação em &lt;a href="http://msdn2.microsoft.com/en-us/library/ms732009.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms732009.aspx&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WCF Test Client&lt;/strong&gt; – aplicação que permite efectuar testes "offline" sobre serviços WCF (Start&lt;span style="FONT-FAMILY: Wingdings"&gt;à&lt;/span&gt;Run&lt;span style="FONT-FAMILY: Wingdings"&gt;à&lt;/span&gt; WcfTestClient). Mais informação em &lt;a href="http://msdn2.microsoft.com/en-us/library/bb552364.aspx"&gt;http://msdn2.microsoft.com/en-us/library/bb552364.aspx&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Service Trace Viewer Tool&lt;/strong&gt; – aplicação que permite a análise dos logs de mensagens geradas pelo WCF (Start&lt;span style="FONT-FAMILY: Wingdings"&gt;à&lt;/span&gt;Run&lt;span style="FONT-FAMILY: Wingdings"&gt;à&lt;/span&gt; SvcTraceViewer). Mais informação em &lt;a href="http://msdn2.microsoft.com/en-us/library/ms732023.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms732023.aspx&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;ARC01 - Software + Services: The Convergence of SaaS, SOA and Web 2.0 &lt;/h4&gt;
&lt;p&gt;Orador: Beat Schwegler, Microsoft&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Esta sessão retratou um tema muito em voga: o Software + Services. A sessão não teve qualquer demo, tendo tido uma componente bastante teórica, tendo sido iniciada com a referência a três conceitos importantes: SaaS (&lt;a href="http://msdn2.microsoft.com/en-us/architecture/aa699384.aspx"&gt;http://msdn2.microsoft.com/en-us/architecture/aa699384.aspx&lt;/a&gt;), SOA (&lt;a href="http://msdn2.microsoft.com/en-us/architecture/aa948857.aspx"&gt;http://msdn2.microsoft.com/en-us/architecture/aa948857.aspx&lt;/a&gt;) e Web 2.0 (&lt;a href="http://twopointouch.com/2006/08/17/10-definitions-of-web-20-and-their-shortcomings/"&gt;http://twopointouch.com/2006/08/17/10-definitions-of-web-20-and-their-shortcomings/&lt;/a&gt;). Foram referidos alguns exemplos de modelos de negócio usados com S+S: Subscription/License Model, Advertisement Base Model (ex: Google). Foram dados ainda alguns exemplos de aplicações S+S: Eve Online (&lt;a href="http://www.eve-online.com/"&gt;http://www.eve-online.com/&lt;/a&gt;), o Amazon S3 (&lt;a href="http://www.amazon.com/gp/browse.html?node=16427261"&gt;http://www.amazon.com/gp/browse.html?node=16427261&lt;/a&gt;) e a British Library. Por fim, foram ainda referidos alguns exemplos concretos de implementação do S+S pela Microsoft: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Finished Services – Windows Live, Office Online 
&lt;/li&gt;&lt;li&gt;Attached Services – XBOX Live 
&lt;/li&gt;&lt;li&gt;Building Blocks – BizTalk Services &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;INT06: Viagem ao Centro da Núvem – O Internet Service Bus (ISB) e os BizTalk Services &lt;/h4&gt;
&lt;p&gt;Orador: João Pedro Martins a.k.a "Jota", Create IT &lt;/p&gt;
&lt;p&gt;A sessão começou de uma forma muito interessante com o Jota a "provocar" a audiência com algumas ideias sobre a forma como será o mundo das aplicações no futuro como a transição de um mundo com "data centers" nas próprias empresas para um em que o "hosting" é feito por grandes empresas com super "data centers" dedicados a fazer o "hosting" de milhares de aplicações. Foi uma forma interessante de cativar desde início a audiência. Neste sentido, foram dadas algumas estatísticas interessantes como a previsão do aumento de número de servidores de hosting da Microsoft de 200000 actuais para 800000 em 2011, indo de encontro à adopção do conceito de Software como um serviço (S+S) com as aplicações a ser alojadas em "hosting" externo e serem expostas como serviços. Os BizTalk Services, são basicamente a visão da Microsoft da forma como as aplicações irão comunicação entre si no futuro, facilitando o desenvolvimento de aplicações orientadas a serviços (SOA). A ideia fundamental dos BizTalk Services é a de permitir a comunicação segura entre as aplicações das organizações através de firewalls.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;COL07 - Microsoft Search Server 2008 - Introdução e Apresentação de Novas Funcionalidades&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;Oradores: Bruno Valente e Luís Calado, Microsoft &lt;/p&gt;
&lt;p&gt;O Microsoft Search Server 2008 (MSS 2008) é a versão 2 do já existente "SharePoint Server for Search". As principais diferenças de para a versão anterior são:&lt;span style="COLOR: #17365d"&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Melhorias significativas na interface de administração 
&lt;/li&gt;&lt;li&gt;Pesquisa federada (a maior novidade) 
&lt;/li&gt;&lt;li&gt;Melhorias de performance e estabilidade 
&lt;/li&gt;&lt;li&gt;Pesquisa "cross-site" mesmo na versão Express (ao contrário do que acontecia antes) 
&lt;/li&gt;&lt;li&gt;
&lt;div&gt;Melhorias nos relatórios &lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Duração última indexação e da actual 
&lt;/li&gt;&lt;li&gt;Última indexação completa, etc &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Vão existir duas versões do produto: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Search Server 2008 – versão paga que pode ser instalada num cenário de farm. Os clientes MOSS não terão custos adicionais para fazer o upgrade para MSS 2008. 
&lt;/li&gt;&lt;li&gt;Search Server 2008 Express – versão gratuita que apenas pode ser instalada num único servidor. &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;A principal novidade do produto é a pesquisa federada. A ideia passa por permitir a pesquisa sobre outros motores de pesquisa ou aplicações, integrada no SharePoint, sem ter que ter os conteúdos indexados no índice de SharePoint. Alguns dados sobre a pesquisa federada:&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A única desvantagem é a inexistência de "ranking" dos resultados de pesquisa pelo facto de não estarem indexados. 
&lt;/li&gt;&lt;li&gt;Cada motor de pesquisa tem que ser configurado no SharePoint como uma localização federada. 
&lt;/li&gt;&lt;li&gt;A pesquisa é efectuada com base no standard OpenSearch (&lt;a href="http://www.opensearch.org/Home"&gt;http://www.opensearch.org/Home&lt;/a&gt;) onde a query de pesquisa é enviada por URL. Ex: &lt;a href="http://search.live.com/result.aspx?q=%7bsearchTerms%7d"&gt;http://search.live.com/result.aspx?q={searchTerms}&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;Resultados de pesquisa devolvidos em XML &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Existem duas web parts "out-of-the-box" para pesquisa federada: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Federated Results Web Part: mostra todos os resultados de uma localização federada 
&lt;/li&gt;&lt;li&gt;Top Federated Results Web Part: mostra os "top x" resultados de uma ou mais localizações federadas &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Podem consultar as sessões do dia 1 &lt;a href="http://blogit.create.pt/blogs/miguelisidoro/archive/2008/03/17/TechDays-_1320_-1_BA00_-Dia.aspx"&gt;aqui&lt;/a&gt;.&lt;/p&gt;</description><body xmlns="http://www.w3.org/1999/xhtml"><p>Decorreu na passada semana entre os dias 12 e 14 de Março a edição deste ano do <a href="http://www.techdays.pt/" target="_blank">TechDays</a>, o maior evento de tecnologia do país. Este evento juntou mais de 2000 profissionais na área das TI, tendo sido dadas mais de 150 sessões técnicas por 120 oradores, tendo sido claramente a maior edição deste evento. De seguida, deixo o meu testemunho relativamente às sessões a que tive oportunidade de assistir no 2º dia.<br /></p>
<h4>INT04 - Qual é o Contexto desta Conversação? Activando Conversações Longas em Serviços de Workflow. Serviços "Duráveis" </h4>
<p>Orador: José António Silva, Microsoft </p>
<p>Tendo em consideração a natureza dos workflows onde uma instância de workflow pode estar activa durante u