Showing newest 15 of 20 posts from October 2009. Show older posts
Showing newest 15 of 20 posts from October 2009. Show older posts

Thursday, 29 October 2009

I'm in love...with the new OpenXML SDK!

Tobias Lekman, Technical Architect

I have spent the last couple of weeks creating a Word report based on SharePoint data that spans over a hundred pages using tables and custom graphs.

To do this, I used OpenXML. The file format (.docx) is basically a ZIP file containing a bunch of XML files. I did this using LINQ, XSLT and System.IO.Packaging to compress and order the XML sections into a .docx file. The OpenXML SDK version 1 allows you to manage the packaging side and relationships of the “parts” (XML files).

The new SDK allows you to manage the entire document directly using LINQ which would have bypassed my 60+ XSLT library that I had to create for the original conversion to work. The structure of the program would have been the same but could have saved me a lot of code lines!

When creating OpenXML documents you often end up with corruption. The file is missing a relationship between a diagram and the underlying data, an ID of a part is repeated and so forth. Opening the file in Word will give you a nasty error without any detailed information and you are left to open the document and manually figure out where the corruption could have occurred. The SDK now contains a class called OpenXmlValidator which will validate the entire package and give you a detailed error report. Again, this could have saved me hours and hours of debug time.

To make things even better, the SDK contains some fantastic tools. My favourite is the Document Reflector which opens an OpenXML document from a template and will give you the full code for how to generate that document using the SDK. Now, I don’t even want to begin to estimate how much time THAT would have saved me.

As a final nail in my coffin, SharePoint 2010 introduces REST for Excel Services. My report contained 50+ graph reports which had to be created using 6 different XML parts. This can now be done by inserting the graph generated directly by Excel Services using SharePoint 2010.

The final version of the new SDK will be released together with Office 2010.

Wednesday, 28 October 2009

Data Sources and Features in Visio Services

Zane Freame, Product Manager

Following on from my earlier post, Visio Services in SharePoint 2010, I wanted to delve a little deeper into how this new Shared Service works. Microsoft have been working hard to create a great framework for creating your own data driven visualisation in SharePoint. Here's a high level look at how they're helping you do it.

 
Diagrams can be published directly to SharePoint document libraries and either opened in the browser directly from the file, or published in full fidelity using a Visio Web Access web part. Both methods use Silverlight to render the diagram, and for those who don't have Silverlight, the diagrams can be published as a PNG image minus a few interactive features.

 
According to the guys from Microsoft, the published diagrams are browser agnostic and will work in Internet Explorer, Firefox and Safari to name a few. Data can be refreshed manually or automatically with a variety of options in the web part to customise what users can see and do.

Visio Services for SharePoint 2010 supports a variety of data sources including:
  • SQL (ODC)
  • Excel workbooks (via Excel Services)
  • SharePoint Lists
  • OLEDB
  • ODBC
  • Custom (not sure what this is yet, but I'm sure I'll find out soon!)
The features don't end there either. I haven't had a chance to build my own (yet!) but here are just a few of the features and tools that you can expect to see in the final product.
  • Ability to pull data from multiple data sources on the same diagram
  • Zoom in/out functionality
  • Automatic refresh of data
  • JavaScript Mash-up API
  • Support for web part connections
One disclaimer... although you can still create diagrams in Microsoft Visio 2007, in order to publish them to SharePoint 2010, you will need Microsoft Visio 2010 installed on the client computer. Of course, users just viewing the diagrams in SharePoint will not require Visio installed.
 
For more information about Visio 2010 visit the official Visio Blog on MSDN - Visio Insights.

Tuesday, 27 October 2009

SharePoint 2010: Architecture Guidance - things everyone should know!

Martin Hatch, Solutions Architect

Well, the final day of the conference came and with it some of the most useful sessions (from my perspective). One of which was the "Architecture Guidance for SharePoint 2010". This hopefully distils some of that information. It's not a be all and end all, but hopefully points you in the right direction so that you can focus your research a little better!

