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


__EOF__

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