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 41

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 2 and 1 and type the answer here:
  • Post
  • we are unable to update part timer’s information (work Type Exceptions) at EPM level. It is not allowing us to update / delete any type of exceptions but, we can add the exceptions for existing resource. How we can update part timer’s information (work Type Exceptions) at EPM level?

    Any help or direction will help us.

  • I am working on a requirement which requires updating the actual hour against resources and actual cost against the task for a particular projcet.

    We are using Statusing web service to update the actual hour of the resources on date basis.

    We are using status method to update the actuals.

    We can only invoke this method if the user is an administrator otherwise we encounter General Security Exception. And only the resource can update his\her own actuals. if using some other resource account we try to update the actuals we again get General Security Exception.

    Currently we are using a single dedicated account to call the web service and method. After googling we came up with impersonation to actually update the actuals for all the resources using a single dedicated account. We are trying to achieve impersontaion in PSI using SSP in Project Server.

    But while calling SSP from my .net component which runs on the Project Server where PWA is hosted i am getting HTTP 401 error.

    The account which i am using to call the SSP web service has administrator previliges in Project Web Access.

    Please suggest me the resolution. Please do the needful.

  • I am working on a requirement which requires updating the actual hour against resources and actual cost against the task for a particular projcet.

    We are using Statusing web service to update the actual hour of the resources on date basis.

    We are using status method to update the actuals.

    We can only invoke this method if the user is an administrator otherwise we encounter General Security Exception. And only the resource can update his\her own actuals. if using some other resource account we try to update the actuals we again get General Security Exception.

    Currently we are using a single dedicated account to call the web service and method. After googling we came up with impersonation to actually update the actuals for all the resources using a single dedicated account. We are trying to achieve impersontaion in PSI using SSP in Project Server.

    But while calling SSP from my .net component which runs on the Project Server where PWA is hosted i am getting HTTP 401 error.

    The account which i am using to call the SSP web service has administrator previliges in Project Web Access.

    Please suggest me the resolution. Please do the needful.

  • The article on Impersonation in the SDK covers full details.  Please read this as impersonation in the context of Project Server may not be the same as you think it is from other .NET development.  Key things are creating derived classes, accessing the Web Service from the SSP and identifying the calling PWA instance and finally using the account that is running the SSP.

  • Hi!!

    I'm having similar problem to this but trying to remove a Line Row from the TimeSheet.

    When I call the QueueUpdateTimesheet everything seems to be ok (in the cool data visualizer I can see the row has disappeared) but after the call every thing remains (no row deleted...).

    Do you know how should I do?

    Thanks ;-)

  • Hi Esfer,

    Do you see any errors or messages in the ULS logs?  What code are you using to remove the line?

    Best regards,

    Brian

  • Hi brian,

    I have an error when updating a customfield a project. The error is "LastError = ProjectHasWriteLock Instructions" and appears in the following line of code:

    projectDs = myproject.ReadProjectEntities (ProjGuid, 32, WebSvcProject.DataStoreEnum.WorkingStore);

    You know what is this error?

    Thanks

  • Hi Laura,

    I am not familiar with this error.  Is the project checked out in another session?  Do you get this with all projects - all custom fields?

    Best regards,

    Brian.

  • Hi!

    I have a problem that i can't resolve. I have to create a new line in a timesheet. To do that I use the msdn example but when a call PrepareTimesheetLine method, i always have GeneralObjectReferenceAlreadyExists error. When I pass this into PSIerror the UID concerned with the error is the UID created with this line:

    newLine.TS_LINE_UID = Guid.NewGuid();

    I tried to create a new project and just use the msdn code but i get an error when I execute this line:

    AdminWebSvc.TimesheetLineClassDataSet tsLineClassDs = adminSvc.ReadLineClasses(WindowsFormsApplication1.AdminWebSvc.LineClassType.AllNonProject, WindowsFormsApplication1.AdminWebSvc.LineClassState.Enabled);

    I have to use impersonation???

    The msdn code example should work well, shouldn't?

    Thks

    Nuno Coelho - PT

  • Hi Nuno,

    The MSDN code should certainly work - although it will rely on the user context in some cases, and other PWA settings such as the configured line classes for timesheets.  Are these things that work fine for you as a user through the UI?

    Best regards,

    Brian.

  • Hi Brian!,

    Thanks for the response.

    I can create timesheet lines throw PWA.

    In my code everything is cool with the timesshet dataset. The new line is sucessfully created at dataset but when I call PrepareTimesheetLine method I get GeneralObjectReferenceAlreadyExists error.

    The code is that on:

    ...

    //TIMESHEET DATASET fill

    line.TS_UID = LinhaTimeSheet.TS_UID;

    line.TS_LINE_UID = Guid.NewGuid();

    line.TS_LINE_CLASS_UID = tsLineClassDs.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 = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_DESC;

                                   timeSheet.Lines.AddLinesRow(line);

                                   Report.Program.timesheet.PrepareTimesheetLine(LinhaTimeSheet.TS_UID, ref timeSheet, new Guid[] { line.TS_LINE_UID });

    ...

    Thks

    Nuno Coelho

  • Thks Brian!

    I've discover the issue.

    In the msdn example we have that line:

    line.TS_LINE_CLASS_UID = tsLineClassDs.LineClasses[0].TS_LINE_CLASS_UID;

    This retrieve the LinaCLassType "Administrative".

    I think that we just can have 1 Administrative time line, so, I have changed to Standart time (type of project tasks) and then everything works fine.

  • Excellent!  Glad you worked it out Nuno - and thanks for the feedback.  If you think this will help others then feel free to post some community comments to MSDN.

    Best regards,

    Brian.

  • Hi one more time!

    I'm back :)

    I have a question related with "The number of hours in a standard timesheet day" that we can define in Timesheet Settings and Defaults.

    Can we access to thtat value programatically??

    Until now I can't find a way to do that.

    Thanks

    Nuno Coelho

    PT

  • Sorry Nuno,

    That setting isn't available programmatically.  The best solution for these types of things is a PSI extension and getting it from the DB.  But don't tell anyone I told you to access the DB directly...

    Best regards,

    Brian.

Page 2 of 3 (41 items) 123