none
Deleting ResourceRatesRows RRS feed

  • Question

  • Hi all,

    To put in our background, we migrated the Project Server 2007 databases to a new environment in Project Server 2010. We already have the SP1 installed and June 2011 CU and October 2011 CU. We also are using Project Professional 2007.

    The issue comes when we try to delete the Resource Rates rows by PSI with the code below:

     setRes=resourceWS.ReadResource(Entity.GUID); 

    ResourceDataSet.ResourceRatesRow[] ratesRows =  resourceRow.GetResourceRatesRows();
     foreach (ResourceDataSet.ResourceRatesRow rr in ratesRows)
     setRes.ResourceRates.RemoveResourceRatesRow(rr);

     setRes.CalendarExceptions.AcceptChanges();
      //CALL UPDATE RESOURCE METHOD - We were receiving a CalendarUnusedException Exception and as Brian Smith advice change the dataset to update as following


      ResourceDataSet changeDs = new ResourceDataSet();

      changeDs.Resources.Merge(setRes.Tables[setRes.Resources.TableName], false);
       changeDs.ResourceRates.Merge(setRes.Tables[setRes.ResourceRates.TableName], false);

     resourceWS.UpdateResources(changeDs, false, true);

     

    Ok, but after UpdateResources, we try the next code to ensure the RateRows were removed, but we receive the same Rate Rows as the beginning...

     setRes = new ResourceDataSet();

    setRes = resourceWS.ReadResource(Entity.GUID);

     resourceRow = setRes.Resources.FindByRES_UID(Entity.GUID);

     

    Any helps would be appreciated!

    Thanks!

     


    Miguel Soler
    Monday, December 12, 2011 4:08 PM

