Download presentation
Presentation is loading. Please wait.
1
SharePoint Object Model
Site Address: Central admin:
2
Agenda Introduction to the Object Model
11/18/ :38 AM Agenda Introduction to the Object Model Object model of Server Architecture Object model of Site Architecture Windows SharePoint Services Objects Accessing data in a WSS List Updating data Tips & Tricks SharePoint Web Services Working with Lists 2 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
3
Introduction to the Object Model
Managed code object model on the server Accessible via ASP.NET or any other server process Implemented in C# Exposes almost of all of the data stored in WSS Windows SharePoint Services is a technology that enables people to collaborate in browser-based workspaces while providing a manageable in frastructure and extensible application platform for improving the efficiency of business processes SharePoint is an integrated suite of server capabilities that can help improve organizational effectiveness by providing Enforce check in and check out, Minor versioning Microsoft SharePoint is an intelligent, enterprise portal that provides a central place to access, manage, share, and interact with relevant information, documents, applications, and people. It enables faster, more informed decision making, more effective sharing across teams organizations have created a huge volume of unstructured content that includes documents, messages, videos, instant messages, Web pages, and more. Enterprise Content Management (ECM) from Microsoft is a key component of an organization's infrastructure, that can help companies overcome these challenges.(a) Document management(b) Records management(c )Web content management SharePoint provides built-in workflow templates to automate approval, review, and archiving processes. With SharePoint, you can also create, maintain, and analyze custom workflows, enabling you to streamline your collaborative processes. Electronic forms provided through InfoPath Forms Services are an integral part of such workflows. These electronic forms designed in InfoPath make it easy to collect and validate information that drives your business processes. providing users with a single place to store and collaborate on content Document management Version Check in/Checkout Access Control Collaboration Share Docs with others Instant messaging tools Document and meeting work space Site collection Integration with office Improved intranet Dynamic User Friendly Self Publish Centralized Search for Information Document Word Date Author Doc Type Portal Creation
4
Introduction to the Object Model
Examples of what can be done with the Object Mode: Add, edit, delete, and retrieve data from SharePoint Lists Create new lists and set list metadata (e.g. the fields in a list) Work with documents in document libraries. Perform administrative tasks such as creating webs, adding users, creating roles, etc. Pretty much any functionality in the UI can be automated through the OM! Windows SharePoint Services is a technology that enables people to collaborate in browser-based workspaces while providing a manageable in frastructure and extensible application platform for improving the efficiency of business processes SharePoint is an integrated suite of server capabilities that can help improve organizational effectiveness by providing Enforce check in and check out, Minor versioning Microsoft SharePoint is an intelligent, enterprise portal that provides a central place to access, manage, share, and interact with relevant information, documents, applications, and people. It enables faster, more informed decision making, more effective sharing across teams organizations have created a huge volume of unstructured content that includes documents, messages, videos, instant messages, Web pages, and more. Enterprise Content Management (ECM) from Microsoft is a key component of an organization's infrastructure, that can help companies overcome these challenges.(a) Document management(b) Records management(c )Web content management SharePoint provides built-in workflow templates to automate approval, review, and archiving processes. With SharePoint, you can also create, maintain, and analyze custom workflows, enabling you to streamline your collaborative processes. Electronic forms provided through InfoPath Forms Services are an integral part of such workflows. These electronic forms designed in InfoPath make it easy to collect and validate information that drives your business processes. providing users with a single place to store and collaborate on content Document management Version Check in/Checkout Access Control Collaboration Share Docs with others Instant messaging tools Document and meeting work space Site collection Integration with office Improved intranet Dynamic User Friendly Self Publish Centralized Search for Information Document Word Date Author Doc Type Portal Creation
5
Object model of Server Architecture
11/18/ :38 AM Object model of Server Architecture SPFarm Object SPFarm object is the highest object within the Windows SharePoint Services object model hierarchy which represents a WSS farm and used for central configuration settings. It contains global settings for all the servers, services, and solutions that are installed in a WSS farm. With this object you can also access all the servers, services, and solutions that are installed in a WSS farm. · Create method can be used to a server farm, its associated configuration database, and a farm account on the local computer based on the specified connection string. · Open method can be used to get a remote server farm based on the specified connection string. · Servers property of SPFarm object is used to get the collection of all physical computers that are in the server farm. This property returns a SPServerCollection object which is a collection of SPServer objects (one SPServer object for each physical computer in the current server farm). · Services property of SPFarm object is used to get the collection of all the services that are in the server farm. This property returns a SPServiceCollection object which is a collection of SPService objects (one SPService object for each Service in the current server farm). · Solutions property of SPFarm object is used to get the collection of all the solutions that are in the server farm. This property returns a SPSolutionCollection object which is a collection of SPSolution objects (one SPSolution object for each Solution in the current server farm). SPServer Object SPServer object represents a physical computer in the server farm. ServiceInstances property is used to get the collection of individual service instances that run on the individual computer. SPService Object SPService object represents a logical service or application installed in the server farm. SPSolution Object SPSolution object represents a SharePoint Solution installed in the server farm. SPWebService Object SPWebService object represents a Web service that contains one or more WSS web applications. It can be used to access configuration settings for a specific logical service or web application. WebApplications property is used to get the collection of all the web applications that are running within this service. It returns SPWebApplicationCollection object which is a collection of SPWebApplication objects (one SPWebApplication object for each web application). SPServiceInstance Object SPServiceInstance object represents a single instance of service running in the server computer. ServiceInstances property of the SPServer object can be used to get the SPServiceInstanceCollection object that represents all the service instances that are currently running on a server computer. Service property is used to get the SPService object that contains the farm-wide settings that apply to the service that this instance implements. Server property is used to get the SPServer object on which this instance is installed. SPDatabaseServiceInstance Object SPDatabaseServiceInstance object represents a single instance of a database service running on the server computer. The SPDatabaseServiceInstance class derives from the SPServiceInstance class and thus inherits the Service property, which provides access to the service or application that the instance implements. The Databases property gets the collection of content databases used in the service. SPWebApplication Object SPWebApplication object represents a WSS web application and it contains a set of content databases and site collections. The SPWebApplication object provides access to credentials and other server farm wide application settings SPWebApplication inherits from SPPersistedObject, which means that an object of the class persists in the configuration database. SPWebApplication class enables administrators to access IIS properties without opening IIS Manager for example with the help of IisSettings and ApplicationPool property, we can access the properties of the IIS application pool to which the WSS Web application is assigned. Sites property is used to get the collection of site collections within the Web application. It returns SPSiteCollection object which is a collection of SPSite objects. ContentDatabases property is used to get the collection of content databases used in the Web application. It return SPContentDatabaseCollection object which is a collection of SPContentDatabase objects. SPDatabase Object SPDatabase object encapsulates access to Microsoft SQL Server databases. Databases property of the SPDatabaseServiceInstance object can be used to get the collection of databases that support the database service instance. SPContentDatabase Object SPContentDatabase object represents a content database that contains user data for a SharePoint web application. ContentDatabases property of the SPWebApplication object can be used to get the collection of all the content databases that are used by the Web application. ContentDatabase property of the SPSite object can also be used to get the content database for a site collection. Sites property is used to get the collection of site collections for which the content database stores data. WebApplication property is used to get the parent Web application. SPSiteCollection Object SPSiteCollection object represents the collection of site collections within the Web application and each site collection is represented by SPSite object. © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
6
Object model of Site Architecture
11/18/ :38 AM Object model of Site Architecture SPSite Object SPSite object represents a collection of sites in a Web application, including a top-level Web site and all its sub sites. This collection of sites is known as “Site Collection”. Each site in the site collection, top-level site as well as all its sub sites is represented by a SPWeb object. Although a SPSite object represents a collection of sites, the SPSite class is not a collection in the sense of a class that implements ICollection. A SPSiteCollection class implements the latter interface and it represents a collection of SPSite objects. SPSite object can be instantiated by following methods: · SPSite constructor can be used to instantiate a SPSite object for a specific site collection within a console application, or windows application, or on an ASP.NET page SPSite objSPSite = new SPSite("Absolute_URL"); · Within an ASP.NET application, Site property of the SPContext class can be used to get the SPSite object that represents the current site collection SPSite objSPSite = SPContext.Current.Site; · Get SPSiteCollection object from the Sites property of the SPWebApplication class. This SPSiteCollection represents the collection of site collections in a SharePoint Web application, so just use an indexer to return a single site collection from the collection. SPSiteCollection objSiteCollection = objWebApplication.Sites; int index = 0; SPSite objSite = objSiteCollection[index]; · RootWeb property of SPSite class returns its child top-level website. In turn, the SPWeb object that represents the top-level Web site has a Webs property that holds all its immediate child sub sites. The AllWebs property of SPSite returns all the sub sites and the top-level Web site. SPWeb Object Each SharePoint website is represented by SPWeb object whether it is a top level website or a sub site. SPWeb object has members that can be used to manage a site, including its template and theme, as well as to access files and folders on the site. SPWeb object can be a child of another SPWeb object or of a SPSite object. If it is the child of a SPSite object, it is the top-level Web site in its site collection. A hierarchy of Web sites always has exactly one top-level Web site. This site is represented by a SPWeb object which is an immediate child of a SPSite object. SPWeb object has a Webs property that returns a collection of other SPWeb objects; specifically, the immediate child sub sites under it. The Lists property returns a SPListCollection object that represents all the lists in the site. Each list in a site is represented by SPList object. SPWeb object can be instantiated by following methods: · To get SPWeb object for top level website following code snippet can be used: 1) SPSite objSPSite = new SPSite("Absolute_URL"); SPWeb objSPWeb = objSPSite.OpenWeb(); OR 2) SPSite objSPSite = new SPSite("Absolute_URL"); SPWeb objSPWeb = objSPSite.RootWeb(); · To get SPWeb object for top level website as well as for each sub site, following code snippet can be used: SPWeb objSPWeb = objSPSite.AllWebs[index]; · To get SPWeb object for each sub site only, following code snippet can be used: SPWeb objSPWeb = objSPWeb.Webs[index]; SPList Object Each shared list and document library in a SharePoint website is represented by SPList object. SPList object has members that are used to manage the list or access items in the list. · GetItems method can be used to perform queries that return specific items. · Fields property returns a SPFieldCollection object that represents all the fields, or columns, in the list. · Items property returns a SPListItemCollection object that represents all the items, or rows, in the list. · Folders property returns the collection of folder items for the list. · Lists property can be used to get the parent collection of lists to which the list belongs. · ParentWeb property can be used to get the parent Web site for the list. · Delete method can be used to delete the list. · GetChanges method can be used to get from the change log the collection of changes that have occurred in the list. · Update method can be used to update the database with changes that are made to the list. SPField Object SPField object represents a field in a list. · Title property can be used to get or set the display name for the field. · Type property can be used to get or set the type of the field. · Delete method can be used to delete the field. · Update method can be used to update the database with changes that are made to the field. SPListItem Object SPListItem object represents a single row item in the list. · Fields property returns the collection of all fields in the parent list of the SPListItem. · Delete method can be used to delete a row from the list. · Update method can be used to update a row in the list. · Following code snippet can be used to add a row in the list: spListItemObject = spListObject.Items.Add(); //assign values for each column of this row spListItemObject.Update(); Content Management © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
7
Windows SharePoint Services Objects
11/18/ :38 AM Security SPUser SPRole SPGroup SPPermission SPRightsEnumeration Administration SPGlobalAdmin SPVirtualServer SPQuota SPGlobalConfig SPSiteCollection Documents SPDocumentLibrary SPFile SPFileCollection SPFolder Lists SPList SPListCollection SPListItem SPListItemCollection SPView SPField SPListTemplate Files SPFile SPFileCollection SPFileVersion SPFolder SPDocumentLibrary SPDocDiscussion SPDocTemplate Lists SPList SPListCollection SPListItem SPListItemCollection SPView SPField SPListTemplate Files SPFile SPFileCollection SPFileVersion SPFolder SPDocumentLibrary SPDocDiscussion SPDocTemplate Lists SPList SPListCollection SPListItem SPListItemCollection SPView SPField SPListTemplate Files SPFile SPFileCollection SPFileVersion SPFolder SPDocumentLibrary SPDocDiscussion SPDocTemplate Efficient collaboration Rapid deployment, ease of use Manageable infrastructure Robust foundation platform for Web-based applications These were memories of corrupted files which had to be rebuilt from scratch, of unrecorded changes to documents (which resulted in hours and hours of rework), of server space issues and sharing limitations. And I wasn’t the only person who faced these problems. Others I worked with experienced them as well. There was a point where we actually needed to back up the versions of a critical spreadsheet we were sharing to our own hard-drives © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
8
Working with the OM The object model has three top-level objects:
SPWeb (represents an individual site) SPSite (represents a site collection, which is a set of web sites) SPGlobalAdmin (used for global administration settings) In order to perform actions on data within a web, you must first get an SPWeb object.
9
Adding our namespace You should add references to the WSS namespaces to your source files using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.Administration; …
10
Key Object – SPWeb Starting point to get at the Lists, Items, Documents, Users, Alerts, etc. for a web site. Example Properties: Web.Lists (returns a collection of lists) Web.Title (returns the title of the site) Web.Users (returns the users on the site) In a web part or ASPX page, you can use the following line to get a SPWeb: SPWeb myweb = SPControl.GetContextWeb(Context);
11
Accessing data in a WSS List
Get a SPList or SPDocumentLibrary object. SPList mylist = web.Lists[“Events”]; You can then call the .Items property to get all of the items: SPListItemCollection items = mylist.Items;
12
Accessing data in a list
To get data for a field, specify the field name in the indexer for an SPListItem foreach(SPListItem item in items) { Response.Write(item["Due Date"].ToString()); Response.Write(item["Status"].ToString()); Response.WRite(item["Title"].ToString()); }
13
Full Example SPWeb web = SPControl.GetContextWeb(Context);
SPList tasks = web.Lists["Tasks"]; SPListItemCollection items=tasks.Items; foreach(SPListItem item in items) { output.Write(item["Title"].ToString() + item["Status"].ToString() + "<br>"); }
14
Updating data Most objects in WSS do not immediately update data when you change a property You need to first call the Update() method on the object This helps performance by minimizing SQL queries underneath the covers Example: SPList mylist = web.Lists[“Tasks”]; mylist.Title=“Tasks!!!”; mylist.Description=“Description!!”; Mylist.Update();
15
Updating List Data SPListItem is another example of an object where you need to call update: Example: SPListItem item = items[0]; item["Status"]="Not Started"; item["Title"]="Task Title"; item.Update();
16
Code Example -- Enumerate Lists and Webs
private void ShowSubWebs(HtmlTextWriter output) { SPWeb web = SPControl.GetContextWeb(Context); SPWebCollection mywebs = web.Webs; foreach (SPWeb myweb in mywebs) output.Write(myweb.Title + "<br>"); } private void ShowSubWebsWithLists(HtmlTextWriter output) output.Write("<b>" + myweb.Title + "<br>" + "</b>"); SPListCollection lists = myweb.Lists; foreach (SPList list in lists) if (list.ItemCount>10) output.Write(list.Title + ": " + list.ItemCount + "<br>");
17
Tips & Tricks To optimize performance, use foreach() to step through collections. Iterating through collections by index can result in unnecessary database calls Calls to collections such as List.Items are expensive. Preserve the collection rather than requesting it again For best performance, use SQL Profiler to minimize the # of queries that your app makes to the database TIMING: 30 seconds Performance Tips To optimize performance, use foreach() to step through collections. Iterating through collections by index can result in unnecessary database calls. Also, calls to collections such as List.Items are expensive. Preserve the collection rather than requesting it again. For best performance, use SQL Profiler to learn to minimize the # of queries that your app makes to the database.
18
Tips & Tricks User Interface -> OM terminology mapping:
Site Collection -> Site Site -> Web Top-level Site -> Rootweb Subsite -> Subweb Free your objects when you’re done using them. Call ‘Close’ or ‘Dispose’ on Web and Site objects. Use the following command to get the current SPWeb object from a web part or aspx page: SPWeb web = SPControl.GetContextWeb(Context);
19
SharePoint Web Services
SharePoint has web services APIs for accessing content remotely. The web services layer are built on top of the server OM. Allows manipulation of Lists, Webs, Views, List Items, etc. Functionality will be similar to server object model, but with fewer interfaces optimized to minimize transactions. Microsoft Office 2003 (e.g. Excel, Data Sheet, Work, Outlook, FrontPage, etc) use web services to access data from SharePoint Services. For more information please visit the following link In Windows SharePoint Services, site settings and information, along with all site content — such as all list data, all documents in document libraries, and other page content — is now stored in the Microsoft SQL Server computer You can choose between two configurations for Windows SharePoint Services: stand-alone server or server farm. There is a single server running Windows SharePoint Services. Multiple sites and subsites are grouped in site collections on each virtual server in IIS that is extended with Windows SharePoint Services. (InternetServerAPI) filter maps incoming Uniform Resource Locator (URL) to specific sites on that virtual server Scaling is achieved by adding site collections to an existing virtual server, or by adding subsites to an existing site collection Each virtual server has its own set of content database in SQL Server The configuration database directs each virtual server to the appropriate content database for a given Web site The content for the top-level Web site and any subsites within a site collection is stored in the same content database
20
SharePoint Web Services
Create a Windows Application In Visual Studio.Net, choose ‘Add Web Reference’ Enter to access the lists web service Other services include: Webs.asmx – Web information Views.asmx – View information Alerts.asmx – Alerts Admin.asmx – Administering Sites Permissions.asmx, UserGroups.asmx – Site permissions Versions.asmx – File Version Info Forms.asmx – Form information For more information please visit the following link In Windows SharePoint Services, site settings and information, along with all site content — such as all list data, all documents in document libraries, and other page content — is now stored in the Microsoft SQL Server computer You can choose between two configurations for Windows SharePoint Services: stand-alone server or server farm. There is a single server running Windows SharePoint Services. Multiple sites and subsites are grouped in site collections on each virtual server in IIS that is extended with Windows SharePoint Services. (InternetServerAPI) filter maps incoming Uniform Resource Locator (URL) to specific sites on that virtual server Scaling is achieved by adding site collections to an existing virtual server, or by adding subsites to an existing site collection Each virtual server has its own set of content database in SQL Server The configuration database directs each virtual server to the appropriate content database for a given Web site The content for the top-level Web site and any subsites within a site collection is stored in the same content database
21
Creating Site Collection
DEMO Creating Site Collection
22
Q&A
23
11/18/ :38 AM Resources 1. Fantastic “40” and Splendid “7” – 2. SharePoint Team blog – 3. My new book from Wrox of course! Pro SharePoint Development 4. Telerik’s RAD Editor for SharePoint (Free!) 5. MOSS SDK – 6. Codeplex – Some favorites – Smartpart Sharepoint Inspector, CAML Viewer 7. Dan Winter’s Blog - 8. SharePoint Designer Free Training!!!! 9. JoelO’s SharePointLand (Tons of admin content in Joel’s style!) – 10. All the SharePoint bloggers! Thank you all! © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
24
Resources Technical Chats and Webcasts
1. Technical Chats and Webcasts 2. Microsoft Learning and Certification 3. MSDN & TechNet 4. Technical Community Sites
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.