Tuesday, May 22, 2007

SPS/WSS 2003 : Overview of custom webparts

There are some steps that you have to take when you want to upgrade your existing 2003 environment to a 2007 environment. One of those steps is to get an overview of all the installed custom webparts. Now this is not that difficult, you just use the STSADM command to retrieve all the installed webparts.
But what you want to know (and this is even not only desirable information to have when you are not upgrading) is, are the custom webparts used by our users? If so, on which site and on which page is the custom webpart dropped?

To find out these answers we use the GetWebPartCollection method from the SPWeb object. This method returns a collection of WebParts. If you take a look at all of the properties of this object there is nothing that truly identifies the webpart. Sure you've got the ID and ClientID but those ID's are unique for the webpage where the webpart is hosted. What I found was that the Description property is the only property that is easily identified and unique (unless you've build all you're webparts with "WebPart1." as the default description :P)

The next thing to overcome was that you use the GetWebPartCollection method with a specifaction of the page (e.g. default.aspx), now this works fine for a default sitetemplate. But if your sites are based upon the workingspace template, the possibility exists that there are more pages on the sites where the webpart could be found. So you've got to enumarate through all the pages as well.

So here's the function:

 

static void GetWebparts (string url)
{
    
    //boolean to determine when we want to add an WebpartItem to the ArrayList
    bool GotWebPart = false;
    
    
    //Opening the site
    SPSite siteCollection = new SPSite(url);
    SPWeb web = siteCollection.OpenWeb();
    
    try
    {
        //Retrieving all the webparts on a particular page. 
        SPWebPartCollection collection = web.GetWebPartCollection("default.aspx", 
            Microsoft.SharePoint.WebPartPages.Storage.Shared);

        foreach (Microsoft.SharePoint.WebPartPages.WebPart webpart in collection)
        {
            //If the webpart has a description like the description that can be found in the .DWP file, we are gonna add this webpart to the collection
            if (webpart.Description == "WhatNew." 
                
                )
            {
                WebpartItem item = new WebpartItem();
                item.OriginalTitle = GetOriginalTitle(webpart.Description);
                item.Webpart = webpart.Title;
                string LinkToSite = web.Url.ToString() + ", " + web.Title.ToString();
                item.Site = LinkToSite;
                item.Page = "default.aspx";
                
                GotWebPart = true;
                
                //If the webtemplate is based on a workspace, we have not only the default.aspx 
                //page but also for every tab a new .aspx file
                if (web.WebTemplate == "MPS")
                {
                    SPFolder srcFolder = web.Folders["pages"];
                    foreach(SPFile file in srcFolder.Files)
                    {
                        SPWebPartCollection pagescollection = 
                            web.GetWebPartCollection("pages/"+file.Name.ToString(), 
                            Microsoft.SharePoint.WebPartPages.Storage.Shared);
                        foreach (Microsoft.SharePoint.WebPartPages.WebPart _webpart in pagescollection)
                        {
                            if (_webpart.Description == webpart.Description)
                            {
                                item.Page += " | " + file.Name.ToString();
                            }
                        }
                        
                    }
        
                }
                if (GotWebPart == true)
                {
                    //Finally we put the item in the ArrayList                        
                    items.Add(item);
                }
            }
        }
    }
    catch (Exception error)
    {
        Console.WriteLine(error.Message.ToString() + "    " + url.ToString());
    }

    finally
    {
        web.Close();
        web.Dispose();

        siteCollection.Close();
        siteCollection.Dispose();
        
    }

}

 

Hope this helps somebody out  :)

 

Technorati tags: , ,

Sunday, May 20, 2007

