我想在Gridview中显示来自Project Server的信息。
但我无法获得项目成本的价值。
这是我获取项目成本价值的方法
projContext = new ProjectContext(pwaPath)
projContext.Credentials = new NetworkCredential(username, secpassword);
// Get the list of published projects in Project Web App.
projContext.Load(projContext.Projects,
Pro => Pro.IncludeWithDefaultProperties(
projectDetail => projectDetail.Id,
projectDetail => projectDetail.Name,
projectDetail => projectDetail.StartDate,
projectDetail => projectDetail.FinishDate,
projectDetail => projectDetail.Tasks,
projectDetail => projectDetail.PercentComplete,
projectDetail => projectDetail.Assignments,
projectDetail => projectDetail.ProjectResources,
projectDetail => projectDetail.CustomFields,
projectDetail => projectDetail.PercentComplete,
projectDetail => projectDetail.CurrencySymbol,
projectDetail => projectDetail.Assignments.IncludeWithDefaultProperties(
task => task.ActualCost),
projectDetail => projectDetail.DefaultOvertimeRate,
projectDetail => projectDetail.SpreadActualCostsToStatus));
projContext.ExecuteQuery();
DataTable dt = new DataTable();
dt.Clear();
dt.Columns.Add("ProjectID");
dt.Columns.Add("ProjectName");
dt.Columns.Add("Start");
dt.Columns.Add("End");
dt.Columns.Add("PercentComplete");
dt.Columns.Add("Cost");
foreach (PublishedProject pubProj in projContext.Projects)
{
DataRow dr = dt.NewRow();
dr["ProjectID"] = pubProj.Id.ToString();
dr["ProjectName"] = pubProj.Name;
dr["Start"] = pubProj.StartDate.ToString("yyyy-MM-dd");
dr["End"] = pubProj.FinishDate.ToString("yyyy-MM-dd");
dr["PercentComplete"] = pubProj.PercentComplete.ToString();
dr["Cost"] = pubProj.CurrencySymbol + pubProj.SpreadActualCostsToStatus;
dt.Rows.Add(dr);
}
如何在Microsoft Project Server中获得项目成本值?
[解决了]
我用这个
dr["Cost"] = pubProj.CurrencySymbol + pubProj.Tasks[0].ActualCost;
最佳答案
[解决了]
我用这个
dr["Cost"] = pubProj.CurrencySymbol + pubProj.Tasks[0].ActualCost;