Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Add task to project using CSOM - Project Server 2013

$
0
0

Hi. I'm trying to add a task to a project using CSOM, but I always get an exception in return.
Here's a piece of my code:

using (projContext = new ProjectContext(pwaPath))
{
    SecureString passWord = new SecureString();
    foreach (char c in connectPwd.ToCharArray()) passWord.AppendChar(c);
    projContext.Credentials = new SharePointOnlineCredentials(connectUserName, passWord);
}

var projCollection = projContext.LoadQuery(
    projContext.Projects
        .Where(p => p.Name == projName));

projContext.ExecuteQuery();

if (projCollection.Count() > 0)
{
    PublishedProject proj2Edit = projCollection.First();

    DraftProject projCheckedOut = proj2Edit.CheckOut();

    // Create a task.
    TaskCreationInformation newTask = new TaskCreationInformation();
    newTask.Name = "Test";
    newTask.IsManual = false;
    newTask.Duration = "3d";
    newTask.Start = DateTime.Today;

    // Add the task to the checked out project.
    projCheckedOut.Tasks.Add(newTask);
    projCheckedOut.Publish(true);

    // Update the published projects collection.
    QueueJob qJob = projContext.Projects.Update();
    JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);

    if (jobState == JobState.Success)
    {
        Console.WriteLine("\nSuccess!");
    }
    else
    {
        Console.WriteLine("\nThere is a problem in the queue. Timeout is {0} seconds.",
            timeoutSeconds);
    }
}
else
{
    Console.WriteLine("\nNo project with the name '{0}'", projName);
}

I always see Success! as a result, but in Project Online I see this error:

  • GeneralQueueException:
    • GeneralQueueException (9131). Detalles: id='9131' name='GeneralQueueException' uid='eb7f7781-2410-e311-98be-00155d00480b' messageID='2' exception='System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.Project.Server.BusinessLayer.ProjectEngineUpdate.HandleSSPUpdates() at Microsoft.Office.Project.Server.BusinessLayer.ProjectEngineUpdate.HandleUpdate() at Microsoft.Office.Project.Server.BusinessLayer.ProjectQueueDispatch.HandleProject2(MessageContext mContext, ProjectMain project, ServerEventManager sem, ProjectDataSet dataset, Guid projectUid, Guid sessionUid) at Microsoft.Office.Project.Server.BusinessLayer.ProjectQueueDispatch.InternalDispatchMessage(IPlatformContext context, Message msg, Group messageGroup, JobTicket jobTicket, MessageContext mContext)'.
  • Queue:
    • GeneralQueueJobFailed (26000) - ProjectUpdate.ProjectUpdate2Message. Detalles: id='26000' name='GeneralQueueJobFailed' uid='ec7f7781-2410-e311-98be-00155d00480b' JobUID='854bbd7f-2410-e311-99a4-00155d9cbe08' ComputerName='59c3d949-216d-472d-a8b1-2b2f33b57f66' GroupType='ProjectUpdate' MessageType='ProjectUpdate2Message' MessageId='2' Stage='' CorrelationUID='4a8e3d9c-baea-b083-4282-05d97120a1cf'. Para obtener más información, compruebe que el ULS inicie sesión en el equipo 59c3d949-216d-472d-a8b1-2b2f33b57f66 para las entradas con JobUID854bbd7f-2410-e311-99a4-00155d9cbe08


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>