ProjectOperationsGetProjectProperties Method |
Get a list of projects 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 Exceptions Exception | Condition |
---|
InvalidOperationException | Thrown 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 projects with their properties.
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 = 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.");
ProjectOperations projectOperations = cobraServices.CreateServiceOperations<ProjectOperations>();
ProjectPropertiesFilter projectPropertiesFilter = projectOperations.CreateProjectOperationsServiceArguments<ProjectPropertiesFilter>();
projectPropertiesFilter.ProjectFilter = projectOperations.CreateProjectOperationsServiceArguments<ProjectFilter>();
projectPropertiesFilter.ProjectFilter.Operator = FilterStringOperator.Like;
projectPropertiesFilter.ProjectFilter.Value = "Demo%";
Console.WriteLine("Getting projects with their properties...");
ProjectPropertiesCollection projectProperties = projectOperations.GetProjectProperties(projectPropertiesFilter);
bool hasError = false;
foreach (ServiceMessage serviceMessage in projectProperties.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 (ProjectProperties project in projectProperties) {
Console.WriteLine("Name: {0}", project.Name);
Console.WriteLine("Description: {0}", project.Description);
Console.WriteLine("Is Master Project: {0}", project.IsMasterProject);
Console.WriteLine("Project Key Fields:");
Console.WriteLine("\tControl Account 1:");
Console.WriteLine("\t\tPrompt: {0}", project.Fields.ControlAccountField1.Prompt);
Console.WriteLine("\t\tCode File: {0}", project.Fields.ControlAccountField1.CodeFile);
if (project.Fields.ControlAccountField2 != null) {
Console.WriteLine("\tControl Account 2:");
Console.WriteLine("\t\tPrompt: {0}", project.Fields.ControlAccountField2.Prompt);
Console.WriteLine("\t\tCode File: {0}", project.Fields.ControlAccountField2.CodeFile);
}
if (project.Fields.ControlAccountField3 != null) {
Console.WriteLine("\tControl Account 3:");
Console.WriteLine("\t\tPrompt: {0}", project.Fields.ControlAccountField3.Prompt);
Console.WriteLine("\t\tCode File: {0}", project.Fields.ControlAccountField3.CodeFile);
}
Console.WriteLine("\tWork Package:");
Console.WriteLine("\t\tPrompt: {0}", project.Fields.WorkPackageField.Prompt);
Console.WriteLine("\t\tCode File: {0}", project.Fields.WorkPackageField.CodeFile);
Console.WriteLine("Project Code Fields:");
Console.WriteLine("\tControl Account:");
foreach(ProjectCodeField codeField in project.Fields.ControlAccountCodes) {
Console.WriteLine("\t\tNumber: {0}", codeField.Number);
Console.WriteLine("\t\tPrompt: {0}", codeField.Prompt);
Console.WriteLine("\t\tType: {0}", codeField.CodeFieldType);
Console.WriteLine("\t\tFile: {0}", codeField.CodeFile);
}
Console.WriteLine("\tWork Package:");
foreach (ProjectCodeField codeField in project.Fields.WorkPackageCodes) {
Console.WriteLine("\t\tNumber: {0}", codeField.Number);
Console.WriteLine("\t\tPrompt: {0}", codeField.Prompt);
Console.WriteLine("\t\tType: {0}", codeField.CodeFieldType);
Console.WriteLine("\t\tFile: {0}", codeField.CodeFile);
}
Console.WriteLine("\tResource Assignment:");
foreach (ProjectCodeField codeField in project.Fields.ResourceAssignmentCodes) {
Console.WriteLine("\t\tNumber: {0}", codeField.Number);
Console.WriteLine("\t\tPrompt: {0}", codeField.Prompt);
Console.WriteLine("\t\tType: {0}", codeField.CodeFieldType);
Console.WriteLine("\t\tFile: {0}", codeField.CodeFile);
}
Console.WriteLine("Files:");
Console.WriteLine("\tCalendar: {0}", project.Files.Calendar);
Console.WriteLine("\tRate: {0}", project.Files.Rate);
Console.WriteLine("\tResource: {0}", project.Files.Resource);
if (project.Files.RollingWave != null) {
Console.WriteLine("\tRolling Wave:");
Console.WriteLine("\t\tCalendar: {0}", project.Files.RollingWave.Calendar);
}
Console.WriteLine("Classes:");
foreach(Class @class in project.Classes) {
Console.WriteLine("\tName: {0}", @class.Name);
Console.WriteLine("\tDescription: {0}", @class.Description);
Console.WriteLine("\tType: {0}", @class.ClassType);
Console.WriteLine("\tLevel: {0}", @class.Level);
}
}
Console.WriteLine("Getting projects with their properties completed successfully.");
}
else
Console.WriteLine("Getting projects with their properties did not completed successfully.");
cobraServices.Logout();
See Also