312
OFFICIAL MICROSOFT LEARNING PRODUCT 10232A Lab Instructions and Lab Answer Key: Designing and Developing Microsoft® SharePoint® Server 2010 Applications

10232AD-ENU_LabManual

  • Upload
    -

  • View
    71

  • Download
    2

Embed Size (px)

Citation preview

Page 1: 10232AD-ENU_LabManual

O F F I C I A L M I C R O S O F T L E A R N I N G P R O D U C T

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

Page 2: 10232AD-ENU_LabManual

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

Page 3: 10232AD-ENU_LabManual

Lab Instructions: ASP.NET Advanced Concepts for SharePoint 1

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 3

Exercise 2: Using Fiddler to Examine Page Size 4

Exercise 3: Reducing Page Size 5

Lab B: Memory and Performance

Exercise 1: Starting a Performance Capture 6

Exercise 2: Reviewing the Report 8

Exercise 3: Resolving Memory Issues and Retest 9

Page 4: 10232AD-ENU_LabManual

2 La

Lab A

ScSeththto

b Instructions: ASP.N

A: Page

cenario everal users inhe manufacturhe performancool.

NET Advanced Conce

Size an

n a remote offiring system buce may be slow

epts for SharePoint

d ViewS

ice are complauilt on ASP.NEw for them and

State

aining about thET 2.0. You’ve d resolve the i

he overall perfbeen asked to

ssues using th

formance of o identify whyhe Fiddler

y

Page 5: 10232AD-ENU_LabManual

Lab Instructions: ASP.NET Advanced Concepts for SharePoint 3

Exercise 1: Using Fiddler to Observe Page Loading The Fiddler tool is used for diagnosing and resolving issues on Web sites. It’s 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. Launch Fiddler.

2. 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.

Page 6: 10232AD-ENU_LabManual

4 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.

Page 7: 10232AD-ENU_LabManual

Lab Instructions: ASP.NET Advanced Concepts for SharePoint 5

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. Open default.aspx.

2. Turn off ViewState as much as is practical.

3. 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.

Page 8: 10232AD-ENU_LabManual

6 La

Lab B

ScRchapasap

EVapthPe

Th

1.

2.

b Instructions: ASP.N

B: Memo

cenario emote users hhanges you’vepplication ands time goes onpplication.

xercise 1: Visual Studio opplication andhe Analyze meerformance M

he main tasks

. Start captu

. Exercise th

NET Advanced Conce

ory and

have indicated e made. Howevd you’ve been n. You’ve been

Starting a ffers a set of to

d understand henu. They prov

Monitor that yo

s for this exerc

re.

he application.

epts for SharePoint

Perfor

that performaver, the attentimade aware th

n asked to iden

Performaools to help yohow memory vide even morou learned abo

cise are as follo

mance

ance has imprion has causedhat the applica

ntify what is ha

ance Captuou analyze theis being used.

re detail than tout earlier in th

ows:

roved due to thd more focus oation seems toappening and

ure e performance You can acce

the Reliability his module.

he ViewState on the o get slower improve the

e of your ss them from and

Page 9: 10232AD-ENU_LabManual

Lab Instructions: ASP.NET Advanced Concepts for SharePoint 7

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.

Page 10: 10232AD-ENU_LabManual

8 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.

Page 11: 10232AD-ENU_LabManual

Lab Instructions: ASP.NET Advanced Concepts for SharePoint 9

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. Identify the memory issues.

2. Resolve the memory issues by eliminating the poor pattern.

3. 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 that’s likely to change quickly

(LinePerformance).

• Remove the single instance pattern that’s implemented incorrectly.

Task 3: Retest • Verify different (better) results.

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

Page 12: 10232AD-ENU_LabManual

Lab Instructions: Designing for User Experience 1

Module 2 Lab Instructions: Designing for User Experience

Contents: Lab A: Selecting Page Parts

Exercise 1: Line Dashboard 4

Exercise 2: Manager’s Dashboard 5

Exercise 3: Alert Notification 6

Lab B: Selecting Page Types

Exercise 1: Plant Summary Page 9

Exercise 2: Plant Configuration Page 10

Exercise 3: Employee List 11

Exercise 4: Line Status 12

Page 13: 10232AD-ENU_LabManual

2 La

Lab A

SuInunuste

Ahesctom

b Instructions: Desig

A: Select

upporting Inn this lab, we’rnderstand howsed to build th

eams to talk ou

s with the pagelp you focus cenario to deteo illustrate of t

may be possible

gning for User Experi

ting Pag

nformationre focused on w to make thehe pages and cut the right de

ge types, the don the types oermine the corthe types of que to have a con

ence

ge Parts

the parts that e right decisioncomplete the uecisions for eac

ecision tree shof questions thrrect control tyuestions and dntrol that doe

s

go on to the pns around theuser experiencch of the follo

hown in the nehat you shouldype. Again, th

decisions. Duesn’t directly fi

page. The objee controls and ce. You’ll be wwing compon

ext slide is desd be asking abe decision tree

e to over-simplt this decision

ective is to components

working in nents.

signed to bout the e is designed lification, it

n tree.

Page 14: 10232AD-ENU_LabManual

Lab Instructions: Deesigning for User Expperience 33

Page 15: 10232AD-ENU_LabManual

4 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 machine’s 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.

Page 16: 10232AD-ENU_LabManual

Lab Instructions: Designing for User Experience 5

Exercise 2: Manager’s 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 what’s 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.

Page 17: 10232AD-ENU_LabManual

6 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.

Page 18: 10232AD-ENU_LabManual

Lab B

SuBnemthsosein

ThUisoban

B: Select

upporting Inecause of the meed to be crea

move. They alsohis lab, you’ll wolve the probleeveral differennformation you

he following dUnderstand thas more complebjective is to ilnswers to thos

ting Pag

nformationmove from the

ated in SharePoo need to suppwork togetherem including

nt potential pagu’ll need to m

diagram is inteat this decisionex than what allustrate the tyse questions c

ge Type

e manufacturioint to supporport enhanced

r in teams to idthe identificatge types. You’

make the best d

ended to aid yn tree is not da diagram like ypes of questiocan lead you d

Lab Instructions: De

es

ing applicationrt different aspd functionalitydentify the pottion of the benll also try to d

decision for the

you with makinesigned to be this can show

ons that you sown one path

esigning for User Exp

n, several diffepects of the apy based on thetential page tynefits and weadetermine whae page type.

ng these decisauthoritative.

w. The decisionshould ask, anh or another.

perience 7

erent pages pplication’s e platform. In ypes that will knesses of

at additional

sions. The problem

n tree’s nd then the

7

Page 19: 10232AD-ENU_LabManual

8 Lab Instructions: Desiggning for User Experience

Page 20: 10232AD-ENU_LabManual

Lab Instructions: Designing for User Experience 9

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 there’s 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.

Page 21: 10232AD-ENU_LabManual

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 won’t 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.

Page 22: 10232AD-ENU_LabManual

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 employees—an employee directory—for 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, it’s 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.

Page 23: 10232AD-ENU_LabManual

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 isn’t 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 they’re having a problem and it’s 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 isn’t 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.

Page 24: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data 1

Module 3 Lab Instructions: Designing for Data

Contents: Lab A: Time Tracking

Exercise 1: Creating List Views 2

Exercise 2: Adding Indexes 4

Lab B: Invoice Management

Exercise 1: Creating an Invoice Content Type 7

Exercise 2: Enabling Content Organization 8

Exercise 3: Testing Content Organization 9

Page 25: 10232AD-ENU_LabManual

2 La

Lab A

E

ScCovmdem

Thco

Th

1.

2.

3.

b Instructions: Desig

A: Time

xercise 1:

cenario Contoso wants

ver 2,000 wormonths, manag

eveloped to mmake sure that

he time-trackiontains time-tr

he main tasks

. Create a vie

. Create a vie

. Create a vie

gning for Data

Trackin

Creating L

to use SharePrkers in 20 plagers at Contos

maintain perforperformance

ng site has beracking inform

s for this exerc

ew for accoun

ew for aggrega

ew for aggrega

ng

List Views

Point to do timants and a planso know that thrmance. You’vis acceptable.

en created andmation.

cise are as follo

nting to aggreg

ating time by e

ating time by p

me recording fon to keep the dhe system nee

ve been asked

d includes a ti

ows:

gate time.

employee.

plant and by e

or each of its wdata in SharePeds to be propto design a se

ime-tracking li

employee.

workers. WithPoint for two perly et of views to

ist that

h

Page 26: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data 3

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.

Page 27: 10232AD-ENU_LabManual

4 Lab Instructions: Designing for Data

Exercise 2: Adding Indexes

Scenario The work you’ve 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. You’ve been asked to look into adding indexes to the list to improve performance.

The main tasks for this exercise are as follows:

1. Add an index by employee and by start date.

2. Add an index by plant and by employee.

3. 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 shouldn’t 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.

Page 28: 10232AD-ENU_LabManual

Lab B

ScCevveth

Bco

K1.

2.

3.

B: Invoic

cenario Contoso is planveryone in accendor invoiceshe future.

ecause accounontributors to

Key Consider. Contributo

. The systemprovided.

. The solutioproblems w

ce Mana

nning to use Scounting can ss may contain

nts payable ofthave to know

rations ors can be requ

m must ensure

on should be twith invoice pr

agemen

harePoint to ssee all of the in

n confidential i

ten uses tempw where to file

uired to know

that the appr

transportable trocessing.

Lab Inst

nt

store invoices nvoices from einformation th

orary staff, thedocuments.

w where to file

opriate metad

to other divisi

tructions: Designing f

from vendorsevery vendor, bhat needs to be

e department

documents.

data about the

ions that face s

for Data 5

. Right now, but some e restricted in

doesn’t want

invoice is

similar

5

Page 29: 10232AD-ENU_LabManual

6 Lab Instructions: Designing for Data

4. The members of accounting need to be able to open the invoices from the Office client applications.

5. 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.

Page 30: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data 7

Exercise 1: Creating an Invoice Content Type The main tasks for this exercise are as follows:

1. Create the site columns for the invoice content type.

2. 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.

Page 31: 10232AD-ENU_LabManual

8 Lab Instructions: Designing for Data

Exercise 2: Enabling Content Organization The main tasks for the exercise are as follows:

1. Activate content organization.

2. Add the invoice content type to libraries.

3. 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.

Page 32: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data 9

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.

Page 33: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data Capture and Integration 1

Module 4 Lab Instructions: Designing for Data Capture and Integration

Contents: Lab A: Creating External Lists

Exercise 1: Connecting to the Data Source 3

Exercise 2: Defining the External Content Types 4

Exercise 3: Defining the External Lists 5

Exercise 4: Setting Security for the Content Types 6

Exercise 5: Defining an Association 7

Lab B: Creating an InfoPath Form

Exercise 1: Creating the Calculations 9

Exercise 2: Publishing the Form to a SharePoint Library 10

Page 34: 10232AD-ENU_LabManual

2 La

Lab A

ScCsitoas

b Instructions: Desig

A: Creati

cenario Contoso’s enteringle Microsofo review in Shasked to conne

gning for Data Captu

ing Exte

rprise resourcft SQL Server®arePoint the pct SharePoint

re and Integration

ernal Li

ce planning (E® database. Thpurchase order

to the ERP sy

sts

RP) system is he purchasing rs from the ER

ystem.

a simple systemanager want

RP system. You

em that uses ats to be able u’ve been

a

Page 35: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data Capture and Integration 3

Exercise 1: Connecting to the Data Source The main tasks for this exercise are as follows:

1. Open SharePoint Designer.

2. Create a starting content type.

3. 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.

Page 36: 10232AD-ENU_LabManual

4 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. Create the GL Account content type.

2. Create the Vendor content type.

3. Create the Purchase Request Header content type.

4. 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.

Page 37: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data Capture and Integration 5

Exercise 3: Defining the External Lists The main tasks for this exercise are as follows:

1. Create the GL Accounts external list.

2. Create the Vendors external list.

3. Create the Purchase Request Header external list.

4. 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.

Page 38: 10232AD-ENU_LabManual

6 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. Go to the Business Data Connectivity Service in Central Administration.

2. 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 you’ve created to read or add data.

Page 39: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data Capture and Integration 7

Exercise 5: Defining an Association The main tasks for this exercise are as follows:

1. Open the Purchase Request Line content type.

2. 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.

Page 40: 10232AD-ENU_LabManual

8 La

Lab B

ScThpuasprca

FoE

b Instructions: Desig

B: Creati

cenario he purchasingurchased requsked to designrocess with a wan use a one-to

or this exercis:\Student\Mo

gning for Data Captu

ing an I

g manager is puests from papn a form that cworkflow. Youo-many relatio

se, you use theodule4 directo

re and Integration

nfoPath

preparing to trper to a SharePcan be used latu have decidedonship, which

e PurchaseReqory.

h Form

ransition the aPoint workflowter when you wd to create an isn’t supporte

questForm-Sta

pproval procew process. Youwant to automInfoPath form

ed on list form

rter.xsn file lo

ess for u have been

mate the m so that you ms.

ocated in the

Page 41: 10232AD-ENU_LabManual

Lab Instructions: Designing for Data Capture and Integration 9

Exercise 1: Creating the Calculations The main tasks for this exercise are as follows:

1. Convert Vendor to a drop-down list.

2. Convert GL Account to a drop-down list.

3. 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.

Page 42: 10232AD-ENU_LabManual

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. Decide whether to publish the form as a content type or as a form.

2. 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.

Page 43: 10232AD-ENU_LabManual

Lab Instructions: Designing Artifacts 1

Module 5 Lab Instructions: Designing Artifacts

Contents: Lab A: Incident Response Site

Exercise 1: Evaluating the Requirements 3

Exercise 2: Designing the Solution 6

Lab B: Expense Reports

Exercise 1: Evaluating the Requirements 8

Exercise 2: Designing the Solution 12

Page 44: 10232AD-ENU_LabManual

2 La

Lab A

ScCsyocberepr

b Instructions: Desig

A: Incide

cenario Contoso is creaystem will recoccurs. An incideing knocked equirements inroblem.

gning Artifacts

ent Resp

ating an incideord the set of pdent can be soover to a criti

nto the approp

ponse S

ent managemeprocedures th

omething as sical leak in a kpriate set of co

Site

ent system for hat should be eimple as a coney system. You

omponents in

floor incidentenacted when

ntainer of mateur job is to coSharePoint to

ts. This an incident

erials nvert the

o solve the

Page 45: 10232AD-ENU_LabManual

Lab Instructions: Designing Artifacts 3

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, it’s 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.

Page 46: 10232AD-ENU_LabManual

4 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

Requirement Ob

ject

ive

Pre

cise

Mea

sura

ble

Un

der

stan

dab

le

Suggestions

Page 47: 10232AD-ENU_LabManual

Lab Instructions: Designing Artifacts 5

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

Requirement Res

po

nsi

ven

ess

Skill

s

Scal

e

Rat

e o

f C

han

ge

Suggestions

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

Page 48: 10232AD-ENU_LabManual

6 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.

Page 49: 10232AD-ENU_LabManual

Lab B

ScCprlobereso

