Fabio Santini.NET Senior Developer Evangelist. 2 SharePoint Customizzazione 4 principali modalità 4 principali modalità Componenti (Web Parts e Event.

Post on 01-May-2015

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Fabio SantiniFabio Santini.NET Senior Developer Evangelist.NET Senior Developer Evangelist

2

SharePoint CustomizzazioneSharePoint Customizzazione

4 principali modalità4 principali modalità Componenti (Web Parts e Event Handler)Componenti (Web Parts e Event Handler) Custom TemplatesCustom Templates Site DefinitionsSite Definitions Web ServicesWeb Services

Web PartsWeb Parts

4

"Hello World""Hello World" Creare una classe che…Creare una classe che…

Eredita da Eredita da Microsoft.SharePoint.WebPartPages.WebPartMicrosoft.SharePoint.WebPartPages.WebPart Overrides del metodo Overrides del metodo RenderWebPartRenderWebPart Utilizza Utilizza HtmlTextWriterHtmlTextWriterusing Microsoft.SharePoint.WebPartPages;

using System.Web.UI;

namespace AcmeWebParts { public class WebPart1 : WebPart { protected override void RenderWebPart(HtmlTextWriter output) { output.Write("Hello, World"); } }}

5

Assembly DeploymentAssembly Deployment Copiare l’assembly nella cartella Copiare l’assembly nella cartella \bin\bin del del

virtual server rootvirtual server root Solo in ambiente di sviluppoSolo in ambiente di sviluppo

Global Assembly Cache (GAC)Global Assembly Cache (GAC) Raccomandata in ambiente di produzioneRaccomandata in ambiente di produzione

6

Web Parts come Safe ControlsWeb Parts come Safe Controls Web Parts sono eseguite dall’engine di Web Parts sono eseguite dall’engine di

SharePointSharePoint Web Part vengono eseguite in Safe ModeWeb Part vengono eseguite in Safe Mode

Sottosistema di security integrato in WSSSottosistema di security integrato in WSS L’amministratore DEVE mL’amministratore DEVE modificare il web.config per abilitare odificare il web.config per abilitare

una nuova Web Partuna nuova Web Part<!– web.config in root directory of hosting virtual server -->

<configuration> <SharePoint> <SafeControls> <SafeControl Assembly="AcmeWebParts" Namespace="AcmeWebParts" TypeName="*" Safe="True" /> </SafeControls> </SharePoint></configuration>

7

Web Parts e CASWeb Parts e CAS Le Le Web Parts nella GAC sono considerate fidate dalla CASWeb Parts nella GAC sono considerate fidate dalla CAS Web Parts nella \bin sono eseguite in sandboxWeb Parts nella \bin sono eseguite in sandbox

Sandbox controllata dalla Code Access Security .Net (CAS)Sandbox controllata dalla Code Access Security .Net (CAS) Sandbox configurata nell’elemento Sandbox configurata nell’elemento <trust><trust> del web.config del web.config 3 Livelli di sicurezza3 Livelli di sicurezza

1) WSS_Minimum (default)1) WSS_Minimum (default) 2) WSS_Medium2) WSS_Medium 3) Full3) Full

<!– web.config in root directory of hosting virtual server -->

<configuration> </system.web> <!-- <trust level="WSS_Minimal" originUrl="" /> --> <trust level="WSS_Medium" originUrl="" />

</system.web></configuration>

8

Importare Web PartImportare Web Part Dal menù Dal menù Modify Shared Web PageModify Shared Web Page

Scegliere Scegliere Add Web PartAdd Web Part >> >> ImportImport

9

Debugging di una Web PartDebugging di una Web Part Attach sul worker process di SharePoint Attach sul worker process di SharePoint

(w3wp.exe)(w3wp.exe) importare i break points in Visual Studio .NETimportare i break points in Visual Studio .NET

10

Custom PropertiesCustom Properties Le proprietà sono aggiunte alla definizione della Web PartLe proprietà sono aggiunte alla definizione della Web Part

sono usate per memorizzare informazioni sono usate per memorizzare informazioni hanno un valore di defaulthanno un valore di default possono essere modificate direttamente dal designer di Web possono essere modificate direttamente dal designer di Web

Part in SharepointPart in Sharepoint vengono persisite in due modi : shared o per-uservengono persisite in due modi : shared o per-user

[ XmlRoot(Namespace="AcmeWebParts") ]public class WeatherReportWebPart : WebPart {

protected string _ZipCode = string.Empty;

[ WebPartStorage(Storage.Personal), DefaultValue(""), Browsable(true), FriendlyName("Zip Code"), Category("Acme Custom Props") ] public string ZipCode { get { return _ZipCode; } set { _ZipCode = value; } } }}

11

Impostare le Custom PropertiesImpostare le Custom Properties L’utente può modificare le custom L’utente può modificare le custom

propertyproperty WSS fornisce un interfaccia all’interno del WSS fornisce un interfaccia all’interno del

browserbrowser L’interfaccia può essere estesa scrivendo dei L’interfaccia può essere estesa scrivendo dei

custom toolcustom tool

12

File .DWPFile .DWP Contiene i metadati necessari alla configurazioneContiene i metadati necessari alla configurazione

<?xml version="1.0" encoding="utf-8"?><WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" >

<!– required web part properties --> <Title>First AcmeCorp WebPart</Title> <Description>AcmeCorp's very first Web Part</Description> <Assembly>AcmeWebParts</Assembly> <TypeName>AcmeWebParts.WebPart1</TypeName>

<!– extended web part properties --> <Zipcode xmlns="AcmeWebParts">98052</ZipCode>

</WebPart>

Event HandlerEvent Handler

14

Document Library Events (1)Document Library Events (1)

Posso essere avvertito quando cambia Posso essere avvertito quando cambia un documento in WSS?un documento in WSS?

Creare un Assembly .NETCreare un Assembly .NET Implementare Implementare IListEventSink IListEventSink Registrare nella Global Assembly Cache (GAC)Registrare nella Global Assembly Cache (GAC)

In WSSIn WSS Abilitare la notifica degli eventi a livello di serverAbilitare la notifica degli eventi a livello di server Configurare la Document Library per inviare le notifiche al Configurare la Document Library per inviare le notifiche al

nostro assemblynostro assembly Specificare il fully qualified nameSpecificare il fully qualified name

15

Document Library Events (2)Document Library Events (2)

IListEventSink InterfaceIListEventSink Interface OnEvent method al cambiamento di un docOnEvent method al cambiamento di un doc Gli eventi sono asincroni EventsGli eventi sono asincroni Events No delegates / callbacksNo delegates / callbacks

NotificheNotifiche

Edited Edited Moved Moved Renamed Renamed UploadedUploaded

Checked in Checked in Checked out Checked out Check-out cancelled Check-out cancelled Copied Copied DeletedDeleted

16

Object ModelObject Model List DataList Data

SPFieldSPField SPFieldCollectionSPFieldCollection SPListCollectionSPListCollection SPListSPList SPListItemCollectionSPListItemCollection SPListItemSPListItem SPViewSPView

AdministrationAdministration SPGlobalAdminSPGlobalAdmin SPQuotaSPQuota SPVirtualServerSPVirtualServer

SecuritySecurity SPGroupSPGroup SPGroupCollectionSPGroupCollection SPSiteSPSite SPUserSPUser SPUserCollectionSPUserCollection

DocumentsDocuments SPDocumentLibrarySPDocumentLibrary SPFileSPFile SPFileCollectionSPFileCollection SPFolderSPFolder

Site definitionsSite definitions

18

Site Definition FilesSite Definition Files

C:\Program FilesC:\Program Files\Common Files\Common Files\Microsoft Shared\Microsoft Shared\web server \web server

extensionsextensions\60\template\60\template

File ScopesFile Scopes Server Language Server Language

E.g., E.g., \1033\1033 Site Definition Site Definition

E.g., E.g., \1033\STS\1033\STS List DefinitionList Definition

E.g., E.g., \1033\STS\LISTS\\1033\STS\LISTS\DOCLIBDOCLIB

Enumeration of site definitions

Site definition

List definition

Minimalistsite definition

19

