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.user
|
||||
*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>
|
||||
/// <see cref="OperationResponse"/> to indicate procedure status.
|
||||
/// </returns>
|
||||
OperationResponse LogEventTime(Identifier identifier, out int logId);
|
||||
LogEventResponse LogEventTime(Identifier identifier, out int logId);
|
||||
|
||||
OperationResponse CreateGroup(Group group, out int groupId);
|
||||
List<Group> GetGroups(int userId = -1);
|
||||
|
||||
@ -60,6 +60,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AppDetails.cs" />
|
||||
<Compile Include="DailyLogs.cs" />
|
||||
<Compile Include="EventLogResponse.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="GroupList.cs" />
|
||||
<Compile Include="ILogger.cs" />
|
||||
|
||||
@ -99,26 +99,6 @@ namespace SQLiteRepository
|
||||
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<CardUniqueId>(
|
||||
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)
|
||||
|
||||
@ -14,10 +14,12 @@ namespace WindowsDataCenter
|
||||
{
|
||||
private readonly IRepository _repo;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="logger"></param>
|
||||
public SwipeDataController(IRepository repo, ILogger logger)
|
||||
{
|
||||
if(repo == null) throw new ArgumentNullException(nameof(repo));
|
||||
@ -36,13 +38,10 @@ namespace WindowsDataCenter
|
||||
public IHttpActionResult PostData([FromBody] CardData cData)
|
||||
{
|
||||
int logId;
|
||||
_repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId);
|
||||
_logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}", cData.CardUId, DateTime.UtcNow);
|
||||
return
|
||||
ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent(logId.ToString())
|
||||
});
|
||||
var resp = _repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId);
|
||||
_logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}, direction is : {2}", cData.CardUId,
|
||||
DateTime.UtcNow, resp.Direction);
|
||||
return Ok(new {Id = logId, resp.Direction});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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