B: Expen

cenario Contoso, like m

ressures and iooking to bothetter reportingesult, you’ve bolution in Sha

nse Repo

many other orgis improving ith standardize tg on the kindseen asked to trePoint to help

orts

ganizations, ists cost controlthe way that es of expenses ttransform a sep manage exp

Lab Inst

feeling the pil measures. Asxpense reportthat the organet of requiremepense reports.

tructions: Designing A

nch of compes a part of this ts are handled

nization is incuents into an in

Artifacts 7

etitive effort, they’re

d and to get urring. As a nexpensive

7

e

Page 50: 10232AD-ENU_LabManual

8 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 company’s 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 it’s 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 employee’s manager. Approval for payment is dependent upon the manager’s 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.

Page 51: 10232AD-ENU_LabManual

Lab Instructions: Designing Artifacts 9

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 employee’s 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?

Page 52: 10232AD-ENU_LabManual

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

Requirement Ob

ject

ive

Pre

cise

Mea

sura

ble

Un

der

stan

dab

le

Suggestions

Page 53: 10232AD-ENU_LabManual

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?

Requirement Res

po

nsi

ven

ess

Skill

s

Scal

e

Rat

e o

f C

han

ge

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.

Page 54: 10232AD-ENU_LabManual

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.

Page 55: 10232AD-ENU_LabManual

Lab Instructions: Designing Processing Solutions 1

Module 6 Lab Instructions: Designing Processing Solutions

Contents: Lab A: Designing an Engineering System

Exercise 1: Evaluating Client Capabilities and Requirements 4

Exercise 2: Evaluating Sandbox Capabilities and Requirements 6

Exercise 3: Evaluating Farm Deployment Capabilities and Requirements 7

Lab B: Creating a Sensor Report

Exercise 1: Designing Data Access for Sensor Data 9

Exercise 2: Designing a Processing Solution for the Report 10

Exercise 3: Designing a Processing Solution for the Approval 11

Page 56: 10232AD-ENU_LabManual

2 La

Lab A

ScCaroudedefo

Thhaprdaev

Thfrde

b Instructions: Desig

A: Desig

cenario Contoso’s enginre storing in Sut of the box cepartment to wevelopers writ

or the engineer

he engineerinas developed reventative maata to know wvaluate the risk

he precise algrequently, so thevelopment an

gning Processing Solu

ning an

neering deparharePoint. Thcalculated fieldwrite their owting code that ring departme

g department a set of predicaintenance to

when a machink of running t

orithm and thhe engineerinnd deploymen

utions

n Engine

rtment needs tis requires calds. You need t

wn code. Howeaffects the en

ent to accomp

captures datactive algorithma machine. Th

ne will be unavthe machine w

hreshold data tg department

nt of updates t

eering S

to do specialtylculations thatto enable memever, you also mtire farm. Devlish their goal

a points off of vms to determinhe productionvailable becau

without the ma

that perform tneeds to retai

to the system.

System

y analysis on dt are not possimbers of the enmust be conceelop an optionl.

various systemne when it’s timn department rse of maintenaaintenance.

the calculationin control of th

data they ible with ngineering erned about n (or options)

ms and me for relies on this ance and to

ns change he

)

Page 57: 10232AD-ENU_LabManual

Lab Instructions: Designing Processing Solutions 3

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.

Page 58: 10232AD-ENU_LabManual

4 Lab Instructions: Designing Processing Solutions

Exercise 1: Evaluating Client Capabilities and Requirements The main tasks for this exercise are as follows:

1. Evaluate the AJAX/JavaScript client.

2. Evaluate the Silverlight client.

3. 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?

Page 59: 10232AD-ENU_LabManual

Lab Instructions: Designing Processing Solutions 5

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 client-based solution can do.

Page 60: 10232AD-ENU_LabManual

6 Lab Instructions: Designing Processing Solutions

Exercise 2: Evaluating Sandbox Capabilities and Requirements The main tasks for this exercise are as follows:

1. Evaluate sandbox capabilities and limitations.

2. Evaluate development skills.

3. 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.

Page 61: 10232AD-ENU_LabManual

Lab Instructions: Designing Processing Solutions 7

Exercise 3: Evaluating Farm Deployment Capabilities and Requirements The main tasks for this exercise are as follows:

1. Evaluate farm deployment capabilities.

2. 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 farm-deployed solution can and cannot do.

Page 62: 10232AD-ENU_LabManual

8 La

Lab B

ScEovm

Threnana

Thinsoth

Bth

b Instructions: Desig

B: Creati

cenario ach month, Coversight agenc

month. You nee

he sensor dataemote file servames include ame unique.

he report is a ncluding aggreome boilerplathe data in the r

ecause Contoshis report.

gning Processing Solu

ing a Se

ontoso must pcies of each coed to build a s

a that is captuver. The formathe computer

document thaegations, averate text and somreport.

so operates in

utions

ensor Re

prepare a repoountry based osystem to crea

red is collecteat of the data is

name as well

at contains tabages, and stanme comments

n 30 countries,

eport

ort for the goveon sensor datate this report.

ed in a set of tes comma-sepaas a date/time

bles of summadard deviation

s from the heal

, 30 people ne

ernmental enva captured dur

ext files that ararated values fie stamp to ma

aries from all thns. It must alslth and safety

eed to be able

vironment ring the

re stored on a files. The file ake each

he sensors o include officer about

to generate

Page 63: 10232AD-ENU_LabManual

Lab Instructions: Designing Processing Solutions 9

Exercise 1: Designing Data Access for Sensor Data The main tasks for this exercise are as follows:

1. Evaluate the use of BCS.

2. 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.

Page 64: 10232AD-ENU_LabManual

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. Evaluate list views.

2. Evaluate Access.

3. 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.

Page 65: 10232AD-ENU_LabManual

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. Evaluate SharePoint Designer workflows.

2. 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 it’s finished.

Page 66: 10232AD-ENU_LabManual

Lab Instructions: Designing Packaging 1

Module 7 Lab Instructions: Designing Packaging

Contents: Lab A: Building a Business Document Solution

Exercise 1: Designing a Solution 3

Exercise 2: Creating the Final Solution 6

Lab B: Working with Dependencies

Exercise 1: Creating a Common Assembly 9

Exercise 2: Creating a Dependent Solution 10

Page 67: 10232AD-ENU_LabManual

2 La

Lab A

ScYocu

Csea appr

Npaandi

b Instructions: Desig

A: Buildi

cenario ou are a develustomer base.

Contoso provideveral differennew line is cre

ppropriate conrovision this li

Note: The intentackaging for thnd this lab quicifferent packag

gning Packaging

ing a Bu

loper at Conto

des a certificatnt documents teated, a certifintent types foribrary with th

t of this lab is the custom applckly highlights aging designs.

usiness

oso, Ltd., whic

ion package wthat together mication packagr that library ne appropriate

o provide you ication. You reca few different

Docum

ch is a large or

with each prodmake up the cges library neeneed to be deficontent types

with an opportceive a fairly gedesign options

ment Sol

ganization wit

duct. The packcertification pads to be set upined. Develops.

tunity to designeneric use case s that may resu

lution

th a global

kage includes ackage. When p and the

p a strategy to

n the scenario,

ult in

Page 68: 10232AD-ENU_LabManual

Lab Instructions: Designing Packaging 3

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. Get more details.

2. 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 platform—Microsoft 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.

Page 69: 10232AD-ENU_LabManual

4 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

Page 70: 10232AD-ENU_LabManual

Lab Instructions: Designing Packaging 5

• 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.

Page 71: 10232AD-ENU_LabManual

6 Lab Instructions: Designing Packaging

Exercise 2: Creating the Final Solution The main tasks for this exercise are as follows:

1. Create a Visual Studio 2010 project.

2. Add a content type to the project.

3. Create a site-scoped feature for the content type.

4. Add a list definition.

5. Create a Web-scoped feature for the list definition.

6. Ensure that the CPL_ContentTypes feature contains only one element.

7. 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.

Page 72: 10232AD-ENU_LabManual

Lab Instructions: Designing Packaging 7

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.

Page 73: 10232AD-ENU_LabManual

8 La

Lab B

ScYodesma

b Instructions: Desig

B: Worki

cenario ou are a develecided to placmaller units ofWeb Part that

gning Packaging

ing with

loper at Contoce common buf functionalityt uses the com

h Depe

oso Manufactuusiness logic iny to reference ammon assembl

ndencie

uring. Contoson a common aa common codly.

es

o’s developmeassembly. Thisde base. You n

nt team has s will allow need to create

Page 74: 10232AD-ENU_LabManual

Lab Instructions: Designing Packaging 9

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:

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

Page 75: 10232AD-ENU_LabManual

10 Lab Instructions: Designing Packaging

Exercise 2: Creating a Dependent Solution The main tasks for this exercise are as follows:

1. Add a sandboxed project.

2. Verify functionality.

3. Remove the farm solution.

4. 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:

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.Utility.GetDataFromSomewhere())));     } // End of CreateChildControls    } // End of CustomDataDisplay class  } // End of the Contoso.DemoApplication.Sandboxed.CustomDataDisplay namespace 

• 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.

Page 76: 10232AD-ENU_LabManual

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:

Page 77: 10232AD-ENU_LabManual

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 application’s 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).

Page 78: 10232AD-ENU_LabManual

Lab Instructions: Designing a Development Strategy 1

Module 8 Lab Instructions: Designing a Development Strategy

Contents: Lab A: Team-Based Logging and Configuration

Exercise 1: Appraising the List-Based Configuration 2

Exercise 2: Using a SharePoint List-Based Configuration 3

Exercise 3: Using SharePoint List-Based Logging 6

Exercise 4: Configuring the Logging Level 8

Lab B: Operational Logging

Exercise 1: Adding Logging to SharePoint ULS 10

Page 79: 10232AD-ENU_LabManual

2 La

Lab A

E

ScThm

Th

1.

T

Inpr

b Instructions: Desig

A: Team

xercise 1:

cenario he plant mana

members can s

he main task f

. Review the

ask 1: Review

n this exerciseros and cons o

Think abou

Evaluate th

gning a Development

-Based

Appraising

ager has set spee the target a

for this exercis

e options.

w the optio

, you will revieof each approa

ut how you pr

he pros and co

t Strategy

Loggin

g the List-

pecific targets and use it to m

se is as follow

ns

ew the configuach for this sc

rovide the con

ons for the sce

ng and C

-Based Con

for each manumonitor their p

ws:

uration optioncenario.

nfiguration opt

narios and pic

Configu

nfiguration

ufacturing planprogress.

ns available an

tions for the sc

ck a preferred

uration

n

nt. Team

nd provide

cenario.

solution.

Page 80: 10232AD-ENU_LabManual

Lab Instructions: Designing a Development Strategy 3

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. Create a Visual Studio 2010 project.

2. Add a Constants file to the project.

3. Create Viewer Web Part.

4. Create Setter Web Part.

5. Rename Feature.

6. Add Feature Receiver.

7. 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”

Page 81: 10232AD-ENU_LabManual

4 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”.

Page 82: 10232AD-ENU_LabManual

Lab Instructions: Designing a Development Strategy 5

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.

Page 83: 10232AD-ENU_LabManual

6 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. Add additional constants.

2. Add logging list.

3. Add logging capability to Web Part.

4. 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.

Page 84: 10232AD-ENU_LabManual

Lab Instructions: Designing a Development Strategy 7

• 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.

Page 85: 10232AD-ENU_LabManual

8 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. Add Web Part configuration.

2. Add logging evaluation.

3. 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.

Page 86: 10232AD-ENU_LabManual

Lab Instructions: Designing a Development Strategy 9

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.

Page 87: 10232AD-ENU_LabManual

10 La

Lab B

ScThpaup

ETh

1.

2.

3.

b Instructions: Desig

B: Opera

cenario he Operationsarse the Sharepdated to prov

xercise 1: he main tasks

. Upgrade to

. Adding UL

. Deploy and

gning a Development

ational L

s team has impePoint ULS logvide ULS-base

Adding Los for this exerc

o farm solution

LS logging.

d verify.

t Strategy

Logging

plemented a ngs. They have ed logging.

ogging to cise are as follo

n.

g

new monitorinrequested tha

SharePoinows:

ng solution thaat all custom so

nt ULS

at is able to olutions be

Page 88: 10232AD-ENU_LabManual

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.

Page 89: 10232AD-ENU_LabManual

Lab Instructions: Developing Version and Deployment 1

Module 9 Lab Instructions: Developing Version and Deployment

Contents: Lab A: Versioning Assemblies

Exercise 1: Defining Base Version 2

Exercise 2: Upgrading the Assembly 4

Lab B: Feature Upgrade

Exercise 1: Creating Upgrade Manage Page 6

Exercise 2: Adding Feature to Upgrade 8

Exercise 3: Upgrading Feature 9

Page 90: 10232AD-ENU_LabManual

2 La

Lab A

E

ScC

Th

1.

2.

3.

4.

T•

b Instructions: Devel

A: Versio

xercise 1:

cenario Create a simple

he main tasks

. Create a M

. Create a ve

. Rename fea

. Deploy and

ask 1: CreateCreate a neCustomiza

loping Version and D

oning A

Defining B

e Web Part tha

s for this exerc

icrosoft Visua

ersion Web Pa

ature.

d verify.

e a Microsofew project, spetion Wizard.

Deployment

Assembl

Base Versio

at displays the

cise are as follo

al Studio 2010

rt.

ft Visual Stuecifying a farm

ies

on

e assembly ver

ows:

project.

udio 2010 prm solution in th

rsion informati

roject he SharePoint

ion.

t

Page 91: 10232AD-ENU_LabManual

Lab Instructions: Developing Version and Deployment 3

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.

Page 92: 10232AD-ENU_LabManual

4 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. Update version.

2. Package and deploy.

3. Add SafeControl.

4. Add BindingRedirect.

5. Package and update.

6. Evaluate the changes.

7. 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.

Page 93: 10232AD-ENU_LabManual

Lab Instructions: Developing Version and Deployment 5

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 SafeControl—so 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.

Page 94: 10232AD-ENU_LabManual

6 La

Lab B

E

ScDth

Th

1.

2.

3.

4.

T•

b Instructions: Devel

B: Featu

xercise 1:

cenario Develop a basiche UI.

he main tasks

. Create a Vi

. Add feature

. Deploy and

. Add feature

ask 1: CreateCreate an e

loping Version and D

re Upgr

Creating U

c version man

s for this exerc

isual Studio 20

e manager pag

d verify.

e manager pag

e a Visual Stempty SharePo

Deployment

rade

Upgrade M

agement solut

cise are as follo

010 project.

ge.

ge logic.

tudio 2010 point project th

Manage Pa

tion to allow f

ows:

project hat will be farm

age

feature upgrad

m deployed.

des through

Page 95: 10232AD-ENU_LabManual

Lab Instructions: Developing Version and Deployment 7

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.

Page 96: 10232AD-ENU_LabManual

8 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. Add site collection feature.

2. 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.

Page 97: 10232AD-ENU_LabManual

Lab Instructions: Developing Version and Deployment 9

Exercise 3: Upgrading Feature Upgrade the feature and observe the results.

