private void Update_Click(object sender, RoutedEventArgs e)
        {
            Button updateButton = sender as Button;

            updateButton.IsEnabled = false;

            // Create an update toast
            var toast = new UI.Components.Toast.Toast(UI.Components.Toast.Style.Info, new ErrorHandling.UserFacingMessage("update-update-started"), priority: UI.Components.Toast.Priority.Important);

            Manager.ToastManager.Show(toast);
            ErrorHandling.ErrorHandler.WriteToLog(Manager.TranslationService.GetString("update-update-started"), ErrorHandling.LogLevel.Info);

            var updateTask = Task.Run(async() =>
            {
                var success = await Update.Update.Run(ProductConstants.GetNumericVersion());
                if (!success)
                {
                    ErrorHandling.ErrorHandler.Handle(new ErrorHandling.UserFacingMessage("update-update-failed"), ErrorHandling.UserFacingErrorType.Toast, ErrorHandling.UserFacingSeverity.ShowError, ErrorHandling.LogLevel.Error);
                }

                Application.Current.Dispatcher.Invoke(() =>
                {
                    updateButton.IsEnabled = true;
                });
            });
        }
Example #2
0
        async Task FetchItems()
        {
            if (IsLoading)
            {
                return;
            }

            IsLoading = true;

            var items = await StoreManager.SaleOrderStore.GetOrderItemsByCustomer(Customer.ExternalId);

            List <QuotationsModel> Quotations = new List <QuotationsModel>();

            foreach (var item in items)
            {
                Quotations.Add(new QuotationsModel(item));
            }

            foreach (var item in Quotations)
            {
                item.BackColor = Quotations.IndexOf(item) % 2 == 0 ? Color.FromRgb(247, 247, 247) : Color.White;
            }

            all_items = new ObservableCollection <QuotationsModel>(Quotations);

            QuotationsItemSource = all_items;

            SearchQuery.Execute(null);

            ProductConstants.GenerateProductList();

            IsLoading = false;
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiRequest"/> class.
 /// </summary>
 /// <param name="token">Access token to API.</param>
 /// <param name="url">API endpoint.</param>
 /// <param name="method">HTTP method.</param>
 public ApiRequest(string token, string url, RestSharp.Method method = RestSharp.Method.GET)
 {
     client           = new RestClient(ProductConstants.FxAUrl);
     client.UserAgent = ProductConstants.GetUserAgent();
     request          = new RestRequest(url, method);
     request.AddParameter("Authorization", "Bearer " + token, ParameterType.HttpHeader);
     request.RequestFormat = DataFormat.Json;
 }
Example #4
0
        protected async override void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);

            var Has_Permission = await Helpers.Permissions.CheckPermissionLocation();

            await ProductConstants.GenerateProductList();
        }
Example #5
0
        public override void Init(object initData)
        {
            base.Init(initData);

            if (initData != null)
            {
                customer = (Partner)initData;
            }

            ObservableCollection <TTab> pages = new ObservableCollection <TTab>();

            pages.Add(new TTab(this)
            {
                Name = AppResources.ContactDetails, View = typeof(Pages.ContactDetailTabPage)
            });


            if (!CanEdit)
            {
                ProductConstants.GenerateProductList();

                //pages.Add(new TTab(this) { Name = AppResources.Reminder, View = typeof(ContentView) });
                pages.Add(new TTab(this)
                {
                    Name = AppResources.Map, View = typeof(Pages.MapTabPage)
                });
                pages.Add(new TTab(this)
                {
                    Name = AppResources.Quotations, View = typeof(Pages.QuotationsTabPage)
                });
                pages.Add(new TTab(this)
                {
                    Name = AppResources.Orders, View = typeof(Pages.OrderListTabPage)
                });
                pages.Add(new TTab(this)
                {
                    Name = AppResources.Contracts, View = typeof(Pages.ContractListTabPage)
                });
            }

            var selector = new ViewPagerTemplateSelector();

            foreach (var item in pages)
            {
                selector.PageTemplates.Add(new DataTemplate(item.View));
            }

            Tab           = pages;
            ItemTemplates = selector;
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApiRequest"/> class.
        /// </summary>
        /// <param name="token">Access token to API.</param>
        /// <param name="url">API endpoint.</param>
        /// <param name="method">HTTP method.</param>
        /// <param name="caching">Indicates whether caching is enabled for requests.</param>
        public ApiRequest(string token, string url, RestSharp.Method method = RestSharp.Method.GET, bool caching = true)
        {
            client  = new RestClient(ProductConstants.FxAUrl);
            request = new RestRequest(url, method);

            client.UserAgent = ProductConstants.GetUserAgent();

            if (!caching)
            {
                client.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Revalidate);
                request.AddHeader("Connection", "close");
            }

            request.AddParameter("Authorization", "Bearer " + token, ParameterType.HttpHeader);
            request.RequestFormat = DataFormat.Json;
        }
Example #7
0
        public App()
        {
            InitializeComponent();

            ProductConstants.Init();

            PclStorage.Init();

            BasePageModel.Init();

            storeManager = DependencyService.Get <IStoreManager>() as StoreManager;

            Init();

            MainPage = new ContentPage();
        }
