From c92ed064fccf5a71d0f73c77537aabdcc6a99ec9 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Sun, 16 Apr 2017 19:40:33 +0100 Subject: [PATCH] move private methods to end of class. change LogEventTime implementation to return a LogEventResponse object. #17 --- .../SQLiteRepository/SQLiteRepository.cs | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs index 3e2d97d..1d29754 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -98,27 +98,7 @@ namespace SQLiteRepository ret.TotalUserCount = userCount; return ret; } - - private DateTime GetLastLogDateTime(TimeLogDb timeLog) - { - if (timeLog != null) - { - return timeLog.SwipeEventDateTime.DateTime; - } - return DateTime.MinValue; - } - - private bool GetUserState(LogDirectionDb logDirection) - { - switch (logDirection) - { - case LogDirectionDb.OUT: - return true; - default: - return false; - } - } - + public UserList Search(string searchParam) { _logger.Trace("Searching SQLite database for the term: {0}", searchParam); @@ -361,8 +341,9 @@ namespace SQLiteRepository return ret; } - public OperationResponse LogEventTime(Identifier identifier, out int logId) + public LogEventResponse LogEventTime(Identifier identifier, out int logId) { + var ret = new LogEventResponse(); var cardIdQuery = _connection.Query( SQLiteProcedures.GET_CARDS_BY_UNIQUE_ID, identifier.UniqueId); @@ -378,7 +359,9 @@ namespace SQLiteRepository UpdateIdentifierLastUsed(DateTimeOffset.UtcNow, ident.Id); logId = -1; //dont try to log any timelogs against this card, as it is unassigned to a user. - return OperationResponse.SUCCESS; + ret.ProcessResponse=OperationResponse.SUCCESS; + ret.Direction = LogDirection.UNKNOWN; + return ret; } else { @@ -404,7 +387,9 @@ namespace SQLiteRepository { _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; + ret.ProcessResponse = OperationResponse.FAILED; + ret.Direction = LogDirection.UNKNOWN; + return ret; } } @@ -431,8 +416,9 @@ namespace SQLiteRepository UpdateIdentifierLastUsed(timeLog.SwipeEventDateTime, timeLog.IdentifierId); logId = timeLog.Id; - - return OperationResponse.SUCCESS; + ret.Direction = (LogDirection)(int)logDirection; + ret.ProcessResponse = OperationResponse.SUCCESS; + return ret; } /*Groups*/ @@ -565,6 +551,26 @@ namespace SQLiteRepository return OperationResponse.UPDATED; } + private DateTime GetLastLogDateTime(TimeLogDb timeLog) + { + if (timeLog != null) + { + return timeLog.SwipeEventDateTime.DateTime; + } + return DateTime.MinValue; + } + + private bool GetUserState(LogDirectionDb logDirection) + { + switch (logDirection) + { + case LogDirectionDb.OUT: + return true; + default: + return false; + } + } + private int ConvertSourceToIdentifierId(LogSource logSource) { switch (logSource)