Tải bản đầy đủ (.pdf) (458 trang)

Professional sharepoint® 2010 field guide ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (20.42 MB, 458 trang )

PROFESSIONAL
SHAREPOINT® 2010 FIELD GUIDE
INTRODUCTION xxi
 PART I USING SHAREPOINT TECHNOLOGIES AND EXPLOITING
FUNCTIONALITY
CHAPTER 1 Leveraging the SharePoint Object Model 3
CHAPTER 2 Creating Visual Web Parts 35
CHAPTER 3 Customizing Search 55
CHAPTER 4 Leveraging the SharePoint ListsWeb Service 73
CHAPTER 5 Custom Field Types, Content Types, and List Definitions 93
CHAPTER 6 Workflow 131
CHAPTER 7 Administrating SharePoint 2010with PowerShell 175
 PART II SHAREPOINT SOLUTIONS
CHAPTER 8 UI Design and Branding 211
CHAPTER 9 Building a Site Provisioning System 233
CHAPTER 10 Building Scalable Applications inSharePoint 297
CHAPTER 11 Building a Custom Global Navigation Solution 343
APPENDIX A URL Shortcuts 399
APPENDIX B CSS Quick Reference 401
APPENDIX C Hiding and Customizing Page Breadcrumbs 405
APPENDIX D PowerShell Quick Reference 407
GLOSSARY 409
INDEX 411

PROFESSIONAL
SharePoint
®
2010 Field Guide


PROFESSIONAL
SharePoint
®
2010 Field Guide
Steve Mann
Colin Murphy
Pablo Gazmuri
Chris Caravajal
Christina Wheeler
Professional SharePoint® 2010 Field Guide
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2012 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-10505-4
ISBN: 978-1-118-22403-8
ISBN: 978-1-118-23767-0
ISBN: 978-1-118-26224-5
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should
be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201)
748-6011, fax (201) 748-6008, or online at />Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect

to the accuracy or completeness of the contents of this work and specically disclaim all warranties, including without limita-
tion warranties of tness for a particular purpose. No warranty may be created or extended by sales or promotional materials.
The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding
that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is
required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable
for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a poten-
tial source of further information does not mean that the author or the publisher endorses the information the organization or
Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this
work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with
standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to
media such as a CD or DVD that is not included in the version you purchased, you may download this material at
. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2011942765
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its afliates, in the United States and other countries,
and may not be used without written permission. SharePoint is a registered trademark of Microsoft Corporation. All other
trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor
mentioned in this book.
ABOUT THE AUTHORS
STEVE MANN was born and raised in Philadelphia, Pennsylvania, where he still resides today. He is
an Enterprise Applications Engineer for Morgan Lewis and has more than 17 years of professional
experience. Steve was previously a Principal Architect for RDA Corporation, where he worked for
over thirteen years. Steve graduated from Drexel University in 1993. For the past eight years, he has
focused primarily on collaboration and business intelligence solutions using Microsoft technologies.
Steve managed the internal BI Practice Group at RDA for several years. He was also heavily involved
within RDA’s Collaboration/Search Practice Group. Steve has authored and coauthored several books
related to the subject of SharePoint Server 2010. Steve’s blog can be found at:

www.SteveTheManMann
.com
. Steve enjoys vacationing with his family along the east coast, including locations such as
Orlando, Florida; Williamsburg, Virginia; Ocean City and Sea Isle City, New Jersey; and New York
City. They usually hits three or four locations each year. Follow Steve on Twitter @stevethemanmann!
COLIN MURPHY lives in Atlanta, Georgia, where heworks as a Principal Architect for RDA
Corporation, a Microsoft Gold Partner. He has spent the last fteen years developing Web sites
and Windows applications using a variety of languages including C++, PowerBuilder, Java, PHP, and
Python, but has primarily been a .NET/C# developer for the last ten years. Colin has been developing
enterprise solutions built on SharePoint since SharePoint 2007 was in beta. Colin holds a number of
technical certications includingMicrosoft Certied Professional, Microsoft Certied Application
Developer, Microsoft Certied Solutions Developer, and is also a Microsoft Certied Technical
Specialist forSharePoint. Hehas been recognizedas a K2 Insider and is the coauthor of the book
Professional K2blackpearl by Wiley.
PABLO GAZMURI is a Principal Architect with RDA Corporation, an IT Consulting rm. He has led
SharePoint efforts for a number of Fortune 500 companies where he conducts planning, mentoring,
training, and coding activities. With fteen years of development experience, Pablo is a web, collabo-
ration, and search expert who has built numerous corporate intranets, extranets, ecommerce sites,
and custom applications over the course of his career. Pablo has recently built custom SharePoint
applications enabling project management, document generation, SharePoint site provisioning, gover-
nance enforcement, and more. You can nd him on Twitter as @PGazmuri, or contact him through
RDA at
.
CHRIS CARAVAJAL has been working exclusively with SharePoint technologies since 2007. As a con-
sultant, he works with organizations on planning and architecting SharePoint solutions that vary in
both size and complexity. Primarily an “out-of-the-box” specialist, Chris’s main focus is getting the
most out of SharePoint with the native features and tools. He also has experience building InfoPath
forms and SharePoint Designer workow solutions. Chris is a MCTS and is a contributing author to
the top-selling SharePoint technical publication, “Professional SharePoint 2010 Administration.”
CHRISTINA WHEELER is a SharePoint Trainer for Mindsharp and founder of CM Portal Solutions,

