public HiPerfTimerWrapper(string message) { _message = message; _timer = new HiPerfTimer(); }
private void btnExecute_Click(object sender, EventArgs e) { // This item is obfuscated and can not be translated. string str = this.GetActiveTextbox().Text.Trim(); if (string.IsNullOrEmpty(str)) { MessageBox.Show("No expression to execute"); } else { this.toolStripStatusLabel1.Text = "Running query..."; ((GeometryVisualizer) this.elementHost1.Child).Clear(); base.Update(); DataTable dataTable = new DataTable(); HiPerfTimer timer = new HiPerfTimer(); SqlConnection connection = new SqlConnection(this.GetConnectionString()); try { connection.Open(); SqlCommand selectCommand = new SqlCommand(str, connection); selectCommand.CommandTimeout = 180; SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); timer.Start(); adapter.Fill(dataTable); timer.Stop(); adapter.Dispose(); connection.Close(); } catch (Exception exception) { ((GeometryVisualizer) this.elementHost1.Child).ShowBlankMap(this.useCustomToolStripMenuItem.Checked ? this.m_customImageFilename : null); MessageBox.Show(exception.Message); this.toolStripStatusLabel1.Text = "Ready"; return; } finally { if (connection != null) { connection.Dispose(); } } int num = -1; for (int i = 0; i < dataTable.Columns.Count; i++) { Type dataType = dataTable.Columns[i].DataType; if ((dataType == typeof(SqlGeometry)) || (dataType == typeof(SqlGeography))) { num = i; break; } } int num3 = 0; bool isGeographic = true; if (num < 0) { if (dataTable.Rows.Count > 0) { this.tabControl1.SelectTab(1); } } else { List<Feature> features = new List<Feature>(); foreach (DataRow row in dataTable.Rows) { Geometry geometry = null; object obj2 = row[num]; if (obj2 is SqlGeometry) { SqlGeometry geo = obj2 as SqlGeometry; geometry = geo.ToGeometry(); bool x = geo.get_STSrid() < 0xfa0; if (SqlBoolean.op_True(x)) { goto Label_0214; } if (SqlBoolean.op_True(x | (geo.get_STSrid() > 0x1387))) { isGeographic = false; } } else if (obj2 is SqlGeography) { geometry = (obj2 as SqlGeography).ToGeometry(); } if (geometry != null) { Dictionary<string, object> attributes = new Dictionary<string, object>(); for (int j = 0; j < dataTable.Columns.Count; j++) { if (j != num) { attributes.Add(dataTable.Columns[j].ColumnName, row[j]); } } features.Add(new Feature(geometry, attributes)); num3++; } } ((GeometryVisualizer) this.elementHost1.Child).ShowMap(features, isGeographic, this.showBackgroundMapgeographicOnlyToolStripMenuItem.Checked, this.useCustomToolStripMenuItem.Checked ? this.m_customImageFilename : null); this._currentFeatureSet = features; } this.dataGridView1.DataSource = dataTable; this.toolStripStatusLabel1.Text = string.Format("{0} {2} returned ({1} {3}) in {4} seconds", new object[] { dataTable.Rows.Count, num3, (dataTable.Rows.Count != 1) ? "rows" : "row", (num3 != 1) ? "geometries" : "geometry", timer.Duration.ToString("0.######") }); this.exportResultToShapefileToolStripMenuItem.Enabled = num3 > 0; } }