quinta-feira, 9 de fevereiro de 2012

Strange But True: Reading Timesheets

According to the Project 2010 SDK, there's little difference in using TimeSheet.ReadTimesheetByPeriod - "Gets the timesheet header, line items, and timephased data based on the specified period and resource." - or TimeSheet.ReadTimesheet - "Gets the specified timesheet header, line items, and timephased data." - except the number/type of parameters; the first method takes in the resource ID, period ID and "navigation", the second just the timesheet ID.

The fact is i've been getting a different number of timesheet lines by calling one or the other, being TimeSheet.ReadTimesheetByPeriod the one that returns fewer lines. It can't be an issue with the tasks/assignments because they are visible in the Timesheet web form, and even if that was the case, there would still be no explanation why those lines are returned by TimeSheet.ReadTimesheet.

In any case, here's a simple workaround:
  TimesheetDataSet timesheetSet = timesheetClient.ReadTimesheetByPeriod(resourceUID, periodUID, SvcTimeSheet.Navigation.Current);
  timesheetSet = timesheetClient.ReadTimesheet(timesheetSet.Headers[0].TS_UID);

Soundtrack for this finding:
Megadeth - Skin O'My Teeth, Foreclosure Of A Dream