problem with PSI - UpdateProjectTeam

A

alex

Hi,

I use ProjTool to extract the necessaries informations to integrate in my
program.
My objective is to insert a new resource of enterprise in team project of
one project.
So ProjTool has this fonctionnality but it doesn't work.

I decide after to see the source of ProjTool to implement in my own
application.
So I get the list of projects -> ok
I get the list of team project of one project -> ok
I get the list of resource of the enterprise -> ok

When I try to update the list of resource associated to my team project
after to add one resource to the dataset, and when I invoke the webservice, I
obtain the following error :
<errinfo><dataset name="ProjectTeamDataSet"><table name="ProjectTeam"><row
RES_UID="202c0eac-9d30-465a-a713-745e7f90ae29"
PROJ_UID="68ae2c85-bdd9-4992-8205-398a24f410a8"><error id="1100"
name="ProjectResourceNotFound" uid="c65c2011-6058-42a5-8707-e75831806aee"
column="RES_UID" /></row></table></dataset></errinfo>

It's very weird because in projTool I obtain the same error.
And my resource is present!!
I verify the xml and everything is fine.

I try to update without to add a resource.
1\I get all resource of my team project
2\I invoke the method-> in that case, an error is coming say me there is an
error in the queue but nothing is recording on the server.

Do you have an idea?
 
A

alex

Hi,

Psi doesn't work really for this method.
And I try others functionnality of ProjTools and for the read it's working,
but I try to add a task and click update. I obtain another error!!.

So I come back on my old problem and try to do by sql query.
I add the resource in the table project_resources. But the resource doesn't
appears in my team project. So do you know where I should insert informations?

Thanks for your help.
 
B

Bryant Likes

I'd advise against directly updating the project databases. This is not
supported for one and for two there are lots of "tricks" that project server
uses to get things to show up correctly. It is pretty difficult to reverse
engine the tricks, so you're probably stuck with the PSI.

I'm still looking into your first issue.
 
G

Guest

Hi Alex,

If I understand your problem, you are try to add an existing project server
resource to the project team on one of your enterprise projects. If this is
the case, I have it working in one of my applications. I will insert the
subroutine that I use below.

The three input parmeters are a set of credentials with sufficient permissions
to make the PSI calls, the Guid for the Project you want to add the resource
and the Guid for the resource you want to add.

private bool AddResourceToProject(NetworkCredential serviceCredentials,
Guid selResource, Guid selProject)
{
AppSettingsReader reader = new AppSettingsReader();
string PSHost = reader.GetValue("ProjectServerHost",
typeof(System.String)).ToString();
string PSInstance = reader.GetValue("ProjectServerInstance",
typeof(System.String)).ToString();

Guid sessionId = Guid.NewGuid();

// Configure Project web service
ProjectWebSvc.Project projectSvc = new ProjectWebSvc.Project();
projectSvc.Credentials = serviceCredentials;
projectSvc.Url = "http://" + PSHost + "/" + PSInstance +
"/_vti_bin/psi/Project.asmx";

// Configure queue system web service
QueueSystemWebSvc.QueueSystem q = new QueueSystemWebSvc.QueueSystem();
q.Credentials = serviceCredentials;
q.Url = "http://" + PSHost + "/" + PSInstance +
"/_vti_bin/psi/QueueSystem.asmx";

// Retrieve the project team dataset
MyService.ProjectWebSvc.ProjectTeamDataSet dsProjectTeam =
projectSvc.ReadProjectTeam(selProject);

int iResCount = 0;
foreach (ProjectWebSvc.ProjectTeamDataSet.ProjectTeamRow
resourceTeamRow in dsProjectTeam.ProjectTeam)
{
if (resourceTeamRow.RES_UID == selResource)
{
break;
}
iResCount++;
}

// If the selected resource is NOT already in the project team table
if (iResCount >= dsProjectTeam.ProjectTeam.Count)
{
ProjectWebSvc.ProjectTeamDataSet dsNewProjectTeam = new
ProjectWebSvc.ProjectTeamDataSet();
ProjectWebSvc.ProjectTeamDataSet.ProjectTeamRow projTeamRow =
dsNewProjectTeam.ProjectTeam.NewProjectTeamRow();
projTeamRow.PROJ_UID = selProject;
projTeamRow.RES_UID = selResource;
projTeamRow.NEW_RES_UID = selResource;
dsNewProjectTeam.ProjectTeam.AddProjectTeamRow(projTeamRow);

// CheckOut (lock) the project while we modify and update it
projectSvc.CheckOutProject(selProject, sessionId, SESSION_DESC);

// Save the team!
Guid jobId = Guid.NewGuid();
projectSvc.QueueUpdateProjectTeam(jobId, sessionId, selProject,
dsNewProjectTeam);
WaitForQueue(q, jobId);

// CheckIn (unlock) the project
jobId = Guid.NewGuid();
projectSvc.QueueCheckInProject(jobId, selProject, false, sessionId,
SESSION_DESC);
WaitForQueue(q, jobId);
}

return false; // no errors...
}

