Пример #1
0
        private void LoadStatements(StatementLoadMessage msg)
        {
            CapitalServiceClient client = new CapitalServiceClient();
            try
            {
                IsBusy = true;

                client.GetStatementsCompleted += (s, e) =>
                    {
                        IsBusy = false;
                        if (e.Error == null)
                        {
                            // Remove Paid Statements
                            Messenger.Default.Send(new StatementLoadRecentMessage { Statements = e.Result.Where(x => x.IsPaid == true) });
                            PrimaryStatements = new ObservableCollection<Statement>(e.Result.Where(x => x.IsPaid == false));
                            StatementFilterRefresh(SelectedFilter);
                        }
                        else if (e.Error is FaultException<CapitalError>)
                        {
                            ErrorMessages.FaultError(e.Error.Message);
                        }
                        else
                        {
                            ErrorMessages.UnexpectedError();
                        }
                        IsBusy = false;
                    };
                client.GetStatementsAsync(GetUser());
            }
            catch
            {
                client.Abort();
            }
            finally
            {
                client.CloseAsync();
            }
        }