Impersonation

D

David L. Collison

I'm attempting to read the timesheets for active resources within Project
Server 2007. I can successfully read the resources from the PSI interface.
But whenever I attempt to utilize the ReadTimesheetList the system returns 0
rows. I know that there are active timesheets in the system because I have
run reports through the PWA interface. Note, I have attempted to read using
the GUID passed in to the function as well as the impersonated GUID - either
way I get 0 records back.

Here is the snippet of code:

public void GetResourceTimeSheets(String psAccountName, Guid
poAccountGuid, Guid poSiteId)
{
try
{
bool isWindowsUser = true;

pwaTimesheet.TimesheetDataSet.HeadersDataTable
loHdrTimeSheets;


Guid impersonatedResUserGuid =
moResourceDerived.GetCurrentUserUid();

if (psAccountName.Contains("aspnetsqlmembershipprovider"))
isWindowsUser = false;

ResourceDerived.SetImpersonationContext(isWindowsUser,
psAccountName,
impersonatedResUserGuid, Guid.Empty, poSiteId, "1033");

moTimeSheetList =
moTimeSheetDerived.ReadTimesheetList(impersonatedResUserGuid, mdStart,
mdFinish, Convert.ToInt32(PSLibrary.TimesheetEnum.ListSelect.Submitted));

Console.WriteLine(string.Format("\n\tTime Sheet Count: {0}",
moTimeSheetList.Timesheets.Count));

foreach (pwaTimesheet.TimesheetDataSet loTimeSheetRow in
moTimeSheetList.Timesheets)
{
loHdrTimeSheets = loTimeSheetRow.Headers;
foreach (pwaTimesheet.TimesheetDataSet.HeadersRow
loHdrTimeSheet in loHdrTimeSheets)
{
Console.WriteLine("Header Resource Id: " +
loHdrTimeSheet.RES_UID);
Console.WriteLine("Timesheet Id: " +
loHdrTimeSheet.TS_UID);
Console.WriteLine("Hdr Actual Value: " +
loHdrTimeSheet.TS_TOTAL_ACT_VALUE);
}
}
}
catch (System.Web.Services.Protocols.SoapException ex)
{
Console.WriteLine("GetResourceTimeSheets Exception
Encountered: " + ex.ToString());
}
finally
{
// Do Nothing
}
}

Thank you ...
 

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