views:

145

answers:

1

I have a SharePoint 2007 MOSS instance, and I'm on a fact-finding mission. There have been multiple developers, developing multiple webparts and deploying them (using VS2005/2008 SharePoint Extensions).

I thought maybe I could look at the fields in the "Web Part Gallery" list in my site, and look by "Modified by", but it looks like a developer's name is on some of the out-of-the-box webparts somehow, and on ones I know are custom developed, they say "System Account" - so looking at that field in this list is a no go.

I thought then maybe I could look at the "Group" to which each webpart was assigned but it looks like they were arbitrarily assigned to many different groups inconsistently - so using that piece of information is a no go.

Here is my code I have for just looping through and getting the names of all the webparts. Is there any property I can access on the list items of webparts that would tell me whether it's a custom developed webpart? Any way to distinguish the custom webparts from the out-of-the-box ones? Is there another way to do this?

        #region Misc Site Collection Methods
        public static List<string> GetAllWebParts(string connectedSPInstanceUrl)
        {
            List<string> lstWebParts = new List<string>();

            try
            {
                using (SPSite site = new SPSite(connectedSPInstanceUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists["Web Part Gallery"];
                        foreach (SPListItem item in list.Items)
                        {
                            lstWebParts.Add(item.Name);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lstWebParts.Add("Error");
                lstWebParts.Add("Message: " + ex.Message);
                lstWebParts.Add("Inner Exception: " + ex.InnerException.ToString());
                lstWebParts.Add("Stack Trace: " + ex.StackTrace);
            }

            return lstWebParts;
        }
        #endregion
+1  A: 

Have you tried exporting the webparts? Click on the arrow on the top right of the webpart and click on export. It will be exported as an XML file. Look for the metadata tag. e.g.:

<metaData>
  <type name="Microsoft.SharePoint.Portal.WebControls.KPIListWebPart, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <importErrorMessage />
</metaData>

The type attribute will give you the assembly information. If it is a custom webpart, the assembly name should mostly be something other than Microsoft.Sharepoint

desigeek
What about if it's something like a highly customized data form webpart?
zincorp
you can 'customize' an built-in webpart, but thats not the same as a 'custom' webpart, which i believe is what the OP is trying to find out..
desigeek
Maybe as a starting point - does anyone know how many out-of-the-box webparts come with the enterprise version of MOSS 2007? Then at least I'd know there were X original webparts, and see that I have Y installed, and say there is (x - y) = z, Z being how many custom webparts there likely are.
program247365
the number of webparts you see in the gallery depends on the WSS/MOSS features that you have activated and the type of site collection you will create. So this might not be a good approach. I have seen lists on the internet that give you the list of features that come with MOSS though. Try googling for that.
desigeek