The main tasks for this exercise are as follows:

1. Package and update.

2. 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.

Page 98: 10232AD-ENU_LabManual

Lab Instructions: Designing Information Architecture and Navigation 1

Module 10 Lab Instructions: Designing Information Architecture and Navigation

Contents:. Lab A: Developing a Site Structure

Exercise 1: Using Card Sort 2

Exercise 2: Designing Content Types and Site Columns 6

Lab B: Implementing Farm-wide Navigation

Exercise 1: Deploying a Custom SiteMap 9

Exercise 2: Adding an ASPmenu to a Custom Master Page 11

Page 99: 10232AD-ENU_LabManual

2 La

Lab A

N

E

ScYoinst

G•

b Instructions: Desig

A: Devel

Note: Your instr

xercise 1:

cenario ou’ve been ask

nformation arctructure.

Guidelines You should

You may crappropriate

You may nfor referenc

gning Information Arc

oping a

ructor may run

Using Car

ked to organizchitecture. To

d try to create

reate up to fivee categorizatio

ot use the depce) in your con

chitecture and Navig

a Site St

this lab as a cla

d Sort

ze the contentdo this you’ll

a maximum o

e subcategorieon tree.

partment namentent category

gation

tructure

ass discussion.

t from across yuse a card sor

of five main ca

es per category

es (included iny.

e

your companyrt to determin

ategories.

y until you’ve

n the beginnin

y to create e the optimal

developed an

ng of the item

n

Page 100: 10232AD-ENU_LabManual

Lab Instructions: Designing Information Architecture and Navigation 3

Break into groups and start working for 10 minutes. Then we’ll reconvene to discuss the task further.

Content for Card Sort

[Accounting] Expense Reports [Administration] Mission Statements

[Accounting] Purchase Orders [Administration] Phone Lists

[Accounting] Invoices (Accounts Receivable)

[Administration] Corporate Summary Presentations

[Accounting] Invoices (Accounts Payable) [Engineering] Product Design Specifications

[Accounting] Purchase Orders [Engineering] Test Reports

[Accounting] Tax Filings [Engineering] Plant Diagrams (Physical)

[Accounting] Financial Reports [Engineering] Plant Diagrams (Electrical)

[Accounting] Closing Reports [Engineering] Plant Diagrams (Mechanical)

[Administration] Business Planning Presentations

[Engineering] Plant Renderings

[Administration] Organizational Charts [Engineering] Machine Inspection Reports

[Administration] Memos [Engineering] Interface Specifications

[Administration] Board of Directors Meeting Agendas

[HR] Offer Letters

[Administration] Board of Directors Meeting Minutes

[HR] Exit Interviews

[Administration] Customer Complaint [HR] Employee Records

[Administration] Customer Complaint Responses

[HR] Employee Reviews

Page 101: 10232AD-ENU_LabManual

4 Lab Instructions: Designing Information Architecture and Navigation

(continued)

Content for Card Sort

[HR] Benefits Information [Purchasing] Vendor Pricing Agreements

[HR] Time cards [QA] Item Quality Reports

[HR] Union Contracts [QA] Test Procedures

[HR] Workers Compensation Claims [QA] Equipment Inspection Reports

[HR] Workers Compensation Claim Responses

[Sales] Team Performance Reports

[HR] Employee Details [Sales] Competitive Performance Reports

[Legal] Contracts (Bank) [Sales] Proposals

[Legal] Contracts (Customer) [Sales] Sales Presentations

[Legal] Contracts (Vendor) [Sales] Sell Sheets

[Legal] Contracts (Partner) [Sales] Catalogs / Line Cards

[Legal] Releases [Sales] Pricing Contracts

[Legal] Licenses [Sales] Prospects

[Legal] Building Permits [Sales] Client Contacts

[Legal] Zoning Petitions [Sales] Performa P&Ls

[Legal] Wrongful Termination Letters / Responses

[Sales] Flyers

[Legal] Case Files [Sales] Product Images

[Manufacturing] Bill of Materials [Sales] Packaging Inserts

[Manufacturing] Production Costs [Sales] Packaging Designs

[Purchasing] Vendor Quality Reports [Shipping] Bills of Lading

Page 102: 10232AD-ENU_LabManual

Lab Instructions: Designing Information Architecture and Navigation 5

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?

Page 103: 10232AD-ENU_LabManual

6 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 don’t 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. Choose three types of content mentioned in Exercise 1 and identify an existing document content type or design a custom content type for each.

2. Choose existing site columns or design custom site columns for each custom content type.

3. 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.)

2. If no suitable content type already exists, select an appropriate content type to inherit from and give your new content type a name.

Task 2: Select site columns for each custom content type 1. Fill in any existing SharePoint site columns that should be included in this

content type. (Note: site columns may be used more than once.)

2. If no suitable site column already exists, design a new site column.

Page 104: 10232AD-ENU_LabManual

Lab Instructions: Designing Information Architecture and Navigation 7

Task 3: Discuss your choice of content types and site columns Discuss answers to the following questions with the rest of the class.

1. How many custom content types did you design?

2. How many custom site columns did you design?

3. Explain why you chose each content type for each document category?

4. 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.

Page 105: 10232AD-ENU_LabManual

8 La

Lab B

ScEushaShstcrwmIn

In

1.

2.

b Instructions: Desig

B: Imple

cenario ach manufactusers to find inas decided to harePoint. Sintatic, the team reating a custo

will be able to umanufacturing ntranet site wil

n this lab, you

. Add navigaand corpor

. Create a mnodes.

gning Information Arc

ementin

uring plant wiformation aboadd custom n

nce the numbehas decided t

om SiteMapPruse links in thplant’s site coll also be inclu

should:

ation nodes rerate intranet to

aster page wit

chitecture and Navig

ng Farm

ill have its ownout other mannavigation to aer of manufactto use an .xml-ovider class or

he footer to navollection. A roouded.

presenting theo the Layouts.

th navigation l

gation

-wide N

n site collectionufacturing pla

footer on the uring plant sit-based navigatr a custom navvigate betweenot node repres

e manufacturiSitemap of all

links based on

Navigat

on. To make itants, the plann

master page ute collections ition control invigation contrn top-level sitesenting the cor

ing plant’s siteWeb applicat

n the added na

tion

t easier for ning team used by is relatively

nstead of rol. Site users es in each rporate

e collections tions.

avigation

Page 106: 10232AD-ENU_LabManual

Lab Instructions: Designing Information Architecture and Navigation 9

Exercise 1: Deploying a Custom SiteMap The main tasks of this exercise are as follows:

1. Create a new Microsoft Visual Studio® project.

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

Task 1: Create a new Visual Studio project 1. Create a new Empty SharePoint project named Contoso.GlobalNav.

2. Select to Deploy it as a Farm solution.

3. Add a SharePoint Layouts mapped folder.

4. Delete the Contoso.Global.Nav folder.

5. Add an .xml file called Layouts.Sitemap.Global.xml to the Layouts folder.

6. 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.

Page 107: 10232AD-ENU_LabManual

10 Lab Instructions: Designing Information Architecture and Navigation

Task 2: Merge the navigation nodes into the default Layouts.Sitemap 1. Open a command prompt.

2. 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.

Page 108: 10232AD-ENU_LabManual

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. Add an ASPmenu and SiteMapDataSource.

2. Deploy V4Global.master.

3. Use the V4Global.master.

Task 1: Add an ASPmenu and SiteMapDataSource 1. Open the corporate portal site in SharePoint Designer.

2. Make a copy of the V4.master and name it V4global.master.

3. Edit the V4global.master.

4. Add the following code on the line above the developer’s 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. Close and save the V4global.master.

6. Exit SharePoint Designer.

Page 109: 10232AD-ENU_LabManual

12 Lab Instructions: Designing Information Architecture and Navigation

Task 2: Deploy V4global.master 1. Open the corporate portal site in Windows® Internet Explorer®.

2. Navigate to the master page gallery and download V4global.master.

3. Delete V4global.master from the master page gallery.

4. Add a module to the Contoso.GlobalNav project created in Exercise 1.

5. Add the existing V4global.master to the module folder in Visual Studio.

6. 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. Add a feature receiver to the module feature created in Task 2.

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();

Page 110: 10232AD-ENU_LabManual

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. Deploy the project.

5. 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.

Page 111: 10232AD-ENU_LabManual

Lab Instructions: Designing Branding and Customization Support 1

Module 11 Lab Instructions: Designing Branding and Customization Support

Contents: Lab A: Packaging Branding

Exercise 1: Importing .wsp Files Into Microsoft Visual Studio 3

Exercise 2: Extracting the File Resources 4

Exercise 3: Writing the Feature Receiver to Apply Changes 5

Exercise 4: Testing the Changes 6

Lab B: Improving Branding Performance

Exercise 1: Observing Current Performance 8

Exercise 2: Turning on BLOB Caching 9

Exercise 3: Observing BLOB Cached Performance 10

Exercise 4: Observing _layouts Performance 11

Page 112: 10232AD-ENU_LabManual

2 La

Lab A

ScThwdidepa

Yoac

b Instructions: Desig

A: Packa

cenario he designer ha

with SharePoinisabling the puesigner has letackage:

Added a ne

Created a c

Added a Co

Modified th

our package sctivation proce

gning Branding and C

aging Br

as delivered a nt Designer. Thublishing featut you know of

ew master pag

custom CSS ca

ontoso logo

he site logo UR

hould apply aess.

Customization Suppo

randing

Microsoft Shahe designer paures and thenf the following

ge called Conto

alled Contoso.

RL of the site

all of these elem

ort

g

arePoint site wackaged the ch

n selecting saveg changes they

oso.master

.CSS

ments to a site

which has beenhanges up intoe site as temply made which

e as a part of a

n modified o a .wsp by late. The you need to

a feature

Page 113: 10232AD-ENU_LabManual

Lab Instructions: Designing Branding and Customization Support 3

Exercise 1: Importing .wsp Files Into Microsoft Visual Studio The main tasks for this exercise are as follows:

1. Create new project.

2. 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 you’ll 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.

Page 114: 10232AD-ENU_LabManual

4 Lab Instructions: Designing Branding and Customization Support

Exercise 2: Extracting the File Resources The main tasks for this exercise are as follows:

1. Create a new Contoso Branding project.

2. Copy the master page resources to the Contoso Branding project.

3. Copy the site assets resources to the Contoso Branding project.

4. 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.

Page 115: 10232AD-ENU_LabManual

Lab Instructions: Designing Branding and Customization Support 5

Exercise 3: Writing the Feature Receiver to Apply Changes The main tasks for this exercise are as follows:

1. Rename the feature.

2. 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.

Page 116: 10232AD-ENU_LabManual

6 Lab Instructions: Designing Branding and Customization Support

Exercise 4: Testing the Changes The main tasks for this exercise are as follows:

1. Deploy and run the package.

2. 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.

Page 117: 10232AD-ENU_LabManual

Lab B

ScThShdidepa

Yoac

B: Impro

cenario he designer haharePoint Desisabling the puesigner has letackage:

Added a N

Created a c

Added a Co

Modified th

our package sctivation proce

oving Br

as delivered a signer. The desublishing featut you know of

ew Master Pag

custom CSS ca

ontoso logo.

he site logo UR

hould apply aess.

Lab Instructions:

randing

SharePoint sisigner packagures and thenf the following

ge called Cont

alled Contoso.

RL of the site.

all of these elem

Designing Branding

g Perfor

te which has bed the change

n selecting saveg changes they

toso.master.

.CSS.

ments to a site

g and Customization

rmance

been modifiedes up into a We site as temply made which

e as a part of a

Support 7

d with WSP by

late. The you need to

a feature

7

Page 118: 10232AD-ENU_LabManual

8 Lab Instructions: Designing Branding and Customization Support

Exercise 1: Observing Current Performance The main tasks for this exercise are as follows:

1. Deploy and reactivate the Contoso.Branding package.

2. Open Fiddler and force a reload of the home page.

3. 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.

Page 119: 10232AD-ENU_LabManual

Lab Instructions: Designing Branding and Customization Support 9

Exercise 2: Turning on BLOB Caching The main tasks for this exercise are as follows:

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

2. 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.

Page 120: 10232AD-ENU_LabManual

10 Lab Instructions: Designing Branding and Customization Support

Exercise 3: Observing BLOB Cached Performance The main tasks for this exercise are as follows:

1. Refresh the page.

2. Navigate to the page.

3. 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 doesn’t 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.

Page 121: 10232AD-ENU_LabManual

Lab Instructions: Designing Branding and Customization Support 11

Exercise 4: Observing _layouts Performance The main tasks for this exercise are as follows:

1. Review a _layouts request in Fiddler.

2. 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.

Page 122: 10232AD-ENU_LabManual

Lab Instructions: Designing Security 1

Module 12 Lab Instructions: Designing Security

Contents: Lab A: Setting Up a Customer Service Site

Exercise 1: Setting Up the Authentication Provider 3

Exercise 2: Creating an FBA-Claims Site 6

Optional Exercise 3: Viewing Claims for an FBA User 13

Lab B: Solving a Security Issue

Exercise 1: Understanding the Scope and Relating it to Configuration 15

Exercise 2: Designing a Security Strategy 15

Page 123: 10232AD-ENU_LabManual

2 La

Lab A

ScCseidcu

b Instructions: Desig

A: Settin

cenario Contoso manufee the progresdentity. The saustomer’s sites

gning Security

ng Up a

facturing wans of their orde

ales representas.

Custom

ts to allow cusers. Customersative needs the

mer Serv

stomers to logs will not havee ability to ma

vice Site

g into a SharePe an internal nanage access to

e

Point site to network o the

Page 124: 10232AD-ENU_LabManual

Lab Instructions: Designing Security 3

Exercise 1: Setting Up the Authentication Provider The main tasks for this exercise are as follows:

1. Map out requirements, design a plan.

2. 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.

Page 125: 10232AD-ENU_LabManual

4 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. Open IIS Manager. Create a new Web site called fba, which utilizes the SharePoint – 80 application pool.

3. Open Microsoft SQL Server® Management Studio.

• Locate the aspnetdb database.

• Add Network Service as a db owner for the aspnetdb.

4. Navigate to the root folder for the fba Web site that was just created.

5. 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.)

Page 126: 10232AD-ENU_LabManual

Lab Instructions: Designing Security 5

<!-- 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.

7. 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.

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.

Page 127: 10232AD-ENU_LabManual

6 Lab Instructions: Designing Security

Exercise 2: Creating an FBA-Claims Site The main tasks for this exercise are as follows:

1. Create a new SharePoint Web application.

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

3. Add PeoplePicker wildcard information.

4. Define membership and role providers for Central Administration.

5. Define membership and role providers for the Forms Web application.

6. Define membership and role providers for the Security Token Service application.

7. Use Central Administration to designate the first FBA user for the Forms Web application.

8. 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. Navigate to Central Administration, select Application Management.

2. Select Manage Web applications and click New.

3. Specify the following values in the Create New Web Application dialog box:

• Authentication Type: Claims Based Authentication

• Port: 888

• Enable Forms Based Authentication (FBA)

