SharePoint Deployment

The second part of the OBA deployment story is about deploying the SharePoint parts of your application. There are many parts of SharePoint that you can customize and deploy as part of your solution. For example, you might consider building and publishing custom Web parts within your SharePoint site, which needs to be a part of the deployment process. We’ve covered the creation and publishing of Web parts in a couple of chapters (specifically, see Chapter 3 and Chapter 7), so in this chapter we’re going to focus on three main areas:

  1. How you deploy a solution and a feature that contain a single list. This is a simple example, but once you understand how to deploy one part of the model, it is the same for the rest.

  2. A high-level discussion on how to deploy SharePoint workflow using VSTO.

  3. How to deploy a VSTO client-side customization to your SharePoint site and then subsequently map this to a content type. A good example would be a custom budget template that loads data from a LOB system that you then bind to a custom content type on SharePoint.

Features

SharePoint is the center of many Office Business Applications. Most OBA applications contain many components, such as a custom list or library that uses a workflow to show InfoPath forms or uses Excel services. All of these components together make up your application. They all need to be installed and uninstalled together for your application to work properly. SharePoint allows you to bundle all of your various SharePoint components together as an atom unit in a feature. A feature is a collection of a number of elements that work together to provide an application. For example, you could have a feature that contains a number of lists, libraries, and workflows to make up an application. You will see how to create a simple feature in this chapter.

Features are defined as a folder in the features directory located at C:Program FilesCommon FilesMicrosoft SharedWeb server extensions12TEMPLATEFEATURES on the Sharepoint server. In this example, you will create a feature called OBADiscussionList. This feature will contain a custom list for discussion OBAs and a workflow. Create a file under the OBADiscussionList folder called manifest.xml. Example 8-4 shows a simple manifest XML file.

Example 8-4. Simple feature.xml file

<?xml version="1.0" encoding="utf-8" ?>

<Feature
   Id="11111111-2222-3333-4444-555555555555"
   Title="OBA List"
   Description="A Sample OBA List"
   Version="1.0.0.0"
   Scope="Web "
   xmlns="http://schemas.microsoft.com/sharepoint/">

   <ElementManifests>
      <ElementManifest Location="OBADiscussionElement.xml" />
      <ElementManifest Location=" ExpenseReportWorkflowElement.xml " />
   </ElementManifests>

</Feature>

The feature.xml file contains a root node called Feature. This has attributes such as Id, title, version, and description. The scope value is set to "Web," which gives this feature a site scope. The feature node also contains a collection of element manifest. Each element manifest defines a new component for the feature. For example, if your feature had a document library, a list, and a workflow, then you would have three ElementManifest nodes in the ElementManfests node collection. In the example seen in Example 8-5, you have one for the OBAListElement. In this case, use an ID of 11111111-2222-3333-4444-555555555555; this will make it easier to debug and recognize your feature later on.

Example 8-5. Simple OBAListElement.xml element file.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <ListTemplate
   Name="discuss"
   Type="108"
   BaseType="0"
   OnQuickLaunch="TRUE"
   FolderCreation="FALSE"
   SecurityBits="12"
   Sequence="350"
   DisplayName="OBA Discussion List"
   Description="An OBA Discussion List"
   />
</Elements>

In this feature, we are also going to include the workflow that you created in Chapter 7. Add the workflow.xml element shown in Example 8-6 to the feature folder. See Chapter 7 for the complete listing and other components required for the workflow.

Example 8-6. Simple ExpenseReportWorkflowElement.xml element file

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <Workflow
      Name="ExpenseReportWorkflow"
      Description="Use this workflow to track expense report status."
      Id="C6964BFF-BG8D-41ac-AC5E-B61EC111731C"
      CodeBesideClass="OBAExpenseReport.Workflow1"
      CodeBesideAssembly="OBAExpenseReport, Version=12.0.0.0,
      Culture=neutral, PublicKeyToken=71e3bce121e9429c"
      TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"
      AssociationUrl="_layouts/expenseReportAssociationPage.aspx"
      InstantiationUrl="_layouts/expenseReportInitiationPage.aspx"
      ModificationUrl="_layouts/expenseReportModificationPage.aspx">
   <Categories/>
   <AssociationData>
   ...
   </AssociationData>
   <MetaData>
   ...
   </MetaData>
 </Workflow>
</Elements>

Once you have defined the feature.xml and all of the required elements, you must copy the feature to the feature directory on the SharePoint server at C:Program FilesCommon FilesMicrosoft SharedWeb server extensions12TEMPLATEFEATURES. The feature still must be installed using the stsadm.exe command line tool. The first step is to install the feature using the following command run on the server with administrator permissions.

stsadm -o installfeature -filename OBADiscussionList Feature.xml

The next step is to activate the feature using the following command specifying the site to make the feature available.

stsadm -o activatefeature -filename OBADiscussionList Feature.xml -url http://Server/Site/Subsite

Once the feature is installed and activated on the server, the feature is available for end users to use. Open the SharePoint site and open Lists. Click on Create to create a new list. You can see in Figure 8-18 that the OBA Discussion list is now available.

After you click on the OBA Discussion List link, you will be taken to a screen to name the instance of the custom list. In Figure 8-19, you can see in the URL the feature id GUID that you created; in this example, it was a very recognizable pattern of 11111111-2222-3333-4444-555555555555.

Create a new instance of our custom OBA Discussion list.

Figure 8-18. Create a new instance of our custom OBA Discussion list.

The URL displays the feature id GUID for this list.

Figure 8-19. The URL displays the feature id GUID for this list.

SharePoint Workflow Deployment

In some sense, you can characterize VSTO as a "wrapper" technology around the Office system. What this means is that it represents the access layer to the object model for the different Office system products, such as Microsoft Word and Excel. Beyond the client, though, as you saw in Chapter 7, VSTO also has the ability to create and deploy workflow for SharePoint; thus VSTO is a wrapper technology for SharePoint as well. One of the key differentiators, though, is that even though you’re similarly using VSTO to create a project for Word or for SharePoint workflow, the deployment is slightly different.

When building and deploying SharePoint workflow using VSTO, one of the key differences is that VSTO provides a wizard to guide you through the publishing of a specific workflow template, thus significantly reducing the number of steps that are required to build and debug the workflow project. As you go through the process of deploying the workflow, you associate that workflow with a particular SharePoint object—a list, for example. If you have not read Chapter 7, I would suggest taking a look at the Deployment section under SharePoint Workflow, as it provides some detail on SharePoint workflow deployment. Beyond reading Chapter 7, more general SharePoint Workflow documentation exists online at http://msdn2.microsoft.com/en-us/library/ms460303.aspx.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset