public List <Process> GetProcesses() { // create project object using (ProcessHttpClient processHttpClient = new ProcessHttpClient(_uri, _credentials)) { List <Process> processes = processHttpClient.GetProcessesAsync().Result; return(processes); } }
public List <Process> GetProcesses() { // Create instance of VssConnection using passed credentials VssConnection connection = new VssConnection(_uri, _credentials); ProcessHttpClient processHttpClient = connection.GetClient <ProcessHttpClient>(); List <Process> processes = processHttpClient.GetProcessesAsync().Result; return(processes); }
public static Process GetProcessTemplate(VssConnection connection, string processTemplateName) { // list all processes ProcessHttpClient processClient = connection.GetClient <ProcessHttpClient>(); var allProcesses = processClient.GetProcessesAsync().Result; var process = allProcesses.FirstOrDefault(item => item.Name == processTemplateName); return(process); }
public List <Process> ListProcesses() { VssConnection connection = Context.Connection; ProcessHttpClient processClient = connection.GetClient <ProcessHttpClient>(); List <Process> processes = processClient.GetProcessesAsync().Result; foreach (var process in processes) { Console.WriteLine("{0} {1} {2}", (process.IsDefault ? "*" : " "), process.Name.PadRight(12), process.Id); } return(processes); }
/// <summary> /// Get all processtemplates from the VSTS server /// </summary> /// <param name="logMessages">Indicator if logging will be shown</param> /// <returns>List of all processtemplates in VSTS</returns> public static List <Process> GetAllProcessTemplates(bool logMessages = true) { Console.WriteLine($"Checking available processes in VSTS"); ProcessHttpClient processClient = connection.GetClient <ProcessHttpClient>(); var processes = processClient.GetProcessesAsync().Result; if (logMessages) { Console.WriteLine($"Found {processes.Count} processes, incl. defaults"); } return(processes.OrderBy(item => item.Name).ToList()); }
/// <summary> /// List all process templates, with multiple properties /// </summary> /// <param name="totalWidth">Padding to use to create columns</param> public static void ListAllProcessTemplates(int totalWidth) { // list all processes ProcessHttpClient processClient = connection.GetClient <ProcessHttpClient>(); var processes = processClient.GetProcessesAsync().Result; Console.WriteLine($"Found {processes.Count} processes"); foreach (var process in processes.OrderBy(item => item.Name)) { // var fullProcess = processClient.GetProcessByIdAsync(process.Id).Result; Console.WriteLine($"\t{(process.IsDefault ? "*" : " ")} Name: {process.Name.PadRight(totalWidth)} Id: {process.Id}, Type: {process.Type}"); } Console.WriteLine(); }
internal async Task <TeamProject> CreateProject(string projectName, string projectDescription = "", string processName = "Scrum") { Logger.Log(LogLevel.Warning, $"Project '{projectName}' does not exist."); Console.WriteLine("Would you like to create one? (Y/N)"); var answer = Console.ReadKey(); if (answer.KeyChar != 'Y' && answer.KeyChar != 'y') { return(null); } Logger.Log(LogLevel.Info, $"Creating project '{projectName}'."); // Setup version control properties Dictionary <string, string> versionControlProperties = new Dictionary <string, string> { [TeamProjectCapabilitiesConstants.VersionControlCapabilityAttributeName] = SourceControlTypes.Git.ToString() }; // Setup process properties ProcessHttpClient processClient = RestConnection.GetClient <ProcessHttpClient>(); Guid processId = processClient.GetProcessesAsync().Result.Find(process => { return(process.Name.Equals(processName, StringComparison.InvariantCultureIgnoreCase)); }).Id; Dictionary <string, string> processProperaties = new Dictionary <string, string> { [TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityTemplateTypeIdAttributeName] = processId.ToString() }; // Construct capabilities dictionary Dictionary <string, Dictionary <string, string> > capabilities = new Dictionary <string, Dictionary <string, string> > { [TeamProjectCapabilitiesConstants.VersionControlCapabilityName] = versionControlProperties, [TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityName] = processProperaties }; // Construct object containing properties needed for creating the project TeamProject projectCreateParameters = new TeamProject() { Name = projectName, Description = projectDescription, Capabilities = capabilities }; // Get a client ProjectHttpClient projectClient = RestConnection.GetClient <ProjectHttpClient>(); TeamProject project = null; try { Logger.Log(LogLevel.Info, "Queuing project creation..."); // Queue the project creation operation // This returns an operation object that can be used to check the status of the creation OperationReference operation = await projectClient.QueueCreateProject(projectCreateParameters); // Check the operation status every 5 seconds (for up to 30 seconds) Operation completedOperation = WaitForLongRunningOperation(operation.Id, 5, 30).Result; // Check if the operation succeeded (the project was created) or failed if (completedOperation.Status == OperationStatus.Succeeded) { // Get the full details about the newly created project project = projectClient.GetProject( projectCreateParameters.Name, includeCapabilities: true, includeHistory: true).Result; Logger.Log(LogLevel.Info, $"Project created (ID: {project.Id})"); } else { Logger.Log(LogLevel.Error, "Project creation operation failed: " + completedOperation.ResultMessage); } } catch (Exception ex) { Logger.Log(ex, "Exception during create project.", LogLevel.Critical); } return(project); }
public TeamProject CreateProject() { string projectName = "Sample project " + Guid.NewGuid(); string projectDescription = "Short description for my new project"; string processName = "Agile"; // Setup version control properties Dictionary <string, string> versionControlProperties = new Dictionary <string, string>(); versionControlProperties[TeamProjectCapabilitiesConstants.VersionControlCapabilityAttributeName] = SourceControlTypes.Git.ToString(); // Setup process properties ProcessHttpClient processClient = Context.Connection.GetClient <ProcessHttpClient>(); Guid processId = processClient.GetProcessesAsync().Result.Find(process => { return(process.Name.Equals(processName, StringComparison.InvariantCultureIgnoreCase)); }).Id; Dictionary <string, string> processProperaties = new Dictionary <string, string>(); processProperaties[TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityTemplateTypeIdAttributeName] = processId.ToString(); // Construct capabilities dictionary Dictionary <string, Dictionary <string, string> > capabilities = new Dictionary <string, Dictionary <string, string> >(); capabilities[TeamProjectCapabilitiesConstants.VersionControlCapabilityName] = versionControlProperties; capabilities[TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityName] = processProperaties; // Construct object containing properties needed for creating the project TeamProject projectCreateParameters = new TeamProject() { Name = projectName, Description = projectDescription, Capabilities = capabilities }; // Get a client VssConnection connection = Context.Connection; ProjectHttpClient projectClient = connection.GetClient <ProjectHttpClient>(); TeamProject project = null; try { Console.WriteLine("Queuing project creation..."); // Queue the project creation operation // This returns an operation object that can be used to check the status of the creation OperationReference operation = projectClient.QueueCreateProject(projectCreateParameters).Result; ClientSampleHttpLogger.SetSuppressOutput(Context, true); // Check the operation status every 5 seconds (for up to 30 seconds) Operation completedOperation = WaitForLongRunningOperation(operation.Id, 5, 30).Result; // Check if the operation succeeded (the project was created) or failed if (completedOperation.Status == OperationStatus.Succeeded) { // Get the full details about the newly created project project = projectClient.GetProject( projectCreateParameters.Name, includeCapabilities: true, includeHistory: true).Result; Console.WriteLine(); Console.WriteLine("Project created (ID: {0})", project.Id); // Save the newly created project (other sample methods will use it) Context.SetValue <TeamProject>("$newProject", project); } else { Console.WriteLine("Project creation operation failed: " + completedOperation.ResultMessage); } } catch (Exception ex) { Console.WriteLine("Exception during create project: ", ex.Message); } return(project); }