Add support for card reader to provide its own date time.

#103
This commit is contained in:
chris.watts90@outlook.com 2019-09-11 17:37:26 +01:00
parent 4c99dfba71
commit 1943895eec
3 changed files with 1066 additions and 1049 deletions

View File

@ -96,10 +96,12 @@ namespace Interfaces
/// <see cref="Identifier"/> object with the Unique Id triggering the event
/// </param>
/// <param name="logId">The resultant Id of the inserted TimeLog</param>
/// <param name="logTime">Optional - To set the log time of the swipe.
/// <remarks>Particularly useful for buffering logs in nodes if they cannot contact server for whatever reason to minimise data loss</remarks></param>
/// <returns>
/// <see cref="OperationResponse"/> to indicate procedure status.
/// </returns>
LogEventResponse LogEventTime(Identifier identifier, out int logId);
LogEventResponse LogEventTime(Identifier identifier, out int logId, DateTime logTime = default(DateTime));
OperationResponse CreateGroup(Group group, out int groupId);
List<Group> GetGroups(int userId = -1);

View File

@ -410,8 +410,20 @@ namespace SQLiteRepository
return ret;
}
public LogEventResponse LogEventTime(Identifier identifier, out int logId)
public LogEventResponse LogEventTime(Identifier identifier, out int logId, DateTime logTime = default(DateTime))
{
#region Set the LogTime before we start querying anything.
if (logTime == default(DateTime))
{
logTime = DateTime.UtcNow;
_logger.Debug("Using own log time: {0}", logTime.ToString("o"));
}
else
{
_logger.Debug("Using supplied log time: {0}", logTime.ToString("o"));
}
#endregion
var ret = new LogEventResponse();
var cardIdQuery = _connection.Query<CardUniqueId>(
SQLiteProcedures.GET_CARDS_BY_UNIQUE_ID,
@ -465,7 +477,7 @@ namespace SQLiteRepository
#endregion
#region Get the current time (for swiping). and calendar week/year to help recall the data.
var logTime = DateTime.UtcNow;
var calendarWeek = GetIso8601CalendarWeek(logTime);
var year = logTime.Year;
#endregion

View File

@ -1,7 +1,10 @@
namespace WindowsDataCenter
using System;
namespace WindowsDataCenter
{
public class CardData
{
public DateTime? UtcTimeStamp { get; set; }
public string CardUId { get; set; }
}
}