Implementing a public internet web site using Microsoft Office SharePoint Server 2007 (MOSS) Thomas...

67
D107 MOSS / CMS Implementing a public internet web site using Microsoft Office SharePoint Server 2007 (MOSS) Thomas J. Palmié Microsoft Consulting Services http://blogs.msdn.com/thompal

Transcript of Implementing a public internet web site using Microsoft Office SharePoint Server 2007 (MOSS) Thomas...

D107 MOSS / CMS

Implementing a public internet web site using Microsoft Office SharePoint Server 2007 (MOSS)

Thomas J. PalmiéMicrosoft Consulting Serviceshttp://blogs.msdn.com/thompal

Session Objectives And Takeaways

Use Microsoft Office SharePoint Server 2007 (MOSS) as Web Content Management System (WCM) but don’t limit it to WCMImplementation of powerful multi-lingual public web sites based on MOSS is possibleMOSS is extensible with standard ASP.NET and .NET components

Agenda

Overview of the ChallengesArchitectureImplementation DetailsTips & TricksTakeawaysReferencesQ&A

It started with that:

www.swiss.com today

Thomas J. PalmiéMicrosoft Switzerland

demo

Requirements for the re-launch

Multi-lingual: supporting more than 20 countries and their local languagesIntegrating a standard ASP.NET 2.0 based application for the flight-booking applicationVery slim pages with short download timesMulti-lingual forms with special validation and submit logicEasy to use content management functionalityConfigurable presenter for announcing news in a slide-show styleEasy to use translation functionalityRe-use of master-pages and page-layouts for upcoming intra- and extranet projects

Architecture

Development Environment

Development Authoring Production

Team Foundation Server

VPC

VPC

VPC

Sources

Components

Content

There’s a nightly build job on the Team Foundation Server which builds the necessary DLL’s and stores them into this folder

There’s a backup job which runs every night. The backup file is stored into this folder.

Deploy the DLL’s Deploy the DLL’s Deploy the DLL’s

Content Deployment Job every 45 min. Content Deployment Job every 30 min.

Restore (every morning)

Implementation Details

Country/Language selectionUsage of SharePoint Lists (Translations, Lookups, Configurations)Forms DevelopmentCustom Field ControlsOptimizing the page sizeFlash IntegrationNewsletter featureSearch Implementation

Country/Language selection

We had to support >20 countries with theirlocal languages

Language Selection/Local content

language selection web part

country specific content=

local content

Site Setting – Variation Labels

Yes, we are using variations (for the global nav.)

Site Structure/Navigation

But not all levels are used in the navigation

Country specific contentBut we‘re also using custom lists (for the local content)

Integration of the booking app.

http://www.swiss.comhttp://booking.swiss.com

separate ASP.NET 2.0 application

MOSS

The booking app. is a separate ASP.NET 2.0 application

Usage of SharePoint Lists

All of our internal data is stored in SharePoint lists

• Configurations• Translations• Lookups Presenter

Configuration List

Presenter

Presenter Tabs

Translations

Loading the list datapublic override object LoadData(){ DataSet data = new DataSet(); SPWeb site = null;  try { site = SPContext.Current.Site.OpenWeb("/Data"); if (site != null) { cList = site.Lists["TranslationData"]; if (cList != null && cList.ItemCount > 0) { data.Tables.Add(cList.Items.GetDataTable()); }  } } finally { if (site != null) site.Dispose(); }  return data;}

Accessing and caching the data

object cachedVersion = System.Web.HttpContext.Current.Cache[key + language];

if (cachedVersion == null){ DataSet data = DataListReader.GetListData(); DataTable tab = data.Tables["TranslationData"]; DataView view = data.DefaultViewManager.CreateDataView(tab); view.RowFilter = "Title='" + key + "' AND Language='" + language + "' AND Country = ''";

if (view.Count > 0 && view[0] != null) {

string res=RemoveHTML(view[0]["Value"].ToString()); AddToCache(key + language, res); return res; }}

