コード例 #1
0
 public void OnQueryExecute(QueryExecuteParams ep)
 {
     lock (this)
     {
         try
         {
             if (!m_cleared && QueryHistorySettings.Page.DeleteAfterDays > 0)
             {
                 int tm = (DateTime.Now - TimeSpan.FromDays(QueryHistorySettings.Page.DeleteAfterDays)).GetUnixTimestamp();
                 Connection.ExecuteNonQuery("delete from QueryExecute where ExecutedAtTimestamp < @p1", tm);
                 Connection.ExecuteNonQuery("delete from QueryText where not exists (select * from QueryExecute where QueryExecute.QueryText_ID = QueryText.ID)");
                 m_cleared = true;
             }
             if (QueryHistorySettings.Page.UseQueryHistory)
             {
                 int    hash   = ep.Sql.GetHashCode();
                 string codeid = Connection.ExecuteScalar("select ID from QueryText where HashCode=@p1", hash).SafeToString();
                 if (String.IsNullOrEmpty(codeid))
                 {
                     Connection.ExecuteScalar("insert into QueryText (QueryText, HashCode) values (@p1, @p2)", ep.Sql, hash);
                     codeid = Connection.GetInsertId().ToString();
                 }
                 Connection.ExecuteNonQuery(
                     "insert into QueryExecute (ExecutedAt, ExecutedAtTimestamp, Dialect, QueryText_ID, DbServer, DbName, QueryContext, FileName, DurationInMilisecs) values "
                     + "(@p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9)", ep.ExecutedAt.ToString("s"), ep.ExecutedAt.GetUnixTimestamp(), ep.Dialect.DialectName, codeid, ep.DbServer, ep.DbName, ep.QueryContext, ep.FileName, ep.DurationInMilisecs);
             }
         }
         catch (Exception err)
         {
             Logging.Warning("Error saving query to history:" + err.Message);
         }
     }
 }
コード例 #2
0
 private void LoadCurrentCellData()
 {
     if (dataGridView1.CurrentCell != null)
     {
         string      sid      = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
         string      codeid   = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[1].Value.ToString();
         string      sdialect = m_conn.ExecuteScalar("select Dialect from QueryExecute WHERE ID=@p1", sid).ToString();
         ISqlDialect dialect  = m_dialects.Get(sdialect);
         codeEditor1.Dialect = dialect;
         string sql = m_conn.ExecuteScalar("select QueryText from QueryText WHERE ID=@p1", codeid).ToString();
         codeEditor1.Text = sql ?? "";
     }
 }