UI Design
  • Entire interface in SharePoint 2010 to be W3C XHTML compliant
  • SharePoint 2010 "more accessible mode" to be WCAG 2.0 AA compliant
  • New ribbon interface replaces toolbars and menus (and considerations for old "CustomAction" commands which may no longer work!)
  • Wiki content allows web parts to be dropped in (removing over-reliance on web part zones)

Lists
There are a whole load of new List capabilities (in addition to the "External List" that BCS brings to the plate!).
  • Lookup to Multiple
This means that when you create a new lookup column, you can now pull down additional fields from the lookup list item and use them for filtering.
  • CAML support for Joins!
You can now perform "JOIN" operations in your CAML queries for linking lists together.
  • Enforced List Relationships
You can now enforce specific relationships for lookup columns with two options:
  • Restrict Delete - cannot delete parent if child items exist.
  • Cascade Delete - If you delete the parent, all child items are automatically deleted (recycle bin aware with "restore" options!)
  • Store-level enforcement
This is code level "required fields", so now you can enforce the requirements even through code !
  • Unique Fields
Specify a unique field, so that no two values can match (e.g. Email addresses in contacts list)
  • Compound Indices
If you want to query by 2 fields, you can now index both at once as a compound index.
  • <In> clause for reverse lookups
This allows a CAML query to do a reverse lookup to get all child items that are associated with the parent!
  • Formula based validation
e.g. Don't allow Field2 to be lower than Field1.

Workflows
  • Out of the box SharePoint 2010 workflows can now be extended in SharePoint Designer 2010.
  • SharePoint Designer 2010 can be used to create "re-usable" workflows
  • Site Workflows - to manage processes across an entire site.
  • You can now import a SharePoint Designer 2010 workflow into Visual Studio 2010!
  • Import/Export workflow using Visio 2010 for visual workflow modelling.

Content & Document Management
  • "Document Sets" allow you to treat a group of documents as a single item (with 1 version history, group executed workflow and policy, and a "download as zip" option).
  • Managed Metadata Service  allows cross-farm Content Type management. This is a killer-app, bringing true enterprise content management to SharePoint 2010.
  • Enterprise Wiki's allow more rapid "in edit" content, as well as Web Parts deployed directly into the rich text editor (no more web part zones?).
  • Spelling check and broken link check when you "check-in" WCM pages.

Event Handlers
Three new event handlers added (at last!!)
  • WebAdded - Fired every time a child site is created in the web.
  • ListAdded - Fired every time a list is created in the web.
  • Feature Upgrading  - Fired when a feature has it's "upgrade" method called (more on this in a future blog post).

Security
  • Editing of ASPX pages now required "Designer" permissions (instead of contribute).
  • XSS (Cross Site Scripting) protection for pages and web parts.
  • HTML pages will now "force download" by default. This stops people from uploading HTML files with malicious scripts, so if you click on an HTML file in a document library you will get a download dialog instead of the file opening in the browser!
  • There are still no field level permissions (it was estimated that this would add a 30% overhead to performance! Maybe in a future release)

BI and Connectivity
  • New Business Connectivity Services (BCS) allows no-code connections of databases and LOB systems to content types and lists with two-way synchronisation of data  and full CRUD support.
  • PowerPivot for Excel allows upwards of 100 million rows into an excel workbook with phenominal performance.

Office Application Support
  • New web level services for applications (Excel / Visio with JavaScript events!)
  • SharePoint Workspace to replace "Groove" for offline file support and editing.
  • Office Web Applications to allow for direct opening and editing of documents from within the browser!

Databases
  • Still a 100GB "limit" for content databases.
  • Still cannot have site collections spanning multiple databases.
  • New support for "Failover" databases, SharePoint 2010 is now SQL mirror aware!
  • All "Service Applications" have their own SQL database, along with many other new databases (e.g. Feed Activity, Social Data, Usage Logs).
  • New "read only content databases" open the door for simple content deployment (utilising SQL log shipping or database replication).

