Exemplo n.º 1
0
        private void GenerateReport()
        {
            BusyViewModel.ActiveAsync("... Generating ...")
            .Then(() => Items.ClearAsync(), Scheduler.Dispatcher.TPL)
            .Then(() => Service.GenerateAsync(Service.CreateRequest(ParameterViewModel)), Scheduler.Task.TPL)
            .Do(response => _response = response, Scheduler.Task.TPL)
            .Then(response => Service.GenerateDataViewModelsAsync(response), Scheduler.Task.TPL)
            .Do(dataViewModels =>
            {
                foreach (var dataViewModel in dataViewModels)
                {
                    Items.Add(dataViewModel);

                    var supportActivationState = dataViewModel as ISupportActivationState;
                    if (supportActivationState != null)
                    {
                        this.SyncViewModelActivationStates(supportActivationState).AddDisposable(Disposables);
                    }
                }
            }, Scheduler.Dispatcher.TPL)
            .LogException(Log)
            .CatchAndHandle(x => StandardDialog.Error("Error", "Problem Generating Report"), Scheduler.Task.TPL)
            .Finally(() =>
            {
                BusyViewModel.InActive();

                IsExpanded = false;

                _exportToExcel.RaiseCanExecuteChanged();
            }, Scheduler.Task.TPL);
        }
Exemplo n.º 2
0
 protected override Task OnInitialise()
 {
     return(BusyViewModel.ActiveAsync("... Loading quotes ...")
            .Then(() => RefreshQuotesAsync(), Scheduler.Task.TPL)
            .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem loading quotes"), Scheduler.Task.TPL)
            .Finally(BusyViewModel.InActive, Scheduler.Task.TPL));
 }
Exemplo n.º 3
0
 protected override Task OnInitialise()
 {
     return(BusyViewModel.ActiveAsync("... Loading ...")
            .Then(() => Service.ConfigureParameterViewModelAsync(ParameterViewModel), Scheduler.Task.TPL)
            .LogException(Log)
            .CatchAndHandle(x => StandardDialog.Error("Error", "Problem initialising parameters"), Scheduler.Task.TPL)
            .Finally(BusyViewModel.InActive, Scheduler.Task.TPL));
 }
Exemplo n.º 4
0
 private object NewQuote()
 {
     return(_service.NewQuoteAsync()
            .Then(() => BusyViewModel.ActiveAsync("... Refreshing quotes ..."), Scheduler.Dispatcher.TPL)
            .Then(() => RefreshQuotesAsync(), Scheduler.Task.TPL)
            .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem refreshing quotes"), Scheduler.Task.TPL)
            .Finally(BusyViewModel.InActive, Scheduler.Task.TPL));
 }
Exemplo n.º 5
0
 protected override Task OnInitialise()
 {
     return(BusyViewModel.ActiveAsync("... Loading available dates ...")
            .Then(() => _service.GetAvailableDatesAsync(), Scheduler.Task.TPL)
            .Do(x => SelectedDate = x.First(), Scheduler.Dispatcher.TPL)
            .Then(x => Dates.AddRangeAsync(x), Scheduler.Dispatcher.TPL)
            .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem available dates"), Scheduler.Task.TPL)
            .Finally(BusyViewModel.InActive, Scheduler.Task.TPL));
 }
Exemplo n.º 6
0
        public static ContentDialog GetContentDialog(DialogEnum dialogType, object dialogContent = default)
        {
            ContentDialog dialog;

            switch (dialogType)
            {
            case DialogEnum.EditNoteDialog:
                dialog = new EditNoteContentDialog
                {
                    Height      = Window.Current.Bounds.Height,
                    Width       = Window.Current.Bounds.Width,
                    DataContext = (UpdateNote)dialogContent
                };
                break;

            case DialogEnum.DeleteNoteDialog:
                dialog = new DeleteNoteContentDialog
                {
                    DataContext = dialogContent
                };
                break;

            case DialogEnum.DeleteAccountDialog:
                dialog = new DeleteAccountContentDialog
                {
                    DataContext = dialogContent
                };
                break;

            case DialogEnum.DeleteFavoriteDialog:
                dialog = new DeleteFavoriteContentDialog
                {
                    DataContext = dialogContent
                };
                break;

            case DialogEnum.ConnectNetworkDialog:
                dialog = new ConnectNetworkDialog();
                break;

            case DialogEnum.CreateUserDialog:
                dialog = new CreateUserDialog
                {
                    Height      = Window.Current.Bounds.Height,
                    Width       = Window.Current.Bounds.Width,
                    DataContext = (CreateAccount)dialogContent
                };
                break;

            default:
                var content = (string)dialogContent;
                dialog = new StandardDialog(content);
                break;
            }

            return(dialog);
        }
