1 / 45

Developing Applications for SharePoint 2010

Developing Applications for SharePoint 2010. Chris Keyser Principal Program Manager patterns & practices ckeyser@microsoft.com. Objectives. Understand the concepts guidance addresses See examples of what’s in the guidance

pakuna
Télécharger la présentation

Developing Applications for SharePoint 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing Applications for SharePoint 2010 Chris Keyser Principal Program Manager patterns & practices ckeyser@microsoft.com

  2. Objectives • Understand the concepts guidance addresses • See examples of what’s in the guidance • Gain a high level understanding of where and how to apply the guidance

  3. Microsoft SharePoint 2010The Business Collaboration Platform for the Enterprise and the Web Sites Connect and Empower People Composites Communities Cut Costs with a Unified Infrastructure Insights Content Rapidly Respond to Business Needs Search

  4. Composites Sites Communities Search Content Insignts Core Services Management DelegationProvisioningMonitoringStaging Security Rights\RolesPluggable Auth.Per ItemRights Trimming Storage RepositoryMetadataVersioningBackup Topology Config. Mgmt.Farm ServicesFeature PolicyExtranet Site Model RenderingTemplatesNavigationVisual Blueprint APIs Fields\Forms OM and SOAPEventsDeployment SharePoint Application and Platform Applications Core Services Web Parts | Personalization | Master Pages | Provider Framework (Navigation, Security…) Base Platform Search services Workflow services Database services ASP.NET Identity Management IIS Operating System Services

  5. New Decisions with New Features

  6. Guidance Overview

  7. Execution Models Overview

  8. Full Trust Architecture FRONT END IIS(WPW3.EXE) Global Assembly Cache SharePoint Object Model External Resources (other APIs, WCF services, databases, etc Application Assembly

  9. What Happens when Things Go Wrong? FRONT END IIS(WPW3.EXE) Global Assembly Cache SharePoint Object Model External Resources (other APIs, WCF services, databases, etc Application Assembly Request

  10. A Word About “Sandbox” Sandbox Execution Sandbox Solution

  11. Sandbox Architecture FRONT END BACK END User Code Service (SPUCHostService.exe) Execution Manager(Inside Application Pool) Sandbox Worker Process (SPUCWorkerProcess.exe) IIS(WPW3.EXE) Web.config / CAS Policies Untrusted Code SP Object Model Subset Sandbox Worker Proxy Process (SPUCWorkerProcessProxy.exe) Access restricted by CAS policy Full SP Object Model

  12. Processing a Request in Sandbox FRONT END BACK END User Code Service (SPUCHostService.exe) Custom Code Logic Execution Manager(Inside Application Pool) Sandbox Worker Process (SPUCWorkerProcess.exe) IIS(WPW3.EXE) Web.config / CAS Policies Untrusted Code Allowed API Calls SP Object Model Subset Request Sandbox Worker Proxy Process (SPUCWorkerProcessProxy.exe) Access restricted by CAS policy Full SP Object Model

  13. Handling Bad Code in the Sandbox FRONT END BACK END User Code Service (SPUCHostService.exe) Resource Wasting custom Logic Execution Manager(Inside Application Pool) Sandbox Worker Process (SPUCWorkerProcess.exe) IIS(WPW3.EXE) Web.config / CAS Policies • while(true) • { • //Do a Bad Bad Thing! • } Untrusted Code Run for 30sec SP Object Model Subset Request Sandbox Worker Proxy Process (SPUCWorkerProcessProxy.exe) Access restricted by CAS policy Full SP Object Model

  14. Example Reference Implementation – Sandbox with Workflow Scenario: You have designed and implemented a system that tracks the progress of statements of work (SOWs) and budget estimations. The IT manager, CristianPetculescuwants you to extend this solution to automate the creation of project sites. When the approval status of a project estimate is set to Approved, a site is created to collaborate on the project.

  15. Sample Execution Model Topics • Understanding SharePoint Execution Models • What Are the SharePoint Execution Models? • Examples and Scenarios • Farm Solutions • Sandboxed Solutions • How Does the Sandbox Execution Model Work? • What Can I Do with Sandboxed Solutions? • Code Access Security Restrictions • Using Event Receivers • Accessing External Data • Using Workflows • How Do I Manage Sandboxed Solutions? • What Are the Core Issues for Sandboxed Solutions? • Hybrid Approaches • Hybrid Execution with a Full Trust Proxy • Hybrid Execution with External Content Types • Hybrid Execution with Custom Workflow Activities • How Do I Manage Hybrid Solutions? • What Are the Core Issues for Hybrid Solutions?

  16. Data Models Overview

  17. How is a List Model Defined? • Database is the container • A database contains one or more tables, and tables contain entities • Columns define the fields of an entity • A row in a table is an entity instance • Tables have Primary keys • Triggers fire on data events • Foreign Keys relationships relate entities • DDL representation No Equivalent Concepts SharePoint Site SharePoint List SharePoint List Lookup column Item List Column Event Receiver

  18. Site Columns, Content Types and Lists Parent Content Type Content Types support Inheritance Content Type Site Columns Contains references to site columns List List Content Type List Content Type When a content types is added to a list, a copy is placed in the list, and that content type inherits from the original content type List Content Type Lists can contain multiple content types

  19. List Relationships: Lookup Column List Relationships build off of Lookup Columns Lookup Column: Order List Item Relationship Show Column Orders list OrderLines list Projected Column Cascading and restricted delete behaviors based upon lookup relationship

  20. Practices

  21. Indexing Data Types Supported Single line of text Choice field (but not multi-choice) Number Currency Date/ Time Lookup (but not multi-value) Person or Group (but not multi-value) Title (but not in a document library) Automatically generated and maintained ID Index Single Column Index Compound Column Index Machines Content Database Index Index Index Data Types Supported Content Type Currency Lookup Metadata Number Maximum of 20 indices per list Unique constraints are supported for columns in SharePoint 2010. A column with a unique constraint must be indexed.

  22. List Throttling Code or a SharePoint Control • Deleting a list with > 5000 items • Delete a site with > 5000 items • Creating an index on a list > 5000 items query Query Results SPQueryThrottledException (code) Subset of results with warning (UI) Parts Limits apply to all Operations Content Database Query Analyzed • 5,000 rows touched on list query (SPQuery) (List) • 20,000 rows touched (admin) • 20,000 rows touched on cross-list (SPSiteDataQuery)

  23. How Does Indexing Impact Throttling? Code or a SharePoint Control Where Part.SKU== SKU123 Where Part.Name == 8mm Hex Nut Parts list, 20000 items SPQueryThrottledException (code) Content Database Query Analyzer SKU Index No index Use index Scan table

  24. demo List Throttling

  25. Practices

  26. LINQ To SharePoint Process Design Time SPMetal Your Source Your Source Solution Package Your Site DataContext source code Your Source Runtime Deployed & Activated Solution

  27. LINQ to SharePointQuery Efficiency • CAML generated at runtime by provider • Efficient CAML queries generated when possible • Blocks LINQ queries that translate to 2 or more CAML queries • LINQ to Objects does the rest. LINQ Query var results = from projectItem in context.PriorityProjects where projectItem.ExecutiveSponsor == sponsor select projectItem; LINQ to SP Provider <Where> <And> <BeginsWith> <FieldRef Name="ContentTypeId" /> <Value Type="ContentTypeId">0x0100</Value> </BeginsWith> <Eq> <FieldRef Name="Executive_x0020_Sponsor" /> <Value Type="Text">David Pelton</Value> </Eq> </And> </Where> </Query> <ViewFields> <FieldRef Name="Executive_x0020_Sponsor" /> <FieldRef Name="ProjectsLookup" LookupId="TRUE" /> <FieldRef Name="ID" /> <FieldRef Name="Title" /> </ViewFields> <RowLimit Paged="TRUE">2147483647</RowLimit> </View>

  28. View Projections CAML LINQ <View> <Query> <Where> … </Where> </Query> <ViewFields> <FieldRef Name="Title" /> <FieldRef Name="Executive_x0020_Sponsor" /> <FieldRef Name="ProjectLeader" /> </ViewFields> <ProjectedFields> <Field Name="ProjectLeader" Type="Lookup" List="Project" ShowField="Leader" /> </ProjectedFields> <Joins> <Join Type="LEFT" ListAlias="Project"> <!--List Name: Projects--> <Eq> <FieldRef Name="Project" RefType="ID" /> <FieldRef List="Project" Name="ID" /> </Eq> </Join> </Joins> </View> using (ManufacturingSiteDataContext context = new ManufacturingSiteDataContext(SPContext.Current.Web.Url)) { var results = from projectItem in context.PriorityProjects where projectItem.ExecutiveSponsor == sponsor select new { projectItem.Title, projectItem.ExecutiveSponsor, projectItem.Project.Leader }; … } • View projections combine entities • Only way to return data from more than one entity in one query • Use anonymous or strongly typed objects • More efficient than lazy loading when properties will be accessed • Navigating through entity relationships uses lazy loading • Projections are not updateable

  29. demo LINQ To SharePoint

  30. Practices

  31. Guidance Overview

  32. Client Data Access Options SharePoint Web Services Client Object Model REST Interfaces Client Side Object Model (CSOM) WCF Data Services Proxy ASMX Proxy WCF SOAP SharePoint Client Query Protocol OData Protocol SharePoint CSOM Services WCF Data Services provider ASMX Web Services LINQ To SharePoint

  33. Client Data Access

  34. What is OData (www.odata.org)? • REST based protocol • Two serialization formats • JSON • ATOM/ATOM PUB • Supports advanced features • Batching • Concurrency Control • Partial Updates Client URI addressable resources http verbs JSON or ATOM & ATOM Pub MIME ETAGs X-HTTP Merge Service

  35. How Does Command Batching Work? (OData) Calls made on the client into the WCF Data services proxy BeginExecuteBatch called, causing the commands to be sent to the server 2 1 Custom Client-Side Code WCF Data Services Proxy Server Object Model Add Machine Add Machine MIME Encoded Message Update Part Update Part Delete Bin Delete Bin Results User Results Commands are executed, and results gathered and returned. Each operation has a result The proxy calls the callback method with an array of results 3 4

  36. demo Using WCF Data Services

  37. Practices • Recommended Practice: Avoid using SharePoint Web Services to access lists for future compatibility.

  38. How Does the Guidance Library Help? Service Locator Application Settings Manager SharePoint Logger

  39. Example – Service Locator • Scenario: You are logging failures in your system to the event log using the logger. • For compliance reasons you need to log this information using special logger that tracks additional information on the research site • The HiComplianceLoggeris now used without changing the application code var logger = SharePointServiceLocator.GetCurrent().GetInstance<ILogger>(); logger.LogToOperations(error, 0, EventSeverity.Warning, LoggingAreas.ResearchPortal.DrugManagementCategory); cfg= SharePointServiceLocator.GetCurrent() .GetInstance<IServiceLocatorConfig>(); cfg.Site = researchSite; cfg.RegisterTypeMapping<ILogger,HiComplianceLogger>();

  40. Example: Hierarchical Setting Lookup SPFarm Foobar found, return setting value Not found, look for Foobar SPWebApplication SPWebApplication Not found, look for Foobar SPSite SPSite SPSite Not Found, look for Foobar SPWeb SPWeb SPWeb SPWeb Application Code var setting = hconfig.GetByKey<string>[“Foobar”] Foobar in settings?

  41. Why use the Guidance? • Gain deeper insights into SharePoint architecture and internals • Better evaluate your decisions and tradeoffs • Develop applications more efficiently • Develop applications that are more flexible and manageable • http://www.microsoft.com/spg • Production Release • http://spg.codeplex.com • Discussions and support

  42. It’s Easiest to Use Only What you Know

  43. List Relationships: Database Foreign Key A Typical Database Foreign Key Relationship Foreign Key Relationship Orders OrderLines

More Related