none
Editar campo "read only" no PSI (Project Server Interface) RRS feed

  • Question

  • Olá a todos,

    Preciso criar uma mini aplicação para alterar o domínio dos usuários do Project usando o PSI, mas o campo "WRES_ACCOUNT" está marcado como read only. Será que existe agum metodo para executar essa alteração?

    Segue abaixo trecho do código:

    protected void Button1_Click(object sender, EventArgs e)
            {
                Guid jobId = Guid.NewGuid();
                Guid sessionId = Guid.NewGuid();
                NetworkCredential credentials = new NetworkCredential(userLogin, userPassword, userDomain);
                ResourceWebSvc.ResourceDataSet datasetResource = null;
                WebApplication3.ResourceWebSvc.Resource resourceSvc = new WebApplication3.ResourceWebSvc.Resource();
                resourceSvc.Url = resourceServiceUrl;
                resourceSvc.Credentials = credentials;
                string nomeUsuarioCompleto = string.Empty;
    
                QueueSystem queueSvc = new QueueSystem();
                queueSvc.Url = queueServiceUrl;
                queueSvc.Credentials = credentials;
                Guid[] CheckInRecursos;
    
                try
                {
                    datasetResource = resourceSvc.ReadResources(String.Empty, true);
                    CheckInRecursos = new Guid[datasetResource.Resources.Count];
    
                    int i = 0;
                    foreach (WebApplication3.ResourceWebSvc.ResourceDataSet.ResourcesRow recurso in datasetResource.Resources)
                    {
                        if (recurso.RES_UID == new Guid("1c90c56a-15bc-4944-8c98-1875d8176447"))
                        {
                            recurso.BeginEdit();
    
                            recurso.SetWRES_ACCOUNTNull();
                            recurso.WRES_ACCOUNT = "TESTE\\TESTE.ADMIN";
    
                            recurso.SetModified();
    
                            recurso.EndEdit();
    
                        }
                        CheckInRecursos[i] = recurso.RES_UID;
                        i++;
                    }
    
                    resourceSvc.UpdateResources(datasetResource, false, true);
    
                    
                }
                catch (SoapException ex)
                {
                    Textbox1.Text = ex.ToString();
                    
                }
                catch (Exception ex)
                {
                    Textbox1.Text = ex.ToString();
    
                }
            }

    Tuesday, May 15, 2012 8:37 PM

All replies

  • Hi there--

    if you use the ResourceWebSvc.ResourceDataSet , & try to update the Windows account, it will be a Read only property,

    http://msdn.microsoft.com/en-us/library/websvcresource.resourcedataset.resourcesrow.wres_account_di_pj14mref

    You will need to use the ResourceAuthorizationdataset to update the Resource NT account. Please see the below code which I just wrote & tested :

    static void Main(string[] args)
            {
               
                Class1 obj = new Class1();
                try
                {
                    Guid ResUid = new Guid("899F07FA-59B9-4844-A2BD-BA7D19F38FE4");
                    //Update Resource data
                    ResourceSvc.ResourceDataSet rds = new ResourceSvc.ResourceDataSet();
                    ResourceSvc.Resource res = new ResourceSvc.Resource();
                    res.UseDefaultCredentials = true;
                   ResourceSvc.ResourceAuthorizationDataSet resourceAuthDs =   new ResourceSvc.ResourceAuthorizationDataSet();
                    ResourceSvc.ResourceAuthorizationDataSet.ResourcesRow resourceAuthRow = resourceAuthDs.Resources.NewResourcesRow();
                    resourceAuthRow.RES_UID = ResUid;
                    //resourceAuthRow.RES_IS_WINDOWS_USER = WindowsUser;
                    resourceAuthRow.WRES_ACCOUNT = "TESTE\\TESTE.ADMIN";
                    resourceAuthDs.Resources.AddResourcesRow(resourceAuthRow);
                    res.SetResourceAuthorization(resourceAuthDs);
    }
    catch (SoapException ex)
                {
    }
    }   

    Hope this helps.


    If you found this post helpful, Please "Vote as Helpful";. If it answered your question, Please "Mark as Answer". Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82

    Wednesday, May 16, 2012 9:59 AM