protected override void OnInitialize()
        {
            base.OnInitialize();

            var loadingTask = Task.Run(async delegate
            {
                try
                {
                    var productsLoadTask = ProductServiceModel.GetProducts(new ProductQuery
                    {
                        Type           = _partConnector.Type,
                        RevisionFilter = RevisionFilter.All
                    });

                    TaskNotifier = new TaskNotifier(productsLoadTask);

                    var products   = await productsLoadTask;
                    var productVms = products.Select(pm => new ProductInfoViewModel(pm)).OrderBy(p => p.FullIdentifier);

                    await Execute.OnUIThreadAsync(delegate
                    {
                        AvailableProducts = productVms.ToArray();
                        NotifyOfPropertyChange(nameof(AvailableProducts));
                    });
                }
                catch (Exception e)
                {
                    await Execute.OnUIThreadAsync(() => ErrorMessage = e.Message);
                }
            });

            TaskNotifier = new TaskNotifier(loadingTask);
        }
Beispiel #2
0
        private async Task UpdateTreeAsync()
        {
            try
            {
                var customization = await ProductServiceModel.GetCustomization(true);

                var productTypes = customization.ProductTypes;

                var products = await ProductServiceModel.GetProducts(Query.GetQuery());

                Merge(productTypes, products);
            }
            catch (Exception e)
            {
                ProductGroups.Clear();
                ShowEmpty();
            }
        }
        protected override void OnInitialize()
        {
            base.OnInitialize();

            var loaderTask = Task.Run(async delegate
            {
                var parents = await ProductServiceModel.GetProducts(new ProductQuery
                {
                    Identifier     = Product.Identifier,
                    Revision       = Product.Revision,
                    RevisionFilter = RevisionFilter.Specific,
                    Selector       = Selector.Parent
                }).ConfigureAwait(false);

                Parents = parents.Select(p => new ProductInfoViewModel(p)).ToArray();
                await Execute.OnUIThreadAsync(() => NotifyOfPropertyChange(nameof(Parents)));
            });

            TaskNotifier = new TaskNotifier(loaderTask);
        }