使用CSOM - Project Server 2013将任务添加到项目 [英] Add task to project using CSOM - Project Server 2013

查看:162
本文介绍了使用CSOM - Project Server 2013将任务添加到项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我正在尝试使用CSOM向项目中添加任务,但我总是得到一个例外作为回报。

这是我的一段代码:



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);
}

我总能看到成功!因此,但在Project Online中我看到此错误:



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


  • GeneralQueueException:

    • GeneralQueueException (9131)。 Detalles:ID =" 9131’ 名称=" GeneralQueueException为" uid =" eb7f7781-2410-e311-98be-00155d00480b" MESSAGEID =" 2’ 例外=" System.NullReferenceException:对象不设置为一个对象的一个​​实例。在Microsoft.Office.Project.Server.BusinessLayer.ProjectEngineUpdate.HandleSSPUpdates()在Microsoft.Office.Project.Server.BusinessLayer.ProjectEngineUpdate.HandleUpdate
      ()在Microsoft.Office.Project.Server.BusinessLayer.ProjectQueueDispatch.HandleProject2 (MessageContext的mContext,ProjectMain项目,ServerEventManager SEM,ProjectDataSet数据集,
      的Guid projectUid,的Guid sessionUid)在Microsoft.Office.Project.Server.BusinessLayer.ProjectQueueDispatch.InternalDispatchMessage(IPlatformContext上下文中,消息MSG,组messageGroup,JobTicket jobTicket, MessageContext mContext)'。
    • 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)'.

      • 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"消息类型= 'ProjectUpdate2Message' 的MessageId = '2' 阶段= '' CorrelationUID = '4a8e3d9c-baea-b083-4282-05d97120a1cf'。第obtener更多资料,compruebe阙EL ULS inicie使sesion烯EL EQUIPO
        59c3d949-216d-472d降低-a8b1-2b2f33b57f66 第拉斯入住日期CON JobUID
        854bbd7f-2410到e311-99a4-00155d9cbe08 。 
      • 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 JobUID 854bbd7f-2410-e311-99a4-00155d9cbe08

      推荐答案

      问题是否成功?

      Any success with the issue?

      删除任务时我也遇到同样的错误。

      I also have the same error when removing task.


      这篇关于使用CSOM - Project Server 2013将任务添加到项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