public ArrayList GetOperatorLog() { ArrayList opLogs = new ArrayList(); string sql = String.Format("SELECT user, date, func, outfile FROM log order by date desc limit 2000"); SQLiteDataReader reader = dbExecutor.QuerySQL(sql); if (reader != null) { while (reader.Read()) { OpLog log = new OpLog(); log.User = reader["user"] as string; log.OpDate = reader["date"].ToString(); log.FuncName = reader["func"] as string; log.Outfile = reader["outfile"] as string; opLogs.Add(log); } } if (opLogs.Count >= 2000) { // 删除旧记录 string date = (opLogs[2000] as OpLog).OpDate; sql = String.Format("DELETE FROM log where date<'{0}'", date); dbExecutor.ExecuteSQL(sql); } return(opLogs); }
public bool AppendLog(string func, string outfile) { string date = DateTime.Now.ToString("s"); string sql = String.Format("INSERT INTO log(user, date, func, outfile) VALUES('{0}','{1}','{2}','{3}')", this.LoggedUser, date, func, outfile); bool success = dbExecutor.ExecuteSQL(sql); if (success && (NewOpLogArrived != null)) { OpLog log = new OpLog(); log.User = this.LoggedUser; log.OpDate = date; log.FuncName = func; log.Outfile = outfile; NewOpLogArrived(log); } return(success); }