Microsoft SharePoint 2010
Copyright
This is a preliminary document and may be changed substantially prior to final commercial release of the software described herein.
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication.
This white paper is for informational purposes only. MICROSOFT MAKES NO
WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.
Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in, or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other
intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this
document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.
Unless otherwise noted, the example companies, organizations, products, domain
names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred.
© 2009 Microsoft Corporation. All rights reserved.
Microsoft SharePoint Server 2010,Microsoft Visual Studio 2010,Microsoft SharePoint Designer 2010, Microsoft Office InfoPath, Microsoft Office Visio are trademarks of the Microsoft group of companies.
Contents
Abstract... 1
Introduction ... 1
Summary of What’s New ... 2
Key Types of Solutions Built on SharePoint by Developers ... 3
Building Applications on SharePoint ... 3
Business Collaborative Applications ... 4
User Interface Portal for Line of Business Application Data ... 5
Customizing Out-of-Box Workloads... 5
One Web Part Solutions ... 8
Improved Developer Productivity with Better Tools ... 8
Visual Studio 2010 SharePoint tools ... 8
Visual Studio 2010 SharePoint tools extensibility ...13
Developer Workstation support for Windows 7 and Windows Vista SP1 ...14
Upgrading from Visual Studio 2008 extensions for SharePoint to Visual Studio 2010 SharePoint tools ...14
SharePoint Designer 2010 ...16
SharePoint Designer 2010 Workflow Design ...18
SharePoint Designer 2010 Business Connectivity Services Design ...19
Developer Dashboard ...21
SharePoint 2010 Application Lifecycle Management ...23
Better Solutions with Rich Platform Services ...24
User Interface...25
Building User Interface ...27
The SharePoint 2010 Ribbon ...27
The SharePoint 2010 Dialog Framework ...28
SharePoint List Lookups and Relationships ...30
Business Connectivity Services ...32
LINQ to SharePoint ...33
Performance Enhancements ...34
Event Enhancements ...35
Workflow Enhancements ...36
Document Sets...38
SharePoint 2010 API Choices ...39
Flexible Deployment Increases the value of SharePoint Solutions ...41
Sandboxed Solutions ...41
SharePoint Online ...43
Upgrading Solutions ...43
Learning More ...44
Conclusion ...44
SharePoint 2010 Developer Walkthroughs ...45
Walkthrough 1: Using LINQ to SharePoint from within a Visual web part ...45
Walkthrough 2: Building a Web Part for a Sandboxed Solution ...54
Walkthrough 3: SharePoint Designer Workflows imported to Visual Studio 2010 ...63
Walkthrough 4: Accessing List Data using the JavaScript Client OM...88
Walkthrough 5: Creating and Using External Lists in SharePoint 2010 ... 101
Abstract
This evaluation guide is designed to give you an overview of the feature set and extensibility points for Microsoft SharePoint 2010 and an understanding of how the professional developer can use these features and extensibility points to create
comprehensive solutions. This guide begins with an overview of the types of solutions that you can build by developing on SharePoint. It then covers the developer tools for SharePoint 2010, the new platform features and the solution deployment
enhancements. The guide concludes with six walkthroughs showing example developer customizations in SharePoint 2010.
The ultimate goal of this guide is to provide a framework for an effective evaluation of SharePoint 2010 as a solution creation platform. This guide is intended for the
professional developer, development lead, and software architect. Also available are an evaluation guide focused on SharePoint 2010 the product and an evaluation guide for the IT Professional.
For the latest information about SharePoint 2010, go to
http://SharePoint.Microsoft.com. For other product information resources, refer to the “Learning More” section in this guide. Feedback on this guide can be emailed to [email protected].
Introduction
Welcome to the professional developers evaluation guide for Microsoft SharePoint 2010. The goal of this guide is to help you gain sufficient knowledge and understanding of SharePoint 2010 to evaluate this product from Microsoft.
SharePoint 2010 provides the business collaboration platform for developers to rapidly build solutions using familiar tools while leveraging a rich set of out of the box features. Visual Studio 2010 and SharePoint Designer 2010 make developers more productive and Visual Studio Team Foundation Server delivers support for application lifecycle management. Developers can integrate Line of Business data in SharePoint 2010 with read/write capability delivered by Business Connectivity Services. Sandboxed Solutions can be deployed to a shared hosting environment to limit the impact of unpredictable
SharePoint 2010 is a major step forward for SharePoint as a development platform not only because of the richer set of overall features that the platform supports but also because significant investments have been made in the suite of tools to make
developers more productive, and also more accessible to developers of all skill levels. This guide will walk you through some of the most compelling enhancements to the SharePoint 2010 platform for developers.
Summary of What’s New
SharePoint 2010 includes numerous new capabilities and features for professional
developers most of which are highlighted in this document. Here is a summary of what’s new.
Developer Productivity
Visual Studio 2010 SharePoint Project Types and Items Visual Studio 2010 SharePoint tools extensibility
Visual Studio Extensions For SharePoint Upgrade
Windows 7 and Windows Vista Operating System Support SharePoint Designer 2010
Developer Dashboard
Team Foundation Server 2010 Integration
Rich Platform Services
SharePoint Ribbon SharePoint Dialogs Silverlight Web Part
List Lookups and Relationships Business Connectivity Services LINQ to SharePoint
Performance Enhancements Solution Throttling
Event Enhancements Workflow Enhancements Client Object Model REST APIs
Flexible Deployment
Sandboxed Solutions SharePoint Online Upgrading Solutions
In this guide we will walk through all of the new features in SharePoint 2010 that pertain to professional software developers. First we will briefly discuss some key types of
solutions that can be built by developers by leveraging the benefits of SharePoint 2010.
Key Types of Solutions Built on SharePoint by
Developers
Developers create solutions every day. SharePoint 2010 makes developing those
solutions easier, quicker, and more flexible. Much of the work that the developer had to do in the past with earlier versions of SharePoint has been replaced with simple
configuration of the SharePoint 2010 platform, use of Visual Studio 2010 and SharePoint Designer 2010 or with calls to the SharePoint API.
Building Applications on SharePoint
SharePoint as a platform for application development has really spread its wings with the release of SharePoint 2010. Organizations can get greater productivity by
capitalizing on the out of the box features and rich extensibility of SharePoint. Visual Studio 2010, SharePoint Designer 2010, and the SharePoint web user interface
common way to share work between those tools the development process has become more streamlined. Better connectivity between the tooling in SharePoint 2010 facilitates business analysts and even end users becoming a part of the development process by creating assets that the developer can leverage in the development process.
Business Collaborative Applications
In organizations there is a whole class of applications which don’t fit into the categories of the structured systems that manage relational data for process, control, or
production. Collaborative applications are designed to facilitate and even encourage users to work with one another toward a common goal. Office 2010 and related products and technologies including SharePoint 2010 make developing these types of applications quicker and more effective.
SharePoint 2010 is a web-based product and that makes it easy for users to access their information from anywhere. The built in document management and list management features with which SharePoint users are familiar have been extended in several key ways to accelerate solutions which have not been easy in the past. Data management enhancements allow for larger list support, better validation, and connectivity to line of business systems.
Many scenarios including for tracking defects or incidents in a manufacturing line become easy to solve by creating a few simple forms. Workflow enhancements for performance, stability, and manageability can be leveraged to solicit feedback on the types of causes for the defect – and what can be done to mitigate or resolve them. Enterprise Content Management capabilities of the platform allow defects and the analysis to be placed into a records retention policy. All of this can be done with minimal work on the part of the developer to create the lists, construct the workflows, and configure the platform.
The updated client applications, including SharePoint Workspace, mean that the mobile workforce in today’s business climate can do work whether they’re connected to the server or not. This extends the reach of the application from the users in the office to the users out in the field as well.
The new tagging and rating support mean that aggregating the wisdom of large numbers of users becomes easier. Popular responses can now be highlighted. Instead of building collaborative applications which served smaller groups of people, the new
social features allow larger teams and even the entire organization to find valuable content developed through the collaborative process.
We have moved from an era of data into an era of information and with the features of SharePoint 2010 we can move into an era of personal information.
User Interface Portal for Line of Business Application Data
Just as line of business systems are a key need for organizations, so too are front end systems which can help get information into the core line of business (LOB) systems that drive the transactional and production throughput of the organization. Traditional LOB systems have a core set of users who are well educated in their use and a much broader audience of users who are less trained and whom interact only in limited or occasional ways.
The integration of SharePoint 2010 with back end systems through Business
Connectivity Services (formerly known as Business Data Catalog), allows SharePoint to be used to deliver data to the LOB systems. For instance, purchase order requests can be routed for approval in SharePoint via a workflow and delivered to the back end system pre-approved. Similarly, a Word form can be created which reads from the LOB system to look up the customer and product descriptions. The end result of the form can be an order in the sales order system. The ability to read information from the LOB system – and to write back changes – makes it easy to integrate SharePoint 2010 and Office 2010 into your existing back end systems.
Customizing Out-of-Box Workloads
SharePoint 2010 offers six out of the box workloads as shown in Figure 1. These
capabilities make SharePoint a powerful platform for any user and a powerful platform for extension by a developer.
Figure 1 – SharePoint 2010 Capabilities
More detail about each of these workloads can be found in the SharePoint 2010
Evaluation Guide, this Developer Evaluation Guide will overview the extensibility points that developers can customize. Some of the ways that professional developers can customize and extend them as shown in this table:
Capability Out of the Box features Extensibility points
Sites The capability to store and
retrieve both list and document content in an easy and flexible way with connectivity to the
Microsoft Office client applications.
Web Parts, Master Pages, Pages, Delegate Controls, InfoPath Forms, and solutions leveraging the Word File Conversion Service. Access Services for deploying Access solutions to SharePoint.
Communities The capability to locate and interact with people
through expertise,
relationships, tagging, and rating of content.
Predefined searches, search web parts, tagging
interfaces, rating interfaces, and custom user interfaces
Content The capability to manage content whether that content is a web page, a document, or a set of documents and records management of the content that is created.
Custom page types, field controls, content types, document sets, remote blog storage providers, workflows and Word Services. Records
management extensibility and Public Web Sites extensibility.
Search The capability to search
content inside and outside of SharePoint including information in structured database systems.
Predefined search result transformations, web parts leveraging search for navigation and location of content, and connections to back end systems. Also IFilters and Protocol Handlers.
Insights The capability to leverage
Excel to access and display data on a web page, Dashboards, and Key Performance Indicators to transform raw data into actionable information.
Excel Services, Excel User defined functions, key performance indicators, and dashboards
Composites The capability for business users to create their own solutions through
connection and
arrangement of the features of the platform.
Web parts, workflows and InfoPath Forms Services that increase the tools available for the end user.
One Web Part Solutions
Web Parts are the simplest building block in SharePoint and developers are often called on to build just one. A web part may be used to add a data viewer to a SharePoint site, to show user interface for a custom process or to show a new kind of social data. The possibilities are broad and web parts are easy to create for SharePoint Server 2010.
Improved Developer Productivity with Better Tools
Developers will be excited with the rich set of tools for building solutions withSharePoint 2010. Visual Studio 2010 has direct support for the most common kinds of projects that you might want to create in SharePoint 2010 and it has tools for packaging SharePoint solutions as WSP files. SharePoint Designer 2010 includes new support to help make the transition between designers and analysts to developers smoother and more productive. The developer tools and SharePoint 2010 can be run on a workstation operating system including Windows 7 and Windows Vista SP1 rather than requiring a server Operating System for each developer.
Visual Studio 2010 SharePoint tools
Visual Studio 2010 includes support out of the box for the most common types of projects that you may want to build with SharePoint 2010 as well as new features for more easily defining features, solutions, and wizards to walk through the most common settings for each project type. Visual Studio 2010 has the following project templates built in:
Empty SharePoint Project Visual Web Part
Sequential Workflow State Machine Workflow
Business Data Connectivity Model Event Receiver
List Definition Content Type Module (Files) Site Definition
Import Reusable Workflow
Import SharePoint Solution (WSP) Package
Each project is either C# or VB.NET project that contains particular initial project items. You can add typical C# or VB.NET artifacts as well. In addition Visual Studio 2010 includes additional SharePoint project items as items that you can add to any of your projects:
Web Part
Workflow Association Form Workflow Instantiation Form Application Page
List Definition from Content Type List Instance
Empty Element User Control
Figure 3 – SharePoint Item Templates in Visual Studio 2010
Each project wizard guides you through the process by asking what site you want to use to deploy and debug your solution. It also asks whether the result of the project will be deployed as a sandboxed solution as shown in figure 4.
Figure 4 – Project wizard connects the development environment to a SharePoint instance
Visual Studio 2010 also includes support for viewing SharePoint 2010 sites through the Server Explorer. You can now use Server Explorer to look at all of the SharePoint settings for sites, lists, content types, workflow associations, and other objects. This allows you to navigate and view SharePoint sites. It simplifies the process of checking code against the implementation in the system because all of the implementation details available to you in the Visual Studio 2010 environment. For document libraries and lists it also gives you quick access to an artifact you view in the Server Explorer with a link to the SharePoint Web UI. Figure 5 shows the Server Explorer with a SharePoint site open.
Figure 5 – Server Explorer allows you to navigate SharePoint
Visual Studio 2010 SharePoint tools extensibility
Visual Studio 2010 provides a rich set of project templates and tools that developers can use to create custom SharePoint solutions. Although these SharePoint projects and tools work well for many application development scenarios, there may be times when
different or new functionality is needed. In these cases, you can adapt the SharePoint projects and tools in Visual Studio by using a new Visual Studio extensibility Application Programming Interface (API).
This API lets you create new SharePoint project items, automate and extend existing SharePoint project items, enhance packaging, validation, deployment and retraction, extend the SharePoint nodes in Server Explorer, and even create new designers.
Developer Workstation support for Windows 7 and Windows Vista SP1
SharePoint 2010 makes great advances in the development environments that can be used to create SharePoint solution. In addition to a broader set of tools for developing solutions for SharePoint the requirement to be running on a server operating system has been relaxed so that it is possible to develop applications on a local developer workstation running a client operating system like Windows 7. Support for Windows 7, Windows Vista Service Pack 1, in addition to Windows Server 2008 means thatdevelopers can build on a non-server OS locally and then deploy to a server running Windows Server 2008 for integration, testing, and production.
It is important to note that SharePoint 2010 is only available as 64 bit version and therefore the operating system, whether client or server, must be a 64 bit version.
Upgrading from Visual Studio 2008 extensions for SharePoint to Visual
Studio 2010 SharePoint tools
Visual Studio 2010 provides developers with many resources to help upgrade their code from Office SharePoint Server 2007 to SharePoint 2010.
Projects based on the Visual Studio 2008 workflow project templates are upgraded automatically by Visual Studio 2010 to equivalent projects which still target Office SharePoint Server 2007 but can now be developed in Visual Studio 2010. All other SharePoint projects in Visual Studio 2010 target SharePoint 2010.
Projects based on the Visual Studio 2008 extensions for Windows SharePoint Services (VSeWSS) project templates can be upgraded to equivalent projects targeting
SharePoint 2010 and continued development on Visual Studio 2010. An upgrade tool is available that upgrades these projects to the new project and packaging format of the Visual Studio 2010 SharePoint tools. Figures 6 and 7 show the wizard that walks you through the upgrade process.
Figure 7 – Visual Studio Extensions for Windows SharePoint Services Step 2
SharePoint Designer 2010
SharePoint Designer 2010 is a fully functional participant in the solution creation
lifecycle for SharePoint 2010. Applications can be created with the SharePoint web user interface and with SharePoint Designer 2010 as complete applications. Or they can be packaged into a SharePoint Solution (WSP) file that can be imported into and further edited by Visual Studio 2010. For example a declarative re-usable workflow can be prototyped in SharePoint Designer 2010 and moved in to Visual Studio 2010.
The ability of the farm administrator to control of usage of SharePoint Designer 2010 has been substantially improved. You can now specify which SharePoint Designer features are available at a web application and site collection level. This will make it
easier for organizations to allow SharePoint Designer in some areas of a site and restrict it in others.
From the perspective of the user of SharePoint Designer the fundamental approach has changed. Instead of being focused on pages and as a HTML/CSS editor, it is been
refocused around the artifacts that you create in SharePoint. Sometimes the artifact that you are creating with SharePoint designer is a master page but more often it is the implementation for lists and libraries, workflows, content types, data sources, entities, or site level settings. Figure 8 shows the primary left navigation menu of SharePoint
designer which highlights the new focus on SharePoint artifacts.
Figure 8 – SharePoint Designer navigation is SharePoint Site focused
A site dashboard in SharePoint Designer 2010 allows you to see at a glance the basic information about the site. The navigation bar allows you to navigate into more details about the specific lists and libraries. Figure 9 shows the site dashboard for a site
Figure 9 – SharePoint Designer’s Site Dashboard provides an “at a glance” view of the SharePoint site SharePoint Designer 2010 Workflow Design
In SharePoint Designer 2010 the workflow design experience is a perfect example of how a business analyst can access a tool that can be leveraged as the first step in a development cycle. The workflow designer in SharePoint Designer 2010 allows you to specify a set of steps, conditions, and actions that fit together into a sequential
workflow. The designer allows you to create complex workflows that include looping and branching by clicking a few buttons in the ribbon. By assembling the out of the box actions and custom actions it is possible to develop workflows which do not require any custom code.
The user interface for building the workflow is a full page, artifact model which allows you to develop a workflow like any other SharePoint artifact by referring to other resources and potentially making changes to lists and content types while building the workflow.
Those workflows that are developed in SharePoint Designer 2010 can be exported into a SharePoint Solution Package file (WSP) so that they can be imported in Visual Studio 2010 and from there enhanced or changed. Workflows can also be designed in Visio and imported into SharePoint Designer and Figure 10 shows the Approval workflow when visualized with Microsoft Visio.
Figure 10 – Microsoft Visio can visualize workflows
The workflow editor in SharePoint Designer 2010 has two basic modes. A non-reusable workflow mode which uses the specific attributes of a list and embeds those fields, content types, etc., into the workflow and the reusable workflow which can be packaged for redeployment. The non-reusable workflow allows for a simpler design experience when the workflow will only ever need to exist in one place. The reusable workflow can be reused anywhere – so therefore does not bring context from the current site and thus requires more work to deliver. Having both allows the developer to decide which workflow solution is best for the specific scenario.
SharePoint Designer 2010 Business Connectivity Services Design
features to data outside of SharePoint. SharePoint Designer 2010 makes the process of defining external entities easy. A wizard guides you through making connections to an external system whether it is Windows Communication Foundation (WCF) Service, a Web Service, a .NET class, or a database. Once the connection is made you will see a list of the entities. By right clicking on the entity you can have SharePoint Designer
automatically generate the actions needed to support the entity. Within just a few minutes you can create the connections for all of the tables in your database and connect those to external lists in SharePoint. Figure 11 shows the AdventureWorks customer entity that was created by connecting to the Microsoft SQL Server
Figure 11 – The Entity information for a database connected customer entity
Developer Dashboard
Developing any complex system creates the opportunities for unexpected interactions. In most complex systems determining what part of the system is causing a delay or is consuming resources is difficult. SharePoint 2010 solves this problem by providing a developer dashboard which can be turned on as needed. The developer dashboard records and displays performance statistics related to the code that executed to
You can turn on the Developer Dashboard by running the following stsadm command: stsadm -o setproperty -pn developer-dashboard -pv OnDemand
Once enabled, you can turn the Developer Dashboard on and off by clicking on the Developer Dashboard action in the upper right corner of any page, see figure 12.
Figure 12: Developer Dashboard command
By turning on the detailed view – via a link in the developer dashboard itself – you get a function-by-function level trace of the time that was taken during the page load in addition to the tracing provided by ASP.NET. This allows the developer to pinpoint exactly which components on the page is generating load on the system and which components are causing the page load time. Figure 13 shows both the summary view of the developer dashboard without the extended tracing.
Figure13 - The Developer Dashboard Shows the Elapsed Time of Every Operation
SharePoint 2010 Application Lifecycle Management
The lifecycle for development in SharePoint 2010 includes business analysts as well as end users. End users and analysts develop the foundation for the solution they want in the web user interface and in SharePoint Designer 2010. SharePoint Designer 2010 can export changes into the standard SharePoint Solution Package (WSP) which can be imported into Visual Studio 2010 and used as the starting point for coding
development. By connecting the rapid prototyping phase of a project and directly linking it into the development process developer productivity is greatly enhanced. Further, because there is no loss between the work done in the web UI and SharePoint Designer, the end users and business analysts can truly start the development process and turn the artifacts over to the developer when there are features that cannot be created with the web and SharePoint Designer.
By connecting the end user and business analyst work with the developer, SharePoint facilitates a rapid development process where the user is encouraged to start the development process.
Visual Studio 2010 also supports tight integration with Visual Studio Team Foundation Server which includes both source control and team builds. Figure 14 shows the
definition of a specific build definition for SharePoint projects.
Figure 14 – SharePoint Project Specific build process implemented in Team Foundation Server
Better Solutions with Rich Platform Services
SharePoint 2010 is a rich platform on which you can build your application. The
Microsoft .NET framework provides base level services that developers can import and use through code. The SharePoint 2010 platform extends this with additional libraries and functionality that can be called directly from developer code. SharePoint also
provides a set of end user and business analyst tools that integrate tightly into the features and APIs available to developers. Figure 15 shows a diagrammatic overview of the components of the platform.
Figure 15 – The SharePoint Platform
User Interface
The look and feel of SharePoint has radically changed from earlier versions of the product. In addition to being more accessible to the user it allows for improved
can extend and build applications with include the fluent UI ribbon and an extensible dialog system. Figure 16 shows the new home page for the default team site template in edit mode.
Figure 16 – The New SharePoint Home Page with the Enhanced User Interface
SharePoint 2010 supports XSLT views which leverage a standard for transformation of information from XML into HTML. XSLT support means that any XSLT editor can help you create compelling views. SharePoint Designer 2010 improves on its support for XSLT view generation by allowing you to edit the template for an individual item or for the overall view. The new XSLT engine provides a mechanism for exporting and reusing list views between sites by removing the requirement that a view be associated by a GUID. Mixing the display content and code has never been so easy. In SharePoint 2010 the dividing line between content and code has been blurred because web parts can now be added as a part of content. This means that you can make your components finer
grained, gaining even more re-use.
Web Parts are arguably the most frequently used extension point for SharePoint with nearly every project including at least one web part. Developer tooling for creating web
parts has been extended to Visual Web Parts which manages an ASP.NET User Control (ASCX) connected to a web part class. This approach allows the developer to leverage the visual designers in Visual Studio 2010 to edit their web parts. This can dramatically improve developer productivity over the previous server control-type, non-visual approaches.
Building User Interface
SharePoint 2010 leverages wiki concepts for managing content and extends these concepts by allowing for the inclusion of web parts within the wiki pages themselves. In previous versions you were allowed to add web parts to web part zones. In SharePoint 2010 the developer (and the user) has compete control of the user interface including the placement of web parts anywhere on the page. For instance, this means that it is possible to put the results of a survey next to text describing the survey. So the results of code and content can be comingled on the page to create rich live content scenarios. The SharePoint 2010 Ribbon
The context sensitive ribbon interface is now integrated into the SharePoint 2010 user experience. Your applications can extend the ribbon interface to include new menu items and options both on a global level and based on the context of the user. Figure 17 shows how SharePoint changes the ribbon when a user selects a list web part. The arrow shows the addition of the List Tools section to the ribbon when the list web part is selected.
Figure 17 - SharePoint Server 2010 allows developers to easily control the entire page experience from the menus to the content
The user interface now also features a status bar immediately below the ribbon to indicate the status of the page that you are working on. Not only do you have context for where you are on the page by context sensitive menus but the overall settings, status, or errors on the page have a consistent location to be displayed as shown in figure 18.
Figure 18 – SharePoint Server 2010 has a consistent place to communicate status and errors The SharePoint 2010 Dialog Framework
A serious challenge in user interface design for the web is the long page refresh times and the constant switching of context from one page to another. SharePoint 2010 has solved these concerns through the use of AJAX requests for partial updates and by providing a flexible popup dialog framework that allows you to pop up entry boxes on
top of the existing page. Instead of having users navigate to a new page and then come back after the data entry is completed the user stays on the same page and a dialog appears above the page.
The dialogs are just pages which are loaded with a special master page and are
therefore completely customizable by users and developers to meet their needs. Figure 19 shows a new announcement being entered in a dialog over a wiki web page.
Figure 19 – Web Dialogs provide quick entry and consistent context New Silverlight Web Part
There are times when the user interface needs to provide a level of interactivity that is simply not possible with XHTML technologies. That is where Silverlight steps in. Silverlight is the best way to leverage your .NET development skills in creating rich interactive experiences for the web. SharePoint now includes native support for Silverlight files. Simply develop your Silverlight application (.XAP) and deploy it to the server. You can then add the Silverlight application to your web page by adding the Silverlight web part and providing the location of the .XAP file. The Silverlight
Figure 20 – Silverlight brings even richer interactivity to SharePoint 2010
Data and Programmability
SharePoint provides a wealth of features and services which allow developers to quickly develop solutions to organizational problems. Developers can quickly create solutions with relate data, connect to other systems, manage a process flow, and can be deployed anywhere.
SharePoint List Lookups and Relationships
In a typical system data is somewhat normalized – not all of the system's data exists in one large table or list. Instead data exists in sets of tables or lists which have one entry for each entity across multiple tables. The SharePoint lookup field allows you to connect an identifier of one list and to display a different, friendlier field – such as name – for users to select. SharePoint 2010 adds the ability to create additional columns which display other fields from another list. In the case of a customer, it is possible to create a lookup on the ID of the other list and not only display the customer name but to also bring across multiple other fields. Figure 21 shows the definition for this customer lookup.
Figure 21 – SharePoint 2010 allows you to define lookup fields that bring other fields into the list The second major improvement in lookup fields is that they now allow you to enforce relationships. You can choose to reject deletes which would otherwise orphan data – or you can have SharePoint automatically cascade deletes so that when you delete a
customer all of their invoices are deleted as well. As a result SharePoint 2010 can now be used to create sites which have related data connected in ways familiar to users of
traditional database tools – with the additional user interface options provided by SharePoint.
Business Connectivity Services
Business Connectivity Services (formerly known as the Business Data Catalog) provides access to external data sourced from a Line of Business system, web services or other external data provider within SharePoint 2010 and Office 2010 applications. Both SharePoint 2010 and Office 2010 applications have product features that can use external data directly and tools are also provided in SharePoint Designer 2010 and Visual Studio 2010 for working with External Data. Business Connectivity Services is built on the Business Data Catalog that was included in Office SharePoint Server 2007 and adds write capability, new tools, offline caching from Office Client 2010 applications and more.
Enhancements in the infrastructure configuration allow you to specify which servers can manage this process, enhance the ability to locate the profile pages created for the entities, and create opportunities for easier connections to existing data sources. External lists also provide a greater level of control for the developer because the table structure, indexing, and access methods can be customized to improve performance of the list or to match internal guidelines. This allows developers to include large lists and tables in existing systems in their solutions with the ability to tune the performance as they better understand how the users will use the tool.
Figure 22 shows how the inclusion of BCS creates opportunities to leverage SharePoint features and APIs against your existing line of business data that is available via direct database access or via web services.
Figure 22- Architecture of Business Connectivity Services LINQ to SharePoint
LINQ is a new data access paradigm which allows users to express SQL like syntax against a variety of data sources. LINQ can improve performance by allowing the back end data source to decide the best way to solve the query. SharePoint now fully
supports LINQ for querying lists so that you can query information from the platform in a more condensed, easier to understand format. LINQ also provides strongly typed access to data in Visual Studio offering compile time validation to help avoid runtime errors. Figure 23 shows a LINQ expression targeting SharePoint.
Figure 23 – Sample method that uses LINQ for SharePoint Performance Enhancements
From optimizations in the code and SQL queries being used to generate SharePoint out of the box interfaces, to radical changes in the implementation of views, and greater flexibility for the use of large lists outside of the core data structures, SharePoint 2010 will deliver greater performance by reducing choke points in the software related to size of data, and improve performance due to more optimized queries.
SharePoint has been tightened in key spots to yield better performance including XSLT view processing and list data operations. The XSLT views have been optimized to support SharePoint 2010 emphasis on them. SharePoint list data operation
improvements include core enhancements as well as the automatic creation of indexes on lists when necessary, and improved time to first byte. In addition, SharePoint’s client object model is designed to be batched so that the number of round trips between the browser and the server are reduced to improve the overall performance of the client object model.
The use of Sandboxed Solutions (discussed in the section Sandboxed Solutions below) allows for the monitoring and management of solutions at a site collection level to limit the negative impact of a poorly performing SharePoint Solution Package (WSP) file. In addition to the performance monitoring and management for solutions, SharePoint 2010 monitors and manages large running queries via application level settings. These settings allow you to set limits and warnings when the number of records returned from a query is large. There is also an object model override that allows you to enabled developers to bypass these limits – and exclusion for a time during the day when the queries are allowed – so that large reports can be generated in batch during the
evening. Figure 24 shows the Query throttling sections of the Web Application Resource Throttling Dialog.
Figure 24 – Query Throttling can be configured for users and administrators with warnings and hard limits
Event Enhancements
In SharePoint 2010 SPListEventReceiver allows you to track events, including when a list is added. SPWebEventReceiver allows you to track web events including webs being added and sites and webs being deleted. Figure 25 shows the Visual Studio 2010 wizard for creating a web event.
Figure 25 – The Visual Studio Event Receiver Wizard for Web Events Workflow Enhancements
In SharePoint 2010 you can associate workflows with a site so you need not associate a workflow instance with a specific item in a list. Site-level workflows are a powerful mechanism to create generic functionality using the power of Windows Workflow Foundation (WF).
Prior to SharePoint 2010, workflows had to be associated with a list. This meant that if you found a problem that would be well suited to using workflow that wasn’t list or document related, you would have to find some way to associate that workflow with a list. This often led to "dummy" list items only created to be a vehicle for a workflow. With the ability to create a workflow not attached to a list, SharePoint 2010 enables a number of new workflow scenarios that where impossible or difficult.
To create a site-level workflow, you pick the Site Workflow option when creating a new workflow with Visual Studio 2010, either by picking one of the workflow project
templates, or by adding a new workflow to an existing project.
Figure 26: Site-level workflow option
Once deployed, site workflow can be started via their initiation page. There is a new action under the site actions menu which will display the site workflow page which is a dashboard where you can see all the site workflows in your site, start site workflow, and monitor their execution.
Figure 27: Site workflow page
Enhancements also allow you to run rules only workflows in a non-persisted and blocking way. This creates the opportunity to do simple event receiver like activities without the need to write code. All that is necessary is to simply declare a rules only workflow and associate it with a list. Because these workflows are not allowed to persist to the disk they are run quickly.
Visio 2010 added support to visualize what step a workflow is in via a Visio diagram. This allows users to see not only the current state of the workflow but how many additional planned steps there are before completion.
Document Sets
Additionally, SharePoint 2010 includes an Enterprise Content Management (ECM) feature called document sets. Document sets are a folder like entity that can contain other documents and because it is a content type in its own right it can have workflows associated with it as well.
Document Sets coupled with workflows creates powerful new scenarios where you can route complex documents for approval. Consider a multi-part proposal that needs to be approved. By attaching a workflow to a child document set content type you can have the whole package managed at once.
Document sets also manage shared metadata in the documents contained in the
document set so workflows can easily change the properties of all of the documents in a document set. Figure 28 shows a document set that contains two documents.
Figure 28 – Document Sets allow you to run workflows on sets of documents at the same time SharePoint 2010 API Choices
SharePoint 2010 makes SharePoint APIs available on every platform from the web server to the client, by integrating access to non-SharePoint hosted data, and by providing a richer set of tools for creating SharePoint solutions. The platform has gotten broader in the types of applications it can support and deeper in the scenarios that are supported. In SharePoint 2010 there are a number of object models that can be used by developers to access the server. The Client Object Model (Client OM) is a unified model which uses the same or similar programming concepts as the Server Object Model (Server OM). The Client OM can be accessed via web services, via a client (JavaScript) API, and via REST. This paves the way for richer applications by dramatically simplifying accessing SharePoint data from client machines and other machines in the infrastructure. Figure 29 shows the SharePoint object model options.
Figure 29 – The SharePoint Object Model Options
Through the use of Windows Communication Foundation (WCF) based services and ADO.NET Data Services v.1.5 it is possible to access the WCF services via a REST
interface. This makes it possible to make a simple web request to get data. This makes it easy to get access to SharePoint data from any client application. The basic C# code to access a REST service (excluding required references) is shown in Figure 30.
Figure 30 – Loading data from a list via a web request in C#
Having the APIs available everywhere makes it possible to integrate to SharePoint from a wide variety of applications whether they are sophisticated implementations including
the latest features like WCF, a web based application, or whether they are a legacy application with limited options for integration. By providing a set of similar APIs
accessible from a client, the server, or the cloud, the benefits provided by SharePoint are available to all kinds of applications including those on non-Windows platforms.
Flexible Deployment Increases the value of SharePoint
Solutions
The need to deliver business solutions as cost effectively as possible has lead
organizations to share platforms between applications. Servers and farms are being tasked with supporting dozens of applications, not just one or two applications as they have in the past. This creates challenges for centralized infrastructure teams that are tasked with maintaining a stable platform for all of the developers who are creating solutions. SharePoint 2010 has a set of solutions that are specifically designed to allow for this shared platform scenario – like the one run by Microsoft itself in the SharePoint Online offering.
Sandboxed Solutions
SharePoint 2010 has significant improvements for multi-stakeholder scenarios where it is necessary to provide a level of isolation between different sets of code both from a security perspective as well as from the perspective of maintaining performance.
Sandboxed Solutions are SharePoint Solution Package files (WSP files) that are limited in what they can do and in the server resources they can use. What they can do is limited using Process Isolation and Code Access Security limited to the SharePoint Site. The resources they can use are limited by process monitoring, logging and log aggregation. Any individual action is limited and the solution is also given a daily limit of resources. This provides for a complete isolation system that ensures code running in a sandboxed solution cannot reach out to access information beyond the scope of the deployment. Specifically, sandboxed solutions will not be able to make updates to the SharePoint object model beyond the scope of the SPSite object. Farm level and web application level changes are allowed only for read operations. Figure 31 shows how the process works from retrieving the code to returning the results to the user.
Figure 31 – SharePoint Sandboxed Solution Execution
Each Sandboxed Solution is stored in a solution gallery similar to the web part gallery. SharePoint tracks and displays the resource usage as an abstract concept called points. Administrators can set a maximum number of points that a site collection can use through quotas. When the utilization of the site collection exceeds its quota solutions are be temporarily disabled. This prevents a single site collection from consuming all of the resources on the server farm. Resource limits for Sandboxed Solutions are designed to avoid disruption of Document Library users on the same server.
Figure 32 shows a site collection with 300 resources allocated and a solution called BadWSP which has consumed 0.12 resources to date.
Figure 32 – Sandboxed Solution resource management
SharePoint Online
SharePoint Online is a shared hosting service and in the 2007 version it does not allow for custom code to be uploaded in the standard offering. Custom code is only allowed on dedicated farms and then only after an exhaustive review. Sandboxed Solutions in SharePoint 2010 will enable SharePoint Online to allow user provided code to be installed on the shared platform. This opens a new arena for developers who want to create solutions for their customers who want to use hosting instead of maintaining their own servers.
Upgrading Solutions
As developers revise solutions on the platform, SharePoint 2010 provides upgrade semantics in the WSP file to allow for seamless upgrade of developer provided solutions from one version to another.
The addition of upgrading semantics includes support for including <BindingRedirect> elements in the web.config file – to allow redirection from one assembly version to another, the inclusion of a version for features and syntax around upgrade actions that should be performed based on what version range the feature was before being
upgraded.
A new FeatureUpgrading event is raised when a feature is being upgraded from a previous version to a new version. This allows developers to capture and upgrade any items in the feature which cannot be upgraded via the declarative XML syntax.
In addition, new API methods exist to make it easier for developers and administrators to identify which features are activated across the farm and what version those features
are. This makes it easy for developers to see where their features are activated – and which locations the feature hasn’t been upgraded yet.
Learning More
http://msdn.microsoft.com/SharePoint : SharePoint MSDN Developer Center http://MSSharePointForums.com : SharePoint Forums
http://MSSharePointConference.com : The Microsoft SharePoint Conference http://MSSharePointDeveloper.com : Introductory Training For Developing on SharePoint
Conclusion
Whether the challenge that you are trying to solve is a simple one-off application with a few data tables or the front end for an enterprise solution that drives the organization, SharePoint 2010 and the Office 2010 clients provide the tools you need to manage your data, support your users, and connect the processes. As a developer using SharePoint you are not tied to tediously building interactive edit screens, buried in building
architecture, or stymied by building security. Building on the benefits of the SharePoint platform allows you to get more done.
SharePoint 2010 Developer Walkthroughs
The following code walkthroughs demonstrate some of the new functionality available to developers of SharePoint 2010. Screenshots are provided so that if you do not have a SharePoint 2010 installed machine you can still review the steps that would be taken and the outcome that you would see.
Walkthrough 1: Using LINQ to SharePoint from within a Visual web part
Exercise Duration: 10 minutesExercise Overview
This example demonstrates how to use the SharePoint LINQ provider to read data from a SharePoint list and render the data using the SPGrid web control. It shows these created in the Visual Web Part designer in Visual Studio 2010.
Task 1: Create a new Empty Project and add a Visual Web Part
1. Open Visual Studio 2010 from the Start | Programs | Visual Studio 2010 menu.
2. Create a new project by using File | New Project. 3. Pick the SharePoint | 2010 templates.
4. From the SharePoint | 2010 templates select the Visual Web Part project template.
5. Use SPLinqSolutionDemo as the name of the project. 6. Use C:\SPHOLs as the location.
8. When the SharePoint Customization Wizard dialog appears, select the site you want to deploy the Web Part to. Click the Finish button to complete the project creation process.
9. Within Solution Explorer expand VisualWebPart1 and open VisualWebPart1.webpart. a. Set the title element to: SPLinqDemoPart Title
Task 2: Generate LINQ to SharePoint proxy class to access list data.
1. Start a Visual Studio 2010 Command Prompt from the Start | All Programs | Visual Studio 2010 | Visual Studio Tools |Visual Studio Command Prompt (2010) menu
2. Change the directory to C:\SPHOLS\SPLinqSolutionDemo cd C:\SPHOLS\SPLinqSolutionDemo
3. spmetal.exe is a command line tool that can generate C# or VB.NET classes from a SharePoint site's list definitions. It is similar to wsdl.exe that generates a proxy from a Web Service's WSDL file.
4. Run the following command to generate the LINQ proxy code.
spmetal /web:http://<YourServerName> /namespace:Projects /code:Projects.cs
5. Go back to Visual Studio 2010.
6. Right-click on the SPLinqSolutionDemo project in the Solution Explorer and select
Add | Existing Item.
7. Browse to C:\SPHOLS\SPLinqSolutionDemo and select the Project.cs file that was generated when you ran spmetal.
8. Right-click on the SPLinqSolutionDemo in the Solution Explorer and select Add
9. Click on the Browse tab, navigate to the C:\Program Files\Common Files\Microsoft Shared\Web Server Extension\14\ISAPI folder, and select Microsoft.SharePoint.Linq.dll and select OK.
Task 3: Write the code for the Visual WebPart User to access the list data. 1. In Visual Studio 2010 open the SPLinqDemoPartUserControl.ascx file from the
Solution Folder by double-clicking on it.
2. Add the following markup to SPLinqDemoPartUserControl.ascx under the <%@ Control... declaration
<%@ Import Namespace="Microsoft.SharePoint.WebControls" %> <SharePoint:SPGridView id="spGridView" runat="server"
AutoGenerateColumns="false">
<SharePoint:SPBoundField DataField="Title"
HeaderText="Title"></SharePoint:SPBoundField> <SharePoint:SPBoundField DataField="JobTitle"
HeaderText="JobTitle"></SharePoint:SPBoundField> <SharePoint:SPBoundField DataField="ProjectTitle"
HeaderText="ProjectTitle"></SharePoint:SPBoundField> <SharePoint:SPBoundField DataField="DueDate"
HeaderText="DueDate"></SharePoint:SPBoundField> </Columns>
</SharePoint:SPGridView>
3. In the Solution Explorer, expand the carat icon next to the
SPLinqDemoPartUserControl.asx, and then double-click on the
SPLinqDemoPartUserControl.ascx.cs file to open it.
4. Add the following using statements to SPLinqDemoPartUserControl.ascx.cs file after the existing using statements.
using System.Linq;
using Projects;
using Microsoft.SharePoint;
5. Add the following code to the SPLinqDemoPartUserControl.ascx.cs file (replace the existing Page_Load method).
protected void Page_Load(object sender, EventArgs e) {
ProjectsDataContext dc = new
ProjectsDataContext(SPContext.Current.Web.Url); EntityList<EmployeesItem> Employees = dc.GetList<EmployeesItem>("Employees"); var empQuery = from emp in Employees
where emp.Project.DueDate < DateTime.Now.AddMonths(6)
select new { emp.Title, emp.JobTitle, ProjectTitle = emp.Project.Title, DueDate = emp.Project.DueDate.Value.ToShortDateString() }; spGridView.DataSource = empQuery; spGridView.DataBind(); }
Task 4: Deploy and Test the WebPart
1. Right click on your project and select Deploy. 2. Add the web part to a web part page:
Click the Edit button to put the page in edit mode. Click Insert
Click Web Part Click Custom
Click SPLinqDemoPart Title Click Add
Exercise Summary
In this walkthrough you built and deployed a Visual Web Part that uses LINQ to SharePoint to gather data from a SharePoint list.
Walkthrough 2: Building a Web Part for a Sandboxed Solution
Exercise Duration: 20 minutesExercise Overview
This exercise demonstrates creating a web part that renders and updates list data that is deployed as a Sandboxed Solution.
Feature Overview
A sandboxed solution can be deployed to a site by a site administrator, without requiring intervention from the farm administrator. The solution has full access to the immediate site and restricted access to system resources and other sites.
Task 1: Create Sandboxed Solution Project with a webpart.
1. Open Visual Studio 2010 from the Start | Programs | Visual Studio 2010 menu.
2. Create a new project by using File | New Project. 3. Pick the SharePoint | 2010 templates.
4. From the SharePoint | 2010 templates select the Empty Project project template.
5. Use SBSolutionDemo as the name. 6. Set the location to be C:\SPHOLs.
8. When the SharePoint Customization Wizard dialog appears, select the site you want to deploy the Web Part to.
9. Select the Deploy as a sandboxed solution radio button
11. Right-click on the SBSolutionDemo project in the Solution Explorer and choose Add |
New Item.
12. Select the Web Part (not the Visual Web Part) template from the SharePoint | 2010 templates in the Add New Item dialog. Name it SBWebPart.
13. Press OK to close the dialog and add the item to the project.
Task 2: Add code to provide querying and rendering functionality.
1. In the Solution Explorer, double-click on the SBWebPart.cs file to open it in the editor window.
2. Add the following using statement after the other using statements.
using System.Web.UI.HtmlControls;
3. Add the following variables to the class declaration. DropDownList _ddlProjects = new DropDownList(); TextBox _tbDescription = new TextBox();
TextBox _tbDueDate = new TextBox();
{
base.OnLoad(e);
if (!Page.IsPostBack) GetProjectDetails(); }
/* Populate the text boxes with the selected project details */
private void GetProjectDetails() {
EnsureChildControls();
if (_ddlProjects.SelectedValue != "-- Select a Project --") {
SPList pList = SPContext.Current.Web.Lists["Projects"];
int nProjectID = Convert.ToInt32(_ddlProjects.SelectedValue); SPListItem spliProject = pList.GetItemById(nProjectID);
_tbDescription.Text = spliProject["Description"].ToString(); DateTime dueDate = Convert.ToDateTime(spliProject["Due_x0020_Date"]); _tbDueDate.Text = dueDate.ToShortDateString(); } else { _tbDescription.Text = String.Empty; _tbDueDate.Text = String.Empty; } }
5. Add the following CreateChildControls implementation beneath the previous code (replace the existing CreateChildControls method).
/* Build the UI and setup events */
protected override void CreateChildControls() {
base.CreateChildControls(); Panel parent = new Panel();
parent.Style.Add("border", "solid 1px Navy"); parent.Style.Add("background-color", "#EEEEEE"); parent.Style.Add("width", "250px"); _ddlProjects.ID = "ddlProjects"; _ddlProjects.AutoPostBack = true; _ddlProjects.SelectedIndexChanged += new EventHandler(ddlProjects_SelectedIndexChanged); PopulateProjects(); parent.Controls.Add(_ddlProjects); Panel panel = new Panel();
Label label = new Label(); label.Text = "Description"; panel.Controls.Add(label);
parent.Controls.Add(panel); panel = new Panel();
panel.Controls.Add(_tbDescription); parent.Controls.Add(panel);
label = new Label(); label.Text = "Due Date"; panel = new Panel();
panel.Controls.Add(label); parent.Controls.Add(panel); panel = new Panel();
panel.Controls.Add(_tbDueDate); parent.Controls.Add(panel); panel = new Panel();
Button bUpdateProject = new Button(); bUpdateProject.Text = "Update Project";
bUpdateProject.Click += new EventHandler(bUpdateProject_Click); panel.Controls.Add(bUpdateProject);
parent.Controls.Add(panel); Controls.Add(parent);
}
6. Add the following code beneath the CreateChildControls method: /* Populate the projects drop down */
private void PopulateProjects() {
SPList splProjects = SPContext.Current.Web.Lists["Projects"]; _ddlProjects.Items.Add("-- Select a Project --");
foreach (SPListItem spli in splProjects.Items) {
_ddlProjects.Items.Add(new ListItem(spli.Title, spli.ID.ToString()));
} }
7. Add the following event handling code beneath the PopulateProjects method:
/* Change projects handler */
void ddlProjects_SelectedIndexChanged(object sender, EventArgs e) {
GetProjectDetails(); }
/* Update the current project */
int nProjectID = Convert.ToInt32(_ddlProjects.SelectedValue); SPListItem spliProject = SPContext.Current.Web.Lists["Projects"].GetItemById(nProjectID); spliProject["Description"] = _tbDescription.Text; spliProject["Due_x0020_Date"] = _tbDueDate.Text; spliProject.Update(); }
Task 3: Build and Deploy the Sandboxed Solution.
1. Right-click on your project in the Solution Explorer and select Deploy.
2. Browse to your server. Click Site Actions | Site Settings . Then click on Solutions
(under Galleries), you will see your sandboxed solution deployed and activated.
3. Add the webpart to a webpart page.
Click the Edit button to put the page in edit mode. Click Insert
Click Web Part Click Miscellaneous Click the SBWebPart Title Click Add
4. Now you will see the web part running in the Sandboxed Solution. Click the drop down to select a project. The description and due date fields are both updatable.
Exercise Summary
In this walkthrough you built and deployed a Web Part that runs in the context of a Sandboxed Solution.
Walkthrough 3: SharePoint Designer Workflows imported to Visual
Studio 2010
Exercise Duration : 20 minutes Exercise Overview
This exercise shows how to create a custom workflow activity used by a SharePoint Designer reusable workflow and deploy them together as a single *.WSP. It also shows how to import that whole workflow model into Visual Studio 2010.
Feature Overview
SharePoint Designer allows creating a workflow that is reusable across multiple lists and multiple sites. The workflow can be exported as a SharePoint Solution File (*.WSP). Task 1: Create and Prepare Project
1. Open Visual Studio 2010 from the Start | Programs | Visual Studio 2010 menu.
2. Create a new project by using File | New Project. 3. Pick the SharePoint | 2010 templates.
4. From the SharePoint | 2010 templates select the Empty Project template. 5. Use SPDWorkflowDemo as the name.
6. Set the location to be C:\SPHOLs.
8. When the SharePoint Customization Wizard dialog appears, select Deploy as a farm solution, and press Finish.
Task 2: Create a new Workflow Activity for use by the Reusable Workflow
1. Right-click on the SPDWorkflowDemo solution in the Solution Explorer and select
Add | New Project.
2. Under the Visual C# | Workflow project templates, select the Workflow Activity Library template.
3. Name the project SPDActivityDemo and press OK to add the project to the
4. Right-click on the SPActivityDemo project in the Solution Explorer and select Add Reference.
5. Under the .Browse tab, browse to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI and select both
Microsoft.SharePoint.dll and Microsoft.SharePoint.WorkflowActions.dll. 6. Press OK to add these two references to the SPDActivityDemo project.
7. Right-click on the Activity1.cs (under the SPActivityDemo project in the Solution Explorer) and select rename.
8. Rename the file CreateDocumentLibrary.cs.
9. Select Yes when the Microsoft Visual Studio dialog appears to allow Visual Studio to re-factor the code.
Task 3: Add code to create a document library based on parameters passed to our activity.
1. Right-click on the CreateDocumentLibrary.cs activity and select View Code. 2. Change the CreateDocumentLibrary base class from SeqeuenceActivity to :
Activity
public partial class CreateDocumentLibrary: Activity 3. Add the following using statements to the activity:
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
4. Add a new DependencyProperty to the CreateDocumentLibrary class named UrlProperty of type string. (Hint - type wdp inside of the class definition and then tab twice - this will create the DependencyProperty using the built-in Workflow Dependency Property snippet)
This will be the location where the document library will be created. public static DependencyProperty UrlProperty =
DependencyProperty.Register("Url", typeof(string),
typeof(CreateDocumentLibrary));
[DescriptionAttribute("Url of base site")] [CategoryAttribute("Input Property")] [BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibil ity.Visible)]
[ValidationOption(ValidationOption.Required)]
public string Url {
get
{
return
((string)(base.GetValue(CreateDocumentLibrary.UrlProperty))); }
set
{
base.SetValue(CreateDocumentLibrary.UrlProperty, value); }
}
5. Add a new DependencyProperty of type string to the activity named DocLibNameProperty.