Does this look like what you are looking for?

Bob Segrest
 
A

alex

Thanks for your advice.
I still continu in my side to search a solution.

Best regards,
Alexandre
 
A

alex

Hi Bob,

I really appreciate your answer.
I try your source code.
Now it's working.

So i see why the program send me an error.

In your program, you use
ProjectWebSvc.ProjectTeamDataSet.ProjectTeamRow projTeamRow =
dsNewProjectTeam.ProjectTeam.NewProjectTeamRow();
projTeamRow.PROJ_UID = selProject;
projTeamRow.RES_UID = selResource;
projTeamRow.NEW_RES_UID = selResource;
dsNewProjectTeam.ProjectTeam.AddProjectTeamRow(projTeamRow);

In my case, I don't use this method to add a new line in the dataset.

private void btnAdd_Click(object sender, EventArgs e)
{


ProjectWebSvc.ProjectTeamDataSet readProjectTeamDataSet = new
ProjectWebSvc.ProjectTeamDataSet();
ProjectWebSvc.ProjectTeamDataSet updateProjectTeamDataSet = new
ProjectWebSvc.ProjectTeamDataSet();
try
{
//on ajout la ressource
DataRow dr = ((DataTable)dgTeam.DataSource).NewRow();
DataGridViewRow dgrv = new DataGridViewRow();
dr["RES_UID"] = new
Guid(informationsEpm.Instance.m_resourceUidEnterpriseSelected);
dr["PROJ_UID"] = new
Guid(informationsEpm.Instance.m_projectSelected);
dr["NEW_RES_UID"] = DBNull.Value;
dr["RES_NAME"] = informationsEpm.Instance.m_resourceName;
dr["RES_BOOKING_TYPE"] = 0;
dr["RES_HAS_ACTUALS"] = DBNull.Value;
dr["RES_TYPE"] = 2;
dr["RES_IS_ENTERPRISE_RESOURCE"] = true;
((DataTable)dgTeam.DataSource).Rows.Add(dr);



AddResourceToProject(
new
Guid(informationsEpm.Instance.m_resourceUidEnterpriseSelected),
new Guid(informationsEpm.Instance.m_projectSelected));



updateProjectTeamDataSet.Clear();
updateProjectTeamDataSet.ProjectTeam.Merge(

(ProjectWebSvc.ProjectTeamDataSet.ProjectTeamDataTable)dgTeam.DataSource,
true);
Guid sessionGuid = Guid.NewGuid();


Framework.project.CheckOutProject(
new Guid(informationsEpm.Instance.m_projectSelected),
sessionGuid,
"To build team, ProjTool checked out project.");


Framework.UpdateProjectTeam(
new Guid(informationsEpm.Instance.m_projectSelected),
sessionGuid,
updateProjectTeamDataSet);
Framework.CheckInProject(
new Guid(informationsEpm.Instance.m_projectSelected),
sessionGuid,
true,
"Project checked in.");

Thanks,
Best regards,
Alexandre
 
M

Martin Winzig

Hi alex there is fragment of code which reating new project and buiding
project team.


MyProjectWebSvc.QueueCreateProjectAndCheckOut(jobId,sessionId,"Te
Training",DSProject, false);
WaitForQueueJobCompletion(jobId);
MyProjectWebSvc.QueueUpdateProjectTeam(jobId,
sessionId,projectGuid , dsProjectTeam);
MyProjectWebSvc.QueueCheckInProject(jobId, projectGuid, false,
sessionId, "TE training");

MyProjectWebSvc.QueuePublish(jobId, projectGuid, true,
projectname);
WaitForQueueJobCompletion(jobId);
 

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