Project Server Event Handler—程序设计流程
添加库引用
Using Microsoft.Office.Project.Server.Events;
Using Microsoft.Office.Project.Server.Library;
继承所需的Receiver类,重载相应事件的方法
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Project.Server.Events;
using Microsoft.Office.Project.Server.Library;
using System.Diagnostics;
using System.Data.Common;
using WayGo.Apms.BLL;
namespace WayGo.Apms.pwaEventHandlers
{
public class pwaPublished : ProjectEventReceiver
{
public override void OnPublished(PSContextInfo contextInfo, ProjectPostPublishEventArgs e)
{
try
{
base.OnPublished(contextInfo, e);
//2.1 从Project Server 取数据
pwaProject pwaproject = new pwaProject();
ProjectWebSvc.ProjectDataSet pwaData = pwaproject.ReadProject(e.ProjectGuid);
if (pwaData == null) return;
//2.2将数据导入本地数据库
string projectType = ssCommonFunction.getProjectType(pwaData);
if (projectType == "Programme")
{
ssProgramme ssprogramme = new ssProgramme();
ssprogramme.SubscibessProgramme(pwaData);
}
else
{
ssDeliverable ssdeliverable = new ssDeliverable();
Guid deliverableGuid = pwaData.Project[0].PROJ_UID;
Guid sectionGuid = ssCommonFunction.GetSectionGuid(deliverableGuid);
ssdeliverable.SubscibeDeliverable(pwaData, sectionGuid, deliverableGuid);
}
}
catch (Exception ex)
{
pwaEventHandlerLog.WriteEntry(ex.Message);
}
}
部署
设置DLL强名称
把DLL及相关引用拷贝到C:\Program Files\Microsoft Office Servers\12.0\Bin\ProjectServerEventHandlers
用gacutil命令把DLL注册到GAC里面
修改配置文件Microsoft.Office.Project.Server.Eventing.exe.config
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="ProjectServerEventHandlers"/>
</assemblyBinding>
</runtime>
<connectionStrings>
<add name="APMSProject" connectionString="Data Source=localhost;User ID=sa;Password=pass@word1;Initial Catalog=APMSProject;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="PWAUrl" value="http://10.20.88.99/PWA"/>
</appSettings></configuration>
浙公网安备 33010602011771号