Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Editting TimeSheets with the PSI QueueUpdateTimesheet

$
0
0

Would some one who has been successful with editting TimeSheets via QueueUpdateTimesheet() help us out with a look at this code? 

Variables:

DateTime [] dates; // arrays are same size
decimal [] actuals;
Guid tsLineGuid;   // from existing TimeSheet

try
{
   SvcAdmin.TimesheetLineClassDataSet tsLineClassDs =
      adminClient.ReadLineClasses(SvcAdmin.LineClassType.AllNonProject, SvcAdmin.LineClassState.Enabled);

// delta TS is the difference in previous to new timesheet SvcTimeSheet.TimesheetDataSet deltaTsDs = new SvcTimeSheet.TimesheetDataSet(); SvcTimeSheet.TimesheetDataSet.HeadersRow headersRow = deltaTsDs.Headers.NewHeadersRow(); headersRow.RES_UID = resourceGuid; headersRow.TS_UID = timeSheetGuid; headersRow.WPRD_UID = periodGuid; headersRow.TS_CREATOR_RES_UID = managerGuid; headersRow.TS_NAME = "Delta Timesheet " + periodStartDate + " to " + periodFinishDate; headersRow.TS_COMMENTS = "Delta Timesheet created by Web Part."; headersRow.TS_ENTRY_MODE_ENUM = (byte)PSLibrary.TimesheetEnum.EntryMode.Daily; deltaTsDs.Headers.AddHeadersRow(headersRow);
SvcTimeSheet.TimesheetDataSet.LinesRow line = deltaTsDs.Lines.NewLinesRow(); line.TS_UID = timeSheetGuid; line.TS_LINE_UID = tsLineGuid; line.TS_LINE_CLASS_UID = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_UID; line.TS_LINE_COMMENT = "Timesheet created by Web Part."; line.TS_LINE_STATUS = (byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable; line.TS_LINE_VALIDATION_TYPE = (byte)PSLibrary.TimesheetEnum.ValidationType.Unverified; line.TS_LINE_CACHED_ASSIGN_NAME = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_DESC; deltaTsDs.Lines.AddLinesRow(line);
// add actuals for (int i = 0; i < dates.Length; i++) { SvcTimeSheet.TimesheetDataSet.ActualsRow actual = deltaTsDs.Actuals.NewActualsRow(); actual.TS_LINE_UID = tsLineGuid; actual.TS_ACT_VALUE = actuals[i]; actual.TS_ACT_START_DATE = dates[i]; actual.TS_ACT_FINISH_DATE = dates[i]; deltaTsDs.Actuals.AddActualsRow(actual); }
timeSheetClient.PrepareTimesheetLine(timeSheetGuid, ref deltaTsDs, new Guid[] { tsLineGuid }); timeSheetClient.QueueUpdateTimesheet(timeSheetGuid, jobGuid, deltaTsDs);
} catch (SoapException ex) { throw new Exception(ex.Message); } catch (WebException ex) { throw new Exception(ex.Message); } catch (Exception ex) { throw new Exception(ex.Message); }

The error is coming via a GridView Editing Javascript window:

Message: Sys.WebForms.PageRequestManagerServerErrorException: ProjectServerError(s) LastError=GeneralItemDoesNotExist Instructions: Pass this into PSClientError constructor to access all error information
Line: 4723
Char: 21
Code: 0
URI: http://<my_url>/ScriptResource.axd?d=...
The goal is to take delta hours and update an existing TimeSheet with them.  I tried using the tsLineGuid and timeSheetGuid from the existing TimeSheet and I tried creating them anew with Guid.NewGuid(); 

Jonathan M Beck


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>