Error creating tasks

I

Ismael

I have the next method for creating tasks into a existing project:

public void CreateTask(string ProjectID, string TaskName
, string start, string duration)
{
try
{
Guid projectGuid = new Guid(ProjectID);
Guid sessionGuid = Guid.NewGuid();
const string SESSION_DESC = "description";

project.CheckOutProject(projectGuid, sessionGuid, SESSION_DESC);

dsProject = new
w2003wss1.ProjectDataSet(); w2003wss1.ProjectDataSet.TaskRow taskRow =
dsProject.Task.NewTaskRow();

Guid taskGuid = Guid.NewGuid();
taskRow.PROJ_UID = projectGuid;
taskRow.TASK_UID = taskGuid;
taskRow.TASK_NAME = TaskName;
taskRow.TASK_START_DATE = DateTime.Parse(start);
taskRow.TASK_DUR = Convert.ToInt32(duration);
taskRow.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.EstHour;

dsProject.Task.AddTaskRow(taskRow);

Guid jobGuid = Guid.NewGuid();
bool validateOnly = false;
project.QueueUpdateProject(jobGuid, sessionGuid, dsProject, validateOnly);

System.Threading.Thread.Sleep(5000);

jobGuid = Guid.NewGuid();
project.QueueCheckInProject(jobGuid, projectGuid, false, sessionGuid,
SESSION_DESC);
}
catch (Exception e)
{
throw e;
}
}

When CheckOutProject() method is executed, an exception appears:

System.Web.Services.Protocols.SoapException: ProjectServerError(s)
LastError=CICOCheckedOutInOtherSession Instructions: Pass this into
PSClientError constructor to access all error information
at
Microsoft.Office.Project.Server.WebService.Project.CheckOutProject(Guid
projectUid, Guid sessionUid, String sessionDescription)

What happen? How can I solve this problem?
 
C

Chris Boyd

By looking at the exception you got, the project you are trying to create a
task for is already checked out in another session. You can force check in
the project by calling the force check in method before commiting the
changes, but this may cause issues if someone else has it checked out and is
updating the project. Their changes will be lost. If you are always getting
this error, your most likely not checking in the project somewhere else in
your code.
 
D

David

Instead of get exception on the time to checkout the project, is there any
method in psi like the one in object module CanCheckOut call?
 
B

brian logan

you need to "unravel" this error to get at the actual error messages, and each errors attributes.

Here is how I do it....

catch (SoapException ex1)
{
string errMess = "";

errMess += "\n" + ex1.Message.ToString();
errMess += "\n";
PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex1);
PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();

errMess += "Unravelled Exception Details...\n";
for (int j = 0; j < errors.Length; j++)
{
errMess = errMess + "ErrId" + j.ToString() + ":" + errors[j].ErrId.ToString() + "\n";
errMess = errMess + "ErrName" + j.ToString() + ":" + errors[j].ErrName.ToString() + "\n";
errMess = errMess + "ErrorAttributes...\n";
for (int k=0; k<errors[j].ErrorAttributes.Length; k++)
{
errMess = errMess + "ErrorAttributes"+k.ToString()+":" + errors[j].ErrorAttributes[k].ToString() + "\n";
}
}

errMess += "templateGuidFromLookup:" + templateGuidFromLookup +"\n";
errMess += "templateNameFromLookup:" + templateNameFromLookup +"\n";
errMess += "projectNameToCreate:" + projectNameToCreate +"\n";

//display "unravelled" soap exception
string errorMessage = "SOAP Exception During Project Creation (ProvisionProject()) (code:434n45).. ";
string errorDetails = errMess;
LoggerUtil.LogException(errorMessage, errorDetails, ex1);

//re throw
throw new ApplicationException(errMess);
}
 

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