update timesheet using PSI failed RRS feed

  • Question

  • Hi, I faced a strange problem when updating the timesheet. It was successful when I update timesheetline first time. But when I do the same job again, something strange occured as follows.

    Queue request failed Failed for Job ID a83364d9-b388-4c80-8e3c-02f0c4cb9d63.
    <?xml version="1.0" encoding="utf-16"?>
        <class name="Queue">
          <error id="26000" name="GeneralQueueJobFailed" uid="22a9f782-82b7-40e6-9be0-f48b94c0b8f3" JobUID="a83364d9-b388-4c80-8e3c-02f0c4cb9d63" ComputerName="WIND" GroupType="TimesheetUpdate" MessageType="UpdateTimesheetMessage" MessageId="1" Stage="" />

    The problem trubled me for a long time. Anyone can help me? Thanks!

    Following are my main code.

     UpdateTimesheetLine(timesheetDs, tslineuid, updatedate, actualworktime);

     Guid jobUid = Guid.NewGuid();
     timeSheet.QueueUpdateTimesheet(jobUid, tsuid, timesheetDs);
     WaitForQueue(general.queueSystem, jobUid);  

     private void UpdateTimesheetLine(WebSvcTimeSheet.TimesheetDataSet mytimesheetDS, Guid lineGuid, DateTime updateDate, int actualWork)
                if (mytimesheetDS.Actuals.FindByTS_LINE_UIDTS_ACT_START_DATE(lineGuid, updateDate) == null)
                    WebSvcTimeSheet.TimesheetDataSet.ActualsRow newActualsRow = mytimesheetDS.Actuals.NewActualsRow();
                    newActualsRow.TS_LINE_UID = lineGuid;
                    newActualsRow.TS_ACT_START_DATE = updateDate;
                    newActualsRow.TS_ACT_FINISH_DATE =
                        new DateTime(updateDate.Year, updateDate.Month, updateDate.Day, 23, 59, 59);
                    newActualsRow.TS_ACT_VALUE = actualWork;
                    mytimesheetDS.Actuals.FindByTS_LINE_UIDTS_ACT_START_DATE(lineGuid, updateDate).TS_ACT_VALUE = actualWork;

    Wednesday, January 4, 2012 9:30 AM

All replies

  • Hi,

    It would be a great help for us if you can post ULS or Event logs error description which indeed help us to find out the root cause of this problem.

    In between I have few question for you as well.


    1) For which resource you are updating the timesheet means if it is for some body else then either you have to use Surrogate or Impersonation to update the time timesheet.

    2) If in your PSI code you are saving and submitting the timesheet at same time then you need to recall your timesheet first before updating it again.

    Let me know your point for further help

    Thanks !!!

    Sachin Vashishth MCTS
    Wednesday, January 4, 2012 12:38 PM
  • Hi,

    I checked the ULS logs and the log said that I disobeyed the rules "PRIMARY KEY:PK_MSP_TIMESHEET_CUSTOM_FIELD_VALUES". Can not insert into dbo.MSP_TIMESHEET_CUSTOM_FIELD_VALUES duplicate key.

    Actually, I add a customfield in the timesheet and I want to write something into the MSP_TIMESHEET_CUSTOM_FIELD_VALUES using PSI. And I can't find where the error is.

    Following are my update customfieldrow codes:

     private  void UpdateTimeSheetCF(WebSvcTimeSheet.TimesheetDataSet mytimesheetDS, Guid tsuid, Guid lineGuid, Guid mdpropuid, int mdpropid, string workdescrip)
                if (FindTSCFRowByTsLineUidMdPropUid(mytimesheetDS, lineGuid, mdpropuid) == null)
                    WebSvcTimeSheet.TimesheetDataSet.CustomFieldsRow newtscfrow = mytimesheetDS.CustomFields.NewCustomFieldsRow();
                    newtscfrow.CUSTOM_FIELD_UID = Guid.NewGuid();
                    newtscfrow.TS_UID = tsuid;
                    newtscfrow.TS_LINE_UID = lineGuid;
                    newtscfrow.MD_PROP_UID = mdpropuid;
                    newtscfrow.MD_PROP_ID = mdpropid;
                    newtscfrow.FIELD_TYPE_ENUM = (byte)PSLibrary.PSDataType.STRING;
                    newtscfrow.TEXT_VALUE = workdescrip;

                    WebSvcTimeSheet.TimesheetDataSet.CustomFieldsRow updaterow = FindTSCFRowByTsLineUidMdPropUid(mytimesheetDS, lineGuid, mdpropuid);
                    updaterow.TEXT_VALUE = workdescrip;

            private  WebSvcTimeSheet.TimesheetDataSet.CustomFieldsRow FindTSCFRowByTsLineUidMdPropUid
                (WebSvcTimeSheet.TimesheetDataSet mytimesheetDS, Guid lineGuid, Guid mdpropuid)
                WebSvcTimeSheet.TimesheetDataSet.CustomFieldsRow findcfrow = null;
                foreach (WebSvcTimeSheet.TimesheetDataSet.CustomFieldsRow cfrow in mytimesheetDS.CustomFields)
                    if ((cfrow.TS_LINE_UID == lineGuid) && (cfrow.MD_PROP_UID == mdpropuid))
                        findcfrow = cfrow;
                return findcfrow;

    still the case:

    update the first time:ok, second time:maybe ok, again:failed.

    Hope anyone can help me. Thanks!

    Thursday, January 5, 2012 8:13 AM
  • no one else can help me?

    As I egnored the code of update customfield values, the program  always runned successfully. But the primary key error made me confused. There may be something wrong when I try to update the customfield value.

    Friday, January 6, 2012 9:19 AM
  • Still no one reply me? Hope anyone help me. The problem trubled me long time.

    Wednesday, January 11, 2012 7:57 AM