private void ToolStripMenuItemOpen(object sender, EventArgs e) { var dlg = new OpenFileDialog(); dlg.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dlg.Multiselect = false; var result = dlg.ShowDialog(); if (result == DialogResult.OK) { String filename = dlg.FileName; ConversionConfiguration config = null; Boolean success = SerializationHelper.TryXmlDeserialize(filename, out config); if (success) { _manager.CurrentConfiguration = config; } else { throw new Exception("File couldn't be opened."); } } }
private void btnSet_Click(object sender, EventArgs e) { try { ConversionConfiguration config = _manager.CurrentConfiguration; string connectionString = config.ConnectionString; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); // Get the names of all DBs in the database server. SqlCommand query = new SqlCommand(@"select distinct [name] from sysdatabases", conn); using (SqlDataReader reader = query.ExecuteReader()) { cboDatabases.Items.Clear(); while (reader.Read()) { cboDatabases.Items.Add((string)reader[0]); } if (cboDatabases.Items.Count > 0) { cboDatabases.SelectedIndex = 0; } } } pbrProgress.Value = 0; AddMessage(String.Format("Connected to SQL Server ({0})", config.SqlServerAddress)); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Failed To Connect", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnStart_Click(object sender, EventArgs e) { ConversionConfiguration config = _manager.CurrentConfiguration; string sqlConnString = config.ConnectionString; this.Cursor = Cursors.WaitCursor; SqlConversionHandler handler = this.OnSqlConversionHandler; SqlTableSelectionHandler selectionHandler = this.OnSqlTableSelectionHandler; FailedViewDefinitionHandler viewFailureHandler = this.OnFailedViewDefinitionHandler; SqlServerToSQLite.ConvertSqlServerToSQLiteDatabase(sqlConnString, config.SqLiteDatabaseFilePath, config.EncryptionPassword, handler, selectionHandler, viewFailureHandler, config.CreateTriggersEnforcingForeignKeys, config.TryToCreateViews); }
private void UpdateUI() { try { this._isLoading = true; ConversionConfiguration config = _manager.CurrentConfiguration; txtSqlAddress.Text = config.SqlServerAddress; txtSQLitePath.Text = config.SqLiteDatabaseFilePath; txtPassword.Text = config.EncryptionPassword; txtUserDB.Text = config.User; txtPassDB.Text = config.Password; int cboDatabaseIndex = cboDatabases.Items.Add(config.DatabaseName); cboDatabases.SelectedIndex = cboDatabaseIndex; cbxEncrypt.Checked = !(String.IsNullOrWhiteSpace(config.EncryptionPassword)); cbxTriggers.Checked = config.CreateTriggersEnforcingForeignKeys; cbxCreateViews.Checked = config.TryToCreateViews; cbxIntegrated.Checked = config.IntegratedSecurity; if (config.IntegratedSecurity) { lblPassword.Visible = false; lblUser.Visible = false; txtPassDB.Visible = false; txtUserDB.Visible = false; } else { lblPassword.Visible = true; lblUser.Visible = true; txtPassDB.Visible = true; txtUserDB.Visible = true; } this._isLoading = false; UpdateSensitivity(); } catch (Exception ex) { // Do nothing. } }
private void ToolStripMenuItemSave(object sender, EventArgs e) { var dlg = new SaveFileDialog(); dlg.AddExtension = true; dlg.DefaultExt = "xml"; dlg.FileName = "SqlConverter.Configuration.xml"; dlg.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var result = dlg.ShowDialog(); if (result == DialogResult.OK) { ConversionConfiguration config = _manager.CurrentConfiguration; var sw = new StreamWriter(dlg.OpenFile()); sw.Write(config.SerializedXml); sw.Flush(); sw.Close(); } }
public ConfigurationManager() { CurrentConfiguration = new ConversionConfiguration(); }