public void getValuesFromProfil(Profil source) { this.checkProfil(); if (this.isXmlMode()) { this.setup = source.setup.copyValues(this.setup); } if (this.isPmode()) { this.name = source.getName(); } }
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]); }
//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(); } }