Example #1
0
        private async void SetLoginPolicy()
        {
            LoadingService.ShowLoadingStatus(true);
            var startTime = DateTime.Now;

            _log.Info("SetLoginPolicy method call started");
            try
            {
                CacheBusinessLogic.IpAddress = GetLocalIp();
                var loginPolicy = await _loginBussinessLogic.GetLoginPolicyAsync();

                var registerNumber = await new Helper().GetRegisterNumber();
                CacheBusinessLogic.RegisterNumber = (byte)registerNumber;
                NavigateService.Instance.NavigateToLogin();
            }
            catch (InternalServerException ex)
            {
                ShowNotification(ex.Error.Message, ShutDownApplication, ShutDownApplication, ApplicationConstants.ButtonWarningColor);
            }
            catch (ApiDataException ex)
            {
                _log.Warn(ex);
                ShowNotification(ex.Error.Message, ShutDownApplication, ShutDownApplication
                                 , ApplicationConstants.ButtonWarningColor);
            }
            catch (NullReferenceException ex)
            {
                _log.Warn(ex);

                ShowNotification(ApplicationConstants.ApiNotConnected, ShutDownApplication, ShutDownApplication,
                                 ApplicationConstants.ButtonWarningColor);
            }
            catch (ArgumentException ex)
            {
                _log.Warn(ex);

                ShowNotification(ApplicationConstants.LanguageNotSupported, ShutDownApplication, ShutDownApplication,
                                 ApplicationConstants.ButtonWarningColor);
            }
            catch (Exception ex)
            {
                _log.Warn(ex);
                ShowNotification(ApplicationConstants.SomethingBadHappned, ShutDownApplication, ShutDownApplication,
                                 ApplicationConstants.ButtonWarningColor);
            }
            finally
            {
                LoadingService.ShowLoadingStatus(false);
                var endTime = DateTime.Now;
                _log.Info(string.Format("Time Taken In Login Page is {0}ms", (endTime - startTime).TotalMilliseconds));
            }
        }
Example #2
0
        private async void LoadBottlePages()
        {
            LoadingService.ShowLoadingStatus(true);
            var bottlePages = await _stockBusinessLogic.GetHotProductPages();

            Bottles = new ObservableCollection <BottleModel>(
                from b in bottlePages
                select new BottleModel
            {
                PageId   = b.PageId,
                PageName = b.PageName
            });

            foreach (var bottle in Bottles)
            {
                bottle.BottleDetails = await LoadBottles(bottle.PageId);
            }
            LoadingService.ShowLoadingStatus(false);
        }
Example #3
0
        /// <summary>
        /// Method to get all suspended sale
        /// </summary>
        /// <returns></returns>
        private async void LoadAllSuspendSale()
        {
            try
            {
                LoadingService.ShowLoadingStatus(true);
                var response = await _saleBussinessLogic.GetAllSuspendSales();

                var suspendedSales = new ObservableCollection <SuspendSaleModel>();
                foreach (var sale in response)
                {
                    suspendedSales.Add(new SuspendSaleModel
                    {
                        Customer   = sale.Customer,
                        SaleNumber = sale.SaleNumber,
                        Till       = sale.Till
                    });
                }
                SuspendedSales = new ObservableCollection <SuspendSaleModel>(suspendedSales);
            }
            catch (UserNotAuthorizedException ex)
            {
                Log.Warn(ex);
                NavigateService.Instance.NavigateToLogin();
            }
            catch (InternalServerException ex)
            {
                Log.Error(ex);
                ShowNotification(ex.Error.Message, NavigateService.Instance.NavigateToHome,
                                 NavigateService.Instance.NavigateToHome, ApplicationConstants.ButtonWarningColor);
            }
            catch (ApiDataException ex)
            {
                Log.Warn(ex);
                ShowNotification(ex.Error.Message, NavigateService.Instance.NavigateToHome,
                                 NavigateService.Instance.NavigateToHome, ApplicationConstants.ButtonWarningColor);
            }
            finally
            {
                LoadingService.ShowLoadingStatus(false);
            }
        }
        private async void LoadHotCategories(LoadHotCategoriesMessage message)
        {
            LoadingService.ShowLoadingStatus(true);
            try
            {
                var hotProductPages = await _stockBussinessLogic.GetHotProductPages();

                var categories = new ObservableCollection <HotProductModel>(
                    from h in hotProductPages
                    select new HotProductModel
                {
                    PageId   = h.PageId,
                    PageName = h.PageName
                });

                HotCategories = new ObservableCollection <HotProductModel>(categories);

                // Load for First Category
                if (HotCategories.Count > 0)
                {
                    LoadHotProducts(HotCategories.FirstOrDefault().PageId);
                }
            }
            catch (UserNotAuthorizedException)
            {
                NavigateService.Instance.NavigateToLogin();
            }
            finally
            {
                OperationsCompletedInLogin++;
                if (IsSwitchUserStarted)
                {
                    OperationsCompletedInSwitchUser++;
                }
                LoadingService.ShowLoadingStatus(false);
            }
        }
