/// <summary> /// Delete an instrument and all locally stored data. /// </summary> public static void RemoveInstrument(Instrument instrument, IDataStorage localStorage) { using (var entityContext = new MyDBContext()) { //hacking around the circular reference issue if (instrument.IsContinuousFuture) { entityContext.Instruments.Attach(instrument); var tmpCF = instrument.ContinuousFuture; instrument.ContinuousFuture = null; instrument.ContinuousFutureID = null; entityContext.SaveChanges(); entityContext.ContinuousFutures.Attach(tmpCF); entityContext.ContinuousFutures.Remove(tmpCF); entityContext.SaveChanges(); } entityContext.Instruments.Attach(instrument); entityContext.Instruments.Remove(instrument); entityContext.SaveChanges(); } localStorage.Connect(); localStorage.DeleteAllInstrumentData(instrument); }
/// <summary> /// Delete an instrument and all locally stored data. /// </summary> public async Task RemoveInstrument(Instrument instrument, IDataStorage localStorage) { Context.Instruments.Attach(instrument); Context.Instruments.Remove(instrument); await Context.DbContext.SaveChangesAsync().ConfigureAwait(false); localStorage.Connect(); localStorage.DeleteAllInstrumentData(instrument); }
/// <summary> /// Loops through data sources and tries to connect to those that are disconnected /// </summary> private void TryConnect() { if (!_dataStorage.Connected) { _dataStorage.Connect(); } foreach (KeyValuePair <string, IHistoricalDataSource> s in DataSources) { if (!s.Value.Connected) { Log(LogLevel.Info, string.Format("Historical Data Broker: Trying to connect to data source {0}", s.Key)); s.Value.Connect(); } } }
/// <summary> /// Loops through data sources and tries to connect to those that are disconnected /// </summary> private void TryConnect() { if (!dataStorage.Connected) { lock (localStorageLock) { dataStorage.Connect(); } } foreach (KeyValuePair <string, IHistoricalDataSource> s in DataSources) { if (!s.Value.Connected) { Log(LogLevel.Info, $"Historical Data Broker: Trying to connect to data source {s.Key}"); s.Value.Connect(); } } }
/// <summary> /// Delete an instrument and all locally stored data. /// </summary> public async Task RemoveInstrument(Instrument instrument, IDataStorage localStorage) { //hacking around the circular reference issue if (instrument.IsContinuousFuture) { Context.Instruments.Attach(instrument); var tmpCF = instrument.ContinuousFuture; instrument.ContinuousFuture = null; instrument.ContinuousFutureID = null; await Context.SaveChangesAsync().ConfigureAwait(false); Context.ContinuousFutures.Attach(tmpCF); Context.ContinuousFutures.Remove(tmpCF); await Context.SaveChangesAsync().ConfigureAwait(false); } Context.Instruments.Attach(instrument); Context.Instruments.Remove(instrument); await Context.SaveChangesAsync().ConfigureAwait(false); localStorage.Connect(); localStorage.DeleteAllInstrumentData(instrument); }