SlideShare a Scribd company logo
1 of 49
Consultant
Certification
Mohan Arumugam
Technologies Specialist
E-mail : moohanan@gmail.com
Phone : +91 99406 53876
Profile
Blogger
Trainer
Who Am I ?
• 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
• 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)
 Set web properties
 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!
• For content stored in WSS, only registered set of web custom
controls will run in pages
• Inline script in the page will not execute
 Code behind in pages can be made to work
• All Executable code (e.g. web custom controls, web parts, and
code-behind classes) needs to be installed on physical web server
• SharePoint Foundation(WSS)
 Site and Workspace Provisioning Engine
 Out-of-the-box Collaboration Services
• SharePoint Server
 User Profiles, Search, Workflows, WCM
 BCS, Excel Services, Forms Services, Access, ECM
SharePoint 2013 Foundation
Browser Clients
MS Word Clients
MS Outlook Clients
SharePoint 2013 Server
Windows Server 2008 R2 / Windows 2012
Internet Information Services 7.0 or Above
.NET Framework 4.5
• Farm-Trust Solutions
 Introduced in SharePoint 2007
 Hosted in the same process as SharePoint
 Full server-side SharePoint API access
• Sandbox Solutions
 For existing SharePoint 2010 solutions only
• SharePoint App Model
 Introduced in SharePoint 2013
 Provides for highest level of app isolation
 Much cleaner & simpler install & upgrade process
 Requires x64 operating system
 Windows Server 2008/2012
 Windows Server 2008R2/2013
 SharePoint 2010 must be installed locally
 SharePoint Foundation or SharePoint Server
 Visual Studio 2010/2012
 Additional software as required in the project
 Build a web part
 This is the best option to write code that functions are part of a WSS site or
solution
 There will be lots of documentation with the beta on how to build a web part.
 Web Part is reusable and can be managed using all of the web part tools and
UI.
 Build an ASPX page
 Code cannot live inline in a page within the site.
 Creating pages underneath the /_layouts directory is often the best option for
custom ASPX apps on top of SharePoint
 This lets your page be accessible from any web. For example, if you build mypage.aspx in
_Layouts, it is accessible from the following URLs:
 http://myweb/_layouts/myapp/mypage.aspx
 http://myweb/subweb1/_layouts/myapp/mypage.aspx
 ASPX page will run using the context of the web under which it is running.
 Windows Executable or any other application
 Object model can be called from pretty much any code context. It is not
limited to just web parts or ASP.Net
 For example, you could build a command-line utility to perform certain actions
 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.
 You should add references to the WSS
namespaces to your source files
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Administration;
…
 List Data
◦ SPField
◦ SPFieldCollection
◦ SPListCollection
◦ SPList
◦ SPListItemCollection
◦ SPListItem
◦ SPView
 Administration
◦ SPGlobalAdmin
◦ SPQuota
◦ SPVirtualServer
 Security
◦ SPGroup
◦ SPGroupCollection
◦ SPSite
◦ SPUser
◦ SPUserCollection
 Documents
◦ SPDocumentLibrary
◦ SPFile
◦ SPFileCollection
◦ SPFolder
SPFarm
SPService
SPWeb Application
SPSite
SPWeb
SPList
SPWeb
SPList
 SPFarm represents the highest-level object in the
hierarchy
 It is a class AND a global, static object
 SPFarm has no constructors
 Cannot be created or disposed
 Must be set to an existing static object
 SPFarm.Local provides the entry point to the current
farm
 SPFarm exposes properties, methods, and events that
affect farmwide settings
 For example:
DefaultServiceAccount, Servers, Services, Solutions, OnBackup, OnRestore, Upgrade
SPFarm thisFarm = SPFarm.Local;
if (thisFarm.CurrentUserIsAdministrator)
{
...
}
 SPService objects represent farmwide services
 For example: Forms Services, Access Services, PerformancePoint
Services, SharePoint Server Search Service, Excel Calculation Services, User
Profile Service, Business Data Connectivity Service, Managed Metadata
Services
 SPWebService is a type of SPService
 Each Web Application belongs to an SPWebServiceSPFarm thisFarm = SPFarm.Local;
