Пример #1
0
        protected override void DoExecute()
        {
            var doc = new CurrenciesSheet(IsoCurrenciesUrl);

            if (doc.TryLoadFromWebSite())
            {
                ScrappedCurrenciesCollection scrappedCurrencies = doc.SelectCurrencies();
                Currency[] allCurrencies = Currency.FindAll().ToArray();
                showImplementedOnly(scrappedCurrencies, allCurrencies);
                showScrappedOnly(scrappedCurrencies, allCurrencies);
                showDiscrepancies(scrappedCurrencies, allCurrencies.ToDictionary(c => c.NumericCode));
            }
        }
Пример #2
0
        public ScrappedCurrenciesCollection SelectCurrencies()
        {
            var currencies = new ScrappedCurrenciesCollection();

            if (_currenciesWereLoaded)
            {
                IExcelDataReader dr = null;
                try
                {
                    dr = ExcelReaderFactory.CreateBinaryReader(File.OpenRead(_cachedFile));
                    var ds = dr.AsDataSet();

                    currencies.Add(
                        ds.Tables[0].AsEnumerable()
                        .Skip(3)                         // first 3 rows do not contain any info
                        .Select(r =>
                    {
                        string code = r[2].ToString(), numericCode = r[3].ToString(), name = r[1].ToString(), decimals = r[4].ToString();
                        return(ScrappedCurrency.IsCode(code) && ScrappedCurrency.IsNumericCode(numericCode) ?
                               new ScrappedCurrency(code, numericCode, name, decimals) :
                               null);
                    })
                        .ToArray());
                }

                finally
                {
                    if (dr != null)
                    {
                        dr.Close();
                        dr.Dispose();
                    }
                }
            }
            return(currencies);
        }