Exemplo n.º 7
0
 protected override Task OnInitialise()
 {
     return(BusyViewModel.ActiveAsync("... Loading Attributes ...")
            .Then(() => _service.GetAttributesAsync(), Scheduler.Task.TPL)
            .Do(response => Available.AddRangeAsync(response.Dimensions.Select(CreateDimension)), Scheduler.Dispatcher.TPL)
            .Do(response => Available.AddRangeAsync(response.Measures.Select(CreateMeasure)), Scheduler.Dispatcher.TPL)
            .LogException(Log)
            .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem initialising attributes"), Scheduler.Task.TPL)
            .Finally(BusyViewModel.InActive, Scheduler.Task.TPL));
 }
Exemplo n.º 8
0
 private void GetData()
 {
     BusyViewModel.ActiveAsync(string.Format("... Loading {0} ...", _ticker))
     .Then(() => Items.ClearAsync(), Scheduler.Dispatcher.TPL)
     .Then(() => _service.GetDataAsync(_ticker, DateTime.Now.AddMonths(-1), DateTime.Now), Scheduler.Task.TPL)
     .Then(data => Items.AddRangeAsync(data), Scheduler.Dispatcher.TPL)
     .LogException(Log)
     .CatchAndHandle(x => StandardDialog.Error("Error", "Problem getting chart data"), Scheduler.Task.TPL)
     .Finally(BusyViewModel.InActive, Scheduler.Task.TPL);
 }
Exemplo n.º 9
0
 private void NewQuote()
 {
     BusyViewModel.ActiveAsync("... Loading Quote ...")
     .Then(() => _service.GetInitialisationDataAsync(), Scheduler.Task.TPL)
     .Then(response => Instruments.AddRangeAsync(response.Instruments), Scheduler.Dispatcher.TPL)
     .Then(() => _service.NewQuoteAsync(), Scheduler.Task.TPL)
     .Do(model => Model = model, Scheduler.Task.TPL)
     .LogException(Log)
     .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem loading quote"), Scheduler.Task.TPL)
     .Finally(BusyViewModel.InActive, Scheduler.Task.TPL);
 }
Exemplo n.º 10
0
 private void Open(object sender, DataEventArgs <long> e)
 {
     BusyViewModel.ActiveAsync("... Opening Historic Report ...")
     .Then(() => Items.ClearAsync(), Scheduler.Dispatcher.TPL)
     .Then(() => Service.GenerateReportAsync(Service.CreateReportRequest(e.Value)), Scheduler.Task.TPL)
     .Then(response => Service.GenerateReportViewModelsAsync(response), Scheduler.Task.TPL)
     .Then(dataViewModels => Items.AddRangeAsync(dataViewModels), Scheduler.Dispatcher.TPL)
     .LogException(Log)
     .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem loading historic report"), Scheduler.Task.TPL)
     .Finally(BusyViewModel.InActive, Scheduler.Task.TPL);
 }
Exemplo n.º 11
0
 private void Save()
 {
     BusyViewModel.ActiveAsync("... Saving Quote ...")
     .Then(() => _service.SaveQuoteAsync(Model), Scheduler.Task.TPL)
     .LogException(Log)
     .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem saving quote"), Scheduler.Task.TPL)
     .Finally(() =>
     {
         BusyViewModel.InActive();
         ClosingStrategy.Close();
     }, Scheduler.Task.TPL);
 }
Exemplo n.º 12
0
        private void ExportToExcel()
        {
            BusyViewModel.ActiveAsync("... Exporting to Excel ...")
            .Do(() => Service.ExportToExcel(_response), Scheduler.Task.TPL)
            .LogException(Log)
            .CatchAndHandle(x => StandardDialog.Error("Error", "Problem Exporting to Excel"), Scheduler.Task.TPL)
            .Finally(() =>
            {
                BusyViewModel.InActive();

                IsExpanded = false;
            }, Scheduler.Task.TPL);
        }
Exemplo n.º 13
0
        protected override Task OnInitialise()
        {
            return(BusyViewModel.ActiveAsync("... Loading ...")
                   .Then(() => Items.ClearAsync(), Scheduler.Dispatcher.TPL)
                   .Then(() => _historyViewModel.Items.ClearAsync(), Scheduler.Dispatcher.TPL)
                   .Then(() => Service.GetHistoryAsync(Service.CreateHistoryRequest()), Scheduler.Task.TPL)
                   .Then(response => Service.GenerateHistoryItemViewModelsAsync(response), Scheduler.Task.TPL)
                   .Do(dataViewModels =>
            {
                _historyViewModel.Items.AddRange(dataViewModels);

                Items.Add(_historyViewModel);
                _historyViewModel.ActivationStateViewModel.Activate();
            }, Scheduler.Dispatcher.TPL)
                   .LogException(Log)
                   .CatchAndHandle(_ => StandardDialog.Error("Error", "Problem loading History"), Scheduler.Task.TPL)
                   .Finally(BusyViewModel.InActive, Scheduler.Task.TPL));
        }