Project Server PSI的简单调用方式:读取我的问题和风险

PWA中其实已经内置了跨所有项目工作环境来查询其中的风险和问题,而不用我们再去写复杂的CAML来查询了,效果如下:

读取个数提醒:

读取处理结果摘要:

我们就想啊,人家已经写好了啊,想办法借鉴下实现代码吧:

// Fields

private const string ColNameActive = "Active";

private const string ColNameClosed = "Closed";

private const string ColNameListId = "ListId";

private const string ColNamePostponed = "Postponed";

private const string ColNameProjId = "ProjId";

private const string ColNameProjName = "ProjName";

private const string ColNameStatus = "Status";

private DataTable dtGrid;

//Method

this.dtGrid = new DataTable("GridTable", "Microsoft.Office.Project.Server");

this.dtGrid.Locale = CultureInfo.InvariantCulture;

this.dtGrid.Columns.Add("ListId", typeof(Guid));

this.dtGrid.Columns.Add("Active", typeof(int));

this.dtGrid.Columns.Add("Postponed", typeof(int));

this.dtGrid.Columns.Add("Closed", typeof(int));

DataTable dtItems = PJContext.Current.PSI.PWAWebService.ProjectPWSCrossSiteQueryForIssueRiskCenter(templateType).Tables[0];

if (dtItems.Rows.Count != 0)

{

while (true)

{

try

{

this.dtGrid = PjContext.PSI.PWAWebService.ProjectGetProjectDataForIssueRiskCenter(this.dtGrid, templateType);

}

catch (SoapException)

{

}

}

}

   

其中:PWSListTemplateType.Issues 问题,PWSListTemplateType.Risks 风险

   

从以上代码中很清楚的可以看到:PJContext.Current.PSI 又用到它了:

PJContext.Current.PSI.PWAWebService.ProjectPWSCrossSiteQueryForIssueRiskCenter(templateType).Tables[0];

既然是公开的Web Service 方法,那么还可以快速的查询到当前项目总数了:

Int totalNum = PJContext.Current.PSI.PWAWebService.ProjectReadProjectCount();

又或者我们需要读取所有有效资源列表,PWA自带效果页面如下:

后台查询数据代码:

ResourceDataSet RDS = PJContext.Current.PSI.PWAWebService.ResourceReadUserSummariesFilterByNameOrEmail(string filter);

若不过滤数据,则可以查询所有数据:

ResourceDataSet  RDS = PJContext.Current.PSI.PWAWebService.ResourceReadUserListAll();

 

这里要提到的是默认情况下,问题和风险都有自己默认的一些栏,这些是不能删除的,如下图:

最好也不要改名,当然自己追加的列是可以的,否则会出现异常哦,比如如下错误:

0x1304 Project Server                 Project Server - General       0 Exception Exception occurred in method PWA.ProjectGetProjectDataForIssueRiskCenter System.NullReferenceException: 未将对象引用设置到对象的实例。     在 System.Data.Index.CompareRecords(Int32 record1, Int32 record2)     在 System.Data.Index.IndexTree.CompareNode(Int32 record1, Int32 record2)     在 System.Data.RBTree`1.SearchSubTree(Int32 root_id, K key)     在 System.Data.RBTree`1.GetNodeByKey(K key)     在 System.Data.Index.ApplyChangeAction(Int32 record, Int32 action)     在 System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2)     在 System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Int32 position, Boolean fireEvent, Exceptio... 7df48253-33ed-4b7d-9503-cf5a160838da
06/20/2011 17:01:45.53

 

其中:ProjectGetProjectDataForIssueRiskCenter 就是我们PSI中的方法,报:未将对象引用设置到对象的实例! 嘿嘿,家常便饭,但是你实在无从调试起阿。也不知道是那个列少了,总之一句话:你还是都留着吧!


__EOF__

本文作者pccai
本文链接https://www.cnblogs.com/pccai/archive/2011/06/19/2084837.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   pccai  阅读(877)  评论(3编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2007-06-19 AD用户帐户属性对照表
点击右上角即可分享
微信分享提示