• Provider Name: fbaMembers

• Role Manager Name: fbaRoles

• Security Account: Network Service

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

Page 128: 10232AD-ENU_LabManual

Lab Instructions: Designing Security 7

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="%" />

Page 129: 10232AD-ENU_LabManual

8 Lab Instructions: Designing Security

Task 4: Define membership and role providers for Central Administration Update the membership and role provider information contained within Central Administration’s 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.)

Page 130: 10232AD-ENU_LabManual

Lab Instructions: Designing Security 9

<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 application’s 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.)

Page 131: 10232AD-ENU_LabManual

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.SPClaimsAuthRoleProvider, 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.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> </providers> </membership>

Page 132: 10232AD-ENU_LabManual

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 Service’s 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>

Page 133: 10232AD-ENU_LabManual

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. Don’t 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.

Page 134: 10232AD-ENU_LabManual

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 that’s shown in the following figure, which shows claims for an authenticated FBA user.

Page 135: 10232AD-ENU_LabManual

14 La

Lab B

ScCbeth

An

b Instructions: Desig

B: Solvin

cenario Contoso manuf

een reported though they sh

nalyze and de

gning Security

ng a Sec

facturing is mthat some of thould have acc

evelop a securi

curity Is

oving more inhe documents

cess to the doc

ity strategy an

ssue

nformation to s are unavailabcuments.

nd implement i

the customer ble to the cust

it.

portals. It hasomer, even

Page 136: 10232AD-ENU_LabManual

Lab Instructions: Designing Security 15

Exercise 1: Understanding the Scope and Relating it to Configuration The scenario statement is fairly generic. Let’s try to dig a little deeper into the issue to see how it might relate to the configuration. Let’s 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, let’s 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.

Page 137: 10232AD-ENU_LabManual

Lab Instructions: Designing for Page and Data Access Performance 1

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 2

Exercise 2: Leveraging the SharePoint Server 2010 Search API for Large Data Queries 4

Page 138: 10232AD-ENU_LabManual

2 La

Lab: DPerfo

ED

ScYocoThpeD

Th

1.

2.

b Instructions: Desig

Designiormance

xercise 1: Dashboard

cenario ou have createollection and ahe user has poerformance im

Dashboard.

he main tasks

. Enable the

. Deploy the

gning for Page and D

ng for Pe

Using the to Captur

ed a custom lia Web Part to opulated the li

mpact of the cu

s for this exerc

SharePoint D

e Contoso.Perf

Data Access Performa

Page an

SharePoinre Perform

st and list instretrieve the lisist with large austom Web Pa

cise are as follo

eveloper Dash

formance.Lists

ance

nd Data

nt Server 2mance Met

tance for deplost data and renamounts of daart using the S

ows:

hboard.

s solution.

Access

2010 Devetrics

oyment into ander it in a daata. You must SharePoint Dev

s

eloper

a site ata grid. assess the veloper

Page 139: 10232AD-ENU_LabManual

Lab Instructions: Designing for Page and Data Access Performance 3

3. Add performance instrumentation to a custom Web Part.

4. 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.

Page 140: 10232AD-ENU_LabManual

4 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. Create a search query to retrieve list items.

2. 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.

Page 141: 10232AD-ENU_LabManual

Lab Instructions: Designing a Testing Strategy 1

Module 14 Lab Instructions: Designing a Testing Strategy

Contents: Exercise 1: Conducting Unit Testing 2

Exercise 2: Conducting Performance Testing 5

Exercise 3: Conducting Load Testing 6

Page 142: 10232AD-ENU_LabManual

2 La

Lab: D

E

ScTha sewvia lisobre

b Instructions: Desig

Designi

xercise 1:

cenario he developmenew Web Par

election of avawill fire which liew. In preparModel-View-Pst items into abject, performeturns the resu

gning a Testing Strate

ng a Te

Conductin

ent team leadet project. The

ailable lists in aloads the defaation for unit

Presenter pattea DataTable ob

ms some text multing GridVie

egy

esting St

ng Unit Te

er has identifiedesired functia SharePoint 2

ault view of thetesting, the te

ern, with a Mobject, and a Vie

manipulation, bew to the Web

trategy

esting

ed the need forionality is to p2010 team sitee list into a dyam lead has re

odel class that ew class whichbinds the data Part (Present

y

r unit tests as present a drope; when selecteynamically-genefactored the sretrieves the Sh takes the Daa to a GridViewer) class.

part of p-down ed, an event

nerated grid solution into SharePoint ataTable w, and

Page 143: 10232AD-ENU_LabManual

Lab Instructions: Designing a Testing Strategy 3

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.

Page 144: 10232AD-ENU_LabManual

4 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.

Page 145: 10232AD-ENU_LabManual

Lab Instructions: Designing a Testing Strategy 5

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.

Page 146: 10232AD-ENU_LabManual

6 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.

Page 147: 10232AD-ENU_LabManual

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint 1

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 2

Exercise 2: Using Fiddler to Examine Page Size 3

Exercise 3: Reducing Page Size 3

Lab B: Memory and Performance

Exercise 1: Starting a Performance Capture 4

Exercise 2: Reviewing the Report 4

Exercise 3: Resolving Memory Issues and Retest 5

Page 148: 10232AD-ENU_LabManual

2 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. Browse to E:\Student\Module 1\Class\ManufacturingDashboard and open

ManufacturingDashboard.csproj with Visual Studio 2010.

2. In Visual Studio®, right-click ManufacturingDashboard and select Set as Startup Project.

3. Press F5 to launch the application with debugging. The Windows® Internet Explorer® browser window appears.

4. 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 /.

Page 149: 10232AD-ENU_LabManual

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint 3

Exercise 2: Using Fiddler to Examine Page Size

Task 1: Review the default.aspx request 1. Click the session that is reading from 127.0.0.1 (the port number will be

random) and the path of /.

2. 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.

3. On the right side, click the Inspectors tab.

4. Click the TextView tab in the response (bottom) section.

5. 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. In Visual Studio, open the Default.aspx file.

2. Add the attribute EnableViewState=”false” to the <%@Page %> tag at the top and:

• Both <asp:Repeater> tags

• Both <asp:GridView> tags

• All three <asp:TextBox> tags

3. Click Save to save the Default.aspx file.

4. Open Internet Explorer and press F5.

5. Examine the revised page (see Exercise 2). Now, the size is 112848 bytes.

Page 150: 10232AD-ENU_LabManual

4 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. In Visual Studio, click the Analyze menu, and then click Launch Performance

Wizard.

2. In the Performance Wizard -- Page 1 of 4 dialog box, select .NET Memory Allocation (Sampling) and specify the profiling method.

3. In the Performance Wizard -- Page 2 of 4 dialog box, click Next.

4. In the Performance Wizard -- Page 3 of 4 dialog box, click Next.

5. 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. Stop the application profiling session by closing Internet Explorer.

2. 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.

Page 151: 10232AD-ENU_LabManual

Lab Answer Key: ASP.NET Advanced Concepts for SharePoint 5

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. Remove the Get() method.

2. Remove the GetCacheKey() methods.

3. Change the constructor from private to public; add a parameter of the SQL reader.

4. Add to the constructor a call to .LoadFromReader().

5. 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.

Page 152: 10232AD-ENU_LabManual

Lab Answer Key: Designing for User Experience 1

Module 2 Lab Answer Key: Designing for User Experience

Contents: Lab A: Selecting Page Parts

Exercise 1: Line Dashboard 2

Exercise 2: Manager’s Dashboard 3

Exercise 3: Alert Notification 4

Lab B: Selecting Page Types

Exercise 1: Plant Summary Page 5

Exercise 2: Plant Configuration Page 6

Exercise 3: Employee List 7

Exercise 4: Line Status 8

Page 153: 10232AD-ENU_LabManual

2 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 Comments

Delegate Control Shouldn’t appear on every page.

Web Part – Visual Possible but designing for something that could be seen 6 feet away isn’t practical with HTML.

Web Part – Server Control See Web Part – Visual

Web Part – AJAX See Web Part – Visual

Silverlight 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.

Menu Item Not applicable as a dashboard.

Status Bar Possible—but would require refresh strategy and isn’t really appropriate for 6 feet away.

Notification Area The message/status would be a persistent concern, not a transient one.

Page 154: 10232AD-ENU_LabManual

Lab Answer Key: Designing for User Experience 3

Exercise 2: Manager’s Dashboard Best Choice: Web Part with AJAX

Key Criteria: Performance concerns, drill into

Comments by page part type:

Page Part Type Comments

Delegate Control Not appropriate – not for every page.

Web Part – Visual A possible option. The concern here is making sure to leverage AJAX to minimize page refreshes.

Web Part – Server Control A possible option. Probably too difficult to be practical.

Web Part – AJAX Best answer. The idea here is to minimize page refreshes and maintain good performance.

Silverlight A possible option. Generally the ability to drill in means going back to Web pages. It’s a good interface design to keep from doing too many transitions.

Menu Item Not appropriate for a dashboard.

Status Bar Not appropriate for a drill-in dashboard.

Notification Area Not appropriate for a drill-in dashboard.

Page 155: 10232AD-ENU_LabManual

4 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 Comments

Delegate Control Best answer. Can be caused to load on every page in the system so the alert can be displayed on every page.

Web Part – Visual Not appropriate because it would require modifying every page (including out-of-the-box pages) to refer to the Web Part.

Web Part – Server Control See Web Part – Visual.

Web Part – AJAX See Web Part – Visual.

Silverlight See Web Part – Visual.

Menu Item Not appropriate for an alert.

Status Bar You still need something to trigger the status bar message. The delegate control could trigger a message to be displayed in the status bar.

Notification Area The notification area is for temporary/non-persistent messages. The requirements are such that this isn’t a one passing message; something still needs to trigger the message into the notification area.

Page 156: 10232AD-ENU_LabManual

Lab Answer Key: Designing for User Experience 5

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 Comments

Dialog Not appropriate because the plant summary doesn’t appear over anything.

Application Doesn’t manage the storage of content. Developer would have to manually address this need.

Master The formatting doesn’t apply to every page in the site, just to the plant summary page.

Web Part Wouldn’t manage the storage of the plant content.

Wiki Would manage the storage of content, but wouldn’t provide the kind of consistency the scenario describes.

Page Layout / Instance The best choice. Provides content management and consistency.

Static Page Not an appropriate choice. The dynamic menus can’t be handled by a static page.

Page 157: 10232AD-ENU_LabManual

6 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 Comments

Dialog Possible but where would the dialog be raised from?

Application Best choice. No need for individual content storage—only configuration information. Low usage and necessary in every site.

Master Not appropriate—configuration shouldn’t be on every page.

Web Part Possibility but how would the page be provisioned? Where would it be linked from?

Wiki Possible with same issues as Web part page, and no need to mix content and code.

Page Layout / Instance There’s no “content” to hold on to for each page, so creating a page layout and instance isn’t necessary.

Static Page Wouldn’t support the changes to the configuration required.

Page 158: 10232AD-ENU_LabManual

Lab Answer Key: Designing for User Experience 7

Exercise 3: Employee List Best Choice: Publishing Page

Key Criteria: Consistency, Extra Content Per Plant

Comments by page type:

Page Type Comments

Dialog Not appropriate due to the amount of information to be displayed.

Application No storage of the per plant descriptive text.

Master The layout doesn’t apply to every page in the site.

Web Part Possible but would require storing content in the CEWP instead of a content page.

Wiki Possibility but not likely to provide the level of consistency called for in the scenario.

Page Layout / Instance 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.

Static Page Not appropriate because code can’t run on a static page.

Page 159: 10232AD-ENU_LabManual

8 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 Comments

Dialog Not appropriate because the line status doesn’t appear over anything. However, possible that this could appear over the plant—but another page type should be selected for the implementation of the dialog.

Application Doesn’t manage the storage of content. (i.e. image of line). Developer would have to manually address this need.

Master The formatting doesn’t apply to every page in the site, just to the line status page.

Web Part Wouldn’t manage the line content.

Wiki Would manage the storage of content—but wouldn’t provide the kind of consistency the scenario describes.

Page Layout / Instance The best choice. Provides content management and consistency.

Static Page Not an appropriate choice. The status can’t be handled by a static page.

Page 160: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data 1

Module 3 Lab Answer Key: Designing for Data

Contents: Lab A: Time Tracking

Exercise 1: Creating List Views 2

Exercise 2: Adding Indexes 4

Lab B: Invoice Management

Exercise 1: Creating an Invoice Content Type 5

Exercise 2: Enabling Content Organization 7

Exercise 3: Testing Content Organization 9

Page 161: 10232AD-ENU_LabManual

2 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. Go to http://localhost/student/module3.

2. Click Time Tracking in the Quick Launch area to open the Time Tracking List.

3. Click the List Tools-List tab. In the Settings group, click List Settings.

4. Scroll down to Columns and click Create column.

5. Enter YearMonth as the column name.

6. In the The type of information in this column is: option list, select Calculated (calculation based on other column).

7. 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.

8. Scroll down to Views and click Create view.

9. Click Standard View.

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.

Page 162: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data 3

Task 2: Create a view for aggregating time by employee 1. Click the List Tools-List tab. In the Manage Views group, click Create View.

2. Click Standard View.

3. In the View Name box, enter ByEmployeeByDay.

4. In the Columns section, clear the Employee option.

5. In the Columns section, click Plant and select 1 from the drop-down list to the right.

6. Scroll down and click the plus sign to the left of the Group By section to expand it.

7. In the First group by the column list, select Employee.

8. In the Then group by the column list, select Start Date.

9. Scroll down and click OK.

Task 3: Create a view for aggregating time by plant and by employee 1. Click the List Tools-List tab. In the Manage Views group, click Create View.

2. Click Standard View.

3. In the View Name box, enter ByPlantByEmployee.

4. In the Columns section, clear the Employee option.

5. In the Columns section, select the Start Date option and select 1 from the drop-down list to the right.

6. Scroll down and click the plus sign to the left of the Group By section to expand it.

7. In the First group by the column list, select Plant.

8. In the Then group by the column list, select Employee.

9. Scroll down and click OK.

Page 163: 10232AD-ENU_LabManual

4 Lab Answer Key: Designing for Data

Exercise 2: Adding Indexes

Task 1: Add an index by employee and by start date 1. Click the List Tools-List tab. In the Settings group, click List Settings.

2. Scroll down to the Columns section and click Indexed columns.

3. Click Create a new index.

4. In the Primary column for this index list, select Employee.

5. In the Secondary column for this index list, click Start Date.

6. Click Create.

Task 2: Add an index by plant and by employee 1. Click Create a new index.

2. In the Primary column for this index list, select Plant.

3. In the Secondary column for this index list, click Employee.

4. Click Create.

Task 3: Add an index by start date 1. Click Create a new index.

2. In the Primary column for this index list, select Start Date.

3. Click Create.

Page 164: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data 5

Lab B: Invoice Management Exercise 1: Creating an Invoice Content Type

Task 1: Create the site columns for the invoice content type 1. Click Site Actions-Site Settings.

2. In the Galleries section, click Site columns.

3. Click Create.

4. In the Column name field, enter InvoiceNumber.

5. In the Group section in the Existing Group section, select Contoso and click OK.

6. Click Create.

7. In the Column name field, enter PONumber.

8. In the Group section in the Existing Group section, select Contoso and click OK.

9. 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).

Page 165: 10232AD-ENU_LabManual

6 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. In the breadcrumbs, click Site Settings.

2. In the Galleries section, click Site content types.

3. Click Create.

4. In the Name text box, enter Invoice.

5. In the Select parent content type from drop-down list, select Document Content Types.

6. In the Parent Content Type drop-down list, select Document.

7. In the Existing Group drop-down list, select Contoso.

8. Click OK.

9. 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.

Page 166: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data 7

Exercise 2: Enabling Content Organization

Task 1: Activate content organization 1. Click Site Actions-Site Settings.

2. In the Site Actions, click Manage site features.

3. 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. In the Quick launch area, click the Invoices library.

2. Click the Library Tools-Library tab. In the Settings Group, click Library Settings.

3. In the General Settings column, click Advanced settings.

4. In the Allow management of content types? option list, click Yes.

5. Scroll down and click OK.

6. In the Content Types section, click Add from existing site content types.

7. In the Available Site Content Types list box, click Invoice and then click Add.

8. Click OK.

9. 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.

Page 167: 10232AD-ENU_LabManual

8 Lab Answer Key: Designing for Data

Task 3: Create a content organizer rule to move invoices 1. Click Site Actions-Site Settings.

2. In the Site Administration section, click Content Organizer Rules.

3. Click Add new item.

4. In the Name box, enter Invoices.

5. In the Submission’s Content Type section, in the Type setting, select Invoice.

6. In the Target Location section, click Browse.

7. In the Select Target Location Web page dialog box, click the Invoices library and then click OK.

8. 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.

Page 168: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data 9

Exercise 3: Testing Content Organization

Task 1: Test content organization 1. In the Quick Launch area, click the Drop Off Library library.

2. Click the Library Tools-Documents tab.

3. Click Upload Document.

4. Click Browse. Navigate to the folder E:\Student\Module 3\Demo Data \Invoices and select the file Invoice 101.docx.

5. Click OK.

6. In the Drop Off Library – Invoice 101.docx dialog box enter the following values:

• 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.

7. In the Quick Launch area, click the Invoices library.

8. Notice that a folder exists with the name 12; Fabrikam, Inc. Click on the folder 12; Fabrikam, Inc.

9. Notice that the document exists in the folder.

Page 169: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data Capture and Integration 1

Module 4 Lab Answer Key: Designing for Data Capture and Integration

Contents: Lab A: Creating External Lists

Exercise 1: Connecting to the Data Source 2

Exercise 2: Defining the External Content Types 3

Exercise 3: Defining the External Lists 6

Exercise 4: Setting Security for the Content Types 7

Exercise 5: Defining an Association 8

Lab B: Creating an InfoPath Form

Exercise 1: Creating the Calculations 9

Exercise 2: Publishing the Form to a SharePoint Library 12

Page 170: 10232AD-ENU_LabManual

2 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. Open Windows® Internet Explorer® to http://localhost/student/module4.

2. Click Site Actions, and then click Edit in SharePoint Designer.

Task 2: Create a starting content type 1. In the Site Objects section, click External Content Types.

2. On the ribbon, click External Content Types, and in the New group, click the External Content Type button.

3. 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. Click the Add Connection button.

2. In the External Data Source Type Selection dialog box, select the SQL Server option, and click OK.

3. In the Database Server field, type .\SHAREPOINT.

4. In the Database Name field, type ContosoERP, and then click OK.

5. Click the plus sign to the left of ContosoERP.

6. Click the plus sign to the left of Tables.

Page 171: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data Capture and Integration 3

Exercise 2: Defining the External Content Types

Task 1: Create the GL Account content type 1. In the breadcrumbs, click New external content type.

2. In the Name field, type GLAccount.

3. In the Display Name field, change the value to GL Account.

4. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link.

5. Right-click the GLAccounts table, and select Create All Operations.

6. Click the Next button.

7. In the Properties section, select the Map to Identifier check box.

8. In the Data Source Elements section, click the AccountNumber option.

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 2: Create the Vendor content type 1. In the Site Objects section, click the External Content Types link.

2. On the ribbon, in the External Content Types tab, in the New group, click the External Content type button.

3. In the Name field, type Vendor.

4. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link.

5. Right-click the Vendors table, and select Create All Operations.

6. Click the Next button.

7. In the Properties section, select the Map to Identifier check box.

8. In the Data Source Elements section, click VendorName.

Page 172: 10232AD-ENU_LabManual

4 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. In the Site Objects section, click the External Content Types link.

2. On the ribbon, in the External Content Types tab, in the New group, click the External Content type button.

3. In the Name field, type PurchaseRequestHeader.

4. In the Display Name field, modify the value to Purchase Request Header.

5. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link.

6. Right-click the PurchaseRequestHeader table, and select Create All Operations.

7. Click the Next button.

8. In the Properties section, select the Map to Identifier check box.

9. 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.

Page 173: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data Capture and Integration 5

Task 4: Create the Purchase Request Line content type 1. In the Site Objects section, click the External Content Types link.

2. On the ribbon, in the External Content Types tab, in the New group, click the External Content type button.

3. In the Name field, type PurchaseRequestLine.

4. In the Display Name field, modify the value to Purchase Request Line.

5. In the External Content Type Operations section, click the Click here to discover external data sources and define operations link.

6. Right-click the PurchaseRequestLine table, and select Create All Operations.

7. Click the Next button.

8. In the Properties section, select the Map to Identifier check box.

9. 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.

Page 174: 10232AD-ENU_LabManual

6 Lab Answer Key: Designing for Data Capture and Integration

Exercise 3: Defining the External Lists

Task 1: Create the GL Accounts external list 1. In the Site Objects section, click the External Content Types link.

2. Right-click the GLAccount content type, and select External List.

3. 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. In the Site Objects section, click the External Content Types link.

2. Right-click the Vendor content type, and select External List.

3. 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. In the Site Objects section, click the External Content Types link.

2. Right-click the PurchaseRequestHeader content type, and select External List.

3. 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. In the Site Objects section, click the External Content Types link.

2. Right-click the PurchaseRequestLine content type, and select External List.

3. In the Create External List dialog box, type the name PurchaseRequestLines in the Name field, and then click OK.

Page 175: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data Capture and Integration 7

Exercise 4: Setting Security for the Content Types

Task 1: Go the Business Data Connectivity Service in Central Administration 1. On the Start menu, click All Programs, click Microsoft SharePoint 2010

Products, and then click SharePoint 2010 Central Administration.

2. In the Application Management section, click the Manage service applications link.

3. Click the Business Data Connectivity Service link.

Task 2: Define the security for all content types 1. On the ribbon, in the Edit tab, in the Permissions section, click the Set

Metadata Store Permissions button.

2. 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.

3. 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.

4. In the section below the name entry, click Administrator and make sure that in the Permissions for section all of the options are selected.

5. Select the Propagate permissions to all BDC Models, External Systems and External Content Types option, and then click OK.

Page 176: 10232AD-ENU_LabManual

8 Lab Answer Key: Designing for Data Capture and Integration

Exercise 5: Defining an Association

Task 1: Open the Purchase Request Line content type 1. Open SharePoint Designer to the http://localhost/student/module4 site.

2. In the Site Objects section, click the External Content Types link.

3. Click the PurchaseRequestLine content type.

Task 2: Create the association 1. On the ribbon, in the External Content Types tab, in the Views group, click

the Operations Design View button.

2. Right-click PurchaseRequestHeader, and select New Association.

3. In the Association dialog box, click the Browse button.

4. In the External Content Type Selection, click the PurchaseRequestHeader option, and then click OK.

5. In the field drop-down list, select PurchaseRequestID.

6. Click Next.

7. In the Properties section, select the Map to Identifier check box.

8. Click Next twice.

9. 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.

Page 177: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data Capture and Integration 9

Lab B: Creating an InfoPath Form Exercise 1: Creating the Calculations

Task 1: Convert Vendor to a drop-down list 1. Open the file E:\Student\Module 4\PurchaseRequestForm-Starter.xsn with

Microsoft InfoPath Designer 2010.

2. Right-click the text box to the right of Vendor, and click Change Control – Drop-Down List Box.

3. Right-click the Drop-Down list and select Drop-Down List Box Properties.

4. In the List box choices list, select Get choices from an external data source.

5. Click Add.

6. Click Next.

7. In the From where do you want to receive your data? list, select SharePoint library or list, and then click Next.

8. In the Enter the location of the SharePoint site box, type http://sharepoint/student/module4, and then click Next.

9. 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.

Page 178: 10232AD-ENU_LabManual

10 Lab Answer Key: Designing for Data Capture and Integration

Task 2: Convert GL Account to a drop-down list 1. Right-click the text box under GL Account, and click Change Control – Drop-

Down List Box.

2. Right-click the drop-down list box under GL Account, and click Drop-Down list box properties.

3. In the list box choices, select the Get choices from an external data source option.

4. Click Add.

5. Click Next.

6. In the From where do you want to receive your data? list, select SharePoint library or list, and then click Next.

7. In the Enter the location of the SharePoint site text box, type http://sharepoint/student/module4, and then click Next.

8. In the Select a list or library list box, select GLAccounts, and then click Next.

9. 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. Right-click in the cell under the Extended Amount heading, and select Text

Box Properties.

2. Click the Format button.

3. In the Format list, click the Currency symbol, and then click OK.

4. To the right of the value box, click the Fx button.

5. Click the Insert Field or Group button.

6. Double-click the Quantity field.

7. Type a multiplication symbol (*).

Page 179: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Data Capture and Integration 11

8. Click the Insert Field or Group button.

9. 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.

Page 180: 10232AD-ENU_LabManual

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. On the ribbon, click the File tab.

2. In the left-hand column, click the Publish option.

3. Click the SharePoint Server button.

4. If prompted to save the form template before publishing, click OK. Save the form to E:\Student\Module 4\PurchaseRequest.xsn.

5. In the publishing wizard that appears, type http://sharepoint/student/module4, and then click Next.

6. In the What do you want to create or modify? list, select Form Library, and then click Next twice.

7. Type the name for the form library as Purchase Requests, and then click Next twice.

8. Click the Publish button.

9. Click the Close button.

Page 181: 10232AD-ENU_LabManual

Lab Answer Key: Designing Artifacts 1

Module 5

Lab Answer Key: Designing Artifacts

Contents: Lab A: Incident Response Site

Exercise 1: Evaluating the Requirements 2

Exercise 2: Designing the Solution 6

Lab B: Expense Reports

Exercise 1: Evaluating the Requirements 8

Exercise 2: Designing the Solution 14

Page 182: 10232AD-ENU_LabManual

2 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

Page 183: 10232AD-ENU_LabManual

Lab Answer Key: Designing Artifacts 3

Requirement Ob

ject

ive

Pre

cise

Mea

sura

ble

Un

der

stan

dab

le

Suggestions

Implementation in 90 days

+ 0 + 0 Ask which parts of the system need to be functional in order to pass the government review.

Incident response pages that can be printed

+ 0 + + 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?

Select a set of procedures

+ 0 + + Can an incident response be saved with no procedures? Are all procedures centralized or can a plant have their own procedures?

Incident responses can be unique or shared

+ 0 + + How do you control which responses are shared for a plant from the corporate responses and which ones are unique?

Two incident workflows

0 - + + What are the reminder intervals? What happens if a response is rejected?

Notification of changes to procedures or incident response

+ 0 - + Who is notified? When are they notified?

Page 184: 10232AD-ENU_LabManual

4 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

Requirement Res

po

nsi

ven

ess

Skill

s

Scal

e

Rat

e o

f C

han

ge

Suggestions

Implementation in 90 days

+ 0 + 0 The skills of the project team members would likely be clear if you worked for the organization but aren’t clear here. The rate at which the procedures change wasn’t specified.

Incident response pages that can be printed

+ + + + The requirements make it clear that this has to be self-service.

Select a set of procedures

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

Page 185: 10232AD-ENU_LabManual

Lab Answer Key: Designing Artifacts 5

(continued)

Requirement Res

po

nsi

ven

ess

Skill

s

Scal

e

Rat

e o

f C

han

ge

Suggestions

Incident responses can be unique or shared

+ - + 0 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 isn’t made clear.

Two incident workflows

- + - - The reminder frequency (if any) isn’t called out. The skills are specified by the fact that the requirements call out senior management, and the scale is missing. The requirements don’t define the number of incidents in a typical year. Nor do the requirements call out an expected frequency of change for the workflows.

Notification of changes to procedures or incident response

- + + - The requirements aren’t clear on the number of changes (rate of change) or the responsiveness window after a change is approved.

Page 186: 10232AD-ENU_LabManual

6 Lab Answer Key: Designing Artifacts

Exercise 2: Designing the Solution

Task 1: Create a high-level plan for delivering the solution The goal here isn’t to create a final plan, but rather a draft design to see what does and doesn’t work well. Based on the requirements, it’s expected that the following components are necessary:

• A site template. Although the sites are unique and may need to be targeted to additional features, it’s quite likely that they’ll all be located in one hierarchy. There’s a relatively fixed number of sites (one for each plant) so a site definition isn’t 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 control—or custom equivalent—that 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.

Page 187: 10232AD-ENU_LabManual

Lab Answer Key: Designing Artifacts 7

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? It’s 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 it’s time to change the workflow, and who is responsible for changing it?

Page 188: 10232AD-ENU_LabManual

8 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 user’s manager and possibly through the user’s manager’s 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

Page 189: 10232AD-ENU_LabManual

Lab Answer Key: Designing Artifacts 9

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.

Page 190: 10232AD-ENU_LabManual

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

Requirement Ob

ject

ive

Pre

cise

Mea

sura

ble

Un

der

stan

dab

le

Suggestions

Expense Report types

+ + + + The only ambiguity that might be questionable would be expense reports for vendors or customers that aren’t related to a trip. For instance, the purchase of a “top vendor” award.

Approval process

- - + + The approval process is described generically. Exception conditions, like the CEO who doesn’t have a manager and where the manager approval amounts will be retrieved from, aren’t covered. There’s no mention of guidance for the managers on approval/rejection and no discussion of potential automatic approval.

Approval process—Vendor

+ 0 + + 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?

Page 191: 10232AD-ENU_LabManual

Lab Answer Key: Designing Artifacts 11

(continued)

Requirement Ob

ject

ive

Pre

cise

Mea

sura

ble

Un

der

stan

dab

le

Suggestions

Approval Process—Customer

+ 0 + + The key piece of missing data is the same as for vendor, except that we’re talking about the sales manager.

Capture fields + + + + This is clear. However, the relatively small set of fields would generally indicate a need to probe for other questions like totals by category.

Capture fields—Vendor

+ 0 + + 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?

Capture fields—Customer

+ 0 + + See Capture fields for Vendor.

Capture fields—Training

+ 0 + + Is the list of training opportunities a constrained list? Where will this list come from?

Reporting 0 - + + The formats for the report aren’t covered, nor the details for the fields to be displayed in the report.

