/// <summary> /// 写入至文本或XML /// </summary> public static void L(Model.ZLEnum.Log type, M_Log model) { EmptyDeal(type, model); ILog logs = LogManager.GetLogger(type.ToString()); logs.Info(model.ToString()); }
private static M_Log EmptyDeal(Model.ZLEnum.Log type, M_Log model) { if (string.IsNullOrEmpty(model.Action)) { model.Action = type.ToString(); } if (model.CDate <= DateTime.MinValue) { model.CDate = DateTime.Now; } try { //if (string.IsNullOrEmpty(model.IP)) { model.IP = IPScaner.GetUserIP(); } //if (string.IsNullOrEmpty(model.Source)) { model.Source = HttpContext.Current.Request.RawUrl; } } catch { } if (type == Model.ZLEnum.Log.fileup || type == Model.ZLEnum.Log.safe) { //try //{ // if (string.IsNullOrEmpty(model.UName)) { M_UserInfo mu = new B_User().GetLogin(); if (mu != null && mu.UserID != 0) { model.UName = mu.UserName; } } // if (string.IsNullOrEmpty(model.AName)) { M_AdminInfo adminMod = B_Admin.GetLogin(); if (adminMod != null && adminMod.AdminId > 0) { model.AName = adminMod.AdminName; } } //} //catch { } } return(model); }
/// <summary> /// 写入至文本或XML /// </summary> public static void L(Model.ZLEnum.Log type, M_Log model) { EmptyDeal(type, model); //ILog logs = LogManager.GetLogger(type.ToString()); //logs.Info(model.ToString()); ZoomLa.Components.CMSLog.L(type.ToString(), model.ToString()); }
public static void L(Model.ZLEnum.Log type, string msg) { M_Log model = new M_Log() { Message = msg }; L(type, model); }
//写入至SQL public static int ToSQL(Model.ZLEnum.Log type, M_Log model) { EmptyDeal(type, model); try { int id = Sql.insertID(model.TbName, model.GetParameters(), BLLCommon.GetParas(model), BLLCommon.GetFields(model)); if (id % 200 == 0) { string sql = "DELETE FROM " + model.TbName + " WHERE (SELECT COUNT(ID) FROM " + model.TbName + ")> 30000 AND ID IN (SELECT TOP 10000 ID FROM " + model.TbName + " ORDER BY CDate ASC)"; SqlHelper.ExecuteSql(sql); } return(id); } catch { return(0); } }
/// <summary> /// 写入至SQLite /// </summary> /// <returns>插入的ID</returns> public static int ToDB(Model.ZLEnum.Log type, M_Log model) { try { //EmptyDeal(type, model); //string dbfile = GetDBFile(type); //int id = SQLiteHelper.Insert(dbfile, GetTableName(type), model.ToDic()); //if (id % 100 == 0) //{ // //如果数据大于3万条,则删除1万条 // string sql = "DELETE FROM ZL_ConLog WHERE (SELECT count(ID) FROM ZL_ConLog)> 30000 AND ID in (SELECT ID FROM ZL_ConLog ORDER BY CDate DESC"; // sql += " LIMIT (SELECT count(ID) FROM ZL_ConLog) offset 20000 ) "; // SQLiteHelper.ExecuteSql(dbfile, sql); //} //return id; return(1); } catch { return(1); } }
//private static string GetDBFile(Model.ZLEnum.Log type) //{ // switch (type) // { // case Model.ZLEnum.Log.content: // return function.VToP("/Log/ConLog.db"); // case Model.ZLEnum.Log.alogin: // return function.VToP("/Log/AdminLogin.db"); // default: // throw new Exception("无对应数据库"); // } //} //private static string GetTableName(Model.ZLEnum.Log type) //{ // return "ZL_ConLog";//用此名,按数据库分 //} #endregion /*---------------------------------------------*/ //内容管理日志 public DataTable SelLog(Model.ZLEnum.Log type) { //string dbfile = GetDBFile(type); //try //{ // return SQLiteHelper.ExecuteTable(dbfile, "SELECT * FROM ZL_ConLog"); //} //catch { return null; } switch (type) { case Model.ZLEnum.Log.alogin: //return SqlHelper.ExecuteTable(CommandType.Text,"SELECT * FROM ZL_Log4"); return(SqlCEHelper.ExecuteTable(constr, "SELECT * FROM ZL_Log4 ORDER BY CDate DESC")); case Model.ZLEnum.Log.content: return(null); default: return(null); } }
public static void ToCE(Model.ZLEnum.Log type, M_Log model) { try { string tbname = "ZL_Log4"; EmptyDeal(type, model); SqlCEHelper.InsertID(constr, tbname, BLLCommon.GetFields(model), BLLCommon.GetParas(model), GetCESP(model)); int ran = new Random().Next(0, 151); if (ran == 150) { int count = Convert.ToInt32(SqlCEHelper.ExecuteTable(constr, "SELECT COUNT(*) FROM " + tbname).Rows[0][0]); if (count > 30000)//如果数据大于3万条,则删除1万条 { string midsql = "SELECT * FROM " + tbname + " ORDER BY CDate DESC OFFSET 20000 ROWS FETCH NEXT 1 ROWS ONLY;"; int id = Convert.ToInt32(SqlCEHelper.ExecuteTable(constr, midsql).Rows[0][0]); string delsql = "DELETE FROM " + tbname + " WHERE ID<" + id; SqlCEHelper.ExecuteSql(constr, delsql); } } } catch { } }