Exemplo n.º 1
0
        private void MergeOneDay(string[] ss)
        {
            Hashtable       ht = new Hashtable();
            IFormatProvider fp =
                new System.Globalization.CultureInfo("en-US", true);

            for (int i = 1; i < ss.Length; i++)
            {
                string[] sss = ss[i].Split(',');
                ht.Add(sss[0], new DataPackage(
                           (float)DateTime.Parse(sss[1], fp).ToOADate(),
                           float.Parse(sss[2]),
                           float.Parse(sss[3]),
                           float.Parse(sss[4]),
                           float.Parse(sss[5]),
                           float.Parse(sss[6]),
                           float.Parse(sss[5])));
            }

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

            BaseDb UpdateDb = BaseDb.FromConfig("ConnStr");
            SQL    bd       = (SQL)DB.Open(false);

            try
            {
                SqlDataReader sdr = bd.GetDataReader("select * from StockData");

                while (sdr.Read())
                {
                    string      QuoteCode = sdr["QuoteCode"].ToString();
                    DataPackage dp        = (DataPackage)ht[QuoteCode];
                    if (dp != null)
                    {
                        object o = sdr["HistoryData"];
                        if (o == DBNull.Value)
                        {
                            o = new byte[0];
                        }
                        byte[] bs = MergeOneQuote((byte[])o, dp);
                        dps[0].Value = bs;
                        dps[1].Value = QuoteCode;
                        UpdateDb.DoCommand("update StockData set HistoryData=? where QuoteCode=?", dps);
                    }
                }
                sdr.Close();
            }
            finally
            {
                bd.Close();
            }
        }