none
Error while Pushing actual hours via PSI RRS feed

  • Question

  • I am trying to push actual hours to a new timesheet from a previous sheet via PSI. I am getting the below error message. can some one help on this?

    Error Message : System.wem.services.protocols.soapexception:ProjectServerError(s) LastError=TimesheetUnverfiedTSLineNotAllowed Instruction: Pass this into PSClientError constructer to access all error information at PrepareTimesheetLine(Guid tsuid,TimesheetDataset& dsDelta,Guid[]tlsNeedFill)

    The above error message is bombing at PrepareTimesheetLine method.

    Please find the code snippet below:

    protected void LaunchImportActualsClick(object sender, EventArgs e)
            {
                ResourceVacation.AdminWebSvc.TimesheetLineClassDataSet classifications = null;
                ResourceVacation.TimeSheetWebSvc.TimesheetDataSet currentTimesheet = null;
                ResourceVacation.TimeSheetWebSvc.TimesheetDataSet previousTimesheet = null;
                ResourceVacation.TimeSheetWebSvc.TimeSheet timeSheetSvc = null;          
                ResourceVacation.ResourceWebSvc.Resource resourceSvc = null;
                ResourceVacation.AdminWebSvc.Admin adminSvc = null;

                try
                {
                   GUid timeSheetUid = new Guid("FCB3AC2C-1695-44A6-A662-671BB2F216D6");
                    Guid newtimeSheetUid = new Guid("35FA41CA-7FCC-4660-A4AD-969C7A6B9256");

                    timeSheetSvc = new ResourceVacation.TimeSheetWebSvc.TimeSheet();
                    timeSheetSvc.Url = SERVER_URI + TIMESHEET_SERVICE_PATH;
                    timeSheetSvc.CookieContainer = new CookieContainer();
                    timeSheetSvc.Credentials = CredentialCache.DefaultCredentials;

                    adminSvc = new ResourceVacation.AdminWebSvc.Admin();
                    adminSvc.Url = SERVER_URI + ADMIN_SERVICE_PATH;
                    adminSvc.CookieContainer = new CookieContainer();
                    adminSvc.Credentials = CredentialCache.DefaultCredentials;

                    resourceSvc = new ResourceVacation.ResourceWebSvc.Resource();
                    resourceSvc.Url = SERVER_URI + RESOURCE_SERVICE_PATH;
                    resourceSvc.CookieContainer = new CookieContainer();
                    resourceSvc.Credentials = CredentialCache.DefaultCredentials;

                    Guid currentUserID = resourceSvc.GetCurrentUserUid();

                    currentTimesheet = timeSheetSvc.ReadTimesheet(newtimeSheetUid);
                    previousTimesheet = timeSheetSvc.ReadTimesheetByPeriod(currentUserID, currentTimesheet.Headers[0].WPRD_UID, ResourceVacation.TimeSheetWebSvc.Navigation.Previous);

                    classifications = adminSvc.ReadLineClasses(ResourceVacation.AdminWebSvc.LineClassType.All,ResourceVacation.AdminWebSvc.LineClassState.Enabled);

                    foreach (ResourceVacation.TimeSheetWebSvc.TimesheetDataSet.LinesRow line in previousTimesheet.Lines)
                    {
                        Guid lineClassGuid;

                        if (IsCorrectForCopy(line, classifications, out lineClassGuid))
                        {
                            ResourceVacation.TimeSheetWebSvc.TimesheetDataSet.LinesRow newLine = currentTimesheet.Lines.NewLinesRow();

                            newLine.TS_UID = newtimeSheetUid;
                            newLine.TS_LINE_UID = Guid.NewGuid();
                            newLine.TS_LINE_CLASS_UID = lineClassGuid;
                            newLine.TS_LINE_COMMENT = string.Empty;
                            newLine.TS_LINE_STATUS = (byte)PSLibrary.TimesheetEnum.LineStatus.NotApplicable;
                            newLine.TS_LINE_VALIDATION_TYPE =(byte)PSLibrary.TimesheetEnum.ValidationType.Unverified;                            newLine.TS_LINE_CACHED_PROJ_NAME = line.TS_LINE_CACHED_PROJ_NAME;
                            newLine.TS_LINE_CACHED_ASSIGN_NAME = line.TS_LINE_CACHED_ASSIGN_NAME;
                            newLine.TS_LINE_STATUS = (byte)PSLibrary.TimesheetEnum.Status.InProgress;

                            //Prepare the timesheet...
                            currentTimesheet.Lines.AddLinesRow(newLine);
                            timeSheetSvc.PrepareTimesheetLine(newLine.TS_UID, ref currentTimesheet, new Guid[] { newLine.TS_LINE_UID });

                            // Save the changes to the database...
                            Guid jobGuid = Guid.NewGuid();
                            timeSheetSvc.QueueUpdateTimesheet(jobGuid, newtimeSheetUid, currentTimesheet);
         
                        }
                    }

                   catch (Exception ex)
                {
                    String error = string.Empty;
                    error = "Error! Message: " + ex.Message.ToString();
                    this.messageDelEncodedLiteral.Text = error;
                }

            }

        private static bool IsCorrectForCopy(ResourceVacation.TimeSheetWebSvc.TimesheetDataSet.LinesRow line,
                                                 ResourceVacation.AdminWebSvc.TimesheetLineClassDataSet classifications,
                                                 out Guid lineClassGuid)
            {

                lineClassGuid = Guid.Empty;

                ResourceVacation.AdminWebSvc.TimesheetLineClassDataSet.LineClassesRow lineClass = FindLineClass(line, classifications);

                if (lineClass == null)
                {
                    return false;
                }

                lineClassGuid = lineClass.TS_LINE_CLASS_UID;

                return line.TS_LINE_ACT_SUM_VALUE > 0 &&
                       line.PROJ_UID != PSLibrary.TimesheetConst.const_UnverifiedProjectGuid &&
                       line.TS_LINE_CLASS_UID != PSLibrary.TimesheetConst.const_StandardLineClassGuid &&
                       line.TS_LINE_CLASS_UID != PSLibrary.TimesheetConst.const_SickTimeLineClassGuid &&
                       line.TS_LINE_CLASS_UID != PSLibrary.TimesheetConst.const_VacationLineClassGuid;
            }

           private static ResourceVacation.AdminWebSvc.TimesheetLineClassDataSet.LineClassesRow FindLineClass(ResourceVacation.TimeSheetWebSvc.TimesheetDataSet.LinesRow line,
                                                                                  ResourceVacation.AdminWebSvc.TimesheetLineClassDataSet classifications)
            {
                return classifications.LineClasses.FindByTS_LINE_CLASS_UID(line.TS_LINE_CLASS_UID);
            }

    Thanks,

    Vivek


    • Edited by Vivek V Sunday, November 6, 2011 2:41 PM
    Sunday, November 6, 2011 2:38 PM