Question

Currently I am developing an AddIn for MS Project 2010.

In this AddIn the user filters all employees stored as MS Project Resources on the Project Server by several criteria. After finding a matching human resource the user should be able to add this resource to a selected task.

Unfortunately I do not find the link between adding the resource locally by

 _activeProject.Resources.Add("ResourceName") 

and the resource being stored on the server. "ResourceName" shown in Project has no connection to "ResourceName" on the server.

I tried to load the Microsoft.Office.Interop.MSProject.Resource somehow from the server via the PSI and add it to the project team by:

    Dim projectTeamRow As SvcProject.ProjectTeamDataSet.ProjectTeamRow = projectTeamDs.ProjectTeam.NewProjectTeamRow()
    projectTeamRow.PROJ_UID = projectGuid
    projectTeamRow.RES_UID = resGuid
    projectTeamRow.NEW_RES_UID = resGuid
    projectTeamDs.ProjectTeam.AddProjectTeamRow(projectTeamRow)

But that's not really what I want. I simply need to add a server related resource to the local version of the project. In other words: I am looking for a way to convert a SvcProject.ProjectTeamDataSet.ProjectTeamRow to a Microsoft.Office.Interop.MSProject.Resource.

I really hope somebody can help me, since all my researches failed.

Was it helpful?

Solution

To add resource from Project server to your project you need to know ID of the resource (Not GUID). This information is stored in the RES_ID column. Just quest resource from server and get the ID.

If you plan to add several resources - I would recommend to cache a list of resources locally. I'm using this query to organize several dictionaries inside of my add-on:

ResourceDataSet resourceDs = new ResourceDataSet();

PSLibrary.Filter resourceFilter = new Microsoft.Office.Project.Server.Library.Filter();
resourceFilter.FilterTableName = resourceDs.Resources.TableName;

resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_IDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_UIDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_NAMEColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_TYPEColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_INITIALSColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_EXTERNAL_IDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_IS_WINDOWS_USERColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.WRES_ACCOUNTColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.WRES_EMAILColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_TIMESHEET_MGR_UIDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));

resourceDs = ReadResources(resourceFilter.GetXml(), false);

The query is defined as extension of ResourceClient class from PSI.

As soon as you know ID of the resource just execute: Application.EnterpriseResourceGet(resId, omissing);

Application is from Microsoft.Office.Interop.MSProject.

This command will load the resource from Project Server into Active Project. Oh yes, please don't forget to check that your project is active when you call the command.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top