Site Definition FilesSite Definition Files WEBTEMPWEBTEMP**.XML.XML

Per linguaPer lingua Definisce i tipi di sitoDefinisce i tipi di sito Contiene i puntatori a più ONET.XMLContiene i puntatori a più ONET.XML

ONET.XMLONET.XML Definisce un sitoDefinisce un sito Definisce proprietà e navigazioneDefinisce proprietà e navigazione Contiene i puntatori a più SCHEMA.XMLContiene i puntatori a più SCHEMA.XML

SCHEMA.XMLSCHEMA.XML Definisce una listaDefinisce una lista Definisce proprietà, schema e visteDefinisce proprietà, schema e viste

Custom TemplatesCustom Templates

21

Custom TemplatesCustom Templates Una customizzazione di una site definitionUna customizzazione di una site definition ScopoScopo

Creare nuovi template senza modificare il serverCreare nuovi template senza modificare il server Impostare nuovi template e contenuti per la creazione Impostare nuovi template e contenuti per la creazione

di Sitedi Site Meno “pericolosi” dei Custom SiteMeno “pericolosi” dei Custom Site

Da considerarsi il delta tra un Site Definition ed il Da considerarsi il delta tra un Site Definition ed il risultato utenterisultato utente

Sono legati ad un paritcolare Site DefinitionSono legati ad un paritcolare Site Definition

Integrati in FrontPage 2003Integrati in FrontPage 2003

Web ServiceWeb Service

23

I WebServices espongono il modello a oggetti lato I WebServices espongono il modello a oggetti lato serverserver

Consentono il controllo completo di liste, siti, viste, Consentono il controllo completo di liste, siti, viste, ecc…ecc…

Le funzionalità sono state ottimizzate per minimizzare Le funzionalità sono state ottimizzate per minimizzare le transazionile transazioni

Microsoft Office 2003 (Microsoft Excel, DataSheet, Microsoft Office 2003 (Microsoft Excel, DataSheet, Microsoft Word, Microsoft OutlookMicrosoft Word, Microsoft Outlook®®, Microsoft , Microsoft FrontPageFrontPage®®, etc.) Sono stati integrati utilizzando I Web , etc.) Sono stati integrati utilizzando I Web Service espostiService esposti

Web Services in WSSWeb Services in WSS

24

Web ServiceWeb Service GetListCollectionGetListCollection GetListItemsGetListItems GetWebCollectionGetWebCollection UpdateListUpdateList UpdateListItemsUpdateListItems GetWebInfoGetWebInfo GetWebPartGetWebPart GetSmartPageDocumentGetSmartPageDocument And more… And more…

25

Getting Started with Web ServicesGetting Started with Web Services

Creare una Windows applicationCreare una Windows application Microsoft Visual StudioMicrosoft Visual Studio®®, “Add Web , “Add Web

Reference”Reference”

http://localhost/_vti_bin/http://localhost/_vti_bin/ lists.asmx - Listslists.asmx - Lists UserGroup.asmx – users and groupsUserGroup.asmx – users and groups Webs.asmx – Web informationWebs.asmx – Web information Views.asmx – view informationViews.asmx – view information Subscription.asmx – subscriptionsSubscription.asmx – subscriptions

26

ApprofondimentiApprofondimenti

SharePoint Products and Technologies Developer CenterSharePoint Products and Technologies Developer Centerhttp://msdn.microsoft.com/SharePoint http://msdn.microsoft.com/SharePoint

GotDotNetGotDotNethttp://gotdotnet.com/team/sharepoint http://gotdotnet.com/team/sharepoint

MSD2DMSD2Dhttp://www.sharepointd2d.com/http://www.sharepointd2d.com/

WSS FAQ WSS FAQ http://wss.collutions.com/http://wss.collutions.com/

SharePoint customizationSharePoint customizationhttp://www.sharepointcustomization.com/default.aspxhttp://www.sharepointcustomization.com/default.aspx

Barry's BlogBarry's Bloghttp://Barracuda.net/BarrysBlog.aspxhttp://Barracuda.net/BarrysBlog.aspx

27

© 2002 Microsoft Corporation. All rights reserved.© 2002 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.

top related