/// <summary> /// Updates the available tfs fields based on the selection change in effectedRow /// </summary> /// <param name="effectedRow"></param> public void UpdateAvailableFields(FieldMappingRow effectedRow) { // if there is really a change in TFS Field selection if (String.CompareOrdinal(effectedRow.PreviousTFSField, effectedRow.TFSField) != 0) { // If the current mappping row is not the effected row if (this != effectedRow) { string ignore = Resources.IgnoreLabel; // If effected row become a valid Field Mapping Row then remove the corresponding // tfs field from the list of available fields if (String.CompareOrdinal(effectedRow.PreviousTFSField, ignore) == 0) { RemoveAvailableTFSField(effectedRow.TFSField); } // else if the effected row was earlier mapped but now mapped to noting // then Add the previous mapped tfs field to the list of allowed values else if (String.CompareOrdinal(effectedRow.TFSField, ignore) == 0) { AddAvailableTFSField(effectedRow.PreviousTFSField); } // else it is only a change of mapped WorkItem field in the effected row. just updates the // corresponding fields in the current list of allowed tfs fields else { AddAvailableTFSField(effectedRow.PreviousTFSField); RemoveAvailableTFSField(effectedRow.TFSField); } } } }
private void WIFieldComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox wiFieldBox = sender as ComboBox; FieldMappingRow row = wiFieldBox.DataContext as FieldMappingRow; if (wiFieldBox.SelectedItem != null) { row.TFSField = wiFieldBox.SelectedItem.ToString(); } }
/// <summary> /// Updates the allowed values of each Field Mapping Row if Workitem Field Selection of any mapping row is changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UpdateAvailableTFSFields(object sender, PropertyChangedEventArgs e) { if (String.CompareOrdinal(e.PropertyName, "TFSField") == 0) { FieldMappingRow effectedRow = sender as FieldMappingRow; foreach (FieldMappingRow row in FieldMappingRows) { row.UpdateAvailableFields(effectedRow); } effectedRow.PreviousTFSField = effectedRow.TFSField; CanNext = ValidatePartState(); } }
/// <summary> /// Initializes the Field Mapping Rows /// </summary> /// <param name="workItemFieldByFieldName"></param> private void InitializeFieldMappingRows(IDictionary <string, IWorkItemField> workItemFieldByTFSFieldName) { IList <SourceField> fieldNames = m_wizardInfo.DataSourceParser.StorageInfo.FieldNames; bool isMultipleHistoryMappingMode = false; if (m_wizardInfo.DataSourceType == DataSourceType.MHT) { isMultipleHistoryMappingMode = true; } if (fieldNames != null) { // For each header create a field mapping row foreach (SourceField field in fieldNames) { FieldMappingRow row = new FieldMappingRow(field.FieldName, null, workItemFieldByTFSFieldName, isMultipleHistoryMappingMode); row.PropertyChanged += new PropertyChangedEventHandler(UpdateAvailableTFSFields); App.CallMethodInUISynchronizationContext(AddFieldMappingRow, row); } } }
/// <summary> /// Resets/ Updates the Field Mapping Wizard part /// </summary> public override void Reset() { m_mandatoryFields = new List <string>(); foreach (var field in WizardInfo.WorkItemGenerator.TfsNameToFieldMapping.Values) { if (field.IsMandatory) { m_mandatoryFields.Add(field.TfsName); } } IList <SourceField> fieldNames = m_wizardInfo.DataSourceParser.StorageInfo.FieldNames; // if Data Source is updated then clear all mapping rows and initialize them if (m_prerequisite.IsDataSourceChanged()) { IsFirstLineTitle = false; IsFileNameTitle = false; App.CallMethodInUISynchronizationContext(ClearFieldMappingRows, null); InitializeFieldMappingRows(m_wizardInfo.WorkItemGenerator.TfsNameToFieldMapping); } // if headers collection is not null if (fieldNames != null) { // then iterate throgh each header foreach (SourceField field in fieldNames) { // getting the Work item field IWorkItemField wiField = null; if (m_wizardInfo.Migrator.SourceNameToFieldMapping != null && m_wizardInfo.Migrator.SourceNameToFieldMapping.ContainsKey(field.FieldName)) { wiField = m_wizardInfo.Migrator.SourceNameToFieldMapping[field.FieldName]; } // Getting Field Mapping Row having data source field equal to header FieldMappingRow row = FieldMappingRows.FirstOrDefault((r) => { return(String.CompareOrdinal(r.DataSourceField, field.FieldName) == 0); }); if (row != null) { // If TFS is Updated then Update the allowed values of WorkitemField in Mapping Row if (m_prerequisite.IsServerConnectionChanged()) { row.ResetAvailableFields(m_wizardInfo.WorkItemGenerator.TfsNameToFieldMapping); } // Setting the Workitemfield in colum mapping row row.SetWorkItemField(wiField); } if (m_wizardInfo.DataSourceType == DataSourceType.MHT) { MHTStorageInfo info = m_wizardInfo.DataSourceParser.StorageInfo as MHTStorageInfo; IsFileNameTitle = info.IsFileNameTitle; IsFirstLineTitle = info.IsFirstLineTitle; } } } ResetTestSuiteFields(); NotifyPropertyChanged("IsTestSuiteVisible"); }