Presentation is loading. Please wait.

Presentation is loading. Please wait.

Developing Applications for SharePoint 2010 Chris Keyser Principal Program Manager patterns & practices

Similar presentations


Presentation on theme: "Developing Applications for SharePoint 2010 Chris Keyser Principal Program Manager patterns & practices"— Presentation transcript:

1

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

3 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

4

5 SharePoint Application and Platform Base Platform Core Services Applications Operating System Services Web Parts | Personalization | Master Pages | Provider Framework (Navigation, Security…) Database services Workflow services Search services Core Services CompositesSitesCommunitiesSearchContentInsignts Site Model Rendering Templates Navigation Visual Blueprint Storage Repository Metadata Versioning Backup Security Rights\Roles Pluggable Auth. Per Item Rights Trimming Management Delegation Provisioning Monitoring Staging Topology Config. Mgmt. Farm Services Feature Policy Extranet APIs Fields\Forms OM and SOAP Events Deployment ASP.NET Identity Management IIS

6 New Decisions with New Features

7 Guidance Overview SharePoint Development ClientExecutionData Application Foundations

8 Execution Models Overview SharePoint Development ClientExecutionData Application Foundations

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

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

11 A Word About “Sandbox”

12 patterns & practices Sandbox Architecture Sandbox Worker Process () (SPUCWorkerProcess.exe) User Code Service () User Code Service (SPUCHostService.exe) Execution Manager (Inside Application Pool) IIS (WPW3.EXE) FRONT END BACK END Sandbox Worker Proxy Process () (SPUCWorkerProcessProxy.exe) Web.config / CAS Policies Access restricted by CAS policy

13 patterns & practices Processing a Request in Sandbox Sandbox Worker Process () (SPUCWorkerProcess.exe) User Code Service () User Code Service (SPUCHostService.exe) Execution Manager (Inside Application Pool) IIS (WPW3.EXE) FRONT END Sandbox Worker Proxy Process () (SPUCWorkerProcessProxy.exe) Web.config / CAS Policies Request Access restricted by CAS policy BACK END Custom Code Logic Allowed API Calls

14 patterns & practices Handling Bad Code in the Sandbox Sandbox Worker Process () (SPUCWorkerProcess.exe) User Code Service () User Code Service (SPUCHostService.exe) Execution Manager (Inside Application Pool) IIS (WPW3.EXE) FRONT END Sandbox Worker Proxy Process () (SPUCWorkerProcessProxy.exe) Web.config / CAS Policies Request Run for 30sec Access restricted by CAS policy BACK END Resource Wasting custom Logic

15 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, Cristian Petculescu wants 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.

16 Sample Execution Model Topics Understanding SharePoint Execution Models Understanding SharePoint Execution Models – What Are the SharePoint Execution Models? What Are the SharePoint Execution Models? – Examples and Scenarios 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?

17 Data Models Overview SharePoint Development ClientExecutionData Application Foundations

18 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 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 SharePoint Site SharePoint List Item List Column SharePoint List Lookup column Event Receiver No Equivalent Concepts

19 Site Columns, Content Types and Lists Content Type Site Columns List List Content Type Parent Content Type Contains references to site columns Content Types support Inheritance 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 Lists can contain multiple content types List Content Type

20 OrderLines list List Relationships: Lookup Column List Relationships build off of Lookup Columns Orders list ID (built in) OrderNoAmountCost List Item Relationship Show Column Lookup Column: Order ID (built in) Order (lookup column) TotalSKUQuantityPrice Projected Column Cascading and restricted delete behaviors based upon lookup relationship

21 Practices Good Practices Using site columns and content types Defining site columns in the root site collection Defining lookup columns using site columns Bad Practices Defining the same list structures over and over

22 Content Database Indexing Machines ID (built in) ModelManuPricePrice Expire Date Description Index ID Index Single Column Index Index Compound Column Index Automatically generated and maintained 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) 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) Data Types Supported Content Type Currency Lookup Metadata Number 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.

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

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

25 List Throttling

26 Practices Good Practices Index columns used to filter Schedule off-hour maintenance window Use Content Iterator to process all list items Use Metadata Navigation to partition list access Use List Patterns to segment views and data Bad Practices Indexing columns you don’t use to filter Globally disabling throttling Permanently disabling throttling on a list Using all of your index slots for a list

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

28 LINQ to SharePoint Query Efficiency LINQ Query LINQ to SP Provider var results = from projectItem in context.PriorityProjects where projectItem.ExecutiveSponsor == sponsor select projectItem; 0x0100 David Pelton 2147483647  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.  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.

29 View Projections 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 }; … } … LINQ CAML  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  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

30 LINQ To SharePoint

31 Practices Good Practices Inspect CAML output Use View Projections Apply efficient LINQ syntax Use SPSiteDataQuery to aggregate items if no relationship exist Bad Practices Ignoring CAML generated by queries Using LINQ to aggregate lists without relationships

32 Guidance Overview SharePoint Development ClientExecutionData Application Foundations

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

34 Client Data Access Client Side Object Model (CSOM) REST interfaceWeb services List queries List join queries Implicit only to satisfy where clause External list queries View projections Request batching Synchronous operations (except ECMA) Asynchronous operations SharePoint Foundation object model access Access to SharePoint Server functionality (beyond SharePoint Foundation) Support non-Windows clients (ECMA only) Support strongly-typed LINQ queries (objects only, no list queries)(with proxy, lists only)

35 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 Service URI addressable resources http verbs URI addressable resources http verbs JSON or ATOM & ATOM Pub MIME ETAGs X-HTTP Merge MIME ETAGs X-HTTP Merge

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

37 Using WCF Data Services

38 Practices Good Practices Use command batching Minimize data returned to the client Use asynchronous processing Use View Projections Bad Practices Override concurrency control without a good reason Recommended Practice: Avoid using SharePoint Web Services to access lists for future compatibility.

39 How Does the Guidance Library Help? Flexibility Testability Supportability Manageability Service Locator SharePoint Logger Application Settings Manager

40 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 HiComplianceLogger is now used without changing the application code  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 HiComplianceLogger is now used without changing the application code cfg = SharePointServiceLocator.GetCurrent().GetInstance (); cfg.Site = researchSite; cfg.RegisterTypeMapping (); var logger = SharePointServiceLocator.GetCurrent().GetInstance (); logger.LogToOperations(error, 0, EventSeverity.Warning, LoggingAreas.ResearchPortal.DrugManagementCategory);

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

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

43

44 It’s Easiest to Use Only What you Know

45 List Relationships: Database Foreign Key OrderLines Orders ID (primary key) OrderNoAmountCostID (primary key) OrderID (foreign key) SKUQuantityPrice Foreign Key Relationship A Typical Database Foreign Key Relationship


Download ppt "Developing Applications for SharePoint 2010 Chris Keyser Principal Program Manager patterns & practices"

Similar presentations


Ads by Google