3

我正在尝试使用 Project Server 2013 CSOM,我可以进行身份​​验证、读取任何信息、创建新项目等,但是我对草稿项目有疑问,无论如何,当我想对草稿项目执行查询时,我会收到错误消息CSOMUnknownUser和任何东西。在我的搜索中,我没有得到有关此错误的特殊信息,这
是我的代码的一部分:

context = GetContext(pwaInstanceUrl);

// Retrieve publish project named "New Project"
// if you know the Guid of project, you can just call context.Projects.GetByGuid()
csom.PublishedProject project = GetProjectByName(projectName, context);
if(project == null)
   {
      Console.WriteLine("Failed to retrieve expected data, make sure you set up server data right. Press any key to continue....");
                return;
   }

csom.DraftProject draft = project.CheckOut();

   // Retrieve project along with tasks & resources
context.Load(draft, p => p.StartDate,                                                         
                                    p => p.Description);                                                      
context.Load(draft.Tasks, dt => dt.Where(t => t.Name == taskName));                           
context.Load(draft.Assignments, da => da.Where(a => a.Task.Name == taskName &&                
                                                                    a.Resource.Name == localResourceName));   
context.Load(draft.ProjectResources, dp => dp.Where(r => r.Name == localResourceName));       
context.ExecuteQuery();

我在最后一行收到错误context.ExecuteQuery()

4

3 回答 3

1

Please add user credential in projectcontext as below:

NetworkCredential cred = new NetworkCredential();
cred.Domain = "domain";
cred.UserName = "username";
cred.Password = "password";

context.Credentials = cred;
于 2016-05-05T05:52:26.377 回答
1

执行这些命令时: 尝试删除该位并检查您要查找的资源是否确实存在于 Project Server 上。请让我知道它是否有帮助context.Load(draft.Assignments, da => da.Where(a => a.Task.Name == taskName && a.Resource.Name == localResourceName));
context.Load(draft.ProjectResources, dp => dp.Where(r => r.Name == localResourceName));
da=>da.Where(r => r.Name == localResourceName)

于 2016-04-27T12:42:18.730 回答
0

我有同样的问题。问题是我试图编辑的项目已被签出。我使用此代码将其签入,然后我尝试完成其余的工作。这是首先检查它的代码:

 DraftProject draft;
        draft = pubPro.Draft;
        JobState job1 = projectContext.WaitForQueue(draft.CheckIn(true), 20);

        draft = pubPro.CheckOut();
        projectContext.Load(draft);
        projectContext.ExecuteQuery();
于 2019-01-31T09:03:00.617 回答