• Project Server PSI的简单调用方式


    当我们调用PSI进行开发时候,通常要处理各种Web Service调用情况,包括权限等处理,容易出错。我们分析12目录下PWA产品相关页面,发现很多时候在aspx页面直接调用如下对象:

    PJContext.Current.PSI

    在我们创建一个简单的页面并添加引用,默认本地磁盘可能是找不到这些文件的,都在GAC中,若是需要这些文件可以从GAC中复制出来即可:

    using Microsoft.Office.Project.Server.Library;

    using Microsoft.Office.Project.PWA;

    using Microsoft.SharePoint.Utilities;

    using Microsoft.Office.Project.Server.Schema;

     

    之后发现PSI对象中已经处理好了各种我们需要的Web Service 及公开的方法:

    public class PSI

    {

    public PSI();

     

    public Admin AdminWebService { get; }

    public Archive ArchiveWebService { get; }

    public Assignment AssignmentWebService { get; }

    public Authentication AuthenticationWebService { get; }

    public Calendar CalendarWebService { get; }

    public CubeAdmin CubeAdminWebService { get; }

    public CustomFields CustomFieldsWebService { get; }

    public Events EventsWebService { get; }

    public LookupTable LookupTableWebService { get; }

    public Notifications NotificationsWebService { get; }

    public ObjectLinkProvider ObjectLinkProviderWebService { get; }

    public Project ProjectWebService { get; }

    public PWA PWAWebService { get; }

    public QueueSystem QueueSystemWebService { get; }

    public ResourcePlan ResourcePlanWebService { get; }

    public Resource ResourceWebService { get; }

    public Security SecurityWebService { get; }

    public Statusing StatusingWebService { get; }

    public TimeSheet TimeSheetWebService { get; }

    public View ViewWebService { get; }

    public WssInterop WssInteropWebService { get; }

     

    public class ProxyContainer

    {

    public Admin AdminWebService;

    public Archive ArchiveWebService;

    public Assignment AssignmentWebService;

    public Authentication AuthenticationWebService;

    public Calendar CalendarWebService;

    public CubeAdmin CubeAdminWebService;

    public CustomFields CustomFieldsWebService;

    public Events EventsWebService;

    public LookupTable LookupTableWebService;

    public Notifications NotificationsWebService;

    public ObjectLinkProvider ObjectLinkProviderWebService;

    public Project ProjectWebService;

    public PWA PWAWebService;

    public QueueSystem QueueSystemWebService;

    public ResourcePlan ResourcePlanWebService;

    public Resource ResourceWebService;

    public Security SecurityWebService;

    public Statusing StatusingWebService;

    public TimeSheet TimeSheetWebService;

    public View ViewWebService;

    public WssInterop WssInteropWebService;

     

    public ProxyContainer();

    }

    }

     

    如上表所示,基本上所有的服务都涉及到了,而它们的调用无需我们引用Web Service、处理用户凭证等复杂工作,比喻读取任务路径:

     

    我们只需要在用户控件或者WebPart中写如下代码:

    Guid taskid = new Guid(Request["taskid"]);

     

    SummaryTaskPathDataSet ds = PJContext.Current.PSI.StatusingWebService.ReadSummaryTaskPath(taskid);

    StringBuilder path = new StringBuilder();

    DataRowCollection rows = ds.SummaryTaskPath.Rows;

     

    if (rows.Count > 0)

    {

    for (int i = rows.Count - 1; i >= 0; i--)

    {

    string taskname = String.Format("<nobr>{0}</nobr><br>\n", SPHttpUtility.HtmlEncode(rows[i][PSDBField.TASK_NAME].ToString()));

    path.Append(taskname);

    for (int j = i; j < rows.Count; j++) path.Append("&nbsp;&nbsp;-");

    }

    }

     

    pathtext.Controls.Add(new LiteralControl(path.ToString()));

    有了以上代码很容易通过自助构造任务WBS显示方式,如下:

    接下来会陆续贴上其它在项目中用到的功能,当然单点调试只能附加进程了,iisapp

    msn: pccai1983@hotmail.com
  • 相关阅读:
    SkyWalking结合Logback获取全局唯一标识 trace-id 记录到日志中
    Mysql数据库优化技术
    MySQL中集合的差的运算方法
    深入理解Java ClassLoader及在 JavaAgent 中的应用
    自制吸锡带
    Ubuntu下双显示器设定
    ffmpeg 命令的使用
    ifeq ifneq ifdef ifndef
    字符对齐
    ruby on rails使用gmail的smtp发送邮件
  • 原文地址:https://www.cnblogs.com/pccai/p/2084467.html
Copyright © 2020-2023  润新知