Oct 10

This was supposed to be purely a tech blog, but this got my blood boiling enough to write about it.  Some friends and I had IRAs/401Ks with AIG that are basically useless now thanks to likes of Joe Cassano.   The man basically responsible for bringing AIG down is now getting paid $1 million a month of our tax money as a consultant. 

Join my group on facebook and show your outrage…

http://www.facebook.com/group.php?gid=31013323035

Here is more on Joe Cassano…

http://www.bloomberg.com/apps/news?pid=20601103&sid=aOIwMdX.6IBc&refer=us

http://voices.washingtonpost.com/livecoverage/2008/10/joe_cassano_the_man_who_brough.html?hpid=topnews

http://online.wsj.com/article/SB122342739746113715.html?mod=googlenews_wsj

http://www.guardian.co.uk/business/feedarticle/7846208

http://www.youtube.com/watch?v=zv1xSipXWM8

http://www.youtube.com/watch?v=fx2FA-7gtbI&feature=related
 

Sep 5

The SmartPart Report can be downloaded at http://www.codeplex.com/SmartPartReport

If you use SmartParts then you’ll know how messy that usercontrols folder can get.  Worse, if you’ve inherited a SharePoint project with many pages that has SmartParts used all over the site, most likely you’ll need to know where each user control is being used.  This is the reason I came about making the SmartPart report.

The code is pretty straight forward.  It basically loops through each file, looks for only aspx files, and then goes through each webpart and checks to see if the type is a SmartPart. 

 You could also expand upon this and search for other web part types as well.  For example if you wanted to also look for Microsoft.SharePoint.WebPartPages.ListViewWebPart you can add it to the searchWebPartTypes array on line 83:

                    string[] searchWebPartTypes = { “SmartPart.SmartPart”, “SmartPart.AJAXSmartPart” , “Microsoft.SharePoint.WebPartPages.ListViewWebPart” };

It then uses reflection to get the “UserControl” property for a SmartPart.  Again, if you’re using this to find another web part, you could put some conditions around this and modify the propertyname to get the value you’re looking for.  Ex:

line 97:

          string propertyName = “UserControl”;
          string userControlFileName = “”;
         
          if (webPartType == “Microsoft.SharePoint.WebPartPages.ListViewWebPart”)
          {
                propertyName = “Title”;
          
}

Aug 7

public SPListItemVersion GetLatestMajorVersion(SPListItem listItem)
        {
            SPListItemVersion latestMajorSourceFileVersion = null;

            foreach (SPListItemVersion sourceListItemVersion in listItem.Versions)
            {
                Version thisVersion = new Version(sourceListItemVersion.VersionLabel);

                if (thisVersion.Minor != 0)
                {
                    continue;
                }
                else
                {
                    if (latestMajorSourceFileVersion != null)
                    {
                        Version v = new Version(latestMajorSourceFileVersion.VersionLabel);
                        if (thisVersion.Major > v.Major)
                        {
                            latestMajorSourceFileVersion = sourceListItemVersion;
                        }
                    }
                    else
                    {
                        latestMajorSourceFileVersion = sourceListItemVersion;
                    }
                }
            }

            return latestMajorSourceFileVersion;
        }

Apr 5

Sharepoint Workflow Starter is a tool I made for helping with mass starting/stopping workflows for items accross a Sharepoint site.

Download: The executable and source code are available at http://www.codeplex.com/SPWorkflowStarter.

***TEST IN YOUR DEV ENVIRONMENTS FIRST!***

The app needs to be run on a Sharepoint server with an account that has sufficient permissions to access the API.

This is what it looks like…

Overview Screenshot

So lets say you want to run the Approval workflow for every item in every list for a site and all its subsites. Here’s how we could do that:

1) Looking at the example above, you would first navigate to the site you want, in this case the root site http://stdemo.

2) Under that site we can find all the workflow templates available and we’ll select the Approval workflow template.

3) Once we select the Approval workflow template, you can check Run for all sub sites so that this workflow will run for all lists for this site and any sub sites.

4) You must choose the actions to take, stop, start, and you can also choose to use your own custom event data.

*Custom event data is the xml data passed to the workflow. When selecting a workflow template you will not see the event data that will be used by default because the workflow association to its list is what defines the event data. If you want to see what the event data looks like, select a list under that workflow template and you’ll see the event data used for that workflow association.

5) You can choose to log your results. This should always be done because I have yet to add any verbose output except in the logs.

6) Review your plan below and then click EXECUTE when ready.

The same steps above can be done for a list or single items in a list.

The tool still needs some work and if would like to help please drop me a line. Some future release features would be:

  • Running workflows for multiple items (via checkbox)
  • Better UI form design
  • Better log output control
  • Easier way to edit event data
  • A lot of code clean up :-O
Mar 31

Anyone working on a Sharepoint Workflow using the VS 2005 extensions will realize how after a recompile you have to go back to the List’s workflow settings and re-enable the workflow again.  After a recompile it always defaults to “No New Instances” and you have to set it back to “Allow” which is synonymous with enabling/disabling the workflow assocation.  Here’s some code you can throw in a console app and run everytime you compile so you don’t have to waste your time after every re-compile. 

 

SPSite site = new SPSite(”http://stdemo“);
SPWeb web = site.RootWeb;
// get the list where the workflow is associated            
SPList sharedDocumentsList = web.Lists["Shared Documents"];
 
// get the workflow assocation (check the index)           
Microsoft.SharePoint.Workflow.SPWorkflowAssociation wrkflow = sharedDocumentsList.WorkflowAssociations[0];
wrkflow.Enabled = true; sharedDocumentsList.UpdateWorkflowAssociation(wrkflow);