Content Deployment
  • All execution now in Timer Jobs.
  • Performance (and memory usage) improved.
  • Export routine now creates database snapshot to improve data integrity!

Sandboxed Solutions
  • Ability to upload WSPs directly into the content database to execute in minimal permissions using "virtual files" (no impact on the file system!)
  • Resource throttling, code performance checking and "bad routine" blocking
  • Provides new best practice for code development and deployment!

I'm sure there are many other things, so please let me know if there's anything else you think should "make the grade" and I'll see if I can add it in :)

[Also posted on Martin's personal blog]

Wednesday, 21 October 2009

My Site 2010 Profile Pictures Centrally Managed

Glyn Clough, Solutions Consultant

Responding to what most surely be one of the most common questions and requests from users of previous SharePoint My Sites, Microsoft have updated the manner in which profile pictures are managed within SharePoint 2010 My Sites (actually the User Profile Database).

The key areas of the new approach are:
  • Pictures are now stored centrally within the My Site Host site collection in a picture library located http://host/userphotos.
  • Pictures are resized three ways when uploaded:
    • 32x32 pixels for use within SharePoint 2010
    • 48x48 pixels for use within Active Directory and other client applications (such as Outlook and Office Communicator)
    • 96x96 pixels for use on the My Profile page of a My Site
  • The Picture Picker can be customised or replaced to support feature such as requesting usage consent or providing default images.
Managing profile pictures was a common headache in SharePoint 2007 and given all the new social features of SharePoint 2010, it's great news that this has been addressed.

[Also posted on Glyn's personal blog]

SharePoint 2010 brings versioning to Web Parts

Tobias Lekman, Technical Architect

In the upcoming release of SharePoint Server 2010 we will see versioning of web parts and their properties.

Why is this important?

In the past we had full versioning and approval workflows around the contents of items and pages but any change to web parts and their properties were instantaneous. This caused a lot of confusion and aggravation as web parts, their configurations and content were lost irretrievably when users made changes to them.

All web parts within the page are now fully version controlled with the rest of your page and will not require any additional code within the web part itself.

Visio Services in SharePoint 2010

Zane Freame, Product Manager

As many of my colleagues will testify, I've had a long love affair with Visio. It started when I was at University in Melbourne over 12 years ago. I stumbled across a free student version in a local computer store and from that point forward I've been creating all my flowcharts, processes, layouts and many other diagrams in Visio. In fact, in every job I've had, I've found a new application for the product. Content and Code has been no exception. On my first day I discovered that the team were already using Visio to create quick and easy wireframes...so I then went about creating new templates and stencils/shapes to meet our wireframing needs for website development.

Visio is a brilliantly simple visual tool with advanced options for integrating with external data, but until now the missing link has been publishing to SharePoint. Several years ago Content and Code developed a Visio Viewer web part for SharePoint 2003 which enabled users to view Visio diagrams in a SharePoint page provided they had the Visio Viewer add-on installed on the machine. Although that was a great option for many companies, it was no holy grail either.

With Excel Services bringing the power of publishing spread sheets and charts to SharePoint, it was only a matter of time before Microsoft decided to do the same with Visio. Well, there's no more waiting... Visio Services is here! What's more they've packed it with great data interaction features which will blow your socks off! Trust, me if you're a visual person like me, Visio Services for SharePoint 2010 is your bag of fun and will take your Visio diagrams to the next level.

From the slides, Microsoft are proud to point out that with Visio Services for SharePoint 2010 you can:
  • Share Diagrams in SharePoint
  • Build Data Driven Visualisations
  • Integrate with SharePoint Applications
But what does this mean?

I think the best way to explain this is with some real-life examples which most of you would have come across in the past.

  • A restaurant seating plan indicating which tables are availble before you make a reservation.
  • Flight seating plan to check which seats are available when you check-in online.
  • Elections results on a map (e.g. votes per state/county) - picture the election TV broadcast with data presented in blue or red areas on a map with bar graphs and numbers indicating which political party is winning the election race.
These are just a few examples that are out there which you could easily reproduce in Visio Services with little or no development.

It's clear to see the benefits of visualising data in this way, and now with Visio Services we can combine data in SharePoint and other data sources with our Visio diagrams and publish them to SharePoint.

The presenters here at the SharePoint Conference had plenty of other great examples to demonstrate during the sessions I attended (factory floor plans, manufacturing cycles, hotel vacancies, insurance loss per state, ski lift status etc.) proving that the opportunity with Visio Services is only limited by your visual imagination.

Tuesday, 20 October 2009

Silverlight and SharePoint 2010

Jason Visser, Technical Architect

Development of Silverlight and SharePoint has always been very painful however with SharePoint 2010 Silverlight integration has been simplified greatly.

Why use Silverlight instead of other technologies:

  1. It is easier to build for .NET developers as it uses a common language.
  2. Less browser compatibility issues - either the Silverlight app renders or it does not.
  3. More powerful animations, algorithms and a rich development API.
  4. Very powerful client integration, e.g. out of browser support, offline mode, multi touch and access to the local file system.
Silverlight should not be used everywhere and samples of that would be:

  1. When you need to capture or render rich text or html.
  2. When there is large amounts of content that will be paginated and referenced by URL's.
There are 4 main ways to develop Silverlight applications with SharePoint 2010 (these can all be combined if required):
  1. Read and Write to SharePoint using Web Service's.
  2. Read and Write to SharePoint using the new client object model.
  3. Read and Write to SharePoint using REST
  4. Load data from SharePoint by rendering data on the page.
My current preferences would be using REST and the new client object model to read and write to SharePoint.

Silverlight and Web Service integration

SharePoint has always shipped with built-in web services. These include reading and writing to different areas of SharePoint 2007. SharePoint 2010 is no exception and it too ships with various web services.

A quick sample of the type of web services available would be getting lists, list items, sites, navigation, security and search. The exposed web services all make use of the in-built SharePoint security trimming.

If you do not find a web service that works for you, you can build your own web service and call that from your Silverlight application. When developing Silverlight applications using these web services, you will be using asynchronous execution and will be retrieving your result in xml form. These results can then be interpreted and manipulated using various different .net technologies. My favourite would be XLINQ which was the preferred method for reading and writing to SharePoint 2007.

Silverlight and the Client Object Model

New for SharePoint 2010 is the Client Object Model. The client object model for Silverlight is basically a subset of some of the objects that were previously not available to be used by the Silverlight API.

Object's available from the Silverlight client object model include:

  • Site
    • Web
      • ContentType
      • List
        • Form
        • View
        • Field
        • ListItem
      • Folder
        • File
          • WebPart
      • Navigation
        • NavigationNode
      • UserCustomAction
      • RoleDefinition
      • RoleAssignement
      • WorkflowAssosiation
      • WorkflowTemplate
The client object model uses asynchronous call's to read and write to the SharePoint site in batches. There are 2 assemblies that can now be found in the SharePointRoot\14\template\layouts\clientbin folder that include the object described above. The client object model uses a context similar to the SPContext object, this is called the ClientContext. An example of how to code using this model is:

ClientContext context = ClientContext.Current();
Web = context.web;
context.load(web);
context.load(web.lists);
context.ExecuteQueryasync(this.ExecuteMethod, null);

Silverlight and REST

You can read and write to SharePoint using REST which creates strongly typed object using the REST services. It allows you to code against SharePoint using OOP and ATOM-based means. This and the client object model are the preferred ways to communicate with SharePoint.

Silverlight and rendering data on the page as initialisation parameters

This is the oldest way of providing your Silverlight application with SharePoint data. Initiation Parameters can only read data from SharePoint using the Silverlight 'init params' method. Using this method you need to print out the data that you need to load into the Silverlight application. If there is a lot of data it will all need to be printed to the page / Silverlight object. This can be useful for initial Silverlight setups like theme settings and view settings, rather than loading up a default skin and waiting for the response from SharePoint to load up your initialisation parameters.

Sandboxed Solutions

Tobias Lekman, Technical Architect

One of the largest paradigm shifts for developers in SharePoint 2010 is the introduction of “sandboxed solutions”.

“A sandboxed solution is a new concept in Microsoft SharePoint Foundation that allows site collection users to upload their own custom code solutions. A sandboxed solution uses a subset of the Microsoft.SharePoint namespace. These objects are marked in the object model to show their availability in a sandboxed solution”

Source: http://msdn.microsoft.com/en-us/library/ee539083(office.14).aspx

Simply put – you should always use a sandboxed solution until you can prove that a sandboxed solution is not sufficient to get the job done.

A sandboxed solution works in the same way as a normal solution (farm level solution) but runs in minimal privilege mode. You cannot place files within the old “hive” but rather work with virtual files. It also runs within a separate process outside of the SharePoint application and communicates with SharePoint 2010 over a proxy.

On the upside: your code will not conflict with other custom solutions. On a shared environment this is a huge benefit. The system is also protected from bad code as detection of abnormal CPU, thread or memory usage will cause the component to be booted out of the system.

On the downside: It means more work for developers.

When you need to access external systems, you will now write a “full-trust proxy” that is installed in GAC and made available to all sandbox solutions. This class will have a contract describing exactly what additional access the code can gain. For example, you can read information from a CRM database, but not add data nor access any other external database.

This means less risk of installing third party and bespoke components, less need for code reviews and easy monitoring of software components.

A common breakdown of your solution might be:

  • List definitions, fields and content types (sandbox)
  • Code-only Web parts (sandbox)
  • Full-trust proxy solution with contract for access to read CRM (GAC)
  • Data layer for CRM (GAC)
For a complete architectural view of sandboxed solutions, see http://msdn.microsoft.com/en-us/library/ee539417(office.14).aspx.

Top 10 (+1) new things in SharePoint Designer 2010

Glyn Clough, Solutions Consultant

I attended a great session on day one of the SharePoint Conference by a guy called Asif Rehmani, MVP MCT. Asif is the co-founder of SharePoint-Videos.com and a mixture of trainer and solution architect for SharePoint and perhaps it was this training background that helped him deliver such a fantastic session. I strongly recommend checking out SharePoint-Videos.com as there is already SPD 2010 content up there!

The introduction to SharePoint Designer 2010 was a demo of the top 10 cool new things that you can do in the product. Here they are:
  1. Restrict SPD as needed
    It's possible to set permissions at the web application or the site collection level as to who can use (and what they can do) SPD 2010.
  2. New user experience with summary pages, ribbon and quick launch navigation
    SPD 2010 has had a re-design along with the rest of office. The key element for me is that it is now a highly integrated experience with SharePiont. For example you can browse the content types and site columns available in a site direction from SPD.
  3. Create SharePoint content
    As you'd expect you can create new pages, sites, lists etc all from within SPD.
  4. Configure site security
    Previously it was only possible to configure the permissions of a site through the browser, but now SPD also provides this functionality.
  5. Create new content types and attach to lists directly
  6. Create site assets to store files needed for the site
    There's a new type of library called 'site assets' in SharePoint 2010 and this can be populated via SPD. Assets such as CSS, XML or JavaScript files can be stored here.
  7. XSLT List View Web Parts... Everywhere!
    A new web part for 2010 is the XSLT List View Web Part which is a mix of the old XSLT Data View Web Part and the List View Web Part from 2007. This provides fantastic functionality such as conditional formatting etc in a really well integrated web part - that can now also be configured via the browser.
  8. Connect to data sources outside of SharePoint
    Databases / XML files / Server-side scripts / Web Services are all external data sources that can be easily dropped into a page and presented to the user via SPD.
  9. Create Business Connectivity Services external content types
    The BCS is the evolution of the Business Data Catalogue and has been fully integrated into SPD. It's possible to quickly, with no code, link to an external data source (e.g. SQL) and present this information as an 'External Content Type' in SharePoint 2010. This can then be viewed and edited in SharePoint via a new list type 'External List'.
  10. Create powerful reusable workflow
    There are now three types of workflow available in SPD: List Workflows, Reusable Workflows, Site Workflows. The impressive thing is that SPD workflows now no longer need to be tied to a specific list in a specific site! They can also be saved out as a WSP or exported to Visio.
These are all fantastic features - and the implicit one in all of them is the great usability of SharePoint Designer. As with other areas of the SharePoint experience, there have been huge efforts at increasing productivity. It's obvious to see that its matured as a product, to such a level that (pending further investigation!) I'd be comfortable recommending using SPD for day-to-day activities of site administration - on the production environment!

[Also posted on Glyn's personal blog]

Standards compliant SharePoint - too good to be true?

Martin Hatch, Solutions Architect

Well it seems not. Microsoft have really pulled out all of the stops this time around, with standards compliant, cross browser compatibility and even accessibility hitting the conference headlines.

The first item of note is that SharePoint 2010 aims to be W3C XHTML compliant. This is a massive leap towards making SharePoint 2010 a truly robust platform, worthy of both internet facing sites and global internal systems.

I saw a demo of an embedded video in the Monday afternoon Web Content Management session where a video was streamed from a document library (another new SharePoint 2010 feature) and it was loaded in FireFox with no plugins or downloads, full screen streaming and buffering.

But the biggest impact is bound to be around the statement that one of the major release goals for the SharePoint 2010 release is that the entire interface of SharePoint 2010 meets WCAG 2.0 AA compliance! This includes editing and authoring of content! This is absolutely massive, and represents a huge push from Microsoft to really respond to the community feedback that accessibility is a subject to be taken seriously.

Of course, there is bound to be community discussions around the ideology that "compliant" is not the same as "accessible" (which we at Content and Code know all too well, having developed several fully accessible SharePoint 2007 solutions for the Royal National Institute of Blind People ) but this is still a massive step forward and certainly shows a continuing respect of standards from Microsoft and good news for the future of compliant software.

[Also posted on Martin's personal blog]

Key notes from the Keynotes

Martin Hatch, Solutions Architect

The keynote speeches contained a huge amount of content, but there were some standout points for me that were worth condensing into a post...
  • One of the main aesthetic changes is that Windows SharePoint Services (WSS) is now called SharePoint Foundation 2010. Hopefully more details about capabilities will surface during the conference.
  • There was much talk about SharePoint Online. They apparently have over 100,000,000 users and the platform is updated quarterly with new functionality, so we can hope to see new SharePoint 2010 functionality in that creeping through once the RTM version of SharePoint is released.
  • The list item storage limits has gone WAY up ... 1,000,000 items per folder/list and over 10,000,000 documents per library.
  • Another favourite was how Excel Services in SharePoint 2010 allows you to expose excel data as REST feeds (such as charts, tables, images, pivot tables). This allows you to subscribe to an image URL which is actually being dynamically generated from the Excel 2010 spread sheet. The main focus here was that you can embed this image anywhere that a normal HTML or Office Client image can be placed, but if the Excel 2010 spread sheet data is modified then the image is automatically updated to reflect those changes!
  • Other highlights included forcing spelling checkers and broken link checkers on check-in of a page. In fact there was a lot of mention around web sites full stop, particularly 2 new products for websites: SharePoint Server 2010 for Internet Sites and FAST Search Server for Internet Business.
  • The new Wiki Editing features were demonstrated with auto-complete URLs for lists, views and folders in libraries.
  • For those power users there are also over 500 new PowerShell commands for SharePoint 2010 which will be shipped with the Beta version in November. These can even be run on a Windows 7 machine and executed remotely!
But by far the most impressive part for me was the presentation on SQL Server PowerPivot for SharePoint 2010 and SQL Server PowerPivot for Excel 2010. This is the product formerly known as "Gemini" and allows you to pull data in from SQL databases to allow up to 100,000,000 rows of data in Excel 2010! You can then filter, sort and produce charts which refresh near instantaneously! There was a demo of this in the session causing a round of applause from pretty much everyone.

A very interesting session in the end, with glimpses of promise from all over the platform. I can't wait to get my hands on it!

[Also posted on Martin's personal blog]

The strategic evolution of SharePoint

Glyn Clough, Solutions Consultant

During his keynote session at the SharePoint Conference 2009 Jeff Teper, Corporate Vice President for SharePoint, showed an interesting PowerPoint slide from 1999 when Microsoft were first strategising about a new product that was to become SharePoint. The amazing thing is that 10 years later the key elements of the strategy set down then are now just as applicable now:
  • Provide a great integrated solution
  • Out of the box work spaces
  • Compelling Office integration
  • Easy and flexible deployment
The good news for all of us SharePoint professionals, and more importantly the millions of SharePoint end-users, is that this shows a consistent long-term approach to the product that has definitely helped shape where we find SharePoint 2010 today and hopefully where it will go in the future!

[Also posted on Glyn's personal blog]

Facts and figures from the SharePoint Conference 2009

Martin Hatch, Solutions Architect

Wow - that's the word that summed up our reaction to the Keynote speeches to open the SharePoint Conference 2009. We'll be posting more about that shortly, but to warm you up here's some tasty facts and figures:

  • 538 onsite labour days to setup the conference
  • 7.5 miles of CAT5e cable used
  • 7400+ attendees (up over 90% on the last SharePoint conference)
  • 160+ partners
  • 300+ hours of brand new content
  • 297 speakers
  • 240 break-out sessions
  • (and 2 marriages!!)
So - you could say they are taking this conference VERY seriously.

It was also confirmed that the Public Beta of SharePoint 2010 and Office 2010 will be launched in November and they are expecting an RTM release in the first half of 2010.

Visual Studio 2010 Beta 2 was also released today!

[Also posted on Martin's personal blog]

Wednesday, 14 October 2009

Shortcut Keys for Windows Server 2008 R2 and Windows 7

Tristan Watkins, Infrastructure Consultant

As part of our recent roll-out of Windows Server 2008 R2 and Windows 7 machines I've been coming across a lot of good information. Here are a few shortcut keys (some new, some old) that I think could help you get the most of your new desktop. I found these in the Windows 7: 77 Windows 7 Tips article on Microsoft TechNet.

  1. Win+H - Move current window to full screen
  2. Win+I - Restore current full screen window to normal size or minimize current window if not full screen
  3. Win+Shift+arrow - Move current window to alternate screen
  4. Win+D - Minimize all windows and show the desktop
  5. Win+E - Launch Explorer with Computer as the focus
  6. Win+F - Launch a search window
  7. Win+G - Cycle through gadgets
  8. Win+L - Lock the desktop
  9. Win+M - Minimize the current window
  10. Win+R - Open the Run window
  11. Win+T - Cycle through task bar opening Aero Peek for each running item
  12. Win+U - Open the Ease of Use center
  13. Win+Space - Aero Peek the desktop
  14. Ctrl+Win+Tab - Open persistent task selection window, roll mouse over each icon to preview item and minimize others
Plus, one of my favourites (for laptop users), Win+P - Presentation mode.

Saturday, 10 October 2009

Multiple Language Support Without Variations

Tobias Lekman, Technical Architect

My site uses variations to publish Arabic and English content. This works well for all pages except for the login page, which sits in the root site at “/pages/login.aspx” and uses forms authentication.
I have implemented a custom language switch which allows the culture to be switched dynamically. This is done by using a custom code-behind page for the layout.
First, I override the OnPreInit to set the culture manually:
   1: /// <summary>
   2: /// Override to set UI culture according to query string or client settings.
   3: /// </summary>
   4: /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.
   5: /// </param>
   6: protected override void OnPreInit(EventArgs e)
   7: {
   8:     Thread.CurrentThread.CurrentCulture = 
   9:         Thread.CurrentThread.CurrentUICulture = CurrentCulture;
  10: }
I then get culture by query string or by client settings as:
   1: /// <summary>
   2: /// Gets or sets the current culture by query string or client settings.
   3: /// </summary>
   4: /// <returns>The current <see cref="CultureInfo"/>.</returns>
   5: protected virtual CultureInfo CurrentCulture
   6: {
   7:     get
   8:     {
   9:         if (currentCulture == null)
  10:         {
  11:             currentCulture = !string.IsNullOrEmpty(Page.Request.QueryString["lang"])
  12:                                  ? new CultureInfo(Page.Request.QueryString["lang"])
  13:                                  : new CultureInfo(Page.Request.UserLanguages[0]);
  14:         }
  15:         return currentCulture;
  16:     }
  17:     set { currentCulture = value; }
  18: }
Finally, I populate my dropdown list of choices as:
   1: /// <summary>
   2: /// Gets the variations of the system.
   3: /// </summary>
   4: /// <value>The variations.</value>
   5: private static SPListItem[] Variations
   6: {
   7:     get
   8:     {
   9:         if (variations == null)
  10:         {
  11:             using (SPSite site = new SPSite(SPContext.Current.Site.ID))
  12:             {
  13:                 using (SPWeb web = site.OpenWeb(SPContext.Current.Site.RootWeb.ID))
  14:                 {
  15:                     SPList list = web.Lists[new Guid(web.AllProperties["_VarLabelsListId"].ToString())];
  16:                     List<SPListItem> items = new List<SPListItem>(list.ItemCount);
  17:                     for (int step = 0; step < list.ItemCount; step++)
  18:                     {
  19:                         items.Add(list.Items[step]);
  20:                     }
  21:                     variations = items.ToArray();
  22:                 }
  23:             }
  24:         }
  25:         return variations;
  26:     }
  27: }
  28:  
  29: /// <summary>
  30: /// Override to populate the variation selection drop down list.
  31: /// </summary>
  32: /// <param name="e">
  33: /// The <see cref="T:System.EventArgs"/> object that contains the event data. 
  34: /// </param>
  35: protected override void OnLoad(EventArgs e)
  36: {
  37:     base.OnLoad(e);
  38:     SPSecurity.RunWithElevatedPrivileges(() => BindVariations(ddlVariations));
  39:     ddlVariations.Attributes.Add("onchange", "window.location.href='?lang='+this.options[this.selectedIndex].value");
  40: }
  41:  
  42: /// <summary>
  43: /// Binds the variations from the language variations to a list control.
  44: /// </summary>
  45: /// <param name="list">The list.</param>
  46: private void BindVariations(ListControl list)
  47: {
  48:     bool selected = false;
  49:     foreach (SPListItem variation in Variations)
  50:     {
  51:         ListItem item = new ListItem(variation["ows_Description"].ToString(),
  52:                                      variation["ows_Language"].ToString().ToLowerInvariant());
  53:         if (string.Compare(variation["ows_Language"].ToString(),
  54:                            CurrentCulture.ToString(),
  55:                            true) == 0 &&
  56:             !selected)
  57:         {
  58:             item.Selected = true;
  59:             selected = true;
  60:         }
  61:         list.Items.Add(item);
  62:     }
  63:     if (!selected)
  64:     {
  65:         //Exact culture not found. Use language, not culture as "en-US" == "en-GB"
  66:         string language = CurrentCulture.TwoLetterISOLanguageName;
  67:         foreach (ListItem item in list.Items)
  68:         {
  69:             if (item.Value.StartsWith(language + "-"))
  70:             {
  71:                 item.Selected = true;
  72:                 break;
  73:             }
  74:         }
  75:     }
  76: }
In the end, I will move the OnPreInit code into the master page or a HTTP module and encapsulate the variations list into a control, but you get the point from the code above. The benefit of using this in a HTTP module would be translation of system pages without usage of variations, but that’s another story.
 
[Also posted on Tobias' personal blog]