LLC. She is a highly respected SharePoint consultant who is extremely active in the SharePoint com-
munity. With over ten years of experience in the industry, Christina has knowledge and experience in
graphic design, web development, and custom development. Her work is targeted primarily toward
educational institutions, nancial institutions, and telecommunications. As a trainer, Christina brings
her real-world experience to the classroom. She enjoys contributing articles to technical Web sites
and often speaks at SharePoint community events and conferences. You can follow her on Twitter
as @cwheeler76.
ABOUT THE TECHNICAL EDITOR
REZA ALIREZAEI MVP, MCP, MCPD, MCITP & MCTS for SharePoint 2010, is a SharePoint solu-
tion architect focused on designing custom applications with SharePoint, Ofce, and Microsoft
Business Intelligence technologies. Reza is the founder and president of Development Horizon, where
he has helped many clients architect and build large-scale, mission-critical SharePoint applications.
He also speaks in many local and international conferences. Reza achieved the status of Microsoft
Most Valuable Professional (MVP) for SharePoint in 2006, which he still is today. He has also co-
authored several books, papers, and articles. Reza can be reached at

ACQUISITIONS EDITOR
Paul Reese
PROJECT EDITOR
Christina Haviland
TECHNICAL EDITOR
Reza Alirezaei
PRODUCTION EDITOR
Daniel Scribner
COPY EDITOR
San Dee Phillips
EDITORIAL MANAGER
Mary Beth Wakefield
FREELANCER EDITORIAL MANAGER
Rosemarie Graham

ASSOCIATE DIRECTOR OF MARKETING
David Mayhew
MARKETING MANAGER
Ashley Zurcher
BUSINESS MANAGER
Amy Knies
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE
GROUPPUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE PUBLISHER
Neil Edde
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Katie Crocker
COMPOSITOR
Craig Woods, Happenstance Type-O-Rama
PROOFREADER
Mark Steven Long
INDEXER
Robert Swanson
COVER DESIGNER
LeAndra Young
COVER IMAGE
© iStock / ulamonge
CREDITS

ACKNOWLEDGMENTS

THANKS TO CHRISTINA WHEELER for taking over one of the chapters in this book. I am so glad she
joined the group of authors. Also, thanks to Chris Caravajal from SharePoint 911 for stepping in and
taking a chapter as well. Thanks to all my SharePoint expert friends and Twitter followers. You inspire
me to keep going and doing more with technology. Special thanks to Paul Reese, our acquisitions editor,
and the entire Wrox project team for helping us create an excellent SharePoint 2010 resource.

CONTENTS
INTRODUCTION xxi
PART I: USING SHAREPOINT TECHNOLOGIES AND
EXPLOITING FUNCTIONALITY
CHAPTER 1: LEVERAGING THE SHAREPOINT OBJECT MODEL 3
Customizing SharePoint 3
UI Components 4
Nonvisual Components 11
External Access 13
Putting It All Together 24
A Blog Aggregator 24
Calendar Reminders 28
Scheduled Workflows 31
Summary 33
CHAPTER 2: CREATING VISUAL WEB PARTS 35
Creating Visual Web Parts 35
Visual Web Part Project 35
Adding Controls 38
Adding Code 40
Deployment 41
Connecting Web Parts 43
Creating an Interface 44
Creating the Provider Web Part 45
Creating the Consumer Web Part 46

Deploying the Solution 48
Connecting the Web Parts 48
Using SharePoint Controls 49
Leveraging the XSLT Web Part 53
Summary 54
CONTENTS
INTRODUCTION xxi
Who This Book Is For xxi
What This Book Covers xxi
How This Book Is Structured xxi
What You Need to Use This Book xxi
Conventions xxii
Source Code xxii
Errata xxiii
p2p.wrox.com xxiii
PART I: USING SHAREPOINT TECHNOLOGIES AND EXPLOITING F
LEVERAGING THE SHAREPOINT OBJECT MODEL 3
Customizing SharePoint 3
Putting It All Together 24
Summary 33
CREATING VISUAL WEB PARTS 35
Creating Visual Web Parts 35
Connecting Web Parts 43
Using SharePoint Controls 49
Leveraging the XSLT Web Part 53
Summary 54
CUSTOMIZING SEARCH 55
Configuring and Creating Content Sources 55
Configuring Search Scopes 57
Creating Managed Properties 62

Customizing the Enterprise Search Center 63
Finding Content with Alerts 70
Summary 71
LEVERAGING THE SHAREPOINT LISTSWEB SERVICE 73
Web Services Overview 73
xiv
CONTENTS
CHAPTER 3: CUSTOMIZING SEARCH 55
Configuring and Creating Content Sources 55
Indexing Content 55
Planning Content Sources 56
Implementing Content Sources 57
Configuring Search Scopes 57
Defining Search Scopes in the Service Application 58
Defining Site Collection Search Scopes and Scope Display Groups 60
Creating Managed Properties 62
Customizing the Enterprise Search Center 63
Creating a New Search Results Page 65
Modifying the Advanced Search Screen 68
Finding Content with Alerts 70
Summary 71
CHAPTER 4: LEVERAGING THE SHAREPOINT LISTSWEB SERVICE 73
Web Services Overview 73
SharePoint Web Services Introduction 73
Instantiating a Web Service 73
Setting Credentials 76
Querying Lists and List Items 78
Modifying the SharePoint Location 78
Retrieving Lists from a SharePoint Location 79
Retrieving List Items from a SharePoint List 79

Modifying List Items 83
Creating a New Item 83
Updating an Existing Item 84
Deleting an Existing Item 86
Programmatically Uploading Files to SharePoint 89
Adding References 89
Create Upload Method 90
Create Web Request and File Buer 90
Use Stream and FileStream Objects 90
Perform the Upload 91
Error Handling and Returns 91
Summary 92
xv
CONTENTS
CHAPTER 5: CUSTOM FIELD TYPES, CONTENT TYPES,
ANDLISTDEFINITIONS 93
Field Types 94
Field Type Definition Components 95
Building a Restricted Social Security Number Field Type 99
Custom Content Types 114
Creating the Employee Details Content Type Stub 114
Implementing the Employee Details Content Type 116
List Definitions 120
Creating the Employees List Definition 120
Customizing the List Schema 122
Summary 129
CHAPTER 6: WORKFLOW 131
Workflow Introduction 131
Getting Started 132
Defining the Process 132

Types of Workflow Associations 133
Starting Workflows 134
Selecting Your Solution Method 134
SharePoint 2010 Native Tools 136
SharePoint Workflow Tools 136
SharePoint Workflow Templates 138
Microsoft Oce Visio 2010 Premium 148
SPD 2010 151
Conditions 151
Actions 154
Workflow Options and Features 160
Visual Studio 2010 171
Summary 173
CHAPTER 7: ADMINISTRATING SHAREPOINT 2010WITH POWERSHELL 175
Getting Started 176
Starting PowerShell 176
PowerShell Conventions 177
Command Discovery 178
Function Key Shortcuts 180
Command Prompt System Commands 180
xvi
CONTENTS
SharePoint Management with PowerShell 181
SharePoint Farm Management 181
Web Application Management 184
Site Management 186
Solutions and Features 189
Enterprise Content Management 192
SharePoint Database Management 193
Search Administration with PowerShell 195

SharePoint Foundation Search 195
Enterprise Search 196
Service Applications 199
Access Services 200
Excel Services 200
InfoPath Forms Services 201
Metadata Service 202
PerformancePoint Services 202
Secure Store Service 204
State Service 205
User Profile Service 205
Visio Services 206
Word Services 207
Summary 208
PART II: SHAREPOINT SOLUTIONS
CHAPTER 8: UI DESIGN AND BRANDING 211
Themes 211
Creating Themes 212
Using Themes 212
Configuring Themes from the Site User Interface 215
Deploying Themes Through a Feature 217
Branding with Custom CSS 217
Themes and CSS 217
Building and Including Custom CSS 218
Using a Centered Fixed Width Design 218
Styling Individual Navigation Items 219
Changing SharePoint Search Icon with CSS 220
Master Pages 220
Browser Support 221
Deploying Master Pages via Visual Studio 2010 221

