Solved

Removing resource from project

Posted on 2009-04-14
9
1,045 Views
Last Modified: 2013-11-15
I want to remove a resource from a given project but keep getting jobStatus = 'unknown' and the error description is empty.

Got no problem adding resources.
So if anyone got some code to remove a resource, please share.
project.CheckOutProject(ProjectUID, sessionID, ((string)Langauge.Txt["RmvResSessionDesc"]));
projectTeamDS.ProjectTeam.RemoveProjectTeamRow(rowToRemove);
project.QueueUpdateProjectTeam(jobID, sessionID, ProjectUID, projectTeamDS);
queue.WaitForQueue(jobID); //here i get jobStatus = 'unknown' 
project.QueueCheckInProject(jobID, ProjectUID, true, sessionID, ((string)Langauge.Txt["RmvResSessionDesc"]));
queue.WaitForQueue(jobID);
 
WaitForQueue() //standart taken from MS
{
            WSQueue.JobState jobState;
            const int QUEUE_WAIT_TIME = 2; // two seconds
            bool jobDone = false;
            string xmlError = string.Empty;
            int wait = 0;
            wait = queue.GetJobWaitTime(jobId);
 
            System.Threading.Thread.Sleep(wait * 1000);
            do
            {
                jobState = queue.GetJobCompletionState(jobId, out xmlError);
                
                if (jobState == WSQueue.JobState.Success)
                {
                    jobDone = true;
                }
                else
                {
                    if (jobState == WSQueue.JobState.Unknown
                    || jobState == WSQueue.JobState.Failed
                    || jobState == WSQueue.JobState.FailedNotBlocking
                    || jobState == WSQueue.JobState.CorrelationBlocked
                    || jobState == WSQueue.JobState.Canceled)
                    {
                        // If the job failed, error out
                        throw (new ApplicationException("Queue request failed \"Job State: " + jobState + 
                                "\"<br />Job ID: " + jobId + 
                                ".<br />" + xmlError +
                                "<br />Estimated wait time:" + wait + "<br />iteration:" + iteration));
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(QUEUE_WAIT_TIME * 1000);
                    }
                }
            }
            while (!jobDone);
}

Open in new window

0
Comment
Question by:Skullkid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 13

Expert Comment

by:jbfraser
ID: 24147796
I don't have any code for thise, but I've got a couple ideas.

Does your queue job actually fail? Use the PWA web interface to check the queue jobs. Make sure to show successful jobs as well as failed and cancelled.

Also, does your WaitforQueue code run as a user with enough permissions to manage the Queue? That's more than usual Project Manager permissions, for example.


James Fraser
0
 
LVL 1

Author Comment

by:Skullkid
ID: 24156453
The queue job never shows, as it is never in the queue, when i check in the project that queue job shows in the list.

User got all permissions possible on computer and in PWA, (system admin)
0
 
LVL 13

Expert Comment

by:jbfraser
ID: 24158549
If the job isn't in the queue, then "Unknown" is the correct result for WaitForQueue, as I understand it. Your problem is earlier in the code: check the QueueUpdateProjectTeam call.  Is this throwing any exceptions? Are you using a new GUID for the job?


James Fraser
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Author Comment

by:Skullkid
ID: 24161166
No exceptions, and yes new Guid.
I have made it work for the add resource.

However i looked at ProjTool, and found that it worked if i remove the resource like this:
'See code snipped'.
But i can't show the form from a webpart, and if i did'nt call the show() method the DataSource is'nt loaded.


int index = projectTeamDS.ProjectTeam.Rows.IndexOf(row);
System.Windows.Forms.DataGridView remover = new System.Windows.Forms.DataGridView();
remover.DataSource = projectTeamDS.ProjectTeam;
((System.ComponentModel.ISupportInitialize)remover).BeginInit();
System.Windows.Forms.Form f = new System.Windows.Forms.Form();
f.Controls.Add(remover);
f.Show();
remover.DataSource = projectTeamDS.ProjectTeam;
Console.WriteLine("index: " + index + " count: " + remover.Rows.Count + " count: " + projectTeamDS.ProjectTeam.Count);
if (index == -1)
{
   Console.WriteLine("res not round");
   return; 
}
remover.Rows.RemoveAt(index);

