Click or drag to resize

ResourceOperationsGetResourceFileProperties Method

Get a list of resource files with their properties.

Namespace:  Cobra.WebService.ClientAPI.Application.Files
Assembly:  Cobra.WebService.ClientAPI (in Cobra.WebService.ClientAPI.dll) Version: 8.4.717.3176 (8.4.0717.3176)
Syntax
C#
public ResourceFilePropertiesCollection GetResourceFileProperties(
	ResourceFilePropertiesFilter resourceFilePropertiesFilter
)

Parameters

resourceFilePropertiesFilter
Type: Cobra.Model.WebServiceResourceFilePropertiesFilter
An instance of ResourceFilePropertiesFilter class containing the filters applied to the list of resource files with their properties.

Return Value

Type: ResourceFilePropertiesCollection
An instance of ResourceFilePropertiesCollection class containing the list of resource files with their properties.
Exceptions
ExceptionCondition
InvalidOperationExceptionThrown when state of the instance of the CobraServices that generated the current ProjectOperations is not in opened state.
Examples
This example shows how to get list of resource files with their properties.
C#
using Cobra.Model.WebService;
using Cobra.WebService.ClientAPI.Application.Files;
using Cobra.WebService.ClientAPI.Client;

.
.
.

CobraServices cobraServices = new CobraServices();
cobraServices.ServiceIdentityData.Username = "SYSADMIN";
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('P');
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('A');
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('S');
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('S');
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('W');
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('O');
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('R');
cobraServices.ServiceIdentityData.SecurePassword.AppendChar('D');
cobraServices.ServiceIdentityData.DataSourceKey = "COBRA";

LoginResult loginResult = cobraServices.Login();
if (!loginResult.Success) {
    Console.WriteLine("Login failed.");
    return;
}

Console.WriteLine("Login Success.");

ResourceOperations resourceOperations = cobraServices.CreateServiceOperations<ResourceOperations>();
ResourceFilePropertiesFilter resourceFilePropertiesFilter = resourceOperations.CreateResourceOperationsServiceArguments<ResourceFilePropertiesFilter>();
resourceFilePropertiesFilter.ResourceFileFilter = resourceOperations.CreateResourceOperationsServiceArguments<ResourceFileFilter>();
resourceFilePropertiesFilter.ResourceFileFilter.Operator = FilterStringOperator.Like;
resourceFilePropertiesFilter.ResourceFileFilter.Value = "Demo%";

Console.WriteLine("Getting resource files with their properties...");
ResourceFilePropertiesCollection resourceFileProperties = resourceOperations.GetResourceFileProperties(resourceFilePropertiesFilter);

bool hasError = false;
foreach (ServiceMessage serviceMessage in resourceFileProperties.GetMessages()) {
    Console.WriteLine("Message Type: {0}", serviceMessage.MessageType);
    Console.WriteLine("Message: {0}", serviceMessage.Message);

    if (serviceMessage.MessageType == MessageType.Error || serviceMessage.MessageType == MessageType.ValidationError) {
        hasError = true;
    }
}

if (!hasError) {
    foreach (ResourceFileProperties resourceFile in resourceFileProperties) {
        Console.WriteLine("Name: {0}", resourceFile.Name);
        Console.WriteLine("Description: {0}", resourceFile.Description);

        Console.WriteLine("Results:");
        foreach (Result result in resourceFile.Results) {
            Console.WriteLine("\tField Name: {0}", result.FieldName);
            Console.WriteLine("\tResult Name: {0}", result.ResultName);
            Console.WriteLine("\tUnit: {0}", result.Unit);
            Console.WriteLine("\tDefault Rate Set: {0}", result.DefaultRateSet);
            Console.WriteLine("\tCurrency: {0}", result.Currency);
            Console.WriteLine("\tResult Code: {0}", result.ResultCode);
        }

        Console.WriteLine("Referenced Projects:");
        foreach (ResourceFileReferencedProject project in resourceFile.ReferencedProjects) {
            Console.WriteLine("\tName: {0}", project.Name);
            Console.WriteLine("\tDescription: {0}", project.Description);
        }
    }

    Console.WriteLine("Getting resource files with their properties completed successfully.");
}
else
    Console.WriteLine("Getting resource files with their properties did not completed successfully.");

cobraServices.Logout();
See Also