private async void StartAction(string userId) { StandardPopup.IsOpen = false; lastMeasurement = 0.0f; string beepFileName = "beep-06.wav"; //Start Validation if (Common.KegSettings == null) { await Common.GetKegSettings(); } //User Validation await Page2Dispatcher.RunAsync(CoreDispatcherPriority.Low, async() => { if (Window.Current.Bounds.Width >= Common.AppWindowWidth) { this.Page2LimitText1.Text = $"{Common.KegSettings.MaxUserOuncesPerHour.ToString()} Oz.(Max)"; this.Page2LimitText3.Text = "0 Oz.(Min)"; } else { this.Page2LimitText3.Text = $"{Common.KegSettings.MaxUserOuncesPerHour.ToString()} Oz.(Max)"; this.Page2LimitText1.Text = "0 Oz.(Min)"; } User user = await User.GetUserByHashcode(userId); this.loggedInUser = user; Dictionary <string, string> props = new Dictionary <string, string> { { "UserID", user != null ? user.HashCode : string.Empty } }; KegLogger.KegLogEvent("User Badge Scan", "BadgeScan", props); if (null != this.loggedInUser && this.loggedInUser.Type == "KegUser") { //Check Database SqLiteHelper localDB = new SqLiteHelper(); //Check if 25 people limit reached //Check Event serve Count Int32 visited = localDB.GetVisitedPersonsCount(Common.KegSettings.MaxEventDurationMinutes); if (visited >= Common.KegSettings.MaxPersonsPerEvent) { this.Page2Part1Text.Text = Common.GetResourceText("Page2ServeLimitText"); List <string> visitors = localDB.GetVisitedPersons(Common.KegSettings.MaxEventDurationMinutes).ToList(); if (visitors.Any(v => v.Equals(this.loggedInUser.HashCode, StringComparison.InvariantCultureIgnoreCase))) { //Found in list and this particular user is allowed } else { //Not found, no new users accepted this.Page2Part1Text.Text = Common.GetResourceText("Page2ServeLimitText"); this.Page2Image.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/no-beer.png")); beepFileName = "fail-buzzer-04.wav"; Counter = Common.COUNTERSHORTWAIT; timer.Start(); //Raise event on max count reached KegLogger.KegLogEvent("Max Visitors reached!", "MaxVisitors", null); return; } } //Check total consumption totalConsumption = localDB.GetPersonConsumption(userId); if (totalConsumption >= Common.KegSettings.MaxUserOuncesPerHour) { // If Limit Reached, display required text this.Page2Part1Text.Text = Common.GetResourceText("Page2LimitSorryText"); this.Page2Part2Text.Text = Common.GetResourceText("Page2LimitReachedText"); this.Page2Image.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/no-beer.png")); beepFileName = "fail-buzzer-04.wav"; //TODO: //Start a timer to return to main screen Counter = Common.COUNTERSHORTWAIT; timer.Start(); } else { //Success: this.Page2Part1Text.Text = Common.GetResourceText("Page2SuccessValidationText"); this.Page2Part2Text.Text = Common.GetResourceText("Page2SuccessStart"); this.Page2Image.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/checkmark.png")); this.GridConsumption.Visibility = Visibility.Visible; this.Page2OuncesPanel.Visibility = Visibility.Visible; this.Page2LimitText2.Text = $"{totalConsumption.ToString()} Oz"; AllowedLimitFill(); deliverOunces = true; dispensed = new List <float>(); //Initialize if (App._flowControl != null) { //App._flowControl = new FlowControl(App.calibration); App._flowControl.FlowControlChanged += OnFlowControlChanged; // App._flowControl.Initialize(1000, 1000); App._flowControl.IsActive = true; Reset(true); } if (App._flow != null) { //App._flow = new Flow(App.calibration); App._flow.FlowChanged += OnFlowChange; //App._flow.Initialize(); //App._flow.Initialize(1000, 1000); App._flow.ResetFlow(); } //Initialize Flow measure dispensed = new List <float>(); Counter = Common.COUNTERWAIT; timer.Start(); } } else { ////Access Denied: this.Page2Part1Text.Text = Common.GetResourceText("Page2SorryText"); this.Page2Part2Text.Text = Common.GetResourceText("Page2ContactText"); this.Page2Image.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/no-beer.png")); beepFileName = "fail-buzzer-04.wav"; //TODO: //Start a timer to return to main screen Counter = Common.COUNTERSHORTWAIT; timer.Start(); //denied users KegLogger.KegLogEvent("User Denied!", "UserDenied", new Dictionary <string, string>() { { "UserID", userId } }); } PlayBeep(beepFileName); }); }