예제 #1
0
 public WorkItemConfigurationItem(WorkItemConfigurationItemType type, string name, XmlDocument xmlDefinition)
 {
     this.Type          = type;
     this.Name          = name ?? GetDisplayName(type);
     this.DisplayName   = GetDisplayName(type, name);
     this.XmlDefinition = xmlDefinition;
 }
예제 #2
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);
            }
        }
예제 #3
0
        public static string GetDisplayName(WorkItemConfigurationItemType type, string workItemTypeName)
        {
            switch (type)
            {
            case WorkItemConfigurationItemType.AgileConfiguration:
                return(WorkItemConfigurationItem.AgileConfigurationName);

            case WorkItemConfigurationItemType.CommonConfiguration:
                return(WorkItemConfigurationItem.CommonConfigurationName);

            case WorkItemConfigurationItemType.ProcessConfiguration:
                return(WorkItemConfigurationItem.ProcessConfigurationName);

            case WorkItemConfigurationItemType.WorkItemType:
                if (!string.IsNullOrEmpty(workItemTypeName))
                {
                    return("{0}: {1}".FormatCurrent(WorkItemConfigurationItem.WorkItemTypeDefinitionName, workItemTypeName));
                }
                else
                {
                    return(WorkItemConfigurationItem.WorkItemTypeDefinitionName);
                }

            case WorkItemConfigurationItemType.Categories:
                return(WorkItemConfigurationItem.CategoriesName);

            default:
                return(type.ToString());
            }
        }
예제 #4
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));
        }
예제 #5
0
 private WorkItemConfigurationItemComparisonResult(XmlDocument normalizedSourceDefinition, XmlDocument normalizedTargetDefinition, string itemName, WorkItemConfigurationItemType type, ICollection <WorkItemConfigurationItemPartComparisonResult> partResults, ComparisonStatus?status)
 {
     this.NormalizedSourceDefinition = normalizedSourceDefinition;
     this.NormalizedTargetDefinition = normalizedTargetDefinition;
     this.ItemName     = itemName;
     this.Type         = type;
     this.PartResults  = partResults ?? new WorkItemConfigurationItemPartComparisonResult[0];
     this.Status       = status.HasValue ? status.Value : (this.PartResults.Any(r => r.Status == ComparisonStatus.AreDifferent) ? ComparisonStatus.AreDifferent : ComparisonStatus.AreEqual);
     this.PercentMatch = this.PartResults.Sum(r => r.Status == ComparisonStatus.AreEqual ? r.RelativeSize : 0.0);
 }
예제 #6
0
 public WorkItemConfigurationItemComparisonResult(XmlDocument normalizedSourceDefinition, XmlDocument normalizedTargetDefinition, string itemName, WorkItemConfigurationItemType type, ICollection <WorkItemConfigurationItemPartComparisonResult> partResults)
     : this(normalizedSourceDefinition, normalizedTargetDefinition, itemName, type, partResults, null)
 {
 }
예제 #7
0
 public WorkItemConfigurationItemComparisonResult(XmlDocument normalizedSourceDefinition, XmlDocument normalizedTargetDefinition, string itemName, WorkItemConfigurationItemType type, ComparisonStatus status)
     : this(normalizedSourceDefinition, normalizedTargetDefinition, itemName, type, null, status)
 {
 }
예제 #8
0
 public WorkItemConfigurationItem(WorkItemConfigurationItemType type, XmlDocument xmlDefinition)
     : this(type, null, xmlDefinition)
 {
 }
예제 #9
0
 public static string GetDisplayName(WorkItemConfigurationItemType type)
 {
     return(GetDisplayName(type, null));
 }