if(thisFarm.CurrentUserIsAdministrator)
{
foreach (SPService svc in thisFarm.Services)
{
if (svc is SPWebService)
{
SPWebService webSvc = (SPWebService)svc;
...
}
}
}
 SPWebApplication objects map to IIS Web sites
 Not the same as a SharePoint Site or SharePoint Web
 Each SPWebApplication has its own Web.config
 Administrators typically create Web Applications
by using SharePoint Central Administration
 Developers can also create Web Applications by adding to the
WebApplications collection of a SPWebService object, but this is not a typical
action
 More typically, developers work with an existing SPWebApplication
 For example, to control Alert settings, create new site collections, or to
control maximum file size settings
 Developers can also delete Web Applications, but this is not a typical action
 Exercise caution
SPFarm thisFarm = SPFarm.Local;
if(thisFarm.CurrentUserIsAdministrator)
{
foreach(SPService svc in thisFarm.Services)
{
if(svc is SPWebService)
{
SPWebService webSvc = (SPWebService)svc;
foreach (SPWebApplication webApp in webSvc.WebApplications)
{
if (!webApp.IsAdministrationWebApplication)
{
...
}
}
}
}
}
 SPSite objects represent site collections
 Each SPSite has a RootWeb property (SPWeb)
 Typically a security boundary and a container for users, groups, rights, permissions
 SPSite objects can contain site-level features and
solutions
 Instantiate SPSite objects:
 By using its constructor
 As a member of the Sites collection of an SPWebApplication
 By referencing the current context site
 Different instantiation approaches require different
disposal strategies
...
foreach (SPSite site in webApp.Sites)
{
site.CatchAccessDeniedException = false;
try
{
...
site.CatchAccessDeniedException = false;
}
finally
{
site.Dispose();
}
}
SPSite remoteSite = new SPSite("http://sharepoint");
...
remoteSite.Dispose();
SPSite thisSite = SPContext.Current.Site;
...
// Do NOT dispose thisSite
 SPWeb objects represent SharePoint sites
 Can contain pages, lists, and libraries
 Can contain other objects (subwebs)
 Instantiating SPWeb objects:
 As the RootWeb property of an SPSite object
 As a member of the AllWebs collection of an SPSite object
 As the return value of the OpenWeb method of an SPSite object
 By referencing the current context Web
 Different instantiation approaches require different
disposal strategies
SPSite knownSite= new SPSite("http://sharepoint");
SPWeb knownWeb = knownSite.RootWeb;
SPWeb knownSubWeb = knownSite.OpenWeb("/projects");
...
knownSubWeb.Dispose();
knownWeb.Dispose();
knownSite.Dispose();
SPWeb thisWeb = SPContext.Current.Web;
...
// Do NOT dispose thisWeb
...
foreach (SPWeb childWeb in site.RootWeb.Webs)
{
try
{
...
}
finally
{
childWeb.Dispose();
}
}
 SPList objects are the primary container for data
 Native data
 Documents
 Images and other media
 Lookups
 SPList objects can be referenced as members of
the Lists collection from an SPWeb object
 Developers can create SPList objects by adding to the Lists collection
 SPList objects expose many properties that affect
list behaviors, such as versioning settings, content
type support, and visibility
...
foreach (SPSite site in webApp.Sites)
{
site.CatchAccessDeniedException = false;
try
{
foreach (SPWeb childWeb in site.RootWeb.Webs)
{
try
{
foreach (SPList list in childWeb.Lists)
{
if(!list.Hidden)
{
...
}
}
}
finally
{
childWeb.Dispose();
}
}
site.CatchAccessDeniedException = false;
}
finally
{
site.Dispose();
}
}
 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);
 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;
 If you only want a subset of the items, call the GetItems method and
pass a SPQuery object
SPListItemCollection items = mylist.GetItems(query);
 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());
}
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>");
}
 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();
 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();
 By default, the object model will not allow data updates if the form submitting the data
does not contain the „FormDigest‟ security key.
 FormDigest is based on username and site. It will time out after 30 minutes.
 Best solution is to include <FormDigest runat=“Server”/> web folder control in ASPX
page.
 If you do not need the security the FormDigest provides, you can set to
SPWeb.AllowUnsafeUpdates to bypass this check.
 Get the appropriate SPRole object:
SPRole admins = web.Roles["Administrator"];
 Call the AddUser method:
