Click or drag to resize

ExplorerOperationsGetMasterAndSubProjects Method

Retrieves list of master projects and their sub-projects.

Namespace:  Cobra.WebService.ClientAPI.Application.Explorer
Assembly:  Cobra.WebService.ClientAPI (in Cobra.WebService.ClientAPI.dll) Version: 8.4.717.3176 (8.4.0717.3176)
Syntax
C#
public MasterAndSubProjectCollection GetMasterAndSubProjects(
	MasterAndSubProjectsFilter masterAndSubProjectsFilter
)

Parameters

masterAndSubProjectsFilter
Type: Cobra.Model.WebServiceMasterAndSubProjectsFilter
An instance of MasterAndSubProjectsFilter class containing the filters applied to the list of master projects and their sub-projects.

Return Value

Type: MasterAndSubProjectCollection
An instance of MasterAndSubProjectCollection containing the list of master projects and their sub-projects.
Exceptions
ExceptionCondition
InvalidOperationExceptionThrown when state of the instance of the CobraServices that generated the current ExplorerOperations is not in opened state.
Examples
This example shows how to get list of master projects and their sub-projects.
C#
using Cobra.Model.WebService;
using Cobra.WebService.ClientAPI.Application.Explorer;
using Cobra.WebService.ClientAPI.Client;

.
.
.

CobraServices cobraServices = new CobraServices();
cobraServices.ServiceIdentityData.Username = "SYSADMIN";
cobraServices.ServiceIdentityData.SecurePassword = new SecurePassword();
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.");

ExplorerOperations explorerOperations = cobraServices.CreateServiceOperations<ExplorerOperations>();
MasterAndSubProjectsFilter masterAndSubProjectsFilter = explorerOperations.CreateExplorerOperationsServiceArguments<MasterAndSubProjectsFilter>();
masterAndSubProjectsFilter.ProjectFilter = explorerOperations.CreateExplorerOperationsServiceArguments<ProjectFilter>();
masterAndSubProjectsFilter.ProjectFilter.Value = "Demos";

Console.WriteLine("Getting master projects with their sub-projects...");
MasterAndSubProjectCollection masterAndSubProjects = explorerOperations.GetMasterAndSubProjects(masterAndSubProjectsFilter);

bool hasError = false;
foreach (ServiceMessage serviceMessage in masterAndSubProjects.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 (MasterAndSubProjects masterProject in masterAndSubProjects) {
        Console.WriteLine("Name: {0}", masterProject.Name);
        Console.WriteLine("Description: {0}", masterProject.Description);

        Console.WriteLine("Sub-Projects:");
        foreach(SubProject subProject in masterProject.SubProjects) {
            Console.WriteLine("\tName: {0}", subProject.Name);
            Console.WriteLine("\tDescription: {0}", subProject.Description);
        }
    }

    Console.WriteLine("Getting master projects with their sub-projects completed successfully.");
}
else
    Console.WriteLine("Getting master projects with their sub-projects did not completed successfully.");

cobraServices.Logout();
See Also