简体   繁体   English

在 Project Server 2013 CSOM 中处理草稿项目时出现 CSOMUnknownUser 错误

[英]CSOMUnknownUser error on working with draft project in Project Server 2013 CSOM

I'm trying to work with Project Server 2013 CSOM and I can authenticate, read any information, create new project and so, but I have problem with draft projects, in any way when I want to execute query on draft project I receive error message CSOMUnknownUser and any thing.我正在尝试使用 Project Server 2013 CSOM,我可以进行身份验证、读取任何信息、创建新项目等,但是我对草稿项目有疑问,无论如何,当我想对草稿项目执行查询时,我会收到错误消息CSOMUnknownUser和任何东西。 In my search's I didn't get special information about this error and在我的搜索中,我没有得到有关此错误的特殊信息,并且
here is part of my codes:这是我的代码的一部分:

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

I receive error on last line context.ExecuteQuery()我在最后一行context.ExecuteQuery()收到错误

When executing these commands: 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.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.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));
try to remove the da=>da.Where(r => r.Name == localResourceName) bit and check if the Resource you are looking for really exists on the Project Server. 尝试删除da=>da.Where(r => r.Name == localResourceName)位并检查您要查找的资源是否确实存在于Project Server上。 Please let me know if it helped 如果有帮助,请告诉我

Please add user credential in projectcontext as below: 请在projectcontext中添加用户凭证,如下所示:

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

context.Credentials = cred;

I had the same problem. 我有同样的问题。 the problem was that the project which I was trying to edit, was checked out. 问题是我试图编辑的项目已经签出。 I used this code to check it in , then I tried to do the rest of the job. 我用这段代码来检查它,然后我尝试完成剩下的工作。 here is the code to check it in first: 这是首先检查它的代码:

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

        draft = pubPro.CheckOut();
        projectContext.Load(draft);
        projectContext.ExecuteQuery();

You must use the elevated permission for checkout the draft project.您必须使用提升的权限来签出草稿项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM