private void Readlog() { string ConnectionString, StartTime, EndTime, TableName; ConnectionString = txtConnectionstring.Text; StartTime = dtStarttime.Value.ToString("yyyy-MM-dd HH:mm:ss"); EndTime = dtEndtime.Value.ToString("yyyy-MM-dd HH:mm:ss"); TableName = txtTablename.Text.TrimEnd(); dbla = new DatabaseLogAnalyzer(ConnectionString); logs = dbla.ReadLog(StartTime, EndTime, TableName); }
private void fshowresult(DatabaseLogAnalyzer p) { btnReadlog.Text = "ReadLog\r\n[" + p.ReadPercent.ToString() + "%]"; if (p.ReadPercent >= 100) { bindingSource1.DataSource = logs; bindingSource1.ResetBindings(false); timer.Enabled = false; btnReadlog.Text = "ReadLog"; } }
private void Readlog() { string ConnectionString, StartTime, EndTime, TableName; DatabaseLogAnalyzer dbla; DatabaseLog[] logs; ConnectionString = txtConnectionstring.Text; StartTime = dtStarttime.Value.ToString("yyyy-MM-dd HH:mm:ss"); EndTime = dtEndtime.Value.ToString("yyyy-MM-dd HH:mm:ss"); TableName = txtTablename.Text.TrimEnd(); dbla = new DatabaseLogAnalyzer(ConnectionString); logs = dbla.ReadLog(StartTime, EndTime, TableName); Invoke(new ShowResult(ResetDataSource), new object[] { logs }); }
private void btdblog_Click(object sender, RoutedEventArgs e) { try { DatabaseLogAnalyzer dbla; string dblacon = ""; if (checkBox.IsChecked == false) { dblacon = "data source=" + thost.Text.Trim() + ";initial catalog=" + sdatabase.SelectedValue.ToString() + ";persist security info=False;user id=" + tuser.Text.Trim() + ";pwd=" + tcode.Password.Trim() + ";"; } else { dblacon = "data source=" + thost.Text.Trim() + ";initial catalog=" + sdatabase.SelectedValue.ToString() + ";persist security info=False;trusted_connection=SSPI;"; }; dbla = new DatabaseLogAnalyzer(dblacon); if (stable.SelectedValue.ToString() == "所有数据表") { loggird.DataContext = null; logs = dbla.ReadLog(sbegindate.SelectedDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), senddate.SelectedDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), ""); loggird.DataContext = logs; } else { loggird.DataContext = null; logs = dbla.ReadLog(sbegindate.SelectedDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), senddate.SelectedDate.Value.ToString("yyyy-MM-dd HH:mm:ss"), stable.SelectedValue.ToString()); loggird.DataContext = logs; } MessageBox.Show("读取到" + logs.Length + "条日志记录!"); if (logs.Length > 0) { btextsql.IsEnabled = true; } else { btextsql.IsEnabled = false; } } catch (Exception ex) { MessageBox.Show("读取日志记录失败!"); btextsql.IsEnabled = false; return; } }
public static IEnumerable DBAReadLog(string pconnectionstring, string pbegintime, string pendtime, string pobjectname) { DatabaseLog[] r; DatabaseLogAnalyzer xc; if (string.IsNullOrEmpty(pbegintime)) { pbegintime = DateTime.Now.AddSeconds(-5).ToString("yyyy-MM-dd HH:mm:ss"); } if (string.IsNullOrEmpty(pendtime)) { pendtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } xc = new DatabaseLogAnalyzer(pconnectionstring); r = xc.ReadLog(pbegintime, pendtime, pobjectname); return(r); }