admins.AddUser("redmondgfoltz","Greg@hotmail.com","Greg Foltz","");
 If you create and destroy objects frequently, you may do extra SQL queries and have
code that is incorrect:
 Bad Example:
SPWeb web = SPControl.GetContextWeb(Context);
web.Lists["Tasks"].Title="mytitle";
web.Lists["Tasks"].Description="mydescription";
web.Lists["Tasks"].Update();
 Good Example:
SPWeb web = SPControl.GetContextWeb(Context);
SPList mylist = web.Lists["Tasks"];
mylist.Title="mytitle";
mylist.Description="mydescription";
mylist.Update();
 SharePoint will have web services APIs for accessing content. The
web services layer will be 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.
 Office11 (e.g. Excel, DataSheet, Work, Outlook, FrontPage, etc) use
web services to access data from WSS.
 GetListCollection
 GetListItems
 GetWebCollection
 UpdateList
 UpdateListItems
 GetWebInfo
 GetWebPart
 GetSmartPageDocument
 And more…
 Create a Windows Application
 In Visual Studio, choose „Add Web Reference‟
 Enter http://<server>/_vti_bin/lists.asmx to access the lists web service
 Other services include:
 UserGroups.asmx – users and groups
 Webs.asmx – Web information
 Views.asmx – View information
 Subscription.asmx – Subscriptions
 To send the logged on users‟ credentials from the
client, add the following line in the web reference
object‟s constructor:
public Lists() {
this.Url = "http://mikmort3/_vti_bin/lists.asmx";
this.Credentials=System.Net.CredentialCache.DefaultCredentials;
}
 We support events on document libraries.
 Operations such as add, update, delete, check-in, check-out, etc.
 Events are asynchronous
 Events call IListEventSink managed interface.
 Documentation and Sample in the SDK
 The biggest goal is to minimize the number of SQL queries.
 It may be helpful to use the SQL profiler to monitor what the OM is doing
underneath the covers
 Minimizing managed/unmanaged transitions also a goal, though this is
mostly taken care within the OM.
 Page Execution will no longer be driven by