Customizing the Ribbon 224
xvii
CONTENTS
Working with Page Layouts 225
Creating Page Layouts Using SharePoint Designer 2010 226
Deploy Custom Page Layouts Through Visual Studio 2010 227
Branding Layouts Pages 228
Customizing Application Pages 229
Creating Custom Application Pages 229
Registering Custom Application Pages from Receivers 231
Registering Custom Application Pages from Windows PowerShell 232
Summary 232
CHAPTER 9: BUILDING A SITE PROVISIONING SYSTEM 233
Sites and Site Collections 234
Determining Your Site Taxonomy 235
Example Taxonomy Matrix 235
Additional Factors 236
The Site Request Process 237
An Example Site Request Process 237
Security Challenges 240
Our Example Solution 241
Alternatives in Implementation 242
Buildout 243
Creating the Project Framework 244
Creating the Necessary Lists 244
Creating a Custom Feature Receiver 251
Building and Deploying the Solution 255
Creating a Custom List Item Form 256
Creating Form Helper Functions 258
Creating Form Controls 261

Building Out the Custom Form Code 265
Creating the Core Site Provisioning Functionality 276
Deploying the Solution 284
Next Steps 293
User Experience 293
Site Request and Configuration 293
Additional Uses for Site Data 294
Summary 295
CHAPTER 10: BUILDING SCALABLE APPLICATIONS INSHAREPOINT 297
General Performance Issues 298
Memory, Disk, and Network Access 298
Algorithmic Eciency 299
xviii
CONTENTS
Load Balancing and Farm Configuration 300
Server Configuration Options 300
Load-Balancing Options 302
Database Allocation 304
Data Sharding 305
SharePoint Caching Options 306
Page Output Caching 306
SharePoint Object Cache 309
The BLOB Cache 312
Caching in Code 316
Application Object 316
Session Object 317
View State 317
HTTPContext 318
HTTP Cache 319
Static Variables 320

Local Files and the SharePoint Content DB 320
A Reusable Caching Method 321
Managing Large Lists 325
Query Throttling 325
Indexed Fields 327
Configuring Views 328
Client-Side Optimizations 329
Content Distribution Networks 329
Reducing Server Round Trips 330
Writing Ecient Code in SharePoint 331
Adding and Retrieving List Data 331
Batch Operations 333
Supported Batch Operations 334
Multithreaded Operations 336
String Processing 338
Exception Handling 340
SPMonitoredScope 340
General Tips for Solving Hard Problems 341
Summary 342
CHAPTER 11: BUILDING A CUSTOM GLOBAL NAVIGATION SOLUTION 343
Defining the Requirements 343
Reviewing the Architecture 344
Understanding OOTB SharePoint Navigation 345
Pieces of the Solution 346
xix
CONTENTS
Creating the Solution 348
Creating the Visual Studio Solution and Projects 348
Building the Navigation Menu UI 350
Building the Processing Layer 363

Building the Global Navigation Consumer 377
Building the Timer Job 394
Summary 398
APPENDIX A: URL SHORTCUTS 399
Site Management 399
Galleries 400
Page Maintenance 400
APPENDIX B: CSS QUICK REFERENCE 401
APPENDIX C: HIDING AND CUSTOMIZING PAGE BREADCRUMBS 405
APPENDIX D: POWERSHELL QUICK REFERENCE 407
Backup and Restore 407
Features 407
Form Templates 407
Sites and Webs 408
Solutions 408
Users 408
Glossary 409
INDEX 411

INTRODUCTION
THIS BOOK WAS WRITTEN TO PROVIDE a wide coverage of complex solutions to common needs and
desires from SharePoint 2010 implementations along with great reference material for digging in
and learning the new platform; an excellent guide and handbook for people in the eld. There are
plenty of books to ramp up and learn how to do things with SharePoint; however, this book focuses
on the main areas of customization and provides more intricate details as well as specic full-scale
solutions that people need to implement. It is not a beginner how-to but a second or third book to
further deepen one’s understanding and knowledge in SharePoint 2010. It is meant to be a guide for
those in the eld that suddenly nd themselves needing to create custom SharePoint solutions.
WHO THIS BOOK IS FOR
This book is for SharePoint or .NET Developers who now need to implement solutions in SharePoint

