Exemplo n.º 1
0
        private void Paste_Click(object sender, EventArgs e)
        {
            try
            {
                var s                   = Clipboard.GetText();
                var stringReader        = new StringReader(s);
                var xmlTextReader       = new XmlTextReader(stringReader);
                var configurationReader = new ConfigurationReader();
                var propertyFolder      = configurationReader.Read(xmlTextReader);
                propertyFolder.Write(TraceWriter.Instance);

                var configurationNodes = propertyFolder.ChildNodes.Count > 0
                    ? (IEnumerable <ConfigurationNode>)propertyFolder.ChildNodes
                    : new[] { propertyFolder };

                foreach (var configurationNode in configurationNodes)
                {
                    var connectionProperties = ConnectionPropertiesRepository.GetFromConfiguration(configurationNode);
                    Add(connectionProperties);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void CopyConnectionString_Click(object sender, EventArgs e)
        {
            var configurationNode    = SelectedConfigurationNode;
            var connectionProperties = ConnectionPropertiesRepository.GetFromConfiguration(configurationNode);
            var connectionString     = connectionProperties.ConnectionString;

            Clipboard.SetText(connectionString);
        }
Exemplo n.º 3
0
        private void LoadConnection(ConfigurationNode configurationNode, DataRow row)
        {
            var connectionProperties = ConnectionPropertiesRepository.GetFromConfiguration(configurationNode);

            row["ConnectionName"] = connectionProperties.ConnectionName;
            row["ProviderName"]   = connectionProperties.ProviderName;
            row[ConnectionStringKeyword.DataSource]         = connectionProperties.DataSource;
            row[ConnectionStringKeyword.InitialCatalog]     = connectionProperties.InitialCatalog;
            row[ConnectionStringKeyword.IntegratedSecurity] = connectionProperties.IntegratedSecurity;
            row[ConnectionStringKeyword.UserId]             = connectionProperties.UserId;
        }
Exemplo n.º 4
0
        private void Add(ConnectionProperties connectionProperties)
        {
            var node      = DataCommanderApplication.Instance.ConnectionsConfigurationNode;
            var subFolder = new ConfigurationNode(null);

            node.AddChildNode(subFolder);
            ConnectionPropertiesRepository.Save(connectionProperties, subFolder);
            var row = _dataTable.NewRow();

            LoadConnection(subFolder, row);
            _dataTable.Rows.Add(row);
            _isDirty = true;
        }
Exemplo n.º 5
0
        private void Edit_Click(object sender, EventArgs e)
        {
            var configurationNode = SelectedConfigurationNode;
            var form = new ConnectionStringBuilderForm();

            form.ConnectionProperties = ConnectionPropertiesRepository.GetFromConfiguration(configurationNode);
            var dialogResult = form.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                ConnectionPropertiesRepository.Save(form.ConnectionProperties, configurationNode);
                var row = _dataTable.DefaultView[_dataGrid.CurrentCell.RowIndex].Row;
                LoadConnection(configurationNode, row);
            }
        }
Exemplo n.º 6
0
        private void Connect(ConfigurationNode folder)
        {
            if (_isDirty)
            {
                if (MessageBox.Show(this, "Do you want to save changes?", null, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    DataCommanderApplication.Instance.SaveApplicationData();
                }
            }

            using (new CursorManager(Cursors.WaitCursor))
            {
                var connectionProperties = ConnectionPropertiesRepository.GetFromConfiguration(folder);
                var form = new OpenConnectionForm(connectionProperties);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    ConnectionProperties = connectionProperties;
                    DialogResult         = DialogResult.OK;
                    Duration             = form.Duration;
                }
            }
        }