Skip to main content
Boman.Biz

Boman.Biz

Go Search
Home
Mobile Monger
  

Boman.Biz > Categories
Project Server and the Milli-Minute

I just thought it was interesting to note that internally Project Server stores durations in what here at IPMO has become known as milli-minutes.

In Project Server 1 minute is stored as 1000.  We have dubbed these “MilliMinutes”.

Therefore 1 MilliMinute:

  • = 0.6 seconds
  • = 3 Jiffies
  • = 20.16 MicroFortnights
  • = 52.58 NanoCenturies
  • = 2.38 Dog Seconds (Assuming a dog year is the equivalent of 7 human years)
Accessing Project Server Reporting Database from Code

imageWhat you must learn is that these rules are no different than the rules of a computer system...some of them can can be bent. Others...can be broken.”

When developing software for Project Server 2010, occasionally we need to present information to the user that can only be sourced from the Project Server Reporting database.  Actually getting the data out of the database is a fairly simple exercise, once you know which one it is! 

The class that Project Server uses to manage this sort of thing is the PsiServiceApplication that lives in the Microsoft.Office.Project.Server.Administration assembly.  Unfortunately all the classes in this assembly are marked as internal and sealed to prevent unauthorised use – i.e. Us. 

So in situations like this, its sometimes necessary to use Reflection to bend the rules a little Winking smile

Enjoy!

/// <summary>
/// Gets the reporting database based on a PWA URL.
/// </summary>
/// <param name="vstrPWAUrl">The PWA URL.</param>
/// <returns>
/// SPDatabase object representing the required Reporting database or Null if not found
/// </returns>
/// <history>
///     <change user="JBoman" date="10/08/2011">Initial version.</change>
/// </history>
public SPDatabase GetReportingDatabase(string vstrPWAUrl)
{
    Assembly assPSA = Assembly.Load("Microsoft.Office.Project.Server.Administration, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
    Type typePsiServiceApplication = assPSA.GetType("Microsoft.Office.Project.Server.Administration.PsiServiceApplication");

    MethodInfo minfGetServiceAppByIUrl = typePsiServiceApplication.GetMethod("GetServiceAppByUrl", BindingFlags.NonPublic | BindingFlags.Static);
    object objPsiServiceApplication = minfGetServiceAppByIUrl.Invoke(null, new object[] { vstrPWAUrl });

    if (objPsiServiceApplication != null)
    {
        MethodInfo minfGetSiteList = typePsiServiceApplication.GetMethod("GetSiteList", BindingFlags.NonPublic | BindingFlags.Instance);
        object objSiteList = minfGetSiteList.Invoke(objPsiServiceApplication, new object[] { Microsoft.SharePoint.Administration.SPUrlZone.Default });
        if (objSiteList != null)
        {
            IEnumerable colSiteList = (IEnumerable)objSiteList;
            IEnumerator enumSiteList = colSiteList.GetEnumerator();
            while (enumSiteList.MoveNext())
            {
                KeyValuePair<string, SPPersistedObject> kvpSite = (KeyValuePair<string, SPPersistedObject>)enumSiteList.Current;
                if (kvpSite.Key.ToLower() == vstrPWAUrl.ToLower())
                {
                    Type typeProjectSite = assPSA.GetType("Microsoft.Office.Project.Server.Administration.ProjectSite");
                    PropertyInfo pinfReportingDatabase = typeProjectSite.GetProperty("ReportingDatabase", BindingFlags.Instance | BindingFlags.Public);
                    if (pinfReportingDatabase != null)
                    {
                        object objReportingDatabase = pinfReportingDatabase.GetValue(kvpSite.Value, null);
                        if (objReportingDatabase != null)
                        {
                            return (SPDatabase)objReportingDatabase;
                        }
                    }
                }
            }
        }
    }
    return null;
}
Project Server 2010:Deploying Workflows

I have recently been getting into the new workflow capabilities of Project Server 2010, which are basically SharePoint 2010 Workflows using Project Server activities.

There are 4 steps to creating your Project Server 2010 Workflow:

  1. Plan, Plan, Plan – you can never have enough documentation about the behaviour the customer actually wants.  Visio really helps here.
  2. Create the Project Server primitives to support your workflow, in this order; Custom Fields (CF), Project Detail Pages (PDP), Phases, Stages and finally an Enterprise Project Type.
  3. Using Visual Studio 2010, create the orchestration of your workflow, tying together all the objects you created.
  4. Packaging and deployment; use the resulting WSP to deploy to your target.

This took some time to get to step 3 using Visual Studio to test out the workflow, and when I got there I was pleasantly surprised to see the first workflow be deployed and run mostly successfully.  Obviously nothing works exactly right the first time, so as developers do, I changed some things and redeployed – this was where the fun began.

After Visual Studio retracted, redeployed and reactivated the solution the next attempt to run the workflow failed with an error indicating it couldn’t start the workflow.  I quickly found that the workflow had become disconnected from the Enterprise Project Type:

image

Once discovered, its easy to just re-attach the workflow to the Enterprise Project Type, however this happens on every redeploy!  If someone has a script to automatically hook this back up – let me know as I would be very appreciative!

 

 

 

After reattaching the workflow, it turned out that the old version of the workflow was still being initiated – so I thought an IISRESET would fix it.  Nope, still the old workflow was running, no matter how many times I IISRESET or redeployed the solution.

image

It turns out, that when you redeploy a workflow, you need to restart the Project Server Queue Service, as it has the old workflow assembly still in memory.

 

To automate this in Visual Studio you need to add the following commands to your Visual Studio post deployment steps:

net stop ProjectQueueService14
net start ProjectQueueService14

image

Hope this saves someone some time!

J.