示例#1
0
        public List <ProcessInfo> Process_List()
        {
            VssConnection connection = Context.Connection;
            WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>();

            Console.Write("Getting list of processes....");

            List <ProcessInfo> list = client.GetListOfProcessesAsync().Result;

            if (list == null || list.Count == 0)
            {
                Console.WriteLine("No processes found");
            }
            else
            {
                Console.WriteLine("Done");

                foreach (var item in list)
                {
                    Console.WriteLine("{0}    {1}    {2}", item.Name, item.TypeId, item.ReferenceName);
                }
            }

            return(list);
        }
示例#2
0
        public ProcessInfo Process_Get()
        {
            ProcessInfo processInfo = null;

            VssConnection connection = Context.Connection;
            WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>();

            //extra step to get the process by name
            //you should not have to do this
            List <ProcessInfo> list = client.GetListOfProcessesAsync().Result;
            ProcessInfo        item = list.Find(x => x.ReferenceName == _refName);

            //we did not find the process by name
            if (item == null)
            {
                Console.WriteLine("Process '{0}' not found", _refName);
                return(null);
            }

            //we found something, so lets store the id in cache
            Context.SetValue <Guid>("$processId", item.TypeId);

            //load the process by id
            processInfo = client.GetProcessByItsIdAsync(item.TypeId).Result;

            Console.WriteLine("Get process...success");
            Console.WriteLine("{0}    {1}", _refName, processInfo.TypeId);

            return(processInfo);
        }
示例#3
0
        public ProcessInfo Get()
        {
            System.Guid processTypeId;
            ProcessInfo processInfo = null;

            VssConnection connection = Context.Connection;
            WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>();

            Console.Write("Get process....");

            //get a list of the procesess so i can pull the right process and get the id
            //shouldn't need to do this in production code. Just save the typeId to load process directly
            List <ProcessInfo> list = client.GetListOfProcessesAsync().Result;

            //get the process for a specific refname
            var item = list.Find(x => x.ReferenceName == _refname);

            if (item == null)
            {
                Console.WriteLine("Failed");
                Console.WriteLine("No process found for '{0}'", _refname);
            }
            else
            {
                processTypeId = item.TypeId;

                //load the process by id
                processInfo = client.GetProcessByItsIdAsync(processTypeId).Result;

                Console.WriteLine("success");
                Console.WriteLine("{0}    {1}", _refname, processInfo.TypeId);
            }

            return(processInfo);
        }
示例#4
0
        /// <summary>
        /// Remove an existing project
        /// </summary>
        private static void RemoveProcess()
        {
            string processName = "My New Process";

            var processes = ProcessHttpClient.GetListOfProcessesAsync().Result;

            var processToRemoveId = (from p in processes where p.Name == processName select p.TypeId).FirstOrDefault();

            if (processToRemoveId != null)
            {
                ProcessHttpClient.DeleteProcessByIdAsync(processToRemoveId).Wait();

                Console.WriteLine("Done");
            }
            else
            {
                Console.WriteLine("Can not find project to remove");
            }
        }
        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);
        }
        public static List <ProcessInfo> GetProcesses(VssConnection connection)
        {
            WorkItemTrackingProcessHttpClient client = connection.GetClient <WorkItemTrackingProcessHttpClient>();

            try
            {
                List <Microsoft.TeamFoundation.WorkItemTracking.Process.WebApi.Models.ProcessInfo> list = client.GetListOfProcessesAsync().Result;

                return(list);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public async Task <ProcessInfo> GetProcessByName(string processName)
        {
            var processes = await witProcessClient.GetListOfProcessesAsync();

            return(processes.FirstOrDefault(p => p.Name.ToLower() == processName.ToLower()));
        }