CAML (XML schema used in SharePoint)
 CAML is still used in several places
 Field Type Definitions
 Site and List Templates
 View definitions
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)
{
SPWeb web = SPControl.GetContextWeb(Context);
SPWebCollection mywebs = web.Webs;
foreach (SPWeb myweb in mywebs)
{
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>");
}
}
}
}
private SPWeb web;
private void Page_Load(object sender, System.EventArgs e)
{
web = SPControl.GetContextWeb(Context);
}
private void Button1_Click(object sender, System.EventArgs e)
{
int maxsize = Convert.ToInt32(TextBox1.Text);
SPFolder myfolder=web.GetFolder("Shared Documents");
SPFileCollection myfiles = myfolder.Files;
foreach (SPFile file in myfiles)
{
if (file.Length>(maxsize*1024))
{
Response.Write(file.Name + ": " + file.Length/1024 + "kb<br>");
file.CopyTo("Archive/"+file.Name,true);
}
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
SPWeb web = SPControl.GetContextWeb(Context);
string username = TextBox1.Text;
string displayname = TextBox2.Text;
string email = TextBox3.Text;
SPRole admins = web.Roles["Administrator"];
try
{
admins.AddUser(username,email,displayname,"");
Label4.Text="Successfully added user";
}
catch(Exception ex)
{
Label4.Text=ex.ToString();
}
}
Mohan Arumugam
Technologies Specialist
E-mail : moohanan@gmail.com
Phone : +91 99406 53876
Profile
Thank You

More Related Content

What's hot

Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...SharePoint Saturday NY
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0Dima Maleev
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIRob Windsor
 
Integrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchIntegrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchRob Windsor
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questionsAkhil Mittal
 
Charla desarrollo de apps con sharepoint y office 365
Charla   desarrollo de apps con sharepoint y office 365Charla   desarrollo de apps con sharepoint y office 365
Charla desarrollo de apps con sharepoint y office 365Luis Valencia
 
Taking Advantage of the SharePoint 2013 REST API
Taking Advantage of the SharePoint 2013 REST APITaking Advantage of the SharePoint 2013 REST API
Taking Advantage of the SharePoint 2013 REST APIEric Shupps
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartSPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartJenkins NS
 
Are you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsAre you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsLiam Cleary [MVP]
 
Working With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps DevelopmentWorking With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps DevelopmentPankaj Srivastava
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
CMS Lessons Learned at Vassar by Megg Brown
CMS Lessons Learned at Vassar by Megg BrownCMS Lessons Learned at Vassar by Megg Brown
CMS Lessons Learned at Vassar by Megg Brownhannonhill
 

What's hot (19)

Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
 
Sharepoint Online
Sharepoint OnlineSharepoint Online
Sharepoint Online
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST API
 
Integrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchIntegrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio Lightswitch
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Microsoft Azure
Microsoft AzureMicrosoft Azure
Microsoft Azure
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
 
Charla desarrollo de apps con sharepoint y office 365
Charla   desarrollo de apps con sharepoint y office 365Charla   desarrollo de apps con sharepoint y office 365
Charla desarrollo de apps con sharepoint y office 365
 
Lect06 tomcat1
Lect06 tomcat1Lect06 tomcat1
Lect06 tomcat1
 
Taking Advantage of the SharePoint 2013 REST API
Taking Advantage of the SharePoint 2013 REST APITaking Advantage of the SharePoint 2013 REST API
Taking Advantage of the SharePoint 2013 REST API
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartSPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx Webpart
 
Are you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsAre you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint Apps
 
WSS And Share Point For Developers
WSS And Share Point For DevelopersWSS And Share Point For Developers
WSS And Share Point For Developers
 
Working With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps DevelopmentWorking With Sharepoint 2013 Apps Development
Working With Sharepoint 2013 Apps Development
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
CMS Lessons Learned at Vassar by Megg Brown
CMS Lessons Learned at Vassar by Megg BrownCMS Lessons Learned at Vassar by Megg Brown
CMS Lessons Learned at Vassar by Megg Brown
 

Similar to SharePoint Object Model, Web Services and Events

Wss Object Model
Wss Object ModelWss Object Model
Wss Object Modelmaddinapudi
 
SharePoint 2007 Presentation
SharePoint 2007 PresentationSharePoint 2007 Presentation
SharePoint 2007 PresentationAjay Jain
 
Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-codeNarayana Reddy
 
Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-codeNarayana Reddy
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 
Design and Development performance considerations
Design and Development performance considerationsDesign and Development performance considerations
Design and Development performance considerationsElaine Van Bergen
 
Stefaan Ponnet, Fusebox
Stefaan Ponnet, FuseboxStefaan Ponnet, Fusebox
Stefaan Ponnet, Fuseboxnascomgenk
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...SPTechCon
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
Introduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointIntroduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointRene Modery
 
Building fast track external facing sharepoint site
Building fast track external facing sharepoint siteBuilding fast track external facing sharepoint site
Building fast track external facing sharepoint siteManish Rawat
 
SharePoint Development For Asp Net Developers
SharePoint Development For Asp Net DevelopersSharePoint Development For Asp Net Developers
SharePoint Development For Asp Net DevelopersCorey Roth
 
Best Practices Configuring And Developing Share Point Solutions
Best Practices Configuring And Developing Share Point SolutionsBest Practices Configuring And Developing Share Point Solutions
Best Practices Configuring And Developing Share Point SolutionsAlexander Meijers
 
Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Mohan Arumugam
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperVinay Kumar
 
Share point development 101
Share point development 101Share point development 101
Share point development 101Becky Bertram
 
Monitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 ServerMonitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 ServerLearning SharePoint
 

Similar to SharePoint Object Model, Web Services and Events (20)

Wss Object Model
Wss Object ModelWss Object Model
Wss Object Model
 
Share Point Object Model
Share Point Object ModelShare Point Object Model
Share Point Object Model
 
SharePoint 2007 Presentation
SharePoint 2007 PresentationSharePoint 2007 Presentation
SharePoint 2007 Presentation
 
DEVICE CHANNELS
DEVICE CHANNELSDEVICE CHANNELS
DEVICE CHANNELS
 
Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-code
 
Share point 2010_overview-day4-code
Share point 2010_overview-day4-codeShare point 2010_overview-day4-code
Share point 2010_overview-day4-code
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
Design and Development performance considerations
Design and Development performance considerationsDesign and Development performance considerations
Design and Development performance considerations
 
Stefaan Ponnet, Fusebox
Stefaan Ponnet, FuseboxStefaan Ponnet, Fusebox
Stefaan Ponnet, Fusebox
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Introduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointIntroduction to using jQuery with SharePoint
Introduction to using jQuery with SharePoint
 
Building fast track external facing sharepoint site
Building fast track external facing sharepoint siteBuilding fast track external facing sharepoint site
Building fast track external facing sharepoint site
 
SharePoint Development For Asp Net Developers
SharePoint Development For Asp Net DevelopersSharePoint Development For Asp Net Developers
SharePoint Development For Asp Net Developers
 
Best Practices Configuring And Developing Share Point Solutions
Best Practices Configuring And Developing Share Point SolutionsBest Practices Configuring And Developing Share Point Solutions
Best Practices Configuring And Developing Share Point Solutions
 
Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paper
 
Session 1
Session 1Session 1
Session 1
 
Share point development 101
Share point development 101Share point development 101
Share point development 101
 
Monitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 ServerMonitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 Server
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

SharePoint Object Model, Web Services and Events

  • 1.
  • 2. Consultant Certification Mohan Arumugam Technologies Specialist E-mail : moohanan@gmail.com Phone : +91 99406 53876 Profile Blogger Trainer Who Am I ?
  • 3.
  • 4.
  • 5. • 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 • 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)  Set web properties  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!
  • 6. • For content stored in WSS, only registered set of web custom controls will run in pages • Inline script in the page will not execute  Code behind in pages can be made to work • All Executable code (e.g. web custom controls, web parts, and code-behind classes) needs to be installed on physical web server
  • 7. • SharePoint Foundation(WSS)  Site and Workspace Provisioning Engine  Out-of-the-box Collaboration Services • SharePoint Server  User Profiles, Search, Workflows, WCM  BCS, Excel Services, Forms Services, Access, ECM SharePoint 2013 Foundation Browser Clients MS Word Clients MS Outlook Clients SharePoint 2013 Server Windows Server 2008 R2 / Windows 2012 Internet Information Services 7.0 or Above .NET Framework 4.5
  • 8.
  • 9. • Farm-Trust Solutions  Introduced in SharePoint 2007  Hosted in the same process as SharePoint  Full server-side SharePoint API access • Sandbox Solutions  For existing SharePoint 2010 solutions only • SharePoint App Model  Introduced in SharePoint 2013  Provides for highest level of app isolation  Much cleaner & simpler install & upgrade process
  • 10.
  • 11.  Requires x64 operating system  Windows Server 2008/2012  Windows Server 2008R2/2013  SharePoint 2010 must be installed locally  SharePoint Foundation or SharePoint Server  Visual Studio 2010/2012  Additional software as required in the project
  • 12.  Build a web part  This is the best option to write code that functions are part of a WSS site or solution  There will be lots of documentation with the beta on how to build a web part.  Web Part is reusable and can be managed using all of the web part tools and UI.
  • 13.  Build an ASPX page  Code cannot live inline in a page within the site.  Creating pages underneath the /_layouts directory is often the best option for custom ASPX apps on top of SharePoint  This lets your page be accessible from any web. For example, if you build mypage.aspx in _Layouts, it is accessible from the following URLs:  http://myweb/_layouts/myapp/mypage.aspx  http://myweb/subweb1/_layouts/myapp/mypage.aspx  ASPX page will run using the context of the web under which it is running.
  • 14.  Windows Executable or any other application  Object model can be called from pretty much any code context. It is not limited to just web parts or ASP.Net  For example, you could build a command-line utility to perform certain actions
  • 15.  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.
  • 16.  You should add references to the WSS namespaces to your source files using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.Administration; …
  • 17.  List Data ◦ SPField ◦ SPFieldCollection ◦ SPListCollection ◦ SPList ◦ SPListItemCollection ◦ SPListItem ◦ SPView  Administration ◦ SPGlobalAdmin ◦ SPQuota ◦ SPVirtualServer  Security ◦ SPGroup ◦ SPGroupCollection ◦ SPSite ◦ SPUser ◦ SPUserCollection  Documents ◦ SPDocumentLibrary ◦ SPFile ◦ SPFileCollection ◦ SPFolder
  • 19.  SPFarm represents the highest-level object in the hierarchy  It is a class AND a global, static object  SPFarm has no constructors  Cannot be created or disposed  Must be set to an existing static object  SPFarm.Local provides the entry point to the current farm  SPFarm exposes properties, methods, and events that affect farmwide settings  For example: DefaultServiceAccount, Servers, Services, Solutions, OnBackup, OnRestore, Upgrade SPFarm thisFarm = SPFarm.Local; if (thisFarm.CurrentUserIsAdministrator) { ... }
  • 20.  SPService objects represent farmwide services  For example: Forms Services, Access Services, PerformancePoint Services, SharePoint Server Search Service, Excel Calculation Services, User Profile Service, Business Data Connectivity Service, Managed Metadata Services  SPWebService is a type of SPService  Each Web Application belongs to an SPWebServiceSPFarm thisFarm = SPFarm.Local; if(thisFarm.CurrentUserIsAdministrator) { foreach (SPService svc in thisFarm.Services) { if (svc is SPWebService) { SPWebService webSvc = (SPWebService)svc; ... } } }
  • 21.  SPWebApplication objects map to IIS Web sites  Not the same as a SharePoint Site or SharePoint Web  Each SPWebApplication has its own Web.config  Administrators typically create Web Applications by using SharePoint Central Administration  Developers can also create Web Applications by adding to the WebApplications collection of a SPWebService object, but this is not a typical action  More typically, developers work with an existing SPWebApplication  For example, to control Alert settings, create new site collections, or to control maximum file size settings  Developers can also delete Web Applications, but this is not a typical action  Exercise caution
  • 22. SPFarm thisFarm = SPFarm.Local; if(thisFarm.CurrentUserIsAdministrator) { foreach(SPService svc in thisFarm.Services) { if(svc is SPWebService) { SPWebService webSvc = (SPWebService)svc; foreach (SPWebApplication webApp in webSvc.WebApplications) { if (!webApp.IsAdministrationWebApplication) { ... } } } } }
  • 23.  SPSite objects represent site collections  Each SPSite has a RootWeb property (SPWeb)  Typically a security boundary and a container for users, groups, rights, permissions  SPSite objects can contain site-level features and solutions  Instantiate SPSite objects:  By using its constructor  As a member of the Sites collection of an SPWebApplication  By referencing the current context site  Different instantiation approaches require different disposal strategies
  • 24. ... foreach (SPSite site in webApp.Sites) { site.CatchAccessDeniedException = false; try { ... site.CatchAccessDeniedException = false; } finally { site.Dispose(); } } SPSite remoteSite = new SPSite("http://sharepoint"); ... remoteSite.Dispose(); SPSite thisSite = SPContext.Current.Site; ... // Do NOT dispose thisSite
  • 25.  SPWeb objects represent SharePoint sites  Can contain pages, lists, and libraries  Can contain other objects (subwebs)  Instantiating SPWeb objects:  As the RootWeb property of an SPSite object  As a member of the AllWebs collection of an SPSite object  As the return value of the OpenWeb method of an SPSite object  By referencing the current context Web  Different instantiation approaches require different disposal strategies
  • 26. SPSite knownSite= new SPSite("http://sharepoint"); SPWeb knownWeb = knownSite.RootWeb; SPWeb knownSubWeb = knownSite.OpenWeb("/projects"); ... knownSubWeb.Dispose(); knownWeb.Dispose(); knownSite.Dispose(); SPWeb thisWeb = SPContext.Current.Web; ... // Do NOT dispose thisWeb ... foreach (SPWeb childWeb in site.RootWeb.Webs) { try { ... } finally { childWeb.Dispose(); } }
  • 27.  SPList objects are the primary container for data  Native data  Documents  Images and other media  Lookups  SPList objects can be referenced as members of the Lists collection from an SPWeb object  Developers can create SPList objects by adding to the Lists collection  SPList objects expose many properties that affect list behaviors, such as versioning settings, content type support, and visibility
  • 28. ... foreach (SPSite site in webApp.Sites) { site.CatchAccessDeniedException = false; try { foreach (SPWeb childWeb in site.RootWeb.Webs) { try { foreach (SPList list in childWeb.Lists) { if(!list.Hidden) { ... } } } finally { childWeb.Dispose(); } } site.CatchAccessDeniedException = false; } finally { site.Dispose(); } }
  • 29.  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);
  • 30.  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;  If you only want a subset of the items, call the GetItems method and pass a SPQuery object SPListItemCollection items = mylist.GetItems(query);
  • 31.  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()); }
  • 32. 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>"); }
  • 33.  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();
  • 34.  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();
  • 35.  By default, the object model will not allow data updates if the form submitting the data does not contain the „FormDigest‟ security key.  FormDigest is based on username and site. It will time out after 30 minutes.  Best solution is to include <FormDigest runat=“Server”/> web folder control in ASPX page.  If you do not need the security the FormDigest provides, you can set to SPWeb.AllowUnsafeUpdates to bypass this check.
  • 36.  Get the appropriate SPRole object: SPRole admins = web.Roles["Administrator"];  Call the AddUser method: admins.AddUser("redmondgfoltz","Greg@hotmail.com","Greg Foltz","");
  • 37.  If you create and destroy objects frequently, you may do extra SQL queries and have code that is incorrect:  Bad Example: SPWeb web = SPControl.GetContextWeb(Context); web.Lists["Tasks"].Title="mytitle"; web.Lists["Tasks"].Description="mydescription"; web.Lists["Tasks"].Update();  Good Example: SPWeb web = SPControl.GetContextWeb(Context); SPList mylist = web.Lists["Tasks"]; mylist.Title="mytitle"; mylist.Description="mydescription"; mylist.Update();
  • 38.  SharePoint will have web services APIs for accessing content. The web services layer will be 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.  Office11 (e.g. Excel, DataSheet, Work, Outlook, FrontPage, etc) use web services to access data from WSS.
  • 39.  GetListCollection  GetListItems  GetWebCollection  UpdateList  UpdateListItems  GetWebInfo  GetWebPart  GetSmartPageDocument  And more…
  • 40.  Create a Windows Application  In Visual Studio, choose „Add Web Reference‟  Enter http://<server>/_vti_bin/lists.asmx to access the lists web service  Other services include:  UserGroups.asmx – users and groups  Webs.asmx – Web information  Views.asmx – View information  Subscription.asmx – Subscriptions
  • 41.  To send the logged on users‟ credentials from the client, add the following line in the web reference object‟s constructor: public Lists() { this.Url = "http://mikmort3/_vti_bin/lists.asmx"; this.Credentials=System.Net.CredentialCache.DefaultCredentials; }
  • 42.  We support events on document libraries.  Operations such as add, update, delete, check-in, check-out, etc.  Events are asynchronous  Events call IListEventSink managed interface.  Documentation and Sample in the SDK
  • 43.  The biggest goal is to minimize the number of SQL queries.  It may be helpful to use the SQL profiler to monitor what the OM is doing underneath the covers  Minimizing managed/unmanaged transitions also a goal, though this is mostly taken care within the OM.
  • 44.  Page Execution will no longer be driven by CAML (XML schema used in SharePoint)  CAML is still used in several places  Field Type Definitions  Site and List Templates  View definitions
  • 45. 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) { SPWeb web = SPControl.GetContextWeb(Context); SPWebCollection mywebs = web.Webs; foreach (SPWeb myweb in mywebs) { 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>"); } } } }
  • 46. private SPWeb web; private void Page_Load(object sender, System.EventArgs e) { web = SPControl.GetContextWeb(Context); } private void Button1_Click(object sender, System.EventArgs e) { int maxsize = Convert.ToInt32(TextBox1.Text); SPFolder myfolder=web.GetFolder("Shared Documents"); SPFileCollection myfiles = myfolder.Files; foreach (SPFile file in myfiles) { if (file.Length>(maxsize*1024)) { Response.Write(file.Name + ": " + file.Length/1024 + "kb<br>"); file.CopyTo("Archive/"+file.Name,true); } } }
  • 47. private void Button1_Click(object sender, System.EventArgs e) { SPWeb web = SPControl.GetContextWeb(Context); string username = TextBox1.Text; string displayname = TextBox2.Text; string email = TextBox3.Text; SPRole admins = web.Roles["Administrator"]; try { admins.AddUser(username,email,displayname,""); Label4.Text="Successfully added user"; } catch(Exception ex) { Label4.Text=ex.ToString(); } }
  • 48.
  • 49. Mohan Arumugam Technologies Specialist E-mail : moohanan@gmail.com Phone : +91 99406 53876 Profile Thank You