private void FillDefaultCustomStates(ConfigurationV2 config) { var allWorkItemTypes = TaskboardService.GetWorkItemTypes(); if (allWorkItemTypes != null) { List <WorkItemType> workItemTypes = new List <WorkItemType>(); if ((config.ChildItems != null) && (config.ChildItems.Count > 0)) { // Only consider the work item types that have been configured as child items workItemTypes.AddRange(allWorkItemTypes.Cast <WorkItemType>().Where(workItemType => config.ChildItems.Contains(workItemType.Name))); } else { // Consider all work item types workItemTypes.AddRange(allWorkItemTypes.Cast <WorkItemType>()); } var states = new List <string>(); foreach (WorkItemType workItemType in workItemTypes) { List <string> witStates = GetStatesForWorkItemType(workItemType); foreach (string allowedValue in witStates) { if (!states.Contains(allowedValue)) { states.Add(allowedValue); } } } foreach (string state in states) { CreateDefaultCustomStates(states, config, state, state, GetStateColor(state)); } } }
private static void CreateDefaultCustomStates(List <string> states, ConfigurationV2 configuration, string customeStateName, string expectedWorkItemState, Color customeStateColor) { if (states.Contains(expectedWorkItemState)) { var newState = new CustomState() { Color = customeStateColor, Name = customeStateName }; newState.WorkItemStates.Add(expectedWorkItemState); configuration.States.Add(newState); } }
private void FillDefaultChildItems(ConfigurationV2 config) { var workItemTypes = TaskboardService.GetWorkItemTypes(); if (workItemTypes == null) { return; } foreach (WorkItemType workItemType in workItemTypes) { if ((workItemType.Name.ToUpper().Contains("TASK")) && (!config.BacklogItems.Contains(workItemType.Name))) { config.ChildItems.Add(workItemType.Name); } } }
private void FillDefaultBacklogItems(ConfigurationV2 config) { if (TfsInformationProvider.TeamProject == null) { return; } foreach (Category category in TfsInformationProvider.TeamProject.Categories) { if ((category.ReferenceName == "Microsoft.RequirementCategory") || (category.ReferenceName == "Microsoft.BugCategory")) { // Pick the items from the category and make them backlog items foreach (WorkItemType workItemType in category.WorkItemTypes) { config.BacklogItems.Add(workItemType.Name); } } } }
private ConfigurationV2 ReadTaskboardConfigurationV2(StreamReader s, string configurationData) { Logger.Write(TraceCategory.Information, "V2 .tbconfig version is being loaded"); try { var serializer = new DataContractSerializer(typeof(ConfigurationV2), new[] { typeof(CustomState) }); return((ConfigurationV2)serializer.ReadObject(s.BaseStream)); } // this happens if old version of .tbconfig is being loaded catch (SerializationException) { Logger.Write(TraceCategory.Information, "V2 .tbconfig version could not be loaded"); s.BaseStream.Seek(0, new SeekOrigin()); Configuration configOld1 = ReadTaskboardConfigurationV1(s, configurationData); ConfigurationV2 cfg = new ConfigurationV2(); cfg.CopyFromConfigurationOld1(configOld1); return(cfg); } }
public void CopyFromConfigurationOld2(ConfigurationV2 configOld2) { TeamProjectCollection = configOld2.TeamProjectCollection; TeamProject = configOld2.TeamProject; ChildItems.AddRange(configOld2.ChildItems); BacklogItems.AddRange(configOld2.BacklogItems); foreach (var state in configOld2.States) { States.Add(state.Clone() as ICustomState); } SortFieldName = configOld2.SortFieldName; SortDirection = configOld2.SortDirection; RowSummaryFieldName = configOld2.RowSummaryFieldName; ColumnSummaryFieldName = configOld2.ColumnSummaryFieldName; LinkType = configOld2.LinkType; QueryId = configOld2.QueryId; ReportId = configOld2.ReportId; ReportParameters.AddRange(configOld2.ReportParameters); IsAutoRefreshChecked = configOld2.IsAutoRefreshChecked; AutoRefreshDelay = configOld2.AutoRefreshDelay; }
public object Clone() { ConfigurationV2 result = new ConfigurationV2(); result.TeamProjectCollection = TeamProjectCollection; result.TeamProject = TeamProject; result.ChildItems.AddRange(ChildItems); result.BacklogItems.AddRange(BacklogItems); foreach (var state in States) { result.States.Add(state.Clone() as ICustomState); } result.SortFieldName = SortFieldName; result.SortDirection = SortDirection; result.RowSummaryFieldName = RowSummaryFieldName; result.ColumnSummaryFieldName = ColumnSummaryFieldName; result.LinkType = LinkType; result.QueryId = QueryId; result.ReportId = ReportId; result.ReportParameters.AddRange(ReportParameters); result.IsAutoRefreshChecked = IsAutoRefreshChecked; result.AutoRefreshDelay = AutoRefreshDelay; return(result); }