コード例 #1
0
        public FormLayout Layout_Get()
        {
            //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 layout for '{0}'....", _witRefName);

            FormLayout layout = client.GetFormLayoutAsync(processId, _witRefName).Result;

            Console.WriteLine("success");
            Console.WriteLine("");

            List <Page> pages = layout.Pages as List <Page>;

            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(layout);
        }
コード例 #2
0
        public Group Group_AddWithFields()
        {
            //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 form layout to find all pages, sections, and groups...");

            FormLayout layout = client.GetFormLayoutAsync(processId, _witRefName).Result;

            //searching through the layout page to find the right page, section, and group
            Page  page  = ProcessHelper.getPage(layout, "Details");
            Group group = ProcessHelper.getGroup(layout, "Details", "Section2", "NewGroup");

            Console.WriteLine("done");

            if (group != null)
            {
                Console.WriteLine("Group '{0}' already exists on section '{1}' on page '{2}'", group.Label, "Section2", page.Label);
            }
            else
            {
                Console.Write("Creating new group 'NewGroup'...");

                List <Control> controlList = new List <Control>()
                {
                    new Control()
                    {
                        Id = _fieldRefName, Order = 1, Label = "Colors", Visible = true, Name = "Colors", Watermark = "Select a color"
                    },
                    new Control()
                    {
                        Id = "Microsoft.VSTS.Common.Activity", Order = 2, Label = "Activity", Visible = true
                    }
                };

                Group newGroup = new Group()
                {
                    Controls   = controlList,
                    Id         = null,
                    Label      = "NewGroup",
                    Overridden = false,
                    Visible    = true,
                    Order      = 1
                };

                group = client.AddGroupAsync(newGroup, processId, _witRefName, page.Id, "Section2").Result;

                Console.WriteLine("done");
            }

            return(group);
        }