2010. These are developers that may have been exposed to some SharePoint development but haven’t
spent extensive time customizing solutions. Those that consider themselves more than beginner but
not quite intermediate or advanced can benet greatly from this book. If you need to become an
expert in SharePoint 2010 solutions, this book takes you down that road.
WHAT THIS BOOK COVERS
This book covers the main aspects of customizing SharePoint from branding and creating web parts,
to exploiting the SharePoint API and building workows. PowerShell administration is discussed
and explained. The Search features of SharePoint are demonstrated and customized. Full-scale
solutions are dissected to present best practices and understanding of SharePoint development way
beyond out-of-the-box.
HOW THIS BOOK IS STRUCTURED
There are two parts to this book. The rst part starts out with the building blocks of SharePoint
knowledge and customization. The second part gets deeper and more complex while building out
applications and custom solutions.
WHAT YOU NEED TO USE THIS BOOK
In order to benet the most from this book, readers need to have a SharePoint 2010 development envi-
ronment along with Visual Studio 2010 Professional Edition (or higher). Usually a virtual-machine-
based environment is more available than physical servers. SharePoint 2010 requires 64-bit hardware
with at least 8GB of memory and the Windows 2008 R2 operating system.
xxii
INTRODUCTION
CONVENTIONS
To help you get the most from the text and keep track of what’s happening, we’ve used a number of
conventions throughout the book.
As for styles in the text:

We italicize new terms and important words when we introduce them.

We show keyboard strokes like this: Ctrl+A.


We show le names, URLs, and code within the text like so: persistence.properties.

We present code in two different ways:
We use a monofont type with no highlighting for most code examples.
We use bold to emphasize code that is particularly important in the present
context or to show changes from a previous code snippet.
SOURCE CODE
As you work through the examples in this book, you may choose either to type in all the code man-
ually, or to use the source code les that accompany the book. All the source code used in this book
is available for download at
www.wrox.com. When at the site, simply locate the book’s title (use the
Search box or one of the title lists) and click the Download Code link on the book’s detail page to
obtain all the source code for the book. Code that is included on the Web site is highlighted by the
following icon:
Listings include the lename in the title. If it is just a code snippet, you’ll nd the lename in a code
note such as this:
Code snippet lename
Because many books have similar titles, you may nd it easiest to search by
ISBN; this book’s ISBN is 978-0-470-10505-4.
Once you download the code, just decompress it with your favorite compression tool. Alternately,
you can go to the main Wrox code download page at
www.wrox.com/dynamic/books/download
.aspx
to see the code available for this book and all other Wrox books.
xxiii
INTRODUCTION
ERRATA
We make every effort to ensure that there are no errors in the text or in the code. However, no one
is perfect, and mistakes do occur. If you nd an error in one of our books, like a spelling mistake
or faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may

save another reader hours of frustration, and at the same time, you will be helping us provide even
higher-quality information.
To nd the errata page for this book, go to
www.wrox.com and locate the title using the Search box
or one of the title lists. Then, on the book details page, click the Book Errata link. On this page, you
can view all errata that has been submitted for this book and posted by Wrox editors. A complete
book list, including links to each book’s errata, is also available at
www.wrox.com/misc-pages/
booklist.shtml
.
If you don’t spot “your” error on the Book Errata page, go to
www.wrox.com/contact/techsupport
.shtml
and complete the form there to send us the error you have found. We’ll check the information
and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions
of the book.
P2P.WROX .COM
For author and peer discussion, join the P2P forums at . The forums are a
Web-based system for you to post messages relating to Wrox books and related technologies and inter-
act with other readers and technology users. The forums offer a subscription feature to email you top-
ics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other
industry experts, and your fellow readers are present on these forums.
At
, you will find a number of different forums that will help you, not only
as you read this book, but also as you develop your own applications. To join the forums, just follow
these steps:

1. Go to p2p.wrox.com and click the Register link.

2. Read the terms of use and click Agree.


3. Complete the required information to join, as well as any optional information you wish to
provide, and click Submit.

4. You will receive an email with information describing how to verify your account and
complete the joining process.
You can read messages in the forums without joining P2P, but in order to post
your own messages, you must join.

×