Forms Development

•We didn‘t use Forms Server because:• No need for the „Powered by InfoPath Forms Services“ message

• Need for multi-lingual labels, lookups and error messages

• validations should be rendered inline instead of having a JavaScript alert for every validation error

• We wanted to use our existing CSS Styles• We wanted rendering of HTML without <TABLE> tags

• Need to submit the form as e-mail or posting it to a 3rd party service

General Enquiries Form

Inline Validation

s

Rent-a-Plane Form

Multi-lingual lookups

Forms Configuration in SPD

Using Form Controls

protected void Page_Load(object sender, EventArgs e){ string lang = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToString().ToUpperInvariant(); FormInfo.Text = Swiss.WebParts.General.Translator.Translate("FormInfo", lang); GeneralInformation.Text = Swiss.WebParts.General.Translator.Translate("GeneralInformation", lang);

Salutation.Text = Swiss.WebParts.General.Translator.Translate("Salutation", lang); cmbSalutationDS.Data = Swiss.WebParts.General.Translator.GetLookupData("Salutation", lang); cmpValidatorSalutation.ErrorMessage = "<div style='clear:both;'><ul class='exclamationmark'><li>" + Swiss.WebParts.General.Translator.Translate("reqFieldValidatorSalutation", lang) + "</li></ul></div>"; cmpValidatorSalutation.ValueToCompare = Swiss.WebParts.General.Translator.Translate("PleaseSelect", lang);

Forms Configuration

Thomas J. PalmiéMicrosoft Switzerland

demo

Custom Field Controls

Sometimes a Rich-Text Field Control is just not user-friendly enoughTradeoff between freedom and limitations for the authors

Custom Field Controls

Custom Field Controls

Pure ASP.NET prototype

Offer in Edit ModeNew Offer was added

Rendering after

Publishing

Offers Field Control

Thomas J. PalmiéMicrosoft Switzerland

demo

Offers Control Implementation/Deployment

derive class form BaseFieldControldefine field tyles in fldtypes_offers.xmldefine UI in OffersFieldRendering.ascx

Deploy your assemblyCopy “fldtypes_offers.xml” to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML

Offers Control Usage

Optimizing the page size

implemented as HttpModuleremoves hidden <input tagsremoves core.css, Band.css, Controls.css, HtmlEditorTableFormats.cssremoves core.js, WebResource.axd, init.js, portal.js, ie55up.js, non_ie.jsfixes several special character issuesinserts versioning for .js files (fixing cache issue)

<httpModules> <clear /> <add name="MOSSCleanupModule" type="HttpModules.MOSSCleanupModule, ..." />

Analysis using Firebug

Authenticated Access:376kB

Anonymous Access:240kB

We saved: 136kB

Analysis using FiddlerAuthenticate

d Access401‘538

Bytes

Anonymous Access

303‘695 Bytes

Flash integration

usage of a configurable Flash Control within a Rich-Text field control (not possible with the default Rich-Text editor)FlashFile list: stores the .swf filesFlashConfiguration list: stores the configuration<img tag used as a placeholder

Configuration of the Flash Control

Flash Placeholder

Flash File

Newsletter Feature

Usage of a page layout to edit a newsletterComponent which modifies the generated HTML

remove several tagsconvert relative URL‘s of <img tags into absolute URL‘s

Deployed as a feature

Newsletter Feature<img alt="" border=0 src="/SiteCollectionImages/General/2%20cols/LX_LH_SWI491_2col.jpg" style="border:0px solid">

<img alt="" border=0 src="http://thompal06.swiss.com:10028/SiteCollectionImages/General/2%20cols/LX_LH_SWI491_2col.jpg" style="border:0px solid">

Newsletter Feature Implementation

.aspx for UI

.cs for Business Logic

public static string GetHtml(string url, string rootURL){ StringBuilder html = new StringBuilder();

WebRequest myReq = WebRequest.Create(url); myReq.Credentials = CredentialCache.DefaultNetworkCredentials; // set myReq.Proxy if required // set myReq.Timeout if required WebResponse wr = null; StreamReader reader = null; try { wr = myReq.GetResponse();

Stream receiveStream = wr.GetResponseStream(); reader = new StreamReader(receiveStream, Encoding.UTF8); html.Append(reader.ReadToEnd()); CleanupHtml(html, rootURL); } finally { if (wr != null) wr.Close(); if (reader != null) reader.Close(); } return html.ToString();}

