【问题标题】:CSOMUnknownUser error on working with draft project in Project Server 2013 CSOM在 Project Server 2013 CSOM 中处理草稿项目时出现 CSOMUnknownUser 错误
【发布时间】:2016-08-21 05:55:05
【问题描述】:

我正在尝试使用 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()

【问题讨论】:

    标签: c# csom project-server ms-project-server-2013


    【解决方案1】:

    执行这些命令时: 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) 位并检查您要查找的资源是否确实存在于Project Server 上。 如果有帮助请告诉我

    【讨论】:

    • 项目、资源和任务有时会存在,我认为它与项目签出状态有关。我尝试了您建议的更改,但仍然出现该错误
    【解决方案2】:

    请在项目上下文中添加用户凭据,如下所示:

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

    【讨论】:

    • 凭证的默认值为当前用户,不需要设置凭证
    • 是的,但是请检查项目是否已经checkout,如果是,必须先check-in。
    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-01-08
      • 1970-01-01
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      • 2016-04-15
      • 2016-08-27
      • 2015-11-28
      相关资源
      最近更新 更多