none
Why doesn't this code produce Actuals lines in the Timesheet Data Set RRS feed

  • Question

  • I use this code to create an administrative line in my timesheet.  The Timesheet line gets added, but no actuals lines are generated (in the Actuals DataTable).  How can I accomplish this?

        private void PrepareTimesheet (Guid tsUID, SvcTimeSheet.TimesheetDataSet ds)
            {
                SvcAdmin.AdminClient adminSvc = new SvcAdmin.AdminClient();
                SvcAdmin.TimesheetLineClassDataSet tslcds = adminSvc.ReadLineClasses(SvcAdmin.LineClassType.AllNonProject, SvcAdmin.LineClassState.Enabled);
    
    
                SvcTimeSheet.TimesheetDataSet.LinesRow line = ds.Lines.NewLinesRow();
                line.TS_UID = tsUID;
                line.TS_LINE_UID = Guid.NewGuid();
                line.TS_LINE_CLASS_UID = tslcds.LineClasses[0].TS_LINE_CLASS_UID;
                line.TS_LINE_COMMENT = "Added by code sample.";
                line.TS_LINE_STATUS = (byte)PSLib.TimesheetEnum.LineStatus.NotApplicable;
                line.TS_LINE_VALIDATION_TYPE = (byte)PSLib.TimesheetEnum.ValidationType.Unverified;
                line.TS_LINE_CACHED_ASSIGN_NAME = tslcds.LineClasses[1].TS_LINE_CLASS_DESC;  // this is the vacation task
                ds.Lines.AddLinesRow(line);
    
                SvcTimeSheet.TimeSheetClient tsc = new SvcTimeSheet.TimeSheetClient();
                tsc.PrepareTimesheetLine(tsUID, ref ds, new Guid[] { line.TS_LINE_UID });
    
            }
    Thanks in advance!


    • Edited by BayouB Wednesday, May 23, 2012 9:48 PM
    Wednesday, May 23, 2012 9:46 PM

Answers

  • You need to fill the ds.Actuals table
    TimeSheetWS.TimesheetDataSet.ActualsRow actualsRow = ds.Actuals.NewActualsRow();
    actualsRow.TS_ACT_COMMENT = "code sample";
    // add 40h 8h
    actualsRow.TS_ACT_VALUE = 480000;
    // do this for each individual date
    actualsRow.TS_ACT_START_DATE = new DateTime(...);
    actualsRow.TS_ACT_FINISH_DATE = actualsRow.TS_ACT_START_DATE+AddDays(1)+AddMinutes(-1);
    // Your guid from above
    actualsRow.TS_LINE_UID = line.TS_LINE_UID;
    ds.Actuals.AddActualsRow(actualsRow);     
    


    Jan Cirpka

    • Marked as answer by BayouB Thursday, May 24, 2012 11:13 AM
    Thursday, May 24, 2012 5:27 AM

All replies

  • You need to fill the ds.Actuals table
    TimeSheetWS.TimesheetDataSet.ActualsRow actualsRow = ds.Actuals.NewActualsRow();
    actualsRow.TS_ACT_COMMENT = "code sample";
    // add 40h 8h
    actualsRow.TS_ACT_VALUE = 480000;
    // do this for each individual date
    actualsRow.TS_ACT_START_DATE = new DateTime(...);
    actualsRow.TS_ACT_FINISH_DATE = actualsRow.TS_ACT_START_DATE+AddDays(1)+AddMinutes(-1);
    // Your guid from above
    actualsRow.TS_LINE_UID = line.TS_LINE_UID;
    ds.Actuals.AddActualsRow(actualsRow);     
    


    Jan Cirpka

    • Marked as answer by BayouB Thursday, May 24, 2012 11:13 AM
    Thursday, May 24, 2012 5:27 AM
  • I always thought the Prepare Timesheet method was supposed to pre-populate actuals rows.  Thanks.
    Thursday, May 24, 2012 11:13 AM
  • Actuals filled, but the timesheet is empty. There is just a line to the task.
    Tuesday, August 28, 2012 11:10 AM
  • While we are discussing Actuals, when I look at the PSDB MSP_TimesheetActual I see many entries per Line ID. 

    If we are following this Update algorithm:

    1) Open a Timesheet

    2) Use an existing Line. (Not sure if I must use existing Lines or create a new Line everytime I update).

    3) Add Actuals

    Will this overwrite any Actuals that already exist for that Line?  Or does it always pull the newest ones? 

    What are the dangers of writing Actuals directly to the Reporting database?


    Jonathan M Beck

    • Edited by Beta Star Thursday, August 30, 2012 6:13 PM
    Thursday, August 30, 2012 6:08 PM