All replies

  • Hi Miquel,

    How are you defining and setting resourceRow in the code above?

    Also looking at the Project Professional client it isn't possible to delete the first row in a data table - but you can delete subsequent rows. What are you trying to achieve?  Can you update the rows ok - or add news rows with effective dates?

    Best regards,

    Brian. 

     


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    Monday, December 12, 2011 7:01 PM
    Owner
  • Hi Brian,

    Thanks for your quick reply. First, by Project Professional, as you explain, we want just to delete de subsequent rows. When we try to delete them, we attain, but when we press the Ok button, nothing happens. I try to explain: We can delete all the rows, except the first one, but the only way to go out of the dialog form is press Cancel. We only can go out of dialog form when Ok is pressed, when we don´t delete any rate row.

    So is because that we are trying to delete them via PSI.

    The code for what you are asking, the definition of resourceRow is the next:

    Resource resourceWS = new Resource();
    resourceWS.UseDefaultCredentials = true;
    resourceWS.PreAuthenticate = true;
    resourceWS.Url = http://server/pwa/_vti_bin/psi/resource.asmx;
    resourceWS.Credentials = System.Net.CredentialCache.DefaultCredentials;
    ResourceDataSet setRes = new ResourceDataSet();
                   
    setRes=resourceWS.ReadResource(resourceGuid);
    ResourceDataSet.ResourcesRow resourceRow = setRes.Resources.FindByRES_UID(Entity.GUID);

    After that snnipet, I call ResourceDataSet.ResourceRatesRow[] ratesRows = resourceRow.GetResourceRatesRows(); and always is 138 the number of elements in that dataset, I´m not able to delete and not to add.

    The same via Project Professional, I cannot add, change or delete any row...

    What´s going on wrong??

    Thankss!!

     


    Miguel Soler
    Tuesday, December 13, 2011 9:01 AM
  • OK, I think I have a solution Miguel. Took me a while as I'd missed out the Merge for the ResourceRates - that you had identified needed to be added. However, the RemoveResourceRatesRow actually removes the rows and they do not then show as changed or deleted - but are just gone. Using the .Delete() on each row will mark them as deleted and then the PSI will take action and remove them.

    This was my initial thought - but missing the other Merge nothing was being passed back anyway in my tests...

    So something like:

    foreach (SvcResource.ResourceDataSet.ResourceRatesRow rr in setRes.ResourceRates)
    rr.Delete();

    Hope this works for you.

    Best regards,

    Brian


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    Tuesday, December 13, 2011 6:52 PM
    Owner
  • Brian,

     

    Same issue... I removed out from my code the second Merge for the ResourceRates, and same issue too...

    After the UpdateResources I test how is the resourceRows, and the result is the as the begin (138).

    resourceWS.UpdateResources(changeDs, false, true);

    setRes = new ResourceDataSet();
    setRes = resourceWS.ReadResource(Entity.GUID);
    resourceRow = setRes.Resources.FindByRES_UID(Entity.GUID);

    ratesRows = resourceRow.GetResourceRatesRows();

     

    Any more ideas?


    Miguel Soler
    Wednesday, December 14, 2011 10:25 AM
  • Sorry Miguel - I think I may have confused you.  You do need the second Merge.  I accidentally left it out of my code which then meant I wasn't seeing the behavior I was expecting - my problem not yours.  Using the two merge rows and the .Delete() certainly worked for me.  However, when opening the dataset again you will still see 1 row for each of all the rate tables but rates will be set as $0.00.  This is expected behavior.  Any further rows will be deleted.

    Best regards,

    Brian


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    Wednesday, December 14, 2011 2:33 PM
    Owner
  • I´m doing exactly what you explained, with the second Merge too, but as you said "expected behavior" I see the 138 rows again, with yes, rates set as $0.00. Certainly all the rows I can see via Project Professional has this rate.

    Finally PSI don´t delete the rows after the UpdateResource method, and via Project Professional I can see the same number of rows.

    I discovered this problem because  when I want to modify some resources in Project Web App and press Save, appears the next message:

    •Availability segment already exists.
    •Availability segment already exists.

    ....

    (more than 20 times)

    I readed in some posts that this behavior is related with the resource rates, and certainly, new resources with just a rate row can be Saved and modified via PWA.

    When I try to modify a resource via Project Professional I have no problems (except the resource rates hehe)

     

    Kind Regards,


    Miguel Soler
    Thursday, December 15, 2011 2:23 PM
  • I hope not happens the same as when you try to modify the project finish date or duration, because I saw the same behavior (you change rows, you see the change, update, and after that you don´t see the change).

    http://social.technet.microsoft.com/Forums/en-HK/project2010custprog/thread/d4c2a16d-38ce-4fbc-af0e-0bcc75cd0a1a

     

    Kind Regards,


    Miguel Soler
    Friday, December 16, 2011 11:01 AM
  • Brian,

     

    Any more advices to test? Do you think is a problem in Published database?

    We are very stuck in this issue since we cannot edit users in PWA.

     

    Many thanks !


    Miguel Soler
    Wednesday, December 21, 2011 11:39 AM
  • Hi Miguel,

    The answers I have already given are the correct ones for removing resource rate rows.  You will always see the first row.  This is the first you have mentioned that you cannot edit users in PWA - tell me more about that issue - or open a support incident with us.  Not sure about the link you sent - that is a straightforward design behavior.  Project is a scheduling engine and certain behavior is built in - you cannot over-ride some of the out of the box design just by using the PSI.  Jack gave the right answer to that forum posting.

    Best regards,

    Brian


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    Wednesday, December 21, 2011 2:30 PM
    Owner
  • Hi again Brian,

    The beginning problem discovered is when we try to update some resource in PWA we receive a repeated message:

    •Availability segment already exists.

    As I readed in a post, this is strictly related with the Cost Rate Rows, solved deleting that , but the problem is that we are not able to delete them as I described here.

    The only resources have that problem, are the resources that have this dummy cost rate rows, visible only by Project Professional.

     

    Kind Regards,

     


    Miguel Soler
    Wednesday, December 21, 2011 3:21 PM