Вы находитесь на странице: 1из 312

OFFICIAL

MICROSOFT

LEARNING

PRODUCT

10232A
Lab Instructions and Lab Answer Key: Designing and Developing Microsoft SharePoint Server 2010 Applications

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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. 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. The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein. 2010 Microsoft Corporation. All rights reserved. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. Product Number: 10232A Part Number: Released: 09/2010

Lab Instructions: ASP.NET Advanced Concepts for SharePoint

Module 1
Lab Instructions: ASP.NET Advanced Concepts for SharePoint
Contents:
Lab A: Page Size and ViewState Exercise 1: Using Fiddler to Observe Page Loading Exercise 2: Using Fiddler to Examine Page Size Exercise 3: Reducing Page Size Lab B: Memory and Performance Exercise 1: Starting a Performance Capture Exercise 2: Reviewing the Report Exercise 3: Resolving Memory Issues and Retest 6 8 9 3 4 5

Lab Instructions: ASP.N Advanced Conce for SharePoint NET epts

Lab A Page Size and ViewS A: State

Sc cenario
Se everal users in a remote offi are compla n ice aining about th overall perf he formance of th manufactur he ring system bu on ASP.NE 2.0. Youve been asked to identify why uilt ET o y th performanc may be slow for them and resolve the issues using th Fiddler he ce w d he to ool.

Lab Instructions: ASP.NET Advanced Concepts for SharePoint

Exercise 1: Using Fiddler to Observe Page Loading


The Fiddler tool is used for diagnosing and resolving issues on Web sites. Its a transparent proxy that intercepts and monitors transactions between the Web browser and the Web sites that it contacts. The main tasks for this exercise are as follows: 1. 2. Launch Fiddler. Start the ManufacturingDashboard project.

Task 1: Launch Fiddler


Launch Fiddler from the Start menu.

Task 2: Start the ManufacturingDashboard project


In Visual Studio, ensure that the ManufacturingDashboard is set as the default project. Press F5. In the Microsoft Internet Explorer, in the address bar, change the localhost portion to ipv4.fiddler and press ENTER. (Internet Explorer is hardcoded to bypass proxies, including transparent proxies such as Fiddler, on localhost.) Go back to the Fiddler window and examine the requests that it is capturing.

Lab Instructions: ASP.NET Advanced Concepts for SharePoint

Exercise 2: Using Fiddler to Examine Page Size


Fiddler can display a summary of the size of the individual requests, and can provide several ways for decoding the response so that it makes sense. The main task for this exercise is as follows: 1. Review the default.aspx request.

Task 1: Review the default.aspx request


Look for the default.aspx page. Look in the Requests window at the response from the server to evaluate where the size may be coming from.

Lab Instructions: ASP.NET Advanced Concepts for SharePoint

Exercise 3: Reducing Page Size


The page is pretty big even for a dashboard. Your job is to reduce the page size. Several controls have ViewState enabled. Disable ViewState where possible to improve performance. The main task for this exercise is as follows: 1. Disable ViewState.

Task 1: Disable ViewState


1. 2. 3. Open default.aspx. Turn off ViewState as much as is practical. Examine the revised page.

Results: After this exercise, you should have a default.aspx page that emits slightly more than half the number of bytes as before.

Lab Instructions: ASP.N Advanced Conce for SharePoint NET epts

Lab B Memo and Performance B: ory

Sc cenario
Remote users have indicated that performa h ance has impr roved due to th ViewState he hanges youve made. Howev the attenti has caused more focus o the e ver, ion d on ch ap pplication and youve been made aware th the applica d hat ation seems to get slower o as time goes on Youve been asked to iden s n. n ntify what is ha appening and improve the ap pplication.

Exercise 1: Starting a Performa ance Captu ure


Visual Studio offers a set of to to help yo analyze the performance of your V ools ou e e ap pplication and understand h d how memory is being used. You can access them from th Analyze me he enu. They prov vide even mor detail than t Reliability and re the Pe erformance Monitor that yo learned abo earlier in th module. M ou out his Th main tasks for this exerc are as follo he s cise ows: 1. . 2. . Start capture. Exercise th application. he

Lab Instructions: ASP.NET Advanced Concepts for SharePoint

Task 1: Start capture


Use the same project from Exercise 1. From the Analyze menu, launch the Performance Wizard, and select the .NET Memory Allocation (Sampling) option from the first dialog box. Walk through the remaining dialog boxes to start the capture.

Task 2: Exercise the application


In Internet Explorer, refresh the page a few times to demonstrate some load on the application.

Lab Instructions: ASP.NET Advanced Concepts for SharePoint

Exercise 2: Reviewing the Report


Once the application terminates, in this case by closing Internet Explorer, Visual Studio will begin to process the captured data. The report that is generated will help you see how memory is used in your application. The main task for this exercise is as follows: 1. Review the summary.

Task 1: Review the summary


Look for those objects using the most memory (in most applications, this is System.String). Look for the locations in code that are allocating the most memory.

Lab Instructions: ASP.NET Advanced Concepts for SharePoint

Exercise 3: Resolving Memory Issues and Retest


With the information provided by the Performance Wizard, you have some clues as to where problems exist. In this case, you can investigate the LinePerformance.Get() method to determine whether it is effectively allocating and using memory. The main tasks for this exercise are as follows: 1. 2. 3. Identify the memory issues. Resolve the memory issues by eliminating the poor pattern. Retest.

Task 1: Identify the memory issues


Investigate Contoso.Manufacturing.Data.LinePerformance.

Task 2: Resolve the memory issues by eliminating the poor pattern


Eliminate caching of information thats likely to change quickly (LinePerformance). Remove the single instance pattern thats implemented incorrectly.

Task 3: Retest
Verify different (better) results.

Results: After this exercise, you should have an application that doesnt consume as much memory during runtime.

Lab Instructions: Designing for User Experience

Module 2
Lab Instructions: Designing for User Experience
Contents:
Lab A: Selecting Page Parts Exercise 1: Line Dashboard Exercise 2: Managers Dashboard Exercise 3: Alert Notification Lab B: Selecting Page Types Exercise 1: Plant Summary Page Exercise 2: Plant Configuration Page Exercise 3: Employee List Exercise 4: Line Status 9 10 11 12 4 5 6

Lab Instructions: Desig gning for User Experience

Lab A Select A: ting Pag Parts ge s

Su upporting In nformation
In this lab, wer focused on the parts that go on to the p n re page. The obje ective is to un nderstand how to make the right decision around the controls and components w e ns e us to build th pages and c sed he complete the u experienc Youll be w user ce. working in te eams to talk ou the right de ut ecisions for eac of the following compon ch nents. As with the pag types, the decision tree sh ge hown in the ne slide is des ext signed to elp of hat d bout the he you focus on the types o questions th you should be asking ab sc cenario to dete ermine the cor rrect control ty ype. Again, the decision tree is designed e to illustrate of the types of qu o t uestions and d decisions. Due to over-simpl e lification, it may m be possible to have a con e ntrol that doesnt directly fit this decision tree. n

Lab Instructions: Designing for User Experience e p

Lab Instructions: Designing for User Experience

Exercise 1: Line Dashboard


Scenario
One of the features of the existing manufacturing application is a line status dashboard that an operator can glance at from six feet away and understand at a high level how the line is operating. The dashboard is receiving information in near real time from the machines controllers and from the monitoring equipment at the end of the line. The line operators alternate between taking direct inspections of the machine and glancing at the dashboard.

Results: After this exercise, you should have a group decision on the type of control to use and why this is the right type of page, including reasons why the other types of controls are not appropriate or are not the best choice.

Lab Instructions: Designing for User Experience

Exercise 2: Managers Dashboard


Scenario
Plant managers often look through current data and compare it to historical data to evaluate the performance of the teams working on the systems and to evaluate when a more aggressive preventative maintenance program for a line is warranted. The system needs to provide a way for managers to drill into data in the system that will help them better understand whats happening. While the managers expect some level of delay, due to back-end system accesses, when they click on the dashboard, they want to minimize these delays as much as possible.

Results: After this exercise, you should have a group decision on the type of control to use and why this is the right type of page, including reasons why the other types of controls are not appropriate or are not the best choice.

Lab Instructions: Designing for User Experience

Exercise 3: Alert Notification


Scenario
The plant has numerous notification systems in place designed to keep its employees safe. Some of those systems, like rotating beacon lights, are reserved for truly critical or life-threatening conditions. However, in some cases, informational messages are displayed to the operators of machines, such as impending power maintenance or notifications from utilities about potential outages. You need to deliver a control that will be displayed conspicuously throughout the system.

Results: After this exercise, you should have a group decision on the type of control to use and why this is the right type of page, including reasons why the other types of controls are not appropriate or are not the best choice.

Lab Instructions: De esigning for User Exp perience

Lab B Select B: ting Pag Type ge es

Su upporting In nformation
Because of the move from the manufacturi application several diffe m e ing n, erent pages eed ated in SharePo to suppor different asp oint rt pects of the ap pplications ne to be crea move. They also need to supp enhanced functionality based on the platform. In m o port d y e th lab, youll work together in teams to id his w r dentify the pot tential page ty ypes that will so the proble including the identificat olve em tion of the ben nefits and weaknesses of se everal differen potential pag types. Youll also try to d nt ge determine wha additional at in nformation you need to m ull make the best d decision for the page type. e Th following diagram is inte he d ended to aid y with makin these decis you ng sions. Understand tha this decision tree is not designed to be authoritative. The problem U at n is more comple than what a diagram like this can show The decision trees s ex w. n ob bjective is to il llustrate the ty ypes of questio that you s ons should ask, an then the nd an nswers to thos questions c lead you down one path or another. se can h

Lab Instructions: Designing for User Experience g

Lab Instructions: Designing for User Experience

Exercise 1: Plant Summary Page


Scenario
The plant manager and the HR department at the organization have determined that it would be good to provide some basic statistics and information about the various plants in the organization to help users feel more like a part of the organization. They expect that theres some standard information on each page including an exterior picture of the plant, an address, and perhaps some of the local hotels and restaurants for team members who may be traveling between plants.

Results: After this exercise, you should have arrived at a decision about the type of Plant Summary page to use. You should also understand why this is the right type of page, why other types of pages are not appropriate, and whether this is your best option.

10

Lab Instructions: Designing for User Experience

Exercise 2: Plant Configuration Page


Scenario
As a part of the migration to SharePoint from the custom application, there have been some SharePoint Web Parts developed. These Web Parts utilize information stored in the SPWeb property bag. There needs to be a page developed that will allow the configuration of the interface to the ERP system. This task wont be performed often but must be performed on every manufacturing site in the SharePoint system.

Results: After this exercise, you should have arrived at a decision about the type of Plant Configuration page to be used, as well as why this is the right type of page and why other types of pages may or may not be appropriate or the best option.

Lab Instructions: Designing for User Experience

11

Exercise 3: Employee List


Scenario
The HR department maintains a list of all of the employees at each plant in an external system. That system is accessible from SharePoint via Web services. The plant manager wants a list of employeesan employee directoryfor his plant based on the information in the external HR system. The HR managers for each location want to be able to place a message on the employee directory page that may be different at each plant. Because the organization has locations around the world, its necessary to address the differing legal concerns about the disclosure and use of employee information in each country. Management is concerned about the need for all of the employee directories needing to appear similar. They believe that any employee should be able to find any other employee in a consistent way.

Results: After this exercise, you should have arrived at a decision about the type of Employee List page to be used, as well as why this is the right type of page and why other types of pages may or may not be appropriate or the best option.

12

Lab Instructions: Designing for User Experience

Exercise 4: Line Status


Scenario
The operations team at each plant maintains a notebook for the unique quirks for each line in the plant. Some machines just seem to run better at one part rate than another does. The settings or readings for a line might be slightly different than normal, but well within specification. The notebook approach isnt working so well any longer because there are too many notes about each line, and because the notebook tends to wander off to a line where theyre having a problem and its not available to the crews on other lines to refer to. Because of this, the operations team has decided to put the content in SharePoint. Since the information is primarily of use to the individual operators of the line, and because each line is inherently different from the others, information consistency isnt the chief concern. Instead, the operations team is focused on providing the line operators with an easy way to access, update, and use the information for their line.

Results: After this exercise, you should have arrived at a decision about the type of Line Status page to be used, as well as why this is the right type of page and why other types of pages may or may not be appropriate or the best option.

Lab Instructions: Designing for Data

Module 3
Lab Instructions: Designing for Data
Contents:
Lab A: Time Tracking Exercise 1: Creating List Views Exercise 2: Adding Indexes Lab B: Invoice Management Exercise 1: Creating an Invoice Content Type Exercise 2: Enabling Content Organization Exercise 3: Testing Content Organization 7 8 9 2 4

Lab Instructions: Desig gning for Data

Lab A Time Trackin A: ng

Exercise 1: Creating L Views List


Sc cenario
Contoso wants to use ShareP C Point to do tim recording fo each of its w me or workers. With h ov 2,000 wor ver rkers in 20 pla ants and a plan to keep the d in ShareP n data Point for two months, manag at Contos know that th system nee to be prop m gers so he eds perly de eveloped to maintain perfor m rmance. Youv been asked to design a se of views to ve et make sure that performance is acceptable. m Th time-tracking site has been created and includes a ti he d ime-tracking li that ist co ontains time-tr racking inform mation. Th main tasks for this exerc are as follo he s cise ows: 1. . 2. . 3. . Create a vie for accoun ew nting to aggreg time. gate Create a vie for aggrega ew ating time by e employee. Create a vie for aggrega ew ating time by p plant and by e employee.

Lab Instructions: Designing for Data

Task 1: Create a view for accounting to aggregate time


Create a calculated field that can be used to aggregate by month. Create a view that groups time by month and by plant.

Task 2: Create a view for aggregating time by employee


Create a view that groups by employee and by month.

Task 3: Create a view for aggregating time by plant and by employee


Create a view grouped by plant and by employee.

Results: After this exercise, you should have three views on your Time Tracking table to make it easier to process the information.

Lab Instructions: Designing for Data

Exercise 2: Adding Indexes


Scenario
The work youve done on lists has improved performance on the time tracking list, but the administrator still believes there is more that can be done to improve performance of the list. Youve been asked to look into adding indexes to the list to improve performance. The main tasks for this exercise are as follows: 1. 2. 3. Add an index by employee and by start date. Add an index by plant and by employee. Add an index by start date.

Task 1: Add an index by employee and by start date


Create an index with employee as primary column and start date as secondary column.

Task 2: Add an index by plant and by employee


Create an index with plant as primary column and employee as secondary column.

Task 3: Add an index by start date


Create an index with start date as primary column. Question: How do calculated columns play a part in how you group information? Question: Why should or shouldnt you use filtered views in this scenario?

Results: After this exercise, you should have improved list performance by providing indexes for the views to use in rendering the data.

Lab Inst tructions: Designing f Data for

Lab B Invoic Mana B: ce agemen nt

Sc cenario
Contoso is plan C nning to use SharePoint to s store invoices from vendors. Right now, ev veryone in acc counting can s all of the in see nvoices from e every vendor, b some but ve endor invoices may contain confidential i s n information th needs to be restricted in hat e th future. he Because accoun payable oft uses temporary staff, the department doesnt want nts ten e ontributors to have to know where to file documents. w co

Key K Consider rations


1. . 2. . 3. . Contributo can be requ ors uired to know where to file documents. w The system must ensure that the appropriate metad about the invoice is m data provided. The solutio should be t on transportable t other divisi to ions that face s similar problems with invoice pr w rocessing.

Lab Instructions: Designing for Data

4. 5.

The members of accounting need to be able to open the invoices from the Office client applications. The content must be searchable by vendor or by invoice number.

Starting Point
You already have a content type and list for vendors created that you can use. A sample set of vendor data has been populated. An Invoices document library has been created for your use.

Lab Instructions: Designing for Data

Exercise 1: Creating an Invoice Content Type


The main tasks for this exercise are as follows: 1. 2. Create the site columns for the invoice content type. Create the invoice content type.

Task 1: Create the site columns for the invoice content type
Invoices have fields, such as Invoice Number, Purchase Order Number, Vendor ID, Invoice Date, Total Amount, and Sales Tax.

Task 2: Create the invoice content type


Create an invoice content type based on the appropriate base and with the appropriate additional fields. Set the Invoice Number and Vendor fields to required.

Lab Instructions: Designing for Data

Exercise 2: Enabling Content Organization


The main tasks for the exercise are as follows: 1. 2. 3. Activate content organization. Add the invoice content type to libraries. Create a content organizer rule to move invoices.

Task 1: Activate content organization


Activate the Content Organization Site Feature.

Task 2: Add the invoice content type to the libraries


Add the Invoice content type to Invoices Library. Add the Invoice content type to the Drop Off Library.

Task 3: Create a content organizer rule to move invoices


Create a content organizer rule to move instances of the Invoice content type to the Invoices document library with a folder name that matches the vendor name.

Lab Instructions: Designing for Data

Exercise 3: Testing Content Organization


The main task for the exercise is as follows: Test the content organization.

Task 1: Test content organization


Upload invoice to the Drop Off Library. Provide the required metadata. Review the routing in the invoices document library.

Question: How do you determine what site columns to create for your content types? Question: How do you determine what the key criteria is for establishing the folder structure?

Results: After this exercise, you should have a functioning invoice management system that automatically moves invoices to the correct directory.

Lab Instructions: Designing for Data Capture and Integration

Module 4
Lab Instructions: Designing for Data Capture and Integration
Contents:
Lab A: Creating External Lists Exercise 1: Connecting to the Data Source Exercise 2: Defining the External Content Types Exercise 3: Defining the External Lists Exercise 4: Setting Security for the Content Types Exercise 5: Defining an Association Lab B: Creating an InfoPath Form Exercise 1: Creating the Calculations Exercise 2: Publishing the Form to a SharePoint Library 9 10 3 4 5 6 7

Lab Instructions: Desig gning for Data Capture and Integration

Lab A Creati Exte A: ing ernal Lists

Sc cenario
Contosos enter C rprise resourc planning (ERP) system is a simple syste that uses a ce em si ingle Microsof SQL Server database. Th purchasing manager want to be able ft he ts to review in Sha o arePoint the p purchase order from the ER system. You been rs RP uve as sked to connect SharePoint to the ERP sy ystem.

Lab Instructions: Designing for Data Capture and Integration

Exercise 1: Connecting to the Data Source


The main tasks for this exercise are as follows: 1. 2. 3. Open SharePoint Designer. Create a starting content type. Define the data connection.

Task 1: Open SharePoint Designer


Open the Web site in Windows Internet Explorer. Open SharePoint Designer from the Site Actions menu.

Task 2: Create a starting content type


Go to External Content Types. Create a new content type. Provide a temporary name for the content type.

Task 3: Define the data connection


Use the local machine SQL\SHAREPOINT instance. Connect to the ContosoERP database.

Results: After this exercise, you should have a connection in SharePoint Designer to the Contoso ERP database.

Lab Instructions: Designing for Data Capture and Integration

Exercise 2: Defining the External Content Types


The main tasks for this exercise are as follows: 1. 2. 3. 4. Create the GL Account content type. Create the Vendor content type. Create the Purchase Request Header content type. Create the Purchase Request Line content type.

Task 1: Create the GL Account content type


Define the content type. Define the operations.

Task 2: Create the Vendor content type


Define the content type. Define the operations.

Task 3: Create the Purchase Request Header content type


Define the content type. Define the operations.

Task 4: Create the Purchase Request Line content type


Define the content type. Define the operations.

Results: After this exercise, you should have four external content types for the four main entities exposed in the Contoso ERP database.

Lab Instructions: Designing for Data Capture and Integration

Exercise 3: Defining the External Lists


The main tasks for this exercise are as follows: 1. 2. 3. 4. Create the GL Accounts external list. Create the Vendors external list. Create the Purchase Request Header external list. Create the Purchase Request Line external list.

Task 1: Create the GL Accounts external list


Base the list on the GL Account content type.

Task 2: Create the Vendors external list


Base the list on the Vendor content type.

Task 3: Create the Purchase Request Header external list


Base the list on the Purchase Request Header content type.

Task 4: Create the Purchase Request Line external list


Base the list on the Purchase Request Line content type.

Results: After this exercise, you should have four external lists, one for each of the external content types.

Lab Instructions: Designing for Data Capture and Integration

Exercise 4: Setting Security for the Content Types


The main tasks for this exercise are as follows: 1. 2. Go to the Business Data Connectivity Service in Central Administration. Define security for all content types.

Task 1: Go to the Business Data Connectivity Service in Central Administration


Open Central Administration. Go to Manage Services. Go to Business Data Connectivity Service.

Task 2: Define security for all content types


Set Metadata Store Permissions.

Results: After this exercise, you should be able to access the external lists that youve created to read or add data.

Lab Instructions: Designing for Data Capture and Integration

Exercise 5: Defining an Association


The main tasks for this exercise are as follows: 1. 2. Open the Purchase Request Line content type. Create the association.

Task 1: Open the Purchase Request Line content type


Open Internet Explorer. Start SharePoint Designer from the Site Actions menu. Open the Design Operations View of the Purchase Request Line content type.

Task 2: Create the association


Right-click the PurchaseRequestHeader table in the ContosoERP data source, and select Create Association. Complete the association setup.

Results: After this exercise, you should have created an association you can use to navigate from a purchase request line to the purchase request header record.

Lab Instructions: Desig gning for Data Capture and Integration

Lab B Creati an InfoPath Form B: ing h

Sc cenario
Th purchasing manager is p he g preparing to tr ransition the approval proce for ess pu urchased requ uests from pap to a ShareP per Point workflow process. You have been w u as sked to design a form that c be used lat when you w n can ter want to autom the mate pr rocess with a workflow. You have decided to create an InfoPath form so that you w u d m ca use a one-to an o-many relatio onship, which isnt supporte on list form ed ms. Fo this exercis you use the PurchaseReq or se, e questForm-Starter.xsn file lo ocated in the E:\Student\Mo odule4 directo ory.

Lab Instructions: Designing for Data Capture and Integration

Exercise 1: Creating the Calculations


The main tasks for this exercise are as follows: 1. 2. 3. Convert Vendor to a drop-down list. Convert GL Account to a drop-down list. Establish formulas.

Task 1: Convert Vendor to a drop-down list


In the header of the document, convert the vendor into a drop-down list. Connect the drop-down list to the vendor list of the site.

Task 2: Convert GL Account to a drop-down list


In the line area of the form, convert the GL Account field to a drop-down list. Connect the drop-down list to the GL Accounts table.

Task 3: Establish formulas


Establish a formula for extended amount in the line area of the form for quantity multiplied by amount. Establish a formula for the total amount field, which sums the extended amount from each line.

Results: After this exercise, you should have an InfoPath form that represents a complete purchase request.

10

Lab Instructions: Designing for Data Capture and Integration

Exercise 2: Publishing the Form to a SharePoint Library


The main tasks for this exercise are as follows: 1. 2. Decide whether to publish the form as a content type or as a form. Publish the form.

Task 1: Decide whether to publish the form as a content type or as a form


Evaluate the benefits and limitations of publishing the form as a content type. Evaluate the benefits and limitations of publishing the form as a form library.

Task 2: Publish the form


Use the InfoPath File tab and the Publish option to publish the form to the SharePoint Server.

Results: After this exercise, you should have a published InfoPath form that you can use to capture purchase request information.

Lab Instructions: Designing Artifacts

Module 5
Lab Instructions: Designing Artifacts
Contents:
Lab A: Incident Response Site Exercise 1: Evaluating the Requirements Exercise 2: Designing the Solution Lab B: Expense Reports Exercise 1: Evaluating the Requirements Exercise 2: Designing the Solution 8 12 3 6

Lab Instructions: Desig gning Artifacts

Lab A Incide Resp A: ent ponse S Site

Sc cenario
Contoso is crea C ating an incide manageme system for floor incident This ent ent ts. sy ystem will reco the set of p ord procedures th should be e hat enacted when an incident oc ccurs. An incid dent can be so omething as si imple as a con ntainer of mate erials be eing knocked over to a critical leak in a key system. You job is to convert the ur re equirements in the approp nto priate set of co omponents in SharePoint to solve the o pr roblem.

Lab Instructions: Designing Artifacts

Exercise 1: Evaluating the Requirements


Scenario
After a recent government audit, it was discovered that the paper manuals that supervisors and foremen were using as reference procedures for handling floor incidents were not always up to date. The Contoso safety department has presented you with the following requirements: Contoso has 90 days to revise the incident management system. They must demonstrate compliance with current records being available to all floor manufacturing staff at all times.

Incidents are defined as unexpected situations that require a response. Incidents include any situation where a worker is injured, product has been damaged or destroyed, or situations where systems break down. In all, Contoso has over 2,000 defined incident responses across the 20 plants that Contoso operates. An average plant will have about 50 custom response plans and approximately 75 that are standard responses for the company. Every incident occurrence requires the creation of an incident response form. This incident response must be routed to the plant manager and to the vice president of safety. Most incident occurrences are minor and the information in the response form is the same. Some incidents are special because they have caused harm to an employee or because they have represented a significant loss of product. These forms are different from the standard form and are routed to the president of Contoso Manufacturing for review. Due to regulations, its necessary to have a backup copy of the Web site with the response plans in paper form on the shop floor at all times. Managers are instructed to print a copy of the incident response plan from the Web site, if possible. If a response form cannot be printed through the Web site, then a copy must be made of the hardcopy file. The hardcopy file will be managed by the safety officer for the plant. Managers will be required to update the files on the floor when a change is recorded and to reprint all response plans every 6 months. The system must notify the safety officer that content has changed. Since many of the procedures in an incident response are the same, the safety department wants to be able to select from a set of procedures and have those procedures included as the incident response plan on the page.

Lab Instructions: Designing Artifacts

Task 1: Identify the key requirements


What are the key functionalities that are specified in the requirements?

Task 2: Evaluate requirements against the objective, precise, measurable, and understandable criteria
Which of the requirements are good requirements? Which requirements would you need to clarify?

A template is provided for your reference. Use the following legend to evaluate the requirement against these parameters: + = Yes 0 = Needs Information - = No
Understandable

Requirement

Measurable

Objective

Precise

Suggestions

Lab Instructions: Designing Artifacts

Task 3: Evaluate requirements against responsiveness, skills, scale, and rate of change
Do you have the information that you need in order to create the solution, or are their gaps that need to be addressed first?

A template is provided for your reference. Use the following legend to evaluate the requirement against these parameters: + = Yes 0 = Needs Information - = No

Responsiveness

Requirement

Rate of Change

Scale

Skills

Suggestions

Results: After this exercise, you should have an understanding of the quality of the requirements across two different evaluation criteria.

Lab Instructions: Designing Artifacts

Exercise 2: Designing the Solution


Task 1: Create a high-level plan for delivering the solution
Create a list of the types of artifacts that you need to create. Deliver a high-level block diagram of how the solution fits together.

Task 2: Create a set of clarifying questions that you would ask to further refine and validate your proposed solution
What requirements do you need clarified? What design approaches do you want to verify with the customer?

Results: After this exercise, you should have greater clarity for the types of questions that you would need to ask to better understand the requirements and a prototypical design to evaluate with the customer.

Lab Inst tructions: Designing A Artifacts

Lab B Expen Repo B: nse orts

Sc cenario
Contoso, like many other org C m ganizations, is feeling the pinch of compe etitive pr ressures and is improving it cost control measures. As a part of this effort, theyre i ts l s e lo ooking to both standardize t way that expense report are handled and to get h the ts d be etter reporting on the kinds of expenses t g s that the organ nization is incu urring. As a re esult, youve been asked to t transform a se of requireme et ents into an in nexpensive so olution in SharePoint to help manage exp p pense reports.

Lab Instructions: Designing Artifacts

Exercise 1: Evaluating the Requirements


Scenario
The accounting department has provided the following requirements for the expense report system: There are four basic types of expense reports that need to be tracked: vendor, customer, training, and miscellaneous. The vendor expense report must be used when the expenses are related to visiting with a customer to perform quality audits or other activities related to maintaining an appropriate relationship with a vendor. Customer expense reports are related to customer expenses including customer visits and any appropriate expenses for a customer. The training category of expense reports is used to record training related expenses. This would include books in accordance with the companys education reimbursement plan as well as expenses while traveling to company required or approved training events. The final, miscellaneous category is used for expenses, which are not related to any of the above categories.

The accounting department acknowledges that its quite likely that there will be more variations of the expense report in the future as they understand expenses better. All of the expense reports are required to run through a similar approval process. The approval routing is slightly different for the vendor and customer expense reports being routed to the production manager and sales manager for approval, respectively. The training and miscellaneous expense reports get routed to the employees manager. Approval for payment is dependent upon the managers approval authorization and the amount of the expense reported to the manager. Obviously, the expense reports need to capture the details for the expenses in the appropriate categories. However, the key concerns for the system will be capturing the total dollars of expenses and the vendor, customer, or training, for which the expenses were incurred.

Lab Instructions: Designing Artifacts

Therefore, the following criteria must be satisfied before an expense report can be approved and submitted for payment: The vendor expense form must record the vendor that was visited as well as the dates of the visit. The customer expense form must record the customer that was visited as well as the dates of the visit. The training expense report must record the training event for which the expenses were incurred. The miscellaneous report must include a description about the general purpose of the expenses as well as a date range for which the expenses were incurred. All of the reports need a report date and the employees name and information for which the expenses apply. The system must be able to report the number of expense reports by category, and the total amount by category. In addition, it must report the total amount spent per vendor and per customer. It should also show the expense reports by employee.

Task 1: Identify the key requirements


What are the key functionalities that are specified in the requirements?

10

Lab Instructions: Designing Artifacts

Task 2: Evaluate requirements against the objective, precise, measurable, and understandable criteria
Which of the requirements are good requirements? Which requirements would you need to clarify?

A template is provided for your reference. Use the following legend to evaluate the requirement against these parameters: + = Yes 0 = Needs Information - = No
Understandable

Requirement

Measurable

Objective

Precise

Suggestions

Lab Instructions: Designing Artifacts

11

Task 3: Evaluate requirements against responsiveness, skills, scale, and rate of change
Do you have the information that you need in order to create the solution, or are their gaps that need to be addressed first?

Responsiveness

Requirement

Rate of Change

Scale

Skills

Suggestions

Results: After this exercise, you should have a better understanding of the gaps in the requirements as they were provided and what questions you need answered to understand the situation.

12

Lab Instructions: Designing Artifacts

Exercise 2: Designing the Solution


Task 1: Create a high-level plan for delivering the solution
Identify the shared data that must be captured for each type of expense report and indicate which fields can be reused. Create a list and hierarchy of content types that need to be created.

Task 2: Create a set of clarifying questions that you would ask to further refine and validate your proposed solution
What questions do you need answered in order to understand the situation enough to be comfortable with your proposed solution? What parts of the proposed solution do you want the customer to verify?

Results: After this exercise, you should have a proposed solution that you could discuss with the customer to better understand the situation and how the solution may or may not fit.

Lab Instructions: Designing Processing Solutions

Module 6
Lab Instructions: Designing Processing Solutions
Contents:
Lab A: Designing an Engineering System Exercise 1: Evaluating Client Capabilities and Requirements Exercise 2: Evaluating Sandbox Capabilities and Requirements Exercise 3: Evaluating Farm Deployment Capabilities and Requirements Lab B: Creating a Sensor Report Exercise 1: Designing Data Access for Sensor Data Exercise 2: Designing a Processing Solution for the Report Exercise 3: Designing a Processing Solution for the Approval 9 10 11 4 6 7

Lab Instructions: Desig gning Processing Solu utions

Lab A Designing an Engine A: n eering S System

Sc cenario
Contosos engin C neering depar rtment needs t do specialty analysis on d they to y data ar storing in SharePoint. This requires cal re lculations that are not possi t ible with ou of the box calculated field You need t enable mem ut c ds. to mbers of the en ngineering de epartment to write their ow code. Howe w wn ever, you also m must be conce erned about de evelopers writ ting code that affects the entire farm. Develop an option (or options) n ) fo the engineer or ring departme to accomplish their goal ent l. Th engineering department captures data points off of v he a various system and ms ha developed a set of predic as ctive algorithm to determin when its tim for ms ne me pr reventative ma aintenance to a machine. Th production department r he n relies on this da to know when a machin will be unav ata w ne vailable because of maintena ance and to ev valuate the risk of running t machine w k the without the ma aintenance. Th precise algorithm and th he hreshold data t that perform t calculation change the ns fr requently, so th engineering department needs to retai control of th he in he de evelopment an deploymen of updates t the system. nd nt to

Lab Instructions: Designing Processing Solutions

A typical algorithm reviews more than 1,000 data points but less than 5,000 and performs some statistical analysis on the data when compared to output and a number of other metrics. The output of the evaluation is added to an analysis results table. The engineering department includes C++ developers with experience in writing very low level interfaces between programmable logic controllers and data capture systems.

Lab Instructions: Designing Processing Solutions

Exercise 1: Evaluating Client Capabilities and Requirements


The main tasks for this exercise are as follows: 1. 2. 3. Evaluate the AJAX/JavaScript client. Evaluate the Silverlight client. Evaluate other types of external clients.

Task 1: Evaluate the AJAX/JavaScript client


What are the benefits of a JavaScript client? What would this allow you to do easily? What would you be concerned about?

What would be the drawbacks or requirements of a JavaScript client? What limits would it place on the design of the solution? Which activities would be difficult to accomplish?

Task 2: Evaluate the Silverlight client


What are the benefits of a Silverlight client? What would this allow you to do easily? What would you be concerned about?

What would be the drawbacks or requirements of a Silverlight client? What limits would it place on the design of the solution? Which activities would be difficult to accomplish?

Lab Instructions: Designing Processing Solutions

Task 3: Evaluate other types of external clients


What are the benefits of another type of external client? What would this allow you to do easily? What would you be concerned about?

What would be the drawbacks or requirements of another type of external client? What limits would it place on the design of the solution? Which activities would be difficult to accomplish?

Results: After this exercise, you should have a clear understanding of what a clientbased solution can do.

Lab Instructions: Designing Processing Solutions

Exercise 2: Evaluating Sandbox Capabilities and Requirements


The main tasks for this exercise are as follows: 1. 2. 3. Evaluate sandbox capabilities and limitations. Evaluate development skills. Evaluate which requirements might get in the way.

Task 1: Evaluate sandbox capabilities and limitations


Can a sandbox solution process the amount of data required? Can the solution be deployed safely?

Task 2: Evaluate development skills


How easily will C++ development skills translate to C#? Which SharePoint-specific development skills will be needed?

Task 3: Evaluate which requirements might get in the way


How long does processing a data set take?

Results: After this exercise, you should have a clear understanding of what a sandbox solution can and cannot do.

Lab Instructions: Designing Processing Solutions

Exercise 3: Evaluating Farm Deployment Capabilities and Requirements


The main tasks for this exercise are as follows: 1. 2. Evaluate farm deployment capabilities. Evaluate farm deployment limitations and requirements.

Task 1: Evaluate farm deployment capabilities


Will the farm deployment allow the development options needed?

Task 2: Evaluate farm deployment limitations and requirements


What risks does deploying the engineering department code to the farm incur?

Results: After this exercise, you should have a clear understanding of what a farmdeployed solution can and cannot do.

Lab Instructions: Desig gning Processing Solu utions

Lab B Creati a Se B: ing ensor Re eport

Sc cenario
Each month, Co ontoso must p prepare a repo for the gove ort ernmental env vironment versight agenc of each co cies ountry based o sensor data captured dur on a ring the ov month. You nee to build a s m ed system to create this report. Th sensor data that is captured is collecte in a set of te files that ar stored on a he a ed ext re re emote file serv The forma of the data is comma-sepa ver. at s arated values fi files. The file na ames include the computer name as well as a date/time stamp to ma each e ake na ame unique. Th report is a document tha contains tab of summa he at bles aries from all th sensors he in ncluding aggre egations, avera ages, and standard deviation It must also include ns. so ome boilerplat text and som comments from the heal and safety officer about te me s lth th data in the report. he r Because Contos operates in 30 countries, 30 people ne to be able to generate so n , eed his th report.

Lab Instructions: Designing Processing Solutions

Exercise 1: Designing Data Access for Sensor Data


The main tasks for this exercise are as follows: 1. 2. Evaluate the use of BCS. Evaluate a data import application.

Task 1: Evaluate the use of BCS


How would you access the sensor data?

Task 2: Evaluate a data import application


Would a data import application for the sensor data make the overall solution easier to build without making it more complex to maintain? What level of time synchronization is required between the reporting and the raw data?

Results: After this exercise, you should have decided on an approach for accessing the sensor data.

10

Lab Instructions: Designing Processing Solutions

Exercise 2: Designing a Processing Solution for the Report


The main tasks for this exercise are as follows: 1. 2. 3. Evaluate list views. Evaluate Access. Evaluate custom-coded solution options.

Task 1: Evaluate list views


Will a list view or a list view exported to a worksheet be enough to complete the report? Can you use list views to start the development of the report?

Task 2: Evaluate Access


Can you use Microsoft Office Access to create the report? Can you use Access to start the report?

Task 3: Evaluate custom-coded solution options


What kinds of processing solutions might be appropriate for the report generation? Which techniques might you be able to use for the creation of the report?

Results: After this exercise, you should have a plan for processing the report.

Lab Instructions: Designing Processing Solutions

11

Exercise 3: Designing a Processing Solution for the Approval


The main tasks for this exercise are as follows: 1. 2. Evaluate SharePoint Designer workflows. Evaluate Visual Studio workflows.

Task 1: Evaluate SharePoint Designer workflows


Can you use SharePoint Designer to design support of an approval workflow for the sensor report?

Task 2: Evaluate Visual Studio workflows


Which additional options might Visual Studio give you to create a solution for report approval?

Results: After this exercise, you should have a design for approving the workflow when its finished.

Lab Instructions: Designing Packaging

Module 7
Lab Instructions: Designing Packaging
Contents:
Lab A: Building a Business Document Solution Exercise 1: Designing a Solution Exercise 2: Creating the Final Solution Lab B: Working with Dependencies Exercise 1: Creating a Common Assembly Exercise 2: Creating a Dependent Solution 9 10 3 6

Lab Instructions: Desig gning Packaging

Lab A Buildi a Bu A: ing usiness Docum ment Sol lution

Sc cenario
Yo are a devel ou loper at Conto Ltd., whic is a large organization wit a global oso, ch th cu ustomer base. Contoso provid a certification package w each prod C des with duct. The pack kage includes se everal differen documents t nt that together m make up the c certification pa ackage. When a new line is cre eated, a certifi ication packag library needs to be set up and the ges p ppropriate con ntent types for that library n r need to be defi ined. Develop a strategy to p ap pr rovision this li ibrary with the appropriate content types s.

Note: The intent of this lab is to provide you with an opport N t tunity to design the n pa ackaging for th custom application. You rec he ceive a fairly ge eneric use case scenario, an this lab quic highlights a few different design options that may resu in nd ckly s ult di ifferent packag ging designs.

Lab Instructions: Designing Packaging

Exercise 1: Designing a Solution


This exercise reviews the use case as it is provided. You need to understand how to best meet the requirements. The main tasks for this exercise are as follows: 1. 2. Get more details. Review answers, and finalize the design.

Task 1: Get more details


The following questions can help you determine how to frame the final solution: What is the platformMicrosoft SharePoint Foundation or Microsoft SharePoint Server (MSS)? Can there be more than one certification package library (CPL) per site? Is there a naming convention for the list? Have the content types been defined elsewhere? Do any of the content type fields require additional setup work? Can there be more than one certification package type per list? How often will the certification package lists need to be created? What is the intended livelihood of the data after it is created?

Results: The use case scenario as provided is very open ended. After this exercise, you should have a better idea of the requirements as they relate to the various products and the functionality that the two platforms offer and the expected use and livelihood.

Lab Instructions: Designing Packaging

Assume that you arrive at the following answers: SharePoint Foundation is the platform. Multiple CPL lists can exist in a single site. There are no naming conventions. No content types exist elsewhere. These content types will not be used elsewhere and are intended for use only by this application. There are no lookup fields. There can be only one content type per list. Lists are created on fairly infrequent basis. The administrative team expects artifacts to allow creation of a backup/archive site without installation of any assemblies.

Task 2: Review answers, and finalize the design


The answers from Task 1 paint a clear picture of how your design can come together. Because SharePoint Foundation is the intended deployment target, you need to use standard feature sets. Because there are multiple CPLs, you can create a list template. There is no requirement to create custom code for enforcement of names, provisioning of lists, setting field properties, and so forth. Custom content types can be created. Based on the refined requirements, the packaging design will look like the following: One solution package containing two features: Feature: CPL_ContentTypes Feature: CPL_ListDefinition

Lab Instructions: Designing Packaging

The CPL_ContentTypes Feature has the following characteristics: Hidden (because it is not intended for use by anyone else) Contain one content type that inherits from the Document content type

Additionally, note that the final design could operate as a sandboxed solution.

Lab Instructions: Designing Packaging

Exercise 2: Creating the Final Solution


The main tasks for this exercise are as follows: 1. 2. 3. 4. 5. 6. 7. Create a Visual Studio 2010 project. Add a content type to the project. Create a site-scoped feature for the content type. Add a list definition. Create a Web-scoped feature for the list definition. Ensure that the CPL_ContentTypes feature contains only one element. Deploy and verify.

Task 1: Create a Visual Studio 2010 project


Create an empty SharePoint project that will be deployed to the sandbox and that is named Contoso.CertificationPackageList. Be sure to clear the Create directory for solution check box.

Task 2: Add a content type to the project


Create a new content type named Certification Package Documents that is based on the Document content type.

Task 3: Create a site-scoped feature for the content type


Create a site-scoped feature named Certification Package Content Types. Add the Certification Package Documents content type to the new feature.

Task 4: Add a list definition


Add a new list definition that is based on the Certification Package Document content type.

Lab Instructions: Designing Packaging

Task 5: Create a Web-scoped feature for the list definition


Create a Web-scoped feature named Contoso Certification Package List. Select the list definition for inclusion in the feature.

Task 6: Ensure that the CPL_ContentTypes feature contains only one element
Visual Studio 2010 may add the certification package list definition to the CPL_ContentTypes feature when the definition is created. Ensure that the element is not included in the feature.

Note: It is now safe to remove the Feature1 feature.

Task 7: Deploy and verify


In Solution Explorer, right-click the project and click Deploy. In Manage Site Features: Verify that the CPL Content Types feature is not listed (because you marked it as hidden). Verify that the Contoso Certification Package List is listed and Activated. Locate the Contoso Certification Package List and create a list named Packages.

After the list is created, in Advanced Settings, enable management of content types. On the List Settings page: Verify that the Contoso.CertificationPackageList - Certification Package Documents content type is associated with the list.

Lab Instructions: Desig gning Packaging

Lab B Worki with Dependencie B: ing h es

Sc cenario
Yo are a devel ou loper at Conto Manufactu oso uring. Contoso development team has os de ecided to plac common bu ce usiness logic in a common a n assembly. This will allow s sm maller units of functionality to reference a common cod base. You n f y de need to create a Web Part that uses the com t mmon assembl ly.

Lab Instructions: Designing Packaging

Exercise 1: Creating a Common Assembly


The main task for this exercise is as follows: 1. Create a new Visual Studio project.

Task 1: Create a new Visual Studio project


