Merge branch 'ShowLastEventDateTime-#53' into Release0.1.5
This commit is contained in:
commit
168154a561
BIN
DataCenter_Windows/DBTestData/flexitimedb.db
Normal file
BIN
DataCenter_Windows/DBTestData/flexitimedb.db
Normal file
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Interfaces
|
namespace Interfaces
|
||||||
{
|
{
|
||||||
@ -19,7 +20,7 @@ namespace Interfaces
|
|||||||
{
|
{
|
||||||
get { return AssociatedIdentifiers.Count; }
|
get { return AssociatedIdentifiers.Count; }
|
||||||
}
|
}
|
||||||
|
public DateTime LastEventDateTime { get; set; }
|
||||||
public List<Identifier> AssociatedIdentifiers { get; set; }
|
public List<Identifier> AssociatedIdentifiers { get; set; }
|
||||||
|
|
||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
|
|||||||
@ -67,26 +67,15 @@ namespace SQLiteRepository
|
|||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
var userObj = ChangeToUserObject(user);
|
var userObj = ChangeToUserObject(user);
|
||||||
var cards = _connection.Query<CardUniqueId>(
|
|
||||||
SQLiteProcedures.GET_CARDS_BY_USER_ID,
|
|
||||||
user.Id);
|
|
||||||
|
|
||||||
foreach (var card in cards)
|
userObj.AssociatedIdentifiers = GetAssociatedIdentifiers(user.Id);
|
||||||
{
|
|
||||||
userObj.AssociatedIdentifiers.Add(new Identifier()
|
|
||||||
{
|
|
||||||
UniqueId = card.CardUId,
|
|
||||||
IsAssociatedToUser = true,
|
|
||||||
Id = card.Id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
userObj.State = GetUserState(GetLogDirection(user.Id));
|
userObj.State = GetUserState(GetLogDirection(user.Id));
|
||||||
|
userObj.LastEventDateTime = GetLastLogDateTime(GetLastTimeLog(user.Id));
|
||||||
ret.Users.Add(userObj);
|
ret.Users.Add(userObj);
|
||||||
}
|
}
|
||||||
if (pageNumber == -1 && pageSize == -1)
|
if (pageNumber == -1 && pageSize == -1)
|
||||||
{
|
{
|
||||||
ret.PageSize = 1; //TODO: switch to ret.UserCount
|
ret.PageSize = 10;
|
||||||
ret.PageNumber = 1;
|
ret.PageNumber = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -98,6 +87,15 @@ namespace SQLiteRepository
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DateTime GetLastLogDateTime(TimeLogDb timeLog)
|
||||||
|
{
|
||||||
|
if (timeLog != null)
|
||||||
|
{
|
||||||
|
return timeLog.SwipeEventDateTime.DateTime;
|
||||||
|
}
|
||||||
|
return DateTime.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
private bool GetUserState(LogDirectionDb logDirection)
|
private bool GetUserState(LogDirectionDb logDirection)
|
||||||
{
|
{
|
||||||
switch (logDirection)
|
switch (logDirection)
|
||||||
@ -142,6 +140,7 @@ namespace SQLiteRepository
|
|||||||
Id = card.Id
|
Id = card.Id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
userObj.State = GetUserState(GetLogDirection(user.Id));
|
||||||
ret.Users.Add(userObj);
|
ret.Users.Add(userObj);
|
||||||
}
|
}
|
||||||
//TODO: figure out paging here. - should there be any?
|
//TODO: figure out paging here. - should there be any?
|
||||||
@ -186,7 +185,7 @@ namespace SQLiteRepository
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
//TODO: refac this as it duplicates a lot of code.
|
|
||||||
public TimeLogList GetTimeLogs(int userId)
|
public TimeLogList GetTimeLogs(int userId)
|
||||||
{
|
{
|
||||||
return GetTimeLogs(userId, DateTime.UtcNow);
|
return GetTimeLogs(userId, DateTime.UtcNow);
|
||||||
@ -503,23 +502,20 @@ namespace SQLiteRepository
|
|||||||
var logDirection = LogDirectionDb.UNKNOWN;
|
var logDirection = LogDirectionDb.UNKNOWN;
|
||||||
if (userId != -1)
|
if (userId != -1)
|
||||||
{
|
{
|
||||||
var lastEntry = _connection.Query<TimeLogDb>(
|
var lastEntry = GetLastTimeLog(userId);
|
||||||
SQLiteProcedures.GET_LAST_TIMELOG_DIRECTION,
|
if (lastEntry != null)
|
||||||
userId);
|
|
||||||
if (lastEntry.Any())
|
|
||||||
{
|
{
|
||||||
var lastLog = lastEntry.First();
|
|
||||||
// See if the datetime retrieved is yesterday. If yesterday, logDirection = true (in)
|
// See if the datetime retrieved is yesterday. If yesterday, logDirection = true (in)
|
||||||
if (IsLogDateTimeYesterdayOrOlder(lastLog.SwipeEventDateTime.DateTime))
|
if (IsLogDateTimeYesterdayOrOlder(lastEntry.SwipeEventDateTime.DateTime))
|
||||||
{
|
{
|
||||||
logDirection = LogDirectionDb.IN;
|
logDirection = LogDirectionDb.IN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we have a time log from today already, so just do the opposite of what we last did!
|
// we have a time log from today already, so just do the opposite of what we last did!
|
||||||
if (lastLog.Direction == LogDirectionDb.IN)
|
if (lastEntry.Direction == LogDirectionDb.IN)
|
||||||
logDirection = LogDirectionDb.OUT;
|
logDirection = LogDirectionDb.OUT;
|
||||||
else if (lastLog.Direction == LogDirectionDb.OUT)
|
else if (lastEntry.Direction == LogDirectionDb.OUT)
|
||||||
logDirection = LogDirectionDb.IN;
|
logDirection = LogDirectionDb.IN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,6 +528,36 @@ namespace SQLiteRepository
|
|||||||
return logDirection;
|
return logDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TimeLogDb GetLastTimeLog(int userId)
|
||||||
|
{
|
||||||
|
var lastEntry = _connection.Query<TimeLogDb>(
|
||||||
|
SQLiteProcedures.GET_LAST_TIMELOG_DIRECTION,
|
||||||
|
userId);
|
||||||
|
if (lastEntry.Any())
|
||||||
|
{
|
||||||
|
return lastEntry.First();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Identifier> GetAssociatedIdentifiers(int userId)
|
||||||
|
{
|
||||||
|
var cards = _connection.Query<CardUniqueId>(
|
||||||
|
SQLiteProcedures.GET_CARDS_BY_USER_ID,
|
||||||
|
userId);
|
||||||
|
var ret = new List<Identifier>();
|
||||||
|
foreach (var card in cards)
|
||||||
|
{
|
||||||
|
ret.Add(new Identifier()
|
||||||
|
{
|
||||||
|
UniqueId = card.CardUId,
|
||||||
|
IsAssociatedToUser = true,
|
||||||
|
Id = card.Id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the calendar week of the year according to the ISO8601 standard (starts monday).
|
/// Get the calendar week of the year according to the ISO8601 standard (starts monday).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -76,10 +76,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="valign text-center">
|
<td class="valign text-center">
|
||||||
<!-- ko if: State -->
|
<!-- ko if: State -->
|
||||||
<span class="label label-success" style="display: block">IN</span>
|
<span class="label label-success" data-toggle="tooltip" data-placement="top" title="" data-bind="attr:{'title': $root.convertToDisplayDateTime(LastEventDateTime)}" style="display: block">IN</span>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- ko if: !State -->
|
<!-- ko if: !State -->
|
||||||
<span class="label label-danger" style="display: block">OUT</span>
|
<span class="label label-danger" data-toggle="tooltip" data-placement="top" title="" data-bind="attr:{'title': $root.convertToDisplayDateTime(LastEventDateTime)}" style="display: block">OUT</span>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
</td>
|
</td>
|
||||||
<td class="valign" data-bind="text: FirstName"></td>
|
<td class="valign" data-bind="text: FirstName"></td>
|
||||||
|
|||||||
@ -142,7 +142,7 @@
|
|||||||
};
|
};
|
||||||
self.convertToDisplayTime = function (dateValue) {
|
self.convertToDisplayTime = function (dateValue) {
|
||||||
var date = new Date(dateValue);
|
var date = new Date(dateValue);
|
||||||
return date.getHours() + ":" + (date.getMinutes() < 10 ? '0' : '') + date.getMinutes();
|
return date.getHours() + ":" + self.padNumber(date.getMinutes());
|
||||||
};
|
};
|
||||||
self.correctLogOffset = function (logCount) {
|
self.correctLogOffset = function (logCount) {
|
||||||
if (logCount % 2 !== 0) {
|
if (logCount % 2 !== 0) {
|
||||||
@ -156,6 +156,18 @@
|
|||||||
self.getTimeLogEntryArrayLength = function(maxDailyLogs) {
|
self.getTimeLogEntryArrayLength = function(maxDailyLogs) {
|
||||||
return Math.round(maxDailyLogs/2);
|
return Math.round(maxDailyLogs/2);
|
||||||
};
|
};
|
||||||
|
self.padNumber = function(number) {
|
||||||
|
return (number < 10 ? '0' : '') + number;
|
||||||
|
}
|
||||||
|
self.convertToDisplayDateTime = function (dateValue) {
|
||||||
|
var date = new Date(dateValue); // dd MM YY HH:mm:ss e.g.: 01 Mar 17 17:34:02
|
||||||
|
return date.getDay() + " "
|
||||||
|
+ date.toLocaleString("en-us", { month: "long" }) + " "
|
||||||
|
+ (date.getYear()-100) + " "
|
||||||
|
+ self.padNumber(date.getHours()) + ":"
|
||||||
|
+ self.padNumber(date.getMinutes()) + ":"
|
||||||
|
+ self.padNumber(date.getSeconds());
|
||||||
|
};
|
||||||
self.dismissAlert = function(data, event) {
|
self.dismissAlert = function(data, event) {
|
||||||
self.errorData(null);
|
self.errorData(null);
|
||||||
};
|
};
|
||||||
@ -229,6 +241,7 @@
|
|||||||
var url = self.createRequestUrl(self.apiEndpoints.getUserList, args, false);
|
var url = self.createRequestUrl(self.apiEndpoints.getUserList, args, false);
|
||||||
$.getJSON(url, function (res) {
|
$.getJSON(url, function (res) {
|
||||||
self.userList(res);
|
self.userList(res);
|
||||||
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
}).fail(function (response, status, error) {
|
}).fail(function (response, status, error) {
|
||||||
console.log("error - getusers");
|
console.log("error - getusers");
|
||||||
var errObj = self.processRequestFailure(response, status, error);
|
var errObj = self.processRequestFailure(response, status, error);
|
||||||
|
|||||||
@ -76,7 +76,9 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user