public async Task <ProcessWorkItemType> GetWorkItemType(Guid processId, string workItemTypeReferenceName) { var types = await witProcessClient.GetProcessWorkItemTypesAsync(processId); var type = types.FirstOrDefault(t => t.ReferenceName == workItemTypeReferenceName); //FormLayout layout = witProcessClient.GetFormLayoutAsync(processId, workItemTypeReferenceName).Result; //IList<Page> pages = layout.Pages; //foreach (Page page in pages) //{ // Console.WriteLine("{0} ({1})", page.Label, page.Id); // foreach (Section section in page.Sections) // { // Console.WriteLine(" {0}", section.Id); // foreach (Group group in section.Groups) // { // Console.WriteLine(" {0} ({1})", group.Label, group.Id); // } // } //} return(type); }
public ProcessWorkItemType WorkItemTypes_Create() { //get process id stored in cache so we don't have to load it each time System.Guid processId = Context.GetValue <Guid>("$processId"); ProcessWorkItemType processWorkItemType = null; CreateProcessWorkItemTypeRequest createWorkItemType = new CreateProcessWorkItemTypeRequest() { Name = "Change Request", Description = "Change request to track requests for changes :)", Color = "f6546a", Icon = "icon_airplane" //InheritsFrom = "Microsoft.VSTS.WorkItemTypes.UserStory" }; VssConnection connection = Context.Connection; WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>(); Console.Write("Does work item type '{0}' already exists? ... ", createWorkItemType.Name); //get list of work item types and see if wit exists List <ProcessWorkItemType> list = client.GetProcessWorkItemTypesAsync(processId).Result; processWorkItemType = list.Find(x => x.Name == "Change Request"); if (processWorkItemType == null) { Console.WriteLine("No"); Console.WriteLine(""); Console.Write("Creating new work item type '" + createWorkItemType.Name + "'..."); try { //create new work item type processWorkItemType = client.CreateProcessWorkItemTypeAsync(createWorkItemType, processId).Result; Console.WriteLine("success"); Console.WriteLine("{0} : {1}", processWorkItemType.Name, processWorkItemType.ReferenceName); } catch (Exception ex) { Console.WriteLine("failed"); Console.WriteLine("Error creating work item type: " + ex.InnerException.Message); } } else { Console.WriteLine("Yes"); Console.WriteLine("{0} : {1}", processWorkItemType.Name, processWorkItemType.ReferenceName); } Context.SetValue <ProcessWorkItemType>("$newWorkItemType", processWorkItemType); return(processWorkItemType); }
public static List <ProcessWorkItemType> GetWorkItemTypes(VssConnection connection, System.Guid processId) { WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>(); try { List <ProcessWorkItemType> list = client.GetProcessWorkItemTypesAsync(processId).Result; return(list); } catch (Exception) { return(null); } }
public List <ProcessWorkItemType> WorkItemTypes_List() { //get process id stored in cache so we don't have to load it each time System.Guid processId = Context.GetValue <Guid>("$processId"); VssConnection connection = Context.Connection; WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>(); Console.Write("Getting list of work item types for '" + processId.ToString() + "'..."); List <ProcessWorkItemType> list = client.GetProcessWorkItemTypesAsync(processId).Result; Console.WriteLine("success"); foreach (var item in list) { Console.WriteLine("{0} : {1}", item.Name, item.ReferenceName); } return(list); }
public static List <FieldsPerProcess> ListFieldsForProcess(VssConnection connection, string process) { WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>(); List <FieldsPerProcess> list = new List <FieldsPerProcess>(); //get the process by name List <ProcessInfo> listProcess = client.GetListOfProcessesAsync().Result; ProcessInfo processInfo = listProcess.Find(x => x.Name == process); //if processInfo is null then just return null if (processInfo == null) { return(null); } //get list of work item types per the processid List <ProcessWorkItemType> listWorkItemTypes = client.GetProcessWorkItemTypesAsync(processInfo.TypeId).Result; //loop thru each wit and get the list of fields //add to viewmodel object and return that foreach (ProcessWorkItemType wit in listWorkItemTypes) { List <ProcessWorkItemTypeField> listFields = client.GetAllWorkItemTypeFieldsAsync(processInfo.TypeId, wit.ReferenceName).Result; if (listFields.Count > 0) { list.Add(new FieldsPerProcess() { workItemType = wit, fields = listFields }); } else { list.Add(null); } } return(list); }