none
PSI - cannot delete resource rate row RRS feed

  • Question

  • I have a service that does the update of resource's cost rate via PSI in Project Server 2010.
    New rates are included successfully. But when I can't delete old rates.
    When I run the code, I see that the records are deleted. But after execute the UpdateResources method, the resource is not updated and old rates remain visible.
    The user who runs the service has administrative permission in Project Server.

    Does anyone know where I could be wrong?

    That's the code:

    resourceSvc = new ResourceWebSvc.Resource();

                    resourceSvc.Url = PROJECT_SERVER_URI + RESOURCE_SERVICE_PATH;
                    resourceSvc.Credentials = new NetworkCredential(USERNAME, PASSWORD, DOMAIN);

                    resourceDS = new ResourceWebSvc.ResourceDataSet();
                    
                    foreach (EPMResource resource in EPMResources)
                    {
                        eAcessoUser eAcessoInfo = new eAcessoUser();
                        eAcessoInfo = eAcessoUsers.Where(u => u.ID.Equals(resource.eAcessoID)).FirstOrDefault();

                        if (eAcessoInfo != null)
                        {                                                 
                            resourceDS = resourceSvc.ReadResource(resource.GUID);
                            
                            if (resourceDS.ResourceRates[resourceDS.ResourceRates.Count - 1].RES_STD_RATE != Convert.ToDouble(eAcessoInfo.CostValue.Value))
                            {
                                if (resourceDS.ResourceRates.Count >= 25)
                                {
                                    ResourceWebSvc.ResourceDataSet.ResourceRatesRow rowDel = resourceDS.ResourceRates[1];
                                    if (!rowDel.IsRES_RATE_EFFECTIVE_DATENull())
                                    {
                                        rowDel.Delete();
                                        rowDel.AcceptChanges();
                                        resourceDS.ResourceRates.AcceptChanges();
                                        resourceDS.AcceptChanges();
                                    }
                                }

                                ResourceWebSvc.ResourceDataSet.ResourceRatesRow row = resourceDS.ResourceRates.NewResourceRatesRow();
                                row.RES_RATE_EFFECTIVE_DATE = eAcessoInfo.EffectiveDate.Value;
                                row.RES_STD_RATE = Convert.ToDouble(eAcessoInfo.CostValue.Value);
                                row.RES_OVT_RATE = Convert.ToDouble(eAcessoInfo.OvertimeValue.Value);
                                //row.RES_RATE_TABLE
                                row.RES_UID = resource.GUID;
                                resourceDS.ResourceRates.AddResourceRatesRow(row);                                                               

                                if (resourceDS.Resources[0].IsRES_CHECKOUTBYNull())
                                {
                                    resourceSvc.CheckOutResources(new Guid[] { resource.GUID });
                                }

                                resourceSvc.UpdateResources(resourceDS, false, false);
                                resourceSvc.CheckInResources(new Guid[] { resource.GUID }, true);
                                resourceDS.Resources[0].SetModified();
                            }
                                                                 
                        }
                    }

                    resourceDS.Dispose();
                    resourceSvc.Dispose();

    Wednesday, August 8, 2012 8:00 PM

All replies

  • Hi ipaquino,

    try to call call resourceDS.Resources[0].SetModified() before you use the UpdateResource method.

    Greets
    Maik

    Thursday, August 9, 2012 4:32 AM
  • Hi ipaquino,

    try to call call resourceDS.Resources[0].SetModified() before you use the UpdateResource method.

    Greets
    Maik

    Hi Maik,

    Thanks for your answer.

    Unfortunately it didn't work and i got the same result: deleted rows remain.

    Thursday, August 9, 2012 12:15 PM
  • Had this problem many times,

    Get rid of ALL the AcceptChanges(); calls. These calls ruin everything. SImply delete the row(s) you want, then call the PSI to update the resource and check it in.


    120811049008

    Monday, August 13, 2012 7:47 PM