public void Dispose() { if (Commoditys != null) { Commoditys.Clear(); } if (Users != null) { Users.Clear(); } if (Accounts != null) { Accounts.Clear(); } if (ClosedTradeDetails != null) { ClosedTradeDetails.Clear(); } if (CommoditySummarizations != null) { CommoditySummarizations.Clear(); } if (FundStatus != null) { FundStatus.Clear(); } if (Parameters != null) { Parameters.Clear(); } if (PositionDetails != null) { PositionDetails.Clear(); } if (Positions != null) { Positions.Clear(); } if (Remittances != null) { Remittances.Clear(); } if (Stocks != null) { Stocks.Clear(); } if (TradeDetails != null) { TradeDetails.Clear(); } if (Trades != null) { Trades.Clear(); } Commoditys = null; Users = null; Accounts = null; ClosedTradeDetails = null; CommoditySummarizations = null; FundStatus = null; Parameters = null; PositionDetails = null; Positions = null; Remittances = null; Stocks = null; TradeDetails = null; Trades = null; }
public void Delete(DateTime dateTime, Guid accountId, params Type[] types) { foreach (var type in types) { SQLiteCommand cmd = null; if (type == typeof(Commodity)) { continue; } else if (type == typeof(User)) { continue; } else if (type == typeof(Account)) { continue; } else if (type == typeof(ClosedTradeDetail)) { string sql = "DELETE FROM ClosedTradeDetail WHERE AccountId=@AccountId AND ActualDate>=@Date"; cmd = new SQLiteCommand(sql); ClosedTradeDetails.RemoveAll(m => m.AccountId == accountId && m.ActualDate >= dateTime.Date); } else if (type == typeof(CommoditySummarization)) { string sql = "DELETE FROM CommoditySummarization WHERE AccountId=@AccountId AND Date>=@Date"; cmd = new SQLiteCommand(sql); CommoditySummarizations.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date); } else if (type == typeof(FundStatus)) { string sql = "DELETE FROM FundStatus WHERE AccountId=@AccountId AND Date>=@Date"; cmd = new SQLiteCommand(sql); FundStatus.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date); } else if (type == typeof(Parameter)) { continue; } else if (type == typeof(PositionDetail)) { string sql = "DELETE FROM PositionDetail WHERE AccountId=@AccountId AND DateForPosition>=@Date"; cmd = new SQLiteCommand(sql); PositionDetails.RemoveAll(m => m.AccountId == accountId && m.DateForPosition >= dateTime.Date); } else if (type == typeof(Position)) { string sql = "DELETE FROM Position WHERE AccountId=@AccountId AND Date>=@Date"; cmd = new SQLiteCommand(sql); Positions.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date); } else if (type == typeof(Remittance)) { string sql = "DELETE FROM Remittance WHERE AccountId=@AccountId AND Date>=@Date"; cmd = new SQLiteCommand(sql); Remittances.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date); } else if (type == typeof(Stock)) { string sql = "DELETE FROM Stock WHERE AccountId=@AccountId AND Date>=@Date"; cmd = new SQLiteCommand(sql); Stocks.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date); } else if (type == typeof(TradeDetail)) { string sql = "DELETE FROM TradeDetail WHERE AccountId=@AccountId AND ActualTime>=@Date"; cmd = new SQLiteCommand(sql); TradeDetails.RemoveAll(m => m.AccountId == accountId && m.ActualTime >= dateTime.Date); } else if (type == typeof(Trade)) { string sql = "DELETE FROM Trade WHERE AccountId=@AccountId AND Date>=@Date"; cmd = new SQLiteCommand(sql); Trades.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date); } else { continue; } cmd.Parameters.AddWithValue("@AccountId", accountId.ToString()); cmd.Parameters.AddWithValue("@Date", dateTime.Date); cmds.Add(cmd); } }