June 4-8 Orlando

bubblemessengerΑσφάλεια

5 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

91 εμφανίσεις

June 4
-
8 Orlando

OFC330

WSS Object Model Fundamentals

Working Remotely with Lists and Document Libraries

Cross
-
Site Data Queries

Exploring New WSS Classes

Event Handlers

WSS

3.0

MOSS 2007

Microsoft.SharePoint.dll

Microsoft
.Office.Server.dll

Microsoft.Office.Server.Publishing.dll

Microsoft.Office.Server.Policy.dll

Microsoft.Office.Server.Search.dll

Microsoft.SharePoint.Portal.dll

Microsoft.Office.Workflow.Tasks.dll

Microsoft.SharePoint.Publishing.dll

Microsoft.SharePoint.Workflow.Actions.dll

There
is

also

the .NET
Reflector

on www.aisto.com/roeder

Download the SDK!!!!

WSS Sites

WSS Object Model

Web Parts

Web Pages

Smart Clients

Smart and

Mobile Clients

Web Services

Web Parts

ASP.NET Custom Controls
and User Controls

Application pages

Feature activation event
handlers

Event handlers for lists,
doc
libs
, sites & site
collections

ASP.NET applications and
Web services

Windows Forms and
Console applications

High

Backward

Compatibility

With

WSS v2


Some

classes

are
obsolote


-
SPGlobalConfig

-
SPVirtualServer

SPWebServer

SPWebApplication

SPSite

SPWeb

SPList

SPListItem

SPFarm

Represents site collection

User must be authenticated and authorized

unless anonymous access is enabled

Site Collection has an owner

Site Collection contains hierarchy of child site


Sites accessible through
SPWeb

objects

Often must use
SPSite

object to access
SPWeb

objects

Many WSS OM objects follow
IDisposable

pattern

They use unmanaged resources that must be released

Failure to call Dispose can cause serious memory leakage

Lists are modeled using SPList objects

Items modeled using SPListItem objects

Document libraries can be accessed using SPList

Site represents hierarchy of files and folders

Files represented through
SPFile

objects

Folders represented through
SPFolder

objects






What can be done?

Discover all files and folders within a site

Add, move, copy, delete files and folders

Return a page to its initial ghosted state

Program against Web Part data on a Web Part Page

Document Library is more than a
SPList

object

Can convert
SPList

to
SPDocumentLibrary

Make extra functionality accessible

Impersonating

using

the
SPSite

constructor

Elevating

Privileges

The
ISecurableObject

Interface





Don’t

forget
:

Test
your

Web Parts
with


the least
security

permissions!


Web Part code is executed with the account of the logged
-
on user

Impersonation done by SharePoint

Handle this elegantly!

Constructor of SPSite accepts now an SPUserToken used
to impersonate a specific user

Tokens time out after 24 hours

Web Part requires SharePointPermission with Impersonate
option

Some aspects of WSS OM require privileged users

Run your code with the SharePoint
\
System account

Use with care! The behavior has been created by design (not a mistake!)

SPSecurity.RunWithElevatedPrivileges

solves many problems

Web Parts must have the ‘SharePointPermission’ to execute this code

Seal your Web Part!

Everybody doing security implements this interface

SPWeb, SPList, SPListItem


CAML = Collaborative Application
Markup

Language

Used in SharePoint for

Definition of the Sites, Lists and Views

Querying of SharePoint content


Executing CAML Queries

SPQuery

SPSiteDataQuery

Lists.asmx

Remotely view and edit SharePoint List data

http://[server]/_vti_bin/Lists.asmx

Operations available:








Work with Document Libraries using FrontPage RPC


AddAttachment


UpdateList


DeleteList


UpdateListItems


GetAttachmentCollection


AddList


GetListItemChanges


GetListAndView


GetList


GetListCollection


GetListItems


DeleteAttachment


What is an event handlers?

An event handler is a .NET assembly containing one or more classes
handling events that are triggered by SharePoint

WSS v2

only possible for document libraries

executed in an asynchronous manner

WSS v3 events architecture significantly improved

Scope has been extended: lists, document libraries, content types, site, site
collection

Events supported for incoming email messages

Support for synchronous events and asynchronous events

Synchronous events occur before the fact and are cancel
-
able

Events are used in other scenarios

Custom policies

Features

Scope

Description

Base Class

Item in a list or
library

Actions users can do in a list include
adding, modifying, deleting, check
-
in and
check
-
out, ...

SPItemEventReceiver

List or library

Trap changes to entities of list schema
events, supporting list schema operations
and the addition or removal of content
types.

SPListEventReceiver

Web

Events fired at the level of the site (e.g.
adding and removing sites, creating and
deleting lists)

SPWebEventReceiver

Email

Provides a method for trapping the event
when a list receives an e
-
mail message

(
EmailReceived
)

SPEmailEventReceiver

Feature

Trap the activation, deactivation,
installation, or
uninstallation

of a Feature

SPFeatureReceiver

.NET class library

Reference to Microsoft.SharePoint.dll

Custom class inheriting a WSS receiver class

Override base methods

using Microsoft.SharePoint;

namespace Demos {


public class MyEventHandler:
SPItemEventReceiver

{



public override void
ItemDeleting(SPItemEventProperties properties)

{


// do something and possibly cancel the event


properties.Cancel = true;


properties.ErrorMessage = “my message";


}



public override void
ItemDeleted(
SPItemEventProperties properties)

{


// do something


}


}

}

Compile class into strong
-
named assembly

Deploy the DLL in GAC


Register DLL as event handler in WSS v3


The WSS v2 way (only for document libraries)

Programmatically via the object model

Using the new WSS feature framework


Navigation

Content Types

Recycle Bin

Versioning

Workflow


WSS Navigation is extensible

Add nodes through WSS UI

Adds nodes through code


SPContentTypeCollection

SPContentType

SPContentTypeId

SPFieldLinkCollection

SPFieldLink

SPXmlDocumentCollection


WSS provides rich auditing support

But doesn't make auditing usable OOB
-

you need MOSS

Custom development required to make WSS auditing functional

enable auditing using code




now examine what's in WSS audit log


WSS exposes a
very

rich

object

model

Don’t

forget

to clean up
your

WSS v2 code a bit

And do call Dispose()

Many

improvements

have been
done

to
remove

the
many

issues
regarding

security

and SharePoint
programming

Impersonation

is

more
elegant

Common interface for
objects

that

support
ACL’s

Web Services are
your

way

of
getting

acces

to SharePoint
remotely

Event
handlers

are
now

a major
extensibility

option

Many

many

new classes .. And
wait

‘till
you’ve

seen

the
MOSS
object

models

Breakout Sessions

Session Codes and Titles

Chalk
-
Talks

Session Codes and Titles

Instructor
-
led Labs

Session Codes and Titles

Hands
-
on Labs

Hands
-
on Lab Codes and Titles

Technical Communities,
Webcasts
,
Blogs
, Chats & User Groups

http://www.microsoft.com/communities/
default.mspx


Microsoft Developer Network (MSDN) & TechNet

http://microsoft.com/
msdn


http://microsoft.com/
technet


Trial Software and Virtual Labs

http://www.microsoft.com/
technet/downloads/trials/default.mspx


Microsoft Learning and Certification

http://www.microsoft.com/learning/
default.mspx


Required slide

Complete an
evaluation on
CommNet

and

enter to win!

Required slide

©
2007 Microsoft
Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademar
ks
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
dat
e 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 accu
rac
y 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.