diff --git a/.gitignore b/.gitignore
index 97a2c2b..0930bf1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
**csproj.DotSettings
**.csproj.user
*spa.min.*
+**spa.min.*
diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/EventLogResponse.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/EventLogResponse.cs
new file mode 100644
index 0000000..8331d70
--- /dev/null
+++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/EventLogResponse.cs
@@ -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; }
+ }
+}
diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs
index bdd3acf..30f8141 100644
--- a/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs
+++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs
@@ -95,7 +95,7 @@ namespace Interfaces
///
/// to indicate procedure status.
///
- OperationResponse LogEventTime(Identifier identifier, out int logId);
+ LogEventResponse LogEventTime(Identifier identifier, out int logId);
OperationResponse CreateGroup(Group group, out int groupId);
List GetGroups(int userId = -1);
diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/Interfaces.csproj b/DataCenter_Windows/WindowsDataCenter/Interfaces/Interfaces.csproj
index 70f72cc..2a53dee 100644
--- a/DataCenter_Windows/WindowsDataCenter/Interfaces/Interfaces.csproj
+++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/Interfaces.csproj
@@ -60,6 +60,7 @@
+
diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs
index 3e2d97d..1d29754 100644
--- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs
+++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs
@@ -98,27 +98,7 @@ namespace SQLiteRepository
ret.TotalUserCount = userCount;
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(
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)
diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs
index a1b8a9d..ed31a9f 100644
--- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs
+++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs
@@ -14,10 +14,12 @@ namespace WindowsDataCenter
{
private readonly IRepository _repo;
private readonly ILogger _logger;
+
///
///
///
///
+ ///
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});
}
}
}
\ No newline at end of file
diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.min.css b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.min.css
deleted file mode 100644
index 69d4616..0000000
--- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.min.css
+++ /dev/null
@@ -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}
\ No newline at end of file
diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.min.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.min.js
deleted file mode 100644
index 47caf59..0000000
--- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.min.js
+++ /dev/null
@@ -1 +0,0 @@
-function DataVM(){"use strict";var n=this;n.menuOptions=["Home"];n.chosenMenuItemId=ko.observable();n.appDetails=ko.observable(null);n.userList=ko.observable(null);n.groupsList=ko.observable(null);n.chosenUserDetails=ko.observable(null);n.userTimeLogData=ko.observable(null);n.unassignedCardData=ko.observable(null);n.chosenTimeLogUserId=-1;n.selectedCalendarWeek=ko.observable(0);n.errorData=ko.observable(null);n.apiEndpoints={root:"http://localhost:8800",getUserList:"/api/users",getUserDetails:"/api/users",editUser:"/api/users/edit",getTimeLogs:"/api/timelogs",getUnassignedCards:"/api/cards/unassigned",getGroups:"/api/groups",getAppDetails:"/api/app"};n.uiPages={users:"users",userDetails:"userData",timeLogs:"timelogs",home:function(){return this.users}};n.goToMenuOption=function(n){location.hash=n;console.log("goToMenuOption: "+n)};n.goToUserDetails=function(t){location.hash=n.uiPages.userDetails+"/"+t.UserId};n.goToTimeLogs=function(t,i,r){var f,u;f=t.UserId?t.UserId:t;u="timelogs/"+f;r&&(u=n.createRequestUrl(u,r,!1,!1));location.hash=u};n.assignErrorObject=function(t,i,r){var u={errorCode:t,errorMessage:i,errorSource:r,errorDate:(new Date).toDateString("yyyy-mm-dd")};n.errorData(u)};n.processRequestFailure=function(n){return n.readyState===4?{errorCode:n.status,errorMessage:n.statusText,errorSource:""}:n.readyState===0?{errorCode:n.status,errorMessage:"Network Error - Is the server available?",errorSource:""}:{errorCode:n.status,errorMessage:"Unknown Error",errorSource:""}};n.createRequestUrl=function(t,i,r,u){var o="?",f="",e;if(u&&(f=n.apiEndpoints.root),f=f+t,i!==undefined&&i!==null&&i.length>0)for(e=0;e0?n.getUserList(null,null,t):n.getUserList(r,u)});this.get("#userData/:userId",function(){n.chosenMenuItemId("Data");n.userList(null);n.getUserDetails(this.params.userId);n.userTimeLogData(null);n.getUnassignedCardData()});this.get("#timelogs/:userId",function(){var t=this.params.selectedDate;n.chosenMenuItemId("Other");n.userList(null);n.chosenUserDetails(null);n.chosenTimeLogUserId=this.params.userId;n.getTimeLogData(this.params.userId,t)});this.get("#newUser",function(){n.chosenMenuItemId("newUser");n.userList(null);n.userTimeLogData(null);n.chosenUserDetails({UserId:-1,FirstName:null,LastName:null,HoursPerWeek:null,AssociatedIdentifiers:[],Groups:[],IsContractor:!1});n.getGroups(function(t){n.chosenUserDetails().Groups=t;n.chosenUserDetails.valueHasMutated()});n.getUnassignedCardData()});this.get("#stats",function(){n.goToMenuOption("users")});this.post("#edituser",function(){return $.each(n.chosenUserDetails().AssociatedIdentifiers,function(t,i){i.IsAssociatedToUser!==!0&&n.chosenUserDetails().AssociatedIdentifiers.splice(t,1)}),$.each(n.unassignedCardData().data,function(t,i){i.IsAssociatedToUser===!0&&n.chosenUserDetails().AssociatedIdentifiers.push(i)}),n.submitChangedUser(n.chosenUserDetails()),!1});this.get("",function(){this.app.runRoute("get","#"+n.uiPages.home())})}).run()}ko.applyBindings(new DataVM);$(document).on("mouseenter",".datepicker-days tbody tr",function(){$(this).addClass("highlight")});$(document).on("mouseleave",".datepicker-days tbody tr",function(){$(this).removeClass("highlight")})
\ No newline at end of file