/// <summary> /// Create a new process and disable it /// </summary> private static void AddAndEditProcess() { string processName = "My New Process"; string processParetName = "Agile"; string processDescription = "My New Process"; string processDescriptionUpdated = "My New Updated Process"; var processes = ProcessHttpClient.GetListOfProcessesAsync().Result; var parentProcessId = (from p in processes where p.Name == processParetName select p.TypeId).FirstOrDefault(); if (parentProcessId != null) { var newProcess = ProcessHttpClient.CreateNewProcessAsync(new CreateProcessModel() { Name = processName, Description = processDescription, ParentProcessTypeId = parentProcessId }).Result; Console.WriteLine("New process: " + newProcess.Name); Console.WriteLine("New process Id: " + newProcess.TypeId); ProcessHttpClient.EditProcessAsync(new UpdateProcessModel { Description = processDescriptionUpdated, IsEnabled = false }, newProcess.TypeId); } else { Console.WriteLine("Can not find parent project"); } }
public ProcessInfo Process_Create() { ProcessInfo processInfo = Process_Get(); if (processInfo != null) { return(processInfo); } //create process model record object that will be used to create the process CreateProcessModel processModel = new CreateProcessModel { Name = "MyNewAgileProcess", ParentProcessTypeId = new System.Guid("adcc42ab-9882-485e-a3ed-7678f01f66bc"), ReferenceName = _refName, Description = "My new process" }; Console.Write("Creating new processes '" + _refName + "'..."); VssConnection connection = Context.Connection; WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>(); try { //save type id for later use processInfo = client.CreateNewProcessAsync(processModel).Result; Console.WriteLine("success"); Console.WriteLine("Process Id: {0}", processInfo.TypeId); Context.SetValue <Guid>("$processId", processInfo.TypeId); } catch (Exception ex) //exception will be thrown if process already exists { Console.WriteLine("failed"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.InnerException.Message); } finally { Console.ForegroundColor = ConsoleColor.White; } return(processInfo); }