Exemple #1
0
 private void getProfilSettings()
 {
     dbusername           = watchProfil.getProperty("db_username");
     dbpassword           = watchProfil.getProperty("db_password");
     dbhost               = watchProfil.getProperty("db_host");
     dbschema             = watchProfil.getProperty("db_schema");
     connectionLabel.Text = dbusername + "@" + dbschema;
 }
Exemple #2
0
        public MysqlHandler(Profil dbProfil, long timeOutSet)
        {
            this.currentProfil = dbProfil;
            this.userName      = dbProfil.getProperty(ProfilProps.DB_USERNAME);
            this.userPassword  = dbProfil.getProperty(ProfilProps.DB_PASSWORD);
            this.host          = dbProfil.getProperty(ProfilProps.DB_HOST);
            this.table         = dbProfil.getProperty(ProfilProps.DB_SCHEMA);


            this.timeOut = timeOutSet;
            getConnStr();
            this.connection = new MySql.Data.MySqlClient.MySqlConnection();
        }
Exemple #3
0
        public string getDefaultFilename(Profil profil)
        {
            string name = "default";

            if (null != profil)
            {
                name = profil.getProperty("db_username") + profil.getProperty("db_host") + profil.getProperty("db_shema");
                name = name.Replace(@"\", "_");
                name = name.Replace(".", "_");
                name = name.Replace(" ", "_");
                name = name.Replace(":", "_");
            }
            return(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + System.IO.Path.DirectorySeparatorChar + "placeHolder_" + name + ".plc");
        }
Exemple #4
0
        private void fireAsyncQuery(Profil dbProfil, string sql, bool fireSingle)
        {
            asyncSql bgWorkerObj = new asyncSql();

            bgWorkerObj.dbProfil = new Profil(dbProfil.getName());
            bgWorkerObj.dbProfil.setProperty("db_username", dbProfil.getProperty("db_username"));
            bgWorkerObj.dbProfil.setProperty("db_password", dbProfil.getProperty("db_password"));
            bgWorkerObj.dbProfil.setProperty("db_host", dbProfil.getProperty("db_host"));
            bgWorkerObj.dbProfil.setProperty("db_shema", dbProfil.getProperty("db_shema"));
            bgWorkerObj.fireSingleShots = fireSingle;

            bgWorkerObj.sql = sql;
            int curr = ThreadParams.Count;

            ThreadParams.Add(bgWorkerObj);
            addNewAsync(ThreadParams[curr]);
        }
Exemple #5
0
        /**
         * init database handler by seperate
         * information
         * no auto connect
         *
         **/
        /* public MysqlHandler(string username,string password,string host, string table)
         * {
         *   this.userName = username;
         *   this.userPassword = password;
         *   this.host = host;
         *   this.table = table;
         *   getConnStr();
         *   this.connection = new MySql.Data.MySqlClient.MySqlConnection();
         *
         * }*/

        /**
         * init databasehandler with information from profile
         */

        public MysqlHandler(Profil dbProfil)
        {
            this.currentProfil = dbProfil;
            this.userName      = dbProfil.getProperty(ProfilProps.DB_USERNAME);
            this.userPassword  = dbProfil.getProperty(ProfilProps.DB_PASSWORD);
            this.host          = dbProfil.getProperty(ProfilProps.DB_HOST);
            this.table         = dbProfil.getProperty(ProfilProps.DB_SCHEMA);

            string timeOutStr = dbProfil.getProperty(ProfilProps.DB_TIMEOUT);

            if (null != timeOutStr)
            {
                this.timeOut = long.Parse(timeOutStr);
            }


            getConnStr();
            this.connection = new MySql.Data.MySqlClient.MySqlConnection();
        }
Exemple #6
0
        private void selectExistsTables()
        {
            Profil    dbProf  = new Profil();
            ColorCalc cCalc   = new ColorCalc();
            string    groupId = groupName.Text;

            if (this.currentGroups.Contains(groupId))
            {
                groupName.ForeColor = Color.DarkGreen;
                groupName.BackColor = Color.LightSeaGreen;
                List <string> members = Config.getListWidthDefault(PConfig.KEY_GROUPS_MEMBERS + "." + groupId, new List <string>());

                for (int i = 0; i < this.GroupedDatabases.Items.Count; i++)
                {
                    this.GroupedDatabases.Items[i].Checked = (members.Contains(this.GroupedDatabases.Items[i].Text));

                    dbProf.changeProfil(this.GroupedDatabases.Items[i].Text);
                    if (dbProf.getProperty("set_bgcolor") != null && dbProf.getProperty("set_bgcolor").Length > 2)
                    {
                        Color rowCol = Color.FromArgb(int.Parse(dbProf.getProperty("set_bgcolor")));
                        cCalc.setBaseColor(rowCol);
                        this.GroupedDatabases.Items[i].BackColor = cCalc.LightenBy(50);
                        this.GroupedDatabases.Items[i].ForeColor = cCalc.DarkenBy(50);
                    }
                }
                manipulateBtn.Image      = Projector.Properties.Resources.delete_16;
                GroupedDatabases.Enabled = true;
            }
            else
            {
                groupName.ForeColor = Color.DarkRed;
                groupName.BackColor = Color.LightYellow;
                manipulateBtn.Image = Projector.Properties.Resources.add16;
                for (int i = 0; i < this.GroupedDatabases.Items.Count; i++)
                {
                    this.GroupedDatabases.Items[i].Checked = false;
                }
                GroupedDatabases.Enabled = false;
            }
        }
Exemple #7
0
        private void fireSql(Profil dbProfil, string sql)
        {
            MysqlHandler database = new MysqlHandler(dbProfil);

            database.connect();

            if (database.isConnected())
            {
                ListViewWorker listTool  = new ListViewWorker();
                GroupBox       instGroup = new GroupBox();
                instGroup.Width     = MainView.Width - 30;
                instGroup.BackColor = SystemColors.Info;
                //instGroup.Height = 350;
                instGroup.Text     = currentProfileName;
                instGroup.AutoSize = true;

                Label infoData = new Label();
                infoData.AutoSize = true;
                infoData.Text     = dbProfil.getProperty("db_username") + "@" + dbProfil.getProperty("db_host") + "/" + dbProfil.getProperty("db_schema");
                infoData.Top      = 15;
                infoData.Left     = 15;

                ListView resultView = new ListView();
                resultView.View = View.Details;

                resultView.Width  = MainView.Width - 60;
                resultView.Height = 300;
                resultView.Left   = 10;
                resultView.Top    = 30;

                resultView.FullRowSelect = true;

                resultView.GridLines = true;

                MySql.Data.MySqlClient.MySqlDataReader dbResult = database.sql_select(sql);

                if (database.lastSqlErrorMessage != "")
                {
                    Label noData = new Label();
                    noData.Top      = 30;
                    noData.Left     = 15;
                    noData.Text     = database.lastSqlErrorMessage;
                    noData.AutoSize = true;
                    noData.Font     = new Font("Courier New", 10, FontStyle.Bold);
                    instGroup.Controls.Add(noData);
                    instGroup.Controls.Add(infoData);
                    instGroup.Height    = 60;
                    instGroup.BackColor = Color.LightPink;
                }
                else
                {
                    if (dbResult != null && dbResult.HasRows)
                    {
                        database.sql_data2ListView(dbResult, resultView);
                        for (int i = 0; i < resultView.Columns.Count; i++)
                        {
                            resultView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
                        }
                        listTool.setRowColors(resultView, Color.LightBlue, Color.LightGreen);

                        resultView.Height = (resultView.Items.Count * 13) + 50;
                        if (resultView.Height > 700)
                        {
                            resultView.Height = 700;
                        }

                        listLabelExports.Add(instGroup.Text);
                        listViewExports.Add(resultView);
                        instGroup.Controls.Add(resultView);
                        instGroup.Controls.Add(infoData);
                    }
                    else
                    {
                        Label noData = new Label();
                        noData.Top      = 30;
                        noData.Left     = 15;
                        noData.Text     = "No Result for this query ";
                        noData.AutoSize = true;
                        instGroup.Controls.Add(noData);
                        instGroup.Height    = 60;
                        instGroup.BackColor = Color.LightYellow;
                        instGroup.Controls.Add(infoData);
                    }
                }



                MainView.Controls.Add(instGroup);
                MainView.Refresh();
            }


            database.disConnect();
        }
Exemple #8
0
        //ProgressChangedEventArgs
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.UserState != null)
            {
                asyncSql bgWorkerObj = (asyncSql)e.UserState;
                Profil   dbProfil    = bgWorkerObj.dbProfil;
                string   sql         = bgWorkerObj.sql;


                ListViewWorker listTool  = new ListViewWorker();
                GroupBox       instGroup = new GroupBox();
                instGroup.Width     = MainView.Width - 30;
                instGroup.BackColor = SystemColors.Info;

                currentProfileName = dbProfil.getName();
                instGroup.Text     = dbProfil.getName();
                instGroup.AutoSize = true;

                Label infoData = new Label();
                infoData.AutoSize = true;
                infoData.Text     = dbProfil.getProperty("db_username") + "@" + dbProfil.getProperty("db_host") + "/" + dbProfil.getProperty("db_schema");
                infoData.Top      = 15;
                infoData.Left     = 15;

                ListView resultView = bgWorkerObj.resultListView;

                resultView.View = View.Details;

                resultView.Width  = MainView.Width - 60;
                resultView.Height = 300;
                resultView.Left   = 10;
                resultView.Top    = 30;

                resultView.FullRowSelect = true;

                resultView.GridLines = true;

                if (bgWorkerObj.lastError != "")
                {
                    Label noData = new Label();
                    noData.Top      = 30;
                    noData.Left     = 15;
                    noData.Text     = bgWorkerObj.lastError;
                    noData.AutoSize = true;
                    noData.Font     = new Font("Courier New", 10, FontStyle.Bold);
                    instGroup.Controls.Add(noData);
                    instGroup.Controls.Add(infoData);
                    instGroup.Height    = 60;
                    instGroup.BackColor = Color.LightPink;
                    this.onStatusChange("Error on " + infoData.Text);
                }
                else
                {
                    if (bgWorkerObj.haseRows)
                    {
                        for (int i = 0; i < resultView.Columns.Count; i++)
                        {
                            resultView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
                        }
                        listTool.setRowColors(resultView, Color.LightBlue, Color.LightGreen);

                        resultView.Height = (resultView.Items.Count * 13) + 50;
                        if (resultView.Height > 700)
                        {
                            resultView.Height = 700;
                        }

                        listLabelExports.Add(instGroup.Text);
                        listViewExports.Add(resultView);
                        instGroup.Controls.Add(resultView);
                        instGroup.Controls.Add(infoData);

                        this.onStatusChange(resultView.Items.Count + " rows from " + infoData.Text);
                    }
                    else
                    {
                        Label noData = new Label();
                        noData.Top      = 30;
                        noData.Left     = 15;
                        noData.Text     = "No Result for this query ";
                        noData.AutoSize = true;
                        instGroup.Controls.Add(noData);
                        instGroup.Height    = 60;
                        instGroup.BackColor = Color.LightYellow;
                        instGroup.Controls.Add(infoData);

                        this.onStatusChange(" no rows reported from " + infoData.Text);
                    }
                }



                MainView.Controls.Add(instGroup);
                MainView.Refresh();
                Application.DoEvents();
            }
        }
Exemple #9
0
        private void querysToolStripMenuItem_Click(object sender, EventArgs e)
        {
            windowID++;
            mysqlWatch watcher = new mysqlWatch();

            watcher.Name = "MysqlWatcher " + windowID;
            if (currentProfil.getProperty("set_bgcolor") != null && currentProfil.getProperty("set_bgcolor").Length > 2)
            {
                watcher.BackColor = Color.FromArgb(int.Parse(currentProfil.getProperty("set_bgcolor")));
            }
            watcher.watchProfil = currentProfil;
            watcher.MdiParent   = this;
            watcher.Show();

            listWindows();
        }