none
Resources.ReadResources(filterxml,false) doesn't return Resource dataset with CalendarExceptions RRS feed

  • Question

  • Hi,

    I am using Resourceswebsvc.ReadResources(filterXml,false) method to get resource dataset with calendarexceptions tabe, but it only returns me 'Resources' table. This is the filter xml i am passing to 'ReadResources' method -

    <?xml version="1.0" encoding="utf-16"?>
    <Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" filterTableName="Resources" xmlns="http://microsoft.com/ProjectServer/FilterSchema.xsd">
      <Fields>
        <Field tableName="Resources" fieldName="RES_UID" />
        <Field tableName="Resources" fieldName="RES_NAME" />
        <Field tableName="Resources" fieldName="RES_INITIALS" />
        <Field tableName="Resources" fieldName="RES_TYPE" />
      </Fields>
      <Criteria>
        <LogicalOperator logicalOperationType="Or">
          <FieldOperator fieldOperationType="Equal">
            <Field fieldName="RES_UID" />
            <Operand xmlns:q2="http://microsoft.com/wsdl/types/" xsi:type="q2:guid">1667cd0b-1a11-4a82-b7fd-081c43743c6f</Operand>
          </FieldOperator>
         </LogicalOperator>
      </Criteria>
    </Filter>
    what should be the correct xml to get CalendarExceptions as well?

    Manvir


    Wednesday, November 20, 2013 7:19 AM

All replies

  • I got it fixed.

    Actually, we need to ensure that Filter contains all the fields of 'Resources' and 'CalendarExceptions' tables. To add to that if the plan is to to update the Resources dataset, lets say by adding list of calendar exceptions to 'CalendarExceptions' table in Resources DS, then Filter must contain all he fields of 'Resources' (a primary table) and also all the fields from Secondary tables i.e. CalendarExceptions, ResourceRates and ResourceAvailabilities.

    Here is the code -

    using PSLibrary = Microsoft.Office.Project.Server.Library;
    private string GetResourceFilter(Guid[] resources)
            {
                ResourceWS.ResourceDataSet resourceDs = new ResourceWS.ResourceDataSet();
    
                PSLibrary.Filter resourceFilter = new PSLibrary.Filter();
                resourceFilter.FilterTableName = resourceDs.Resources.TableName;
                foreach (DataColumn column in resourceDs.Resources.Columns)
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, column.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
    
                foreach (DataColumn column in resourceDs.CalendarExceptions.Columns)
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.CalendarExceptions.TableName, column.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
    
                foreach (DataColumn column in resourceDs.ResourceRates.Columns)
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.ResourceRates.TableName, column.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
                
    
                foreach (DataColumn column in resourceDs.ResourceAvailabilities.Columns)
                    resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.ResourceAvailabilities.TableName, column.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
                
    
                PSLibrary.Filter.IOperator[] fos = new PSLibrary.Filter.IOperator[resources.Length];
                for (int i = 0; i < resources.Length; i++)
                {
                    fos[i] = new PSLibrary.Filter.FieldOperator(PSLibrary.Filter.FieldOperationType.Equal, resourceDs.Resources.RES_UIDColumn.ColumnName, resources[i]);
                }
    
                PSLibrary.Filter.LogicalOperator lo = new Microsoft.Office.Project.Server.Library.Filter.LogicalOperator(PSLibrary.Filter.LogicalOperationType.Or, fos);
    
                resourceFilter.Criteria = lo;
                return resourceFilter.GetXml();
            }

    
    




    Thursday, November 21, 2013 3:28 AM