private void addItemsFromFilesHyperlink_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Title       = "Please select the work item configuration files (*.xml) to compare with.";
            dialog.Filter      = "XML Files (*.xml)|*.xml";
            dialog.Multiselect = true;
            var result = dialog.ShowDialog(Application.Current.MainWindow);

            if (result == true)
            {
                foreach (var file in dialog.FileNames)
                {
                    try
                    {
                        this.Configuration.Items.Add(WorkItemConfigurationItem.FromFile(file));
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show("An error occurred while loading the work item configuration file: " + exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                UpdateUI();
            }
        }
        public static WorkItemConfiguration FromTeamProject(TfsTeamProjectCollection tfs, Project project)
        {
            // Export work item type definitions.
            var projectWorkItemTypes = new List <WorkItemConfigurationItem>();

            foreach (WorkItemType workItemType in project.WorkItemTypes)
            {
                projectWorkItemTypes.Add(WorkItemConfigurationItem.FromXml(workItemType.Export(false)));
            }

            // Export categories.
            projectWorkItemTypes.Add(WorkItemConfigurationItemImportExport.GetCategories(project));

            // Export process configuration.
            var commonConfig = WorkItemConfigurationItemImportExport.GetCommonConfiguration(project);

            if (commonConfig != null)
            {
                projectWorkItemTypes.Add(commonConfig);
            }
            var agileConfig = WorkItemConfigurationItemImportExport.GetAgileConfiguration(project);

            if (agileConfig != null)
            {
                projectWorkItemTypes.Add(agileConfig);
            }
            var processConfig = WorkItemConfigurationItemImportExport.GetProcessConfiguration(project);

            if (processConfig != null)
            {
                projectWorkItemTypes.Add(processConfig);
            }

            return(new WorkItemConfiguration(project.Name, projectWorkItemTypes));
        }
        private void ImportProcessConfigurations(object argument)
        {
            var options = ImportOptions.None;

            if (this.Simulate)
            {
                options |= ImportOptions.Simulate;
            }
            if (this.SaveCopy)
            {
                options |= ImportOptions.SaveCopy;
            }
            var result = MessageBoxResult.Yes;

            if (!options.HasFlag(ImportOptions.Simulate))
            {
                result = MessageBox.Show("This will import the specified process configurations. Are you sure you want to continue?", "Confirm Import", MessageBoxButton.YesNo, MessageBoxImage.Warning);
            }
            if (result == MessageBoxResult.Yes)
            {
                var processConfigurations = new List <WorkItemConfigurationItem>();
                if (this.SelectedTeamProjectCollection.TeamFoundationServer.MajorVersion >= TfsMajorVersion.V12)
                {
                    if (File.Exists(this.ProcessConfigurationFilePath))
                    {
                        processConfigurations.Add(WorkItemConfigurationItem.FromFile(this.ProcessConfigurationFilePath));
                    }
                }
                else
                {
                    if (File.Exists(this.CommonConfigurationFilePath))
                    {
                        processConfigurations.Add(WorkItemConfigurationItem.FromFile(this.CommonConfigurationFilePath));
                    }
                    if (File.Exists(this.AgileConfigurationFilePath))
                    {
                        processConfigurations.Add(WorkItemConfigurationItem.FromFile(this.AgileConfigurationFilePath));
                    }
                }
                var teamProjectsWithProcessConfigurations = this.SelectedTeamProjects.ToDictionary(p => p, p => processConfigurations);
                PerformImport(teamProjectsWithProcessConfigurations, options);
            }
        }
Пример #4
0
        private void LoadComparisonSources(object argument)
        {
            var dialog = new OpenFileDialog();

            dialog.Title  = "Please select the comparison source list (*.xml) to load.";
            dialog.Filter = "XML Files (*.xml)|*.xml";
            var result = dialog.ShowDialog(Application.Current.MainWindow);

            if (result == true)
            {
                try
                {
                    var persistedSources = SerializationProvider.Read <WorkItemConfigurationPersistenceData[]>(dialog.FileName);
                    this.ComparisonSources.Clear();
                    foreach (var persistedSource in persistedSources)
                    {
                        var items = new List <WorkItemConfigurationItem>();
                        foreach (var itemXml in persistedSource.WorkItemConfigurationItems)
                        {
                            try
                            {
                                items.Add(WorkItemConfigurationItem.FromXml(itemXml));
                            }
                            catch (ArgumentException)
                            {
                            }
                        }
                        this.ComparisonSources.Add(new WorkItemConfiguration(persistedSource.Name, items));
                    }
                }
                catch (Exception exc)
                {
                    this.Logger.Log(string.Format(CultureInfo.CurrentCulture, "An error occurred while loading the work item configuration list from \"{0}\"", dialog.FileName), exc);
                    MessageBox.Show("An error occurred while loading the work item configuration list. See the log file for details", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }
Пример #5
0
        public static XmlDocument GetNormalizedXmlDefinition(WorkItemConfigurationItem item, TfsMajorVersion tfsMajorVersion)
        {
            var normalizedXmlDefinition = new XmlDocument();

            normalizedXmlDefinition.LoadXml(item.XmlDefinition.OuterXml);

            // Perform pre-normalization.
            PreNormalizeXml(normalizedXmlDefinition);

            // Perform type-specific normalization.
            if (item.Type == WorkItemConfigurationItemType.WorkItemType)
            {
                NormalizeWorkItemTypeDefinition(normalizedXmlDefinition, tfsMajorVersion);
            }
            else if (item.Type == WorkItemConfigurationItemType.AgileConfiguration)
            {
                NormalizeAgileConfiguration(normalizedXmlDefinition);
            }
            else if (item.Type == WorkItemConfigurationItemType.CommonConfiguration)
            {
                NormalizeCommonConfiguration(normalizedXmlDefinition);
            }
            else if (item.Type == WorkItemConfigurationItemType.ProcessConfiguration)
            {
                NormalizeProcessConfiguration(normalizedXmlDefinition);
            }
            else if (item.Type == WorkItemConfigurationItemType.Categories)
            {
                NormalizeCategories(normalizedXmlDefinition);
            }

            // Perform other normalization after the specific normalization (nodes could have been added or removed).
            PostNormalizeXml(normalizedXmlDefinition);

            return(normalizedXmlDefinition);
        }
Пример #6
0
 public WorkItemConfigurationItemExport(TeamProjectInfo teamProject, WorkItemConfigurationItem item)
     : this(teamProject, item, null)
 {
 }
        public static WorkItemConfiguration FromProcessTemplate(string processTemplateFileName)
        {
            // Load the process template XML.
            if (!File.Exists(processTemplateFileName))
            {
                throw new FileNotFoundException("The process template file does not exist: " + processTemplateFileName);
            }
            var processTemplate = new XmlDocument();

            processTemplate.Load(processTemplateFileName);
            var    baseDir                 = Path.GetDirectoryName(processTemplateFileName);
            var    items                   = new List <WorkItemConfigurationItem>();
            string processTemplateName     = null;
            var    processTemplateNameNode = processTemplate.SelectSingleNode("/ProcessTemplate/metadata/name");

            if (processTemplateNameNode != null)
            {
                processTemplateName = processTemplateNameNode.InnerText;
            }

            // Find the work item tracking XML file.
            var workItemFileNameAttribute = processTemplate.SelectSingleNode("/ProcessTemplate/groups/group[@id='WorkItemTracking']/taskList/@filename");

            if (workItemFileNameAttribute != null)
            {
                // Load the work item tracking XML.
                var workItemConfigurationTemplateFileName = Path.Combine(baseDir, workItemFileNameAttribute.InnerText);
                if (!File.Exists(workItemConfigurationTemplateFileName))
                {
                    throw new FileNotFoundException("The work item configuration file defined in the process template file does not exist: " + workItemConfigurationTemplateFileName);
                }
                var workItemConfigurationTemplate = new XmlDocument();
                workItemConfigurationTemplate.Load(workItemConfigurationTemplateFileName);

                // Find all work item type definition XML files.
                foreach (XmlAttribute witFileNameAttribute in workItemConfigurationTemplate.SelectNodes("/tasks/task[@id='WITs']/taskXml/WORKITEMTYPES/WORKITEMTYPE/@fileName"))
                {
                    var witFileName = Path.Combine(baseDir, witFileNameAttribute.InnerText);
                    items.Add(WorkItemTypeDefinition.FromFile(witFileName));
                }

                // Find the categories XML file.
                var categoriesFileNameAttribute = workItemConfigurationTemplate.SelectSingleNode("/tasks/task[@id='Categories']/taskXml/CATEGORIES/@fileName");
                if (categoriesFileNameAttribute != null)
                {
                    var categoriesFileName = Path.Combine(baseDir, categoriesFileNameAttribute.InnerText);
                    items.Add(WorkItemConfigurationItem.FromFile(categoriesFileName));
                }
                else
                {
                    // If the process template doesn't specify any categories (typically because it's an old
                    // process template from before Work Item Categories existed), load an empty list anyway.
                    // This will improve comparisons because a Team Project will always have a Work Item
                    // Categories configuration item (even if it's empty).
                    items.Add(WorkItemConfigurationItem.FromXml("<cat:CATEGORIES xmlns:cat=\"http://schemas.microsoft.com/VisualStudio/2008/workitemtracking/categories\"/>"));
                }

                // Find the common configuration XML file.
                var commonConfigurationFileNameAttribute = workItemConfigurationTemplate.SelectSingleNode("/tasks/task[@id='ProcessConfiguration']/taskXml/PROCESSCONFIGURATION/CommonConfiguration/@fileName");
                if (commonConfigurationFileNameAttribute != null)
                {
                    var commonConfigurationFileName = Path.Combine(baseDir, commonConfigurationFileNameAttribute.InnerText);
                    items.Add(WorkItemConfigurationItem.FromFile(commonConfigurationFileName));
                }

                // Find the agile configuration XML file.
                var agileConfigurationFileNameAttribute = workItemConfigurationTemplate.SelectSingleNode("/tasks/task[@id='ProcessConfiguration']/taskXml/PROCESSCONFIGURATION/AgileConfiguration/@fileName");
                if (agileConfigurationFileNameAttribute != null)
                {
                    var agileConfigurationFileName = Path.Combine(baseDir, agileConfigurationFileNameAttribute.InnerText);
                    items.Add(WorkItemConfigurationItem.FromFile(agileConfigurationFileName));
                }

                // Find the process configuration XML file.
                var processConfigurationFileNameAttribute = workItemConfigurationTemplate.SelectSingleNode("/tasks/task[@id='ProcessConfiguration']/taskXml/PROCESSCONFIGURATION/ProjectConfiguration/@fileName");
                if (processConfigurationFileNameAttribute != null)
                {
                    var processConfigurationFileName = Path.Combine(baseDir, processConfigurationFileNameAttribute.InnerText);
                    items.Add(WorkItemConfigurationItem.FromFile(processConfigurationFileName));
                }
            }

            return(new WorkItemConfiguration(processTemplateName, items));
        }
Пример #8
0
        private static void SetProcessConfiguration(Project project, WorkItemConfigurationItemType type, WorkItemConfigurationItem item)
        {
            var tfs           = project.Store.TeamProjectCollection;
            var configService = tfs.GetService <ProjectProcessConfigurationService>();

            try
            {
                if (type == WorkItemConfigurationItemType.CommonConfiguration)
                {
                    CommonProjectConfiguration commonConfig;
                    using (var xmlStringReader = new StringReader(item.XmlDefinition.DocumentElement.OuterXml))
                        using (var xmlReader = XmlReader.Create(xmlStringReader))
                        {
                            while (xmlReader.NodeType != XmlNodeType.Element)
                            {
                                xmlReader.Read();
                            }
                            commonConfig = CommonProjectConfiguration.FromXml(tfs, xmlReader);
                        }
                    configService.SetCommonConfiguration(project.Uri.ToString(), commonConfig);
                }
                else if (type == WorkItemConfigurationItemType.AgileConfiguration)
                {
                    AgileProjectConfiguration agileConfig;
                    using (var xmlStringReader = new StringReader(item.XmlDefinition.DocumentElement.OuterXml))
                        using (var xmlReader = XmlReader.Create(xmlStringReader))
                        {
                            while (xmlReader.NodeType != XmlNodeType.Element)
                            {
                                xmlReader.Read();
                            }
                            agileConfig = AgileProjectConfiguration.FromXml(tfs, xmlReader);
                        }
                    configService.SetAgileConfiguration(project.Uri.ToString(), agileConfig);
                }
                else if (type == WorkItemConfigurationItemType.ProcessConfiguration)
                {
                    ProjectProcessConfiguration processConfig;
                    using (var xmlStringReader = new StringReader(item.XmlDefinition.DocumentElement.OuterXml))
                        using (var xmlReader = XmlReader.Create(xmlStringReader))
                        {
                            while (xmlReader.NodeType != XmlNodeType.Element)
                            {
                                xmlReader.Read();
                            }
                            processConfig = ProjectProcessConfiguration.FromXml(tfs, xmlReader);
                        }
                    configService.SetProcessConfiguration(project.Uri.ToString(), processConfig);
                }
                else
                {
                    throw new ArgumentException("The type argument must be either a CommonConfiguration, AgileConfiguration or ProcessConfiguration.");
                }
            }
            catch (NullReferenceException exc)
            {
                // Working with the ProjectProcessConfigurationService throws NullReferenceException on TFS 2010 or earlier.
                throw new InvalidOperationException("The process configuration could not be saved.", exc);
            }
        }
Пример #9
0
 public static void SetAgileConfiguration(Project project, WorkItemConfigurationItem agileConfiguration)
 {
     SetProcessConfiguration(project, WorkItemConfigurationItemType.AgileConfiguration, agileConfiguration);
 }
Пример #10
0
 public static void SetCommonConfiguration(Project project, WorkItemConfigurationItem commonConfiguration)
 {
     SetProcessConfiguration(project, WorkItemConfigurationItemType.CommonConfiguration, commonConfiguration);
 }
Пример #11
0
 public static void SetCategories(Project project, WorkItemConfigurationItem categories)
 {
     SetCategories(project, categories.XmlDefinition);
 }
Пример #12
0
        public static WorkItemConfigurationItem GetCategories(Project project)
        {
            var categoriesXml = GetCategoriesXml(project);

            return(WorkItemConfigurationItem.FromXml(categoriesXml));
        }
 public static new WorkItemTypeDefinition FromFile(string path)
 {
     return(WorkItemConfigurationItem.FromFile <WorkItemTypeDefinition>(path));
 }
 public static new WorkItemTypeDefinition FromXml(XmlDocument xmlDefinition)
 {
     return(WorkItemConfigurationItem.FromXml <WorkItemTypeDefinition>(xmlDefinition));
 }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(WorkItemConfigurationItem.GetDisplayName((WorkItemConfigurationItemType)value));
 }
Пример #16
0
 public WorkItemConfigurationItemExport(TeamProjectInfo teamProject, WorkItemConfigurationItem item, string saveAsFileName)
 {
     this.TeamProject    = teamProject;
     this.Item           = item;
     this.SaveAsFileName = saveAsFileName;
 }
Пример #17
0
 private WorkItemConfigurationTransformationItemEditorDialog(WorkItemConfigurationTransformationItem transformation, bool canCancel)
 {
     InitializeComponent();
     this.Transformation         = transformation;
     this.cancelButton.IsEnabled = canCancel;
     this.workItemConfigurationItemTypesComboBox.ItemsSource = Enum.GetValues(typeof(WorkItemConfigurationItemType)).Cast <WorkItemConfigurationItemType>().Select(t => new { Key = t, Value = WorkItemConfigurationItem.GetDisplayName(t) });
 }
Пример #18
0
 public static void SetProcessConfiguration(Project project, WorkItemConfigurationItem processConfiguration)
 {
     SetProcessConfiguration(project, WorkItemConfigurationItemType.ProcessConfiguration, processConfiguration);
 }
Пример #19
0
 protected override void OnObservablePropertyChanged(ObservablePropertyChangedEventArgs e)
 {
     base.OnObservablePropertyChanged(e);
     if (!string.IsNullOrEmpty(this.Description))
     {
         this.DisplayName = this.Description;
     }
     else
     {
         this.DisplayName = "{0} transformation of {1}".FormatCurrent(this.TransformationType.ToString().ToUpper(), WorkItemConfigurationItem.GetDisplayName(this.WorkItemConfigurationItemType, this.WorkItemTypeNames));
     }
     this.IsValid = !string.IsNullOrWhiteSpace(this.TransformationXml);
 }
Пример #20
0
        private static WorkItemConfigurationItem GetProcessConfiguration(Project project, WorkItemConfigurationItemType type)
        {
            var    configService = project.Store.TeamProjectCollection.GetService <ProjectProcessConfigurationService>();
            string processConfigXml;

            try
            {
                if (type == WorkItemConfigurationItemType.CommonConfiguration)
                {
                    var commonConfig = configService.GetCommonConfiguration(project.Uri.ToString());
                    var configXml    = new StringBuilder();
                    using (var writer = XmlWriter.Create(configXml, new XmlWriterSettings {
                        Indent = true
                    }))
                    {
                        commonConfig.ToXml(writer, WorkItemConfigurationItem.CommonConfigurationXmlElementName);
                    }
                    processConfigXml = configXml.ToString();
                }
                else if (type == WorkItemConfigurationItemType.AgileConfiguration)
                {
                    var agileConfig = configService.GetAgileConfiguration(project.Uri.ToString());
                    var configXml   = new StringBuilder();
                    using (var writer = XmlWriter.Create(configXml, new XmlWriterSettings {
                        Indent = true
                    }))
                    {
                        agileConfig.ToXml(writer, WorkItemConfigurationItem.AgileConfigurationXmlElementName);
                    }
                    processConfigXml = configXml.ToString();
                }
                else if (type == WorkItemConfigurationItemType.ProcessConfiguration)
                {
                    var processConfig = configService.GetProcessConfiguration(project.Uri.ToString());
                    var configXml     = new StringBuilder();
                    using (var writer = XmlWriter.Create(configXml, new XmlWriterSettings {
                        Indent = true
                    }))
                    {
                        processConfig.ToXml(writer, WorkItemConfigurationItem.ProcessConfigurationXmlElementName);
                    }
                    processConfigXml = configXml.ToString();
                }
                else
                {
                    throw new ArgumentException("The type argument must be either a CommonConfiguration, AgileConfiguration or ProcessConfiguration.");
                }
            }
            catch (NullReferenceException)
            {
                // Working with the ProjectProcessConfigurationService throws NullReferenceException on TFS 2010 or earlier.
                return(null);
            }
            catch (SoapException)
            {
                // A Team Project that doesn't have a process configuration yet throws a SOAP exception
                // "TF400572: The Project Process Settings must be configured for this feature to be used".
                return(null);
            }
            return(WorkItemConfigurationItem.FromXml(processConfigXml));
        }