Group Policy 2 - Installing Software

Download Report

Transcript Group Policy 2 - Installing Software

Welcome
12/19 SharePoint Server 2007 技術深
入探討 – 進階開發篇
敦群數位科技有限公司 vanGene Digital Inc
游家德 Jade Yu
Agenda
• Platform technical overview
• SharePoint Site UI Customization
• SharePoint Content API introduction
• Web Part in SharePoint
• Event Handling in SharePoint
• Feature in SharePoint
Platform technical overview
Pictures of SharePoint Platform
Server-based
spreadsheets plus
BI portals built on
SQL Server
Analysis Services
Server-based
forms and
workflow with
smart client and
browser
interfaces
Business
Intelligence
Business
Processes
Collaboration
Windows
SharePoint
Services
“V3”
Content
Management
Next generation email, project
management,
workflow, blog and
wiki support
Portal
Enhanced
SharePoint Portal
aggregation and
personalization
Search
Great relevance
with rich people and
business data
search
Integrated document,
records and Web
content management
workspace foundation for
scalability and extensibility
Role of WSS3.0 in SharePoint
Framework
• Windows SharePoint Services V3
Core Service platform
• High level components
Office 12 Solutions Built On WSS V3
Collaboration
Portal
Search
ECM
BI
BPM
Project
Core Workspace Services
Storage
Security
Management
Topology
Site Model
APIs
Repository
Metadata
Versioning
Backup
Rights/Roles
Pluggable Auth
Per Item
Rights Trimming
Admin UX
Delegation
Provisioning
Monitoring
Config Mgmt
Farm Services
Feature Policy
Extranet
Rendering
Templates
Navigation
Visual Blueprint
Fields/Forms
OM and SOAP
Events
Deployment
Operating System Services
ASP.NET (Web Parts, Personalization, Master Pages, Provider Model for navigation, security, etc. )
Database
Search
Workflow
WSS3.0 Core Functions
Data Infrastructure
Object Model, Web Services, Events
Document Management, Workflow
Provisioning System
Page and Rendering Model
WSS vs .NET Framework
Windows
SharePoint
Services
“Version 2”
Windows SharePoint Services
“v2”
ASP.NET 1.1
ASP.NET 2.0
Windows
SharePoint
Services
“Version 3”
Windows SharePoint Services “v3”
Why move WSS3.0 to .Net20
• Goals
Build more directly on top of ASP.NET
Move core functionality to ASP.NET
• Benefits
Leverage ASP.NET skills for WSS development
• More consistency, less “SharePointisms”
Use more ASP.NET facilities
Provide & consume more ASP.NET interfaces
• Web Parts, Membership, Site Map Providers, etc.
Handling of SharePoint Request
Internet
Explorer
Windows
SharePoint
Services
“Version 2”
Windows
SharePoint
Services
“Version 3”
HTTP
SharePoint
IIS
Personalization
Office
ASPX Parser
FP RPC
SharePoint
ISAPI Filter
Front
Page
ASP.NET
SOAP
Window
Explorer
WebDav
Internet
Explorer
HTTP
Content DB
SharePoint
Page Handler
ASP.NET
ISAPI Filter
IIS
ASPX Parser
File System
ASPX Rendering
SharePoint
Content DB
ASP.NET
Office
FP RPC
File Provider
Page Filter
File System
Front
Page
SOAP
Personalization
ASPX Parser
Window
Explorer
WebDav
ASPX Rendering
Based on IIS Web Applications
• WSS now creates its own application
Does not “take over” the default app
• No need for “exclusions”(排除路徑)
• Unified application domains
• Centralized Web configuration management
object model
SharePoint Site UI
Customization
What do you want to customize?
• List Fields / View
• Cascading Style Sheets
• UI Look and Feel
• Workflow
Tools for Customization
Office SharePoint
Designer + Browser
Web site
construction
Microsoft
Visual Studio
Custom Coding
(if necessary)
Create lists and doclibs
Design Web pages
Web Controls and Parts
No-code data view/forms
ASP.NET page coding
No-code workflows
Workflow actions
Web part hookup
Event handlers
Impacts and scope of Customization
• List
• Site
• SiteCollection
• Site Definition
Master Page of Site Definition
• C:\Program Files\Common Files\Microsoft
Shared\web server
extensions\12\TEMPLATE\GLOBAL\Mast
er.page
Folder of Site Definition
Folder of CSS
• C:\Program Files\Common Files\Microsoft
Shared\web server
extensions\12\TEMPLATE\LAYOUTS\10
28\STYLES\core.css
Supports by SharePoint Designer
Use custom Master Pages for application chrome
Quick global changes
CSS tools for customizing SharePoint styles
“Core.css” automatically copied to local site
New safety nets
Users can restore original contents of site template pages, i.e. “re-ghost” pages
Versioning and Recycle Bin
“Contributor Mode” for fine-grained restrictions
Deep support for ASP.NET
Application Customization
Changing the application look
and feel using CSS and
Master Pages
Development Deliverables
Types of Development Deliverables
Data
Metadata
Behavior
ASP.NET extensions
Packaged Feature and Site Solutions
Data
• Programmatic access to data and documents
• Custom (or customized) lists, libraries, views
Calendars / Contacts / Announcements / Links / Surveys /
Discussions …
• Content Migration APIs
• Change logs
Metadata
• Column Templates
Centralized Field Management
E.g., all “Priority” fields should have 3 choices: 1, 2, 3
• Content Types
Reusable definition of a list schema
Hierarchical
Associate Behaviors
• Events
• Document Templates
• Workflows
Behavior – Events
• Before and after events
• List schema events
• SPWeb deletion events
• Events on lists and libraries
• Pre-synchronous with cancellation and filtering
• Multiple event receivers
• Event Receivers per-list Item
• Attach events at web or item level
Behavior – Workflow
• Windows Workflow Foundation is embedded
• Projects
Workflow activities
Workflow assemblies
Workflow metadata
Workflow UI
• Tools
Visual Studio
SharePoint Designer
ASP.NET Extensions
• It’s never “should I use ASP.NET or SharePoint sites?,”
it’s “should I use ASP.NET to write from scratch or to
extend SharePoint sites?”
• Web Parts
• Custom controls
• Custom pages
• Master pages
• User/role providers
Features
• Combination of list/view/Web Part/Event
Handler/workflow component/etc.
• Can be packaged and deployed as a single set
• Site Definitions are now largely sets of features
• Sharable across site definitions
Site Definitions
• Low-level instructions and resources for creating,
rendering sites
All sites are based on a site definition
Created with XML and ASP.NET resources
Can execute code during site creation
• Whole new kinds of sites
Team software development
University courses
Specialized project management
Blogs/Wikis
Activity monitors
Customization Issues:
• Store Enhancements
–Event Receivers
–Workflows
–Field Types
–Content Migration
–Security Policies
• Site Metadata
–Site Columns
–Content Types
–List Definitions
• UI Enhancements
–Web Parts
–Master Pages
–View Definitions
• Smart Clients
–SOAP
–WebDAV
–FrontPage RPCs
• Provisioning
–Site Definitions
–Feature Definitions
–Provisioning Assemblies
SharePoint Content API
introduction
Terms of WSS3.0/MOSS2007
• Server Farm
• Web Application(Virtual Server)
• Site Collection(SPSite)
• Site(Web)
Logical Architecture of SharePoint
Object Model about SharePoint
Content Access
SPSite
SPWebCollection
SPWeb
SPListCollection
SPList
SPListItemCollection
SPListItem
SPAttachmentCollection
SPFieldCollection
SPFile
SPField
Scenarios for using Content API
• Web Page / Window Form / Console Aps.
• Retrieve Data in WSS for customized use
• Update Data in WSS
How to get the root object for SPSite
• Web Page
– SPSite
oSite=SPControl.GetContextSite(httpcontext.current);
or
– SPSite oSite=new SPSite(“http://MOSS”));
• Non-Web Form
– SPSite
oSite=new SPSite(“http://MOSS”));
Codes to Get SPWeb object
SPSite oSite=new SPSite(“http://MOSS”));
SPWeb oWeb=SPSite.AllWebs[“/WebURL”];
Codes to get
SPLISTCollection/SPList
SPSite oSite=new SPSite(“http://MOSS”));
SPWeb oWeb=SPSite.AllWebs[“/WebURL”];
SPListCollection oLists = oWeb.Lists;
foreach(SPList oList in oLists)
{
console.write(oList.Title);
}
Codes to get
SPListItemCollection/SPListItem
SPSite oSite=new SPSite(“http://MOSS”));
SPWeb oWeb=SPSite.AllWebs[“/WebURL”];
SPList oList = oWeb[“listname”];
foreach(SPListItem oListItem in oList.Items)
{
console.write(oListItem[“Title”]);
}
Create a new ListItem
SPSite oSite=new SPSite(“http://MOSS”));
SPWeb oWeb=SPSite.AllWebs[“/WebURL”];
oWeb.AllowUnsafeUpdate=true;
SPList oList = oWeb[“listname”];
SPListItem oli = oList.Items.Add();
oli[“Field”]=“Field_value”;
oli.update();
Recommendations about using API
• Reduce the SQL pass through between
using SharePoint Object.
–Get root object as early as possible, and release
as late as possible.
–You should use object loaded from previous API
call in memory
–
Sample of bad / good coding
• Bad Coding
oWeb.List[“name”][0][“Title”]=“new title”;
oWeb.List[“name”][0][“start_date”]=“2007/7/7”;
oWeb.List[“name”][0][“start_date”]=“2007/7/31”;
oWeb.List[“name”][0].update();
Sample of bad / good coding
• Good Coding
oListItem=oWeb.List[“name”][0];
oListItem[“Title”]=“new title”;
oListItem[“start_date”]=“2007/7/7”;
oListItem[“End_date”]=“2007/7/31”;
oListItem.update();
Using SharePoint Content API
Write Console to access data
in SharePoint
Implementation of SharePoint
Web Part
WebPart in SharePoint
• Web Parts are now in ASP.NET 2.0
• ASP.NET 2.0 Web Parts supported
• Full Compatibility for WSS “v2” Web Parts
–WSS “v2” Web Part class rebased
on .NET 2.0 web parts
MyV2WebPart ->
Microsoft.SharePoint.WebPartPages.WebPart ->
Microsoft.Web.UI.WebControls.WebParts.WebPart
• Improved user interface for Web Parts
Types of WebPart in SharePoint
• SharePoint WebPart(WSS WebPart)
• ASP.NET WebPart
• Hybrid WebPart
How to implement and deploy Web
Part in SharePoint
• Create a WebPart Project in VS.NET 2005
• Assign Strong Name and version information
• Copy Dll to bin folder and add SafeControl section in
web.config
• Add web part to WebPart Gallery
• Add web part to WebPage Page
Implementation of WebPart
Implement a “Hello World”
Web Part
Implementation of WebPart
Implement a WebPart with
Paramaters
Implementation of WebPart
Implement a WebPart with
WebControls
Implementation of Event
Handler
Why do you need “Event Handler”
• Add some customized action when user
do something
–Notification
–Verification
–Extra-action
–…
Powerful Event Handler in
SharePoint
• Events architecture significantly improved
•Events supported for lists, document libraries and
content types
•Events supported for changes to list schema as
well as items
•Events supported at site collection and site level
•Events supported for incoming email messages
•Support for synchronous events and
asynchronous events
•Synchronous events occur before the fact and are
cancel-able
How to implement your Event
Handler
• Create an EventHandler DLL
• Register the dll to
GAC(c:\windows\Assembly)
• Register the EventHanlder to List in
SharePoint
ListItem Level Event Receiver
Sample Code for EventHandler
•
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Net.Mail;
namespace myEventHandler
{
public class handler : SPItemEventReceiver
{
public override void ItemAdding(SPItemEventProperties properties)
{
//do something
}
}
}
Build options
• strong name your EventHandler
assembly
• Version for Assembly
Register for List EventHandler
SPSite site = new SPSite("http://sp:81/SiteDirectory/site1");
SPWeb web = site.OpenWeb();
SPList survey = web.Lists[“ListName"];
string assemblyName = “myEventHandler, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=a34245adab33a20a";
string className = “myEventHandler";
survey.EventReceivers.Add(SPEventReceiverType.ItemAdding, assemblyName,
className);
MessageBox.Show("Done");
Implementation of EventHandler
Write an event Handler to log
action performed by user
Implementation of “Feature”
What’s SharePoint Feature
What’s SharePoint Feature
Scope of Feature
Scope
Description
Site
The Feature is defined at site level.
Site Collection
The Feature is defined at the level of a
site collection.
Web Application
The Feature is defined at the level of a
Web application or a virtual server.
Server Farm
The Feature is defined at the level of a
server farm. All Features that are installed
at the Server Farm scope are in the
activated state by default.
Where’s Features Folder
How to implement your feature
• Compose the definition files
–Feature.XML
–Elements.XML
• Implement the action aspx
• Install your feature to SharePoint
• Activate the Feature
•
Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="DE98E72D-80FF-4031-88B0-2E4DEF6312C8"
Title="Save Site As Template"
Description="Adds a 'Save Site As Template' link to the Look and Feel menu in Site Settings."
Version="1.0.0.0"
Scope="Web"
Hidden="FALSE"
xmlns="http://schemas.microsoft.com/sharepoint/" >
<ElementManifests>
<ElementManifest Location="Elements.xml" />
</ElementManifests>
</Feature>
Elements.xml
•
<?xml version="1.0" encoding="utf-8" ?>
•
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
•
<CustomAction
•
Id="SPSolutions.SaveSiteAsTemplate"
•
GroupId="Customization"
•
Location="Microsoft.SharePoint.SiteSettings"
•
Sequence="1000"
•
Title="Save site as template">
•
•
•
<UrlAction Url="_layouts/savetmpl.aspx"/>
</CustomAction>
</Elements>
Install your feature to SharePoint
Using STSADM.exe
stsadm -o installfeature -name
SaveSiteAsTemplate
Implementation of “Feature”
Add a customized feature to
Site Admin Menu