Merge branch 'ReturnDirectionFromSwipeEndpoint-#17' into Release0.2
This commit is contained in:
commit
e7521f824f
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
|||||||
**csproj.DotSettings
|
**csproj.DotSettings
|
||||||
**.csproj.user
|
**.csproj.user
|
||||||
*spa.min.*
|
*spa.min.*
|
||||||
|
**spa.min.*
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Interfaces
|
||||||
|
{
|
||||||
|
public class LogEventResponse
|
||||||
|
{
|
||||||
|
public LogDirection Direction { get; set; }
|
||||||
|
public OperationResponse ProcessResponse { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -95,7 +95,7 @@ namespace Interfaces
|
|||||||
/// <returns>
|
/// <returns>
|
||||||
/// <see cref="OperationResponse"/> to indicate procedure status.
|
/// <see cref="OperationResponse"/> to indicate procedure status.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
OperationResponse LogEventTime(Identifier identifier, out int logId);
|
LogEventResponse LogEventTime(Identifier identifier, out int logId);
|
||||||
|
|
||||||
OperationResponse CreateGroup(Group group, out int groupId);
|
OperationResponse CreateGroup(Group group, out int groupId);
|
||||||
List<Group> GetGroups(int userId = -1);
|
List<Group> GetGroups(int userId = -1);
|
||||||
|
|||||||
@ -60,6 +60,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AppDetails.cs" />
|
<Compile Include="AppDetails.cs" />
|
||||||
<Compile Include="DailyLogs.cs" />
|
<Compile Include="DailyLogs.cs" />
|
||||||
|
<Compile Include="EventLogResponse.cs" />
|
||||||
<Compile Include="Group.cs" />
|
<Compile Include="Group.cs" />
|
||||||
<Compile Include="GroupList.cs" />
|
<Compile Include="GroupList.cs" />
|
||||||
<Compile Include="ILogger.cs" />
|
<Compile Include="ILogger.cs" />
|
||||||
|
|||||||
@ -98,27 +98,7 @@ namespace SQLiteRepository
|
|||||||
ret.TotalUserCount = userCount;
|
ret.TotalUserCount = userCount;
|
||||||
return ret;
|
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)
|
public UserList Search(string searchParam)
|
||||||
{
|
{
|
||||||
_logger.Trace("Searching SQLite database for the term: {0}", searchParam);
|
_logger.Trace("Searching SQLite database for the term: {0}", searchParam);
|
||||||
@ -361,8 +341,9 @@ namespace SQLiteRepository
|
|||||||
return ret;
|
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<CardUniqueId>(
|
var cardIdQuery = _connection.Query<CardUniqueId>(
|
||||||
SQLiteProcedures.GET_CARDS_BY_UNIQUE_ID,
|
SQLiteProcedures.GET_CARDS_BY_UNIQUE_ID,
|
||||||
identifier.UniqueId);
|
identifier.UniqueId);
|
||||||
@ -378,7 +359,9 @@ namespace SQLiteRepository
|
|||||||
UpdateIdentifierLastUsed(DateTimeOffset.UtcNow, ident.Id);
|
UpdateIdentifierLastUsed(DateTimeOffset.UtcNow, ident.Id);
|
||||||
logId = -1;
|
logId = -1;
|
||||||
//dont try to log any timelogs against this card, as it is unassigned to a user.
|
//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
|
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);
|
_logger.Error("Not logging event for user id: {0}, logged event within TimeGap Threshold of {1}", ident.UserId_FK, threshold);
|
||||||
logId = -1;
|
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);
|
UpdateIdentifierLastUsed(timeLog.SwipeEventDateTime, timeLog.IdentifierId);
|
||||||
|
|
||||||
logId = timeLog.Id;
|
logId = timeLog.Id;
|
||||||
|
ret.Direction = (LogDirection)(int)logDirection;
|
||||||
return OperationResponse.SUCCESS;
|
ret.ProcessResponse = OperationResponse.SUCCESS;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Groups*/
|
/*Groups*/
|
||||||
@ -565,6 +551,26 @@ namespace SQLiteRepository
|
|||||||
return OperationResponse.UPDATED;
|
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)
|
private int ConvertSourceToIdentifierId(LogSource logSource)
|
||||||
{
|
{
|
||||||
switch (logSource)
|
switch (logSource)
|
||||||
|
|||||||
@ -14,10 +14,12 @@ namespace WindowsDataCenter
|
|||||||
{
|
{
|
||||||
private readonly IRepository _repo;
|
private readonly IRepository _repo;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="repo"></param>
|
/// <param name="repo"></param>
|
||||||
|
/// <param name="logger"></param>
|
||||||
public SwipeDataController(IRepository repo, ILogger logger)
|
public SwipeDataController(IRepository repo, ILogger logger)
|
||||||
{
|
{
|
||||||
if(repo == null) throw new ArgumentNullException(nameof(repo));
|
if(repo == null) throw new ArgumentNullException(nameof(repo));
|
||||||
@ -36,13 +38,10 @@ namespace WindowsDataCenter
|
|||||||
public IHttpActionResult PostData([FromBody] CardData cData)
|
public IHttpActionResult PostData([FromBody] CardData cData)
|
||||||
{
|
{
|
||||||
int logId;
|
int logId;
|
||||||
_repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId);
|
var resp = _repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId);
|
||||||
_logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}", cData.CardUId, DateTime.UtcNow);
|
_logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}, direction is : {2}", cData.CardUId,
|
||||||
return
|
DateTime.UtcNow, resp.Direction);
|
||||||
ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK)
|
return Ok(new {Id = logId, resp.Direction});
|
||||||
{
|
|
||||||
Content = new StringContent(logId.ToString())
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1 +0,0 @@
|
|||||||
.table td.fit,.table th.fit{white-space:nowrap;width:1%}.table>tbody>tr>td.valign{vertical-align:middle}@media(max-width:576px){ul>li>a.indent-nav-xs{padding-left:50px}}.bootstrap-datetimepicker-widget tr:hover{background-color:#808080}.datepicker tr.highlight{background:#eee;cursor:pointer}.footer{position:absolute;bottom:0;width:100%;height:132px}.footerBody{margin-bottom:132px}
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user