Create a new empty SharePoint project named Contoso.DemoApplication.Common. Select Farm solution. Add a class named Utility.cs. Replace the content with the following code:
usingSystem;
[assembly:System.Security.AllowPartiallyTrustedCallers] namespace Contoso.DemoApplication.Common { public class Utility { private Utility() { } // End of constructor public static string GetDataFromSomewhere() { return "The current time is " + DateTime.Now.ToUniversalTime().ToString("yyyy/MM/dd - HH:mm:ss 'GMT'", System.Globalization.CultureInfo.InvariantCulture); } // End of GetDataFromSomewhere } // End of Utility class } // End of the Contoso.DemoApplication.Common namespace

10

Lab Instructions: Designing Packaging

Exercise 2: Creating a Dependent Solution


The main tasks for this exercise are as follows: 1. 2. 3. 4. Add a sandboxed project. Verify functionality. Remove the farm solution. Remove the sandboxed solution and reinstall.

Task 1: Add a sandboxed project


Add a new empty SharePoint project named Contoso.DemoApplication.Sandboxed. Select Sandbox solution. Add a Web Part, and name it CustomDataDisplay.cs. Replace the content with the following code:
usingSystem.Web; usingSystem.Web.UI; usingSystem.Web.UI.WebControls.WebParts; namespaceContoso.DemoApplication.Sandboxed.CustomDataDisplay { publicclassCustomDataDisplay:WebPart{ protectedoverridevoidCreateChildControls(){ this.Controls.Add(new LiteralControl(HttpUtility.HtmlEncode(DemoApplication.Common. Utility.GetDataFromSomewhere()))); }//EndofCreateChildControls }//EndofCustomDataDisplayclass }//Endofthe Contoso.DemoApplication.Sandboxed.CustomDataDisplaynamespace

Open the Package Designer for the farm solution, and record the Solution ID. You use this in the next step. Open the Package Designer for this sandboxed solution. Click Manifest.

Lab Instructions: Designing Packaging

11

Click Edit Options to open the advanced text box where you can enter custom XML that will be integrated with other settings. Visual Studio merges all information to create a composite solution manifest. Add the following XML to the Manifest Template text box:

Note: Be sure to replace ADD_SOLUTION_ID_FROM_STEP_5 with the value recorded in step 5.

<?xml version="1.0" encoding="utf-8"?> <Solution xmlns="http://schemas.microsoft.com/sharepoint/"> <ActivationDependencies> <ActivationDependency SolutionId="ADD_SOLUTION_ID_FROM_STEP_5"/> </ActivationDependencies> </Solution>

Task 2: Verify functionality


Right-click the Common project, and click Deploy. Right-click the Sandboxed project, and click Deploy. On any page, insert the CustomDataDisplay Web Part. Verify your sandboxed Web Part is operational. Your sandboxed Web Part should provide a rendering similar to this one:

12

Lab Instructions: Designing Packaging

Task 3: Remove the farm solution


In Visual Studio 2010, right-click the Common project, and click Retract. Navigate to the page that contains the Web Part. Verify that the Web Part no longer works. You should see the following:

Note: You see Show Error Details only if Callstack is set to true in the Web applications Web.config file. You should set the value to true only in development environments.

Note: No error messages are shown during the removal of the farm solution. Dependencies are not checked. Therefore, you might end up in a scenario where previously working code breaks because the dependency has been removed.

Task 4: Remove the sandboxed solution and reinstall


In Visual Studio 2010, right-click the Sandboxed project, and click Retract. Right-click the Sandboxed project, and click Deploy.

Note: In Visual Studio 2010, a message indicating that there was a dependency problem and installation was halted will appear. Because the farm solution was removed but never reinstalled, the sandboxed solution cannot be installed. By reinstalling the farm solution, you can reinstall the sandboxed solution (and return to where you were in Task 3).

Lab Instructions: Designing a Development Strategy

Module 8
Lab Instructions: Designing a Development Strategy
Contents:
Lab A: Team-Based Logging and Configuration Exercise 1: Appraising the List-Based Configuration Exercise 2: Using a SharePoint List-Based Configuration Exercise 3: Using SharePoint List-Based Logging Exercise 4: Configuring the Logging Level Lab B: Operational Logging Exercise 1: Adding Logging to SharePoint ULS 10 2 3 6 8

Lab Instructions: Desig gning a Development Strategy t

Lab A Team-Based Loggin and C A: ng Configu uration

Exercise 1: Appraising the Listg -Based Con nfiguration n


Sc cenario
Th plant mana he ager has set sp pecific targets for each manu ufacturing plan Team nt. members can see the target a use it to m m and monitor their p progress. Th main task for this exercis is as follow he f se ws: 1. . Review the options. e

Task 1: Review the options w


In this exercise, you will revie the configu n ew uration option available an provide ns nd pr and cons of each approa for this sc ros o ach cenario.

Think abou how you pr ut rovide the con nfiguration opt tions for the sc cenario. Evaluate th pros and co for the scenarios and pic a preferred solution. he ons ck

Lab Instructions: Designing a Development Strategy

Exercise 2: Using a SharePoint List-Based Configuration


Scenario
The plant manager has set specific targets for each manufacturing plant. Team members can see the target and use it to monitor their progress. The main task for this exercise is as follows: 1. 2. 3. 4. 5. 6. 7. Create a Visual Studio 2010 project. Add a Constants file to the project. Create Viewer Web Part. Create Setter Web Part. Rename Feature. Add Feature Receiver. Deploy and verify.

Task 1: Create a Visual Studio 2010 project


Create a new Empty SharePoint Project entitled Contoso.PlantTargets. Configure the project as a Sandboxed Solution.

Task 2: Add a Constants file to the project


Create a new class to hold string constants. Add the following public constant strings: ConfigurationList = Configuration List TargetForWeekFieldName = ThisWeeksTarget

Lab Instructions: Designing a Development Strategy

Task 3: Create Viewer Web Part


Add a new Web Part item to the project entitled PlantTargetMonitor. Add a new Label control in the CreateChildControls event. Set the text value of the label control to a new method, GetCurrentTargetForWeek, which takes no parameters and returns an integer value. Format the output of the Label text to resemble the following: Current Target for Week : 5

Create the GetCurrentTargetForWeek method. Using the ConfigurationList constant value, retrieve the first item in the specified list from the current Web and return the value in the field specified by the TargetForWeekFieldName constant value.

Task 4: Create Setter Web Part


Add a new Web Part item to the project entitled PlantMonitorSetter. Add a new Label control in the CreateChildControls event. Set the text value of the label control Please enter target for current week.

Add a global variable for a text box control entitled _txtCurrentTarget and then add the text box to the controls collection in CreateChildControls. Add a button to the controls collection and instantiate a new event handler for the button click event. In the button click event handler, add code to create a new list item in the target list specified by the ConfigurationList constant and set the field value specified by the TargetForWeekFieldName constant to the value entered by the user in the _txtCurrentTarget text box.

Task 5: Rename Feature


Change the default Feature name to PlantTargets.

Lab Instructions: Designing a Development Strategy

Task 6: Add Feature Receiver


Add an Event Receiver to the PlantTargets Feature. Edit the receiver class and insert code in the FeatureActivated event to: Check for the existence of a list with the name specified in the ConfigurationList constant. Add a new Generic list if one does not already exist by that name. Add a Field with a Title value set to that specified in the TargetForWeekFieldName constant. Insert a new list item with valid values.

Insert code in the FeatureDeactivating event to remove the list from the current web.

Task 7: Deploy and verify


Build, package, and deploy the solution. Verify the existence of the list and list values. Add Web Parts to a page. Verify functionality of both Web Parts.

Results: After this exercise, you should be able to see how using a SharePoint list for application configuration is simple to do. You should now consider the value the SharePoint platform provides as you can set security on the list to restrict the users who can set the configuration values. You could provide versioning on the list to see how the target has changed over time.

Lab Instructions: Designing a Development Strategy

Exercise 3: Using SharePoint List-Based Logging


Scenario
The plant manager wants to record details of when the plant target is updated, and be able to view these from within SharePoint. The main tasks for this exercise are as follows: 1. 2. 3. 4. Add additional constants. Add logging list. Add logging capability to Web Part. Deploy and verify.

Task 1: Add additional constants


Edit the Constants class file and add the following string constants: SPLogList = LogList LogLine = LogLine DateAndTimeOfLog = DateAndTimeOfLog

Task 2: Add logging list


Edit the Feature Receiver created in the previous exercise. Add a CreateLogList method, which accepts an SPWeb object as a parameter and returns void, to create a new list in the specified context. Insert code to create the list. Insert code to create fields in the list for each new string added to the Constants class (SPLogList, LogLine and DateAndTimeOfLog).

Add a DeleteLogList method, which accepts an SPWeb object as a parameter and returns void, to remove the logging list in the specified context. Insert code to delete the specified list.

Refactor the code in the FeatureActivated event into a new CreateConfigurationList method which accepts an SPWeb object as a parameter and returns void.

Lab Instructions: Designing a Development Strategy

Refactor the code in the FeatureDeactivating event into a new DeleteConfigurationList method which accepts an SPWeb object as a parameter and returns void. Modify the FeatureActivated event to call the CreateCongurationList and CreateLogList methods, passing in the current web context. Modify the FeatureDeactivating event to call the DeleteCongurationList and DeleteLogList methods, passing in the current web context.

Task 3: Add logging capability to Web Part


Edit the PlantMonitorSetter Web Part class file. In the CreateChildControls event, add a button entitled btnSubmitCurrentTargetWithError to the controls collection and instantiate a new event handler for the button click event. In the button event handler, add code to throw an exception and call a new method LogEvent, passing in the exception message as a string. Add a LogEvent method which accepts a string as a parameter and returns void. In the LogEvent method, insert code to create a new list item in the log list and set the appropriate field values (as specified by the Constants class). Update the BtnSubmitCurrentTargetClick event code to also call the LogEvent method and set the appropriate values.

Task 4: Deploy and verify


Build, package and deploy the solution. Verify the existence of the log list. Enter values into the Setter Web Part and verify that items are added to the log list with the appropriate values.

Results: After this exercise, you should be able to see how using a SharePoint list for application logging is simple to do. It is possible to add logging very simply to applications that will enable you to trace error or log information.

Lab Instructions: Designing a Development Strategy

Exercise 4: Configuring the Logging Level


Scenario
It has been reported that users have experienced some issues with updating the target, and they want to provide configurable logging capabilities. The main tasks for this exercise are as follows: 1. 2. 3. Add Web Part configuration. Add logging evaluation. Deploy and verify.

Task 1: Add Web Part configuration


Add a public property to the PlantMonitorSetter Web Part allowing the user to select a logging level from the tool pane. The logging levels should be: None = 0 Info = 1 Error = 2

Task 2: Add logging evaluation


Update the logging you added in Exercise 3 to make use of the logging configuration. Edit the BtnSubmitCurrentTargetWithErrorClick event. Modify the call to the LogEvent method to pass in a logging level value of Error in addition to the error message text.

Edit the BtnSubmitCurrentTargetClick event. Modify the call to the LogEvent method to pass in a logging level of Info in addition to the error message text.

Edit the LogEvent method and insert code to evaluate the value of the logging level passed in as a parameter against the logging level value selected by the user and insert a log item into the log list if the level is greater than or equal to the selected value.

Lab Instructions: Designing a Development Strategy

Task 3: Deploy and verify


Build, package and deploy the solution. Set a logging level value in the Web Part tool pane. Verify that items have or have not been entered into the log list based on the logging level selected.

Results: After this exercise, you will have added application configuration options that allow the level of logging to be controlled via Web part properties. This example shows how it is possible to control the program flow using configuration settings.

10

Lab Instructions: Desig gning a Development Strategy t

Lab B Opera B: ational L Logging g

Sc cenario
Th Operations team has imp he s plemented a n monitorin solution tha is able to new ng at pa the Share arse ePoint ULS log They have requested tha all custom so gs. at olutions be up pdated to prov vide ULS-base logging. ed

Exercise 1: Adding Lo ogging to SharePoin ULS nt


Th main tasks for this exerc are as follo he s cise ows: 1. . 2. . 3. . Upgrade to farm solution o n. Adding UL logging. LS Deploy and verify. d

Lab Instructions: Designing a Development Strategy

11

Task 1: Upgrade to farm solution


Close and re-open Visual Studio, choosing the Contoso.PlantTargets solution from Lab A. Change the Project properties from a Sandboxed to a Farm -based solution.

Task 2: Adding ULS logging


Diagnostic logging is part of the SharePoint Administration API. Extend the logging solution to support writing to the SharePoint ULS logs.

Task 3: Deploy and verify


Build, package, and deploy the solution. Delete existing Web Parts. Add updated Web Parts. Set a logging level value in the Web Part tool pane. Verify logging to the list. Verify logging to the SharePoint ULS.

Results: After this exercise, you will have updated the logging to also target the SharePoint ULS. This example shows how it is possible provide admin level logging capabilities to your solutions.

Lab Instructions: Developing Version and Deployment

Module 9
Lab Instructions: Developing Version and Deployment
Contents:
Lab A: Versioning Assemblies Exercise 1: Defining Base Version Exercise 2: Upgrading the Assembly Lab B: Feature Upgrade Exercise 1: Creating Upgrade Manage Page Exercise 2: Adding Feature to Upgrade Exercise 3: Upgrading Feature 6 8 9 2 4

Lab Instructions: Devel loping Version and D Deployment

Lab A Versio A: oning A Assemblies

Exercise 1: Defining B Base Versio on


Sc cenario
Create a simple Web Part tha displays the assembly ver C e at e rsion informati ion. Th main tasks for this exerc are as follo he s cise ows: 1. . 2. . 3. . 4. . Create a Microsoft Visua Studio 2010 project. al Create a ve ersion Web Part. Rename fea ature. Deploy and verify. d

Task 1: Create a Microsof Visual Stu e ft udio 2010 pr roject

Create a ne project, spe ew ecifying a farm solution in th SharePoint m he t Customization Wizard.

Lab Instructions: Developing Version and Deployment

Task 2: Create a version Web Part


Create a new Web Part that will be used to display the version number of the assembly. Add the value of: System.Reflection.Assembly.GetExecutingAssembly().GetName().Version to the output of the web control.

Task 3: Rename feature


Rename the feature to Version from Feature1.

Task 4: Deploy and verify


Run the project and verify the Web Part displays the version number.

Results: After this exercise, you will have defined a basic version for the feature and also will have demonstrated that the default assembly version for the Web Part assembly is 1.0.0.0.

Lab Instructions: Developing Version and Deployment

Exercise 2: Upgrading the Assembly


Scenario
Upgrade the Web Part assuming a new feature has been added.

Note: This solution must be deployed to a blank Web site and not a team site.

The main tasks for this exercise are as follows: 1. 2. 3. 4. 5. 6. 7. Update version. Package and deploy. Add SafeControl. Add BindingRedirect. Package and update. Evaluate the changes. Optional: Remove the additional SafeControl entry and deploy the solution.

Task 1: Update version


Define the new version. Update the assembly version number.

Task 2: Package and deploy


Deploy without using Visual Studio, because this will not upgrade the solution but retract and deploy, you need to upgrade the solution. Try the new Windows PowerShell command Update-SPSolution.

Lab Instructions: Developing Version and Deployment

Task 3: Add SafeControl


Visual Studio updated the SafeControl entry to match the assembly version you changed; however, v1.0.0.0 will no longer be a SafeControlso add this manually.

Task 4: Add BindingRedirect


Add BindingRedirect markup to allow the new assembly version to be loaded when the reference is to the 1.0.0.0 version.

Task 5: Package and update


Upgrade the solution and see what changed.

Task 6: Evaluate the changes


Look at how the web.config changed after deploying the updated solution.

Optional: Remove the additional SafeControl entry and deploy the solution
Explain why the Web Part still works.

Results: After this exercise, you will have demonstrated how it is possible using the new features of SharePoint 2010 to automatically provide assembly versioning and binding redirects.

Lab Instructions: Devel loping Version and D Deployment

Lab B Feature Upgr B: rade

Exercise 1: Creating U Upgrade M Manage Pa age


Sc cenario
Develop a basic version management solut D c tion to allow f feature upgrad through des th UI. he Th main tasks for this exerc are as follo he s cise ows: 1. . 2. . 3. . 4. . Create a Vi isual Studio 20 project. 010 Add feature manager pag e ge. Deploy and verify. d Add feature manager pag logic. e ge

Task 1: Create a Visual St e tudio 2010 p project

Create an empty SharePo project th will be farm deployed. e oint hat m

Lab Instructions: Developing Version and Deployment

Task 2: Add feature manager page


Create a new application page. Add a table to hold the results of the feature query.

Task 3: Deploy and verify


Deploy and navigate to the page you created to ensure that the page loads correctly.

Task 4: Add feature manager page logic


Add the logic to the page to display the list of features and a button for upgrade when the feature definition version and the deployed version are not the same.

Results: After this exercise, you will have created an application page that queries features in the site collection that need to be upgraded. You will have added an upgrade event handler to the feature that will be called during the upgrade event. You will also have provided specific version information that defines when the upgrade action is called and that action has been passed in the event handler. Based on this understanding of the upgrade framework, you should now be able to work through all of the scenarios.

Lab Instructions: Developing Version and Deployment

Exercise 2: Adding Feature to Upgrade


Create a feature and upgrade it. The main tasks for this exercise are as follows: 1. 2. Add site collection feature. Add feature event handler.

Task 1: Add site collection feature


Add a site collection feature. Add a new list definition based on a custom list for an upgrade log. Name the new list instance and feature appropriately for an upgrade feature. Deploy and activate the feature.

Task 2: Add feature event handler


Add a FeatureUpgradingEvent handler to create an item in the event log every time the feature is upgraded. Change the Feature to include the appropriate UpgradeActions. Change the version number of the feature from 1.0.0.0 to 2.0.0.0.

Results: After this exercise, you will have deployed a feature that will place an entry into a log upon being upgraded.

Lab Instructions: Developing Version and Deployment

Exercise 3: Upgrading Feature


Upgrade the feature and observe the results. The main tasks for this exercise are as follows: 1. 2. Package and update. Upgrade.

Task 1: Package and update


Package and update the solution.

Task 2: Upgrade
Use the FeatureManager page to upgrade the feature.

Results: After this exercise, you will have an entry in the upgrade log indicating that the upgrade has been performed.

Lab Instructions: Designing Information Architecture and Navigation

Module 10
Lab Instructions: Designing Information Architecture and Navigation
Contents:.
Lab A: Developing a Site Structure Exercise 1: Using Card Sort Exercise 2: Designing Content Types and Site Columns Lab B: Implementing Farm-wide Navigation Exercise 1: Deploying a Custom SiteMap Exercise 2: Adding an ASPmenu to a Custom Master Page 9 11 2 6

Lab Instructions: Desig gning Information Arc chitecture and Navig gation

Lab A Developing a Site St A: tructure e

Note: Your instr N ructor may run this lab as a cla discussion. ass

Exercise 1: Using Card Sort


Sc cenario
Yo ouve been ask to organiz the content from across y ked ze t your company to create y in nformation arc chitecture. To do this youll use a card sor to determine the optimal rt st tructure.

Guidelines G

You should try to create a maximum o five main ca d of ategories. You may cr reate up to five subcategorie per category until youve developed an e es y n appropriate categorizatio tree. e on You may not use the dep partment name (included in the beginnin of the item es n ng ce) ntent category y. for referenc in your con

Lab Instructions: Designing Information Architecture and Navigation

Break into groups and start working for 10 minutes. Then well reconvene to discuss the task further.
Content for Card Sort [Accounting] Expense Reports [Accounting] Purchase Orders [Accounting] Invoices (Accounts Receivable) [Accounting] Invoices (Accounts Payable) [Administration] Mission Statements [Administration] Phone Lists [Administration] Corporate Summary Presentations [Engineering] Product Design Specifications [Engineering] Test Reports [Engineering] Plant Diagrams (Physical) [Engineering] Plant Diagrams (Electrical) [Engineering] Plant Diagrams (Mechanical) [Engineering] Plant Renderings

[Accounting] Purchase Orders [Accounting] Tax Filings [Accounting] Financial Reports [Accounting] Closing Reports

[Administration] Business Planning Presentations [Administration] Organizational Charts

[Engineering] Machine Inspection Reports [Engineering] Interface Specifications [HR] Offer Letters

[Administration] Memos [Administration] Board of Directors Meeting Agendas [Administration] Board of Directors Meeting Minutes [Administration] Customer Complaint [Administration] Customer Complaint Responses

[HR] Exit Interviews

[HR] Employee Records [HR] Employee Reviews

Lab Instructions: Designing Information Architecture and Navigation

(continued)
Content for Card Sort [HR] Benefits Information [HR] Time cards [HR] Union Contracts [HR] Workers Compensation Claims [HR] Workers Compensation Claim Responses [HR] Employee Details [Legal] Contracts (Bank) [Legal] Contracts (Customer) [Legal] Contracts (Vendor) [Legal] Contracts (Partner) [Legal] Releases [Legal] Licenses [Legal] Building Permits [Legal] Zoning Petitions [Legal] Wrongful Termination Letters / Responses [Legal] Case Files [Manufacturing] Bill of Materials [Manufacturing] Production Costs [Purchasing] Vendor Quality Reports [Purchasing] Vendor Pricing Agreements [QA] Item Quality Reports [QA] Test Procedures [QA] Equipment Inspection Reports [Sales] Team Performance Reports

[Sales] Competitive Performance Reports [Sales] Proposals [Sales] Sales Presentations [Sales] Sell Sheets [Sales] Catalogs / Line Cards [Sales] Pricing Contracts [Sales] Prospects [Sales] Client Contacts [Sales] Performa P&Ls [Sales] Flyers

[Sales] Product Images [Sales] Packaging Inserts [Sales] Packaging Designs [Shipping] Bills of Lading

Lab Instructions: Designing Information Architecture and Navigation

Task 1: Use card sort to create an information architecture


After you have completed the exercise, discuss answers to the following questions with the rest of the class. What factors contributed to selecting the structure that you chose? Did you consider any other ways of organizing the site? If so, why did you settle on the structure that you chose?

Lab Instructions: Designing Information Architecture and Navigation

Exercise 2: Designing Content Types and Site Columns


Scenario
(Optional) Use the results of the card sort in Exercise 1 to design content types for storing documents in your application. If suitable content types dont exist, design new content types by selecting appropriate content types to inherit from and identify any additional site columns that are needed. The main tasks for this exercise are as follows: 1. 2. 3. Choose three types of content mentioned in Exercise 1 and identify an existing document content type or design a custom content type for each. Choose existing site columns or design custom site columns for each custom content type. Write down the content type and site column information making sure to consider the stated requirements and findability concerns.

Task 1: Select content types for each information architecture category


1. Choose an existing SharePoint document content type that would be suitable for storing that type of file in a library. (Note: content types may be used more than once.) If no suitable content type already exists, select an appropriate content type to inherit from and give your new content type a name.

2.

Task 2: Select site columns for each custom content type


1. 2. Fill in any existing SharePoint site columns that should be included in this content type. (Note: site columns may be used more than once.) If no suitable site column already exists, design a new site column.

Lab Instructions: Designing Information Architecture and Navigation

Task 3: Discuss your choice of content types and site columns


Discuss answers to the following questions with the rest of the class. 1. 2. 3. 4. How many custom content types did you design? How many custom site columns did you design? Explain why you chose each content type for each document category? Did you use any content type more than once? Which ones?

Results: After completing this exercise, you should have an understanding of how to apply information architecture to content type and site column selection in SharePoint.

Lab Instructions: Desig gning Information Arc chitecture and Navig gation

Lab B Imple B: ementin Farm-wide N ng Navigat tion

Sc cenario
Each manufactu uring plant wi have its own site collectio To make it easier for ill n on. t sers out nufacturing pla ants, the plann ning team us to find information abo other man ha decided to add custom n as navigation to a footer on the master page u used by Sh harePoint. Sin the numbe of manufacturing plant sit collections i relatively nce er te is st tatic, the team has decided t use an .xmlto -based navigat tion control in nstead of cr reating a custo SiteMapProvider class or a custom nav om r vigation contr Site users rol. will w be able to use links in th footer to nav u he vigate between top-level site in each n es manufacturing plants site co m ollection. A roo node repres ot senting the cor rporate In ntranet site wil also be inclu ll uded. In this lab, you should: n 1. . 2. . Add naviga ation nodes representing the manufacturi plants site collections e ing e and corpor intranet to the Layouts.Sitemap of all Web applicat rate o tions. Create a master page wit navigation l th links based on the added na n avigation nodes.

Lab Instructions: Designing Information Architecture and Navigation

Exercise 1: Deploying a Custom SiteMap


The main tasks of this exercise are as follows: 1. 2. Create a new Microsoft Visual Studio project. Merge the navigation nodes into the default Layouts.Sitemap.

Task 1: Create a new Visual Studio project


1. 2. 3. 4. 5. 6. Create a new Empty SharePoint project named Contoso.GlobalNav. Select to Deploy it as a Farm solution. Add a SharePoint Layouts mapped folder. Delete the Contoso.Global.Nav folder. Add an .xml file called Layouts.Sitemap.Global.xml to the Layouts folder. Add the following .xml code:
<?xml version="1.0" encoding="utf-8" ?> <siteMap> <siteMapNode title="Corporate" url="http://sharepoint/student/module10/"> <siteMapNode title="Cleveland" url="/CLE" /> <siteMapNode title="Los Angeles" url="/LAX" /> <siteMapNode title="Denver" url="/DEN" /> </siteMapNode> </siteMap>

7.

Deploy the project.

10

Lab Instructions: Designing Information Architecture and Navigation

Task 2: Merge the navigation nodes into the default Layouts.Sitemap


1. 2. Open a command prompt. Execute the following command:
cd \Program Files\Common Files\Microsoft Shared\web server extensions\14\binstsadm -o copyappbincontent

Note: In a multiple Web front end server environment, the command line must be run once on each server. Invoking the SPWebService.ApplyApplicationContentToLocalServer method will accomplish the same thing, but since it runs only on one server, you would need to create a custom timer job that would invoke the API on each Web front end server.

Lab Instructions: Designing Information Architecture and Navigation

11

Exercise 2: Adding an ASPmenu to a Custom Master Page


The main tasks of this exercise are as follows: 1. 2. 3. Add an ASPmenu and SiteMapDataSource. Deploy V4Global.master. Use the V4Global.master.

Task 1: Add an ASPmenu and SiteMapDataSource


1. 2. 3. 4. Open the corporate portal site in SharePoint Designer. Make a copy of the V4.master and name it V4global.master. Edit the V4global.master. Add the following code on the line above the developers dashboard:
<hr /> <div style="position:relative; left:50%; margin-left:-25%; "> <SharePoint:AspMenu ID="FarmNavigationMenuV4" Runat="server" EnableViewState="false" DataSourceID="FarmSiteMap" AccessKey="<%$Resources:wss,navigation_accesskey%>" UseSimpleRendering="true" UseSeparateCss="false" Orientation="Horizontal" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0" SkipLinkText="" CssClass="s4-tn"/> <asp:SiteMapDataSource ShowStartingNode="True" StartingNodeUrl="http://sharepoint/student/module10/" SiteMapProvider="SPXmlContentMapProvider" ID="FarmSiteMap" runat="server"/> </div>

5. 6.

Close and save the V4global.master. Exit SharePoint Designer.

12

Lab Instructions: Designing Information Architecture and Navigation

Task 2: Deploy V4global.master


1. 2. 3. 4. 5. 6. Open the corporate portal site in Windows Internet Explorer. Navigate to the master page gallery and download V4global.master. Delete V4global.master from the master page gallery. Add a module to the Contoso.GlobalNav project created in Exercise 1. Add the existing V4global.master to the module folder in Visual Studio. Modify the Elements.xml for the module so that it matches the following code:
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="CopyMaster" Url="_catalogs/masterpage"> <File Path="CopyMaster\V4global.master" Url="V4global.master" IgnoreIfAlreadyExists="True" Type="GhostableInLibrary"> <Property Name="ContentType" Value="Master Page" /> <Property Name="UI Version" Value="4" /> </File> </Module> </Elements>

Task 3: Use the V4global.master


1. 2. Add a feature receiver to the module feature created in Task 2. Add the code below to the FeatureActivated method:
SPWeb CurrentWeb = properties.Feature.Parent as SPWeb; CurrentWeb.MasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4global.master"; CurrentWeb.CustomMasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4global.master"; CurrentWeb.Update();

Lab Instructions: Designing Information Architecture and Navigation

13

3.

Add the code below to the FeatureDeactivating method:


SPWeb CurrentWeb = properties.Feature.Parent as SPWeb; CurrentWeb.MasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4.master"; CurrentWeb.CustomMasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4.master"; CurrentWeb.Update();

4. 5.

Deploy the project. Navigate to the site you chose as the target when you created the project in Exercise 1. You should see a new global navigation footer at the bottom of the page.

Note: You have only added the V4global.master to one site in this exercise. You would need to deploy and activate the custom master to other sites for the navigation to be complete.

Results: After completing this exercise, you should have an understanding of how to implement a custom global navigation system for a SharePoint site.

Lab Instructions: Designing Branding and Customization Support

Module 11
Lab Instructions: Designing Branding and Customization Support
Contents:
Lab A: Packaging Branding Exercise 1: Importing .wsp Files Into Microsoft Visual Studio Exercise 2: Extracting the File Resources Exercise 3: Writing the Feature Receiver to Apply Changes Exercise 4: Testing the Changes Lab B: Improving Branding Performance Exercise 1: Observing Current Performance Exercise 2: Turning on BLOB Caching Exercise 3: Observing BLOB Cached Performance Exercise 4: Observing _layouts Performance 8 9 10 11 3 4 5 6

Lab Instructions: Desig gning Branding and C Customization Suppo ort

Lab A Packa A: aging Br randing g

Sc cenario
Th designer ha delivered a Microsoft Sha he as arePoint site w which has been modified n with w SharePoin Designer. Th designer pa nt he ackaged the ch hanges up into a .wsp by o di isabling the pu ublishing featu and then selecting save site as templ ures n e late. The de esigner has let you know of the following changes they made which you need to t f g y pa ackage:

Added a ne master pag called Conto ew ge oso.master Created a custom CSS ca c alled Contoso. .CSS Added a Co ontoso logo Modified th site logo UR of the site he RL

Yo package should apply a of these elem our all ments to a site as a part of a feature e ac ctivation proce ess.

Lab Instructions: Designing Branding and Customization Support

Exercise 1: Importing .wsp Files Into Microsoft Visual Studio


The main tasks for this exercise are as follows: 1. 2. Create new project. Review the imported artifacts.

Task 1: Create new project


Open Visual Studio. Create a New Project based on the SharePoint Solution Package project. Create a sandboxed deployment that deploys to http://sharepoint/student/module11. This is a scrap project that youll never use for deployment. Import all artifacts from the .wsp file.

Task 2: Review the imported artifacts


Locate the custom Contoso.master file in the Built-In List Instances -> Master_Page_Gallery -> _catalogsmasterpage_ -> Files -> _catalogs -> masterpage folder. Locate the Header.png, Logo.png, and Contoso.css files in List Instances -> Site_Assets ->SiteAssets_ -> Files ->SiteAssets folder.

Results: After this exercise, you should have a Visual Studio project with the artifacts that the designer created in SharePoint Designer.

Lab Instructions: Designing Branding and Customization Support

Exercise 2: Extracting the File Resources


The main tasks for this exercise are as follows: 1. 2. 3. 4. Create a new Contoso Branding project. Copy the master page resources to the Contoso Branding project. Copy the site assets resources to the Contoso Branding project. Remove the imported project.

Task 1: Create a new Contoso Branding project


Create a new project with the Empty SharePoint Project template. Specify Sandboxed deployment and a site of http://sharepoint /student/module11. Note that normally you would create a farm solution, but for the class, a sandboxed solution is easier.

Task 2: Copy the master page resources to the Contoso Branding project
Drag the Master_Page_Gallery folder hierarchy into the Contoso.Branding project. Delete all of the unnecessary elements until just the list instance and module for Contoso.master remain.

Task 3: Copy the site assets resources to the Contoso Branding project Drag the Site_Assets folder hierarchy into the Contoso.Branding project. Task 4: Remove the imported project
In Solution Explorer, remove the imported project from the solution.

Results: After this exercise, you should have a Contoso Branding project that will deploy all of the required files to support changing the master page.

Lab Instructions: Designing Branding and Customization Support

Exercise 3: Writing the Feature Receiver to Apply Changes


The main tasks for this exercise are as follows: 1. 2. Rename the feature. Add a feature event receiver to set the master page.

Task 1: Rename the feature


Rename the feature in the hierarchy to Contoso.Branding. Change the title to Apply Contoso Branding.

Task 2: Add a feature event receiver to set the master page


Write a feature activated receiver to set the master page to Contoso.master. Write a feature deactivating receiver to restore the default master pages.

Results: After this exercise, you should have a completely functional Visual Studio project, which will deploy the required resources and provide the user with a way to activate the Contoso branding on their site.

Lab Instructions: Designing Branding and Customization Support

Exercise 4: Testing the Changes


The main tasks for this exercise are as follows: 1. 2. Deploy and run the package. Deactivate the feature and ensure the site still works.

Task 1: Deploy and run the package


Run the Visual Studio project. Confirm that Contoso Branding is visible on the site.

Task 2: Deactivate the feature and ensure the site still works
Deactivate the feature Apply Contoso Branding in site features. Navigate back to the home page and ensure that the Contoso Branding has been removed.

Results: After this exercise, you should have demonstrated that your project works correctly.

Lab Instructions: Designing Branding and Customization Support g

Lab B Impro B: oving Br randing Perfor g rmance

Sc cenario
Th designer ha delivered a SharePoint site which has b he as been modified with d Sh harePoint Des signer. The des signer packaged the change up into a W by es WSP di isabling the pu ublishing featu and then selecting save site as templ ures n e late. The de esigner has let you know of the following changes they made which you need to t f g y pa ackage:

Added a New Master Pag called Cont ge toso.master. Created a custom CSS ca c alled Contoso. .CSS. Added a Co ontoso logo. Modified th site logo UR of the site. he RL

Yo package should apply a of these elem our all ments to a site as a part of a feature e ac ctivation proce ess.

Lab Instructions: Designing Branding and Customization Support

Exercise 1: Observing Current Performance


The main tasks for this exercise are as follows: 1. 2. 3. Deploy and reactivate the Contoso.Branding package. Open Fiddler and force a reload of the home page. Observe calls to ~/siteassets and ~/style Library.

Task 1: Deploy and reactivate the Contoso.Branding package


Right-click Contoso.Branding (from Lab A) and deploy. Do not choose run, since run will automatically retract the project when you stop debugging in Visual Studio. Activate the Apply Contoso.Branding feature.

Task 2: Open Fiddler and force a reload of the home page


Start Fiddler2. In Internet Explorer with the home page open, press F5 to refresh the page. Click the logo to demonstrate that the sequence in Fiddler is similar.

Task 3: Observe calls to ~/siteassets and ~/style Library


Find a call to ~/siteassets and review the cache header in the response. Find a call to ~/style library and review the cache header in the response.

Results: After this exercise, you should have observed how out of the box all of the requests which are serviced by the content database have a cache-control header set to private.

Lab Instructions: Designing Branding and Customization Support

Exercise 2: Turning on BLOB Caching


The main tasks for this exercise are as follows: 1. 2. Open the web.config for the web application. Set the BlobCache to enabled.

Task 1: Open the web.config for the web application


Open the web.config file in Visual Studio (C:\inetpub\wwwroot\wss\VirtualDirectories\80).

Task 2: Set the BlobCache to enabled


Locate the <BlobCache> node. Change the location attribute to a directory that exists, or create the directory specified in the location attribute. Change the enabled attribute to true. Save the file.

Results: After this exercise, you should have enabled the SharePoint Server BlobCache on SharePoint so that files from the database are cached locally.

10

Lab Instructions: Designing Branding and Customization Support

Exercise 3: Observing BLOB Cached Performance


The main tasks for this exercise are as follows: 1. 2. 3. Refresh the page. Navigate to the page. Observe cache settings for ~/siteassets.

Task 1: Refresh the page


Press F5 to refresh the home page and notice that all of the files are still requested.

Task 2: Navigate to the page


Click the Contoso logo to return to the site. Notice that Fiddler doesnt show requests for the site assets or style library.

Task 3: Observe cache settings for ~/siteassets


Locate a request for a ~/siteassets file. Inspect the response for the Cache-Control header. Notice that the Cache-Control header is now public.

Results: After this exercise, you should have observed the impact that enabling the BLOB cache has on the client interaction.

Lab Instructions: Designing Branding and Customization Support

11

Exercise 4: Observing _layouts Performance


The main tasks for this exercise are as follows: 1. 2. Review a _layouts request in Fiddler. Compare the cache-control header in siteassets and _layouts.

Task 1: Review a _layouts request in Fiddler


Locate a request to _layouts (or press F5 on the home page to generate another one). Inspect the response for the Cache-Control header.

Task 2: Compare the cache-control header in siteassets and _layouts


Identify which cache-control max-age is longer. Which will perform better over the long term?

Results: After this exercise, you should have an understanding of how performance differs with BlobCache turned on and how _layouts behaves in terms of cache control.

Lab Instructions: Designing Security

Module 12
Lab Instructions: Designing Security
Contents:
Lab A: Setting Up a Customer Service Site Exercise 1: Setting Up the Authentication Provider Exercise 2: Creating an FBA-Claims Site Optional Exercise 3: Viewing Claims for an FBA User Lab B: Solving a Security Issue Exercise 1: Understanding the Scope and Relating it to Configuration Exercise 2: Designing a Security Strategy 15 15 3 6 13

Lab Instructions: Desig gning Security

Lab A Settin Up a Custom Serv A: ng mer vice Site e

Sc cenario
Contoso manuf C facturing wants to allow cus stomers to log into a ShareP g Point site to se the progress of their orde Customers will not have an internal n ee ers. s e network id dentity. The sa representa ales ative needs the ability to ma e anage access to the o cu ustomers sites s.

Lab Instructions: Designing Security

Exercise 1: Setting Up the Authentication Provider


The main tasks for this exercise are as follows: 1. 2. Map out requirements, design a plan. Set up the FBA database and verify you can manage users.

Task 1: Map out requirements, design a plan


The customer scenario outlines two key requirements that guide us to a final design decision: Users will not have an internal network identity. A Contoso employee will manage access.

These two requirements point us in the direction of a solution that leverages FBA. By setting up a custom database that is housed internally (on Contoso property), we are able to isolate user identities and provide Contoso employees the ability to manage user accounts that will be needed to access the site. Knowing that we plan to use FBA, we also know that our Microsoft SharePoint Web application must be set up to use claims-mode authentication.

Task 2: Set up the FBA database and verify you can manage users
For this step, the following assumptions were made to reduce complexity. We are going to use standard instructions for setting up an FBA database. The IIS Management console will serve as our user management interface. The security account for the application pools will be Network Service. This is a predefined local account that will allow us to set up both the SharePoint and generic ASP.Net sites.

Note: These assumptions may not be valid for production systems. They are intended for educational and development use only.

Lab Instructions: Designing Security

1.

Start the ASP.NET SQL Server Setup Wizard. The setup file is located at %windows%\Microsoft.Net\Framework64\ v2.0.50727\aspnet_regsql.exe. Default values should be sufficient for all fields, with the exception of the SQL Server name field. Specify .\SharePoint for the server name.

2. 3.

Open IIS Manager. Create a new Web site called fba, which utilizes the SharePoint 80 application pool. Open Microsoft SQL Server Management Studio. Locate the aspnetdb database. Add Network Service as a db owner for the aspnetdb.

4. 5.

Navigate to the root folder for the fba Web site that was just created. Create a web.config file, and add the following text to the file:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <connectionStrings> <add name="fbaSQL" connectionString="Server=.\SHAREPOINT;Database=aspnetdb;Integrated Security=true" /> </connectionStrings> <system.web> <!-- membership provider --> <membership defaultProvider="fbaMembers"> <providers> <add name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" /> </providers> </membership>

(Code continued on the following page.)

Lab Instructions: Designing Security

<!-- role provider --> <roleManager enabled="true" defaultProvider="fbaRoles"> <providers> <add name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="fbaSQL" applicationName="/" /> </providers> </roleManager> <authentication mode="Forms" /> </system.web> </configuration>

6.

At this point, you should be able to go back to the Internet Information Services (IIS) Management console, add at least one user to your new FBA database, and grant one user access to the site. You can also define roles and associate users with those roles. For demo purposes, create at least one role and associate the user from Step 6 with the role.

7.

Results: After this exercise, you should have all the underlying FBA components in place and ready for SharePoint consumption. You are now ready to provision a SharePoint 2010 site for use with FBA.

Lab Instructions: Designing Security

Exercise 2: Creating an FBA-Claims Site


The main tasks for this exercise are as follows: 1. 2. 3. 4. 5. 6. 7. 8. Create a new SharePoint Web application. Add connection strings to all web.config files. Add PeoplePicker wildcard information. Define membership and role providers for Central Administration. Define membership and role providers for the Forms Web application. Define membership and role providers for the Security Token Service application. Use Central Administration to designate the first FBA user for the Forms Web application. Navigate to the Forms Web application, view user properties.

Task 1: Create a new SharePoint Web application


As mentioned earlier, FBA now requires a Web application to use claims-mode authentication. 1. 2. 3. Navigate to Central Administration, select Application Management. Select Manage Web applications and click New. Specify the following values in the Create New Web Application dialog box: 4. Authentication Type: Claims Based Authentication Port: 888 Enable Forms Based Authentication (FBA) Provider Name: fbaMembers Role Manager Name: fbaRoles Security Account: Network Service

Create a site collection for the top-level site of your Forms Web application.

Lab Instructions: Designing Security

Task 2: Add connection strings to all web.config files


As noted in Lesson 2, enabling FBA requires updates to three web.config files: Forms Web application (created in Task 3) Central Administration Security Token Service application

The web.config files are located in two different folders: The root folders for both the Forms Web application and Central Administration are located under \inetpub\wwwroot\wss\VirtualDirectories. The root folder for the Security Token Service is located under 14\WebServices\SecurityToken. Add the following connection string to the web.config files (as a child of the <configuration> node):

Note: Be sure to place this node after the configSections node; otherwise, you will get an error stating that configSections must be the first child of the configuration node.

<connectionStrings> <add name="fbaSQL" connectionString="Server=.\SHAREPOINT;Database=aspnetdb;Integrated Security=true" /> </connectionStrings>

Task 3: Add PeoplePicker wildcard information


You will need to update the following configuration files: Forms Web application Central Administration

Add the following text as a child of the <PeoplePickerWildcards> node:


<add key="fbaMembers" value="%" />

Lab Instructions: Designing Security

Task 4: Define membership and role providers for Central Administration


Update the membership and role provider information contained within Central Administrations web.config file with the following text:
<roleManager enabled="true" cacheRolesInCookie="false" cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="AspNetWindowsTokenRoleProvider" createPersistentCookie="false" maxCachedResults="25"> <providers> <clear /> <add connectionStringName="fbaSQL" applicationName="/" name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </roleManager> <membership defaultProvider="fbaMembers" userIsOnlineTimeWindow="15" hashAlgorithmType="" > <providers> <clear />

(Code continued on the following page.)

Lab Instructions: Designing Security

<add connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership>

Task 5: Define membership and role providers for the Forms Web application
Update the membership and role provider information contained within Form Web applications web.config file with the following text:
<roleManager enabled="true" cacheRolesInCookie="false" cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="c" createPersistentCookie="false" maxCachedResults="25"> <providers> <clear /> <add connectionStringName="fbaSQL" applicationName="/" name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

(Code continued on the following page.)

10

Lab Instructions: Designing Security

<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add name="c" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvi der, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> </providers> </roleManager> <membership defaultProvider="i" userIsOnlineTimeWindow="15" hashAlgorithmType=""> <providers> <clear /> <add connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershi pProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> </providers> </membership>

Lab Instructions: Designing Security

11

Task 6: Define membership and role providers for the Security Token Service application
Update the membership and role provider information contained within the Security Token Services web.config with the following information:

Note: <system.web> does not exist in a default out-of-box installation. Add the following as the last child of the <configuration> node.

<system.web> <membership> <providers> <add connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership> <roleManager enabled="true"> <providers> <add connectionStringName="fbaSQL" applicationName="/" name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </roleManager> </system.web>

12

Lab Instructions: Designing Security

Task 7: Use Central Administration to designate the first FBA user for the Forms Web application
Designate one of the FBA users created in Task 2 as either a site collection administrator or grant them Full Control via a user policy. If all associations have been properly set, the Central Administration site should be able to locate the FBA users.

Task 8: Navigate to the Forms Web application, view user properties


Navigate to your newly configured site. Dont forget to use the port number specified when creating the Web application (http://sharepoint:888). You should see a login page that allows you to choose between Windows authentication and Forms authentication. Navigate using the following steps: Login using the credentials of the user created in Exercise 1, Task 2. Go to My Settings. Verify that your login name has the new claims-based format.

Results: After this exercise, you should have a fully functioning FBA-Claims SharePoint site.

Lab Instructions: Designing Security

13

Optional Exercise 3: Viewing Claims for an FBA User


The main task for this exercise is as follows: 1. Deploy farm solution

Task 1: Deploy farm solution


Open the Module 12 solution. The ShowMyClaims project is a farm solution that contains a single Web Part that simply enumerates any claims if present. It will also show two property values of SPUser. If you deploy the project to the Forms Web application and the Web Part to any page, you should see output that looks like the data thats shown in the following figure, which shows claims for an authenticated FBA user.

14

Lab Instructions: Desig gning Security

Lab B Solvin a Sec B: ng curity Is ssue

Sc cenario
Contoso manuf C facturing is moving more in nformation to the customer portals. It has be reported that some of th documents are unavailab to the customer, even een t he s ble th hough they should have acc cess to the doc cuments. An nalyze and de evelop a securi strategy an implement i ity nd it.

Lab Instructions: Designing Security

15

Exercise 1: Understanding the Scope and Relating it to Configuration


The scenario statement is fairly generic. Lets try to dig a little deeper into the issue to see how it might relate to the configuration. Lets also assume there are no problems with the actual process of populating the data. Build a set of questions that can be used to debug the problem and determine if there is a problem with the configuration or perhaps the security settings.

Exercise 2: Designing a Security Strategy


In exercise 1, you created a set of questions to help discover and isolate the problem. Now, lets provide some context to see if you can build a list of possible solutions, if the following conditions are known: Users are singularly added to SharePoint sites. Business rules indicate users should be aggregated for application of properties and services. Potentially those grouping rules may change based on external criteria. Item-level security is not desired.

Lab Instructions: Designing for Page and Data Access Performance

Module 13
Lab Instructions: Designing for Page and Data Access Performance
Contents:
Exercise 1: Using the SharePoint Server 2010 Developer Dashboard to Capture Performance Metrics Exercise 2: Leveraging the SharePoint Server 2010 Search API for Large Data Queries 2 4

Lab Instructions: Desig gning for Page and D Access Performa Data ance

Lab: D Designing for P Page an Data Access nd s Perfo ormance e

Exercise 1: Using the SharePoin Server 2 nt 2010 Deve eloper Dashboard to Captur Perform D re mance Met trics
Sc cenario
Yo have create a custom list and list inst ou ed tance for deplo oyment into a site co ollection and a Web Part to retrieve the lis data and ren st nder it in a da grid. ata Th user has po he opulated the li with large a ist amounts of da You must assess the ata. pe erformance im mpact of the cu ustom Web Pa using the S art SharePoint Dev veloper Dashboard. D Th main tasks for this exerc are as follo he s cise ows: 1. . 2. . Enable the SharePoint Developer Dash hboard. Deploy the Contoso.Perf e formance.Lists solution. s

Lab Instructions: Designing for Page and Data Access Performance

3. 4.

Add performance instrumentation to a custom Web Part. Analyze results in the Developer Dashboard.

Task 1: Enable the SharePoint Developer Dashboard


Start the SharePoint 2010 Management Shell. Enter Windows PowerShell commands to enable the Developer Dashboard.

Task 2: Deploy the Contoso.Performance.Lists solution


Locate and open the Contoso.Performance.sln file. Deploy the solution.

Task 3: Add performance instrumentation to a custom Web Part


Edit the custom List View Web Part. Add custom monitor scopes. Build and deploy the solution.

Task 4: Analyze results in the Developer Dashboard


Add the custom List View Web Part to a SharePoint page. View the Developer Dashboard. Analyze and interpret the results.

Results: After this exercise, you should have instrumented the code to write output results to the Developer Dashboard and deployed the solution to SharePoint.

Lab Instructions: Designing for Page and Data Access Performance

Exercise 2: Leveraging the SharePoint Server 2010 Search API for Large Data Queries
Scenario
After analyzing the performance results of the custom List View Web Part, you determine that the performance of the solution is less than optimal. You must now refactor the code to use the SharePoint Search API to retrieve list item data and display it in a data grid. The main tasks for this exercise are as follows: 1. 2. Create a search query to retrieve list items. Analyze performance metrics in the Developer Dashboard.

Task 1: Create a search query to retrieve list items


Create a new search query object and set the required parameters. Execute the search query. Bind the query results to a data grid.

Task 2: Analyze performance metrics in the Developer Dashboard


Add the modified Web Part to a SharePoint page. View the Developer Dashboard. Analyze and interpret the results.

Results: After this exercise, you should have configured Search, modified the code to retrieve list items through the Search API, and compared the performance metrics in the Developer Dashboard.

Lab Instructions: Designing a Testing Strategy

Module 14
Lab Instructions: Designing a Testing Strategy
Contents:
Exercise 1: Conducting Unit Testing Exercise 2: Conducting Performance Testing Exercise 3: Conducting Load Testing 2 5 6

Lab Instructions: Desig gning a Testing Strate egy

Lab: D Designing a Te esting St trategy y

Exercise 1: Conductin Unit Te ng esting


Sc cenario
Th developme team leade has identifie the need for unit tests as part of he ent er ed r a new Web Part project. The desired functi ionality is to p present a drop p-down election of ava ailable lists in a SharePoint 2 2010 team site when selecte an event e; ed, se will w fire which loads the defa view of the list into a dy l ault e ynamically-gen nerated grid vi iew. In preparation for unit testing, the team lead has re efactored the s solution into a Model-View-P Presenter patte with a Mo ern, odel class that retrieves the S SharePoint st bject, and a Vie class which takes the Da ew h ataTable lis items into a DataTable ob ob bject, perform some text m ms manipulation, b binds the data to a GridView and a w, re eturns the resu ulting GridVie to the Web Part (Presenter) class. ew

Lab Instructions: Designing a Testing Strategy

As both the Presenter (Web Part) and Model (data) classes cannot be unit tested without mock (stub) objects due to their dependency upon the SharePoint framework, the developer must write a suite of tests to validate the functionality of the View class. The unit tests must validate that data from a DataTable is properly bound to a GridView object and that the XML Encoded values for list field names are properly decoded into a readable format. Finally, the unit tests must be automatically executed after each successful build of the Web Part project. The main task for this exercise is as follows: 1. Create, execute and automate a unit test.

Task 1: Create, execute, and automate a unit test


Open the Testing solution. Create a new Unit Test project for the ListView_View class and insure coverage for the GetListAsGridView method. Arrange the test by creating a DataTable object, adding a column with an XMLEncoded name value (such as Test_x0020_Value), and inserting a row with a string value. Set variables for the number of rows in the DataTable and the XML Decoded value of the column name. Act on the test by calling the ListView_View.GetListAsGridView method, passing in the test DataTable object as a parameter. Set variables for the row count in the resulting GridView object and the title of the header row cell text. Assert that the number of rows in the Grid View matches the number of rows in the test DataTable object and that the value of the header row cell text matches the XML decoded value of the column name. Compile the test project and execute the test. Create a Test List that includes the GetListAsGridView_Test test in a new list titled UnitTests.

Lab Instructions: Designing a Testing Strategy

Add a postbuild event to the Contoso.Testing.WebParts project to execute mstest.exe from the command line using the Contoso.Testing.vsmdi metadata file and the UnitTests test list. Rebuild the solution and view the results of the test execution in the Output window.

Results: After this exercise, you should have created a unit test, executed the unit test, and automated execution of the unit test as part of the build process for the project. Provide the results of the exercise so that students will know when and if they have completed the lab exercise successfully.

Lab Instructions: Designing a Testing Strategy

Exercise 2: Conducting Performance Testing


Scenario
The Visual Web Part solution has been refactored and unit tested. You must now create and execute performance tests to validate the operational parameters of the solution. The main task for this exercise is as follows: 1. Create and execute a performance test.

Task 1: Create and execute a performance test


Create a performance test project. Add a Web performance test to the project. Add a response time parameter to the test. Execute the test. Add a validation rule to the test. Execute the test.

Results: After this exercise, you should have created a performance test and validated the results of the tests against the target Web application.

Lab Instructions: Designing a Testing Strategy

Exercise 3: Conducting Load Testing


Scenario
The Visual Web Part project has been unit and performance tested. You must now create and execute a load test to determine the operational limits of the target system. The main task for this exercise is as follows: 1. Create and execute a load test.

Task 1: Create and execute a load test


Add a load test to the performance test project. Walk through the wizard and set the required parameters: Test Name Test Pattern Test Mix Model Test Mix Network Mix Browser Mix Counter Steps Run Settings

Execute the load test.

Results: After this exercise you should have created a load test and validate the results of the test against the target web application.

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint

Module 1
Lab Answer Key: ASP.NET Advanced Concepts for SharePoint
Contents:
Lab A: Page Size and ViewState Exercise 1: Using Fiddler to Observe Page Loading Exercise 2: Using Fiddler to Examine Page Size Exercise 3: Reducing Page Size Lab B: Memory and Performance Exercise 1: Starting a Performance Capture Exercise 2: Reviewing the Report Exercise 3: Resolving Memory Issues and Retest 4 4 5 2 3 3

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint

Lab A: Page Size and ViewState


Exercise 1: Using Fiddler to Observe Page Loading
Task 1: Launch Fiddler
From the Start menu, point to All Programs, and then click Fiddler 2.

Task 2: Start the ManufacturingDashboard project


1. 2. 3. 4. Browse to E:\Student\Module 1\Class\ManufacturingDashboard and open ManufacturingDashboard.csproj with Visual Studio 2010. In Visual Studio, right-click ManufacturingDashboard and select Set as Startup Project. Press F5 to launch the application with debugging. The Windows Internet Explorer browser window appears. Change localhost in the URL of the browser with ipv4.fiddler.

Note: If the page is blocked by the Internet Explorer Enhanced Security Configuration, click Add and add the website to the Trusted sites zone.

5.

Change back to the Fiddler window and click the session that is reading from 127.0.0.1 (the port number will be random) and the path of /.

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint

Exercise 2: Using Fiddler to Examine Page Size


Task 1: Review the default.aspx request
1. 2. 3. 4. 5. Click the session that is reading from 127.0.0.1 (the port number will be random) and the path of /. Look at the Body field in the list. This indicates the total size in bytes of the request. At this time, the size is 184,108 bytes. On the right side, click the Inspectors tab. Click the TextView tab in the response (bottom) section. Review the output. Notice the __VIEWSTATE field (scroll down). Notice that the output is fairly large.

Exercise 3: Reducing Page Size


Task 1: Disable ViewState
1. 2. In Visual Studio, open the Default.aspx file. Add the attribute EnableViewState=false to the <%@Page %> tag at the top and: 3. 4. 5. Both <asp:Repeater> tags Both <asp:GridView> tags All three <asp:TextBox> tags

Click Save to save the Default.aspx file. Open Internet Explorer and press F5. Examine the revised page (see Exercise 2). Now, the size is 112848 bytes.

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint

Lab B: Memory and Performance


Exercise 1: Starting a Performance Capture
Task 1: Start capture
1. 2. 3. 4. 5. In Visual Studio, click the Analyze menu, and then click Launch Performance Wizard. In the Performance Wizard -- Page 1 of 4 dialog box, select .NET Memory Allocation (Sampling) and specify the profiling method. In the Performance Wizard -- Page 2 of 4 dialog box, click Next. In the Performance Wizard -- Page 3 of 4 dialog box, click Next. On the Performance Wizard -- Page 4 of 4 dialog box, click Finish. A new instance of Internet Explorer will appear.

Task 2: Exercise the application


In Internet Explorer, refresh the page a few times. This will cause the page to reload, creating information for the summary report.

Exercise 2: Reviewing the Report


Task 1: Review the summary
1. 2. Stop the application profiling session by closing Internet Explorer. Wait for the memory profiling report to complete. Review the Functions Allocating the Most Memory section. Note that Contoso.Manufacturing.Data.LinePerformance.GetCacheKey() is allocating a lot of memory (fourth in the list). Also note that System.String is most of the instances in memory and the most memory allocated. This is typical.

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint

Exercise 3: Resolving Memory Issues and Retest


Task 1: Identify the memory issues
Investigate Contoso.Manufacturing.Data.LinePerformance. Note the poor implementation of a single instance pattern. (The cache key will never match due to the inclusion of the current date/time.)

Task 2: Resolve the memory issues by eliminating the poor pattern


1. 2. 3. 4. 5. Remove the Get() method. Remove the GetCacheKey() methods. Change the constructor from private to public; add a parameter of the SQL reader. Add to the constructor a call to .LoadFromReader(). Change the LinePerformanceCollection class to a new LinePerformance object instead of calling LinePerformance.Get().

Task 3: Retest
Redo Exercise 1 and verify different (better) results.

Lab Answer Key: Designing for User Experience

Module 2
Lab Answer Key: Designing for User Experience
Contents:
Lab A: Selecting Page Parts Exercise 1: Line Dashboard Exercise 2: Managers Dashboard Exercise 3: Alert Notification Lab B: Selecting Page Types Exercise 1: Plant Summary Page Exercise 2: Plant Configuration Page Exercise 3: Employee List Exercise 4: Line Status 5 6 7 8 2 3 4

Lab Answer Key: Designing for User Experience

Lab A: Selecting Page Parts


Exercise 1: Line Dashboard
Best Choice: Microsoft Silverlight Key Criteria: 6-foot display (i.e. Multimedia display) Comments by page part type:
Page Part Type Delegate Control Web Part Visual Comments Shouldnt appear on every page. Possible but designing for something that could be seen 6 feet away isnt practical with HTML. See Web Part Visual See Web Part Visual Best choice. Silverlight has full multimedia support so the page can be blinking red, can play a siren, and do whatever is necessary to be usable from several feet away. Not applicable as a dashboard. Possiblebut would require refresh strategy and isnt really appropriate for 6 feet away. The message/status would be a persistent concern, not a transient one.

Web Part Server Control Web Part AJAX Silverlight

Menu Item Status Bar

Notification Area

Lab Answer Key: Designing for User Experience

Exercise 2: Managers Dashboard


Best Choice: Web Part with AJAX Key Criteria: Performance concerns, drill into Comments by page part type:
Page Part Type Delegate Control Web Part Visual Comments Not appropriate not for every page. A possible option. The concern here is making sure to leverage AJAX to minimize page refreshes. A possible option. Probably too difficult to be practical. Best answer. The idea here is to minimize page refreshes and maintain good performance. A possible option. Generally the ability to drill in means going back to Web pages. Its a good interface design to keep from doing too many transitions. Not appropriate for a dashboard. Not appropriate for a drill-in dashboard. Not appropriate for a drill-in dashboard.

Web Part Server Control Web Part AJAX

Silverlight

Menu Item Status Bar Notification Area

Lab Answer Key: Designing for User Experience

Exercise 3: Alert Notification


Best Choice: Delegate Control Key Criteria: Appear on every page Comments by page part type:
Page Part Type Delegate Control Comments Best answer. Can be caused to load on every page in the system so the alert can be displayed on every page. Not appropriate because it would require modifying every page (including out-of-the-box pages) to refer to the Web Part. See Web Part Visual. See Web Part Visual. See Web Part Visual. Not appropriate for an alert. You still need something to trigger the status bar message. The delegate control could trigger a message to be displayed in the status bar. The notification area is for temporary/non-persistent messages. The requirements are such that this isnt a one passing message; something still needs to trigger the message into the notification area.

Web Part Visual

Web Part Server Control Web Part AJAX Silverlight Menu Item Status Bar

Notification Area

Lab Answer Key: Designing for User Experience

Lab B: Selecting Page Types


Exercise 1: Plant Summary Page
Best Choice: Publishing Page/Page Layout Key Criteria: Consistent content display Comments by page type:
Page Type Dialog Comments Not appropriate because the plant summary doesnt appear over anything. Doesnt manage the storage of content. Developer would have to manually address this need. The formatting doesnt apply to every page in the site, just to the plant summary page. Wouldnt manage the storage of the plant content. Would manage the storage of content, but wouldnt provide the kind of consistency the scenario describes. The best choice. Provides content management and consistency. Not an appropriate choice. The dynamic menus cant be handled by a static page.

Application

Master

Web Part Wiki

Page Layout / Instance

Static Page

Lab Answer Key: Designing for User Experience

Exercise 2: Plant Configuration Page


Best Choice: Application Page Key Criteria: Every Site Collection and Administrative Use Comments by page type:
Page Type Dialog Application Comments Possible but where would the dialog be raised from? Best choice. No need for individual content storage only configuration information. Low usage and necessary in every site. Not appropriateconfiguration shouldnt be on every page. Possibility but how would the page be provisioned? Where would it be linked from? Possible with same issues as Web part page, and no need to mix content and code. Theres no content to hold on to for each page, so creating a page layout and instance isnt necessary. Wouldnt support the changes to the configuration required.

Master

Web Part

Wiki

Page Layout / Instance

Static Page

Lab Answer Key: Designing for User Experience

Exercise 3: Employee List


Best Choice: Publishing Page Key Criteria: Consistency, Extra Content Per Plant Comments by page type:
Page Type Dialog Comments Not appropriate due to the amount of information to be displayed. No storage of the per plant descriptive text. The layout doesnt apply to every page in the site. Possible but would require storing content in the CEWP instead of a content page. Possibility but not likely to provide the level of consistency called for in the scenario. The best choice. Page Layouts can have Web parts embedded on them or Web part zones so that the page instances can add Web parts. Not appropriate because code cant run on a static page.

Application Master Web Part

Wiki

Page Layout / Instance

Static Page

Lab Answer Key: Designing for User Experience

Exercise 4: Line Status


Best Choice: Publishing Page/Page Layout Key Criteria: Consistent content display Comments by page type:
Page Type Dialog Comments Not appropriate because the line status doesnt appear over anything. However, possible that this could appear over the plantbut another page type should be selected for the implementation of the dialog. Doesnt manage the storage of content. (i.e. image of line). Developer would have to manually address this need. The formatting doesnt apply to every page in the site, just to the line status page. Wouldnt manage the line content. Would manage the storage of contentbut wouldnt provide the kind of consistency the scenario describes. The best choice. Provides content management and consistency. Not an appropriate choice. The status cant be handled by a static page.

Application

Master

Web Part Wiki

Page Layout / Instance

Static Page

Lab Answer Key: Designing for Data

Module 3
Lab Answer Key: Designing for Data
Contents:
Lab A: Time Tracking Exercise 1: Creating List Views Exercise 2: Adding Indexes Lab B: Invoice Management Exercise 1: Creating an Invoice Content Type Exercise 2: Enabling Content Organization Exercise 3: Testing Content Organization 5 7 9 2 4

Lab Answer Key: Designing for Data

Lab A: Time Tracking


Exercise 1: Creating List Views
Task 1: Create a view for accounting to aggregate time
1. 2. 3. 4. 5. 6. 7. Go to http://localhost/student/module3. Click Time Tracking in the Quick Launch area to open the Time Tracking List. Click the List Tools-List tab. In the Settings group, click List Settings. Scroll down to Columns and click Create column. Enter YearMonth as the column name. In the The type of information in this column is: option list, select Calculated (calculation based on other column). In the Formula box, enter the following: =TEXT(YEAR([Start Date]), "0000")&"-"&TEXT(MONTH([Start Date]), "00") and click OK. This may take awhile as SharePoint updates each record with the result of the calculation. Scroll down to Views and click Create view. Click Standard View.

8. 9.

10. In the View Name box, enter ByMonthByPlant. 11. Select the Make this the default view check box. 12. In the Columns section, clear the Attachments, Title, and YearMonth options. 13. In the Columns section, select the Employee and Hours options. 14. Scroll down and click the plus sign to the left of the Group By section to expand it. 15. In the First group by the column drop-down list, select YearMonth. 16. In the Then group by the column drop-down list, select Plant. 17. Scroll down to the end of the page and click OK. You now have a view grouped by Year-Month and then by plant.

Lab Answer Key: Designing for Data

Task 2: Create a view for aggregating time by employee


1. 2. 3. 4. 5. 6. 7. 8. 9. Click the List Tools-List tab. In the Manage Views group, click Create View. Click Standard View. In the View Name box, enter ByEmployeeByDay. In the Columns section, clear the Employee option. In the Columns section, click Plant and select 1 from the drop-down list to the right. Scroll down and click the plus sign to the left of the Group By section to expand it. In the First group by the column list, select Employee. In the Then group by the column list, select Start Date. Scroll down and click OK.

Task 3: Create a view for aggregating time by plant and by employee


1. 2. 3. 4. 5. 6. 7. 8. 9. Click the List Tools-List tab. In the Manage Views group, click Create View. Click Standard View. In the View Name box, enter ByPlantByEmployee. In the Columns section, clear the Employee option. In the Columns section, select the Start Date option and select 1 from the drop-down list to the right. Scroll down and click the plus sign to the left of the Group By section to expand it. In the First group by the column list, select Plant. In the Then group by the column list, select Employee. Scroll down and click OK.

Lab Answer Key: Designing for Data

Exercise 2: Adding Indexes


Task 1: Add an index by employee and by start date
1. 2. 3. 4. 5. 6. Click the List Tools-List tab. In the Settings group, click List Settings. Scroll down to the Columns section and click Indexed columns. Click Create a new index. In the Primary column for this index list, select Employee. In the Secondary column for this index list, click Start Date. Click Create.

Task 2: Add an index by plant and by employee


1. 2. 3. 4. Click Create a new index. In the Primary column for this index list, select Plant. In the Secondary column for this index list, click Employee. Click Create.

Task 3: Add an index by start date


1. 2. 3. Click Create a new index. In the Primary column for this index list, select Start Date. Click Create.

Lab Answer Key: Designing for Data

Lab B: Invoice Management


Exercise 1: Creating an Invoice Content Type
Task 1: Create the site columns for the invoice content type
1. 2. 3. 4. 5. 6. 7. 8. 9. Click Site Actions-Site Settings. In the Galleries section, click Site columns. Click Create. In the Column name field, enter InvoiceNumber. In the Group section in the Existing Group section, select Contoso and click OK. Click Create. In the Column name field, enter PONumber. In the Group section in the Existing Group section, select Contoso and click OK. Click Create.

10. In the Column name field, enter InvoiceDate. 11. In the The type of information in this column is option list, select Date and Time. 12. In the Group section in the Existing group section, select Contoso. 13. Click OK. 14. Click Create. 15. In the Column name field, enter InvoiceAmount. 16. In the The type of information in this column is option list, select Currency. 17. In the Group section in the Existing group section, select Contoso. 18. Click OK. 19. Click Create. 20. In the Column name field, enter Vendor. 21. In the The type of information in this column is option list, select Lookup (information already on this site).

Lab Answer Key: Designing for Data

22. In the Group section in the Existing group section, select Contoso. 23. In the Additional Column Settings section, select Vendors from the Get information from drop-down list. 24. Click OK.

Task 2: Create the invoice content type


1. 2. 3. 4. 5. 6. 7. 8. 9. In the breadcrumbs, click Site Settings. In the Galleries section, click Site content types. Click Create. In the Name text box, enter Invoice. In the Select parent content type from drop-down list, select Document Content Types. In the Parent Content Type drop-down list, select Document. In the Existing Group drop-down list, select Contoso. Click OK. In the Columns section, click Add from existing site columns.

10. In the Select columns from drop-down list, select Contoso. 11. In the Available columns list box, press the CTRL key and select InvoiceAmount, InvoiceDate, InvoiceNumber, PONumber, and Vendor and click Add. 12. Click OK. 13. In the Columns section, click Invoice Number. 14. In the Column Settings section, select the Required option. 15. In the Columns section, click Vendor. 16. In the Column Settings section, select the Required option. 17. Click OK.

Lab Answer Key: Designing for Data

Exercise 2: Enabling Content Organization


Task 1: Activate content organization
1. 2. 3. Click Site Actions-Site Settings. In the Site Actions, click Manage site features. To the right of Content Organizer, click Activate. Please note that it is marked as Active.

Task 2: Add the invoice content type to the libraries


1. 2. 3. 4. 5. 6. 7. 8. 9. In the Quick launch area, click the Invoices library. Click the Library Tools-Library tab. In the Settings Group, click Library Settings. In the General Settings column, click Advanced settings. In the Allow management of content types? option list, click Yes. Scroll down and click OK. In the Content Types section, click Add from existing site content types. In the Available Site Content Types list box, click Invoice and then click Add. Click OK. In the Quick Launch area, click the Drop Off Library library.

10. Click the Library Tools-Library tab. In the Settings group, click Library Settings. 11. In the Content Types section, click Add from existing site content types. 12. From the Available Site Content Types list box, click Invoice and then click Add. 13. Click OK.

Lab Answer Key: Designing for Data

Task 3: Create a content organizer rule to move invoices


1. 2. 3. 4. 5. 6. 7. 8. Click Site Actions-Site Settings. In the Site Administration section, click Content Organizer Rules. Click Add new item. In the Name box, enter Invoices. In the Submissions Content Type section, in the Type setting, select Invoice. In the Target Location section, click Browse. In the Select Target Location Web page dialog box, click the Invoices library and then click OK. Select the Automatically create a folder for each unique value of a property check box. Select Vendor in the Select a property dropdown. In the Specify the format of the folder name, change the text to be %2 and click OK.

Lab Answer Key: Designing for Data

Exercise 3: Testing Content Organization


Task 1: Test content organization
1. 2. 3. 4. 5. 6. In the Quick Launch area, click the Drop Off Library library. Click the Library Tools-Documents tab. Click Upload Document. Click Browse. Navigate to the folder E:\Student\Module 3\Demo Data \Invoices and select the file Invoice 101.docx. Click OK. In the Drop Off Library Invoice 101.docx dialog box enter the following values: 7. 8. 9. In the InvoiceAmount box, enter 1000. In the InvoiceDate box, enter 07/25/2010. In the InvoiceNumber box, enter 101. In the PONumber box, enter 4321. In the Vendor drop down list, select Fabrikam, Inc. Click Submit.

In the Quick Launch area, click the Invoices library. Notice that a folder exists with the name 12; Fabrikam, Inc. Click on the folder 12; Fabrikam, Inc. Notice that the document exists in the folder.

Lab Answer Key: Designing for Data Capture and Integration

Module 4
Lab Answer Key: Designing for Data Capture and Integration
Contents:
Lab A: Creating External Lists Exercise 1: Connecting to the Data Source Exercise 2: Defining the External Content Types Exercise 3: Defining the External Lists Exercise 4: Setting Security for the Content Types Exercise 5: Defining an Association Lab B: Creating an InfoPath Form Exercise 1: Creating the Calculations Exercise 2: Publishing the Form to a SharePoint Library 9 12 2 3 6 7 8

Lab Answer Key: Designing for Data Capture and Integration

Lab A: Creating External Lists


Exercise 1: Connecting to the Data Source
Task 1: Open SharePoint Designer
1. 2. Open Windows Internet Explorer to http://localhost/student/module4. Click Site Actions, and then click Edit in SharePoint Designer.

Task 2: Create a starting content type


1. 2. 3. In the Site Objects section, click External Content Types. On the ribbon, click External Content Types, and in the New group, click the External Content Type button. In External Content Type Operations, click the Click here to discover external data sources and define operations link.

Task 3: Define the data connection


1. 2. 3. 4. 5. 6. Click the Add Connection button. In the External Data Source Type Selection dialog box, select the SQL Server option, and click OK. In the Database Server field, type .\SHAREPOINT. In the Database Name field, type ContosoERP, and then click OK. Click the plus sign to the left of ContosoERP. Click the plus sign to the left of Tables.

Lab Answer Key: Designing for Data Capture and Integration

Exercise 2: Defining the External Content Types


Task 1: Create the GL Account content type
1. 2. 3. 4. 5. 6. 7. 8. 9. In the breadcrumbs, click New external content type. In the Name field, type GLAccount. In the Display Name field, change the value to GL Account. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link. Right-click the GLAccounts table, and select Create All Operations. Click the Next button. In the Properties section, select the Map to Identifier check box. In the Data Source Elements section, click the AccountNumber option. In the Properties section, select the Show in Picker check box.

10. Click Finish. 11. In the SharePoint Designer title bar, click Save (disk icon) to save and publish the content type.

Task 2: Create the Vendor content type


1. 2. 3. 4. 5. 6. 7. 8. In the Site Objects section, click the External Content Types link. On the ribbon, in the External Content Types tab, in the New group, click the External Content type button. In the Name field, type Vendor. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link. Right-click the Vendors table, and select Create All Operations. Click the Next button. In the Properties section, select the Map to Identifier check box. In the Data Source Elements section, click VendorName.

Lab Answer Key: Designing for Data Capture and Integration

9.

In the Properties section, select the Show in Picker check box.

10. Click Finish. 11. In the SharePoint Designer title bar, click Save (disk icon) to save and publish the content type.

Task 3: Create the Purchase Request Header content type


1. 2. 3. 4. 5. 6. 7. 8. 9. In the Site Objects section, click the External Content Types link. On the ribbon, in the External Content Types tab, in the New group, click the External Content type button. In the Name field, type PurchaseRequestHeader. In the Display Name field, modify the value to Purchase Request Header. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link. Right-click the PurchaseRequestHeader table, and select Create All Operations. Click the Next button. In the Properties section, select the Map to Identifier check box. In the Data Source Elements section, click Request Date.

10. In the Properties section, select the Show in Picker check box. 11. In the Data Source Elements section, click Total Amount. 12. In the Properties section, select the Show in Picker check box. 13. Click Finish. 14. In the SharePoint Designer title bar, click Save (disk icon) to save and publish the content type.

Lab Answer Key: Designing for Data Capture and Integration

Task 4: Create the Purchase Request Line content type


1. 2. 3. 4. 5. 6. 7. 8. 9. In the Site Objects section, click the External Content Types link. On the ribbon, in the External Content Types tab, in the New group, click the External Content type button. In the Name field, type PurchaseRequestLine. In the Display Name field, modify the value to Purchase Request Line. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link. Right-click the PurchaseRequestLine table, and select Create All Operations. Click the Next button. In the Properties section, select the Map to Identifier check box. In the Data Source Elements section, click Description.

10. In the Properties section, select the Show in Picker check box. 11. In the Data Source Elements section, click Amount. 12. In the Properties section, select the Show in Picker check box. 13. Click Finish. 14. In the SharePoint Designer title bar, click Save (disk icon) to save and publish the content type.

Lab Answer Key: Designing for Data Capture and Integration

Exercise 3: Defining the External Lists


Task 1: Create the GL Accounts external list
1. 2. 3. In the Site Objects section, click the External Content Types link. Right-click the GLAccount content type, and select External List. In the Create External List dialog box, type the name GLAccounts in the Name field, and then click OK.

Task 2: Create the Vendors external list


1. 2. 3. In the Site Objects section, click the External Content Types link. Right-click the Vendor content type, and select External List. In the Create External List dialog box, type the name Vendors in the Name field, and then click OK.

Task 3: Create the Purchase Request Header external list


1. 2. 3. In the Site Objects section, click the External Content Types link. Right-click the PurchaseRequestHeader content type, and select External List. In the Create External List dialog box, type the name PurchaseRequestHeaders in the Name field, and then click OK.

Task 4: Create the Purchase Request Line external list


1. 2. 3. In the Site Objects section, click the External Content Types link. Right-click the PurchaseRequestLine content type, and select External List. In the Create External List dialog box, type the name PurchaseRequestLines in the Name field, and then click OK.

Lab Answer Key: Designing for Data Capture and Integration

Exercise 4: Setting Security for the Content Types


Task 1: Go the Business Data Connectivity Service in Central Administration
1. 2. 3. On the Start menu, click All Programs, click Microsoft SharePoint 2010 Products, and then click SharePoint 2010 Central Administration. In the Application Management section, click the Manage service applications link. Click the Business Data Connectivity Service link.

Task 2: Define the security for all content types


1. 2. On the ribbon, in the Edit tab, in the Permissions section, click the Set Metadata Store Permissions button. In the Set Metadata Store Permissions dialog box, in the To add an account, or group, type or select it below and click Add. section, type Users; Administrator, and then click Add. If the Users entry is not found, indicated by the red underline, click on the entry and choose All Authenticated Users. In the section below the name entry, click Users and make sure that in the Permissions for section the Execute and Selectable In Clients options are selected. In the section below the name entry, click Administrator and make sure that in the Permissions for section all of the options are selected. Select the Propagate permissions to all BDC Models, External Systems and External Content Types option, and then click OK.

3.

4. 5.

Lab Answer Key: Designing for Data Capture and Integration

Exercise 5: Defining an Association


Task 1: Open the Purchase Request Line content type
1. 2. 3. Open SharePoint Designer to the http://localhost/student/module4 site. In the Site Objects section, click the External Content Types link. Click the PurchaseRequestLine content type.

Task 2: Create the association


1. 2. 3. 4. 5. 6. 7. 8. 9. On the ribbon, in the External Content Types tab, in the Views group, click the Operations Design View button. Right-click PurchaseRequestHeader, and select New Association. In the Association dialog box, click the Browse button. In the External Content Type Selection, click the PurchaseRequestHeader option, and then click OK. In the field drop-down list, select PurchaseRequestID. Click Next. In the Properties section, select the Map to Identifier check box. Click Next twice. In the Properties section, select the Map to Identifier check box.

10. Click Finish. 11. In the SharePoint Designer title bar, click Save (disk icon) to save and publish the content type.

Lab Answer Key: Designing for Data Capture and Integration

Lab B: Creating an InfoPath Form


Exercise 1: Creating the Calculations
Task 1: Convert Vendor to a drop-down list
1. 2. 3. 4. 5. 6. 7. 8. 9. Open the file E:\Student\Module 4\PurchaseRequestForm-Starter.xsn with Microsoft InfoPath Designer 2010. Right-click the text box to the right of Vendor, and click Change Control Drop-Down List Box. Right-click the Drop-Down list and select Drop-Down List Box Properties. In the List box choices list, select Get choices from an external data source. Click Add. Click Next. In the From where do you want to receive your data? list, select SharePoint library or list, and then click Next. In the Enter the location of the SharePoint site box, type http://sharepoint/student/module4, and then click Next. In the Select a list or library list box, select the Vendors item, and then click Next.

10. In the list box, select the VendorName field. 11. Click Next twice. 12. Click Finish. 13. Click the button to the right of the Display name text box. 14. In the Select a Field or Group dialog box, verify that the VendorName field is selected, and then click OK twice.

10

Lab Answer Key: Designing for Data Capture and Integration

Task 2: Convert GL Account to a drop-down list


1. 2. 3. 4. 5. 6. 7. 8. 9. Right-click the text box under GL Account, and click Change Control DropDown List Box. Right-click the drop-down list box under GL Account, and click Drop-Down list box properties. In the list box choices, select the Get choices from an external data source option. Click Add. Click Next. In the From where do you want to receive your data? list, select SharePoint library or list, and then click Next. In the Enter the location of the SharePoint site text box, type http://sharepoint/student/module4, and then click Next. In the Select a list or library list box, select GLAccounts, and then click Next. Select the check boxes to the left of the AccountNumber and AccountDescription options.

10. Click Next twice. 11. Click Finish, and then click OK.

Task 3: Establish formulas


1. 2. 3. 4. 5. 6. 7. Right-click in the cell under the Extended Amount heading, and select Text Box Properties. Click the Format button. In the Format list, click the Currency symbol, and then click OK. To the right of the value box, click the Fx button. Click the Insert Field or Group button. Double-click the Quantity field. Type a multiplication symbol (*).

Lab Answer Key: Designing for Data Capture and Integration

11

8. 9.

Click the Insert Field or Group button. Double-click the Amount field.

10. Click OK twice. 11. Right-click the Total amount field in the header, and then select Text Box Properties. 12. To the right of the value text box, click the Fx button. 13. Click the Insert Function button. 14. In the Categories list box, select Math. 15. In the Functions list box, double-click sum. 16. Double-click the text double-click to insert field. 17. Expand PurchaseRequestLines and Lines, double-click ExtendedAmount, and then click OK twice.

12

Lab Answer Key: Designing for Data Capture and Integration

Exercise 2: Publishing the Form to a SharePoint Library


Task 1: Decide whether to publish the form as a content type or as a form
Because this is a purchase request that will likely be used across site collections for different divisions, it is appropriate to consider publishing the form as a content type. In general, if you are going to reuse the form across sites, you want to create it as a content type.

Task 2: Publish the form


1. 2. 3. 4. 5. 6. 7. 8. 9. On the ribbon, click the File tab. In the left-hand column, click the Publish option. Click the SharePoint Server button. If prompted to save the form template before publishing, click OK. Save the form to E:\Student\Module 4\PurchaseRequest.xsn. In the publishing wizard that appears, type http://sharepoint/student/module4, and then click Next. In the What do you want to create or modify? list, select Form Library, and then click Next twice. Type the name for the form library as Purchase Requests, and then click Next twice. Click the Publish button. Click the Close button.

Lab Answer Key: Designing Artifacts

Module 5
Lab Answer Key: Designing Artifacts
Contents:
Lab A: Incident Response Site Exercise 1: Evaluating the Requirements Exercise 2: Designing the Solution Lab B: Expense Reports Exercise 1: Evaluating the Requirements Exercise 2: Designing the Solution 8 14 2 6

Lab Answer Key: Designing Artifacts

Lab A: Incident Response Site


Exercise 1: Evaluating the Requirements
Task 1: Identify the key requirements
Implementation of the system in 90 days. Incident response pages that can be printed. Select from a set of procedures for an incident. Incident responses can be either unique to a plant or shared across the organization. Two incident workflows. Notification of changes to procedures or incident response plans.

Task 2: Evaluate requirements against objective, precise, measurable, and understandable criteria
Use the following legend to evaluate the requirement against these parameters: + = Yes 0 = Needs Information - = No

Lab Answer Key: Designing Artifacts

Requirement Implementation in 90 days

Understandable

Measurable

Objective

Precise

Suggestions Ask which parts of the system need to be functional in order to pass the government review. Clarify what the printed page has to look like. Does it have to convey the key information or does it have to fit a specific format? Can an incident response be saved with no procedures? Are all procedures centralized or can a plant have their own procedures? How do you control which responses are shared for a plant from the corporate responses and which ones are unique? What are the reminder intervals? What happens if a response is rejected? Who is notified? When are they notified?

Incident response pages that can be printed

Select a set of procedures

Incident responses can be unique or shared

Two incident workflows

Notification of changes to procedures or incident response

Lab Answer Key: Designing Artifacts

Task 3: Evaluate requirement against responsiveness, skills, scale, and rate of change
Use the following legend to evaluate the requirement against these parameters: + = Yes 0 = Needs Information - = No
Responsiveness Rate of Change

Requirement Implementation in 90 days

Scale

Skills

Suggestions The skills of the project team members would likely be clear if you worked for the organization but arent clear here. The rate at which the procedures change wasnt specified. The requirements make it clear that this has to be self-service.

Incident response pages that can be printed Select a set of procedures

The requirements are clear about the ability to select procedures and its clear that the safety officer should be able to perform this. However, its not made clear how many procedures theyll select. Nor is it clear the frequency with which the procedures that apply to when an incident response is changed.

Lab Answer Key: Designing Artifacts

(continued)
Responsiveness Rate of Change

Requirement Incident responses can be unique or shared

Scale

Skills

Suggestions The key missing element is an understanding of the skills of those who will be setting up the incident responses. Inheritance is a complex topic, so it will be important to understand how much the system should make this easier. The rate of change between unique and shared incident responses isnt made clear. The reminder frequency (if any) isnt called out. The skills are specified by the fact that the requirements call out senior management, and the scale is missing. The requirements dont define the number of incidents in a typical year. Nor do the requirements call out an expected frequency of change for the workflows. The requirements arent clear on the number of changes (rate of change) or the responsiveness window after a change is approved.

Two incident workflows

Notification of changes to procedures or incident response

Lab Answer Key: Designing Artifacts

Exercise 2: Designing the Solution


Task 1: Create a high-level plan for delivering the solution
The goal here isnt to create a final plan, but rather a draft design to see what does and doesnt work well. Based on the requirements, its expected that the following components are necessary: A site template. Although the sites are unique and may need to be targeted to additional features, its quite likely that theyll all be located in one hierarchy. Theres a relatively fixed number of sites (one for each plant) so a site definition isnt necessary. Four content types. Content types include one for the procedures, one for the incident response plan, and two for incident occurrences. One of the incident occurrences is the critical occurrence and the other is the standard. The critical likely derives from the standard. A page layout for incident response plans. The page layout should include a body for describing the type of incident as well as a summary links field controlor custom equivalentthat can be used to maintain the list of procedures associated with the content type. (Recall that field controls should be used to store contents rather than Web Parts.) A page and associated Web Parts for locating incident response plans. The floor supervisor needs to be able to locate an incident plan quickly. A custom Web Part for managing which incident response plans are shared and which are unique. A workflow for standard incident occurrences. A workflow for critical incident occurrences.

Lab Answer Key: Designing Artifacts

Task 2: Create a set of clarifying questions that you would ask to further refine and validate your proposed solution
The primary suggested questions are included in the preceding table for evaluation. However, the following questions may also be asked to help evaluate the proposed solution: Is it acceptable to have these incident response plan sites located in the same hierarchy? How do you make the decision between a critical incident and a standard incident? Its clear that all injuries are considered critical, but how much product makes an incident critical? Should there be a separate category for product damage and worker injury? Is it acceptable for the safety officer to follow the procedures for printing, or does the system need to allow for the printing of a booklet every 6 months that includes all of the incident plans for a plant? How is it determined when its time to change the workflow, and who is responsible for changing it?

Lab Answer Key: Designing Artifacts

Lab B: Expense Reports


Exercise 1: Evaluating the Requirements
Task 1: Identify the key requirements
There are four key types of expense reports: Vendor Customer Training Miscellaneous

The approval process for training and miscellaneous expenses requires a workflow that is routed through the users manager and possibly through the users managers manager. The approval process for vendors is a custom task and gets routed through the production manager. The approval process for customers is a custom task and gets routed through the sales manager. Expense reports must capture: Total amount Employee

In addition to the standard fields, Vendor expense reports must capture: Vendor for expense Dates of travel

In addition to the standard fields, Customer expense reports must capture: Customer for expense Dates of travel

Lab Answer Key: Designing Artifacts

In addition to the standard fields, Training expense reports must capture training for which the expense was incurred. A reporting system must be capable of reporting: By expense report category By employee By vendor By customer

Security requirements are totally missing and need to be specified.

10

Lab Answer Key: Designing Artifacts

Task 2: Evaluate requirements against objective, precise, measurable, and understandable criteria
Use the following legend to evaluate the requirement against these parameters: + = Yes 0 = Needs Information - = No
Understandable
+

Requirement Expense Report types

Measurable

Objective

Precise

Suggestions The only ambiguity that might be questionable would be expense reports for vendors or customers that arent related to a trip. For instance, the purchase of a top vendor award. The approval process is described generically. Exception conditions, like the CEO who doesnt have a manager and where the manager approval amounts will be retrieved from, arent covered. Theres no mention of guidance for the managers on approval/rejection and no discussion of potential automatic approval. The key piece of missing data is during the process, when does the approval get routed to the production manager, and what happens if the production manager is the direct manager of the person submitting the report?

Approval process

Approval process Vendor

Lab Answer Key: Designing Artifacts

11

(continued)
Understandable +

Requirement Approval Process Customer

Measurable

Objective

Precise

Suggestions The key piece of missing data is the same as for vendor, except that were talking about the sales manager. This is clear. However, the relatively small set of fields would generally indicate a need to probe for other questions like totals by category. The missing information is how the vendor will be recorded. Will this be by vendor ID or by name? Will the user be expected to enter this information manually or will the system need to ensure that this value is correct? See Capture fields for Vendor.

Capture fields

Capture fields Vendor

Capture fields Customer Capture fields Training

Is the list of training opportunities a constrained list? Where will this list come from? The formats for the report arent covered, nor the details for the fields to be displayed in the report. No security requirements are specified, but its quite likely there are requirements that are not expressed.

Reporting

Security

12

Lab Answer Key: Designing Artifacts

Task 3: Evaluate the requirement against responsiveness, skills, scale, and rate of change
Use the following legend to evaluate the requirement against these parameters: + = Yes 0 = Needs Information - = No
Responsiveness Rate of Change
-

Requirement Expense Report types

Scale

Skills

Suggestions Its not clear how many expense reports are processed for a timeframe. Nor is it clear how frequently the expense report policies change, or how frequently manager approval amounts change, and so forth. Its unclear how frequently the approvers need to be reminded they have a pending approval. It also isnt clear how quickly they need to be notified. As with the expense report types, the scale (number of approvals) and the rate of change are unknown. See Approval process.

Approval process

Approval process Vendor Approval Process Customer Capture fields

See Approval process.

Its unclear how frequently accounting may change the number of fields being captured.

Lab Answer Key: Designing Artifacts

13

(continued)
Responsiveness Rate of Change -

Requirement Capture fields Vendor

Scale

Skills

Suggestions In addition to the issues for Capture fields, its also unclear how the vendor will be identified. See Capture fieldsVendor.

Capture fields Customer Capture fields Training Reporting

See Capture fieldsVendor.

The responsiveness for the reports, the skills of the report operator, the number of times the reports will be run (scale), or the frequency of changes (rate of change) are all unknown. Since none of this was specified in the requirements, clarification is required on every aspect.

Security

14

Lab Answer Key: Designing Artifacts

Exercise 2: Designing the Solution


Task 1: Create a high-level plan for delivering the solution
The key solution components might be: A set of InfoPath forms for the expense report itself. The form can calculate total amount and could be used to query a data source for vendor, customer, and training opportunities. The form also supports attachments so receipts could be scanned and attached. A workflow including a custom workflow action to retrieve a managers approval amounts and the components necessary to secure the item once those requirements are understood. A document library to contain all expense reports in folders by the employees ID. A set of content organizer rules to take expense reports dropped in a folder and route them to the right folder. A set of list views for the approval document library, which organizes and groups the results based on the criteria specified.

The proposed content hierarchy would be: Expense Report Trip Expense Report Vendor Expense Report Customer Expense Report

Training Expense Report

The miscellaneous expense report would use the base type. The base type would define fields for the employee and total amount. A trip expense report would be defined with fields for starting and ending dates. The vendor expense report would add the vendor field and the customer expense report would add the customer field. The training expense report would add a training field. Workflows would be attached at the expense report type and overridden or replaced at the vendor expense report and customer expense report level. This arrangement allows for new expense report types with the same basic structuresuch as prospects and vendor evaluation.

Lab Answer Key: Designing Artifacts

15

Task 2: Create a set of clarifying questions that you would ask to further refine and validate your proposed solution
Most of the clarifying questions appear in the preceding requirements, however, several specific questions about the proposed solution could be: Might you have a customer or vendor expense report that doesnt include a trip? Could you have more types of expense reports that you want to track which do involve trips? Do the users know how to use InfoPath well enough that they could fill out expense reports based on InfoPath?

Lab Answer Key: Designing Processing Solutions

Module 6
Lab Answer Key: Designing Processing Solutions
Contents:
Lab A: Designing an Engineering System Exercise 1: Evaluating Client Capabilities and Requirements Exercise 2: Evaluating Sandbox Capabilities and Requirements Exercise 3: Evaluating Farm Deployment Capabilities and Requirements Lab B: Creating a Sensor Report Exercise 1: Designing Data Access for Sensor Data Exercise 2: Designing a Processing Solution for the Report Exercise 3: Designing a Processing Solution for the Approval 6 6 7 2 4 5

Lab Answer Key: Designing Processing Solutions

Lab A: Designing an Engineering System


Exercise 1: Evaluating Client Capabilities and Requirements
Task 1: Evaluate the AJAX/JavaScript client
Some of the key benefits to the JavaScript client are the following: It doesnt require administrative access to the system. The processing load is transferred to the client from the server. It doesnt require anything else on the client.

Some of the key drawbacks of a JavaScript-based client are the following: JavaScript can be turned off by the user or broken by other components of the page (reliability). JavaScript performance isnt optimal because of the language design (performance). JavaScript is, relatively speaking, considered to be more difficult to debug than other programming languages because it isnt type safe (maintenance). The engineering developers are unlikely to be able to adapt to JavaScript (weakly typed language) from C++ (strongly typed language) quickly and easily (startup time). Every client solution would require that the data be transmitted to the client, which may be an issue depending on connectivity.

Lab Answer Key: Designing Processing Solutions

Task 2: Evaluate the Silverlight client


Some of the key benefits to the Microsoft Silverlight client are the following: It doesnt require administrative access to the system. The processing load is transferred to the client from the server.

Some of the key drawbacks to a Silverlight client are the following: It requires the installation of the Silverlight client. Every client solution would require that the data be transmitted to the client, which may be an issue depending on connectivity.

Task 3: Evaluate other types of external clients


Some of the key benefits to another external client are the following: The amount of retraining of the developers or reworking of the algorithms is limited to accessing the data from Microsoft SharePoint. Processing work isnt performed on the SharePoint farm.

Some of the key drawbacks to another external client are the following: There is higher operational complexity with two (or more) interrelated systems. Type-safe checking and error handling are likely to be difficult, complex, or time consuming.

Lab Answer Key: Designing Processing Solutions

Exercise 2: Evaluating Sandbox Capabilities and Requirements


Task 1: Evaluate sandbox capabilities and limitations
Some of the capabilities and limitations of the sandbox are the following: Sandboxed solutions must complete in 60 seconds, so calculations must be completed by then. Sandboxed solutions can process data only inside the site collection, so all of the data for the algorithm must exist in the site collection.

The sandboxed solution can be deployed safely because of the protection and monitoring offered by the sandbox.

Task 2: Evaluate development skills


Because C# is a direct descendant of C++, the skills of the developers are likely to easily transfer to C#. SharePoint-specific skills will be needed for the Web Part development and for developing an understanding of SharePoint packaging. The Microsoft Visual Studio 2010 tools can handle the mechanics of packaging and deploying to the server.

Task 3: Evaluate which requirements might get in the way


The key item that may be a problem is the processing time for the analysis. Theres a hard limit of 60 seconds of execution time for a sandboxed solution, which can be changed. If analysis takes more than 60 seconds to execute, a sandboxed solution wont work. Additionally, if the data estimate is off, the query may be throttled and would require additional code. Sandboxed code cant elevate privileges to get a larger query-throttling limit.

Lab Answer Key: Designing Processing Solutions

Exercise 3: Evaluating Farm Deployment Capabilities and Requirements


Task 1: Evaluate farm deployment capabilities
Farm deployment is an unrestricted development and deployment model. There are no relevant limitations.

Task 2: Evaluate farm deployment limitations and requirements


Farm deployment requires full access to the server, so this couldnt (shouldnt) be done directly by the engineering department. Further, farm-deployed solution code can act in a way that hurts performance or even crashes the servers. Its not recommended to deploy untrusted, unreviewed code to farm level.

Lab Answer Key: Designing Processing Solutions

Lab B: Creating a Sensor Report


Exercise 1: Designing Data Access for Sensor Data
Task 1: Evaluate the use of BCS
To use BCS to get to the data you would have to create a custom Microsoft .NET Framework assembly connector. This task is not insurmountable. However, the .NET assembly connector would have to manage the process of indexing lookups and aggregation. This work is likely to be expensive and is probably not an appropriate solution.

Task 2: Evaluate a data import application


Because this is a reporting application, real-time access to the data isnt required. Thus, a data import application can move the data from the .csv files to a database or directly into SharePoint. A data import application, potentially written as a timer job, would be a good solution. If the output of the data import is a database, you can use BCS to access the external database.

Exercise 2: Designing a Processing Solution for the Report


Task 1: Evaluate list views
List views arent enough to do the report because the report requires descriptive text and analysis as well. However, if the computations arent very complex, or they can be easily applied to the data after they are exported to a worksheet, you can use list views as the basis for the report. That said, this approach works best for infrequent reporting. Monthly reporting may mean that a more automated solution is best.

Lab Answer Key: Designing Processing Solutions

Task 2: Evaluate Access


Microsoft Access has a report generation engine in it that you can use to create reports against SharePoint data. The engine is feature rich and can, generally speaking, display data any way that is necessary. Coupled with the ability to post process data in the Access database, the data at the core of the report should be easy to process each month. Theres still a need to include descriptive text, which would have to be done after the core of the report is generated. Because Access can export reports in a number of formats, including in Microsoft Word format, the report can be exported and the descriptive text added.

Task 3: Evaluate custom-coded solution options


You can use several technologies including Microsoft SQL Server Reporting Services and the OpenXml software development kit (SDK) to create a custom report. However, the cost in developing a solution like this may be more than its worth for a monthly report.

Exercise 3: Designing a Processing Solution for the Approval


Task 1: Evaluate SharePoint Designer workflows
SharePoint Designer supports straight-through flows without loops or restarting. However, SharePoint Designer also supports specific approval tasks that handle retries, reminders, and so forth. It appears that SharePoint Designer may be able to meet the needs of this solutionand at a relatively low cost. If specific requirements arise that cant be handled, it may be possible to extend SharePoint Designer with additional activities.

Task 2: Evaluate Visual Studio workflows


You can absolutely use Visual Studio to create a workflow solution for the report approval; however, the costs likely are substantially higher than the costs of doing the work with SharePoint Designer.

Lab Answer Key: Designing Packaging

Module 7
Lab Answer Key: Designing Packaging
Contents:
Lab A: Building a Business Document Solution Exercise 1: Designing a Solution Exercise 2: Creating the Final Solution Lab B: Working with Dependencies Exercise 1: Creating a Common Assembly Exercise 2: Creating a Dependent Solution 8 9 2 4

Lab Answer Key: Designing Packaging

Lab A: Building a Business Document Solution


Exercise 1: Designing a Solution
Task 1: Get more details
The core intent of the first task is to help you see the wide variety of options that can come into play even with a very simple user scenario. The following questions can help you determine how to frame the final solution: What is the platformMicrosoft SharePoint Foundation or Microsoft SharePoint Server (MSS)? Purpose of question. The underlying product determines which set of features can be used. If you are using SharePoint Server, you can begin to use document sets and the content type hub.

Can there be more than one certification package library (CPL) per site? Purpose of question. Its important to understand the business logic and governance requirements.

Is there a naming convention for the list? Purpose of question. You understand that a CPL is a company standard. However, does the name of each CPL also need to follow a standard? If so, how is that controlled?

Have the content types been defined elsewhere? Purpose of question. Try to use existing work, especially when it comes to site columns and content types. You do not want to create a duplicate content type. The offshoot of this question is deciding whether you need to set up a common set of content types that can be used by others.

Do any of the content type fields require additional setup work? Purpose of question. The initialization of some fields may require custom code, which means you need to create a feature receiver or some other setup code.

Lab Answer Key: Designing Packaging

Can there be more than one certification package type per list? Purpose of question. Multiple content types on a list are useful. However, multiple types introduce opportunities for users to apply the wrong one. You may also need to be concerned with default upload behavior where the first content type is applied to an uploaded document.

How often will certification package lists need to be created? Purpose of question. Will certification package list creation be a task you repeat many times over? If so, maybe the final design should include a programmatic provisioning mechanism that is triggered by workflow, a timer job, custom data, or something similar.

What is the intended livelihood of the data after it is created? Purpose of question. It is really important to understand how long the data is going to live or needs to be retrieved. This in turn affects your final design for both upgrade and administrative archival.

Task 2: Review answers, and finalize the design


The interview answers provided should help illustrate what needs to be built. They serve as the blueprint for the remainder of the lab. You will build: One solution package containing two features: Feature: CPL_ContentTypes Feature: CPL_ListDefinition

The CPL_ContentTypes Feature has the following characteristics: It is hidden. It contains one content type that inherits from the Document content type.

Lab Answer Key: Designing Packaging

Exercise 2: Creating the Final Solution


Task 1: Create a Visual Studio 2010 project
1. Click Start, point to All Programs, click Microsoft Visual Studio 2010, and then click Microsoft Visual Studio 2010. Microsoft Visual Studio 2010 opens. 2. 3. 4. 5. Click File, point to New, and then click Project. In the New Project dialog box, click SharePoint under Installed Templates, and then click Empty SharePoint Project. Specify the name of the project as Contoso.CertificationPackageList. Clear the Create directory for solution check box. Click OK. The SharePoint Customization Wizard appears. 6. 7. Select Deploy as a sandboxed solution. Click Finish.

Task 2: Add a content type to the project


1. 2. 3. Open Solution Explorer and right-click the project, point to Add, and then click New Item. Select Content Type as the item type. Specify the name of the content type as Certification Package Documents, and click Add. It takes some time for the SharePoint Customization Wizard to open. On the Choose Content Type Settings page, select Document as the type from which to inherit. Click Finish.

4. 5.

Task 3: Create a site-scoped feature for the content type


1. 2. Right-click the Features node, and click Add Feature. Specify the title and description as Certification Package Content Types and Content types for Contoso Certification Packages, respectively.

Lab Answer Key: Designing Packaging

3. 4.

Select Site from the Scope drop-down list. In the Items in the Solution list box, select Content Type, and click the button with the right angle bracket (>). The content type will now appear in the Items in the Feature list box. Click Save. In Solution Explorer, rename the newly created feature Feature2 CPL_ContentTypes. Right-click the feature, and click View Designer. In the Properties pane, change the Is Hidden value to True.

5. 6. 7. 8.

Note: If the Properties pane is not open, press F4.

9.

Click Save.

Task 4: Add a list definition


1. 2. 3. 4. In Solution Explorer, right-click the Contoso.CertificationPackageList project, point to Add, and then select New Item. Select List Definition From Content Type as the item type. Specify the name of the list definition as CPL_ListDefinition, and click Add. On the Choose List Definition Settings page, specify the display name of the list definition as Contoso Certification Package List. Notice that the content type created in Task 2 is selected. Clear the Add a list instance for this list definition check box. Click Finish.

5.

Task 5: Create a Web-scoped feature for the list definition


1. 2. In Solution Explorer, right-click the Features node, and select Add Feature. Specify a title and description as Contoso Certification Package List and Demo List Definition for Module 7, respectively.

Lab Answer Key: Designing Packaging

3. 4.

Notice that the scope is selected as Web by default. In the Items in the Solution list box, select List Definition, and click the button with the right angle bracket (>). The list definition appears in the Items in the Feature list box. Click Save. In Solution Explorer, rename the newly created feature Feature2 CPL_ListDefinition.

5. 6.

Task 6: Ensure that the CPL_ContentTypes feature contains only one element
1. 2. In Solution Explorer, right-click CPL_ContentTypes, and click View Designer. Notice that there is only one content type in the Items in the Feature list box.

Note: It is now safe to remove the Feature1 feature.

Task 7: Deploy and verify


1. 2. 3. 4. 5. 6. 7. 8. Press F5. This opens the SharePoint site. Navigate to Site Actions | Site Settings. Click Manage site features under Site Actions. Verify that the Certification Package Content Types (CPL Content Types) feature is not listed (because you marked it as hidden). Verify that the Contoso Certification Package List is listed and activated. Click Site Actions | More Options. Locate the Contoso Certification Package List and specify the name as Packages, and then click Create. After the list is created, select Library Settings in the ribbon.

Lab Answer Key: Designing Packaging

9.

Click Advanced Settings.

10. Select the Yes option in Allow management of content types, and then click OK. 11. On the List Settings page, do the following: Verify that the Contoso.CertificationPackageList - Certification Package Documents content type is associated with the list.

Results: After this exercise, you should be able to see how different design choices can result in different packaging designs. A few subtle changes here and there, and this design could have had a different layout and end-user experience.

Lab Answer Key: Designing Packaging

Lab B: Working with Dependencies


Exercise 1: Creating a Common Assembly
Task 1: Create a new Visual Studio project
1. 2. 3. 4. 5. 6. 7. 8. In Microsoft Visual Studio 2010, click File, point to New, and then click Project. In the New Project dialog box, select SharePoint under Installed Templates, and then select Empty SharePoint Project. Specify the name of the project as Contoso.DemoApplication.Common and click OK. The SharePoint Customization Wizard appears. In the SharePoint Customization Wizard, select the Deploy as a farm solution option. Click Finish. Right-click the project, point to Add, and then click Class. In the Add New Item dialog box, specify the name of the class as Utility.cs and click Add. Add the following code:
using System; [assembly:System.Security.AllowPartiallyTrustedCallers] namespace Contoso.DemoApplication.Common { public class Utility { private Utility() { } // End of constructor public static string GetDataFromSomewhere() { return "The current time is " + DateTime.Now.ToUniversalTime().ToString("yyyy/MM/dd - HH:mm:ss 'GMT'", System.Globalization.CultureInfo.InvariantCulture); } // End of GetDataFromSomewhere } } // End of Utility class

// End of the Contoso.DemoApplication.Common namespace

Lab Answer Key: Designing Packaging

Exercise 2: Creating a Dependent Solution


Task 1: Add a sandboxed project
1. 2. 3. In Solution Explorer, right-click the solution, point to Add, and then click New Project. In the New Project dialog box, select SharePoint under Installed Templates, and then select Empty SharePoint Project. Specify the name of the project as Contoso.DemoApplication.Sandboxed and click OK. The SharePoint Customization Wizard appears.

Note: Note that the Deploy as a sandboxed solution option is in the SharePoint Customization Wizard.

4. 5. 6. 7. 8.

Click Finish. In the Sandboxed project, right-click References and then click Add Reference. In the Add Reference dialog, click the Projects tab and then select the Contoso.DemoApplication.Common project. Click OK. Right-click the project, point to Add, and then click New Item. In the templates displayed, click Web Part, specify the name of the Web part as CustomDataDisplay, and then click Add.

10

Lab Answer Key: Designing Packaging

9.

Add the following code to the file:


using System.Web; using System.Web.UI; using System.Web.UI.WebControls.WebParts; namespace Contoso.DemoApplication.Sandboxed.CustomDataDisplay { public class CustomDataDisplay : WebPart { protected override void CreateChildControls(){ this.Controls.Add(new LiteralControl(HttpUtility.HtmlEncode(DemoApplication.Common.Utili ty.GetDataFromSomewhere()))); } // End of CreateChildControls } // End of CustomDataDisplay class

} // End of the Contoso.DemoApplication.Sandboxed.CustomDataDisplay namespace

10. Open Package Designer for the farm solution and click Manifest. Record the solution ID. You use this in the next step. 11. Open Package Designer for the sandboxed solution. 12. Click Manifest. 13. Click Edit Options. This opens the advanced text box where you can enter custom XML that will be integrated with other settings. Visual Studio merges all information to create a composite solution manifest. 14. Add the following XML to the Manifest Template text box:
<?xml version="1.0" encoding="utf-8"?> <Solution xmlns="http://schemas.microsoft.com/sharepoint/"> <ActivationDependencies> <ActivationDependency SolutionId="ADD THE ID FROM THE FARM SOLUTION"/> </ActivationDependencies> </Solution>

Lab Answer Key: Designing Packaging

11

Task 2: Verify functionality


1. 2. 3. 4. 5. 6. Right-click the Common project, and click Deploy. Right-click the Sandboxed project, and click Deploy. Open Internet Explorer, and navigate to http://sharepoint/student/module7. Enter username sharepoint\administrator with password P@ssw0rd. On the page, insert the CustomDataDisplay Web part. Verify that your sandboxed Web Part is operational. The sandboxed Web part should provide a rendering similar to the following:

Task 3: Remove the farm solution


1. 2. 3. 4. In Visual Studio, right-click the Common project, and click Retract. Navigate to the page that contains the Web Part. Refresh the page and verify. Verify that the Web Part no longer works. You should see the following:

Note: You see Show Error Details only if Callstack is set to True in the Web applications Web.config file. You should set the value to True only in development environments.

12

Lab Answer Key: Designing Packaging

Note: No error messages are shown during the removal of the farm solution. Dependencies are not checked. Therefore, you can end up in a scenario where previously working code breaks because the dependency has been removed.

Task 4: Remove the sandboxed solution and reinstall


1. 2. In Visual Studio, right-click the Sandboxed project, and click Retract. Right-click the Sandboxed project, and click Deploy.

Results: After this exercise, you will have created a dependency between two solutions, verified that a properly sequenced install is possible, verified that the dependent code breaks when the parent solution is removed, verified that SharePoint did not stop removal of the parent solution, and verified installation was prevented when an attempt to install the dependent solution was made without the parent solution.

Lab Answer Key: Designing a Development Strategy

Module 8
Lab Answer Key: Designing a Development Strategy
Contents:
Lab A: Team-Based Logging and Configuration Exercise 1: Appraising the List-Based Configuration Exercise 2: Using a SharePoint List-Based Configuration Exercise 3: Using SharePoint List-Based Logging Exercise 4: Configuring the Logging Level Lab B: Operational Logging Exercise 1: Adding Logging to SharePoint ULS 18 2 3 9 15

Lab Answer Key: Designing a Development Strategy

Lab A: Team-Based Logging and Configuration


Exercise 1: Appraising the List-Based Configuration
Task 1: Review the options
In this exercise, students will review the configuration options available and provide pros and cons for each approach for this scenario.

Possible Solutions
SPList provides a good solution in terms of: Security Line manager read/write Team members Read only Easily extendable to multiple configurations Can be used by custom code/web parts (example) Can use used by OOB functionality

Lab Answer Key: Designing a Development Strategy

Exercise 2: Using a SharePoint List-Based Configuration


Task 1: Create a Visual Studio 2010 project
1. 2. 3. 4. Start Visual Studio 2010. Click File, point to New, and then click Project. In the New Project dialog box, click SharePoint under Installed Templates, and then click Empty SharePoint Project. Specify the name of the project as Contoso.PlantTargets. Clear the Create directory for solution checkbox and click OK. The SharePoint Customization Wizard appears. In the SharePoint Customization Wizard, specify the local site to use for debugging as http://sharepoint/student/module8/ and select Deploy as a sandboxed solution Click Finish.

5.

6.

Task 2: Add a Constants file to the project


1. 2. 3. Right-click the project, point to Add, and then click Class. In the Add New Item dialog box, specify the name of the class as Constants.cs and click Add. Add the following code:
namespace Contoso.PlantTargets { class Constants { public const string ConfigurationList = "ConfigurationList"; public const string TargetForWeekFieldName = "ThisWeeksTarget"; } }

4.

Click Save.

Lab Answer Key: Designing a Development Strategy

Task 3: Create Viewer Web Part


1. 2. 3. Right-click the project, point to Add, and then click New Item. In the templates displayed, click Web Part, specify the name of the Web part as PlantTargetMonitor, and then click Add. Add the following code to the file, replacing only the CreateChildControls method:
protected override void CreateChildControls() { var label = new Label { Text = string.Format("Current target for week : {0}", GetCurrentTargetForWeek()) }; Controls.Add(label); } private int? GetCurrentTargetForWeek() { var currentSite = SPContext.Current.Web; var configList = currentSite.Lists[Constants.ConfigurationList]; if (configList.ItemCount == 0) { return null; } //Use a query rather than List.Items[] especially on large lists var query = new SPQuery { Query = "", RowLimit = 1 }; var items = configList.GetItems(query); var configItem = items[0]; return Convert.ToInt32(configItem[Constants.TargetForWeekFieldName]); }

4.

Click Save.

Lab Answer Key: Designing a Development Strategy

Task 4: Create Setter Web Part


1. 2. 3. Right-click the project, point to Add, and then click New Item. In the templates displayed, click Web Part, specify the name of the Web part as PlantMonitorSetter, and then click Add. Add the following code to the file, replacing only the CreateChildControls method:
private TextBox _txtCurrentTarget; protected override void CreateChildControls() { var currentTargetLabel = new Label { Text = "Please enter target for current week." }; Controls.Add(currentTargetLabel); _txtCurrentTarget = new TextBox(); Controls.Add(_txtCurrentTarget); Button btnSubmitCurrentTarget = new Button { Text = "Set Target for Current Week" }; btnSubmitCurrentTarget.Click += new EventHandler(BtnSubmitCurrentTargetClick); Controls.Add(btnSubmitCurrentTarget); base.CreateChildControls(); } private void BtnSubmitCurrentTargetClick(object sender, EventArgs e) { var currentWeb = SPContext.Current.Web; var configList = currentWeb.Lists[Constants.ConfigurationList]; if (configList.ItemCount == 0) { var spListItem = configList.AddItem(); spListItem[Constants.TargetForWeekFieldName] = Convert.ToInt32(_txtCurrentTarget.Text); spListItem.Update(); }

(Code continued on the following page.)

Lab Answer Key: Designing a Development Strategy

else { var query = new SPQuery { Query = "", RowLimit = 1 }; var items = configList.GetItems(query); var existingListItem = items[0]; existingListItem[Constants.TargetForWeekFieldName] = Convert.ToInt32(_txtCurrentTarget.Text); existingListItem.Update(); } }

4.

Click Save.

Task 5: Rename Feature


1. 2. 3. In Solution Explorer, expand the Features folder. Right-click the Feature1 and select Rename. Name the feature definition as PlantTargets.

Task 6: Add Feature Receiver


1. 2. 3. Right-click the PlantTargets Feature node. Select Add Event Receiver. Open the newly created PlantTargets.EventReceiver.cs file.

Lab Answer Key: Designing a Development Strategy

4.

Add the following code to the file, replacing only the commented out FeatureActivated method:
public override void FeatureActivated(SPFeatureReceiverProperties properties) { //Add a configuration list to root web var sc = properties.Feature.Parent as SPSite; var site = sc.RootWeb; var list = site.Lists.TryGetList(Constants.ConfigurationList); if (list == null) { Guid listId = site.Lists.Add(Constants.ConfigurationList, "", SPListTemplateType.GenericList); list = site.Lists[listId]; list.Fields.Add(Constants.TargetForWeekFieldName, SPFieldType.Integer, true); list.Update(); var configItem = list.AddItem(); configItem["Title"] = "Configuration - Do Not Delete"; configItem[Constants.TargetForWeekFieldName] = 1; configItem.Update(); } }

5.

Add the following code to the file, replacing only the commented out FeatureDeActivating method:
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { //remove the list - Consider if you should do this or not var sc = properties.Feature.Parent as SPSite; var site = sc.RootWeb; var list = site.Lists.TryGetList(Constants.ConfigurationList); if (list != null) list.Delete(); }

6.

Click Save.

Lab Answer Key: Designing a Development Strategy

Task 7: Deploy and verify


1. 2. Press F5 to deploy the solution. Navigate to Lists. 3. 4. 5. 6. 7. 8. 9. Verify ConfigurationList has been created. Verify it has a default value.

Return to Home Page. Click Page Tab and then click Edit Page. In the Left Web part zone, click Add a Web Part. In the Categories list, click Custom. Notice that PlantMonitorSetter and PlanTargetMonitor Web Parts are listed. Select PlantMonitorSetter and click Add. Select PlantTargetMonitor and click Add. Enter a target value in the Setter Web part.

10. Click the Set Target for Current Week button. Verify the value is shown in the Monitor Web partPart.

11. Close Windows Internet Explorer.

Lab Answer Key: Designing a Development Strategy

Exercise 3: Using SharePoint List-Based Logging


Task 1: Add additional constants
1. 2. 3. Open the solution from Exercise 2, Contoso.PlantTargets. Open the Constants.cs file. Add the following code:
public const string SPLogList = "LogList"; public const string LogLine = "LogLine"; public const string DateAndTimeOfLog = "DateAndTimeOfLog";

4.

Click Save.

Task 2: Add logging list


1. 2. Expand the PlantTargets Feature. Open the PlantTargets.EventReceiver.cs file.

10

Lab Answer Key: Designing a Development Strategy

3.

Add the following code to the file, replacing the FeatureActivated and FeatureDeactivating methods:
public override void FeatureActivated(SPFeatureReceiverProperties properties) { //Add a configuration list to root web var sc = properties.Feature.Parent as SPSite; var site = sc.RootWeb; CreateConfigurationList(site); CreateLogList(site); } public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { //remove the list - Consider if you should do this or not var sc = properties.Feature.Parent as SPSite; var site = sc.RootWeb; DeleteConfigurationList(site); DeleteLogList(site); } private void DeleteLogList(SPWeb site) { var loglist = site.Lists.TryGetList(Constants.SPLogList); if (loglist != null) loglist.Delete(); } private void DeleteConfigurationList(SPWeb site) { var list = site.Lists.TryGetList(Constants.ConfigurationList); if (list != null) list.Delete(); }

(Code continued on the following page.)

Lab Answer Key: Designing a Development Strategy

11

private void CreateLogList(SPWeb site) { var logList = site.Lists.TryGetList(Constants.SPLogList); if (logList == null) { Guid listId = site.Lists.Add(Constants.SPLogList, "", SPListTemplateType.GenericList); logList = site.Lists[listId]; logList.Fields.Add(Constants.LogLine, SPFieldType.Text, true); logList.Fields.Add(Constants.DateAndTimeOfLog, SPFieldType.DateTime, true); logList.Update(); } } private void CreateConfigurationList(SPWeb site) { var list = site.Lists.TryGetList(Constants.ConfigurationList); if (list == null) { Guid listId = site.Lists.Add(Constants.ConfigurationList, "", SPListTemplateType.GenericList); list = site.Lists[listId]; list.Fields.Add(Constants.TargetForWeekFieldName, SPFieldType.Integer, true); list.Update(); var configItem = list.AddItem(); configItem["Title"] = "Configuration - Do Not Delete"; configItem[Constants.TargetForWeekFieldName] = 1; configItem.Update(); } }

4.

Click Save.

12

Lab Answer Key: Designing a Development Strategy

Task 3: Add logging capability to Web part


1. 2. 3. Click the plus sign to the left of the PlantMonitorSetter Web part to expand it. Double-click the PlantMonitorSetter.cs file. Add the following code to the file, replacing the CreateChildControls method:
protected override void CreateChildControls() { var currentTargetLabel = new Label { Text = "Please enter target for current week." }; Controls.Add(currentTargetLabel); _txtCurrentTarget = new TextBox(); Controls.Add(_txtCurrentTarget); var btnSubmitCurrentTarget = new Button { Text = "Set Target for Current Week" }; btnSubmitCurrentTarget.Click += new EventHandler(BtnSubmitCurrentTargetClick); Controls.Add(btnSubmitCurrentTarget); var btnSubmitCurrentTargetWithError = new Button { Text = "Set Target for Current Week with Error" }; btnSubmitCurrentTargetWithError.Click += new EventHandler(BtnSubmitCurrentTargetWithErrorClick); Controls.Add(btnSubmitCurrentTargetWithError); base.CreateChildControls(); }

Lab Answer Key: Designing a Development Strategy

13

4.

Add the following code to the file:


private void BtnSubmitCurrentTargetWithErrorClick(object sender, EventArgs e) { try { throw new Exception("An error has happened."); } catch (Exception ex) { LogEvent(ex.Message); } } private void LogEvent(string message) { var currentWeb = SPContext.Current.Web; var currentWeekTargetList = currentWeb.Lists[Constants.SPLogList]; // Add a new item var spListItem = currentWeekTargetList.AddItem(); spListItem[Constants.LogLine] = string.Format(message); spListItem[Constants.DateAndTimeOfLog] = DateTime.Now; spListItem.Update(); }

5.

Add the following code at the top of the BtnSubmitCurrentTargetClick method:


LogEvent(string.Format("Current target for week set at : {0}", _txtCurrentTarget.Text));

6.

Click Save.

14

Lab Answer Key: Designing a Development Strategy

Task 4: Deploy and verify


1. 2. Press F5 to deploy the solution. Click Lists. 3. 4. Verify LogList has been created.

Enter a target value in the Setter Web part. Click the Set Target for Current Week button. Verify that the change has been logged to the LogList.

5.

Enter a target and click the Set Target for Current Week with Error button. Verify that the error has been logged to the LogList.

6.

Close Internet Explorer.

Lab Answer Key: Designing a Development Strategy

15

Exercise 4: Configuring the Logging Level


Task 1: Add Web Part Configuration
1. 2. 3. Click the plus sign to the left of the PlantMonitorSetter Web part to expand it. Double-click the PlantMonitorSetter.cs file. Add the following code to the file:
private LogLevel _logLevel; public enum LogLevel { None = 0, Info = 1, Error = 2 } ; [WebBrowsable(true), WebDescription("LoggingLevel"), WebDisplayName("Default LoggingLevel"), Personalizable(PersonalizationScope.User), Category("Configure LoggingLevel")] public LogLevel LoggingLevel { get { return _logLevel; } set {_logLevel = value;} }

4.

Click Save.

16

Lab Answer Key: Designing a Development Strategy

Task 2: Add logging evaluation


1. 2. Open PlantMonitorSetter.cs. Add the following code to the file, replacing the BtnSubmitCurrentTargetWithErrorClick method:
private void BtnSubmitCurrentTargetWithErrorClick(object sender, EventArgs e) { try { throw new Exception("An error has happened."); } catch (Exception ex) { LogEvent(ex.Message, LogLevel.Error); } }

3. 4.

Locate the method BtnSubmitCurrentTargetClick. Replace the call to LogEvent with the code:
LogEvent(string.Format("Current target for week set at : {0}", _txtCurrentTarget.Text), LogLevel.Info);

5.

Add the following code to the file, replacing the LogEvent method:
private void LogEvent(string message, LogLevel level) { if (level >= _logLevel) { var currentWeb = SPContext.Current.Web; var currentWeekTargetList = currentWeb.Lists[Constants.SPLogList]; // Add a new item var spListItem = currentWeekTargetList.AddItem(); spListItem[Constants.LogLine] = string.Format(message); spListItem[Constants.DateAndTimeOfLog] = DateTime.Now; spListItem.Update(); } }

Lab Answer Key: Designing a Development Strategy

17

Task 3: Deploy and verify


1. 2. 3. 4. Press F5 to deploy the solution. Click the Page tab in the ribbon. Click Edit Page. Hover over the PlantMonitorSetter Web Part. The menu for this web part will appear. Click the menu and then click Edit Web Part. 5. 6. 7. Verify Configure LoggingLevel option is available.

Choose Error as the logging level. Click OK. Click Stop Editing in the ribbon. Verify Logging Level.

8. 9.

Set the target using the Set Target for Current Week. Click Lists and verify that no entry has been added to the LogList.

10. Click Home. 11. Set the target using the Set Target for Current Week with Error. 12. Click Lists and verify that an entry has been added to the LogList. 13. Close Internet Explorer.

18

Lab Answer Key: Designing a Development Strategy

Lab B: Operational Logging


Exercise 1: Adding Logging to SharePoint ULS
Task 1: Upgrade to farm solution
1. 2. 3. 4. Close and re-open Visual Studio, choosing the Contoso.PlantTargets solution from Lab A. Select the Contoso.PlantTargets project in Solution Explorer. In the Properties window, change the Sandboxed Solution option to False. Confirm YES when warned about the impact of the changes.

Task 2: Add ULS Logging


1. 2. 3. Expand the PlantMonitorSetter Web part. Open the file PlantMonitorSetter.cs. Add the following code to the using section:
using Microsoft.SharePoint.Administration;

4.

Add the following code to the LogEvent method:


if (level == LogLevel.Error) { SPDiagnosticsCategory diagCat = new SPDiagnosticsCategory("PlantTargets", TraceSeverity.Monitorable, EventSeverity.Error); SPDiagnosticsService diagSvc = SPDiagnosticsService.Local; diagSvc.WriteTrace(0, diagCat, TraceSeverity.Monitorable, "Plant Targets Setter Web Part: new object[] { message } ); }

{0}",

5.

Click Save.

Lab Answer Key: Designing a Development Strategy

19

Task 3: Deploy and verify


1. 2. 3. 4. 5. Press F5 to deploy the solution. In the ribbon, click the Page tab. Click Edit Page. Delete previous Web parts, as these are looking for the Web parts in the Sandbox. Click Add a Web Part and choose Custom category. 6. 7. 8. 9. Verify the PlantMonitorSetter is listed. Verify the PlantTargetMonitor is listed.

Add both Web parts to the page. Click Stop Editing. Set the target using the Set Target for Current Week with Error. Click Lists and verify that an entry has been added to the LogList.

10. Open Windows Explorer. 11. Navigate to Logs below the SharePoint root (C:\Program Files\Common Files \Microsoft Shared\Web Server Extensions\14\Logs). 12. Order the files by date modified to find the latest file. 13. Using Notepad, open the file. 14. Search for the phrase Plant Targets Setter Web Part.

Lab Answer Key: Developing Version and Deployment

Module 9
Lab Answer Key: Developing Version and Deployment
Contents:
Lab A: Versioning Assemblies Exercise 1: Defining Base Version Exercise 2: Upgrading the Assembly Lab B: Feature Upgrade Exercise 1: Creating Upgrade Manage Page Exercise 2: Adding Feature to Upgrade Exercise 3: Upgrading Feature 10 14 17 2 5

Lab Answer Key: Developing Version and Deployment

Lab A: Versioning Assemblies


Exercise 1: Defining Base Version
Task 1: Create a Microsoft Visual Studio 2010 project
1. 2. 3. 4. 5. Click Start, point to All Programs, click Microsoft Visual Studio 2010, and then click Microsoft Visual Studio 2010. Click File, point to New, and then click Project. In the New Project dialog box, select SharePoint under Installed Templates and then select Empty SharePoint Project. Specify the name of the project as Contoso.Version and click OK. The SharePoint Customization Wizard appears. In the SharePoint Customization Wizard, specify the local site to use for debugging as http://sharepoint/student/module9/ and select Deploy as a farm solution. Click Finish.

6.

Task 2: Create a version Web Part


1. 2. 3. Right-click the Contoso.Version project, point to Add, and then click New Item. Select the Web Part option. Do not select the Visual Web Part option. Specify the name of the Web Part as VersionWebPart and click Add.

Lab Answer Key: Developing Version and Deployment

4.

Add the following code into VersionWebPart in the CreateChildControls method:


using (Label label1 = new Label()) { label1.Text = String.Format("Assembly Version: {0}", System.Reflection.Assembly .GetExecutingAssembly() .GetName() .Version ); Controls.Add(label1); }

5.

Click Save.

Task 3: Rename feature


1. 2. 3. 4. In Solution Explorer, expand the Features folder. Right-click Feature1 and click Rename. Specify the name of the feature as Version. Click Save.

Task 4: Deploy and verify


1. 2. 3. 4. 5. 6. 7. Right-click the Contoso.Version solution and select Properties. Click the SharePoint tab and then clear the check box in front of Auto-retract after debugging. Right-click the Contoso.Version solution and select Package. Right-click the Contoso.Version solution and select Deploy. Press CTRL+F5. Click the Page tab and then click Edit Page. In the Left Web part zone, click Add a Web Part.

Lab Answer Key: Developing Version and Deployment

8. 9.

In the Categories list, click Custom. Notice that VersionWebPart Web Part is listed. Select VersionWebPart and click Add.

10. Click Stop Editing. Notice that the VersionWebPart displays Assembly Version 1.0.0.0.

Results: After this exercise, you will have defined a basic version for the feature and also will have demonstrated that the default assembly version for the Web Part assembly is 1.0.0.0.

Lab Answer Key: Developing Version and Deployment

Exercise 2: Upgrading the Assembly


Task 1: Update version
1. 2. 3. 4. Open the Contoso.Version solution that you created in Exercise 1. Click the plus sign to the left of the Properties option to expand it. Double-click the AssemblyInfo.cs file. Change the AssemblyVersion number from
[assembly: AssemblyVersion("1.0.0.0")]

to
[assembly: AssemblyVersion("1.1.0.0")]

5. 6.

Press CTRL+SHIFT+B to build the solution. This will update the compiled assembly and the SharePoint tools in Visual Studio. Click Save.

Task 2: Package and deploy


1. 2. 3. Right-click the Contoso.Version solution and select Package. Click Start, point to All Programs, click Microsoft SharePoint 2010 Products, and then click SharePoint 2010 Management Shell. Enter the command
PS > Update-SPSolution -Identity Contoso.Version.wsp -LiteralPath <project dir>\bin\Debug\Contoso.Version.wsp GACDeployment -Local

where <project dir> is the location of the Contoso.Version project. You can check that by right-clicking the Contoso.Version project and select Open Folder in Windows Explorer. 4. Return to Internet Explorer and navigate to http://sharepoint/student /module9/. (If the page is already open, click Home.) Notice that the Web Part added previously now reports an error. It cannot be loaded because it cant find the v1.0.0.0 of the Contoso.Version .dll. Click the Page tab and select Edit Page.

5.

Lab Answer Key: Developing Version and Deployment

6. 7. 8. 9.

In the Left Web part zone, click Add a Web Part. In the Categories list, click Custom. Notice that VersionWebPart Web Part is listed. Select VersionWebPart and click Add. Click Stop Editing. Notice that the VersionWebPart displays Assembly Version 1.1.0.0.

Task 3: Add SafeControl


1. 2. 3. Switch to Contoso.Version Microsoft Visual Studio. Double-click Package to open the Package Designer in Solution Explorer. Click Manifest at the bottom of the designer. Notice that SafeControl shows Version 1.1.0.0 as follows:
<SafeControl Assembly="Contoso.Version, Version=1.1.0.0, />

4.

Click the plus sign next to Edit Options at the bottom of the designer. Copy the <Assemblies> tag from Manifest and paste it into the <Solution> tag in the Edit Options window. Edit the copied SafeControl entry in the Edit Options window to read, Version 1.0.0.0.

5.

Lab Answer Key: Developing Version and Deployment

Manifest should look similar to the screenshot below with two SafeControl entries.

Lab Answer Key: Developing Version and D Deployment

Task 4: Add BindingRedirect B


1. . Add the fol llowing code a the top of th assembly ta at he ag:
<BindingR Redirects> <BindingRedirect OldVersion="1.0.0.0"/> </B BindingRedirects>

The manife should look similar to th following sc est he creenshot:

2. .

Click Save. .

Task 5: Packa and upd age date


1. . 2. . Right-click the Contoso.V Version solut tion and select Package. t Click Start point to All P t, Programs, clic Microsoft S ck SharePoint 20 010 Products, and then click SharePoint 2 a k 2010 Manage ement Shell.

Lab Answer Key: Developing Version and Deployment

3.

Enter the command


PS > Update-SPSolution -Identity Contoso.Version.wsp -LiteralPath <project dir>\bin\Debug\Contoso.Version.wsp GACDeployment -Local

where <project dir> is the location of the Contoso.Version project. You can check that by right-clicking the Contoso.Version project and select Open Folder in Windows Explorer. 4. Return to Internet Explorer and navigate to http://sharepoint/student /module9/. (If the page is already open, click Home.) Notice that the Web Part added previously now reports assembly version 1.1.0.0.

Task 6: Evaluate the changes


1. 2. 3. 4. Click Start, point to All Programs, click Administrative Tools, and then click Internet Information Services (IIS) Manager. Double-click SHAREPOINT, double-click Sites, and click SharePoint80. Click Content View, and then click Explore under Actions. Double-click web.config. Notice the two SafeControl entries have been added. Also, notice that the assembly redirect has been added to the <assemblyBinding> element.

Results: After this exercise, you will have demonstrated how it is possible using the new features of SharePoint 2010 to automatically provide assembly versioning and binding redirects.

10

Lab Answer Key: Developing Version and Deployment

Lab B: Feature Upgrade


Exercise 1: Creating Upgrade Manage Page
Task 1: Create a Visual Studio 2010 project
1. 2. 3. 4. 5. 6. Click Start, point to All Programs, click Microsoft Visual Studio 2010, and then click Microsoft Visual Studio 2010. Click File, point to New, and then click Project. In the New Project dialog box, select SharePoint under Installed Templates, and then select Empty SharePoint Project. Specify the name of the project as Contoso.Upgrade and click OK. The SharePoint Customization Wizard appears. In the SharePoint Customization Wizard, select Deploy as a farm solution. Click Finish.

Task 2: Add feature manager page


1. 2. 3. 4. 5. 6. 7. Right-click the Contoso.Upgrade project, point to Add and click SharePoint Layouts Mapped Folder. Right-click the Contso.Upgrade folder below the Layouts mapped folder, point to Add and then click New Item. In the Add New Item dialog box, for the SharePoint 2010 templates, click Application Page. Specify the name of the item as FeatureManager.aspx and click Add. Double-click the FeatureManager.aspx page. Locate the ContentPlaceHolder with the ID PlaceHolderMain, and add the text Feature Manager. In the same content placeholder, add a new Table Control and rename it tblFeatures.

Lab Answer Key: Developing Version and Deployment

11

It should look similar to the following code:


<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> Feature Manager <asp:Table ID="tblFeatures" runat="server"> </asp:Table> </asp:Content>

8.

Click Save.

Task 3: Deploy and verify


1. 2. Press F5 to deploy the solution. Specify the following address and notice that the page loads. http://<siteurl>/_layouts/Contoso.Upgrade/FeatureManager.aspx 3. Close the browser.

Task 4: Add feature manager page logic


1. 2. Double-click the FeatureManager.aspx.cs file from Layouts | Contoso.Upgrade. Add the following using statements:
using System.Collections.Generic; using System.Web.UI.WebControls;

3.

In the Page_Load method, add the following:


SPFeatureQueryResultCollection features = SPContext.Current.Site.QueryFeatures(SPFeatureScope.Site, true); IEnumerator<SPFeature> featureEnumerator = features.GetEnumerator(); while (featureEnumerator.MoveNext()) { SPFeature feature = featureEnumerator.Current; DisplayFeature(feature); }

12

Lab Answer Key: Developing Version and Deployment

4.

Add the following code below the Page_Load method:


private void DisplayFeature(SPFeature feature) { Label lblFeature = new Label() { Text = feature.Definition.DisplayName }; Label lblFeatureVersion = new Label() { Text = feature.Definition.Version.ToString() }; Label lblFeatureActiveVersion = new Label() { Text = feature.Version.ToString() }; Button btnUpgrade = new Button() { Text = "Upgrade", Enabled = feature.Version != feature.Definition.Version }; btnUpgrade.Attributes.Add("FeatureID", feature.DefinitionId.ToString()); btnUpgrade.Click += new EventHandler(btnUpgrade_Click); TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Controls.Add(lblFeature); row.Cells.Add(cell); cell = new TableCell(); cell.Controls.Add(lblFeatureVersion); row.Cells.Add(cell); cell = new TableCell(); cell.Controls.Add(lblFeatureActiveVersion); row.Cells.Add(cell); cell = new TableCell(); cell.Controls.Add(btnUpgrade); row.Cells.Add(cell); tblFeatures.Rows.Add(row); }

(Code continued on the following page.)

Lab Answer Key: Developing Version and Deployment

13

void btnUpgrade_Click(object sender, EventArgs e) { string featureId = ((Button)sender).Attributes["FeatureID"]; SPFeature feature = SPContext.Current.SiteFeatures[new Guid(featureId)]; feature.Upgrade(false); }

5.

Click Save.

Results: After this exercise, you will have created an application page that queries features in the site collection that need to be upgraded. You will have added an upgrade event handler to the feature that will be called during the upgrade event. You will also have provided specific version information that defines when the upgrade action is called and that action has been passed in the event handler. Based on this understanding of the upgrade framework, you should now be able to work through all of the scenarios.

14

Lab Answer Key: Developing Version and Deployment

Exercise 2: Adding Feature to Upgrade


Task 1: Add site collection feature
1. 2. 3. 4. 5. 6. 7. 8. 9. Right-click the Contoso.Upgrade project, point to Add, and click New Item. In the Add New Item dialog box, under SharePoint 2010 Templates, click List Definition. Specify the name of the list definition as UpgradeLog and click Add. The SharePoint Customization Wizard appears. Specify the display name as UpgradeLog. From the What is the type of the list definition drop-down list box, select Custom List. Ensure that the Add a list instance for this list definition check box is selected. Click Finish. Right-click ListInstance1, click Rename, specify the name as ContosoUpgradeLog and press ENTER. Right-click Feature1, click Rename, specify the name as Contoso.Upgrade.SiteCollection, and press ENTER. Double-click the Contoso.Upgrade.SiteCollection feature. In the Properties windows, set the Version property to 1.0.0.0.

10. In the Feature designer, change the Scope to Site. 11. Build the solution by pressing CTRL+SHIFT+B. 12. Right-click the project and choose Package. 13. Right-click the project and choose Deploy.

Task 2: Add feature event handler


1. 2. Right-click the Contoso.Upgrade.SiteCollection feature and choose Add Event Receiver. In the created Contoso.Upgrade.EventReceiver.cs file, uncomment the FeatureUpgrading event.

Lab Answer Key: Developing Version and Deployment

15

3.

Add the following code to the FeatureUpgrading event:


SPSite sc = properties.Feature.Parent as SPSite; using (SPWeb rootweb = sc.RootWeb) { SPList upgradeLog = rootweb.Lists.TryGetList("Contoso.Upgrade - ContosoUpgradeLog"); SPListItem log = upgradeLog.AddItem(); log["Title"] = string.Format("Performed Upgrade Action {0} on Feature {1} from version {2} to {3}", upgradeActionName, properties.Feature.Definition.Name, properties.Feature.Version, properties.Feature.Definition.Version); log.Update(); }

4. 5. 6. 7. 8. 9.

Double-click the Contoso.Upgrade.SiteCollection feature. In the Properties window, copy the Receiver Assembly value to Upgrade Actions Receiver Assembly value. Copy the Receiver Class value to the Upgrade Actions Receiver Class value. Change the Version property to 2.0.0.0. In the feature designer, click Manifest and copy the created <UpgradeActions /> line from the preview. Paste the value in the Edit window. The preview window should remain the same.

10. Open the Feature in XML Editor (using link in designer).

16

Lab Answer Key: Developing Version and Deployment

11. Add the following to the UpgradeActions element:


<VersionRange EndVersion="2.0.0.0"> <CustomUpgradeAction Name="UpgradeTo2.0.0.0"> </CustomUpgradeAction> </VersionRange>

12. Click Save.

Results: After this exercise, you will have deployed a feature that will place an entry into a log upon being upgraded.

Lab Answer Key: Developing Version and Deployment

17

Exercise 3: Upgrading feature


Task 1: Package and update
1. 2. 3. 4. Right-click Solution and choose Package. Open a SharePoint 2010 Management Shell. Click Start, Program Files, Microsoft SharePoint Products, SharePoint 2010 Management Shell. Enter the command
PS > Update-SPSolution -Identity Contoso.Upgrade.wsp -LiteralPath <project dir>\bin\Debug\Contoso.Upgrade.wsp GACDeployment -Local

replacing <project dir> with the location of the Contoso.Upgrade project. Tip, right-click the project and choose Open Folder in Windows Explorer. 5. 6. Type Iisreset to flush the ASP.NET cache. Navigate to http://<siteurl>/_layouts/Contoso.Upgrade /FeatureManager.aspx. Verify that the Contoso.Upgrade feature is listed and shows the feature version 2.0.0.0 and the activated version 1.0.0.0.

Task 2: Upgrade
1. 2. 3. Click the Upgrade button to upgrade this site collection instance of the feature. Refresh the page and verify the feature is no longer listed. Navigate to the Contoso.Upgrade list. Verify that there is one entry in the list showing something similar to: Performed Upgrade Action UpgradeTo2.0.0.0 on Feature FeatureDefinition/c93306cb-f83a-4aa2-a321-4e5cfd5f7aeb from version 1.0.0.0 to 2.0.0.0.

Results: After this exercise, you will have an entry in the upgrade log indicating that the upgrade has been performed.

Lab Answer Key: Designing Information Architecture and Navigation

Module 10
Lab Answer Key: Designing Information Architecture and Navigation
Contents:.
Lab A: Developing a Site Structure Exercise 1: Using Card Sort Exercise 2: Designing Content Types and Site Columns Lab B: Implementing Farm-wide Navigation Exercise 1: Deploying a Custom SiteMap Exercise 2: Adding an ASPmenu to a Custom Master Page 5 7 2 4

Lab Answer Key: Designing Information Architecture and Navigation

Lab A: Developing a Site Structure


Exercise 1: Using Card Sort
There are no right answers to this lab. The purpose of the lab is to create a situation where youthe studentare encouraged to think beyond the departmental structure that most developers are accustomed to. The content in this lab answer key is designed to encourage the right thinking about the problem and is designed to expose portions of the instructional design so you can take better advantage of the exercise.

Guideline Review
Here are the guidelines and why theyre important: You should try to create a maximum of five main categories. Reasoning: Its easy to create hierarchies that are overly flat (too many items at one level) and overly deep (too many levels deep). Five main categories as a guideline tries to keep the set to a manageable size and encourages the right balance of depth versus breadth. You may create up to five subcategories per category until youve developed an appropriate categorization tree. Reasoning: The objective is to ensure that were keeping a relatively good substructure, again to encourage a balance of depth versus breadth. You may not use the department names (included in the beginning of the item for reference) in your content category. Reasoning: Organizing by department is easy. Its encouraged by providing where the type of content comes from in the list. The exercise is deliberately putting a department organization at odds with the objective. Break into groups and start working for 10 minutes. Then get back together to further discuss the task. Reasoning: In most cases, the class will get stuck, or a portion of the class will get stuck. Its important that everyone realize that help is available.

Facilitation Notes
The facilitator should provide alternative approaches to organization, particularly if the students are stuck. Here are a few ideas and examples:

Lab Answer Key: Designing Information Architecture and Navigation

Organize by consumer rather than creatorthat is, who needs to know the information, the employee or the customer? Organize by process or flow. Some information is about taking care of customers. Other information is about managing vendors. Irrespective of which department creates the data, organize it by who needs it and when. Look for content (cards) that dont look like they belong in one department. Develop a grouping around those items that dont fit neatly into specific departments. Consider a contract with a customer. Is that a sales item, a legal item, or an accounting item?

Task 1: Use card sort to create an information architecture


After completing this exercise, discuss the answers to the following questions with the rest of the class: What factors contributed to selecting the structure that you chose? Reasoning: By explaining the sorting process, students can better understand their own thinking about the problem. Did you consider any other ways of organizing the site? If so, why did you choose this structure? Reasoning: Having alternatives is key to developing an information architecture.

Lab Answer Key: Designing Information Architecture and Navigation

Exercise 2: Designing Content Types and Site Columns


Scenario
(Optional) Use the results of the card sort in Exercise 1 to design content types for storing documents in your application. If suitable content types do not exist, design new content types by selecting appropriate content types to inherit from and identify any additional site columns that are needed. Reasoning: The key is to convert the abstract topics (cards) into potentially concrete items as SharePoint fields and content types. The net effect of this is that its easier to consider information architecture when you follow it all the way through to the details.

Task 1: Select content types for each information architecture category


Reasoning: Converting conceptual into concrete often reveals new details about the content, which was not previously considered.

Task 2: Select site columns for each custom content type


Reasoning: By defining the fields/columns, it becomes clear where field name collisions might occur and forces the consideration of how to handle them.

Task 3: Discuss your choice of content types and site columns


Reasoning: By discussing this task with the entire class, its possible to encourage deeper conviction about the information architecture decisions that were made.

Results: After completing this exercise, you should have an understanding of how to apply an information architecture to content type and site column selection in SharePoint.

Lab Answer Key: Designing Information Architecture and Navigation

Lab B: Implementing Farm-wide Navigation


Exercise 1: Deploying a Custom SiteMap
Task 1: Create a new Visual Studio project
1. 2. 3. 4. Click Start, point to All Programs, click Microsoft Visual Studio 2010, and then click Microsoft Visual Studio 2010. Click File, point to New, and then click Project. In the New Project dialog box, select SharePoint under Installed Templates and then select Empty SharePoint Project. Specify the name of the project as Contoso.GlobalNav and click OK. The SharePoint Customization Wizard appears. 5. In the SharePoint Customization Wizard, specify the local site to use for debugging as http://sharepoint/student/module10/ and select Deploy as a farm solution. Click Finish. Right-click the Contoso.GlobalNav project and add a SharePoint Layouts mapped folder. Delete the Contoso.Global.Nav folder. Right click Layouts folder, point to Add, and then click New Item. Under C# under Installed Templates, select Data, and then select XML file. Specify the name as Layouts.Sitemap.Global.xml, and then click Add.

6. 7. 8. 9.

10. Add the following XML code:


<?xml version="1.0" encoding="utf-8" ?> <siteMap> <siteMapNode title="Corporate" url="http://sharepoint/student/module10/"> <siteMapNode title="Cleveland" url="/CLE" /> <siteMapNode title="Los Angeles" url="/LAX" /> <siteMapNode title="Denver" url="/DEN" /> </siteMapNode> </siteMap>

11. Deploy the project.

Lab Answer Key: Designing Information Architecture and Navigation

Task 2: Merge the navigation nodes into the default Layouts.Sitemap


1. 2. Open a command prompt. Execute the following commands:
cd \Program Files\Common Files\Microsoft Shared\web server extensions\14\bin stsadm -o copyappbincontent

Note: In a multiple Web front-end server environment, the command line must be run once on each server. Invoking the SPWebService.ApplyApplicationContentToLocalServer method will accomplish the same thing, but since it only runs on one server, you would need to create a custom timer job that would invoke the API on each Web front-end server.

Lab Answer Key: Designing Information Architecture and Navigation

Exercise 2: Adding an ASPmenu to a Custom Master Page


Task 1: Add an ASPmenu and SiteMapDataSource
1. 2. 3. 4. 5. 6. Open Windows Internet Explorer to http://localhost/student/module10. Click Site Actions-Edit in Microsoft SharePoint Designer. In the Site Objects section, click Master Pages. Make a copy of the V4.master and name it V4global.master. Open V4global.master. Click the Edit File link in the Customization section. Locate the line that contains the following:
<SharePoint:DeveloperDashboard runat=server/>

7.

Add the following code on the line above the DeveloperDashboard tag:
<hr /> <div style="position:relative; left:50%; margin-left:-25%; "> <SharePoint:AspMenu ID="FarmNavigationMenuV4" Runat="server" EnableViewState="false" DataSourceID="FarmSiteMap" AccessKey="<%$Resources:wss,navigation_accesskey%>" UseSimpleRendering="true" UseSeparateCss="false" Orientation="Horizontal" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0" SkipLinkText="" CssClass="s4-tn"/> <asp:SiteMapDataSource ShowStartingNode="True" StartingNodeUrl="http://sharepoint/student/module10/" SiteMapProvider="SPXmlContentMapProvider" ID="FarmSiteMap" runat="server"/> </div>

8. 9.

Close and save the V4global.master. Exit SharePoint Designer.

Lab Answer Key: Designing Information Architecture and Navigation

Task 2: Deploy V4global.master


1. 2. 3. 4. 5. 6. 7. 8. 9. Open the corporate portal site in Internet Explorer. Click Site Actions-Site Settings. In the Galleries section, click Master Pages. Select the check box in front of V4global.master. Select the Library Tools Documents tab and then click Download a Copy. Save the file to the desktop. Delete V4global.master from the master page gallery. Return to the Contoso.GlobalNav project in Visual Studio. Right-click the Contoso.GlobalNav project, point to Add, and then select New Item.

10. Select the Module item. 11. Specify the name of the module as CopyMaster and then click Add. 12. Right-click the CopyMaster module, point to Add, and select Existing Item. 13. Select V4global.master from the Desktop folder and click Add. 14. Right-click the file Sample.txt in the CopyMaster module folder and select Delete. 15. Click OK to confirm. 16. Modify the Elements.xml for the module so that it matches the following code:
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="CopyMaster" Url="_catalogs/masterpage"> <File Path="CopyMaster\V4global.master" Url="V4global.master" IgnoreIfAlreadyExists="True" Type="GhostableInLibrary"> <Property Name="ContentType" Value="Master Page" /> <Property Name="UI Version" Value="4" /> </File> </Module> </Elements>

Lab Answer Key: Designing Information Architecture and Navigation

Task 3: Use the V4global.master


1. 2. 3. 4. In Solution Explorer, right-click Feature1, and click Rename. Specify the name of the feature as GlobalNav. Right-click the GlobalNav feature, and select Add Event Receiver. Uncomment the FeatureActivated method and insert the following code:
SPWeb CurrentWeb = properties.Feature.Parent as SPWeb; CurrentWeb.MasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4global.master"; CurrentWeb.CustomMasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4global.master"; CurrentWeb.Update();

5.

Uncomment the FeatureDeactivating method and insert the following code:


SPWeb CurrentWeb = properties.Feature.Parent as SPWeb; CurrentWeb.MasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4.master"; CurrentWeb.CustomMasterUrl = CurrentWeb.ServerRelativeUrl + "/_catalogs/masterpage/V4.master"; CurrentWeb.Update();

6. 7.

Right-click the Contoso.GlobalNav project and select Deploy. Navigate to the site you chose as the target when you created the project in Exercise 1. You should see a new global navigation footer at the bottom of the page.

Note: You have added only the V4global.master to one site in this exercise. You would need to deploy and activate the custom master to other sites for the navigation to be complete.

Results: After completing this exercise, you should have an understanding of how to implement a custom global navigation system for a SharePoint site.

Lab Answer Key: Designing Branding and Customization Support

Module 11
Lab Answer Key: Designing Branding and Customization Support
Contents:
Lab A: Packaging Branding Exercise 1: Importing .wsp Files into Microsoft Visual Studio Exercise 2: Extracting the File Resources Exercise 3: Writing the Feature Receiver to Apply Changes Exercise 4: Testing the Changes Lab B: Improving Branding Performance Exercise 1: Observing Current Performance Exercise 2: Turning on BLOB Caching Exercise 3: Observing BLOB Cached Performance Exercise 4: Observing _layouts Performance 9 10 11 12 2 4 6 8

Lab Answer Key: Designing Branding and Customization Support

Lab A: Packaging Branding


Exercise 1: Importing .wsp Files into Microsoft Visual Studio
Task 1: Create new project
1. 2. Open Visual Studio 2010. From the menu bar, select File, and then select New Project. The New Project dialog box appears. 3. 4. 5. 6. 7. 8. 9. In the left pane, select Visual C#-SharePoint. In the middle pane, scroll down and select the Import SharePoint Solution Package project type. In the name text box, enter Contoso.BrandingImport. Click OK. In the What local site do you want to use for debugging? text box, enter the URL of http://sharepoint/student/module11. Accept Deploy as a sandbox solution, and click Next. Click Browse, and locate and select the ContosoBranding.wsp file in E:\Student\Module 11\.

10. Click Next. 11. When the list of items to import appears after some delay, click Finish. 12. In the Import Completed dialog box, click OK.

Lab Answer Key: Designing Branding and Customization Support

Task 2: Review the imported artifacts


1. 2. 3. 4. In Solution Explorer, expand the Built-In List Instances node by clicking the plus sign to the left of it. Expand the folders: Master_Page_Gallery, _catalogsmasterpage_, Files, _catalogs, and masterpage folders to reveal the Contoso.master file. Expand the List Instances node by clicking the plus sign to the left of it. Expand the folders: Site_Assets, SiteAssets_, Files, and SiteAssets to reveal the Contoso.css, Header.png, and Logo.png files.

Lab Answer Key: Designing Branding and Customization Support

Exercise 2: Extracting the File Resources


Task 1: Create a new Contoso Branding project
1. 2. 3. 4. 5. 6. In Solution Explorer, right-click the solution and select Add -> New Project. In the center pane, select Empty SharePoint Project. In the name text box, enter Contoso.Branding. Click OK. In the What local site do you want to use for debugging? text box, enter the URL of http://sharepoint/student/module11. Accept Deploy as a sandbox solution and click Finish.

Task 2: Copy the master page resources to the Contoso Branding project
1. 2. In Solution Explorer, drag the Master_Page_Gallery folder from Contoso.BrandingImport to the Contoso.Branding project. In the Solution Explorer, in the Contoso.Branding project, delete the following subfolders of the Master_Page_Gallery: _catalogsmasterpage_Features_EnterpriseWikiLayouts_PageLayouts _catalogsmasterpage_Features_PublishingLayouts_MasterPages _catalogsmasterpage_Features_PublishingLayouts_PageLayouts _catalogsmasterpage_Features_PublishingResources _catalogsmasterpage_Features_PublishingResources1 _catalogsmasterpage_global

Task 3: Copy the site assets resources to the Contoso Branding project
In Solution Explorer, drag the Site_Assets folder from Contoso.BrandingImport to Contoso.Branding.

Lab Answer Key: Designing Branding and Customization Support

Task 4: Remove the imported project


1. 2. In Solution Explorer, right-click the ContosoBrandingImport project and select Remove. Click OK on the Visual Studio dialog box indicating that the Contoso.BrandingImport project will be removed.

Lab Answer Key: Designing Branding and Customization Support

Exercise 3: Writing the Feature Receiver to Apply Changes


Task 1: Rename the feature
1. 2. 3. In Solution Explorer, right-click Feature1 and select Rename. Type Contoso.Branding and press ENTER. Double-click the renamed Contoso.Branding feature. In the Title text box, change the title to Apply Contoso Branding.

Task 2: Add a feature event receiver to set the master page


1. 2. In Solution Explorer, right-click the Contoso.Branding feature, and select Add EventReceiver. Remove the commented FeaturedActivated method and paste in the following code:
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb curWeb = properties.Feature.Parent as SPWeb; if (curWeb != null) { curWeb.MasterUrl = curWeb.ServerRelativeUrl + "/_catalogs/masterpage/Contoso.master"; curWeb.CustomMasterUrl = curWeb.MasterUrl; curWeb.Update(); } }

Lab Answer Key: Designing Branding and Customization Support

3.

Remove the commented FeatureDeactivating method and paste in the following code:
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPWeb curWeb = properties.Feature.Parent as SPWeb; if (curWeb != null) { curWeb.MasterUrl = curWeb.ServerRelativeUrl + "/_catalogs/masterpage/v4.master"; curWeb.CustomMasterUrl = curWeb.ServerRelativeUrl + "/_catalogs/masterpage/nightandday.master"; curWeb.Update(); } }

Lab Answer Key: Designing Branding and Customization Support

Exercise 4: Testing the Changes


Task 1: Deploy and run the package
1. 2. Press F5. Verify that the site has a different header and logo.

Task 2: Deactivate the feature and ensure the site still works
1. 2. 3. 4. 5. In the Site Actions menu, select Site Settings. In the Site Actions group, select Manage site features. To the right of the Apply Contoso Branding feature, click Deactivate. On the feature deactivation confirmation page, click the Deactivate this feature link. Verify that the Contoso branding is no longer displayed.

Lab Answer Key: Designing Branding and Customization Support

Lab B: Improving Branding Performance


Exercise 1: Observing Current Performance
Task 1: Deploy and reactivate the Contoso.Branding package
1. In Visual Studio 2010 with the Contoso.Branding project open, right-click the solution and select Deploy Solution. If youre presented with a deployment conflicts dialog, click Resolve Automatically. Open Internet Explorer to http://sharepoint/student/module11. In the Site Actions menu, select Site Settings. In the Site Actions group, click the Manage site features link. To the right of Apply Contoso Branding, click Activate (if necessary).

2. 3. 4. 5.

Task 2: Open Fiddler and force a reload of the home page


1. 2. 3. Start Fiddler2. Open Internet Explorer to http://sharePoint/student/module11. Press F5 to force Internet Explorer to reload all of the files.

Task 3: Observe calls to ~/siteassets and ~/style Library


1. 2. 3. 4. In Fiddler2, locate the request for /student/module11/siteassets/contoso.css. Click on the Inspectors tab. In the response section, click the Headers button. In the Cache section of the response headers, observe that the Cache-Control header is set to private.

10

Lab Answer Key: Designing Branding and Customization Support

Exercise 2: Turning on BLOB Caching


Task 1: Open the web.config for the web application
1. 2. Open Windows Explorer and navigate to the directory C:\inetpub\wwwroot\wss\VirtualDirectories\80. Double-click the web.config file to open it in Visual Studio.

Task 2: Set the BlobCache to enabled


1. 2. 3. 4. 5. Scroll down to near the end of the </SharePoint> section and locate the <BlobCache> node. Scroll to the end of the line and change the enabled attribute from false to true. Save the web.config file. Open Windows Explorer and create the directory BLOBCACHE off the root of the C drive. In the BLOBCACHE directory, create a directory 14.

Lab Answer Key: Designing Branding and Customization Support

11

Exercise 3: Observing BLOB Cached Performance


Task 1: Refresh the page
Return to Internet Explorer and press F5.

Task 2: Navigate to the page


1. 2. Click the Contoso logo on the home page. In Fiddler, note that the only requests were to /student/Module11/ and /student/Module11/ /_default.aspx.

Task 3: Observe cache settings for ~/siteassets


1. 2. In Fiddler, locate the most recent request for /student/module11/siteassets/contoso.css. Verify that the Cache-Control header is now public.

12

Lab Answer Key: Designing Branding and Customization Support

Exercise 4: Observing _layouts Performance


Task 1: Review a _layouts request in Fiddler
1. 2. In Fiddler, locate the most recent _layouts request. In the Response section, verify that the Cache-Control header indicates a max-age of 31536000.

Task 2: Compare the cache-control header in siteassets and _layouts


1. 2. 3. 4. In the previous task, you saw that the max-age setting of a _layouts page was 31536000. Locate the most recent request to a /student/module11/siteassets/* file. In the Response section, verify that the Cache-Control max-age is 86400. Observe that _layouts has a max-age of 365 times the max-age of a ~/siteassets file.

Lab Answer Key: Designing Security

Module 12
Lab Answer Key: Designing Security
Contents:
Lab A: Setting Up a Customer Service Site Exercise 1: Setting Up the Authentication Provider Exercise 2: Creating an FBA-Claims Site Optional Exercise 3: Viewing Claims for an FBA User Lab B: Solving a Security Issue Exercise 1: Understanding the Scope and Relating it to Configuration Exercise 2: Designing a Security Strategy 14 15 2 6 13

Lab Answer Key: Designing Security

Lab A: Setting Up a Customer Service Site


Exercise 1: Setting Up the Authentication Provider
Task 1: Map out requirements, design a plan
The customer scenario outlines two key requirements that guide us to a final design decision: 1. 2. Users will not have an internal network identity. A Contoso employee will manage access.

These two requirements point us in the direction of a solution that leverages formsbased authentication. By setting up a custom database that is housed internally (on Contoso property), we are able to isolate user identities and provide Contoso employees the ability to manage user accounts that will be needed to access the site. Knowing that we plan to use FBA, we also know that our Microsoft SharePoint Web application must be set up to use claims-mode authentication.

Task 2: Set up the FBA database and verify you can manage users
1. Start the ASP.NET SQL Server Setup wizard. The setup file is located at %windows%\Microsoft.Net\Framework64\ v2.0.50727\aspnet_regsql.exe. a. b. c. Once the wizard is displayed, click Next. Click Next. In the Server text box, type .\SharePoint.

d. Click Next twice. e. 2. Click Finish.

Create a folder for the FBA user maintenance Web site. Create a folder at the location c:\inetpub\wwwroot\ named fba.

Lab Answer Key: Designing Security

3.

Go to the Start menu, point to Administrative Tools and click on IIS Manager. a. b. c. Click the Sites node from the tree view shown in the Connection pane. In the Actions pane, click Add Web Site. Specify fba as the site name and press TAB.

d. Select SharePoint80 as the application pool. e. f. 4. Specify c:\inetpub\wwwroot\fba as the physical path to the site. Specify fba as the Host name and click OK.

Go to Start menu, point to All Programs, point to Microsoft SQL Server 2008, and click on SQL Server Management Studio. a. b. c. Ensure the server name is .\SharePoint. Click Connect. In Object Explorer, expand the Databases node.

d. Expand the aspnetdb node. e. f. g. h. i. 5. 6. Right-click the Security node. Click New and then click User. Specify Network Service as user name and press TAB. Specify NT AUTHORITY\NETWORK SERVICE as login name and press TAB. In Database role membership, select the db_owner check box.

Click OK. In Windows Explorer or a Command Prompt, navigate to the root folder for the fba Web site (c:\inetpub\wwwroot\fba).

Lab Answer Key: Designing Security

7.

Create a web.config file and add the following text to the file:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <connectionStrings> <add name="fbaSQL" connectionString="Server=.\SHAREPOINT;Database=aspnetdb;Integrated Security=true" /> </connectionStrings> <system.web> <!-- membership provider --> <membership defaultProvider="fbaMembers"> <providers> <add name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" /> </providers> </membership> <!-- role provider --> <roleManager enabled="true" defaultProvider="fbaRoles"> <providers> <add name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="fbaSQL" applicationName="/" /> </providers> </roleManager> <authentication mode="Forms" /> </system.web> </configuration>

8.

At this point, you should be able to go back to the Internet Information Services (IIS) Management console and add at least one user to your new FBA database and grant one user access to the site. a. b. Return to the IIS Manager window. Select the fba Web site in the tree view shown in the Connections pane, and then double-click .Net Users.

Lab Answer Key: Designing Security

c.

Add at least one user. You will need to grant one user access to the site to complete this lab.

d. In the Actions pane, click Add. e. f. 9. Specify user name, e-mail, and password. These values are the students choice. Click Next.

Click Finish.

10. You can also define roles and associate users with those roles. For demo purposes, create at least one role and associate the user from Step 6 with the role. 11. Select the fba Web site, and then double-click .Net Roles. 12. In the Actions pane, click Add. a. b. c. Specify a name in the Add .Net role popup window. This value is the students choice. Click OK. Return to the .Net Users section.

d. Double-click the user you created. e. f. Select the newly created role to associate the user with the role. Click OK.

Lab Answer Key: Designing Security

Exercise 2: Creating an FBA-Claims Site


Task 1: Create a new SharePoint Web application
As mentioned earlier, forms-based authentication now requires a Web application to use Claims-mode authentication. 1. 2. 3. 4. On the Start Menu, point to All Programs, point to Microsoft SharePoint 2010 Products, and click on SharePoint 2010 Central Administration. Click Application Management. Select Manage Web applications and click New. Specify the following values in the Create New Web Application dialog box: a. b. c. Select Claims-Based Authentication. Specify a port value of 888. Select the Enable Forms-Based Authentication (FBA) check box.

d. Type fbaMembers in the ASP.NET Membership provider name field. e. f. g. h. 5. 6. 7. Type fbaRoles in the ASP.NET Role Manager name field. Choose Create a new application pool. Choose Predefined. Select Network Service.

Click Application Management. Click Create Site Collection. Select the new web application you just created. Set the title to Forms Site Collection and select the Team Site template. Specify the SHAREPOINT\Administrator account as the Primary Site Collection Administrator.

Task 2: Add connection strings to all web.config files


As noted in Lesson 2, enabling forms-based authentication requires updates to three web.config files: Forms Web application (created in Task 3) Central Administration Security Token Service application

Lab Answer Key: Designing Security

The web.config files are located in two different folders: The root folder for the Forms Web application is located under C:\inetpub\wwwroot\wss\VirtualDirectories\888. The root folders for Central Administration are located under C:\inetpub\wwwroot\wss\VirtualDirectories\28522. The root folder for the Security Token Service is located under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions \14\WebServices\SecurityToken. Add the following connection string to the web.config files (as a child of the <configuration> node):

Note: Be sure to place this node after the configSections node; otherwise, you will get an error stating that configSections must be the first child of the configuration node.

<connectionStrings> <add name="fbaSQL" connectionString="Server=.\SHAREPOINT;Database=aspnetdb;Integrated Security=true" /> </connectionStrings>

Task 3: Add PeoplePicker wildcard information


You will need to update the following configuration files: Forms Web application Central Administration Add the following text as a child of the <PeoplePickerWildcards> node:
<add key="fbaMembers" value="%" />

Lab Answer Key: Designing Security

Task 4: Define membership and role providers for Central Administration


Update the membership and role provider information contained within Central Administrations web.config file with the following text:
<roleManager enabled="true" cacheRolesInCookie="false" cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="AspNetWindowsTokenRoleProvider" createPersistentCookie="false" maxCachedResults="25"> <providers> <clear /> <add connectionStringName="fbaSQL" applicationName="/" name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </roleManager> <membership defaultProvider="fbaMembers" userIsOnlineTimeWindow="15" hashAlgorithmType="" >

(Code continued on the following page.)

Lab Answer Key: Designing Security

<providers> <clear /> <add connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership>

Task 5: Define membership and role providers for the Forms Web application
Update the membership and role provider information contained within Form Web applications web.config file with the following text:
<roleManager enabled="true" cacheRolesInCookie="false" cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="c" createPersistentCookie="false" maxCachedResults="25"> <providers> <clear /> <add connectionStringName="fbaSQL" applicationName="/" name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

(Code continued on the following page.)

10

Lab Answer Key: Designing Security

<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add name="c" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleP rovider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> </providers> </roleManager> <membership defaultProvider="i" userIsOnlineTimeWindow="15" hashAlgorithmType=""> <providers> <clear /> <add connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembe rshipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> </providers> </membership>

Lab Answer Key: Designing Security

11

Task 6: Define membership and role providers for the Security Token Service application
Update the membership and role provider information contained within the Security Token Services web.config with the following information:

Note: <system.web> does not exist in a default out-of-box installation. Add the following as the last child of the <configuration> node.

<system.web> <membership> <providers> <add connectionStringName="fbaSQL" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordAttemptWindow="10" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" name="fbaMembers" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership> <roleManager enabled="true"> <providers> <add connectionStringName="fbaSQL" applicationName="/" name="fbaRoles" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </roleManager> </system.web>

12

Lab Answer Key: Designing Security

Task 7: Use Central Administration to designate the first FBA user for the Forms Web application
1. 2. 3. In Central Administration, click on Application Management. Under Site Collections, click Change Site Collection Administrators. Select the site collection you created in Task 1.

4. Set one of the FBA users you created in Task 2 as a site collection administrator and click OK. If all associations have been properly set, the Central Administration site should be able to locate the FBA users.

Task 8: Navigate to the Forms Web application, view user properties.


1. 2. 3. Navigate to your newly configured site. Dont forget to use the port number specified when creating the Web application (http://sharepoint:888). You should see a login page that allows you to pick between Windows authentication and Forms authentication. Follow these steps:
a.

Choose Forms Authentication. Login using the credentials of the user created in Exercise 1, Task 2. Once on the home page, select the user control that displays your user name (upper right corner).

b. c.

d. Select My Settings. 4. Verify that your login name has the new claims-based format.

Lab Answer Key: Designing Security

13

Optional Exercise 3: Viewing Claims for an FBA User


Task 1: Deploy farm solution
Open the Module 12 solution. The ShowMyClaims project is a farm solution that contains a single Web Part that simply enumerates any claims if present. It will also show two property values of SPUser. If you deploy the project to the Forms Web application and the Web Part to any page, you should see output that looks like the data in the following figure.

14

Lab Answer Key: Designing Security

Lab B: Solving a Security Issue


This lab is designed to get students thinking about different options that may exist when presented with a security issue.

Exercise 1: Understanding the Scope and Relating it to Configuration


There is no right answer. There are a variety of questions that can be compiled to help determine the problem. 1. 2. 3. 4. 5. 6. 7. Is the problem related to all users or specific users? How are the users provisioned? How are the users added to the SharePoint sites? Are there multiple site collections? Does the issue manifest itself in particular locations (i.e. site or sub-site, list or document library)? Is item-level security being used in lists? Does the issue change based on some business condition?

Lab Answer Key: Designing Security

15

Exercise 2: Designing a Security Strategy


There is no right answer. This lab is designed to explore options. Possible solutions may begin with: Creating roles within the FBA database. If you are accustomed to using security groups in Active Directory, getting into the practice of creating, managing, and using FBA roles should be rather easy. Get your development team into the habit of using groups and roles. Using SPGroups, designating permission levels instead of individuals. Believe it or not, although this may seem like an overly simplified solution, this is an overlooked design parameter. Creating a claims provider to handle some of the dynamic criteria. This would be an interesting way to augment the current functionality by adding claims that can be leveraged elsewhere within the SharePoint infrastructure. Separating document libraries and lists based on functional needs or permission requirements rather than trying to use item-level permissions in a single comprehensive library. For example, rather than simply having a single list named Documents that contains various folders and documents that have unique permissions, it might be better to create multiple libraries that each represent the appropriate permission group (Manager Documents, Sales Documents, and so on).

Lab Answer Key: Designing for Page and Data Access Performance

Module 13
Lab Answer Key: Designing for Page and Data Access Performance
Contents:
Exercise 1: Using the SharePoint Server 2010 Developer Dashboard to Capture Performance Metrics Exercise 2: Leveraging the SharePoint Server 2010 Search API for Large Data Queries 2 8

Lab Answer Key: Designing for Page and Data Access Performance

Lab: Designing for Page and Data Access Performance


Exercise 1: Using the SharePoint Server 2010 Developer Dashboard to Capture Performance Metrics
Task 1: Enable the SharePoint Developer Dashboard
1. Start the Microsoft SharePoint 2010 Management Shell by clicking Start, and selecting All Programs, Microsoft SharePoint 2010 Products, SharePoint 2010 Management Shell. Enter the following Windows PowerShell commands to enable the Developer Dashboard:
$dash = [Microsoft.SharePoint.Administration.SPWebService]::ContentService .DeveloperDashboardSettings; $dash.DisplayLevel = 'OnDemand'; $dash.TraceEnabled = $true; $dash.Update()

2.

Task 2: Deploy the Contoso.Performance.Lists solution


1. 2. 3. Open the Contoso.Performance.sln file from the folder E:\Student \Module 13\Module13_Lab_code\Contoso.Performance. Click the Contoso.Performance.Lists project. In the Properties window, change the Site URL property to http://sharepoint/student/module13/. Right-click the Contoso.Performance.Lists project, and click Deploy. See the status bar to check whether the preceding task completed successfully.

Lab Answer Key: Designing for Page and Data Access Performance

Task 3: Add performance instrumentation to a custom Web Part


1. Edit the ListViewWebPart user control class file in Microsoft Visual Studio 2010 by locating and expanding the Contoso.Performance.ListViewWebPart project in the Contoso.Performance solution. Click the plus sign to the left of ListViewWebPart in the project. Click the plus sign to the left of the ListViewWebPart.ascx file. Double-click the ListViewWebPart.ascx.cs file to open it in the Visual Studio 2010 editor. Add a custom monitor scope to the GetItemsButton_Click event to capture code execution in the event. Click the plus sign to the left of the Events region. In the GetItemsButton_Click event handler, wrap the existing code in the following using statement and instantiate a new SPMonitoredScope:
using (SPMonitoredScope getListItemsScope = new SPMonitoredScope(GetListItems)) { //Existing code }

2. 3. 4. 5. 6. 7.

The resulting code should resemble the following:

8. 9.

Add a custom monitor subscope to the GetListItems method to capture metrics for the query against the target SPList object. Click the plus sign to the left of the Methods region.

Lab Answer Key: Designing for Page and Data Access Performance

10. In the GetListItems method, locate the following line of code:


dt = list.GetItems(query).GetDataTable();

11. Wrap the preceding code in a new using statement and instantiate a new SPMonitoredScope. Because this scope is executed inside of the previous scope, it is displayed as a child object of the parent scope.
using (SPMonitoredScope getListItemsScope_Query = new SPMonitoredScope(GetListItems_Query)) { //Existing code }

The resulting code should resemble the following:

Lab Answer Key: Designing for Page and Data Access Performance

12. Click the Contoso.Performance.ListViewWebPart project. In the Properties window, change the Site URL property to http://sharepoint/student /module13/. 13. Press F5 to build and deploy the solution automatically. 14. Alternatively, right-click the Contoso.Performance.ListViewWebPart project and select Deploy.

Task 4: Analyze results in the Developer Dashboard


1. 2. 3. 4. 5. 6. 7. In SharePoint 2010, open the target site, http://sharepoint/student/module13, in a Web browser. Click Page tab on the ribbon and then click Edit Page. In the Left Web Part zone, click Add a Web Part. In the Categories section, click Contoso. From the list of available Web Parts, click Contoso Performance List View, and then click Add. Click Stop Editing on the ribbon. Click the Developer Dashboard icon located in the upper-right corner of the page. If you get a dialogue box asking that the page needs to be resent, click Retry.

Lab Answer Key: Designing for Page and Data Access Performance

The Developer Dashboard will load at the bottom of the page. Note that the custom scopes added to the ListViewWebPart do not appear in the list of monitored events:

8.

In the Contoso Performance List View Web Part, select the Contoso Widgets list option from the drop-down list box, and then click Get List Items.

Lab Answer Key: Designing for Page and Data Access Performance

9.

Review the updated information in the Developer Dashboard. Note that the custom GetListItems scope is present, along with the associated GetListItems_Query subscope.

10. Review the performance metrics provided. Take note of the additional entries in the Database Queries section and the difference in overall execution time.

Results: After this exercise, you should have instrumented the code to write output results to the Developer Dashboard and deployed the solution to SharePoint.

Lab Answer Key: Designing for Page and Data Access Performance

Exercise 2: Leveraging the SharePoint Server 2010 Search API for Large Data Queries
Task 1: Create a search query to retrieve list items
1. 2. 3. 4. 5. Locate and expand the Contoso.Performance.ListViewWebPart project in the Contoso.Performance solution. Click the plus sign to the right of the ListViewSearchWebPart project item. Click the plus sign to the right of ListViewSearchWebPartUserControl.ascx. Double-click the ListViewSearchWebPartUserControl.ascx.cs file. Modify the GetListItems method to retrieve list items from the search results by retrieving the specified list using the Web and ListName parameters passed into the method:
SPList list = web.Lists[ListName];

6.

Remove spaces from the list name to match the value of the managed metadata property created in the previous task:
ListName = ListName.Replace(" ", "");

7.

Instantiate a new FullTextSQLQuery object:


FullTextSqlQuery searchQuery = new FullTextSqlQuery(ServerContext.Current);

8. Set the search query parameters:


searchQuery.TrimDuplicates = true; searchQuery.EnableStemming = true; searchQuery.RowLimit = 10000; searchQuery.ResultTypes |= ResultType.RelevantResults;

9.

Assign a search query string to the searchQuery object. This query selects specific columns from the search results using the previously assigned managed metadata properties and the default search scope:
searchQuery.QueryText = "SELECT Title, ProductID, ProductQuantity FROM Scope() WHERE CONTAINS (*, '" + ListName + "')";

Lab Answer Key: Designing for Page and Data Access Performance

10. Create a DataTable object to hold the search results:


DataTable dt = new DataTable();

11. Create a custom monitor subscope to measure the search query execution:
using (SPMonitoredScope getListItemsScope_Query = new SPMonitoredScope("GetListItemsSearch_SqlQuery")) { }

12. Inside the using statement, execute the search query:


ResultTableCollection resultTables = searchQuery.Execute();

13. Isolate the RelevantResults table from the query results:


ResultTable relevantResults = resultTables[ResultType.RelevantResults];

14. Populate the previously created DataTable object with the query results:
dt.Load(relevantResults, LoadOption.OverwriteChanges);

15. Bind the DataTable to the GridView to display the query results in the Web Part:
ListViewGrid.DataSource = dt; ListViewGrid.DataBind(); ListViewGrid.Visible = true;

16. Press F5 to build, package, and deploy the solution.

10

Lab Answer Key: Designing for Page and Data Access Performance

Task 2: Analyze performance metrics in the Developer Dashboard


1. 2. 3. 4. Click Edit Page on the ribbon. In the Left Web Part zone, click Add a Web Part. Locate the Contoso folder in the Categories section of the expanded ribbon bar. From the list of available Web Parts, select Contoso Performance List View with Search, and click the Add button.

5. 6. 7.

Click Stop Editing on the ribbon. Click the Developer Dashboard icon located in the upper right of the page. If you get a dialogue box asking that the page needs to be resent, click Retry. In the Contoso Performance List View Web Part, select the Contoso Widgets option from the drop-down list, and click the Get List Items button.

Lab Answer Key: Designing for Page and Data Access Performance

11

8.

Review the execution metrics in the Developer Dashboard and compare them to the metrics reported when retrieving items with the ListViewWebPart that does not use the Search API. The performance of the Search Web Part should be significantly better. Also, note the additional performance data available in the Developer Dashboard from the Search query.

Results: After this exercise, you should have configured Search, modified the code to retrieve list items using the Search API, and compared the performance metrics in the Developer Dashboard.

Lab Answer Key: Designing a Testing Strategy

Module 14
Lab Answer Key: Designing a Testing Strategy
Contents:
Exercise 1: Conducting Unit Testing Exercise 2: Conducting Performance Testing Exercise 3: Conducting Load Testing 2 8 10

Lab Answer Key: Designing a Testing Strategy

Lab: Designing a Testing Strategy


Exercise 1: Conducting Unit Testing
Task 1: Create, execute, and automate a unit test
1. Create a Unit Test project. a. b. c. 2. Open the Contoso.Testing.sln file from the folder E:\Student\Module 14 \Module14_Lab_Code\Contoso.Testing. Click the Contoso.Testing.WebParts project. In the Properties window, change the Site URL property to http://sharepoint/student/module14/. Locate and open the ListView_View.cs file within the Contoso.Testing.WebParts project.

Create a new test project. a. Right-click the GetListAsGridView method within the Contoso.Testing.WebParts.ListView_View class.

Lab Answer Key: Designing a Testing Strategy

b.

Select Create Unit Tests from the context menu. In the Create Unit Tests dialog box, be sure that the GetListAsGridView method is selected. In the Output Project options at the bottom of the dialog, select Create a new Visual C# test project, and then click OK.

c.

Enter Contoso.Testing.UnitTests as the name of the new project. Microsoft Visual Studio will generate the project and open the ListView_ViewTest.cs class file in the IDE.

d. Add a Using statement for System.Xml to the ListView_ViewTest.cs class file. 3. Author and validate unit tests. a. i. Arrange the test. Locate the automatically generated test method entitled GetListAsGridViewTest (the method will be decorated with the [TestMethod()] attribute).

Lab Answer Key: Designing a Testing Strategy

ii. iii.

Delete the generated code. Prepare the test by creating the necessary objects and variables. The test will require a valid DataTable object with at least one column and one row of data. The data table will need at least one column title that is XML encoded in order to verify the text manipulation functions in the target method. In addition, a string value for the XML Decoded title and an integer value for the number of table rows will be needed to verify that the test returns valid results. Insert the following code into the GetListAsGridViewTest method:
//Arrange string tableColumnName = "Test_x0020_Column"; string tableColumnName_Decoded = XmlConvert.DecodeName(tableColumnName); DataTable testTable = new DataTable(); testTable.Columns.Add(tableColumnName); DataRow row = testTable.NewRow(); row[tableColumnName] = "Test Value"; testTable.Rows.Add(row); int tableRows = testTable.Rows.Count;

b.

Add test actions. Using the newly created DataTable, call the ListView_View.GetListAsGridView method and retrieve the resulting row count and column name into new variables:
//Act GridView testGrid; testGrid = ListView_View.GetListAsGridView(testTable); int gridRows = testGrid.Rows.Count; string gridColumnName = testGrid.HeaderRow.Cells[0].Text;

c. i.

Create test assertions. The result of these assertions determines whether the test passes or fails. Verify that the number of rows in the GridView equal the number of rows in the test DataTable object:
//Assert Assert.AreEqual(tableRows, gridRows);

Lab Answer Key: Designing a Testing Strategy

ii.

Verify that the encoded column name set in the Arrange section has been properly decoded and is equal to the tableColumnName_Decoded variable:
Assert.AreEqual(tableColumnName_Decoded, gridColumnName);

4.

Execute the Unit Test. Right-click the GetListAsGridViewTest method and select Run Tests. After the test completes, the Test Results window will appear. If the test was successful, a Passed value will be displayed in the Results column:

5.

Automate test execution. i. Create a Test List. From the Test menu, select Create New Test List.

Lab Answer Key: Designing a Testing Strategy

ii.

Type UnitTests as the name of the new Test List and click OK.

iii.

Click the All Loaded Tests in the test explorer tree view. Check the box next to the GetListAsGridView_Test test.

iv. v.

Save the solution. This will generate a .vsmdi file needed by the MSTest.exe command-line utility to run the specified tests. Open the Properties window of the Contoso.Testing.WebParts project.

Lab Answer Key: Designing a Testing Strategy

vi.

On the Build Events tab, insert the following command as the value of the post-build event command line:
"$(DevEnvDir)mstest.exe" /testmetadata:"$(SolutionDir)Contoso.Testing.vsmdi" /testlist:UnitTests

This command will invoke the MSTest utility, load the test metadata from the .vsmdi file located in the root of the solution, and execute the tests specified in the UnitTests Test List. vii. viii. Open the Output window (View > Output). Rebuild the Contoso.Testing solution. Note the results of the unit tests in the Output window.

Results: After this exercise, you should have created a unit test, executed the unit test, and automated execution of the unit test as part of the build process for the project.

Lab Answer Key: Designing a Testing Strategy

Exercise 2: Conducting Performance Testing


Task 1: Create and execute a performance test
1. Create a performance test project. a. b. c. Right-click the Contoso.Testing solution and select Add > New Project. Set the framework type to .NET Framework 4. From the list of installed templates, select the Test category, and then select Test Project.

d. In the Name field, type Contoso.Testing.Performance and click OK. e. By default, Visual Studio will assume that a unit test is desired and create a default class entitled UnitTest1.cs. Select this class in the Solution Explorer and delete it.

2. 3. 4.

Right-click the Contoso.Testing.Performance project and select Add > Web Performance Test. A browser window will appear. Enter the URL http://sharepoint/student/module14/default.aspx and press ENTER. After the page load is complete, click Stop in the Web Test Recorder pane. Visual Studio will automatically generate the test sequence and create a test class entitled WebTest1.webtest. Add a response time parameter to the test. a. b. c. Open WebTest1.webtest. Remove URL references to ScriptResx.ashx from the list of target URLs for the WebTest1 object. Right-click the remaining URL node in WebTest1 and select Properties.

5.

d. In the Properties pane, scroll down to the Response Time Goal parameter and enter a value of 8. This indicates that a successful request for this URL will respond in 8 seconds or fewer. 6. Run the test and analyze the results. a. Review the performance data in the test result report. Note the Status, Total Time, and Request Time statistics for the base URL.

Lab Answer Key: Designing a Testing Strategy

b. c. 7.

Expand the base URL node and note the statistics for each linked resource.

Review the Details window to view results of the default validations for Response URL and Response Time Goal. Close the Test Results tab.

Add a validation rule and run the test again to execute the rule. a. b. c. Right-click the WebTest1 node and select Add Validation Rule. Select the Find Text rule. In the Find Text field, type Contoso Performance List View and click OK.

Note: This step requires either that Exercise 1 be completed and the Contoso Performance List View Web Part has been deployed or that a sample Web Part of any type be added to the page entitled Contoso Performance List View with the default chrome options enabled.

d. Run the test again. e. Review the Details window to determine the status of the Find Text validation rule.

Results: After this exercise, you should have created a performance test and validated the results of the tests against the target web application.

10

Lab Answer Key: Designing a Testing Strategy

Exercise 3: Conducting Load Testing


Task 1: Create and execute a load test
1. Add a load test to the project. a. Right-click the Contoso.Testing.Performance project and select Add > Load Test. Visual Studio will launch the Create New Load Test Wizard. Click Next on the opening screen of the wizard to begin configuring the load test.

Lab Answer Key: Designing a Testing Strategy

11

b.

In the Enter a name for the load test scenario field, enter Contoso Performance Load Test and select the Do not use think times option. Click Next to continue.

c.

Accept the default pattern settings, and click Next to continue.

12

Lab Answer Key: Designing a Testing Strategy

d. In the Test Mix Model step, select the Based on the number of virtual users option, and click Next to continue.

e. i. ii.

In the Test Mix step, add a new Web test. Click the Add button. Select WebTest1 and move it to the list of selected tests.

Lab Answer Key: Designing a Testing Strategy

13

iii. iv.

Click OK. Click Next to continue.

f.

In the Network Mix step, accept the defaults, and click Next to continue.

14

Lab Answer Key: Designing a Testing Strategy

g.

In the Browser Mix step, accept the defaults and click Next to continue.

h.

In the Counter Sets step, add a computer to the counter set. i. ii. Click Add computer. Enter the name of the computer the test is being executed on, and select the ASP.NET check box. Click Next to continue.

iii.

Lab Answer Key: Designing a Testing Strategy

15

i.

In the Run Settings step, change the run duration to 3 minutes. Click Finish to complete the wizard.

2.

Run the load test. a. In the LoadTest1.loadtest tab, click the run icon.

Visual Studio will initiate the load test and load the test monitors during test progress. b. 3. Take note of the various graphs in the test results report while the test is executing.

Review the load test results.

Results: After this exercise, you should have created a load test and validated the results of the test against the target web application.

Вам также может понравиться