none
TimeSheet - Adding new project task line

    Pertanyaan

  • Hello,

    I am working on a time import integration project (using PSI) and am struggling with the step where I try to update my timesheet using PrepareTimesheetLine and then QueueUpdateTimesheet.

    FYI - I have had no trouble with any other service calls to this point, its just this call to QueueUpdateTimesheet that is driving me crazy.

    I can create admin tasks just fine, but whenever I try to create a LINE for a specific project task (the project and task already exists), the project ID always changes to 'cbbeeaf0-ca14-44ab-8a26-665d0cb086b4', which doesn't seem to be a valid PROJ_UID.  Surprisingly, the TASK_UID doesn't change.

    If you open the updated timesheet from PWA, it looks ok, except that the task is not linked, I'm guessing because its not referring to the correct project.

    Also, adding the same task to the timesheet manually via PWA shows additional columns being populated for the line that is different from when I try to do this programatically via the service call.

    Any suggestions or code samples would be greatly appreciated!!!

    Jumat, 18 Juni 2010 19.26

Jawaban

  • Hi,

    I use this code to create a new line in the PWA.

    //Timesheet Credentials
    timeSheetWS.Url = PROJECT_SERVER_URI + TIMESHEET_SERVICE_PATH;
    timeSheetWS.Credentials = CredentialCache.DefaultCredentials;

    //Timesheet Credentials
    adminWS.Url = PROJECT_SERVER_URI + ADMIN_SERVICE_PATH;
    adminWS.Credentials = CredentialCache.DefaultCredentials;

    TimesheetLineClassDataSet tsLineClassDs = adminWS.ReadLineClasses(WebSvcAdmin.LineClassType.All, WebSvcAdmin.LineClassState.Enabled);

    //read the timesheet
    WebSvcTimesheet.TimesheetListDataSet timeSheetList = timeSheetWS.ReadTimesheetList(userUID, date, date, 1);
    Guid timeSheetUID = (Guid)timeSheetList.Tables[0].Rows[timeSheetList.Tables[0].Rows.Count - 1]["TS_UID"];   
    WebSvcTimesheet.TimesheetDataSet timeSheetDS = timeSheetWS.ReadTimesheet(timeSheetUID);

    WebSvcTimesheet.TimesheetDataSet.LinesRow line = timeSheetDS.Lines.NewLinesRow();

    line.TS_UID = timeSheetUID;
    line.TS_LINE_UID = Guid.NewGuid();
    line.TS_LINE_CLASS_UID = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_UID;
    line.TS_LINE_COMMENT = "Project Timesheet - " + DateTime.Today;
    line.TS_LINE_STATUS = (byte)TimesheetEnum.LineStatus.Approved;

    line.TS_LINE_VALIDATION_TYPE = (byte)TimesheetEnum.ValidationType.Verified;
    line.TS_LINE_CACHED_ASSIGN_NAME = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_DESC;

    line.ASSN_UID = assigUID;
    line.PROJ_UID = projectUID;
    line.TASK_UID = taskUID;

    timeSheetDS.Lines.AddLinesRow(line);

    Guid[] uids = new Guid[] { line.TS_LINE_UID };

    timeSheetWS.PrepareTimesheetLine(timeSheetUID, ref timeSheetDS, uids);

    Guid jobUID = Guid.NewGuid();
    timeSheetWS.QueueUpdateTimesheet(jobUID, timeSheetUID, timeSheetDS);
    WaitForQueue(queueWS, jobUID);
      

     Hope this helps,

    Jorge.

    [ The ultimate for Project Server 2007 || http://www.projecttimesheet.com/about-en.php ]

    Selasa, 22 Juni 2010 11.05

Semua Balasan

  • Hi,

    I use this code to create a new line in the PWA.

    //Timesheet Credentials
    timeSheetWS.Url = PROJECT_SERVER_URI + TIMESHEET_SERVICE_PATH;
    timeSheetWS.Credentials = CredentialCache.DefaultCredentials;

    //Timesheet Credentials
    adminWS.Url = PROJECT_SERVER_URI + ADMIN_SERVICE_PATH;
    adminWS.Credentials = CredentialCache.DefaultCredentials;

    TimesheetLineClassDataSet tsLineClassDs = adminWS.ReadLineClasses(WebSvcAdmin.LineClassType.All, WebSvcAdmin.LineClassState.Enabled);

    //read the timesheet
    WebSvcTimesheet.TimesheetListDataSet timeSheetList = timeSheetWS.ReadTimesheetList(userUID, date, date, 1);
    Guid timeSheetUID = (Guid)timeSheetList.Tables[0].Rows[timeSheetList.Tables[0].Rows.Count - 1]["TS_UID"];   
    WebSvcTimesheet.TimesheetDataSet timeSheetDS = timeSheetWS.ReadTimesheet(timeSheetUID);

    WebSvcTimesheet.TimesheetDataSet.LinesRow line = timeSheetDS.Lines.NewLinesRow();

    line.TS_UID = timeSheetUID;
    line.TS_LINE_UID = Guid.NewGuid();
    line.TS_LINE_CLASS_UID = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_UID;
    line.TS_LINE_COMMENT = "Project Timesheet - " + DateTime.Today;
    line.TS_LINE_STATUS = (byte)TimesheetEnum.LineStatus.Approved;

    line.TS_LINE_VALIDATION_TYPE = (byte)TimesheetEnum.ValidationType.Verified;
    line.TS_LINE_CACHED_ASSIGN_NAME = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_DESC;

    line.ASSN_UID = assigUID;
    line.PROJ_UID = projectUID;
    line.TASK_UID = taskUID;

    timeSheetDS.Lines.AddLinesRow(line);

    Guid[] uids = new Guid[] { line.TS_LINE_UID };

    timeSheetWS.PrepareTimesheetLine(timeSheetUID, ref timeSheetDS, uids);

    Guid jobUID = Guid.NewGuid();
    timeSheetWS.QueueUpdateTimesheet(jobUID, timeSheetUID, timeSheetDS);
    WaitForQueue(queueWS, jobUID);
      

     Hope this helps,

    Jorge.

    [ The ultimate for Project Server 2007 || http://www.projecttimesheet.com/about-en.php ]

    Selasa, 22 Juni 2010 11.05
  • Hi Jorge,

    You have created new timesheet lines from the code and created a new job ID to process the timesheet in the queue.

    My question is..incase If I want to get the jobID for the current timesheet how will I be able to get the information.

    i.e once I click on save and submit button..when I enter the Onsubmitting event..I want the JOB ID of the timesheet.

    Please suggest.

    Regards,

    Sudhir

    Senin, 13 Desember 2010 16.20
  • Hi Jorge,

    Thanks for the clear input, even after I am using this I am getting an error like below

    System.InvalidOperationException: Personal tasks are not allowed\r\n   at Microsoft.Office.Project.Server.BusinessLayer.Timesheet.CreatePersonalTaskLine(String taskName, Guid lineClassUid, Guid assignmentUid, Guid taskUid)\r\n   at Microsoft.Office.Project.Server.BusinessLayer.Timesheet.AddTimesheetLine(Guid assignmentUid, Guid taskUid, Guid projectUid, Guid classUid, ValidationType validationType, Guid lineUid, String taskName, String projectName, String comment)\r\n   at Microsoft.Office.Project.Server.BusinessLayer.Timesheet.ImportTimesheetLine(NewTask importedLine)\r\n   at Microsoft.Office.Project.Server.BusinessLayer.Timesheet.

    What I am trying to do:

    Adding a task which is already existing in a project, also it is in timesheet but it can be visible only if we add by using addrow button (add row tab).

    Any response will be helpfull.

    Jumat, 31 Agustus 2018 20.26