/// <summary> /// Validate database size - check how many records are stored /// in database and how much records need space. /// If space or number of records are invalid /// database will remove old reports /// </summary> private bool ValidateDatabaseSize() { //check how many records are stored in database //remove in case when we want to store one more than expected number //If record count == 0 then we ignore this condition if (BacktraceDatabaseContext.Count() + 1 > DatabaseSettings.MaxRecordCount && DatabaseSettings.MaxRecordCount != 0) { if (!BacktraceDatabaseContext.RemoveLastRecord()) { return(false); } } //check database size. If database size == 0 then we ignore this condition //remove all records till database use enough space if (DatabaseSettings.MaxDatabaseSize != 0 && BacktraceDatabaseContext.GetSize() > DatabaseSettings.MaxDatabaseSize) { //if your database is entry or every record is locked //deletePolicyRetry avoid infinity loop int deletePolicyRetry = 5; while (BacktraceDatabaseContext.GetSize() > DatabaseSettings.MaxDatabaseSize) { BacktraceDatabaseContext.RemoveLastRecord(); deletePolicyRetry--; if (deletePolicyRetry != 0) { break; } } return(deletePolicyRetry != 0); } return(true); }
/// <summary> /// Get total number of records in database /// </summary> /// <returns>Total number of records</returns> public int Count() { return(BacktraceDatabaseContext.Count()); }
/// <summary> /// Get total number of records in database /// </summary> /// <returns>Total number of records</returns> internal int Count() { return(BacktraceDatabaseContext.Count()); }
private bool ReachedMaximumNumberOfRecords() { return(BacktraceDatabaseContext.Count() + 1 > DatabaseSettings.MaxRecordCount && DatabaseSettings.MaxRecordCount != 0); }