From 71bb5b70af94ed36af417194a6d5a782bd7d659b Mon Sep 17 00:00:00 2001 From: "Chris.Watts90@outlook.com" Date: Thu, 23 Feb 2017 16:54:15 +0000 Subject: [PATCH 1/8] update ninject packages to fix 500 internal server error. removed dependency resolver configuration line, seemed to be duplicating bindings. #39 --- .../WindowsDataCenter/WindowsDataCenter/StartOwin.cs | 2 +- .../WindowsDataCenter/WindowsDataCenter.csproj | 6 +++--- .../WindowsDataCenter/WindowsDataCenter/packages.config | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/StartOwin.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/StartOwin.cs index 142e637..e9b05a2 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/StartOwin.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/StartOwin.cs @@ -20,7 +20,7 @@ namespace WindowsDataCenter config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; //ninject resolver for ApiController DI. - config.DependencyResolver = new NinjectDependencyResolver(NinjectHelper.GetInstance().Kernel); + //config.DependencyResolver = new NinjectDependencyResolver(NinjectHelper.GetInstance().Kernel); //JSONP formatter for cross-domain requests. config.Formatters.Insert(0, new JsonpFormatter()); diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj index 012fb8d..03cfb28 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj @@ -69,7 +69,7 @@ True - ..\packages\Ninject.3.2.0.0\lib\net45-full\Ninject.dll + ..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll True @@ -85,7 +85,7 @@ True - ..\packages\Ninject.Web.Common.3.2.0.0\lib\net45-full\Ninject.Web.Common.dll + ..\packages\Ninject.Web.Common.3.2.3.0\lib\net45-full\Ninject.Web.Common.dll True @@ -93,7 +93,7 @@ True - ..\packages\Ninject.Web.WebApi.3.2.0.0\lib\net45-full\Ninject.Web.WebApi.dll + ..\packages\Ninject.Web.WebApi.3.2.4.0\lib\net45-full\Ninject.Web.WebApi.dll True diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/packages.config b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/packages.config index f8a9e8b..0363aa3 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/packages.config +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/packages.config @@ -15,13 +15,13 @@ - + - + - + From caa7408465439a9819b7ed8c792f9406d39135a1 Mon Sep 17 00:00:00 2001 From: "Chris.Watts90@outlook.com" Date: Thu, 23 Feb 2017 16:55:13 +0000 Subject: [PATCH 2/8] add mapping for ManuallyPostData method (housekeeping) correct 20 minute swipe event blocker and change to 3 min. --- .../WindowsDataCenter/WindowsDataCenter/App.config | 4 ++-- .../WindowsDataCenter/Controllers/SwipeDataController.cs | 2 ++ .../WindowsDataCenter/WindowsDataServiceHost/App.config | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config index e91591d..00e1396 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config @@ -2,8 +2,8 @@ - - + + diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs index cf7fe12..d2e5d29 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs @@ -49,6 +49,8 @@ namespace WindowsDataCenter /// /// /// + [HttpPost] + [Route("manual")] public IHttpActionResult ManuallyPostData([FromBody] ManualLog log) { throw new NotImplementedException(); diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config index e152d66..b7a67d4 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config @@ -2,8 +2,8 @@ - - + + From 9fa97e2fc99420fa040fb6dfa189e75c4cedef70 Mon Sep 17 00:00:00 2001 From: "Chris.Watts90@outlook.com" Date: Thu, 23 Feb 2017 16:56:10 +0000 Subject: [PATCH 3/8] added extra logging to trace blocked swipe data events. #39 --- .../WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs | 4 +++- .../SQLiteRepository/SQLiteRepository.csproj | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs index 84da476..02bbfaf 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -351,14 +351,16 @@ namespace SQLiteRepository var logDirection = GetLogDirection(ident.UserId_FK); #region Check the user hasnt registered an event in the last few minutes.. - + //BUG: what happens if unassociated cards are swiped within the threshold? need to get all of them. var hysteresisThresholdMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["SwipeTimeGap"] ?? "3"); var threshold = DateTime.UtcNow.AddMinutes(0 - hysteresisThresholdMinutes); var logs = _connection.Query( SQLiteProcedures.GET_LOGS_IN_LAST_X_MINUTES, threshold.Ticks, ident.UserId_FK); + _logger.Trace("Checking last swipe event gap"); if (logs.Any()) { + _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; } diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj index 337b41c..9efe2f3 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj @@ -45,6 +45,7 @@ True + ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net451\System.Data.SQLite.dll From 1be64659012f19b90aefe564403c575336402638 Mon Sep 17 00:00:00 2001 From: "Chris.Watts90@outlook.com" Date: Thu, 23 Feb 2017 17:02:18 +0000 Subject: [PATCH 4/8] change port to default 8800 #40 --- .../WindowsDataCenter/CardReaderService/App.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/App.config b/DataCenter_Windows/WindowsDataCenter/CardReaderService/App.config index 6fda695..a1f8f1f 100644 --- a/DataCenter_Windows/WindowsDataCenter/CardReaderService/App.config +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/App.config @@ -5,6 +5,6 @@ - + \ No newline at end of file From 09e74af16842df638cea46fffdbefc70ae8dff8b Mon Sep 17 00:00:00 2001 From: "Chris.Watts90@outlook.com" Date: Thu, 23 Feb 2017 17:03:14 +0000 Subject: [PATCH 5/8] add dispose for reader in monitor event. to prevent memory leak. --- .../WindowsDataCenter/CardReaderService/CardReaderService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.cs index 380c99a..37a7711 100644 --- a/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.cs +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.cs @@ -142,7 +142,7 @@ namespace CardReaderService { _logger.Trace("Reader failed to connect, error: " + Enum.GetName(typeof(SCardError), err)); } - + reader.Dispose(); } } From 4025663db95d32ddc413e648ea139d308ec8dc20 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Thu, 23 Feb 2017 21:38:40 +0100 Subject: [PATCH 6/8] Change table column titles, add data-binding for Contractor boolean to show a tick on the UI #44 --- .../WindowsDataCenter/www/index.html | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html index 398f305..983b120 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html @@ -61,20 +61,18 @@ - - - - - + + + - - - + + From ded664cdd05f911c9ec6a425f59ed8dd00efef21 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Thu, 23 Feb 2017 20:54:46 +0000 Subject: [PATCH 7/8] corrected rounding issue so that UI will always show hours/mins (3:32 hrs) to two dp. #43 --- .../WindowsDataCenter/WindowsDataCenter/www/spa.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.js index 82ac54b..50911e8 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.js +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.js @@ -134,7 +134,7 @@ if (hrs < 1) { return value + " mins"; } - return (value / 60)+" hrs"; + return self.round(hrs, 2)+" hrs"; }; self.convertToDisplayTime = function (dateValue) { var date = new Date(dateValue); @@ -146,6 +146,9 @@ } return logCount; } + self.round = function (value, decimals) { + return parseFloat(Math.round(value * 100) / 100).toFixed(decimals); + } self.getTimeLogEntryArrayLength = function(maxDailyLogs) { return Math.round(maxDailyLogs/2); }; From fa38512c9ac19e4958779362a21fd807a0c2624e Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Thu, 23 Feb 2017 21:02:37 +0000 Subject: [PATCH 8/8] change code to only check the time log gap if the card is associated to a user. This will ensure that multiple new users swiping their cards will definitely be added to the system. #41 --- .../SQLiteRepository/SQLiteRepository.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs index 02bbfaf..6745187 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -351,18 +351,21 @@ namespace SQLiteRepository var logDirection = GetLogDirection(ident.UserId_FK); #region Check the user hasnt registered an event in the last few minutes.. - //BUG: what happens if unassociated cards are swiped within the threshold? need to get all of them. - var hysteresisThresholdMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["SwipeTimeGap"] ?? "3"); - var threshold = DateTime.UtcNow.AddMinutes(0 - hysteresisThresholdMinutes); - var logs = _connection.Query( - SQLiteProcedures.GET_LOGS_IN_LAST_X_MINUTES, - threshold.Ticks, ident.UserId_FK); - _logger.Trace("Checking last swipe event gap"); - if (logs.Any()) - { - _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; + + if (ident.UserId_FK!=-1) + { //only check log gap if the card is associated to a user + var hysteresisThresholdMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["SwipeTimeGap"] ?? "3"); + var threshold = DateTime.UtcNow.AddMinutes(0 - hysteresisThresholdMinutes); + var logs = _connection.Query( + SQLiteProcedures.GET_LOGS_IN_LAST_X_MINUTES, + threshold.Ticks, ident.UserId_FK); + _logger.Trace("Checking last swipe event gap"); + if (logs.Any()) + { + _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; + } } #endregion
IDUserIdfirstNamelastName + First NameLast NameContractor