示例#1
0
        private async Task <KeyValuePair <IDevOpsField, IdentityField> > ManageField(IDevOpsField field, IdentityField identityField)
        {
            KeyValuePair <IDevOpsField, IdentityField> result = new KeyValuePair <IDevOpsField, IdentityField>(null, null);

            var connector = DevOpsManager.GetConnector(_model);

            if (connector != null)
            {
                var fieldsAsync = await connector.GetWorkItemDevOpsFieldsAsync();

                var fields = fieldsAsync?.ToArray();
                if (fields?.Any() ?? false)
                {
                    var dialog = new FieldAssociationDialog();
                    dialog.Initialize(_model, fields);
                    if (field != null && identityField != null)
                    {
                        dialog.SetField(field, identityField);
                    }
                    if (dialog.ShowDialog(this) == DialogResult.OK)
                    {
                        field         = dialog.Field;
                        identityField = dialog.IdentityField;
                        if (field != null && identityField != null)
                        {
                            connector.SetWorkItemFieldMapping(field, identityField);
                            DevOpsManager.UpdateConfig(_model);
                            result = new KeyValuePair <IDevOpsField, IdentityField>(field, identityField);
                        }
                    }
                }
            }

            return(result);
        }
示例#2
0
        public void SetField([NotNull] IDevOpsField field, [NotNull] IdentityField identityField)
        {
            if (_fields.Items.Contains(field))
            {
                _fields.SelectedItem = field;
            }
            switch (identityField.FieldType)
            {
            case IdentityFieldType.Id:
                _id.Checked = true;
                break;

            case IdentityFieldType.Name:
                _name.Checked = true;
                break;

            case IdentityFieldType.Description:
                _description.Checked = true;
                break;

            case IdentityFieldType.Priority:
                _priority.Checked = true;
                break;

            case IdentityFieldType.Property:
                _property.Checked = true;
                if (_properties.Items.OfType <IPropertyType>().Any(x => x == identityField.PropertyType))
                {
                    _properties.SelectedItem = identityField.PropertyType;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }