zoukankan      html  css  js  c++  java
  • 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中的方法,报:未将对象引用设置到对象的实例! 嘿嘿,家常便饭,但是你实在无从调试起阿。也不知道是那个列少了,总之一句话:你还是都留着吧!

    msn: pccai1983@hotmail.com
  • 相关阅读:
    leveldb实现类sql查询
    系统设计
    Code Complete
    工具 VSCode快捷键
    C/C++ extern
    C/C++ 宏字符串拼接
    【Java】字符串
    【Java】常用类-sysytem-math
    【Java】枚举
    【Java】内部类
  • 原文地址:https://www.cnblogs.com/pccai/p/2084837.html
Copyright © 2011-2022 走看看