Security - - - - No security requirements are specified, but it’s quite likely there are requirements that are not expressed.

Page 192: 10232AD-ENU_LabManual

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

Requirement Res

po

nsi

ven

ess

Skill

s

Scal

e

Rat

e o

f C

han

ge

Suggestions

Expense Report types

+ + - - It’s 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.

Approval process

- + - - It’s unclear how frequently the approvers need to be reminded they have a pending approval. It also isn’t 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.

Approval process—Vendor

- + - - See Approval process.

Approval Process—Customer

- + - - See Approval process.

Capture fields + + - - It’s unclear how frequently accounting may change the number of fields being captured.

Page 193: 10232AD-ENU_LabManual

Lab Answer Key: Designing Artifacts 13

(continued)

Requirement Res

po

nsi

ven

ess

Skill

s

Scal

e

Rat

e o

f C

han

ge

Suggestions

Capture fields—Vendor

+ - - - In addition to the issues for Capture fields, it’s also unclear how the vendor will be identified.

Capture fields— Customer

+ - - - See Capture fields—Vendor.

Capture fields— Training

+ - - - See Capture fields—Vendor.

Reporting - - - - 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.

Security - - - - Since none of this was specified in the requirements, clarification is required on every aspect.

Page 194: 10232AD-ENU_LabManual

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 manager’s 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 employee’s 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 structure—such as prospects and vendor evaluation.

Page 195: 10232AD-ENU_LabManual

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 doesn’t 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?

Page 196: 10232AD-ENU_LabManual

` Lab Answer Key: Designing Processing Solutions 1

Module 6 Lab Answer Key: Designing Processing Solutions

Contents: Lab A: Designing an Engineering System

Exercise 1: Evaluating Client Capabilities and Requirements 2

Exercise 2: Evaluating Sandbox Capabilities and Requirements 4

Exercise 3: Evaluating Farm Deployment Capabilities and Requirements 5

Lab B: Creating a Sensor Report

Exercise 1: Designing Data Access for Sensor Data 6

Exercise 2: Designing a Processing Solution for the Report 6

Exercise 3: Designing a Processing Solution for the Approval 7

Page 197: 10232AD-ENU_LabManual

2 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 doesn’t require administrative access to the system.

• The processing load is transferred to the client from the server.

• It doesn’t 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 isn’t optimal because of the language design (performance).

• JavaScript is, relatively speaking, considered to be more difficult to debug than other programming languages because it isn’t 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.

Page 198: 10232AD-ENU_LabManual

` Lab Answer Key: Designing Processing Solutions 3

Task 2: Evaluate the Silverlight client Some of the key benefits to the Microsoft® Silverlight® client are the following:

• It doesn’t 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 isn’t 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.

Page 199: 10232AD-ENU_LabManual

4 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. There’s 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 won’t work.

Additionally, if the data estimate is off, the query may be throttled and would require additional code. Sandboxed code can’t elevate privileges to get a larger query-throttling limit.

Page 200: 10232AD-ENU_LabManual

` Lab Answer Key: Designing Processing Solutions 5

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 couldn’t (shouldn’t) 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. It’s not recommended to deploy untrusted, unreviewed code to farm level.

Page 201: 10232AD-ENU_LabManual

6 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 isn’t 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 aren’t enough to do the report because the report requires descriptive text and analysis as well. However, if the computations aren’t 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.

Page 202: 10232AD-ENU_LabManual

` Lab Answer Key: Designing Processing Solutions 7

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.

There’s 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 it’s 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 solution—and at a relatively low cost. If specific requirements arise that can’t 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.

Page 203: 10232AD-ENU_LabManual

Lab Answer Key: Designing Packaging 1

Module 7

Lab Answer Key: Designing Packaging

Contents: Lab A: Building a Business Document Solution

Exercise 1: Designing a Solution 2

Exercise 2: Creating the Final Solution 4

Lab B: Working with Dependencies

Exercise 1: Creating a Common Assembly 8

Exercise 2: Creating a Dependent Solution 9

Page 204: 10232AD-ENU_LabManual

2 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 platform—Microsoft® 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. It’s 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.

Page 205: 10232AD-ENU_LabManual

Lab Answer Key: Designing Packaging 3

• 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.

Page 206: 10232AD-ENU_LabManual

4 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. Click File, point to New, and then click Project.

3. In the New Project dialog box, click SharePoint under Installed Templates, and then click Empty SharePoint Project.

4. Specify the name of the project as Contoso.CertificationPackageList.

5. Clear the Create directory for solution check box. Click OK.

The SharePoint Customization Wizard appears.

6. Select Deploy as a sandboxed solution.

7. Click Finish.

Task 2: Add a content type to the project 1. Open Solution Explorer and right-click the project, point to Add, and then

click New Item.

2. Select Content Type as the item type.

3. 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.

4. On the Choose Content Type Settings page, select Document as the type from which to inherit.

5. Click Finish.

Task 3: Create a site-scoped feature for the content type 1. Right-click the Features node, and click Add Feature.

2. Specify the title and description as Certification Package Content Types and Content types for Contoso Certification Packages, respectively.

Page 207: 10232AD-ENU_LabManual

Lab Answer Key: Designing Packaging 5

3. Select Site from the Scope drop-down list.

4. 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.

5. Click Save.

6. In Solution Explorer, rename the newly created feature Feature2 CPL_ContentTypes.

7. Right-click the feature, and click View Designer.

8. In the Properties pane, change the Is Hidden value to True.

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

9. Click Save.

Task 4: Add a list definition 1. In Solution Explorer, right-click the Contoso.CertificationPackageList

project, point to Add, and then select New Item.

2. Select List Definition From Content Type as the item type.

3. Specify the name of the list definition as CPL_ListDefinition, and click Add.

4. 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.

5. Click Finish.

Task 5: Create a Web-scoped feature for the list definition 1. In Solution Explorer, right-click the Features node, and select Add Feature.

2. Specify a title and description as Contoso Certification Package List and Demo List Definition for Module 7, respectively.

Page 208: 10232AD-ENU_LabManual

6 Lab Answer Key: Designing Packaging

3. Notice that the scope is selected as Web by default.

4. 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.

5. Click Save.

6. In Solution Explorer, rename the newly created feature Feature2 CPL_ListDefinition.

Task 6: Ensure that the CPL_ContentTypes feature contains only one element 1. In Solution Explorer, right-click CPL_ContentTypes, and click View Designer.

2. 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. Press F5. This opens the SharePoint site.

2. Navigate to Site Actions | Site Settings.

3. Click Manage site features under Site Actions.

4. Verify that the Certification Package Content Types (CPL Content Types) feature is not listed (because you marked it as hidden).

5. Verify that the Contoso Certification Package List is listed and activated.

6. Click Site Actions | More Options.

7. Locate the Contoso Certification Package List and specify the name as Packages, and then click Create.

8. After the list is created, select Library Settings in the ribbon.

Page 209: 10232AD-ENU_LabManual

Lab Answer Key: Designing Packaging 7

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.

Page 210: 10232AD-ENU_LabManual

8 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. In Microsoft® Visual Studio® 2010, click File, point to New, and then click

Project.

2. In the New Project dialog box, select SharePoint under Installed Templates, and then select Empty SharePoint Project.

3. Specify the name of the project as Contoso.DemoApplication.Common and click OK. The SharePoint Customization Wizard appears.

4. In the SharePoint Customization Wizard, select the Deploy as a farm solution option.

5. Click Finish.

6. Right-click the project, point to Add, and then click Class.

7. In the Add New Item dialog box, specify the name of the class as Utility.cs and click Add.

8. 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

Page 211: 10232AD-ENU_LabManual

Lab Answer Key: Designing Packaging 9

Exercise 2: Creating a Dependent Solution

Task 1: Add a sandboxed project 1. In Solution Explorer, right-click the solution, point to Add, and then click New

Project.

2. In the New Project dialog box, select SharePoint under Installed Templates, and then select Empty SharePoint Project.

3. 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. Click Finish.

5. In the Sandboxed project, right-click References and then click Add Reference.

6. In the Add Reference dialog, click the Projects tab and then select the Contoso.DemoApplication.Common project. Click OK.

7. Right-click the project, point to Add, and then click New Item.

8. In the templates displayed, click Web Part, specify the name of the Web part as CustomDataDisplay, and then click Add.

Page 212: 10232AD-ENU_LabManual

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.Utility.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>

Page 213: 10232AD-ENU_LabManual

Lab Answer Key: Designing Packaging 11

Task 2: Verify functionality 1. Right-click the Common project, and click Deploy.

2. Right-click the Sandboxed project, and click Deploy.

3. Open Internet Explorer, and navigate to http://sharepoint/student/module7.

4. Enter username sharepoint\administrator with password P@ssw0rd.

5. On the page, insert the CustomDataDisplay Web part.

6. 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. In Visual Studio, right-click the Common project, and click Retract.

2. Navigate to the page that contains the Web Part.

3. Refresh the page and verify.

4. 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 application’s Web.config file. You should set the value to True only in development environments.

Page 214: 10232AD-ENU_LabManual

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. In Visual Studio, right-click the Sandboxed project, and click Retract.

2. 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.

Page 215: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 1

Module 8 Lab Answer Key: Designing a Development Strategy

Contents: Lab A: Team-Based Logging and Configuration

Exercise 1: Appraising the List-Based Configuration 2

Exercise 2: Using a SharePoint List-Based Configuration 3

Exercise 3: Using SharePoint List-Based Logging 9

Exercise 4: Configuring the Logging Level 15

Lab B: Operational Logging

Exercise 1: Adding Logging to SharePoint ULS 18

Page 216: 10232AD-ENU_LabManual

2 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

Page 217: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 3

Exercise 2: Using a SharePoint List-Based Configuration

Task 1: Create a Visual Studio 2010 project 1. Start Visual Studio 2010.

2. Click File, point to New, and then click Project.

3. In the New Project dialog box, click SharePoint under Installed Templates, and then click Empty SharePoint Project.

4. Specify the name of the project as Contoso.PlantTargets. Clear the Create directory for solution checkbox 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/module8/ and select Deploy as a sandboxed solution

6. Click Finish.

Task 2: Add a Constants file to the project 1. Right-click the project, point to Add, and then click Class.

2. In the Add New Item dialog box, specify the name of the class as Constants.cs and click Add.

3. Add the following code:

namespace Contoso.PlantTargets { class Constants { public const string ConfigurationList = "ConfigurationList"; public const string TargetForWeekFieldName = "ThisWeeksTarget"; } }

4. Click Save.

Page 218: 10232AD-ENU_LabManual

4 Lab Answer Key: Designing a Development Strategy

Task 3: Create Viewer Web Part 1. Right-click the project, point to Add, and then click New Item.

2. In the templates displayed, click Web Part, specify the name of the Web part as PlantTargetMonitor, and then click Add.

3. 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.

Page 219: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 5

Task 4: Create Setter Web Part 1. Right-click the project, point to Add, and then click New Item.

2. In the templates displayed, click Web Part, specify the name of the Web part as PlantMonitorSetter, and then click Add.

3. 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.)

Page 220: 10232AD-ENU_LabManual

6 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. In Solution Explorer, expand the Features folder.

2. Right-click the Feature1 and select Rename.

3. Name the feature definition as PlantTargets.

Task 6: Add Feature Receiver 1. Right-click the PlantTargets Feature node.

2. Select Add Event Receiver.

3. Open the newly created PlantTargets.EventReceiver.cs file.

Page 221: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 7

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.

Page 222: 10232AD-ENU_LabManual

8 Lab Answer Key: Designing a Development Strategy

Task 7: Deploy and verify 1. Press F5 to deploy the solution.

2. Navigate to Lists.

• Verify ConfigurationList has been created.

• Verify it has a default value.

3. Return to Home Page.

4. Click Page Tab and then click Edit Page.

5. In the Left Web part zone, click Add a Web Part.

6. In the Categories list, click Custom. Notice that PlantMonitorSetter and PlanTargetMonitor Web Parts are listed.

7. Select PlantMonitorSetter and click Add.

8. Select PlantTargetMonitor and click Add.

9. 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®.

Page 223: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 9

Exercise 3: Using SharePoint List-Based Logging

Task 1: Add additional constants 1. Open the solution from Exercise 2, Contoso.PlantTargets.

2. Open the Constants.cs file.

3. 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. Expand the PlantTargets Feature.

2. Open the PlantTargets.EventReceiver.cs file.

Page 224: 10232AD-ENU_LabManual

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.)

Page 225: 10232AD-ENU_LabManual

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.

Page 226: 10232AD-ENU_LabManual

12 Lab Answer Key: Designing a Development Strategy

Task 3: Add logging capability to Web part 1. Click the plus sign to the left of the PlantMonitorSetter Web part to expand it.

2. Double-click the PlantMonitorSetter.cs file.

3. 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(); }

Page 227: 10232AD-ENU_LabManual

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.

Page 228: 10232AD-ENU_LabManual

14 Lab Answer Key: Designing a Development Strategy

Task 4: Deploy and verify 1. Press F5 to deploy the solution.

2. Click Lists.

• Verify LogList has been created.

3. Enter a target value in the Setter Web part.

4. 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.

Page 229: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 15

Exercise 4: Configuring the Logging Level

Task 1: Add Web Part Configuration 1. Click the plus sign to the left of the PlantMonitorSetter Web part to expand it.

2. Double-click the PlantMonitorSetter.cs file.

3. 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.

Page 230: 10232AD-ENU_LabManual

16 Lab Answer Key: Designing a Development Strategy

Task 2: Add logging evaluation 1. Open PlantMonitorSetter.cs.

2. 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. Locate the method BtnSubmitCurrentTargetClick.

4. 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(); } }

Page 231: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 17

Task 3: Deploy and verify 1. Press F5 to deploy the solution.

2. Click the Page tab in the ribbon.

3. Click Edit Page.

4. Hover over the PlantMonitorSetter Web Part. The menu for this web part will appear. Click the menu and then click Edit Web Part.

• Verify Configure LoggingLevel option is available.

5. Choose Error as the logging level.

6. Click OK.

7. Click Stop Editing in the ribbon.

• Verify Logging Level.

8. Set the target using the Set Target for Current Week.

9. 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.

Page 232: 10232AD-ENU_LabManual

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. Close and re-open Visual Studio, choosing the Contoso.PlantTargets solution

from Lab A.

2. Select the Contoso.PlantTargets project in Solution Explorer.

3. In the Properties window, change the Sandboxed Solution option to False.

4. Confirm YES when warned about the impact of the changes.

Task 2: Add ULS Logging 1. Expand the PlantMonitorSetter Web part.

2. Open the file PlantMonitorSetter.cs.

3. 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: {0}", new object[] { message } ); }

5. Click Save.

Page 233: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Development Strategy 19

Task 3: Deploy and verify 1. Press F5 to deploy the solution.

2. In the ribbon, click the Page tab.

3. Click Edit Page.

4. Delete previous Web parts, as these are looking for the Web parts in the Sandbox.

5. Click Add a Web Part and choose Custom category.

• Verify the PlantMonitorSetter is listed.

• Verify the PlantTargetMonitor is listed.

