Пример #1
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            IsLoading = true;

            Task.Factory.StartNew(() =>
            {
                if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["HostAddress"] != null)
                {
                    var customers = CustomerService.GetCustomers();

                    Accounts.AddRange(customers.Where(o => !o.Name.IsMatch("Cash")).OrderBy(o => o.Name).Select(o => new AccountHomeItemViewModel {
                        Customer = o
                    }));
                }
            })
            .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    ScreenCoordinator.HandleFault(task.Exception);
                }
                else
                {
                    Execute.OnUIThread(() => IsLoading = false);
                }
            });
        }
Пример #2
0
        public void CheckPin()
        {
            Working = true;

            Task.Factory
            .StartNew(() =>
            {
                var pinValid = CustomerService.CheckPin(Customer.Id, Pin);
                if (!pinValid)
                {
                    Execute.OnUIThread(() =>
                    {
                        FailureCount++;

                        lock (Pin)
                        {
                            PinState = IncorrectPinState;
                            Pin      = "";
                        }

                        Working = false;
                    });

                    // Reset text or go home if too many failures...
                    Task.Delay(1000).ContinueWith(t => Execute.OnUIThread(() =>
                    {
                        if (FailureCount < 3)
                        {
                            lock (Pin)
                            {
                                if (Pin.Length == 0)
                                {
                                    PinState = EmptyPinState;
                                }
                            }
                        }
                        else
                        {
                            if (IsActive)
                            {
                                GoHome();
                            }
                        }
                    }));
                }
                else
                {
                    Task.Factory.StartNew(() => CardService.Write(Customer));
                    Execute.OnUIThread(() => ScreenCoordinator.NavigateToCustomer(Customer));
                }
            })
            .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    ScreenCoordinator.HandleFault(task.Exception);
                }
            });
        }
Пример #3
0
        public ProcessViewModel(ScreenCoordinator screenCoordinator)
        {
            ScreenCoordinator = screenCoordinator;
            Logger            = log4net.LogManager.GetLogger(GetType());

            ProcessAction  = () => { };
            CompleteAction = () => { };
            ErrorAction    = ex => { ScreenCoordinator.HandleFault(ex); };
        }
Пример #4
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            IsLoading = true;

            var saleViewModel = IoC.Get <SaleViewModel>();

            saleViewModel.Customer = Customer;

            Items.Add(saleViewModel);

            PayViewModel  payViewModel  = null;
            LoanViewModel loanViewModel = null;

            if (!IsCashAccount)
            {
                payViewModel          = IoC.Get <PayViewModel>();
                payViewModel.Customer = Customer;

                loanViewModel          = IoC.Get <LoanViewModel>();
                loanViewModel.Customer = Customer;

                Items.Add(payViewModel);
                Items.Add(loanViewModel);
            }

            Task.Factory.StartNew(() =>
            {
                saleViewModel.Load();

                if (payViewModel != null)
                {
                    payViewModel.Load();
                }

                if (loanViewModel != null)
                {
                    loanViewModel.Load();
                }
            })
            .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    ScreenCoordinator.HandleFault(task.Exception);
                }
                else
                {
                    Execute.OnUIThread(() => IsLoading = false);
                    ActivateItem(Items.First());
                }
            });
        }
Пример #5
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            IsLoading = true;

            Task.Factory.StartNew(() =>
            {
                Items.Add("ACCOUNT");
                Items.Add("VISITOR");

                var customers = CustomerService.GetCustomers().Where(o => !o.Name.IsMatch("Cash"));

                var previousGroup = "";
                foreach (var customer in customers)
                {
                    var item = new HomeItemViewModel {
                        Customer = customer
                    };

                    if (item.Group != previousGroup)
                    {
                        item.IsFirstInGroup = true;
                        previousGroup       = item.Group;
                    }

                    Accounts.Add(item);
                }

                Visitors.AddRange(CustomerService.GetCustomers().Where(o => o.Name.IsMatch("Cash")).Select(o => new HomeItemViewModel {
                    Customer = o
                }));
            })
            .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    ScreenCoordinator.HandleFault(task.Exception);
                }
                else
                {
                    Execute.OnUIThread(() =>
                    {
                        IsLoading    = false;
                        SelectedItem = Items.First();
                    });
                }
            });
        }
Пример #6
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            IsLoading = true;

            var saleViewModel = IoC.Get <SaleViewModel>();

            saleViewModel.Customer = Customer;

            Items.Add(saleViewModel);

            PayViewModel     payViewModel     = null;
            LoanViewModel    loanViewModel    = null;
            ReceiptViewModel receiptViewModel = null;
            AccountViewModel accountViewModel = null;

            if (!IsCashAccount)
            {
                payViewModel          = IoC.Get <PayViewModel>();
                payViewModel.Customer = Customer;

                loanViewModel          = IoC.Get <LoanViewModel>();
                loanViewModel.Customer = Customer;

                receiptViewModel          = IoC.Get <ReceiptViewModel>();
                receiptViewModel.Customer = Customer;

                accountViewModel          = IoC.Get <AccountViewModel>();
                accountViewModel.Customer = Customer;

                Items.Add(payViewModel);
                Items.Add(loanViewModel);
                Items.Add(receiptViewModel);
                Items.Add(accountViewModel);
            }

            Task.Factory.StartNew(() =>
            {
                // Load images from server.
                var serverImages = ApplicationService.GetImageList();
                var cachedImages = ImageService.GetImageList();

                foreach (var image in serverImages)
                {
                    if (!cachedImages.Contains(image, StringComparer.CurrentCultureIgnoreCase))
                    {
                        ImageService.SetImage(image, ApplicationService.GetImage(image));
                    }
                }

                // Load view models.
                saleViewModel.Load();

                if (payViewModel != null)
                {
                    payViewModel.Load();
                }

                if (loanViewModel != null)
                {
                    loanViewModel.Load();
                }

                if (receiptViewModel != null)
                {
                    receiptViewModel.Load();
                }

                if (accountViewModel != null)
                {
                    accountViewModel.Load();
                }
            })
            .ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    ScreenCoordinator.HandleFault(task.Exception);
                }
                else
                {
                    Execute.OnUIThread(() => IsLoading = false);
                    ActivateItem(Items.First());
                }
            });
        }