msg313: sharepoint ™ portal server top 10 programming tasks andrew datars program manager...

38
MSG313: MSG313: SharePoint SharePoint Portal Portal Server Server Top 10 Programming Top 10 Programming Tasks Tasks Andrew Datars Andrew Datars Program Manager Program Manager SharePoint Portal Server SharePoint Portal Server Microsoft Corporation Microsoft Corporation

Upload: blaze-lane

Post on 25-Dec-2015

231 views

Category:

Documents


2 download

TRANSCRIPT

MSG313: MSG313: SharePointSharePoint™™ Portal Server Portal Server Top 10 Programming TasksTop 10 Programming Tasks

Andrew DatarsAndrew DatarsProgram ManagerProgram ManagerSharePoint Portal ServerSharePoint Portal ServerMicrosoft CorporationMicrosoft Corporation

AgendaAgenda

OverviewOverview Top 10 Programming Tasks PreviewTop 10 Programming Tasks Preview Technical BackgroundTechnical Background Top 10 Programming TasksTop 10 Programming Tasks ResourcesResources

OverviewOverview

The flexible portal solution The flexible portal solution that lets you find, share that lets you find, share and publish information and publish information easily within business easily within business units and across units and across enterprisesenterprises Simplest access to Simplest access to

business informationbusiness information Integrated document Integrated document

management to unleash management to unleash portal productivityportal productivity

Easiest and most effective Easiest and most effective way to build and customize way to build and customize intranet portalsintranet portals

Top 10 Programming TasksTop 10 Programming Tasks

Issuing Full-Text Searches (More depth in Issuing Full-Text Searches (More depth in Search Programming presentation)Search Programming presentation)

Creating a web part (More depth in Web Part Creating a web part (More depth in Web Part presentation)presentation)

Document Management TasksDocument Management Tasks Creating CategoriesCreating Categories Creating Document Profiles and PropertiesCreating Document Profiles and Properties Creating and Configuring FoldersCreating and Configuring Folders Importing files from a file shareImporting files from a file share Reading and Setting Document PropertiesReading and Setting Document Properties Enumerating FoldersEnumerating Folders

Creating SubscriptionsCreating Subscriptions Extending SearchExtending Search

Technical BackgroundTechnical Background

TechnologiesTechnologies Workspace structureWorkspace structure URNs and URLsURNs and URLs BindingBinding Searching – ADO and XMLHTTPSearching – ADO and XMLHTTP

TechnologiesTechnologies

PKMCDO read/writePKMCDO read/write SharePoint Portal Server object model, ships only SharePoint Portal Server object model, ships only

with SharePoint Portal Serverwith SharePoint Portal Server Complementary to CDO for Exchange 2000Complementary to CDO for Exchange 2000 Leverages CDO / ADO binding modelLeverages CDO / ADO binding model

XMLHTTP read-onlyXMLHTTP read-only HTTP-DAV object model, part of platform SDKHTTP-DAV object model, part of platform SDK Exposes HTTP-DAV requests and responsesExposes HTTP-DAV requests and responses

ADO read-onlyADO read-only ActiveXActiveX®® data objects, part of platform SDK data objects, part of platform SDK Exposes database services (including queries)Exposes database services (including queries)

ADO Versus PKMCDOADO Versus PKMCDO

Use ADO for read-only tasksUse ADO for read-only tasks Reading file streams and propertiesReading file streams and properties Enumerating foldersEnumerating folders SearchingSearching

Use PKMCDO for read-write tasksUse PKMCDO for read-write tasks Creating and editing properties ofCreating and editing properties of

WorkspacesWorkspaces FoldersFolders DocumentsDocuments Etc.Etc.

Automating document managementAutomating document management

Both use same URL binding modelBoth use same URL binding model

ADO Versus XMLHTTPADO Versus XMLHTTP

Use ADO read-onlyUse ADO read-only Integrate with existing ADO appsIntegrate with existing ADO apps Bind to data controls that require ADOBind to data controls that require ADO Prefer to program with ADOPrefer to program with ADO

Use XMLHTTP read-onlyUse XMLHTTP read-only Bind directly to XML responseBind directly to XML response Use XSL to format resultsUse XSL to format results Control the size of the result setControl the size of the result set Prefer to program with XMLPrefer to program with XML

ADO Versus XMLHTTP ADO Versus XMLHTTP Architectural RelationshipArchitectural Relationship