Example #5
0
        private async Task GetShiftsAsync()
        {
            var startTime = DateTime.Now;

            _log.Info("GetShiftsAsync method call started");
            try
            {
                LoadingService.ShowLoadingStatus(true);
                var shifts = await _loginBussinessLogic.GetShiftsAsync();

                PopulateShifts(shifts);

                if (shifts.ForceShift)
                {
                    LoginUser();
                    return;
                }
                if (CacheBusinessLogic.UseShiftForTheDay)
                {
                    ShowConfirmationMessage(ApplicationConstants.ShiftUsedForTheDay, null, ShutDownApplication, ShutDownApplication);
                }
            }
            catch (UserAlreadyLoggedOnException ex)
            {
                ShowNotification(ex.Error.Message, ResetLogin, ResetLogin, ApplicationConstants.ButtonWarningColor);
            }
            catch (InternalServerException ex)
            {
                ShowNotification(ex.Error.Message, ShutDownApplication, ShutDownApplication, ApplicationConstants.ButtonWarningColor);
            }
            catch (ApiDataException ex)
            {
                ShowNotification(
                    ex.Error.Message,
                    () =>
                {
                    if (ex.Error.ShutDownPos)
                    {
                        ShutDownApplication();
                    }
                    else
                    {
                        ResetUIElements();
                    }
                },
                    () =>
                {
                    if (ex.Error.ShutDownPos)
                    {
                        ShutDownApplication();
                    }
                    else
                    {
                        ResetUIElements();
                    }
                },
                    ApplicationConstants.ButtonWarningColor);
            }
            catch (Exception ex)
            {
                Log.Info(Message, ex);
                ShowNotification(ApplicationConstants.SomethingBadHappned,
                                 null,
                                 null,
                                 ApplicationConstants.ButtonWarningColor);
            }
            finally
            {
                LoadingService.ShowLoadingStatus(false);
            }
            var endTime = DateTime.Now;

            _log.Info(string.Format("GetShiftsAsync method call ended in {0}ms",
                                    (endTime - startTime).TotalMilliseconds));
        }
Example #6
0
 /// <summary>
 /// Generic Method for Load data to/from API depending on function passed as parameter
 /// </summary>
 /// <param name="func"></param>
 protected async void PerformAction(func <Task> func, string elementNameToSetFocus = "")
 {
     LoadingService.ShowLoadingStatus(true);
     try
     {
         if (func != null)
         {
             await func?.Invoke();
         }
     }
     catch (UserNotAuthorizedException ex)
     {
         Log.Warn(ex);
         NavigateService.Instance.NavigateToLogin();
     }
     catch (InternalServerException ex)
     {
         if (!string.IsNullOrEmpty(ex.Error?.Message))
         {
             Log.Warn(ex);
             ShowNotification(ex.Error.Message,
                              () => { SetFocusOnControl(elementNameToSetFocus); },
                              () => { SetFocusOnControl(elementNameToSetFocus); },
                              ApplicationConstants.ButtonWarningColor);
         }
     }
     catch (ApiDataException ex)
     {
         if (!string.IsNullOrEmpty(ex.Error?.Message))
         {
             Log.Warn(ex);
             ShowNotification(ex.Error.Message,
                              () => { SetFocusOnControl(elementNameToSetFocus); },
                              () => { SetFocusOnControl(elementNameToSetFocus); },
                              ApplicationConstants.ButtonWarningColor);
         }
     }
     catch (TaskCanceledException ex)
     {
         Log.Warn(ex);
         ShowNotification(ApplicationConstants.ApiTimeoutMessage,
                          () => { SetFocusOnControl(elementNameToSetFocus); },
                          () => { SetFocusOnControl(elementNameToSetFocus); },
                          ApplicationConstants.ButtonWarningColor);
     }
     catch (PrinterLayerException ex)
     {
         Log.Warn(ex);
         ShowNotification(ApplicationConstants.NoPrinterFound,
                          () => { SetFocusOnControl(elementNameToSetFocus); },
                          () => { SetFocusOnControl(elementNameToSetFocus); },
                          ApplicationConstants.ButtonWarningColor);
     }
     catch (Exception ex)
     {
         Log.Info(Message, ex);
         ShowNotification(ApplicationConstants.SomethingBadHappned,
                          () => { SetFocusOnControl(elementNameToSetFocus); },
                          () => { SetFocusOnControl(elementNameToSetFocus); },
                          ApplicationConstants.ButtonWarningColor);
     }
     finally
     {
         LoadingService.ShowLoadingStatus(false);
         SetFocusOnControl(elementNameToSetFocus);
     }
 }