Search Implementation

Custom search UI because of:• Multi-lingual support• Support for FREETEXT and CONTAINS• Support for different search providers

Search Implementation

Search Provider Interface

Concrete Implementation

uses the configured provider

holds the search results

using (FullTextSqlQuery query = new FullTextSqlQuery(ServerContext.Default)){ query.ResultTypes = ResultType.RelevantResults; query.Culture = CultureInfo.CurrentCulture; query.SiteContext = new Uri(WebConfigurationManager.AppSettings["SharePointSearch.Site"]); query.HighlightedSentenceCount = 3; query.TrimDuplicates = true; query.KeywordInclusion = KeywordInclusion.AnyKeyword;

string queryStatement = ""; if (queryText.Contains("*")) { // do a wildcard search query.EnableStemming = false; queryStatement = "SELECT Path, Rank, Title, HitHighlightedSummary FROM {0}..scope() WHERE \"scope\"='{1}' AND CONTAINS ('\"{2}\"') ORDER By Rank DESC"; } else { query.EnableStemming = true; queryStatement = "SELECT Path, Rank, Title, HitHighlightedSummary FROM {0}..scope() WHERE \"scope\"='{1}' AND FREETEXT(DefaultProperties, '{2}') ORDER By Rank DESC"; }}

Search Configuration

Content Source Type: „SharePoint Sites“Define „Crawl Rules“Define „Search Scopes“Define „Server Name Mapping“„Manage File Types“: add „.pdf“Install PDF iFilter http://blogs.msdn.com/ifilter/archive/2007/03/29/indexing-pdf-documents-with-adobe-reader-v-8-and-moss-2007.aspx start Full-Crawl

Search Implementation

Thomas J. PalmiéMicrosoft Switzerland

demo

Search Configuration Issues

Crawler stops when there‘s no „default“ page defined within a Pages Library

Tool for creating default pages:http://myemea/sites/thompal/Shared%20Documents

generated default page

Search Configuration Issues

SetSearchVisibility must be configured

Tool for setting SearchVisibility:http://myemea/sites/thompal/Shared%20Documents

Tips & Tricks

Allow execution of custom codeDevelopment ToolsCssRegistration issueDebuggingUsing the SharePoint Object ModelULS Log ViewerSharePoint Designer cannot open pageSharePoint Designer and code snippetsPage Approval issue with sub-folders

Allow execution of custom code

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false"> <PageParserPaths> <PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" /> </PageParserPaths>

CssRegistration Issue

<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/Controls.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/main.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/button.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/zbox.css %>" runat="server"/> <SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/home.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/presenter.css %>" runat="server"/>

Question: How will SharePoint render this:

<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/button.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/Controls.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/home.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/main.css %>" runat="server"/> <SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/presenter.css %>" runat="server"/><SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/…/zbox.css %>" runat="server"/>

Answer: Alphabetically

CodeRush templates

Thomas J. PalmiéMicrosoft Switzerland

demo

Debugging

which w3wp.exe process is the one for our web application?

iisapp script

Application Pool Name

What‘s wrong with this code?

SPWeb site = null;

try{ site = SPContext.Current.Site.OpenWeb(); int siteLevel = this.GetSiteLevel(site);

if (siteLevel > 4) { CreateNavigation(writer, site.ParentWeb, null); }}catch (Exception ex) {}finally{ if (site != null) site.Dispose();}

Memory Leak!SPWeb web = null;SPWeb parentWeb = null;

try{ web = SPContext.Current.Site.OpenWeb(); if (web != null) { parentWeb = web.ParentWeb; if (parentWeb != null) { int siteLevel = this.GetSiteLevel(web);

if (siteLevel > 4) { CreateNavigation(writer, parentWeb, null); } } }}catch (Exception ex) { Log.Fatal(ex.ToString());}finally{ if (parentWeb != null) parentWeb.Dispose(); if (web != null) web.Dispose();}

Watch out for:Property / Method / Collection Instantiates Note

SPSite.OpenWeb(...) SPWeb

SPSite.SelfServiceCreateSite SPWeb

SPSite.RootWeb SPWeb

SPSite.AllWebs SPWeb Accessing a collection member creates a new instance.

SPSite.AllWebs.Add SPWeb

SPSite.LockIssue SPWeb References data using SPSite.RootWeb property

SPSite.Owner SPWeb References data using SPSite.RootWeb property

SPSite.SecondaryContact SPWeb References data using SPSite.RootWeb property

SPWeb.ParentWeb SPWeb

SPWeb.Webs() SPWeb Accessing a collection member creates a new instance.

SPWeb.Webs.Add SPWeb

SPSiteCollection.Add Method SPSite

SPSiteCollection Accessing a collection member creates a new instance.SPSiteCollection is returned for instance by new SPGlobalAdmin().VirtualServers(0).Sites

Microsoft.SharePoint.Portal.SiteData.Area.Web

SPRequest calls COM!

Using Disposable Windows SharePoint Services Objectshttp://msdn2.microsoft.com/en-us/library/aa973248.aspx

ULS Log Viewers

https://www.spsdev.com/ulsreader.aspx

http://www.codeplex.com/sharepointloggingspy

SharePoint designer cannot open page

using multiple <FORM tags:After inserting this comment into a page layout SharePoint Designer could not open the page layout any more:<!-- <form name="form" method="post" action="http://.../ask_submit.php"> --><!-- </form> -->

Workaround: tool which extracts the page layouts into the file system:

SharePoint Designer and Code Snippets

Start SharePoint Designer and create a new pagewith Ctrl+Enter you can browse the existing code snippetsclick "Customize list..." for adding your own snippets(you could also use just the context-menu and select "Create Code Snippet...")click "Add..." and there you can add the code for a minimal master-page (this code can be found here: http://msdn2.microsoft.com/en-us/library/aa660698.aspx)

Page Approval issue with sub-folders

when using sub-folders for master-pages or pages layouts: SharePoint uses a wrong URL for the page approval

Workaround: PSS Case: SRZ070607000508

Master-Pages or Page-Layouts in sub-folders of

„masterpages“

Takeaways

start with 64-bit HW AND OSTry using the out-of-the-box controls before developing your own controls(Navigation, CQWP)test your content deployment early and often

MOSS based internet siteshttp://www.threewill.com/Pages/Default.aspxhttp://www.hedkandi.com/Pages/default.aspxhttp://www.alphamosaik.com/Pages/default.aspxhttp://www.spectracomputers.ro/http://www.wssdemo.comhttp://new.culminisconnections.comhttps://live.sharepoint-conference.eu/EN/agenda/Pages/default.aspxhttp://www.rjh.com.cn/http://www.satama.com/en/Pages/Default.aspxhttp://www.monsanto-ag.co.uk/layout/default.asphttp://www.ucb.fr/Pages/Accueil.aspxhttp://www.oasys.fr/Pages/Accueil.aspxhttp://www.revue-d-etudes.fr/Pages/accueil.aspxhttp://www.formextern.fr/Pages/accueil.aspxhttp://www.cegos.fr/Pages/Default.aspx http://www.taiwanlottery.com.tw/http://www.shareview.co.uk/Pages/Default.aspxhttp://www.trustcorgi.com/consumers.htmxhttp://dash8.komatsu.com.au/Pages/dash8.aspxhttp://www.speaktech.com/Pages/Home.aspxhttp://www.paulmitchell.com/Pages/Home.aspx

MOSS based internet siteshttp://www.tylerbutler.com/http://www.microsoft-oracle.com/Pages/default.aspxhttp://demo.empowerid.com/Pages/Default.aspxhttp://www.infocision.com/Pages/Welcome%20to%20InfoCision.aspxhttp://www.sharesquared.com/Pages/Default.aspxhttp://www.cscape.com/Pages/default.aspxhttp://www.moss2007.be/Pages/Default.aspxhttp://www.fertigung-edelstahl.at/default.aspx http://www.hawaiianair.com/Pages/Index.aspx http://www.ggs.wa.edu.au/Pages/Index.aspx http://www.ausinnovation.org/Pages/Home.aspx http://www.cafepedagogique.net/lexpresso/Pages/150307index.aspx http://www.mcgrathnicol.com/Pages/Index.aspx http://www.directenergy.com/EN/Pages/default.aspx http://www.voconversion.com.au/ http://www.shareview.co.uk/Pages/default.aspxhttp://www.infocision.com/Pages/Welcome%20to%20InfoCision.aspxhttp://www.glu.com/noram/Pages/home.aspxhttp://www.migros.chhttp://www.architectureforum.net.au/Pages/aaf.aspxhttp://www.southeastwater.com.au/Pages/SouthEastWater.aspx

MOSS based internet siteshttp://www.obs.com.au/Pages/default.aspxhttp://www.swiss.comhttp://www.viacom.com/default.aspxhttps://www.ocps.net/Pages/default.aspx http://www.westrac.com/Pages/Index.aspxhttp://www.westrac.com.au/http://www.westrac.com.cn/ http://www.jo.zain.com/English/Pages/Home.aspxhttp://www.softwareobjectives.com.au/Pages/Default.aspxhttp://www.statoilhydro.com/http://www.equalityhumanrights.com/en/Pages/default.aspxhttp://www.rado.com/http://www.sonova.com/en/Pages/default.aspx http://eu-shop.swatch.com/eshop/uk/en.aspx http://www.amanaliving.com.au/Pages/index.aspxhttp://www.advis.ch https://www.dolce-gusto.fr/https://www.flybuys.co.nz/ http://www.kroger.comhttp://www.tut.ac.za http://www.mf.co.za

MOSS based internet siteshttp://www.suninternational.com http://www.3fifteen.co.za http://www.ohchr.org http://www.2009congress.olympic.org http://www.parlament.ch http://www.kroger.com http://www.energizer.comhttp://www.lojack.com www.myoerlikon.com www.snf.chwww.economiesuisse.chwww.wahldok.chwww.arabbank.chwww.osn.chwww.itemagroup.com http://portal.gr.ch/ (www.awt.gr.ch; www.kiga.gr.ch ) www.point-s.dehttp://www.amhb.ab.ca/Pages/default.aspx http://www.mentalhealthfirstaid.ca/Pages/default.aspx http://www.fei.org/Pages/Default.aspx

MOSS based internet sites

http://www.spinebreakers.co.uk/Pages/Home.aspxhttp://www.equalityhumanrights.com/en/Pages/default.aspxhttp://www.desjardinsassurancesgenerales.com/d-QC/FR/Pages/accueil.aspx?MCA=Dhttp://www.plymouthhospitals.nhs.uk/Pages/Home.aspx http://www.investored.ca/en/Pages/default.aspxhttp://www.avistautilities.com/residential/pages/default.aspxhttp://www.fiatgroup.com/en-us/Pages/default.aspxhttp://www.informationworker.co.za/Pages/default.aspx http://www.sure.com.sa/sites/arabic/Pages/default.aspxhttp://jo.zain.com/Arabic/Pages/Home.aspx http://www.tut.ac.za/default.aspxhttp://www.absacapital.com/Pages/Absahome.aspxhttp://www.3fifteen.co.za/Pages/HomePage.aspx

Q&A

Questions?

© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks 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 date 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 accuracy 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.