Ejemplo n.º 1
0
        private void btnCreateDb_Click(object sender, EventArgs e)
        {
            try
            {

                var monetConnection = DatabaseForm.GetDatabaseInfo(_serverName);

                if (monetConnection == null)
                    return;

                _db = new MonetDatabase(monetConnection.ToString());

                if (_db.StatusDatabase() == DatabaseStatus.Started)
                {
                    MessageBox.Show(@"Database already created", @"Database", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    return;
                }

                _db.CreateDatabase();

                LoggerHelper.Write(LoggerOption.Info, "Database {0} created", _db.ConnectionInfo.Database);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, @"Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);

                LoggerHelper.Write(LoggerOption.Error, "Error: {0}", exp.Message);
            }
        }
Ejemplo n.º 2
0
        private void btnKillDb_Click(object sender, EventArgs e)
        {
            try
            {
                var connectionString = GetConnectionString();

                if (string.IsNullOrWhiteSpace(connectionString))
                    return;

                _db = new MonetDatabase(connectionString);

                if (_db.StatusDatabase() == DatabaseStatus.None)
                {
                    MessageBox.Show(@"Database is not exists", @"Database", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    return;
                }

                _db.KillDatabase();

                LoggerHelper.Write(LoggerOption.Warning, "Database {0} killed", _db.ConnectionInfo.Database);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, @"Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);

                LoggerHelper.Write(LoggerOption.Error, "Error: {0}", exp.Message);
            }
        }
Ejemplo n.º 3
0
        private void btnLoadDb_Click(object sender, EventArgs e)
        {
            try
            {

                var connectionInfo = GetConnectionString();

                if (string.IsNullOrWhiteSpace(connectionInfo))
                    return;

                _db = new MonetDatabase(connectionInfo);

                if (_db.StatusDatabase() == DatabaseStatus.Started)
                {
                    MessageBox.Show(@"Database already loaded", @"Database", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    return;
                }

                _db.LoadDatabase();

                LoggerHelper.Write(LoggerOption.Info, "Database {0} loaded", _db.ConnectionInfo.Database);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, @"Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);

                LoggerHelper.Write(LoggerOption.Error, "Error: {0}", exp.Message);
            }
        }
Ejemplo n.º 4
0
        private void btnDropDb_Click(object sender, EventArgs e)
        {
            try
            {
                var connectionString = GetConnectionString();

                if (string.IsNullOrWhiteSpace(connectionString))
                    return;

                _db = new MonetDatabase(connectionString);

                if (_db.StatusDatabase() == DatabaseStatus.None)
                {
                    MessageBox.Show(@"Database is not exists", @"Database", MessageBoxButtons.OK, MessageBoxIcon.Stop);

                    return;
                }

                if (
                    MessageBox.Show(@"Do you really want to drop this database?(y/n)", @"Drop", MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) != DialogResult.Yes)
                    return;

                _db.DropDatabase();

                LoggerHelper.Write(LoggerOption.Warning, "Database {0} droped", _db.ConnectionInfo.Database);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, @"Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);

                LoggerHelper.Write(LoggerOption.Error, "Error: {0}", exp.Message);
            }
        }