Ejemplo n.º 1
0
        private void PrepareImport()
        {
            Interpreter.Context.Scope["TestDataDir"] = TestDataRoot;

            Eps.Create();
            Dividend.Create();
            StockPrice.Create();

            var epsProvider = new DatumLocator("eps",
                                               new Site("Ariva",
                                                        new Navigation(DocumentType.Html, "${TestDataDir}/ariva.html"),
                                                        new PathSeriesFormat("Ariva.Eps")
            {
                Path               = @"/BODY[0]/DIV[5]/DIV[0]/DIV[1]/TABLE[7]/TBODY[0]/TR[6]/TD[1]",
                TimeAxisPosition   = 1,
                Expand             = CellDimension.Row,
                SeriesNamePosition = 0,
                // seriesname-contains="unverwässertes Ergebnis pro Aktie">
                ValueFormat    = new FormatColumn("value", typeof(double), Format.PriceDE),
                TimeAxisFormat = new FormatColumn("year", typeof(int), Format.Number)
            },
                                                        new DataContent("Euro")));

            Interpreter.Context.DatumProviderFactory.LocatorRepository.Add(epsProvider);

            var dividendProvider = new DatumLocator("dividend",
                                                    new Site("Sheet",
                                                             new Navigation(DocumentType.Text, @"${TestDataDir}/dividend.csv"),
                                                             new SeparatorSeriesFormat("Sheet.Dividend")
            {
                Separator          = ";",
                Anchor             = Anchor.ForRow(new StringContainsLocator(1, "${stock.isin}")),
                TimeAxisPosition   = 0,
                Expand             = CellDimension.Row,
                SeriesNamePosition = 1,
                SkipColumns        = new int[] { 0, 2, 3 },
                SkipRows           = new[] { 1 },
                ValueFormat        = new FormatColumn("value", typeof(double), Format.PriceDE),
                TimeAxisFormat     = new FormatColumn("year", typeof(int), Format.Number)
            },
                                                             new DataContent("Euro")));

            Interpreter.Context.DatumProviderFactory.LocatorRepository.Add(dividendProvider);

            var stockPriceProvider = new DatumLocator("stock_price",
                                                      new Site("TaiPan",
                                                               new Navigation(DocumentType.Text, @"${TestDataDir}/*/555200.TXT"),
                                                               new CsvFormat("TaiPan.Prices", ";",
                                                                             new FormatColumn("date", typeof(DateTime), "dd.MM.yyyy"),
                                                                             new FormatColumn("close", typeof(double), Format.PriceDE),
                                                                             new FormatColumn("volume", typeof(int), Format.PriceDE),
                                                                             new FormatColumn("high", typeof(double), Format.PriceDE),
                                                                             new FormatColumn("low", typeof(double), Format.PriceDE),
                                                                             new FormatColumn("open", typeof(double), Format.PriceDE)),
                                                               new DataContent("Euro")));

            Interpreter.Context.DatumProviderFactory.LocatorRepository.Add(stockPriceProvider);

            using (var tom = Engine.ServiceProvider.CreateEntityRepository())
            {
                var cur = new Currency("Euro", "Euro");
                tom.Currencies.AddObject(cur);
                tom.SaveChanges();
            }
        }