//TODO: add methods for other types // W3C - COMW3CInputContextClassClass // NCSA - COMIISNCSAInputContextClassClass private static DataTable Execute <T>(string query) where T : new() { LogQueryClassClass log = new LogQueryClassClass(); ILogRecordset recordset = log.Execute(query, new T()); ILogRecord record = null; DataTable dt = new DataTable(); Int32 columnCount = recordset.getColumnCount(); for (int i = 0; i < columnCount; i++) { dt.Columns.Add(recordset.getColumnName(i), types[recordset.getColumnType(i) - 1]); } for (; !recordset.atEnd(); recordset.moveNext()) { DataRow dr = dt.NewRow(); record = recordset.getRecord(); for (int i = 0; i < columnCount; i++) { dr[i] = record.getValue(i); } dt.Rows.Add(dr); } return(dt); }
public void ReadColumnMap(ILogRecordset rs) { this.columnMap = new Dictionary<string, int>(); for (int col = 0; col < rs.getColumnCount(); col++) { string colName = rs.getColumnName(col); this.columnMap[colName] = col; } }
public void ReadColumnMap(ILogRecordset rs) { this.columnMap = new Dictionary <string, int>(); for (int col = 0; col < rs.getColumnCount(); col++) { string colName = rs.getColumnName(col); this.columnMap[colName] = col; } }
private DataTable GetDataFromLogs() { DataTable dataResults = new DataTable(); LogQueryClass LogParser = new LogQueryClass(); ILogRecordset rs = LogParser.Execute("SELECT * FROM '" + textBoxFrom.Text.Trim() + "'", new COMIISW3CInputContextClass()); for (int i = 0; i < rs.getColumnCount(); i++) { if (!dataResults.Columns.Contains(rs.getColumnName(i))) { dataResults.Columns.Add(rs.getColumnName(i)); } } //dataGridView1.DataSource = dataResults.DefaultView; ILogRecord rcd; DataRow row; while (!rs.atEnd()) { row = dataResults.NewRow(); rcd = rs.getRecord(); for (int i = 0; i < rs.getColumnCount(); i++) { row[rs.getColumnName(i)] = rcd.getValue(rs.getColumnName(i)); } dataResults.Rows.Add(row); rs.moveNext(); } rs.close(); return(dataResults); }
public void getLogTable(object sender, EventArgs e) { LogTable.Rows.Clear(); Logger l = new Logger(query.Text); ILogRecordset result = l.executeCommand(); ILogRecord dataRow = null; TableHeaderRow header = new TableHeaderRow(); TableHeaderCell headerCell; for (int i = 0; i < result.getColumnCount(); i++) { headerCell = new TableHeaderCell(); headerCell.Text = result.getColumnName(i); headerCell.CssClass = "forumHeader"; headerCell.Style.Add("border", "1px solid black"); header.Cells.Add(headerCell); } LogTable.Rows.Add(header); while (!result.atEnd()) { dataRow = result.getRecord(); TableRow row = new TableRow(); TableCell cell; for (int i = 0; i < result.getColumnCount(); i++) { cell = new TableCell(); cell.Text = dataRow.getValue(i).ToString(); cell.Style.Add("border", "1px solid black"); row.Cells.Add(cell); } LogTable.Rows.Add(row); result.moveNext(); } }
private void PerformSQLQuery() { DateTime startTime = DateTime.Now; dataGridViewResults.DataSource = null; toolStripStatusLabelDataInfo.Text = ""; QueryButton.Enabled = false; toolStripStatusLabelTimeTaken.Text = "Performing query."; string sqlQuery = BuildSqlQuery(); textFinalQuery.Text = sqlQuery; // Perform the query requested ICOMIISW3CInputContext iisW3c = new COMIISW3CInputContextClassClass(); int recordsCount = GetRecordCount(FromText.Text.Trim(), iisW3c); if (recordsCount > 0) { toolStripProgressBar.Maximum = recordsCount; toolStripProgressBar.Value = 0; ILogRecordset rs = GetRecordSet(sqlQuery.ToString(), iisW3c); ILogRecord rcd; DataTable table = new DataTable(); if (!rs.atEnd()) { for (int i = 0; i < rs.getColumnCount(); i++) { table.Columns.Add(rs.getColumnName(i), Type.GetType("System.String")); } } DataRow row; //textScratchPad.Text = ""; int currentRecord = 0; while (!rs.atEnd()) { currentRecord++; rcd = rs.getRecord(); row = table.NewRow(); for (int i = 0; i < rs.getColumnCount(); i++) { row[i] = rcd.getValue(i).ToString(); } table.Rows.Add(row); //textBox1.Text += rcd.getValue("cs-uri-stem").ToString() + System.Environment.NewLine; rs.moveNext(); if (currentRecord <= toolStripProgressBar.Maximum) { toolStripProgressBar.Value = currentRecord; } else { toolStripProgressBar.Value = toolStripProgressBar.Maximum; } } rs.close(); dataGridViewResults.DataSource = table; toolStripStatusLabelDataInfo.Text = "Records returned: " + table.Rows.Count.ToString(); toolStripProgressBar.Value = 0; } else { MessageBox.Show("No records would be returned by your query."); } DateTime endTime = DateTime.Now; toolStripStatusLabelTimeTaken.Text = ""; toolStripStatusLabelTimeTaken.Text += "Time taken: " + endTime.Subtract(startTime).ToString(); /* * ICOMDataGridOutputContext dataGrid = new COMDataGridOutputContextClassClass(); * * LogParser.ExecuteBatch("SELECT TOP 10 * FROM " + FromText.Text + "", iisW3c, dataGrid); */ /* * ICOMW3COutputContext w3cOutput = new COMW3COutputContextClassClass(); * * LogParser.ExecuteBatch("SELECT TOP 10 * FROM '" + FromText.Text + "'", iisW3c, w3cOutput); */ QueryButton.Enabled = true; }