public static void UpdatePricesToImportMinute() { AlsiDBDataContext dc = new AlsiDBDataContext(); dc.ClearImportTable(); dc.Clean_OHLC_Temp(); DataTable MinData = new DataTable("MinData"); MinData.Columns.Add("Stamp", typeof(DateTime)); MinData.Columns.Add("O", typeof(int)); MinData.Columns.Add("L", typeof(int)); MinData.Columns.Add("H", typeof(int)); MinData.Columns.Add("C", typeof(int)); MinData.Columns.Add("V", typeof(int)); MinData.Columns.Add("Instrument", typeof(string)); foreach (var p in GlobalObjects.Points) { MinData.Rows.Add(p.TimeStamp, p.Open, p.High, p.Low, p.Close, p.Volume, p.InstrumentName); } #region BulkCopy DataSet minuteDataSet = new DataSet("minuteDataset"); minuteDataSet.Tables.Add(MinData); SqlConnection myConnection = new SqlConnection(AlsiUtils.Data_Objects.GlobalObjects.CustomConnectionString); myConnection.Open(); SqlBulkCopy bulkcopy = new SqlBulkCopy(myConnection); bulkcopy.DestinationTableName = "ImportMinute"; bulkcopy.WriteToServer(MinData); Debug.WriteLine("Tick Bulk Copy Complete"); MinData.Dispose(); myConnection.Close(); #endregion dc.UpadteImport(); dc.CleanUp(); }
public static void UpdatetoMinuteImport() { AlsiDBDataContext dc = new AlsiDBDataContext(); dc.Connection.ConnectionString = GlobalObjects.CustomConnectionString; dc.ClearImportTable(); decimal progress = 0; decimal totProgress = GlobalObjects.Points.Count; foreach (Price price in GlobalObjects.Points) { int open = (int)price.Open; int high = (int)price.High; int low = (int)price.Low; int close = (int)price.Close; int volume = (int)price.Volume; ImportMinute c = new ImportMinute { Stamp = price.TimeStamp, O = open, H = high, L = low, C = close, V = volume, Instrument = price.InstrumentName }; dc.ImportMinutes.InsertOnSubmit(c); dc.SubmitChanges(); progress++; int p = Convert.ToInt16(100 * (progress / totProgress)); } GlobalObjects.Points.Clear(); dc.UpadteImport(); dc.CleanUp(); }