6. Add both Web parts to the page.

7. Click Stop Editing.

8. Set the target using the Set Target for Current Week with Error.

9. 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.

Page 234: 10232AD-ENU_LabManual

Lab Answer Key: Developing Version and Deployment 1

Module 9 Lab Answer Key: Developing Version and Deployment

Contents: Lab A: Versioning Assemblies

Exercise 1: Defining Base Version 2

Exercise 2: Upgrading the Assembly 5

Lab B: Feature Upgrade

Exercise 1: Creating Upgrade Manage Page 10

Exercise 2: Adding Feature to Upgrade 14

Exercise 3: Upgrading Feature 17

Page 235: 10232AD-ENU_LabManual

2 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. Click Start, point to All Programs, click Microsoft® Visual Studio® 2010, and

then click Microsoft Visual Studio 2010.

2. Click File, point to New, and then click Project.

3. In the New Project dialog box, select SharePoint under Installed Templates and then select Empty SharePoint Project.

4. Specify the name of the project as Contoso.Version 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/module9/ and select Deploy as a farm solution.

6. Click Finish.

Task 2: Create a version Web Part 1. Right-click the Contoso.Version project, point to Add, and then click New

Item.

2. Select the Web Part option. Do not select the Visual Web Part option.

3. Specify the name of the Web Part as VersionWebPart and click Add.

Page 236: 10232AD-ENU_LabManual

Lab Answer Key: Developing Version and Deployment 3

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. In Solution Explorer, expand the Features folder.

2. Right-click Feature1 and click Rename.

3. Specify the name of the feature as Version.

4. Click Save.

Task 4: Deploy and verify 1. Right-click the Contoso.Version solution and select Properties.

2. Click the SharePoint tab and then clear the check box in front of Auto-retract after debugging.

3. Right-click the Contoso.Version solution and select Package.

4. Right-click the Contoso.Version solution and select Deploy.

5. Press CTRL+F5.

6. Click the Page tab and then click Edit Page.

7. In the Left Web part zone, click Add a Web Part.

Page 237: 10232AD-ENU_LabManual

4 Lab Answer Key: Developing Version and Deployment

8. In the Categories list, click Custom. Notice that VersionWebPart Web Part is listed.

9. 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.

Page 238: 10232AD-ENU_LabManual

Lab Answer Key: Developing Version and Deployment 5

Exercise 2: Upgrading the Assembly

Task 1: Update version 1. Open the Contoso.Version solution that you created in Exercise 1.

2. Click the plus sign to the left of the Properties option to expand it.

3. Double-click the AssemblyInfo.cs file.

4. Change the AssemblyVersion number from

[assembly: AssemblyVersion("1.0.0.0")]

to

[assembly: AssemblyVersion("1.1.0.0")]

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

6. Click Save.

Task 2: Package and deploy 1. Right-click the Contoso.Version solution and select Package.

2. Click Start, point to All Programs, click Microsoft SharePoint® 2010 Products, and then click SharePoint 2010 Management Shell.

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 an error. It cannot be loaded because it can’t find the v1.0.0.0 of the Contoso.Version .dll.

5. Click the Page tab and select Edit Page.

Page 239: 10232AD-ENU_LabManual

6 Lab Answer Key: Developing Version and Deployment

6. In the Left Web part zone, click Add a Web Part.

7. In the Categories list, click Custom. Notice that VersionWebPart Web Part is listed.

8. Select VersionWebPart and click Add.

9. Click Stop Editing. Notice that the VersionWebPart displays Assembly Version 1.1.0.0.

Task 3: Add SafeControl 1. Switch to Contoso.Version – Microsoft Visual Studio.

2. Double-click Package to open the Package Designer in Solution Explorer.

3. 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.

5. Edit the copied SafeControl entry in the Edit Options window to read, Version 1.0.0.0.

Page 240: 10232AD-ENU_LabManual

Lab Answer Key: Developing Version and Deployment 7

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

Page 241: 10232AD-ENU_LabManual

8 La

T1.

2.

T1.

2.

b Answer Key: Devel

ask 4: Add B. Add the fol

<BindingR </B

The manife

. Click Save.

ask 5: Packa. Right-click

. Click StartProducts, a

oping Version and D

BindingRedillowing code a

Redirects> <BindingRedBindingRedir

est should loo

.

age and updthe Contoso.V

t, point to All Pand then click

Deployment

rect at the top of th

irect OldVerects>

k similar to th

date Version solut

Programs, click SharePoint 2

he assembly ta

sion="1.0.0.

he following sc

tion and select

ck Microsoft S2010 Manage

ag:

0"/>

creenshot:

t Package.

SharePoint 20ement Shell.

010

Page 242: 10232AD-ENU_LabManual

Lab Answer Key: Developing Version and Deployment 9

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. Click Start, point to All Programs, click Administrative Tools, and then click

Internet Information Services (IIS) Manager.

2. Double-click SHAREPOINT, double-click Sites, and click SharePoint–80.

3. Click Content View, and then click Explore under Actions.

4. 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.

Page 243: 10232AD-ENU_LabManual

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. Click Start, point to All Programs, click Microsoft Visual Studio 2010, and

then click Microsoft Visual Studio 2010.

2. Click File, point to New, and then click Project.

3. In the New Project dialog box, select SharePoint under Installed Templates, and then select Empty SharePoint Project.

4. Specify the name of the project as Contoso.Upgrade and click OK. The SharePoint Customization Wizard appears.

5. In the SharePoint Customization Wizard, select Deploy as a farm solution.

6. Click Finish.

Task 2: Add feature manager page 1. Right-click the Contoso.Upgrade project, point to Add and click SharePoint

“Layouts” Mapped Folder.

2. Right-click the Contso.Upgrade folder below the Layouts mapped folder, point to Add and then click New Item.

3. In the Add New Item dialog box, for the SharePoint 2010 templates, click Application Page.

4. Specify the name of the item as FeatureManager.aspx and click Add.

5. Double-click the FeatureManager.aspx page.

6. Locate the ContentPlaceHolder with the ID PlaceHolderMain, and add the text Feature Manager.

7. In the same content placeholder, add a new Table Control and rename it tblFeatures.

Page 244: 10232AD-ENU_LabManual

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. Press F5 to deploy the solution.

2. 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. Double-click the FeatureManager.aspx.cs file from Layouts |

Contoso.Upgrade.

2. 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); }

Page 245: 10232AD-ENU_LabManual

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.)

Page 246: 10232AD-ENU_LabManual

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.

Page 247: 10232AD-ENU_LabManual

14 Lab Answer Key: Developing Version and Deployment

Exercise 2: Adding Feature to Upgrade

Task 1: Add site collection feature 1. Right-click the Contoso.Upgrade project, point to Add, and click New Item.

2. In the Add New Item dialog box, under SharePoint 2010 Templates, click List Definition.

3. Specify the name of the list definition as UpgradeLog and click Add. The SharePoint Customization Wizard appears.

4. Specify the display name as UpgradeLog.

5. From the What is the type of the list definition drop-down list box, select Custom List.

6. Ensure that the Add a list instance for this list definition check box is selected. Click Finish.

7. Right-click ListInstance1, click Rename, specify the name as ContosoUpgradeLog and press ENTER.

8. Right-click Feature1, click Rename, specify the name as Contoso.Upgrade.SiteCollection, and press ENTER.

9. 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. Right-click the Contoso.Upgrade.SiteCollection feature and choose Add

Event Receiver.

2. In the created Contoso.Upgrade.EventReceiver.cs file, uncomment the FeatureUpgrading event.

Page 248: 10232AD-ENU_LabManual

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. Double-click the Contoso.Upgrade.SiteCollection feature.

5. In the Properties window, copy the Receiver Assembly value to Upgrade Actions Receiver Assembly value.

6. Copy the Receiver Class value to the Upgrade Actions Receiver Class value.

7. Change the Version property to 2.0.0.0.

8. In the feature designer, click Manifest and copy the created <UpgradeActions … /> line from the preview.

9. 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).

Page 249: 10232AD-ENU_LabManual

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.

Page 250: 10232AD-ENU_LabManual

Lab Answer Key: Developing Version and Deployment 17

Exercise 3: Upgrading feature

Task 1: Package and update 1. Right-click Solution and choose Package.

2. Open a SharePoint 2010 Management Shell.

3. Click Start, Program Files, Microsoft SharePoint Products, SharePoint 2010 Management Shell.

4. 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. Type Iisreset to flush the ASP.NET cache.

6. 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. Click the Upgrade button to upgrade this site collection instance of the

feature.

2. Refresh the page and verify the feature is no longer listed.

3. 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.

Page 251: 10232AD-ENU_LabManual

Lab Answer Key: Designing Information Architecture and Navigation 1

Module 10 Lab Answer Key: Designing Information Architecture and Navigation

Contents:. Lab A: Developing a Site Structure

Exercise 1: Using Card Sort 2

Exercise 2: Designing Content Types and Site Columns 4

Lab B: Implementing Farm-wide Navigation

Exercise 1: Deploying a Custom SiteMap 5

Exercise 2: Adding an ASPmenu to a Custom Master Page 7

Page 252: 10232AD-ENU_LabManual

2 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 you—the student—are 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 they’re important:

• You should try to create a maximum of five main categories.

Reasoning: It’s 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 you’ve developed an appropriate categorization tree.

Reasoning: The objective is to ensure that we’re keeping a relatively good sub-structure, 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. It’s 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. It’s 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:

Page 253: 10232AD-ENU_LabManual

Lab Answer Key: Designing Information Architecture and Navigation 3

• Organize by consumer rather than creator—that 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 don’t look like they belong in one department. Develop a grouping around those items that don’t 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.

Page 254: 10232AD-ENU_LabManual

4 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 it’s 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, it’s 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.

Page 255: 10232AD-ENU_LabManual

Lab Answer Key: Designing Information Architecture and Navigation 5

Lab B: Implementing Farm-wide Navigation Exercise 1: Deploying a Custom SiteMap

Task 1: Create a new Visual Studio project 1. Click Start, point to All Programs, click Microsoft Visual Studio 2010, and

then click Microsoft Visual Studio 2010.

2. Click File, point to New, and then click Project.

3. In the New Project dialog box, select SharePoint under Installed Templates and then select Empty SharePoint Project.

4. 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.

6. Click Finish.

7. Right-click the Contoso.GlobalNav project and add a SharePoint Layouts mapped folder.

8. Delete the Contoso.Global.Nav folder.

9. 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.

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.

Page 256: 10232AD-ENU_LabManual

6 Lab Answer Key: Designing Information Architecture and Navigation

Task 2: Merge the navigation nodes into the default Layouts.Sitemap 1. Open a command prompt.

2. 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.

Page 257: 10232AD-ENU_LabManual

Lab Answer Key: Designing Information Architecture and Navigation 7

Exercise 2: Adding an ASPmenu to a Custom Master Page

Task 1: Add an ASPmenu and SiteMapDataSource 1. Open Windows® Internet Explorer® to http://localhost/student/module10.

2. Click Site Actions-Edit in Microsoft® SharePoint® Designer.

3. In the Site Objects section, click Master Pages.

4. Make a copy of the V4.master and name it V4global.master.

5. Open V4global.master. Click the Edit File link in the Customization section.

6. 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. Close and save the V4global.master.

9. Exit SharePoint Designer.

Page 258: 10232AD-ENU_LabManual

8 Lab Answer Key: Designing Information Architecture and Navigation

Task 2: Deploy V4global.master 1. Open the corporate portal site in Internet Explorer.

2. Click Site Actions-Site Settings.

3. In the Galleries section, click Master Pages.

4. Select the check box in front of V4global.master.

5. Select the Library Tools – Documents tab and then click Download a Copy.

6. Save the file to the desktop.

7. Delete V4global.master from the master page gallery.

8. Return to the Contoso.GlobalNav project in Visual Studio.

9. 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>

Page 259: 10232AD-ENU_LabManual

Lab Answer Key: Designing Information Architecture and Navigation 9

Task 3: Use the V4global.master 1. In Solution Explorer, right-click Feature1, and click Rename.

2. Specify the name of the feature as GlobalNav.

3. Right-click the GlobalNav feature, and select Add Event Receiver.

4. 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. Right-click the Contoso.GlobalNav project and select Deploy.

7. 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.

Page 260: 10232AD-ENU_LabManual

Lab Answer Key: Designing Branding and Customization Support 1

Module 11 Lab Answer Key: Designing Branding and Customization Support

Contents: Lab A: Packaging Branding

Exercise 1: Importing .wsp Files into Microsoft® Visual Studio® 2

Exercise 2: Extracting the File Resources 4

Exercise 3: Writing the Feature Receiver to Apply Changes 6

Exercise 4: Testing the Changes 8

Lab B: Improving Branding Performance

Exercise 1: Observing Current Performance 9

Exercise 2: Turning on BLOB Caching 10

Exercise 3: Observing BLOB Cached Performance 11

Exercise 4: Observing _layouts Performance 12

Page 261: 10232AD-ENU_LabManual

2 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. Open Visual Studio 2010.

2. From the menu bar, select File, and then select New Project.

The New Project dialog box appears.

3. In the left pane, select Visual C#-SharePoint.

4. In the middle pane, scroll down and select the Import SharePoint Solution Package project type.

5. In the name text box, enter Contoso.BrandingImport.

6. Click OK.

7. In the What local site do you want to use for debugging? text box, enter the URL of http://sharepoint/student/module11.

8. Accept Deploy as a sandbox solution, and click Next.

9. 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.

Page 262: 10232AD-ENU_LabManual

Lab Answer Key: Designing Branding and Customization Support 3

Task 2: Review the imported artifacts 1. In Solution Explorer, expand the Built-In List Instances node by clicking the

plus sign to the left of it.

2. Expand the folders: Master_Page_Gallery, _catalogsmasterpage_, Files, _catalogs, and masterpage folders to reveal the Contoso.master file.

3. Expand the List Instances node by clicking the plus sign to the left of it.

4. Expand the folders: Site_Assets, SiteAssets_, Files, and SiteAssets to reveal the Contoso.css, Header.png, and Logo.png files.

Page 263: 10232AD-ENU_LabManual

4 Lab Answer Key: Designing Branding and Customization Support

Exercise 2: Extracting the File Resources

Task 1: Create a new Contoso Branding project 1. In Solution Explorer, right-click the solution and select Add -> New Project.

2. In the center pane, select Empty SharePoint Project.

3. In the name text box, enter Contoso.Branding.

4. Click OK.

5. In the What local site do you want to use for debugging? text box, enter the URL of http://sharepoint/student/module11.

6. Accept Deploy as a sandbox solution and click Finish.

Task 2: Copy the master page resources to the Contoso Branding project 1. In Solution Explorer, drag the Master_Page_Gallery folder from

Contoso.BrandingImport to the Contoso.Branding project.

2. 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.

Page 264: 10232AD-ENU_LabManual

Lab Answer Key: Designing Branding and Customization Support 5

Task 4: Remove the imported project 1. In Solution Explorer, right-click the ContosoBrandingImport project and

select Remove.

2. Click OK on the Visual Studio dialog box indicating that the Contoso.BrandingImport project will be removed.

