如何在microsoft project 2013 PWA csom中获取项目成本值

How to get project cost value in microsoft project 2013 PWA csom

我想在 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;