示例#1
0
        public IDataProvider GetData(string Code)
        {
            DataRow dr = DB.GetFirstRow("select * from StockData where QuoteCode=? or AliasCode=?",
                                        new DbParam[] {
                new DbParam("@QuoteCode", DbType.String, Code),
                new DbParam("@AliasCode", DbType.String, Code),
            });

            CSVDataProvider cdpn = new CSVDataProvider(this);

            if (dr != null)
            {
                byte[] bs = Utils.LoadHisDataFromFile(Code);
                if (DownloadRealTimeQuote)
                {
                    try
                    {
                        DataPackage dp = DataPackage.DownloadFromYahoo(Code);
                        bs = CSVDataProvider.MergeOneQuote(bs, dp);
                    }
                    catch
                    {
                    }
                }

                cdpn.LoadBinary(bs);
                cdpn.SetStringData("Code", Code);
                cdpn.SetStringData("Name", dr["QuoteName"].ToString());
                cdpn.SetStringData("Exchange", dr["Exchange"].ToString());
                return(cdpn);
            }
            throw new Exception("No Data Found");
        }
示例#2
0
        private void btnDownload_Click(object sender, System.EventArgs e)
        {
            DataTable dt  = DB.GetDataTable("select QuoteCode,QuoteName from StockData order by QuoteCode");
            string    URL = "http://table.finance.yahoo.com/table.csv?s={0}&d=8&e=13&f=2004&g=d&a=6&b=30&c=1980&ignore=.csv";
            WebClient wc  = new WebClient();

            DbParam[] dps = new DbParam[] {
                new DbParam("@HistoryData", DbType.Binary, null),
                new DbParam("@QuoteCode", DbType.String, null),
            };
            int i = 0;

            foreach (DataRow dr in dt.Rows)
            {
                string          QuoteCode = dr["QuoteCode"].ToString();
                string          s         = string.Format(URL, QuoteCode);
                byte[]          bs        = wc.DownloadData(s);
                CSVDataProvider cdpn      = new CSVDataProvider(null, bs);
                bs           = cdpn.SaveBinary();
                dps[0].Value = bs;
                dps[1].Value = QuoteCode;
                DB.DoCommand("update StockData set HistoryData=? where QuoteCode=?", dps);
                if (i++ > 40)
                {
                    break;
                }
            }
        }
示例#3
0
        public void StoreExtent(IUriExtent extent, ExtentStorageConfiguration configuration)
        {
            var csvConfiguration = (CSVStorageConfiguration) configuration;

            var provider = new CSVDataProvider(_workspaceCollection, _dataLayerLogic);
            provider.Save(extent, csvConfiguration.Path, csvConfiguration.Settings);
        }
示例#4
0
        public IUriExtent LoadExtent(ExtentStorageConfiguration configuration, bool createAlsoEmpty)
        {
            var csvConfiguration = (CSVStorageConfiguration) configuration;
            var provider = new CSVDataProvider(_workspaceCollection, _dataLayerLogic);
            var mofExtent = new MofUriExtent(csvConfiguration.ExtentUri);
            var factory = new MofFactory();

            var doesFileExist = File.Exists(csvConfiguration.Path);
            if (doesFileExist)
            {
                provider.Load(mofExtent, factory, csvConfiguration.Path, csvConfiguration.Settings);
            }
            else if (!createAlsoEmpty)
            {
                throw new InvalidOperationException(
                    $"File does not exist and empty extents is not given in argument {nameof(createAlsoEmpty)}");
            }

            return mofExtent;
        }
示例#5
0
 private void MainWindow_Load(object sender, EventArgs e)
 {
     webService   = new Sensor.Service.WebServiceClient();
     dataProvider = new CSVDataProvider(PathToCSV);
 }
示例#6
0
 public void Init()
 {
     _dataProvider = new CSVDataProvider();
 }