Book review : Sharepoint 2007 Unleashed

 I've had the privilege to get a free copy of a book called Sharepoint 2007 Unleashed by Michael Noel and Colin Spence (no blogs found?!). The audience level of this book is aimed at intermediate to advanced.  As stated in the introduction of the book, it is divided in to four sections :

  1. Sharepoint 2007 overview, Planning and Implementation, provides an introduction to SharePoint 2007 technologies and covers the architecture process. Details on installing SharePoint 2007 and processes for migrating from SharePoint 2003 are included.
  2. Using Sharepoint 2007 technologies, covers the core feature set of SharePoint 2007 that power users and administrators will need to master, including libraries, lists, designing and managing pages, workspaces, and sites.
  3. Managing a Sharepoint 2007 environment, provides best practices on managing and administering the SharePoint infrastructure, securing the environment, maintaining and managing the environment and databases, and backing up and restoring the SharePoint 2007 environment
  4. Extending a Sharepoint 2007 environment, goes into detail on the topics of configuring email-enabled content, Exchange Server integration, enabling presence information with Office Communication Server 2007, and securing remote access with ISA Server 2006. In addition, chapters are included on using SharePoint Designer 2007.

I was most amazed by the first section, as it describes all the possible scenarios which I could not (yet) find on the Microsoft site and provides valuable information how-to implement that scenario as well. The other sections were fairly straightforward and about 80% of the information can be found on the net. But in contradication to the net, all the information is neatly placed (read : aggregated) and the style of the writers reads very well ;)

Conclusion:
A very good book for those who want to have a complete overview of Sharepoint 2007 (WSSv3 & MOSS) and those who want to get more indepth information. I think the audience level is better if it is set to intermediate alone instead of intermediate to advanced. Since the 'advanced' audience probably knows about everything what is covered in the book.
I give it a 8/10

 

Technorati tags:

Friday, May 18, 2007

SharePoint 2007 Maximum Limitations

From Harsh Chiplonkar comes this table of the limitations of Sharepoint 2007 :

Following is a list of names and other parameters with the maximum allowable size on each.

Entity                        Max Permissible Size
Site Name                    128 characters
Site URL                 255 characters
Display name                 128 characters
Connection string                 384 characters
Email address                    128 characters
Version numbers                064 characters
Virtual Server Friendly Name            064 characters
SQL Database Name                123 characters
SQL Database Column                128 characters
SQL Database Table Name            128 characters
SQL Role Name                    128 characters
Server Name                    128 characters
Windows User Name                300 characters
Windows Password                300 characters
Dependencies per object            032 objects
Zone enumeration value            004 zones
Default SQL command timeout             300 seconds
Number of simultaneous
workflows that can be run             015

If during your course of using the product, you inadvertently cross these limits, then you would end up with errors. These are hard limits.

Technorati tags: , ,

Tuesday, May 15, 2007

Wanna chat in Sharepoint?

Check out what Lawrence has to say on the Sharepoint Team blog:

Have you ever wanted to have a persistent chat session right on your SharePoint team or collaboration site? It can be much easier and quicker for typing a message than SharePoint’s built-in Discussion Board. The ChatterBox web part provides an example of how such a persistent chat session can be implemented by utilizing a SharePoint list, so there’s no need to create a custom database. If you need more than one chat session on your site, you can simply create another instance of the ChatterBox web part and associate it with another SharePoint list. Here’s a screenshot of it in action.
I have not implemented this yet so I don't really know what to expect, but I do see a future for this in the helpdesk areas.

Master Pages vs. Themes: Which Do You Choose?

A great article by Heather Solomon (the Sharepoint diva of branding :)) about the differences between a theme and master pages. The key differences are :

So, to run down some key points:

Master Pages

  • Can totally change the look of a site.
  • Can hide SharePoint components that you don't want to use.
  • Will allow you to alter the layout of the page, in addition to changing the colors and images used in the site.
  • Will not affect _layouts pages.  You will need to use a workaround.

Themes

  • Can re-skin the layout of a site to use different images and colors.
  • Can only hide SharePoint components that can be controlled through hiding it in the CSS (display: none set on a class/ID).
  • Affects _layouts pages.
  • Can be used as an alternate CSS file application method, similar to alternate CSS setting in MOSS sites.
  • Are installed on the web server unless you customize the file.