using System; using System.Data; namespace Cyberpipe { class LogManager { //保存日志 public static void saveLog(String username, String operation) { try { //获得当前时间 string now = DateTime.Now.ToString("yyyy-MM-dd"); //操作名称转换 string convertedOper = operation; //根据oper名称转换为operid string convertSql = "select OPERID from casic_funclist where OPERNAME = '" + convertedOper + "'"; DataTable table = OledbHelper.QueryTable(convertSql); string operId = ""; if (table.Rows.Count > 0) { operId = table.Rows[0][0].ToString(); } else { operId = "0"; } //保存日志 //string sql = " insert into casic_loginfo values('" + now + "','" + // username + "','" + operId + "','')"; string sql = "insert into casic_loginfo(LOGDATE,LOGUSERNAME,LOGOPER) values (to_date('" + now + "','yyyy-MM-dd'),'" + username + "','" + operId + "')"; int count = OledbHelper.sqlExecuteNonQuery(sql); } catch (Exception ex) { LogError.PublishError(ex); } } /// <summary> /// 一个参数,便于线程进行调用 /// </summary> /// <param name="userAndOperate"></param> public static void saveLog(string userAndOperate) { string userName = userAndOperate.Substring(0, userAndOperate.IndexOf(",")); string operation = userAndOperate.Substring(userAndOperate.IndexOf(",") + 1); try { saveLog(userName, operation); } catch (Exception) { throw; } } } }