对于一个项目,我必须将时间从外部程序同步到EPM。不需要使用EPM 2013的客户端对象模型或PSI。但是因为微软在他们的网站上推荐所有新的应用程序,所以我尝试用CSOM来实现它。我想要测试的第一件事是用下面的代码获取所有的时间:(这不是最漂亮的代码,因为它是用于测试的)
private static void GetTimesheets()
{
ProjectContext projContext = new ProjectContext("http://tfspsdemo/PWA/");
projContext.Load(projContext.TimeSheetPeriods);
projContext.ExecuteQuery();
foreach (var period in projContext.TimeSheetPeriods)
{
projContext.Load(period.TimeSheet);
projContext.ExecuteQuery();
Console.WriteLine(period.Name);
try
{
string tempName = period.TimeSheet.Name;
projContext.Load(period.TimeSheet.Lines);
projContext.ExecuteQuery();
Console.WriteLine(period.TimeSheet.Name);
foreach (var line in period.TimeSheet.Lines)
{
try
{
projContext.Load(line);
projContext.Load(line.Work);
projContext.ExecuteQuery();
foreach (var workLine in line.Work)
{
Console.WriteLine(workLine.ActualWork);
}
}
catch (Exception) { }
Console.WriteLine("Total: {0}", line.TotalWork);
}
}
catch (ServerObjectNullReferenceException) { }
}
}但是使用上面的代码,我只得到当前登录用户的代码,即使它是一个有权查看其他用户时间的人。但我想看到的是,所有已经在EPM中为特定项目计划预订了时间的人的所有时间。因此,以后我可以使用这些信息将时间从外部程序同步到EPM。我以为我可以冒充来解决这个问题,但是:
ProjectContext projContext = new ProjectContext("http://tfspsdemo/PWA/");
projContext.Credentials = new NetworkCredentials("username", "password");但这不是我想要的,因为我必须为每个用户这样做。而且我也不能得到所有用户的密码。
现在有谁能解决这个问题和/或任何建议吗?解决方案与EPM PSI也是感谢!
提前感谢!
发布于 2018-06-25 12:27:43
发布于 2014-02-19 14:14:22
Proect server 2013有两种模式。Proect服务器和SharePoint模式。我能够让上面的内容在SharePoint模式下工作,但遗憾的是,即使在传递凭据之后,我也无法读取即使在Project模式下的时间表周期。您当前在服务器上运行的模式是什么?
发布于 2014-04-08 09:24:55
这可能有点晚了,但是要在提供者/自动托管的应用程序中访问这类数据,您需要通过OData访问sharepoint服务器。CSOM只打算提供来自当前用户上下文的数据。
https://stackoverflow.com/questions/19982850
复制相似问题