Example #1
0
        public void ShowDataBaseStatus(Lawyer.Common.CS.ConfigFile.Config c)
        {
            try
            {
                ToolTip1.SetToolTip(btnRestore, "نصب نشده");

                btnRestore.Image = global::WFControls.CS.Properties.Resources.noInstalData24;

                if (IsCorrectConnection(c))
                {
                    btnConfig.Image = global::WFControls.CS.Properties.Resources.Connect;

                    CreateDataBase(c);

                    if (IsInstallDataBase(c))
                    {
                        if (IsAttachDataBase(c))
                        {
                            ToolTip1.SetToolTip(btnRestore, "نصب شده");

                            btnRestore.Image = global::WFControls.CS.Properties.Resources.InstallData24;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #2
0
        private static bool IsInstallDataBase(Lawyer.Common.CS.ConfigFile.Config c)
        {
            MySqlConnection con = new MySqlConnection(string.Format("server={0};Port={1};uid={2}; pwd={3};database=nwdicdad2;", c.IP, c.Port, c.UserName, c.Password));

            try
            {
                con.Open();
                con.Close();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #3
0
        private static bool CreateDataBase(Lawyer.Common.CS.ConfigFile.Config c)
        {
            MySqlConnection con = new MySqlConnection(string.Format("server={0};Port={1};uid={2}; pwd={3};database=mysql;", c.IP, c.Port, c.UserName, c.Password));

            MySqlCommand com = new MySqlCommand("CREATE  SCHEMA IF NOT EXISTS nwdicdad2   COLLATE ='utf8_persian_ci'", con);

            try
            {
                con.Open();
                com.ExecuteNonQuery();
                con.Close();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #4
0
        private static bool IsCorrectConnection(Lawyer.Common.CS.ConfigFile.Config c)
        {
            if (c == null)
            {
                return(false);
            }

            MySqlConnection con = new MySqlConnection(string.Format("server={0};Port={1};uid={2}; pwd={3};database=mysql;", c.IP, c.Port, c.UserName, c.Password));

            try
            {
                con.Open();
                con.Close();
                return(true);
            }
            catch (Exception)
            {
                con.Close();
                return(false);
            }
        }
Example #5
0
        private static bool IsAttachDataBase(Lawyer.Common.CS.ConfigFile.Config c)
        {
            MySqlConnection con = new MySqlConnection(string.Format("server={0};Port={1};uid={2}; pwd={3};database=mysql;", c.IP, c.Port, c.UserName, c.Password));

            MySqlCommand com = new MySqlCommand("select count(*) from `information_schema`.`TABLES` where  table_schema='nwdicdad2';", con);

            try
            {
                con.Open();

                long count = (long)com.ExecuteScalar();

                if (count >= 25)
                {
                    com.CommandText = "select count(*) from `information_schema`.`ROUTINES` where  routine_schema='nwdicdad2';";
                    count           = (long)com.ExecuteScalar();
                    con.Close();
                    if (count > 200)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    con.Close();
                }

                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #6
0
        public void ShowStatus(Lawyer.Common.CS.ConfigFile.Config c)
        {
            try
            {
                btnConfig.Text = "";

                BtnRun.Text = "";

                btnRestore.Text = "";

                ToolTip1.SetToolTip(btnConfig, "پیکربندی نشده");

                ToolTip1.SetToolTip(BtnRun, "Stop");

                ToolTip1.SetToolTip(btnRestore, "نصب نشده");

                btnConfig.Image = global::WFControls.CS.Properties.Resources.noConnect;

                btnRestore.Image = global::WFControls.CS.Properties.Resources.noInstalData24;

                if (IsServiceRuning())
                {
                    ToolTip1.SetToolTip(BtnRun, "Run");

                    BtnRun.Image = global::WFControls.CS.Properties.Resources.Signal24;

                    if (IsCorrectConnection(c))
                    {
                        btnConfig.Image = global::WFControls.CS.Properties.Resources.Connect;

                        ToolTip1.SetToolTip(btnConfig, "پیکربندی شده");

                        CreateDataBase(c);

                        if (IsInstallDataBase(c))
                        {
                            if (IsAttachDataBase(c))
                            {
                                ToolTip1.SetToolTip(btnRestore, "نصب شده");
                                btnRestore.Image = global::WFControls.CS.Properties.Resources.InstallData24;
                            }
                        }
                    }
                }
                else
                {
                    //ایا نصب شده است
                    string defaultMySqlPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\" + "MySQL\\MySQL Server 5.1\\bin\\MySQLInstanceConfig.exe";

                    if (System.IO.File.Exists(defaultMySqlPath))
                    {
                        BtnRun.Image = global::WFControls.CS.Properties.Resources.nosignal24;
                        ToolTip1.SetToolTip(BtnRun, "Stop");
                    }

                    else
                    {
                        BtnRun.Image = global::WFControls.CS.Properties.Resources.nosignal24_u;
                        ToolTip1.SetToolTip(BtnRun, "نصب نشده");
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #7
0
        public void SetInitial(Lawyer.Common.CS.ConfigFile.Config c, bool IsRestore, bool restoreLaws, bool?automaticstart = false)
        {
            RestoreLaws = restoreLaws;

            isAutomaticStart = (bool)automaticstart;

            currentConfig = c;

            if (currentConfig != null)
            {
                txtIPAddress.Text = c.LIP;


                txtUserName.Text = c.LUserName;

                txtPassword.Text = c.LPassword;

                txtPort.Text = c.LPort;



                backupLocation = currentConfig.BackupLocation;

                if ((backupLocation != "") && (backupLocation != null))
                {
                    try
                    {
                        DirectoryInfo dir = new DirectoryInfo(backupLocation);
                        showDirectoryFiles(dir);
                    }
                    catch (Exception)
                    {
                    }
                }


                if (IsRestore)
                {
                    txtIPAddress.Text = c.IP;

                    txtUserName.Text = c.UserName;

                    txtPassword.Text = c.Password;

                    txtPort.Text = c.Port;

                    rdRestore.Checked      = true;
                    IsInstallDefault       = true;
                    rdBackup.Enabled       = false;
                    chkLaws.Checked        = true;
                    grpBackRestore.Enabled = false;
                    if (restoreLaws)
                    {
                        txtPath.Text    = Lawyer.Common.CS.Common.DefaultValues.RestoreLawPath;
                        lblMessage.Text = "برای نصب قوانین دکمه start را کلیک نمایید.";
                    }
                    else
                    {
                        txtPath.Text    = Lawyer.Common.CS.Common.DefaultValues.RestorePath;
                        lblMessage.Text = "برای نصب پایگاه داده دکمه start را کلیک نمایید.";
                    }
                }
                //unzip & restore
                else
                {
                    rdBackup.Checked = true;
                }

                computerName = txtIPAddress.Text;

                SetIP();

                if (isAutomaticStart)
                {
                    doStart();
                }
            }
        }