private void HandleScanProgress(object progress)
        {
            switch (progress)
            {
            case GenericProgress genericProgress:
                switch (genericProgress.ProgressEvent)
                {
                case GenericProgress.Event.SCAN_CREATING_INDEXES:
                    ScanLogs.Add(Localization.CreatingIndexes);
                    break;
                }
                break;

            case ScanProgress scanProgress:
                if (scanProgress.Error)
                {
                    ScanLogs.Add($"{scanProgress.RelativeFilePath} — {Localization.Error}.");
                }
                else if (scanProgress.Found)
                {
                    FoundItems.Add(new ScanResultItemViewModel(LibgenObjectType.NON_FICTION_BOOK, 0, null, scanProgress.RelativeFilePath,
                                                               scanProgress.Authors, scanProgress.Title));
                }
                else
                {
                    NotFoundItems.Add(scanProgress.RelativeFilePath);
                }
                UpdateResultTabHeaders();
                break;

            case ScanCompleteProgress scanCompleteProgress:
                ScanLogs.Add(Localization.GetScanCompleteString(scanCompleteProgress.Found, scanCompleteProgress.NotFound, scanCompleteProgress.Errors));
                break;
            }
        }
        private void HandleScanProgress <T>(object progress) where T : LibgenObject
        {
            switch (progress)
            {
            case GenericProgress genericProgress:
                switch (genericProgress.ProgressEvent)
                {
                case GenericProgress.Event.SCAN_CREATING_INDEXES:
                    ScanLogs.Add(Localization.CreatingIndexes);
                    break;
                }
                break;

            case ScanProgress <T> scanProgress:
                switch (scanProgress.LibgenObject)
                {
                case NonFictionBook nonFictionBook:
                    FoundItems.Add(new NonFictionScanResultItemViewModel(scanProgress.RelativeFilePath, nonFictionBook));
                    break;

                case FictionBook fictionBook:
                    FoundItems.Add(new FictionScanResultItemViewModel(scanProgress.RelativeFilePath, fictionBook));
                    break;

                case SciMagArticle sciMagArticle:
                    FoundItems.Add(new SciMagScanResultItemViewModel(scanProgress.RelativeFilePath, sciMagArticle));
                    break;
                }
                UpdateResultTabHeaders();
                break;

            case ScanUnknownProgress scanUnknownProgress:
                if (scanUnknownProgress.Error)
                {
                    var error = new ScanResultErrorItemViewModel(scanUnknownProgress.RelativeFilePath, scanUnknownProgress.ErrorType);
                    ResolveErrorDescription(error);
                    Errors.Add(error);
                    UpdateResultTabHeaders();
                }
                else
                {
                    NotFoundItems.Add(scanUnknownProgress.RelativeFilePath);
                    UpdateResultTabHeaders();
                }
                break;

            case ScanCompleteProgress scanCompleteProgress:
                ScanLogs.Add(Localization.GetScanCompleteString(scanCompleteProgress.Found, scanCompleteProgress.NotFound, scanCompleteProgress.Errors));
                break;
            }
        }
        private async void GetInvoices()
        {
            if (!string.IsNullOrWhiteSpace(SearchTerm))
            {
                MessageToDisplay = "Searching...";
                IsBusy           = true;
                ButtonEnabled    = false;
                IsLoading        = true;
                GetInvoicesCommand.RaiseCanExecuteChanged();
                var proxy = _serviceFactory.CreateClient <IInvoiceService>();

                using (proxy)
                {
                    var   invoices = proxy.FindInvoicesByCompanyAsync((Company)CurrentCompany, SearchTerm);
                    await invoices;
                    // FoundItems = new ObservableCollection<Invoice>(orders.Result);

                    if (invoices.Result.Count > 0)
                    {
                        foreach (var invoice in invoices.Result)
                        {
                            FoundItems.Add(Map(invoice));
                        }

                        SelectedItem      = FoundItems[0];
                        SelectedItemIndex = 0;
                    }
                }

                MessageToDisplay = FoundItems.Count.ToString() + " invoice(s) found";
                ButtonEnabled    = true;
                GetInvoicesCommand.RaiseCanExecuteChanged();
                //RaisePropertyChanged(nameof(FoundSome));
                //RaisePropertyChanged(nameof(FoundSomeNo));
            }
            else
            {
                MessageToDisplay = "You must enter a search term in order to find an invoice";
            }
            IsLoading = false;
            IsBusy    = false;
        }
示例#4
0
        private async void GetOrders()
        {
            if (!string.IsNullOrWhiteSpace(SearchTerm))
            {
                MessageToDisplay = "Searching...";
                IsBusy           = true;
                ButtonEnabled    = false;
                IsLoading        = true;
                GetOrdersCommand.RaiseCanExecuteChanged();
                var proxy = _serviceFactory.CreateClient <IOrderService>();

                using (proxy)
                {
                    var   orders = proxy.FindOrdersByCompanyAsync((Company)CurrentCompany, SearchTerm);
                    await orders;

                    if (orders.Result.Count > 0)
                    {
                        foreach (var order in orders.Result)
                        {
                            FoundItems.Add(Map(order));
                        }

                        SelectedItem      = FoundItems[0];
                        SelectedItemIndex = 0;
                    }
                }

                MessageToDisplay = FoundItems.Count.ToString() + " order(s) found";
                ButtonEnabled    = true;
                GetOrdersCommand.RaiseCanExecuteChanged();
            }
            else
            {
                MessageToDisplay = "You must enter a search term in order to find an order";
            }
            IsLoading = false;
            IsBusy    = false;
        }
        private async void GetAccounts()
        {
            if (!string.IsNullOrWhiteSpace(SearchTerm))
            {
                IsBusy    = true;
                IsLoading = true;
                var account_service = _serviceFactory.CreateClient <IAccountService>();

                using (account_service)
                {
                    try
                    {
                        var   results = account_service.FindAccountByCompanyAsync((Company)CurrentCompany, SearchTerm);
                        await results;

                        foreach (var account in results.Result)
                        {
                            FoundItems.Add(Map(account));
                        }

                        MessageToDisplay = FoundItems.Count.ToString() + " account(s) found";
                    }
                    catch (Exception ex)
                    {
                        MessageToDisplay = ex.Message;
                        return;
                    }
                }
            }
            else
            {
                MessageToDisplay = "You must enter a search term in order to find an account";
            }
            IsLoading = false;
            IsBusy    = false;
        }
示例#6
0
 public void AddItem(FoundNotepadItemViewModel doc)
 {
     FoundItems.Add(doc);
 }