V
Vincenzo
I try to use Event handler in project server 2007, but I have this problem:
I write the event handler class and override the OnPublishing event, but I
can't access to the "ProjectDataSet" property of ProjectPrePublishEventArgs
"e". ProjectDataSet is null.... maybe I must initialize this property?
I have need to change the enterprice custom fields of the project while it
is publishing.
Event handler class code:
using System;
using Microsoft.Office.Project.Server.Events;
using Microsoft.Office.Project.Server.Library;
using System.Text;
using System.IO;
namespace TestEventHandler{
public class MyEventHandler : ProjectEventReceiver{
public override void OnPublishing(PSContextInfo contextInfo,
ProjectPrePublishEventArgs e){
e.Cancel = false;
TextWriter wr = new StreamWriter("c:\\temp\\log.txt", true);
wr.WriteLine(DateTime.Now.ToString() + " - publishing: " +
e.ProjectName + " user: " + contextInfo.UserName + " - " +
contextInfo.UrlZone + " - " + contextInfo.Lcid);
if(e.ProjectDataSet == null)
wr.WriteLine(DateTime.Now.ToString() + "dataset: null");
else
wr.WriteLine(DateTime.Now.ToString() + "dataset: " +
e.ProjectDataSet.DataSetName);
wr.Close();
}
}
}
I write the event handler class and override the OnPublishing event, but I
can't access to the "ProjectDataSet" property of ProjectPrePublishEventArgs
"e". ProjectDataSet is null.... maybe I must initialize this property?
I have need to change the enterprice custom fields of the project while it
is publishing.
Event handler class code:
using System;
using Microsoft.Office.Project.Server.Events;
using Microsoft.Office.Project.Server.Library;
using System.Text;
using System.IO;
namespace TestEventHandler{
public class MyEventHandler : ProjectEventReceiver{
public override void OnPublishing(PSContextInfo contextInfo,
ProjectPrePublishEventArgs e){
e.Cancel = false;
TextWriter wr = new StreamWriter("c:\\temp\\log.txt", true);
wr.WriteLine(DateTime.Now.ToString() + " - publishing: " +
e.ProjectName + " user: " + contextInfo.UserName + " - " +
contextInfo.UrlZone + " - " + contextInfo.Lcid);
if(e.ProjectDataSet == null)
wr.WriteLine(DateTime.Now.ToString() + "dataset: null");
else
wr.WriteLine(DateTime.Now.ToString() + "dataset: " +
e.ProjectDataSet.DataSetName);
wr.Close();
}
}
}