Beispiel #1
0
        private void sourceEditButton_Click(object sender, EventArgs e)
        {
            Source source = (Source)(sourceList.SelectedItem);

            if (source == null)
            {
                MessageBox.Show("Please select a source to edit.");
            }
            else
            {
                DatabaseForm form = new DatabaseForm();
                form.ServerText.Text = source.server;
                form.DatabaseNameText.Text = source.name;
                form.ConnectionStringText.Text = source.connectionString;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    source.server = form.ServerText.Text;
                    source.name = form.DatabaseNameText.Text;
                    source.connectionString = form.ConnectionStringText.Text;
                    SourcesSave();
                    sourceLoad(source);
                }
            }
        }
Beispiel #2
0
        private void targetEditButton_Click(object sender, EventArgs e)
        {
            Target target = (Target)(targetList.SelectedItem);

            if (target == null)
            {
                MessageBox.Show("Please select a target to edit.");
            }
            else
            {
                DatabaseForm form = new DatabaseForm();
                form.ServerText.Text = target.server;
                form.DatabaseNameText.Text = target.name;
                form.ConnectionStringText.Text = target.connectionString;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    target.server = form.ServerText.Text;
                    target.name = form.DatabaseNameText.Text;
                    target.connectionString = form.ConnectionStringText.Text;

                    OdbcCommand command = new OdbcCommand();
                    command.Connection = meta;
                    command.CommandType = CommandType.Text;
                    command.CommandText = "update meta_db_deploy_targets set meta_dbdt_server = ?, meta_dbdt_name = ?, meta_dbdt_connection_string = ? where meta_db_deploy_target = ?";
                    command.Parameters.Add(new OdbcParameter("1",target.server));
                    command.Parameters.Add(new OdbcParameter("2",target.name));
                    command.Parameters.Add(new OdbcParameter("3",target.connectionString));
                    command.Parameters.Add(new OdbcParameter("4",target.id));

                    try
                    {
                        meta.Open();
                        try
                        {
                            if (command.ExecuteNonQuery() == 1)
                            {
                                log.log(Logger.LogLevel.info, "Target updated successfully.");
                            }
                            else
                            {
                                log.log(Logger.LogLevel.error, "Target was not updated.");
                            }
                        }
                        catch (Exception ex)
                        {
                            log.log(Logger.LogLevel.error, "Exception occurred while trying to update target...");
                            log.log(Logger.LogLevel.error, ex.Message);
                        }
                        finally
                        {
                            meta.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        log.log(Logger.LogLevel.error, "Exception occurred while trying to udpate target...");
                        log.log(Logger.LogLevel.error, ex.Message);
                    }

                    //targetLoad(target);
                }
            }
        }
Beispiel #3
0
 private void sourceAddButton_Click(object sender, EventArgs e)
 {
     DatabaseForm form = new DatabaseForm();
     if (form.ShowDialog() == DialogResult.OK)
     {
         Source source = new Source(form.ServerText.Text, form.DatabaseNameText.Text, form.ConnectionStringText.Text);
         sourceList.Items.Add(source);
         sourceList.SelectedItem = source;
         SourcesSave();
     }
 }
Beispiel #4
0
        private void TargetAddButton_Click(object sender, EventArgs e)
        {
            Source source = (Source)(sourceList.SelectedItem);

            if (source == null)
            {
                MessageBox.Show("Please select a source to which you want to add a target.");
            }
            else
            {
                bool AlreadyClosed = false;
                DatabaseForm form = new DatabaseForm();
                if (form.ShowDialog() == DialogResult.OK)
                {

                    OdbcCommand command = new OdbcCommand();
                    command.Connection = meta;
                    command.CommandType = CommandType.Text;
                    command.CommandText = "insert into meta_db_deploy_targets(meta_dbdt_server, meta_dbdt_name, meta_dbdt_connection_string) values(?,?,?)";
                    command.Parameters.Add(new OdbcParameter("1", form.ServerText.Text));
                    command.Parameters.Add(new OdbcParameter("2", form.DatabaseNameText.Text));
                    command.Parameters.Add(new OdbcParameter("3", form.ConnectionStringText.Text));

                    try
                    {
                        meta.Open();
                        try
                        {
                            if (command.ExecuteNonQuery() == 1)
                            {
                                log.log(Logger.LogLevel.info, "Target added successfully.");

                                command.CommandText = "select max(meta_db_deploy_target) from meta_db_deploy_targets";
                                long id = (long)(command.ExecuteScalar());

                                Target target = new Target(id, form.ServerText.Text, form.DatabaseNameText.Text, form.ConnectionStringText.Text);
                                targetList.Items.Add(target);

                                meta.Close();
                                AlreadyClosed = true;
                                targetList.SelectedItem = target;
                            }
                            else
                            {
                                log.log(Logger.LogLevel.error, "Target was not added.");
                            }
                        }
                        catch (Exception ex)
                        {
                            log.log(Logger.LogLevel.error, "Exception occurred while trying to add target...");
                            log.log(Logger.LogLevel.error, ex.Message);
                        }
                        finally
                        {
                            if (!AlreadyClosed)
                            {
                                meta.Close();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.log(Logger.LogLevel.error, "Exception occurred while trying to add target...");
                        log.log(Logger.LogLevel.error, ex.Message);
                    }

                }
            }
        }