Example #8
0
        private void Update_Click(object sender, RoutedEventArgs e)
        {
            Button updateButton = sender as Button;

            updateButton.IsEnabled = false;

            // Create an update toast
            var toast = new UI.Components.Toast.Toast(UI.Components.Toast.Style.Info, new ErrorHandling.UserFacingMessage("update-update-started"), priority: UI.Components.Toast.Priority.Important);

            Manager.ToastManager.Show(toast);
            ErrorHandling.ErrorHandler.WriteToLog(Manager.TranslationService.GetString("update-update-started"), ErrorHandling.LogLevel.Info);

            var updateTask = Task.Run(async() =>
            {
                var updateResult = await Update.Update.Run(ProductConstants.GetNumericVersion());

                switch (updateResult)
                {
                case Update.Update.UpdateResult.DisconnectTimeout:
                case Update.Update.UpdateResult.GeneralFailure:
                case Update.Update.UpdateResult.HttpError:
                case Update.Update.UpdateResult.InvalidSignature:
                case Update.Update.UpdateResult.SuccessNoUpdate:
                case Update.Update.UpdateResult.RunFailure:
                    ErrorHandling.ErrorHandler.Handle(new ErrorHandling.UserFacingMessage("update-update-failed"), ErrorHandling.UserFacingErrorType.Toast, ErrorHandling.UserFacingSeverity.ShowError, ErrorHandling.LogLevel.Error);
                    break;

                case Update.Update.UpdateResult.Georestricted:
                    ErrorHandling.ErrorHandler.Handle(new ErrorHandling.UserFacingMessage("update-update-failed-georestricted"), ErrorHandling.UserFacingErrorType.Toast, ErrorHandling.UserFacingSeverity.ShowError, ErrorHandling.LogLevel.Error);
                    break;
                }

                Application.Current.Dispatcher.Invoke(() =>
                {
                    updateButton.IsEnabled = true;
                });
            });
        }
        private async void UpdateVersionAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                JSONStructures.BalrogResponse balrogResponse;

                try
                {
                    balrogResponse = await Update.Balrog.QueryUpdate(ProductConstants.GetNumericVersion());
                }
                catch (Exception e)
                {
                    if (e is HttpRequestException)
                    {
                        cancellationToken.WaitHandle.WaitOne(TimeSpan.FromMinutes(5));
                        continue;
                    }
                    else
                    {
                        ErrorHandling.ErrorHandler.Handle(e, ErrorHandling.LogLevel.Error);
                        throw e;
                    }
                }

                if (balrogResponse != null)
                {
                    if (balrogResponse.Required)
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            var owner = Application.Current.MainWindow;
                            if (owner != null)
                            {
                                ((UI.MainWindow)owner).NavigateToView(new UI.UpdateView(), UI.MainWindow.SlideDirection.Right);
                                Manager.MustUpdate = true;
                            }
                        });
                    }
                    else
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (Manager.MainWindowViewModel.UpdateToast == null)
                            {
                                // Create an update toast
                                var message = new ErrorHandling.UserFacingMessage(
                                    "toast-update-version-message-1",
                                    new ErrorHandling.UserFacingMessage[] { new ErrorHandling.UserFacingMessage("toast-update-version-message-2", new List <Type>()
                                    {
                                        typeof(Underline), typeof(Bold)
                                    }) }
                                    );

                                var toast = new UI.Components.Toast.Toast(UI.Components.Toast.Style.Info, message, display: UI.Components.Toast.Display.Persistent, priority: UI.Components.Toast.Priority.Important)
                                {
                                    ClickEventHandler = (sender, e) =>
                                    {
                                        // Create an update toast
                                        var updateToast = new UI.Components.Toast.Toast(UI.Components.Toast.Style.Info, new ErrorHandling.UserFacingMessage("update-update-started"), priority: UI.Components.Toast.Priority.Important);
                                        Manager.ToastManager.Show(updateToast);
                                        ErrorHandling.ErrorHandler.WriteToLog(Manager.TranslationService.GetString("update-update-started"), ErrorHandling.LogLevel.Info);

                                        var updateTask = Task.Run(async() =>
                                        {
                                            var success = await Update.Update.Run(ProductConstants.GetNumericVersion());
                                            if (success)
                                            {
                                                // Dismiss the update toast
                                                Application.Current.Dispatcher.Invoke(() =>
                                                {
                                                    Manager.MainWindowViewModel.UpdateToast.Toast_Dismiss(null, null);
                                                });
                                            }
                                            else
                                            {
                                                ErrorHandling.ErrorHandler.Handle(new ErrorHandling.UserFacingMessage("update-update-failed"), ErrorHandling.UserFacingErrorType.Toast, ErrorHandling.UserFacingSeverity.ShowError, ErrorHandling.LogLevel.Error);
                                            }
                                        });
                                    },
                                };

                                Manager.MainWindowViewModel.UpdateToast = toast;
                            }

                            var owner = Application.Current.MainWindow;
                            if (owner != null)
                            {
                                // Show the update toast
                                Manager.ToastManager.Show(Manager.MainWindowViewModel.UpdateToast);
                            }
                        });
                    }
                }

                cancellationToken.WaitHandle.WaitOne(TimeSpan.FromHours(6));
            }
        }