Open in new window

0
 
LVL 13

Expert Comment

by:jbfraser
ID: 24161484
I don't think your code snippit above actually removes the resource from the project. That only removes them from the Datasource, but doesn't save that back to the project.

When a resource is really removed from a project, many other things need to happen: Assignments need to be deleted, Task work may need to change, &c. Removing a row from the projectTeam won't do these things. Now that I think about it, I'm not sure if RemoveProjectTeamRow() will do those things either. You may need to remove assignments manually.

For the resource you are trying to remove: do you get different behavior if you try removing a team member/resource that has no assignments in the project?


James Fraser
0
 
LVL 1

Author Comment

by:Skullkid
ID: 24161677
Yes i know, the code snip was put in instead of projectTeamDS.ProjectTeam.RemoveProjectTeamRow(rowToRemove);
then i check in/out the project and update. I can see that the resource is removed from the team when i browse it through PWA
0
 
LVL 13

Accepted Solution

by:
jbfraser earned 210 total points
ID: 24161758
Hmm. I surprised that worked.

As a workaround, can you force the DS to load? I forget the method but something like refresh() or load()

I'm about out of options. I think a call to MS support may be your best answer. The documentation for RemoveProjectTeamRow hardly deserves the word documentation.


Sorry I couldn't help...
James Fraser
0
 
LVL 1

Author Comment

by:Skullkid
ID: 24161941
Yes think i will do that, seems like an error in the PSI. Thanks for Your help :-)
0
 
LVL 1

Author Comment

by:Skullkid
ID: 24166864
No tryed several things, cant force it to load. However i decompiled the system.windows.forms.dll and found the source code for DataGridView here i replicaeted the remove code and now it works.

If anyone else should need this solution, my complete test prg is in code snip!!
Some try catch blocks has been removed for reading...
InitWebSvc();
            
//find 
Guid resUID = new Guid("d2064d5b-5dad-4d99-a975-b06bd4f1bdb7");
WSProject.ProjectDataSet.ProjectRow pr = project.ReadProjectList().Project[0];
Guid ProjectUID = pr.PROJ_UID;
Console.WriteLine("Res name: " + resource.ReadResource(new Guid("d2064d5b-5dad-4d99-a975-b06bd4f1bdb7")).Resources[0].RES_NAME);
Console.WriteLine("Proj name: " + pr.PROJ_NAME);
 
 //Insert Res row in project team
Guid sessionID = Guid.NewGuid(), jobID = Guid.Empty;
WSProject.ProjectTeamDataSet projectTeamDS = project.ReadProjectTeam(ProjectUID); 
 
//projectTeamDS.ProjectTeam.RemoveProjectTeamRow();
Console.WriteLine(projectTeamDS.GetXml());
for(int i=0; i<projectTeamDS.ProjectTeam.Rows.Count;i++)
{
   Guid resRowId = (Guid)projectTeamDS.ProjectTeam.Rows[i].ItemArray[1];
   if (resUID == resRowId)
   {
      projectTeamDS.ProjectTeam.Rows[i].Delete();
   }
}
Console.WriteLine(projectTeamDS.GetXml());
 
jobID = Guid.NewGuid();
QueueHandler queue = QueueHandler.GetInstance(URLPREFIX + psiBase);
try
{
   //try catch for project is allready cheched out
   project.CheckOutProject(ProjectUID, sessionID, "desc");
   project.QueueUpdateProjectTeam(jobID, sessionID, ProjectUID, projectTeamDS);
   queue.WaitForQueue(jobID);
} catch (Exception ex)
{ throw ex; }
finally
{
   project.QueueCheckInProject(jobID, ProjectUID, true,  
          sessionID, "desc");
   queue.WaitForQueue(jobID);
   Console.ReadKey();
}

Open in new window

0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn how ViaSat reduced average response times for IT incidents from 10 minutes to 30 seconds.
A simple overview of the possibilities of using technology for project management.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question