Exemplo n.º 1
0
        private void ParseSQLToDict(string sql)
        {
            if (_NotInDict == null)
            {
                _NotInDict = new Dictionary <int, int>();
            }

            SFQLParse sfqlParse = new SFQLParse();

            Hubble.SQLClient.QueryResult qResult = sfqlParse.Query(sql);

            if (qResult.DataSet != null)
            {
                if (qResult.DataSet.Tables != null)
                {
                    if (qResult.DataSet.Tables.Count > 0)
                    {
                        foreach (Hubble.Framework.Data.DataRow row in qResult.DataSet.Tables[0].Rows)
                        {
                            int docid = int.Parse(row["docid"].ToString());
                            if (!_NotInDict.ContainsKey(docid))
                            {
                                _NotInDict.Add(docid, 0);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void toolStripButtonExcute_Click(object sender, EventArgs e)
        {
            try
            {
                toolStripStatusLabelReport.Text = "";

                tabControl1.SelectedTab = tabPageResults;
                textBoxMessages.Text    = "";

                QueryPerfCounter qp = new QueryPerfCounter();
                qp.Start();

                int count = 0;

                SFQLParse sfqlParse = new SFQLParse();
                string    sql       = textBoxSql.Text;

                if (!string.IsNullOrEmpty(textBoxSql.SelectedText))
                {
                    sql = textBoxSql.SelectedText;
                }

                if (sql.StartsWith("SP_", StringComparison.CurrentCultureIgnoreCase))
                {
                    sql = "exec " + sql;
                }

                if (performanceReportToolStripMenuItem.Checked)
                {
                    sql = "[PerformanceReport]\r\n" + sql;
                }

                QueryResult queryResult;

                GlobalSetting.DataAccess.ResetDataCacheAfterTimeout =
                    resetDataCacheAfterTimeoutToolStripMenuItem.Checked;

                if (dataCacheToolStripMenuItem.Checked)
                {
                    queryResult = GlobalSetting.DataAccess.Excute(sql, 0);
                }
                else
                {
                    queryResult = GlobalSetting.DataAccess.Excute(sql);
                }

                Hubble.Framework.Data.DataTable table = null;

                if (queryResult.DataSet.Tables.Count > 0)
                {
                    table = queryResult.DataSet.Tables[0];
                    count = table.MinimumCapacity;
                }

                qp.Stop();
                double ns = qp.Duration(1);

                StringBuilder report = new StringBuilder();

                report.AppendFormat("Duration:{0} ", (ns / (1000 * 1000)).ToString("0.00") + " ms");
                report.AppendFormat("Count={0}", count);

                if (queryResult.PrintMessages != null)
                {
                    if (queryResult.PrintMessageCount > 0)
                    {
                        ShowMessages(queryResult.PrintMessages, table == null);
                    }
                }

                MultiGridView mulitGridView = new MultiGridView(panelResult, queryResult.DataSet.Tables.Count);

                for (int i = 0; i < queryResult.DataSet.Tables.Count; i++)
                {
                    queryResult.DataSet.Tables[i].MinimumCapacity = 0;
                    mulitGridView.GridViewList[i].DataSource      = queryResult.DataSet.Tables[i].ConvertToSystemDataTable();

                    DataTable tbl = queryResult.DataSet.Tables[i];

                    for (int j = 0; j < tbl.Columns.Count; j++)
                    {
                        if (tbl.Columns[j].DataType == typeof(DateTime))
                        {
                            mulitGridView.GridViewList[i].Columns[j].DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:sss";
                        }
                    }
                }

                toolStripStatusLabelReport.Text = report.ToString();

                if (performanceReportToolStripMenuItem.Checked)
                {
                    tabControl1.SelectedTab = tabPageMessages;
                }
            }
            catch (Hubble.Core.SFQL.LexicalAnalysis.LexicalException lexicalEx)
            {
                ShowErrorMessage(lexicalEx.ToString());
            }
            catch (Hubble.Core.SFQL.SyntaxAnalysis.SyntaxException syntaxEx)
            {
                ShowErrorMessage(syntaxEx.ToString());
            }
            catch (Hubble.Framework.Net.ServerException e1)
            {
                ShowErrorMessage(e1.Message + "\r\n" + e1.StackTrace);
            }
            catch (Exception e1)
            {
                ShowErrorMessage(e1.Message + "\r\n" + e1.StackTrace);
            }
            finally
            {
            }

            textBoxSql.Focus();
        }
Exemplo n.º 3
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            try
            {
                QueryPerfCounter qp = new QueryPerfCounter();

                bool dataCacheEnabled = checkBoxDataCache.Checked;

                int dataCacheTimeout = -1;

                if (dataCacheEnabled)
                {
                    dataCacheTimeout = (int)numericUpDownDataCache.Value;
                }

                qp.Start();

                SFQLParse sfqlParse = new SFQLParse();
                string    sql       = textBoxSql.Text;

                if (!string.IsNullOrEmpty(textBoxSql.SelectedText))
                {
                    sql = textBoxSql.SelectedText;
                }

                for (int i = 0; i < numericUpDownIteration.Value; i++)
                {
                    if (dataCacheEnabled)
                    {
                        DataAccess.Excute(sql, dataCacheTimeout);
                    }
                    else
                    {
                        DataAccess.Excute(sql);
                    }
                }

                qp.Stop();
                double ns = qp.Duration(1);

                StringBuilder report = new StringBuilder();

                report.AppendFormat("{0} ", (ns / ((long)1000 * (long)1000 * (int)numericUpDownIteration.Value)).ToString("0.00") + " ms");

                labelDuration.Text = report.ToString();
            }
            catch (Hubble.Core.SFQL.LexicalAnalysis.LexicalException lexicalEx)
            {
                ShowErrorMessage(lexicalEx.ToString());
            }
            catch (Hubble.Core.SFQL.SyntaxAnalysis.SyntaxException syntaxEx)
            {
                ShowErrorMessage(syntaxEx.ToString());
            }
            catch (Exception e1)
            {
                ShowErrorMessage(e1.Message + "\r\n" + e1.StackTrace);
            }
            finally
            {
            }
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                QueryPerfCounter qp = new QueryPerfCounter();

                SFQLParse sfqlParse = new SFQLParse();
                string    sql       = textBoxSql.Text;

                if (!string.IsNullOrEmpty(textBoxSql.SelectedText))
                {
                    sql = textBoxSql.SelectedText;
                }

                Hubble.SQLClient.QueryResult result = DataAccess.Excute(sql);

                qp.Start();

                for (int i = 0; i < numericUpDownIteration.Value; i++)
                {
                    //MemoryStream s = Serialize(result, true);

                    //Hubble.SQLClient.QueryResult r =
                    //    Hubble.SQLClient.QueryResultSerialization.Deserialize(s, true);

                    //if (result.DataSet.Tables.Count == r.DataSet.Tables.Count)
                    //{
                    //    MessageBox.Show("OK");
                    //}

                    //len = s.Length;
                    //MemoryStream s = Hubble.Framework.Serialization.XmlSerialization<Hubble.SQLClient.QueryResult>.Serialize(result, Encoding.UTF8);


                    //MemoryStream s = new MemoryStream();
                    //IFormatter formatter = new BinaryFormatter();
                    //formatter.Serialize(s, result);
                    //s.Position = 0;
                    //len = s.Length;

                    //MemoryStream cs = Compress(s);
                    //cs.Position = 0;
                    //cs = DeCompress(cs);
                    //cs.Position = 0;
                    //formatter = new BinaryFormatter();
                    //formatter.Deserialize(s);

                    //Hubble.Framework.Serialization.XmlSerialization<Hubble.SQLClient.QueryResult>.Deserialize(cs);
                }

                qp.Stop();
                double ns = qp.Duration(1);

                StringBuilder report = new StringBuilder();

                report.AppendFormat("{0} ", (ns / (1000 * 1000 * (int)numericUpDownIteration.Value)).ToString("0.00") + " ms");

                labelDuration.Text = report.ToString();
            }
            catch (Hubble.Core.SFQL.LexicalAnalysis.LexicalException lexicalEx)
            {
                ShowErrorMessage(lexicalEx.ToString());
            }
            catch (Hubble.Core.SFQL.SyntaxAnalysis.SyntaxException syntaxEx)
            {
                ShowErrorMessage(syntaxEx.ToString());
            }
            catch (Exception e1)
            {
                ShowErrorMessage(e1.Message + "\r\n" + e1.StackTrace);
            }
            finally
            {
            }
        }