diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs index 02bbfaf..6745187 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -351,18 +351,21 @@ namespace SQLiteRepository var logDirection = GetLogDirection(ident.UserId_FK); #region Check the user hasnt registered an event in the last few minutes.. - //BUG: what happens if unassociated cards are swiped within the threshold? need to get all of them. - var hysteresisThresholdMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["SwipeTimeGap"] ?? "3"); - var threshold = DateTime.UtcNow.AddMinutes(0 - hysteresisThresholdMinutes); - var logs = _connection.Query( - SQLiteProcedures.GET_LOGS_IN_LAST_X_MINUTES, - threshold.Ticks, ident.UserId_FK); - _logger.Trace("Checking last swipe event gap"); - if (logs.Any()) - { - _logger.Error("Not logging event for user id: {0}, logged event within TimeGap Threshold of {1}", ident.UserId_FK, threshold); - logId = -1; - return OperationResponse.FAILED; + + if (ident.UserId_FK!=-1) + { //only check log gap if the card is associated to a user + var hysteresisThresholdMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["SwipeTimeGap"] ?? "3"); + var threshold = DateTime.UtcNow.AddMinutes(0 - hysteresisThresholdMinutes); + var logs = _connection.Query( + SQLiteProcedures.GET_LOGS_IN_LAST_X_MINUTES, + threshold.Ticks, ident.UserId_FK); + _logger.Trace("Checking last swipe event gap"); + if (logs.Any()) + { + _logger.Error("Not logging event for user id: {0}, logged event within TimeGap Threshold of {1}", ident.UserId_FK, threshold); + logId = -1; + return OperationResponse.FAILED; + } } #endregion