Exemplo n.º 1
0
        /// <summary>
        /// Удалить БД
        /// </summary>
        /// <returns>miaExitCode</returns>
        static int dropdb(string[] args)
        {
            //Environment.ExitCode = miaExitCode.OK;
            String[] dbpar = args[1].Split(';');
            string   host  = dbpar[0];
            string   db    = dbpar[1];
            string   root  = dbpar[4];
            string   rpswd = dbpar[5];

            try {
                MDCreator.DropDb(root, rpswd, db, host);
            } catch (Exception exc) {
                _log.Error(exc);
                return(miaExitCode.ERROR);
            }
            return(miaExitCode.OK);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Новая База данных
        /// </summary>
        /// <returns>miaExitCode</returns>
        static int nudb(string[] args)
        {
            String[] dbpar = args[1].Split(';');
            string   host  = dbpar[0];
            string   db    = dbpar[1];
            string   user  = dbpar[2];
            string   pswd  = dbpar[3];
            string   root  = dbpar[4];
            string   rpswd = dbpar[5];

            //Environment.ExitCode = miaExitCode.OK;
            String[] us = args[2].Split(';');
            if (us.Length < 2)
            {
                return(miaExitCode.EXPECTED_ONE_USER);
            }
            if (us.Length % 2 != 0)
            {
                return(miaExitCode.USER_MUST_HAVE_PASSWORD);
            }
            if (MDCreator.HasDB(root, rpswd, db, host))
            {
                return(miaExitCode.DB_ALREADY_EXISTS);
            }

            MDCreator cr = new MDCreator();

            try {
                int res = cr.Prepare(true, host, user, pswd, db, root, rpswd, false, false);
                if (res != miaExitCode.OK)
                {
                    return(res);
                }
                cr.SetUsers(us);
            } catch (Exception exc) {
                _log.Error(exc);
                return(miaExitCode.ERROR);
            }
            return(miaExitCode.OK);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Начинает конвертирование bp mia-файла
        /// </summary>
        private void btStart_Click(object sender, EventArgs e)
        {
            MDCreator crt = new MDCreator();

#if !NOCATCH
            try
            {
#endif
            pb.Value = 0;
            int code = crt.Prepare(dbnew.Checked, tbHost.Text, tbUser.Text, tbPassword.Text, tbDB.Text, textRoot.Text, textRootPswd.Text, false, Quiet);
            if (code == miaExitCode.OK)
            {
                groupBox1.Enabled = btOpenMIAfile.Enabled = tbMiaFile.Enabled = false;
                //crt.oldid = oldid.Checked;
                crt.Mia = _mia;
                crt.SetUsers(Udata);
                crt.FillAll();
                crt.Finish(tbScript.Text);
                pb.Value             = 0;
                groupBox1.Enabled    = btOpenMIAfile.Enabled = tbMiaFile.Enabled = true;
                Environment.ExitCode = miaExitCode.OK;
            }
            else
            {
                MessageBox.Show(miaExitCode.GetText(code), "Ошибка");
            }
#if !NOCATCH
        }

        catch (Exception ex)
        {
            MessageBox.Show("Программа вызвала исключение: " + ex.GetType().ToString() + "\r\n" + ex.Message);
            button2.Enabled = true;
            btStart.Enabled = true;
        }
#endif
        }