/// <summary> /// Prints a list of tables in the umbraco DB /// </summary> /// <param name="connString"></param> public static void PrintTables(string connString) { var reader = new SqlCEHelper(connString).ExecuteReader( "select table_name from information_schema.tables where TABLE_TYPE <> 'VIEW'"); while (reader.Read()) { var tableName = reader.GetString("table_name"); Console.WriteLine(tableName); var reader1 = new SqlCEHelper(connString).ExecuteScalar<int>("select count(*) from {0}".Formatted(tableName)); Console.WriteLine(reader1); } }
/// <summary> /// Prints a list of tables in the umbraco DB /// </summary> /// <param name="connString"></param> public static void PrintTables(string connString) { var reader = new SqlCEHelper(connString).ExecuteReader( "select table_name from information_schema.tables where TABLE_TYPE <> 'VIEW'"); while (reader.Read()) { var tableName = reader.GetString("table_name"); Console.WriteLine(tableName); var reader1 = new SqlCEHelper(connString).ExecuteScalar <int>("select count(*) from {0}".Formatted(tableName)); Console.WriteLine(reader1); } }
//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 { } }
static ZLLog() { constr = SqlCEHelper.GetConStr(function.VToP("/Log/log.sdf"), "zoomlacms"); }