我想在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;
答案 0 :(得分:0)
[解决]
我用过这个
dr["Cost"] = pubProj.CurrencySymbol + pubProj.Tasks[0].ActualCost;