Page 265: 10232AD-ENU_LabManual

6 Lab Answer Key: Designing Branding and Customization Support

Exercise 3: Writing the Feature Receiver to Apply Changes

Task 1: Rename the feature 1. In Solution Explorer, right-click Feature1 and select Rename. Type

Contoso.Branding and press ENTER.

2. Double-click the renamed Contoso.Branding feature.

3. 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. In Solution Explorer, right-click the Contoso.Branding feature, and select Add

EventReceiver.

2. 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(); } }

Page 266: 10232AD-ENU_LabManual

Lab Answer Key: Designing Branding and Customization Support 7

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(); } }

Page 267: 10232AD-ENU_LabManual

8 Lab Answer Key: Designing Branding and Customization Support

Exercise 4: Testing the Changes

Task 1: Deploy and run the package 1. Press F5.

2. Verify that the site has a different header and logo.

Task 2: Deactivate the feature and ensure the site still works 1. In the Site Actions menu, select Site Settings.

2. In the Site Actions group, select Manage site features.

3. To the right of the Apply Contoso Branding feature, click Deactivate.

4. On the feature deactivation confirmation page, click the Deactivate this feature link.

5. Verify that the Contoso branding is no longer displayed.

Page 268: 10232AD-ENU_LabManual

Lab Answer Key: Designing Branding and Customization Support 9

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 you’re presented with a deployment conflicts dialog, click Resolve Automatically.

2. Open Internet Explorer to http://sharepoint/student/module11.

3. In the Site Actions menu, select Site Settings.

4. In the Site Actions group, click the Manage site features link.

5. To the right of Apply Contoso Branding, click Activate (if necessary).

Task 2: Open Fiddler and force a reload of the home page 1. Start Fiddler2.

2. Open Internet Explorer to http://sharePoint/student/module11.

3. Press F5 to force Internet Explorer to reload all of the files.

Task 3: Observe calls to ~/siteassets and ~/style Library 1. In Fiddler2, locate the request for

/student/module11/siteassets/contoso.css.

2. Click on the Inspectors tab.

3. In the response section, click the Headers button.

4. In the Cache section of the response headers, observe that the Cache-Control header is set to private.

Page 269: 10232AD-ENU_LabManual

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. Open Windows Explorer and navigate to the directory

C:\inetpub\wwwroot\wss\VirtualDirectories\80.

2. Double-click the web.config file to open it in Visual Studio.

Task 2: Set the BlobCache to enabled 1. Scroll down to near the end of the </SharePoint> section and locate the

<BlobCache> node.

2. Scroll to the end of the line and change the enabled attribute from false to true.

3. Save the web.config file.

4. Open Windows Explorer and create the directory BLOBCACHE off the root of the C drive.

5. In the BLOBCACHE directory, create a directory 14.

Page 270: 10232AD-ENU_LabManual

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. Click the Contoso logo on the home page.

2. In Fiddler, note that the only requests were to /student/Module11/ and /student/Module11/ /_default.aspx.

Task 3: Observe cache settings for ~/siteassets 1. In Fiddler, locate the most recent request for

/student/module11/siteassets/contoso.css.

2. Verify that the Cache-Control header is now public.

Page 271: 10232AD-ENU_LabManual

12 Lab Answer Key: Designing Branding and Customization Support

Exercise 4: Observing _layouts Performance

Task 1: Review a _layouts request in Fiddler 1. In Fiddler, locate the most recent _layouts request.

2. 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. In the previous task, you saw that the max-age setting of a _layouts page was

31536000.

2. Locate the most recent request to a /student/module11/siteassets/* file.

3. In the Response section, verify that the Cache-Control max-age is 86400.

4. Observe that _layouts has a max-age of 365 times the max-age of a ~/siteassets file.

Page 272: 10232AD-ENU_LabManual

Lab Answer Key: Designing Security 1

Module 12 Lab Answer Key: Designing Security

Contents: Lab A: Setting Up a Customer Service Site

Exercise 1: Setting Up the Authentication Provider 2

Exercise 2: Creating an FBA-Claims Site 6

Optional Exercise 3: Viewing Claims for an FBA User 13

Lab B: Solving a Security Issue

Exercise 1: Understanding the Scope and Relating it to Configuration 14

Exercise 2: Designing a Security Strategy 15

Page 273: 10232AD-ENU_LabManual

2 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. Users will not have an internal network identity.

2. A Contoso employee will manage access.

These two requirements point us in the direction of a solution that leverages forms-based 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. Once the wizard is displayed, click Next.

b. Click Next.

c. In the Server text box, type .\SharePoint.

d. Click Next twice.

e. Click Finish.

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

Page 274: 10232AD-ENU_LabManual

Lab Answer Key: Designing Security 3

3. Go to the Start menu, point to Administrative Tools and click on IIS Manager.

a. Click the Sites node from the tree view shown in the Connection pane.

b. In the Actions pane, click Add Web Site.

c. Specify fba as the site name and press TAB.

d. Select SharePoint–80 as the application pool.

e. Specify c:\inetpub\wwwroot\fba as the physical path to the site.

f. Specify fba as the Host name and click OK.

4. Go to Start menu, point to All Programs, point to Microsoft SQL Server 2008, and click on SQL Server® Management Studio.

a. Ensure the server name is .\SharePoint.

b. Click Connect.

c. In Object Explorer, expand the Databases node.

d. Expand the aspnetdb node.

e. Right-click the Security node.

f. Click New and then click User.

g. Specify Network Service as user name and press TAB.

h. Specify NT AUTHORITY\NETWORK SERVICE as login name and press TAB.

i. In Database role membership, select the db_owner check box.

5. Click OK.

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

Page 275: 10232AD-ENU_LabManual

4 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. Return to the IIS Manager window.

b. Select the fba Web site in the tree view shown in the Connections pane, and then double-click .Net Users.

Page 276: 10232AD-ENU_LabManual

Lab Answer Key: Designing Security 5

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. Specify user name, e-mail, and password. These values are the student’s choice.

f. Click Next.

9. 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. Specify a name in the Add .Net role popup window. This value is the student’s choice.

b. Click OK.

c. Return to the .Net Users section.

d. Double-click the user you created.

e. Select the newly created role to associate the user with the role.

f. Click OK.

Page 277: 10232AD-ENU_LabManual

6 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. On the Start Menu, point to All Programs, point to Microsoft SharePoint 2010 Products, and click on SharePoint 2010 Central Administration.

2. Click Application Management.

3. Select Manage Web applications and click New.

4. Specify the following values in the Create New Web Application dialog box:

a. Select Claims-Based Authentication.

b. Specify a port value of 888.

c. Select the Enable Forms-Based Authentication (FBA) check box.

d. Type fbaMembers in the ASP.NET Membership provider name field.

e. Type fbaRoles in the ASP.NET Role Manager name field.

f. Choose Create a new application pool.

g. Choose Predefined.

h. Select Network Service.

5. Click Application Management.

6. Click Create Site Collection.

7. 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

Page 278: 10232AD-ENU_LabManual

Lab Answer Key: Designing Security 7

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="%" />

Page 279: 10232AD-ENU_LabManual

8 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 Administration’s 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.)

Page 280: 10232AD-ENU_LabManual

Lab Answer Key: Designing Security 9

<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 application’s 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.)

Page 281: 10232AD-ENU_LabManual

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.SPClaimsAuthRoleProvider, 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.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> </providers> </membership>

Page 282: 10232AD-ENU_LabManual

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 Service’s 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>

Page 283: 10232AD-ENU_LabManual

12 Lab Answer Key: Designing Security

Task 7: Use Central Administration to designate the first FBA user for the Forms Web application 1. In Central Administration, click on Application Management.

2. Under Site Collections, click Change Site Collection Administrators.

3. 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. Navigate to your newly configured site. Don’t forget to use the port number

specified when creating the Web application (http://sharepoint:888).

2. You should see a login page that allows you to pick between Windows authentication and Forms authentication.

3. Follow these steps:

a. Choose Forms Authentication.

b. Login using the credentials of the user created in Exercise 1, Task 2.

c. Once on the home page, select the user control that displays your user name (upper right corner).

d. Select My Settings.

4. Verify that your login name has the new claims-based format.

Page 284: 10232AD-ENU_LabManual

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.

Page 285: 10232AD-ENU_LabManual

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. Is the problem related to all users or specific users?

2. How are the users provisioned?

3. How are the users added to the SharePoint sites?

4. Are there multiple site collections?

5. Does the issue manifest itself in particular locations (i.e. site or sub-site, list or document library)?

6. Is item-level security being used in lists?

7. Does the issue change based on some business condition?

Page 286: 10232AD-ENU_LabManual

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).

Page 287: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Page and Data Access Performance 1

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 2

Exercise 2: Leveraging the SharePoint Server 2010 Search API for Large Data Queries 8

Page 288: 10232AD-ENU_LabManual

2 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.

2. 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()

Task 2: Deploy the Contoso.Performance.Lists solution 1. Open the Contoso.Performance.sln file from the folder E:\Student

\Module 13\Module13_Lab_code\Contoso.Performance.

2. Click the Contoso.Performance.Lists project. In the Properties window, change the Site URL property to http://sharepoint/student/module13/.

3. Right-click the Contoso.Performance.Lists project, and click Deploy.

See the status bar to check whether the preceding task completed successfully.

Page 289: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Page and Data Access Performance 3

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.

2. Click the plus sign to the left of ListViewWebPart in the project.

3. Click the plus sign to the left of the ListViewWebPart.ascx file.

4. Double-click the ListViewWebPart.ascx.cs file to open it in the Visual Studio 2010 editor.

5. Add a custom monitor scope to the GetItemsButton_Click event to capture code execution in the event.

6. Click the plus sign to the left of the Events region.

7. 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 }

The resulting code should resemble the following:

8. Add a custom monitor subscope to the GetListItems method to capture metrics for the query against the target SPList object.

9. Click the plus sign to the left of the Methods region.

Page 290: 10232AD-ENU_LabManual

4 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:

Page 291: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Page and Data Access Performance 5

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. In SharePoint 2010, open the target site,

http://sharepoint/student/module13, in a Web browser.

2. Click Page tab on the ribbon and then click Edit Page.

3. In the Left Web Part zone, click Add a Web Part.

4. In the Categories section, click Contoso.

5. From the list of available Web Parts, click Contoso Performance List View, and then click Add.

6. Click Stop Editing on the ribbon.

7. 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.

Page 292: 10232AD-ENU_LabManual

6 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.

Page 293: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Page and Data Access Performance 7

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.

Page 294: 10232AD-ENU_LabManual

8 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. Locate and expand the Contoso.Performance.ListViewWebPart project in

the Contoso.Performance solution.

2. Click the plus sign to the right of the ListViewSearchWebPart project item.

3. Click the plus sign to the right of ListViewSearchWebPartUserControl.ascx.

4. Double-click the ListViewSearchWebPartUserControl.ascx.cs file.

5. 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 + "')";

Page 295: 10232AD-ENU_LabManual

Lab Answer Key: Designing for Page and Data Access Performance 9

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.

Page 296: 10232AD-ENU_LabManual

10 Lab Answer Key: Designing for Page and Data Access Performance

Task 2: Analyze performance metrics in the Developer Dashboard 1. Click Edit Page on the ribbon.

2. In the Left Web Part zone, click Add a Web Part.

3. Locate the Contoso folder in the Categories section of the expanded ribbon bar.

4. From the list of available Web Parts, select Contoso Performance List View with Search, and click the Add button.

5. Click Stop Editing on the ribbon.

6. 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.

7. 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.

Page 297: 10232AD-ENU_LabManual

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.

Page 298: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Testing Strategy 1

Module 14 Lab Answer Key: Designing a Testing Strategy

Contents: Exercise 1: Conducting Unit Testing 2

Exercise 2: Conducting Performance Testing 8

Exercise 3: Conducting Load Testing 10

Page 299: 10232AD-ENU_LabManual

2 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. Open the Contoso.Testing.sln file from the folder E:\Student\Module 14 \Module14_Lab_Code\Contoso.Testing.

b. Click the Contoso.Testing.WebParts project. In the Properties window, change the Site URL property to http://sharepoint/student/module14/.

c. Locate and open the ListView_View.cs file within the Contoso.Testing.WebParts project.

2. Create a new test project.

a. Right-click the GetListAsGridView method within the Contoso.Testing.WebParts.ListView_View class.

Page 300: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Testing Strategy 3

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. Arrange the test.

i. Locate the automatically generated test method entitled GetListAsGridViewTest (the method will be decorated with the [TestMethod()] attribute).

Page 301: 10232AD-ENU_LabManual

4 Lab Answer Key: Designing a Testing Strategy

ii. Delete the generated code.

iii. 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. Create test assertions. The result of these assertions determines whether the test passes or fails.

i. Verify that the number of rows in the GridView equal the number of rows in the test DataTable object:

//Assert Assert.AreEqual(tableRows, gridRows);

Page 302: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Testing Strategy 5

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.

• Create a Test List.

i. From the Test menu, select Create New Test List.

Page 303: 10232AD-ENU_LabManual

6 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. Save the solution. This will generate a .vsmdi file needed by the MSTest.exe command-line utility to run the specified tests.

v. Open the Properties window of the Contoso.Testing.WebParts project.

Page 304: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Testing Strategy 7

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. Open the Output window (View > Output).

viii. 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.

Page 305: 10232AD-ENU_LabManual

8 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. Right-click the Contoso.Testing solution and select Add > New Project.

b. Set the framework type to .NET Framework 4.

c. 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. Right-click the Contoso.Testing.Performance project and select Add > Web Performance Test. A browser window will appear.

3. Enter the URL http://sharepoint/student/module14/default.aspx and press ENTER.

4. 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.

5. Add a response time parameter to the test.

a. Open WebTest1.webtest.

b. Remove URL references to ScriptResx.ashx from the list of target URLs for the WebTest1 object.

c. Right-click the remaining URL node in WebTest1 and select Properties.

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.

Page 306: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Testing Strategy 9

• Expand the base URL node and note the statistics for each linked resource.

b. Review the Details window to view results of the default validations for Response URL and Response Time Goal.

c. Close the Test Results tab.

7. Add a validation rule and run the test again to execute the rule.

a. Right-click the WebTest1 node and select Add Validation Rule.

b. Select the Find Text rule.

c. 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.

   

Page 307: 10232AD-ENU_LabManual

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.

Page 308: 10232AD-ENU_LabManual

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.

Page 309: 10232AD-ENU_LabManual

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. In the Test Mix step, add a new Web test.

i. Click the Add button.

ii. Select WebTest1 and move it to the list of selected tests.

Page 310: 10232AD-ENU_LabManual

Lab Answer Key: Designing a Testing Strategy 13

iii. Click OK.

iv. Click Next to continue.

f. In the Network Mix step, accept the defaults, and click Next to continue.

Page 311: 10232AD-ENU_LabManual

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. Click Add computer.

ii. Enter the name of the computer the test is being executed on, and select the ASP.NET check box.

iii. Click Next to continue.

Page 312: 10232AD-ENU_LabManual

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. Take note of the various graphs in the test results report while the test is executing.

3. 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.