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

本文关键字:获取 项目 csom PWA microsoft project 2013 | 更新日期: 2023-09-27 18:15:10

我想在Gridview中显示来自项目服务器的信息。但是我不知道项目成本的价值。

这是我获得项目成本值的方法

    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;

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

[SOLVED]

我用了这个

dr["Cost"] = pubProj.CurrencySymbol + pubProj.Tasks[0].ActualCost;