Ejemplo n.º 1
0
        private int GetRecordCount(string from, Object input)
        {
            string countQuery = "SELECT COUNT(*) FROM " + from;

            ILogRecordset returnedCount = GetRecordSet(countQuery, input);

            string returnedValue = "0";

            if (!returnedCount.atEnd())
            {
                returnedValue = returnedCount.getRecord().getValue(0).ToString();
            }
            returnedCount.close();

            int recordsCount;

            int.TryParse(returnedValue, out recordsCount);

            return(recordsCount);
        }
Ejemplo n.º 2
0
        static List <string> ScanRegistry()
        {
            List <string> keys = new List <string>();
            ILogRecordset rs   = null;

            try
            {
                LogQueryClass logQ = new LogQueryClass();
                COMRegistryInputContextClass registryFormat = new COMRegistryInputContextClass();
                string query = @"SELECT Path FROM \ where Value LIKE 'o2Mate%'";
                rs = logQ.Execute(query, registryFormat);
                for (; !rs.atEnd(); rs.moveNext())
                {
                    keys.Add(rs.getRecord().toNativeString(","));
                }
            }
            finally
            {
                rs.close();
            }
            return(keys);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
        }