Cascade Skyline - with Microsoft Logo and Project Support header - author Brian Smith

Working with Project Server datasets and the web services - don't AcceptChanges!

Working with Project Server datasets and the web services - don't AcceptChanges!

Rate This
  • Comments 42

I thought this was one worth mentioning to a wider audience in case it catches others out.  One of our customer had written some code to update data in the timesheet using the PSI.  All seemed to be working OK, but no numbers changed.  You could even debug in Visual Studio and use the cool data visualizer to see the dataset and watch the changes - but even though the call worked and the queue showed a successful update the timesheet didn't reflect the changes.  The right dataset was also being passed to the final web service - in this case the QueueUpdateTimesheet method of the Timesheet web service.

I then noticed that the customer had an ADO.NET "AcceptChanges" call on the dataset before the call to the web service.  This was breaking the update as the web service is expecting the dataset to have a delta holding the changes from the original read of the timehseet dataset.  The AcceptChanges is used in ADO.NET to commit changes in the dataset - but the delta then disappears.  So even though the dataset was different to that originally read from the PSI call, it didn't have the deltas - so no changes were made to the original (different) data.  Simply removing this line got everything working again and the changes were then visible in the timesheet control of PWA!

Technorati Tags:

 

Leave a Comment
  • Please add 6 and 6 and type the answer here:
  • Post
  • Thanks... I had the exact same problem...

    Diogo

    PT-SI

    Portugal

  • Is there anyway to update PWA customized columns (such as in Issues and Risks) onto the Reporting datbase WssRisk/WssIssues if we extend the schema of these tables?

  • Can you please share the code regarding updating the timesheet using PSI.Its my projects requirement.

    Thanks in advance

  • Hi JK,

    See the ChangeXML sample in the SDK - direct link http://msdn2.microsoft.com/en-us/library/bb428819.aspx.

    Best regards,

    Brian.

  • I've tried many times to update CalendarExceptionsDataTable rows in ResourceDataSet, which i'v got via Resource web service, but project server always threw an exception 'GeneralInvalidRowState'. When I tried to use AcceptChanges for table, the row's state switched to Unchanged and the calling of method UpdateResource passed successfully. Of course, calendarexceptions didn't reflect any changes. So, I can't understand whether PSI supports updating of calendar exceptions at all..

  • Hi Yury,

    You don't need to use AcceptChanges - the web service needs to see what has changed. Are you using the UpdateResources method to make the change?  I haven't tried this specific change but can't see anywhere in the SDK that it isn't supported.  Are you checking the resource out first?

    Best regards,

    Brian.

  • I've already found out, that the method AcceptChanges is called implicitly during synchronization of dataset and data in the database. Naturally I used approach, described in Microsoft Office Project 2007 SDK i.e. checkout->updating->checkin. Sample from SDK changes ResourcesDataTable(name of resource) and update passes successfully. But when I try to change CalendarExceptionsDataTable(e.g. start time of exisiting exception) and update resource, GeneralInvalidRowState exception raises. There remains one thing to do - delete exception and then create with modified fields (but who grants, that PS will keep other components untouched after deleting of exception!!)

    How Microft Office Project changes exceptions for resources - it remains a riddle for me (isn't direct access to database is used???)

  • Hi Yury,

    We will not be using direct database access.  In most cases we will be using exactly the same web services that you can use - and you can see this by looking at the http traffic between the client and server.  In some cases we make use of private web services pwa and project - which are only considered private because we don't gurantee not to change the methods for our own needs in new releases.  I would suggest you try the delete/create to see if that resolves your issue.

    Best regards,

    Brian.

  • Hi Brian,

    I have a quick question for you.  I'm working on a project that adds timelines from the contextInfo.UserGuid's previous timesheet to the new timesheet that is created when the OnCreated Timesheet event in PWA is fired.  This works fine when I'm logged in as the box admin, it finds/adds the timelines no problem, however, when I log into pwa with a regular user account it fails every time.  It seems to fail when it hits the waitforqueue().  I was wondering if you've encountered this before and know what may be causing it.

    TimesheetDataSet.Lines.AddLinesRow(line);

                       Timesheet.PrepareTimesheetLine(tsGuid, ref TimesheetDataSet, new Guid[] { line.TS_LINE_UID });

                       Guid jobUid = Guid.NewGuid();

                       Timesheet.QueueUpdateTimesheet(jobUid, tsGuid, TimesheetDataSet);

                       WaitForQueue(QueueSystem, jobUid);

  • Hi Johnny,

    Sounds like a permissions issue.  You could try giving the "manage queue" global permission in PWA to a user to see if this is what is blocking things.  You then have the choice of either giving the permissions or changing context to check the queue.

    Best regards,

    Brian.

  • Hi Brian,

    I already issued my test user "allow" permissions over everything in Edit Resource -> "Global Permissions".  It seems like I've tried everything and still no luck.  Any other ideas?

  • Hi Brian,

    FYI, the error I am receiving is the same as the one this individual is receiving posted in the MS Project Developer NewsGroup.

    http://msdn.microsoft.com/newsgroups/default.aspx?&query=PrepareTimesheetLine&lang=en&cr=US&guid=&sloc=en-us&dg=microsoft.public.project.developer&p=1&tid=9e565e3c-fa9e-426a-a380-a0111d8d8d20&mid=7c61a626-32f7-4422-9fa7-6e565538fce6

  • I still do not have a clue on how to fix this.  Do you have any other ideas?

    Btw, I enjoyed your webcast on using BDC yesterday.

  • Hi Johnny,

    Looking at the newsgroup thread Chris Boyd is saying that impersonation is required.  When you are impersonation you are running as the SSP admin, and hitting the web services in the SSP rather than the pwa instance - so it may be these differences that overcome this issue.

    Glad you enjoyed the webcast - the BDC stuff is a fun feature.  I enjoyed putting that oen together.

    Best regards,

    Brian.

  • Hello Brian,

    i´m trying to delete a CalendarExceptionsRow from the ResourceDataSet.CalendarExceptions table. But the RemoveCalendarExceptionsRow() and Delete() methods don´t work for me. These methods delete the row in the DataTable, but after successfully calling the UpdateResources method the exception is still there ( with/without GetChanges() ). I´m only able to add a new exception. Am i missing something ?

    Best regards

    Maik

Page 1 of 3 (42 items) 123