public void CreateAreas()
        {
            TfsTeamProjectCollection tpc = TfsConnect();
            XmlDocument xmlInput         = new XmlDocument();

            xmlInput.Load(InputFile);
            int         count = 0;
            XmlNodeList areas = xmlInput.SelectNodes("//areas/area");

            foreach (XmlNode area in areas)
            {
                count++;
                Console.Write(".");
                if (area.Attributes["parent"] != null)
                {
                    AddArea(tpc, TeamProject, area.InnerText, area.Attributes["parent"].Value);
                }
                else
                {
                    AddArea(tpc, TeamProject, area.InnerText);
                }
            }

            //  RefreshCache and SyncToCache

            WorkItemStore store = new WorkItemStore(tpc);

            store.RefreshCache();
            store.SyncToCache();

            Console.WriteLine(string.Format(" ({0} areas created)", count));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Associate Work Item to our shelveset
        /// </summary>
        public static void AssociateWorkItemToShelveset()
        {
            WorkItemCheckinInfo work = new WorkItemCheckinInfo(workItemReviewCode, WorkItemCheckinAction.Associate);

            work.CheckinAction = WorkItemCheckinAction.Associate;
            List <WorkItemCheckinInfo> workCollection = new List <WorkItemCheckinInfo>();

            workCollection.Add(work);

            shelveset.WorkItemInfo = workCollection.ToArray();
            if (shelvesetExist)
            {
                //TODO Ne pas remplacer le ShelveSet mais Creér un id Unique
                workspace.Shelve(shelveset, changes, ShelvingOptions.Replace);
            }
            else
            {
                workspace.Shelve(shelveset, changes, ShelvingOptions.None);
                wiStore.SyncToCache();
                wiStore.RefreshCache();
            }
        }
        /// <summary>
        /// Import "My WIT" work item type if it has not been imported yet.
        /// </summary>
        /// <param name="wis">A WorkItemStore instance</param>
        /// <param name="projectName">The name of the team project</param>
        private static void EnsureWITImported(WorkItemStore wis, string projectName)
        {
            Project project = wis.Projects[projectName];

            if (!project.WorkItemTypes.Contains("My WIT"))
            {
                using (var reader = new StreamReader("My WIT.xml"))
                {
                    // Read work item definition from "My WIT.xml".
                    var definition = reader.ReadToEnd();

                    // Import the work item definition.
                    project.WorkItemTypes.Import(definition);

                    // Refresh work item cache.
                    wis.RefreshCache();

                    // Switch the WorkItemStore instance to use the latest metadata.
                    wis.SyncToCache();
                }
            }
        }
        public void CreateIterations()
        {
            try
            {
                TfsTeamProjectCollection tpc = TfsConnect();
                DateTime startDate           = DateTime.Today;
                int      count = 0;

                // Get service and hierarchy

                ICommonStructureService4 css = tpc.GetService <ICommonStructureService4>();
                ProjectInfo project          = css.GetProjectFromName(TeamProject);
                NodeInfo[]  hierarchy        = css.ListStructures(project.Uri);
                XmlElement  tree;
                if (hierarchy[0].Name.ToLower() == "iteration")
                {
                    tree = css.GetNodesXml(new string[] { hierarchy[0].Uri }, true);
                }
                else
                {
                    tree = css.GetNodesXml(new string[] { hierarchy[1].Uri }, true);
                }
                string parentUri  = tree.FirstChild.Attributes["NodeID"].Value;
                int    lastSprint = 1;

                for (int release = 1; release <= TotalReleases; release++)
                {
                    string releaseUri = css.CreateNode("Release " + release.ToString(), parentUri);
                    css.SetIterationDates(releaseUri, startDate, startDate.AddDays(SprintsPerRelease * WeeksPerSprint * 7 - 1));
                    for (int sprint = 1; sprint <= SprintsPerRelease; sprint++)
                    {
                        string sprintUri;
                        count++;
                        Console.Write(".");
                        if (ResetSprintsEachRelease)
                        {
                            sprintUri = css.CreateNode("Sprint " + sprint.ToString(), releaseUri);
                        }
                        else
                        {
                            sprintUri = css.CreateNode("Sprint " + lastSprint, releaseUri);
                        }
                        css.SetIterationDates(sprintUri, startDate, startDate.AddDays(WeeksPerSprint * 7 - 1));
                        startDate = startDate.AddDays(WeeksPerSprint * 7);
                        lastSprint++;
                    }
                }

                //  RefreshCache and SyncToCache

                WorkItemStore store = new WorkItemStore(tpc);
                store.RefreshCache();
                store.SyncToCache();

                Console.WriteLine(string.Format(" ({0} releases, {1} sprints created)", TotalReleases, count));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                throw;
            }
        }