private void FindWork() { try { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { FindWork(); })); } else { FormatGrid(); int iTotal = 0; int iComplete = 0; foreach (M2MMatrixCompressionPlugin.M2MMatrixCompressionStat stat in _list) { iTotal++; if (stat.Status == M2MMatrixCompressionPlugin.M2MMatrixCompressionStat.M2MMatrixCompressionStatStatus.Complete || stat.Status == M2MMatrixCompressionPlugin.M2MMatrixCompressionStat.M2MMatrixCompressionStatStatus.Error) { iComplete++; } else if (!stat.RunQuery) { iTotal--; } } this.Text = "BIDS Helper M2M Matrix Compression - " + iComplete + " of " + iTotal + " complete"; bool bFoundWork = false; foreach (M2MMatrixCompressionPlugin.M2MMatrixCompressionStat stat in _list) { if (stat.RunQuery && stat.Status != M2MMatrixCompressionPlugin.M2MMatrixCompressionStat.M2MMatrixCompressionStatStatus.Complete && stat.Status != M2MMatrixCompressionPlugin.M2MMatrixCompressionStat.M2MMatrixCompressionStatStatus.Error) { currentStat = stat; stat.Status = M2MMatrixCompressionPlugin.M2MMatrixCompressionStat.M2MMatrixCompressionStatStatus.Running; backgroundWorker = new System.ComponentModel.BackgroundWorker(); backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorker_DoWork); backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted); backgroundWorker.RunWorkerAsync(stat); bFoundWork = true; break; } } _complete = !bFoundWork; this.dataGridView1.Refresh(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex >= 0 && this.dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "RunQuery") { BindingSource bindingSource = this.dataGridView1.DataSource as BindingSource; M2MMatrixCompressionPlugin.M2MMatrixCompressionStat item = bindingSource.Current as M2MMatrixCompressionPlugin.M2MMatrixCompressionStat; item.RunQuery = !item.RunQuery; //flip all with same SQL and intermediate MG name foreach (M2MMatrixCompressionPlugin.M2MMatrixCompressionStat stat in _list) { if (item.IntermediateMeasureGroupName == stat.IntermediateMeasureGroupName && item.SQL == stat.SQL) { stat.RunQuery = item.RunQuery; } } dataGridView1.Refresh(); if (item == currentStat) { if (!item.RunQuery) { backgroundWorker.CancelAsync(); try { lock (command) { command.Cancel(); } } catch { } } else { } } if (_complete) { _complete = false; FindWork(); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
private void FormatGrid() { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { FormatGrid(); })); } else { foreach (DataGridViewRow row in this.dataGridView1.Rows) { M2MMatrixCompressionPlugin.M2MMatrixCompressionStat item = (M2MMatrixCompressionPlugin.M2MMatrixCompressionStat)row.DataBoundItem; if (item.Error != null) { foreach (DataGridViewCell cell in row.Cells) { cell.Style.ForeColor = Color.Red; cell.ToolTipText = item.Error; } } } } }