Client AppClient AppClient AppClient App

OLE DB ProviderOLE DB Provider(MSDAIPP)(MSDAIPP)

OLE DB ProviderOLE DB Provider(MSDAIPP)(MSDAIPP)

DASLDASLListenerListenerDASLDASL

ListenerListener

Web Web StoreStoreWeb Web StoreStore

ContentContentSourceSourceContentContentSourceSource

ADOADOADOADO

ASP or Web PartASP or Web PartASP or Web PartASP or Web Part

WebDAV WebDAV SEARCHSEARCH

ADO CommandADO Command

OLE DB OLE DB CommandCommand

RecordsetRecordset

RowsetRowset

WebDAV WebDAV SEARCHSEARCH

WebDAV WebDAV SEARCHSEARCH

XML XML ResultsResults

XML XML ResultsResults

XML XML ResultsResults

Workspace StructureWorkspace Structure

Workspace Root (http://server/wksp)Workspace Root (http://server/wksp) Interesting for this talkInteresting for this talk

CategoriesCategories DocumentsDocuments SystemSystem

Interesting, but not for this talkInteresting, but not for this talk PortalPortal Portal ContentPortal Content SHADOWSHADOW

Wholly uninterestingWholly uninteresting System categoriesSystem categories ManagementManagement _TEMP__TEMP_ LOCKSLOCKS

URNs And URLsURNs And URLs

URN is a name (“Andrew”)URN is a name (“Andrew”) Used to identify properties and profilesUsed to identify properties and profiles More precise than a friendly nameMore precise than a friendly name Has a namespaceHas a namespace ExampleExample

urn:schemas-microsoft-com:office:office#Milestoneurn:schemas-microsoft-com:office:office#Milestone

URL is a place (“Atlanta, GA”)URL is a place (“Atlanta, GA”) Used to identify a locationUsed to identify a location Does not have a namespace, but is hierarchicalDoes not have a namespace, but is hierarchical ExampleExample

http://tahoeweb/tahoe/system/schema/Milestone.pdefhttp://tahoeweb/tahoe/system/schema/Milestone.pdef

BindingBinding

Binding connects an object with a physical Binding connects an object with a physical storage elementstorage element KnowledgeFolder => FolderKnowledgeFolder => Folder KnowledgeContentClass => Document ProfileKnowledgeContentClass => Document Profile KnowledgeCategoryFolder => CategoryKnowledgeCategoryFolder => Category Etc.Etc.

URL is the connective glueURL is the connective glueDim oFolder as New PKMCDO.KnowledgeFolderDim oFolder as New PKMCDO.KnowledgeFolder

oFolder.DataSource.Open oFolder.DataSource.Open http://server/wksp/myfolderhttp://server/wksp/myfolder

Programming Task:Programming Task:Issuing Full Text SearchesIssuing Full Text Searches User ScenarioUser Scenario

I want to return a list of all documents I want to return a list of all documents written by Sherri Hart with the word written by Sherri Hart with the word “thermafill” in the document “thermafill” in the document

Special Item to NoteSpecial Item to Note Searches only return published documentsSearches only return published documents

Searching With XMLHTTPSearching With XMLHTTP

Uses XMLHTTPRequest objectUses XMLHTTPRequest object Client or server solutionClient or server solution

Use ServerXMLHTTP for server side callsUse ServerXMLHTTP for server side calls Use XMLHTTP for client callsUse XMLHTTP for client calls

Custom SEARCH verbCustom SEARCH verb Results returned in XMLResults returned in XML Custom header controls number and Custom header controls number and

paging of resultspaging of results Used by Dashboard web siteUsed by Dashboard web site

Search Example – XMLHTTPSearch Example – XMLHTTP

Dim strQuery As StringDim strQuery As StringDim xh As New XMLHTTPRequestDim xh As New XMLHTTPRequest

xh.open "SEARCH", strWorkspaceUrl, Falsexh.open "SEARCH", strWorkspaceUrl, Falsexh.setRequestHeader "content-type", xh.setRequestHeader "content-type",

“text/xml”“text/xml”

xh.send strQueryxh.send strQuery

xh.responseXML.save "sample1.xml"xh.responseXML.save "sample1.xml"

Dim strQuery As StringDim strQuery As StringDim xh As New XMLHTTPRequestDim xh As New XMLHTTPRequest

xh.open "SEARCH", strWorkspaceUrl, Falsexh.open "SEARCH", strWorkspaceUrl, Falsexh.setRequestHeader "content-type", xh.setRequestHeader "content-type",

“text/xml”“text/xml”

xh.send strQueryxh.send strQuery

xh.responseXML.save "sample1.xml"xh.responseXML.save "sample1.xml"

Search Example – Query Search Example – Query StringString<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>

<a:searchrequest xmlns:a="DAV:"><a:searchrequest xmlns:a="DAV:">

<a:sql><a:sql>

SELECT "DAV:displayname"SELECT "DAV:displayname"

FROM Scope('deep traversal of FROM Scope('deep traversal of "/wksp"')"/wksp"')

WHERE "urn:schemas-microsoft-WHERE "urn:schemas-microsoft-com:office:office#Author" = 'Sherri Hart'com:office:office#Author" = 'Sherri Hart'

AND FREETEXT('thermafill')AND FREETEXT('thermafill')

</a:sql></a:sql>

</a:searchrequest></a:searchrequest>

<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>

<a:searchrequest xmlns:a="DAV:"><a:searchrequest xmlns:a="DAV:">

<a:sql><a:sql>

SELECT "DAV:displayname"SELECT "DAV:displayname"

FROM Scope('deep traversal of FROM Scope('deep traversal of "/wksp"')"/wksp"')

WHERE "urn:schemas-microsoft-WHERE "urn:schemas-microsoft-com:office:office#Author" = 'Sherri Hart'com:office:office#Author" = 'Sherri Hart'

AND FREETEXT('thermafill')AND FREETEXT('thermafill')

</a:sql></a:sql>

</a:searchrequest></a:searchrequest>

Programming Task:Programming Task:Create Web PartCreate Web Part

User ScenarioUser Scenario I want to create a Web Part to display HTML I want to create a Web Part to display HTML

contentcontent

Create Web PartCreate Web Part

Create new WebPart with UICreate new WebPart with UI Edit contentEdit content

Add HTML/VBScript contentAdd HTML/VBScript content

VBScript:VBScript:Function getContent(xmlPart)Function getContent(xmlPart)getContent = getContent = ““<font color= blue><font color= blue>Hello WorldHello World</font>”</font>”End FunctionEnd Function

HTML:HTML:<Font color = blue><Font color = blue>Hello World Hello World </Font></Font>

Programming Task:Programming Task:Creating CategoriesCreating Categories

ScenarioScenario I want to create a place on my server where I want to create a place on my server where

I can organize some or all of my I can organize some or all of my documents in a category called Budget documents in a category called Budget with a subcategory called FY01with a subcategory called FY01

Creating CategoriesCreating Categories

Dim oF as New PKMCDO.KnowledgeCategoryFolderDim oF as New PKMCDO.KnowledgeCategoryFolder

oF.Category = “:Budgets:FY01”oF.Category = “:Budgets:FY01”

oF.Datasource.SaveoF.Datasource.Save

Programming TaskProgramming TaskCreating Document ProfilesCreating Document Profiles

ScenarioScenario I want to create a document profile I want to create a document profile

called “Specification”called “Specification”

Creating Document ProfilesCreating Document Profiles

Dim oCC as New PKMCDO.KnowledgeContentClassDim oCC as New PKMCDO.KnowledgeContentClass

oCC.Name = “urn:content-oCC.Name = “urn:content-classes:Specification”classes:Specification”

oCC.AddPropertyDef(“Title”)oCC.AddPropertyDef(“Title”)

oCC.AddPropertyDef(“Author”)oCC.AddPropertyDef(“Author”)

oCC.AddPropertyDef(“Milestone”)oCC.AddPropertyDef(“Milestone”)

oCC.DataSource.SaveoCC.DataSource.Save

Programming TaskProgramming TaskCreating And Configuring FoldersCreating And Configuring Folders

User ScenarioUser Scenario I want to create a folder called I want to create a folder called

“myfolder” in my Documents directory “myfolder” in my Documents directory and set access to the folderand set access to the folder

Creating And Creating And Configuring FoldersConfiguring FoldersDim oF as New PKMCDO.KnowledgeFolderDim oF as New PKMCDO.KnowledgeFolderoF.Contentclass = “urn:content-oF.Contentclass = “urn:content-classes:myfolder”classes:myfolder”

oF.Authors=Array(“DOMAIN\johndoe”)oF.Authors=Array(“DOMAIN\johndoe”)oF.Readers=Array(“DOMAIN\jackdoe”)oF.Readers=Array(“DOMAIN\jackdoe”)oF.Approvers=Array(“DOMAIN\johndoe”, oF.Approvers=Array(“DOMAIN\johndoe”, “DOMAIN\janedoe”)“DOMAIN\janedoe”)

oF.Coordinators=Array(“DOMAIN\jilldoe”, oF.Coordinators=Array(“DOMAIN\jilldoe”, “DOMAIN\janedoe”)“DOMAIN\janedoe”)

oF.Datasource.SaveTo oF.Datasource.SaveTo "http://server/wksp/Documents/myfolder""http://server/wksp/Documents/myfolder"

Programming TaskProgramming TaskImporting FilesImporting Files

User ScenarioUser Scenario I want to copy a file on my harddrive called I want to copy a file on my harddrive called

C:\test.txt to my “myfolder” folder on my C:\test.txt to my “myfolder” folder on my SharePoint Portal Server and overwrite it if SharePoint Portal Server and overwrite it if the file already exists on the serverthe file already exists on the server

Importing FilesImporting Files

Dim objDoc as New PKMCDO.KnowledgeDocumentDim objDoc as New PKMCDO.KnowledgeDocument

objDoc.ContentClass = “urn:content-objDoc.ContentClass = “urn:content-classes:BaseDocument”classes:BaseDocument”

Set objStream = objDoc.OpenStreamSet objStream = objDoc.OpenStream

objStream.Type = adTypeBinaryobjStream.Type = adTypeBinary

objStream.SetEOSobjStream.SetEOS

objStream.LoadFromFile “C:\test.txt”objStream.LoadFromFile “C:\test.txt”

objStream.FlushobjStream.Flush

Set objStream = NothingSet objStream = Nothing

objDoc.DataSource.SaveTo _ objDoc.DataSource.SaveTo _ “http://server/wksp/Documents/myfolder/tes“http://server/wksp/Documents/myfolder/test.txt”, , , adCreateOverwrite t.txt”, , , adCreateOverwrite

Programming TaskProgramming TaskReading and Setting PropertiesReading and Setting Properties

User ScenarioUser Scenario I want to assign a document to my Budget I want to assign a document to my Budget

category in my FY01 subcategorycategory in my FY01 subcategory

Manipulating PropertiesManipulating Properties

Dim oDoc as New PKMCDO.KnowledgeDocumentDim oDoc as New PKMCDO.KnowledgeDocument

oDoc.DataSource.Open oDoc.DataSource.Open “http://server/wksp/myfolder/mydoc.doc”“http://server/wksp/myfolder/mydoc.doc”

Debug.Print oDoc.BestBetKeywordsDebug.Print oDoc.BestBetKeywords

Debug.Print oDoc.BestBetCategoriesDebug.Print oDoc.BestBetCategories

Debug.Print oDoc.CategoriesDebug.Print oDoc.Categories

Debug.Print oDoc.TitleDebug.Print oDoc.Title

Debug.Print oDoc.DescriptionDebug.Print oDoc.Description

oDoc.Categories = Array(“:Budgets:FY01”) oDoc.Categories = Array(“:Budgets:FY01”)

oDoc.DataSource.SaveoDoc.DataSource.Save

Programming Task:Programming Task:Publishing And Publishing And Versioning DocumentsVersioning Documents User ScenarioUser Scenario

I want to check-out, modify and check-in a I want to check-out, modify and check-in a document and then see the version historydocument and then see the version history

Special Item to NoteSpecial Item to Note If you get access denied on Save/SaveTo, If you get access denied on Save/SaveTo,

make sure you’ve bound to the make sure you’ve bound to the working copyworking copy

Publishing And Publishing And Versioning DocumentsVersioning DocumentsDim oVersion as New PKMCDO.KnowledgeVersionDim oVersion as New PKMCDO.KnowledgeVersion

Dim sPath as StringDim sPath as String

sPath = sPath = “http://server/wksp/Documents/myfolder/my.“http://server/wksp/Documents/myfolder/my.doc”doc”

Dim oRS as ADODB.RecordsetDim oRS as ADODB.Recordset

Set oRS = oVersion.Checkout(sPath)Set oRS = oVersion.Checkout(sPath)

---Modify the Document------Modify the Document---

Set oRS = oVersion.Checkin(sPath)Set oRS = oVersion.Checkin(sPath)

Set oRS = oVersion.VersionHistory(sPath)Set oRS = oVersion.VersionHistory(sPath)

Programming TaskProgramming TaskEnumerating FoldersEnumerating Folders

User ScenarioUser Scenario I want to get a list of all of the subfolders I want to get a list of all of the subfolders

and files in my “myfolder” folder and files in my “myfolder” folder

Enumerating FoldersEnumerating Folders

Dim oF as New PKMCDO.KnowledgeFolderDim oF as New PKMCDO.KnowledgeFolderDim oRS as ADODB.RecordsetDim oRS as ADODB.RecordsetoFolder.DataSource.Open oFolder.DataSource.Open “http://server/wksp/Documents/myfolder”“http://server/wksp/Documents/myfolder”

Set oRS = oF.SubfoldersSet oRS = oF.SubfoldersWhile Not oRS.EOFWhile Not oRS.EOFDebug.Print oRS.Fields("DAV:href")Debug.Print oRS.Fields("DAV:href")oRS.MoveNextoRS.MoveNext

WendWendSet oRS = oF.ItemsSet oRS = oF.ItemsWhile Not oRS.EOFWhile Not oRS.EOFDebug.Print oRS.Fields("DAV:href")Debug.Print oRS.Fields("DAV:href")oRS.MoveNextoRS.MoveNext

Wend Wend

Programming TaskProgramming TaskCreating SubscriptionsCreating Subscriptions

User ScenarioUser Scenario I want to be notified when documents are I want to be notified when documents are

published to the “myfolder” folderpublished to the “myfolder” folder

Special Item to NoteSpecial Item to Note If you want to be notified when documents If you want to be notified when documents

are checked-in or checked-out, you will are checked-in or checked-out, you will need to poll for this using VersionStatus on need to poll for this using VersionStatus on all documentsall documents

Managing SubscriptionsManaging Subscriptions

Dim oSubMgr as New Dim oSubMgr as New PKMCDO.SubscriptionManagerPKMCDO.SubscriptionManager

strSubscriptionUrl = strSubscriptionUrl = oSubMgr.CreateSubscription(oSubMgr.CreateSubscription(““http://server/wksp/Documents/myfolder”,http://server/wksp/Documents/myfolder”,

strQuery,strQuery,NType,NType,1,1,““[email protected]”,[email protected]”,strQuery,strQuery,32767,32767,"") "")

ResourcesResources

SharePoint Portal Server Web SiteSharePoint Portal Server Web Sitehttp://www.microsoft.com/Servers/Sharepoint/http://www.microsoft.com/Servers/Sharepoint/

SharePoint News GroupsSharePoint News Groupshttp://www.microsoft.com/servers/sharepoint/http://www.microsoft.com/servers/sharepoint/newsgroup.htmnewsgroup.htm

Digital Dashboard Web SiteDigital Dashboard Web Sitehttp://www.microsoft.com/digitaldashboardhttp://www.microsoft.com/digitaldashboard

MicrosoftMicrosoft®® Training and Certification Training and Certificationhttp://www.microsoft.com/trainingandservices/http://www.microsoft.com/trainingandservices/default.aspdefault.asp

ResourcesResources

MSDNMSDN SharePoint Portal Server 2001 as a Collaborative SharePoint Portal Server 2001 as a Collaborative

Solutions PlatformSolutions Platformhttp://msdn.microsoft.com/library/techart/tahoe.htmhttp://msdn.microsoft.com/library/techart/tahoe.htm

SharePoint Portal Server – Document Management SharePoint Portal Server – Document Management and Much Moreand Much Morehttp://msdn.microsoft.com/library/periodic/period00/http://msdn.microsoft.com/library/periodic/period00/MSTahoe.htmMSTahoe.htm

PartnersPartners Digital Dashboard Solution ProvidersDigital Dashboard Solution Providers

http://www.microsoft.com/business/digitaldashboard/http://www.microsoft.com/business/digitaldashboard/ddpartners.aspddpartners.asp

Microsoft Direct AccessMicrosoft Direct Accesshttp://www.microsoft.com/directaccesshttp://www.microsoft.com/directaccess