"Advanced" eventhandling in Project Server 2007

Y

YonZo

Hi all!

I've successfully created a basic eventhandler based on the
TimeSheetEventReceiver-class, more spesifically the "OnSubmitting"-event.
(I'm using the pre-event so I can cancel out of the operation if nessesary).

This works fine, but problems occur when trying to do a bit more than just
writing "Hello World" to the Event log.
What I would like to do is to store the reported timesheet-information in a
separate database.

My problem is that I can't figure out how to retrieve the information in the
timesheet!
Both the PScontextInfo- and the TimesheetPreSubmitEventArgs- objects has
very limited information.

How can I access the related TimeSheetLines, or the timesheetowner
(resource) for that matter??
Hope you can help me out here!!

Regards,
YonZo
 
M

Maik

Hi YonZo,

try to use the TimesheetPreSubmitEventArgs e.TsUID to call the
public TimesheetDataSet ReadTimesheet (Guid tsUID) TimeSheet WebService
method

Regards,
Maik
 
Y

YonZo

Hi Maik, and thanx for the quick reply!!

So I have to do PSI-calls even though I'm "inside the application-logic"...
Do you know of any code-examples showing how to do this??
I'm not thinking of examples on standard PSI-calls, but rather PSI-calls
from a custom eventhandler. I'm sure there's some tips and tricks that I
could take advantage of - maybe a nifty way of retrieving the webservice-url
for instance.

I've also read somewhere that you are identified as "Network User" within
the custom eventhandler, which could cause problems when calling the
webservices.

So if you have any references to resources on this issue, I'd be more than
grateful!

Thanx again!!

Regards,
YonZo
 
M

Maik

Hi YonZo,

you can call WebService methods from the eventhandler the same way as you
call them from a web/windows application. In the eventhandler code do
something like this:

public class TimeSheetSubmitHandler : TimesheetEventReceiver
{
public override void OnSubmitting(PSLibrary.PSContextInfo contextInfo,
TimesheetPreSubmitEventArgs e)
{
// webservice instance
TimeSheetWebSvc.TimeSheet timeSheetSvc = new TimeSheetWebSvc.TimeSheet();

// TimeSheetDataSet for return value
TimeSheetWebSvc.TimesheetDataSet _dsTimeSheet;

// get the complete timesheet
_dsTimeSheet = timeSheetSvc.ReadTimesheet(e.TsUID);

// Use debug mode to see the values or write the dataset as xml string to
the eventlog
myLog = new EventLog();
myLog.Source = "TimeSheetDataSet";
mylog.WriteEntry(_dsTimeSheet.GetXml(), EventLogEntryType.Information ,
9999);
}
}

Set the right references to the webservice and namespace and the code above
should work.

Yes you´re identified as Network User /System Account in the custom event
handler (to verify this use the public Guid GetCurrentUserUid () method from
the Resource WebService). This causes problems only if you want to use
methods with a user guid parameter. If you want/must do this you´ve to use
Impersonation.

I´m searching for Information, code samples etc too. Maybe you´ve a look at
the Microsoft Blogs like http://blogs.msdn.com/project_programmability/,
they´re always a good choice i think.
Generally, not every sample (SDK/websites) works well for me, a not shown or
missing parameter in the sample code or something like this, costs me some
hours of searching :)


Hope this helps you a little bit.

Regards
Maik
 
Y

YonZo

Thanx again Maik - guys like you make the world (/us developers) move
forwards! ;o)

If you happen to stumble across how to retrieve the different
webservice-urls from within my eventhandler, I'd really appreciate it if you
could post it here!

What I'd like to do is to "re-use" the logic that (I guess) allready is in
use in the applicationlogic today.

English is not my native language, so just to clearify what I mean;
When for instance a project is saved, the client makes a call to the PSI by
referencing the correct url. My question is simply, in what way does the
client retrieve the url?

I'm considering creating a new post for this question... :eek:)

Regards,
YonZo
 
M

Maik

Hi YonZo,

sry long time no post cause of holiday :)

At the moment i had hardwired the psi url´s for testing reasons. Only thing
i read dynamically is the machine name for the ssp url that i have to use for
the impersonation.

btw, you noticed the isWindowsUser value of the contextInfo object from the
TimesheetEventHandler ? On all our dev systems (all with windows auth) it´s
always "No", so if you want to use impersonation you´ve to build a new
contextInfo object to pass it to the websvc derived class.

Regards
Maik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top