Commit d3604d26 authored by 潘栩锋's avatar 潘栩锋 🚴

修改 BufferError

parent 5e2479d3
......@@ -14,11 +14,10 @@ namespace FLY.OBJComponents.Server
{
public class BufferError : BufferSQLite<FlyData_WarningHistory, DB_Error>
{
public void Init(IErrorDBModel dBModel)
public void Init(DBTable<DB_Error> dbTable)
{
base.Init(dBModel.TbError, mapLc2Db, mapDb2Lc);
base.Init(dbTable, mapLc2Db, mapDb2Lc);
}
static DB_Error mapLc2Db(FlyData_WarningHistory lc)
{
return new DB_Error()
......
......@@ -145,9 +145,8 @@ namespace FLY.OBJComponents.Server
where TDb : IDbBase, new()
{
SQLiteDbContext dbModel;
DBTable<TDb> dbTable;
SQLiteHelper sqliteHelper;
public int NewestID => Count - 1;
public int Count { get; private set; }
......@@ -165,15 +164,15 @@ namespace FLY.OBJComponents.Server
{
}
public void Init(SQLiteDbContext dbModel, DBTable<TDb> dbTable)
public void Init(DBTable<TDb> dbTable)
{
this.dbModel = dbModel;
this.dbTable = dbTable;
this.sqliteHelper = dbTable.sqliteHelper;
Load();
}
void Load()
{
var n = dbModel.sqliteHelper.ExecuteScalar($"SELECT COUNT(*) FROM {dbTable.TableName}");
var n = sqliteHelper.ExecuteScalar($"SELECT COUNT(*) FROM {dbTable.TableName}");
int count = System.Convert.ToInt32(n);
Count = count;
}
......@@ -186,7 +185,7 @@ namespace FLY.OBJComponents.Server
//SQLs
List<string> sqls = new List<string>();
sqls.Add(SQLiteHelper.GetInsertCommandText(db));
dbModel.sqliteHelper.QueryTranAsync(sqls);
sqliteHelper.QueryTranAsync(sqls);
Count++;
}
......@@ -201,7 +200,7 @@ namespace FLY.OBJComponents.Server
//SQLs
sqls.Add(SQLiteHelper.GetInsertCommandText(db));
}
dbModel.sqliteHelper.QueryTranAsync(sqls);
sqliteHelper.QueryTranAsync(sqls);
Count += dbs.Count();
}
......@@ -213,7 +212,7 @@ namespace FLY.OBJComponents.Server
//SQLs
List<string> sqls = new List<string>();
sqls.Add($"DELETE FROM {dbTable.TableName}");
dbModel.sqliteHelper.QueryTranAsync(sqls);
sqliteHelper.QueryTranAsync(sqls);
Count = 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment