我正在尝试使用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()
答案 0 :(得分: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上。
如果有帮助请告诉我
答案 1 :(得分:1)
请在projectcontext中添加用户凭证,如下所示:
NetworkCredential cred = new NetworkCredential();
cred.Domain = "domain";
cred.UserName = "username";
cred.Password = "password";
context.Credentials = cred;
答案 2 :(得分:0)
我有同样的问题。问题是我尝试编辑的项目已签出。我使用此代码将其签入,然后尝试完成其余工作。 这是首先检查它的代码:
DraftProject draft;
draft = pubPro.Draft;
JobState job1 = projectContext.WaitForQueue(draft.CheckIn(true), 20);
draft = pubPro.CheckOut();
projectContext.Load(draft);
projectContext.ExecuteQuery();