none
Read Resources - Project Server 2013 RRS feed

  • Question

  • i have a question about this line of code.

    resourceSvc.ReadResources(filterXml, false);

    It seems that any resource that is read by this piece of code would become active in Project Server , even if they don't exists in AD groups that are synced to PWA and should not exist in PWA/


    tatiana

    Tuesday, February 17, 2015 7:22 PM

Answers

  • well, looks like i didn't read through the code before posting that question. 

    it happens before ReadResources() in the EnsureEnterpriseResource() code. After i commented a piece of that function, no new resources are being created.

     private static Guid EnsureEnterpriseResource(SvcResource.Resource resourceSvc, string resourceName, PSLibrary.Resource.Type resourceType)
            {
                try
                {
                    SvcResource.ResourceDataSet resourceDs = new SvcResource.ResourceDataSet();

                    PSLibrary.Filter resourceFilter = new Microsoft.Office.Project.Server.Library.Filter();
                    resourceFilter.FilterTableName = resourceDs.Resources.TableName;
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_UIDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_NAMEColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_INITIALSColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_TYPEColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));

                    PSLibrary.Filter.FieldOperator existingResource = new PSLibrary.Filter.FieldOperator(PSLibrary.Filter.FieldOperationType.Equal, resourceDs.Resources.RES_NAMEColumn.ColumnName, resourceName);
                    resourceFilter.Criteria = existingResource;
                    string filterXml = resourceFilter.GetXml();
                    resourceDs = resourceSvc.ReadResources(filterXml, false);
                    if (resourceDs.Resources.Count >= 1)
                    {
                        return resourceDs.Resources[0].RES_UID;
                    }
                    else
                    {
                        //this piece creates a new resource
                        /*

                        resourceDs = new SvcResource.ResourceDataSet();
                        SvcResource.ResourceDataSet.ResourcesRow resourceRow = resourceDs.Resources.NewResourcesRow();
                        resourceRow.RES_UID = Guid.NewGuid();
                        resourceRow.RES_NAME = resourceName;
                        resourceRow.RES_INITIALS = resourceName.Substring(0, 1) +
                                          (resourceName.IndexOf(" ") > 0 ? resourceName.Substring(resourceName.IndexOf(" ") + 1, 1) : "");
                        resourceRow.RES_TYPE = (int)resourceType;
                        resourceDs.Resources.AddResourcesRow(resourceRow);
                        resourceSvc.CreateResources(resourceDs, false, true);
                        return resourceRow.RES_UID;
                         */
                    }
                }


    tatiana

    Monday, March 23, 2015 5:58 PM