dynamically retireve PSI Web Service URL in event handler (Project Server 2007)

A

Adrian

We are creating custom event handlers to add projects to categories and
resources to groups when they are saved for the first time. The problem that
we are facing is, in the event handler we are not able to get the instance
Name /URL of the project server from where the event handler has been
invoked. We need to know the server URL so that we can change the PSI web
service URL dynamically at runtime depending upon the project server
instance for which the event handler is invoked.

This would be a very important aspect when there is more than 1 project
server instance running at a time. As of now we are picking up the web
service URL from a config file. But when there is more than 1 instance using
a config file would be a problem.

Any ideas how we could achieve this ?

Thanks

Adrian
 
G

GM

I'm new to ProjectServer 2007 but let me try to answer the question.

EventHandler assembly should not be concern about the URL of the
projectserver.

Instead, it should be

1. Deployed into the server's GAC with a strong name.
2. Configured the association via PWA->Server Settings->Operational
Policies->Server-side Event Handler Configuration

Note when deploying a new version of the event handler assembly, you
need

1. Delete all relative association
2. Remove the assembly from GAC
3. Deploy the new version into GAC
4. Re-config the deleted assocation.

This can be quite tedious if you have many association configured, but
can be done programmatically through Events.asmx web service provided
by PSI.

Hope it helps.

GM
 
B

Brian Smith \(MSFT\)

You may well already have found the answer - but just in case - I did a blog
posting about this in early February. Please see
http://blogs.msdn.com/brismith/arch...pwa-sites-where-did-that-event-come-from.aspx

But the basic, along with a sample is:-

The event itself has a parameter of contextInfo and one of the properties
that gets set for events is the SiteGuid - which is actually the SiteId of
the WSS site hosting PWA. So this can identify the instance of PWA. The
next step to getting a URL rather than the GUID is to create a new instance
of SPSite using this GUID and then simply read the URL property. So a full
event handler that has the extra reference to the required SharePoint
library and writes the Project name, the Site ID and the Project Server URL
out to the event log would look like this:-

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;

using System.Text;
using Microsoft.Office.Project.Server.Events;
using Microsoft.Office.Project.Server.Library;
using WSSDll = Microsoft.SharePoint;


namespace TestEventHandler
{
public class MyEventHandler: ProjectEventReceiver
{
public override void OnPublishing(PSContextInfo contextInfo,
ProjectPrePublishEventArgs e)
{
base.OnPublishing(contextInfo, e);


EventLog myLog = new EventLog();
myLog.Source = "Project Event Handler";

// Get information from the event arguments, and
// write an entry to the Application event log.

string projectName = e.ProjectName.ToString();
Guid siteGuid = contextInfo.SiteGuid;
string pwaUrl = new WSSDll.SPSite(siteGuid).Url;
int eventId = 3652;
string logEntry;

logEntry = "Project: " + projectName +
"\nSiteId " + siteGuid.ToString() +
"\nPWA Instance: " + pwaUrl;
myLog.WriteEntry(logEntry, EventLogEntryType.Information,
eventId);


}


}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top