Esempio n. 1
0
        private void LinkingRow_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            LinkingRow row = sender as LinkingRow;

            AddFieldIntoPool(row.PreviousLinkedField);
            RemoveFieldFromPool(row.LinkedField);
        }
Esempio n. 2
0
        private void AddLinkingRowInUIContext(object obj)
        {
            LinkingRow row = obj as LinkingRow;

            if (row != null)
            {
                row.PropertyChanged += LinkingRow_PropertyChanged;
                LinkingRows.Add(row);
            }
        }
Esempio n. 3
0
        private void LinkedFieldComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox   comboBox = sender as ComboBox;
            LinkingRow row      = comboBox.DataContext as LinkingRow;

            if (comboBox.SelectedItem != null)
            {
                row.LinkedField = comboBox.SelectedItem.ToString();
            }
        }
Esempio n. 4
0
 private void AddLinkingRow(LinkingRow row)
 {
     App.CallMethodInUISynchronizationContext(AddLinkingRowInUIContext, row);
 }
Esempio n. 5
0
        public override void Reset()
        {
            if (!IsLinking || m_wizardInfo == null)
            {
                return;
            }

            if (WizardInfo.DataSourceType == DataSourceType.MHT)
            {
                IsLinking = false;
            }

            m_fieldsPool.Clear();
            ClearSourceIdAvailableFields();

            foreach (var field in m_wizardInfo.DataSourceParser.StorageInfo.FieldNames)
            {
                if (!m_wizardInfo.Migrator.SourceNameToFieldMapping.ContainsKey(field.FieldName) &&
                    String.CompareOrdinal(field.FieldName, WizardInfo.RelationshipsInfo.TestSuiteField) != 0)
                {
                    m_fieldsPool.Add(field.FieldName);
                }
            }

            ClearLinkingRows();

            LinkingRow row1 = null;
            LinkingRow row2 = null;
            LinkingRow row3 = null;
            LinkingRow row4 = null;

            switch (WizardInfo.WorkItemGenerator.WorkItemCategory)
            {
            case WorkItemGenerator.TestCaseCategory:
                row1 = new LinkingRow(this,
                                      WorkItemGenerator.TestsLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType[WorkItemGenerator.RequirementCategory],
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row1);

                row2 = new LinkingRow(this,
                                      WorkItemGenerator.TestsLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType[WorkItemGenerator.BugCategory],
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row2);

                row3 = new LinkingRow(this,
                                      WorkItemGenerator.RelatedLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.SelectedWorkItemTypeName,
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row3);
                break;

            case WorkItemGenerator.BugCategory:
                row1 = new LinkingRow(this,
                                      WorkItemGenerator.TestedByLinkRefernceName,
                                      WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType[WorkItemGenerator.TestCaseCategory],
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row1);

                row2 = new LinkingRow(this,
                                      WorkItemGenerator.RelatedLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.SelectedWorkItemTypeName,
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row2);

                row3 = new LinkingRow(this,
                                      WorkItemGenerator.RelatedLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType[WorkItemGenerator.RequirementCategory],
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row3);
                break;

            case WorkItemGenerator.RequirementCategory:
                row1 = new LinkingRow(this,
                                      WorkItemGenerator.TestedByLinkRefernceName,
                                      WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType[WorkItemGenerator.TestCaseCategory],
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row1);

                row2 = new LinkingRow(this,
                                      WorkItemGenerator.ParentLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.SelectedWorkItemTypeName,
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row2);

                row3 = new LinkingRow(this,
                                      WorkItemGenerator.RelatedLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.SelectedWorkItemTypeName,
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row3);

                row4 = new LinkingRow(this,
                                      WorkItemGenerator.RelatedLinkReferenceName,
                                      WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType[WorkItemGenerator.BugCategory],
                                      m_fieldsPool,
                                      null);
                AddLinkingRow(row4);
                break;

            default:
                break;
            }

            ResetSourceIdField();

            string startCategory = WizardInfo.WorkItemGenerator.WorkItemTypeToCategoryMapping[WizardInfo.WorkItemGenerator.SelectedWorkItemTypeName];

            foreach (var rule in WizardInfo.RelationshipsInfo.LinkRules)
            {
                if (String.CompareOrdinal(startCategory, rule.StartWorkItemCategory) == 0 &&
                    WizardInfo.WorkItemGenerator.LinkTypeNames.Contains(rule.LinkTypeReferenceName) &&
                    IsValidCategory(rule.EndWorkItemCategory) &&
                    m_fieldsPool.Contains(rule.SourceFieldNameOfEndWorkItemCategory))
                {
                    bool isRuleAlreadyAdded = false;
                    foreach (var row in LinkingRows)
                    {
                        string endCategory = WizardInfo.WorkItemGenerator.WorkItemTypeToCategoryMapping[row.EndWorkItemType];

                        if (String.CompareOrdinal(row.LinkRefernceName, rule.LinkTypeReferenceName) == 0 &&
                            String.CompareOrdinal(endCategory, rule.EndWorkItemCategory) == 0 &&
                            row.AvailableFields.Contains(rule.SourceFieldNameOfEndWorkItemCategory))
                        {
                            isRuleAlreadyAdded = true;
                            break;
                        }
                    }
                    if (!isRuleAlreadyAdded &&
                        WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType.ContainsKey(rule.EndWorkItemCategory))
                    {
                        AddLinkingRow(new LinkingRow(this,
                                                     rule.LinkTypeReferenceName,
                                                     WizardInfo.WorkItemGenerator.WorkItemCategoryToDefaultType[rule.EndWorkItemCategory],
                                                     m_fieldsPool,
                                                     rule.Description));
                    }
                }
            }

            foreach (var row in LinkingRows)
            {
                foreach (var rule in WizardInfo.RelationshipsInfo.LinkRules)
                {
                    string endCategory = WizardInfo.WorkItemGenerator.WorkItemTypeToCategoryMapping[row.EndWorkItemType];

                    if (String.CompareOrdinal(startCategory, rule.StartWorkItemCategory) == 0 &&
                        String.CompareOrdinal(row.LinkRefernceName, rule.LinkTypeReferenceName) == 0 &&
                        String.CompareOrdinal(endCategory, rule.EndWorkItemCategory) == 0 &&
                        row.AvailableFields.Contains(rule.SourceFieldNameOfEndWorkItemCategory))
                    {
                        row.LinkedField = rule.SourceFieldNameOfEndWorkItemCategory;
                    }
                }
            }
        }