Tuesday, April 20, 2010

Project Server 2010 - PJContext

Hello everyone.

If you work with Project Server via PSI in web context (in your web parts or pages) it’s not necessary to create references to Project Server WCF services.

There is PJContext class in Microsoft.Office.Project.Server.PWA assembly. You just need to write one line of code to create an instance of service:

Microsoft.Office.Project.Server.WebServiceProxy.CustomFields customFieldsService = PJContext.Current.PSI.CustomFieldsWebService;

Now you can run service methods as you did that before with manually added service references:

var dsCustomFields = customFieldsService.ReadCustomFieldsByMdPropUids(mdPropUids, false);

PJContext has references to all PSI services (even to View and PWA services which are non-public). As far as all requests are run under current user account you should care about any impersonation issues in your application by yourself (see post about impersonation).

Have fun.

3 comments: