Ejemplo n.º 1
0
        public void Fetch(DataProviderRequest request, ICollection <IFigure> resultContainer)
        {
            var previewViewModel = new ImportPreviewModel(myStorageService, myLutService.CurrenciesLut)
            {
                Stock                 = request.Stock,
                From                  = request.From,
                To                    = request.To,
                Series                = resultContainer,
                ThrowOnError          = request.ThrowOnError,
                CustomResolverCreator = CustomResolverCreator
            };

            if (request.WithPreview)
            {
                if (myCurrencyCache.Isin == request.Stock.Isin)
                {
                    // take over last setting from user
                    previewViewModel.Currency = myCurrencyCache.Currency;
                }

                var preview = new ImportPreview(previewViewModel);

                previewViewModel.FinishAction = () =>
                {
                    preview.Close();

                    // remember last setting from user
                    if (previewViewModel.Currency != null)
                    {
                        myCurrencyCache.Isin     = previewViewModel.Stock.Isin;
                        myCurrencyCache.Currency = previewViewModel.Currency;
                    }
                };
                preview.DataContext = previewViewModel;

                previewViewModel.Fetch(request.FigureType);

                preview.Top  = 0;
                preview.Left = 0;
                preview.Show();
            }
            else
            {
                previewViewModel.Browser = new SafeWebBrowser();
                previewViewModel.Fetch(request.FigureType);
                previewViewModel.PublishData();
            }
        }