diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs index 5840581..dfbcb91 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -67,26 +67,15 @@ namespace SQLiteRepository foreach (var user in users) { var userObj = ChangeToUserObject(user); - var cards = _connection.Query( - SQLiteProcedures.GET_CARDS_BY_USER_ID, - user.Id); - foreach (var card in cards) - { - userObj.AssociatedIdentifiers.Add(new Identifier() - { - UniqueId = card.CardUId, - IsAssociatedToUser = true, - Id = card.Id - }); - } + userObj.AssociatedIdentifiers = GetAssociatedIdentifiers(user.Id); userObj.State = GetUserState(GetLogDirection(user.Id)); - + userObj.LastEventDateTime = GetLastLogDateTime(GetLastTimeLog(user.Id)); ret.Users.Add(userObj); } if (pageNumber == -1 && pageSize == -1) { - ret.PageSize = 1; //TODO: switch to ret.UserCount + ret.PageSize = 10; ret.PageNumber = 1; } else @@ -106,6 +95,7 @@ namespace SQLiteRepository } return DateTime.MinValue; } + private bool GetUserState(LogDirectionDb logDirection) { switch (logDirection) @@ -150,6 +140,7 @@ namespace SQLiteRepository Id = card.Id }); } + userObj.State = GetUserState(GetLogDirection(user.Id)); ret.Users.Add(userObj); } //TODO: figure out paging here. - should there be any? @@ -194,7 +185,7 @@ namespace SQLiteRepository return ret; } - //TODO: refac this as it duplicates a lot of code. + public TimeLogList GetTimeLogs(int userId) { return GetTimeLogs(userId, DateTime.UtcNow); @@ -548,6 +539,25 @@ namespace SQLiteRepository } return null; } + + private List GetAssociatedIdentifiers(int userId) + { + var cards = _connection.Query( + SQLiteProcedures.GET_CARDS_BY_USER_ID, + userId); + var ret = new List(); + foreach (var card in cards) + { + ret.Add(new Identifier() + { + UniqueId = card.CardUId, + IsAssociatedToUser = true, + Id = card.Id + }); + } + return ret; + } + /// /// Get the calendar week of the year according to the ISO8601 standard (starts monday). /// diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj index 8b8049d..e5f50d5 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj @@ -76,7 +76,9 @@ - + + Designer +