internal void LoadFromFile(string fileName) { string content = null; using (StreamReader streamReader = new StreamReader(fileName)) { content = streamReader.ReadToEnd(); } string[] lines = content.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { try { string[] items = line.Split(new char[] { ',' }, StringSplitOptions.None); if (items.Length == 7) // originQuotation { DateTime timestamp = DateTime.Parse(items[1]); Guid instrumentId = new Guid(items[0]); string ask = items[2]; string bid = items[3]; string high = items[4]; string low = items[5]; iExchange.Common.OriginQuotation originQuotation = new iExchange.Common.OriginQuotation() { InstrumentID = instrumentId, Timestamp = timestamp, Ask = ask, Bid = bid, High = high, Low = low, Volume = items[6] }; this._OriginQuotations.Add(originQuotation); } else if (items.Length == 10) // OverridedQuotation { Guid instrumentId = new Guid(items[0]); Guid quotePolicyId = new Guid(items[1]); DateTime timestamp = DateTime.Parse(items[2]); string origin = items[3]; string ask = items[4]; string bid = items[5]; string high = items[6]; string low = items[7]; Guid dealerId = new Guid(items[8]); iExchange.Common.OverridedQuotation overridedQuotation = new iExchange.Common.OverridedQuotation() { InstrumentID = instrumentId, QuotePolicyID = quotePolicyId, Timestamp = timestamp, Origin = origin, Ask = ask, Bid = bid, High = high, Low = low, DealerID = new Guid(items[8]), Volume = items[9] }; this._OverridedQuotations.Add(overridedQuotation); } } catch (Exception exception) { Manager.Common.Logger.TraceEvent(TraceEventType.Warning, "MemoryBatch.LoadFromFile\r\nline:\r\n[{0}] \r\nexception\r\n{1}", line, exception); } } this._FileNames.Add(fileName); }
public iExchange.Common.OverridedQuotation ToLightVersion() { iExchange.Common.OverridedQuotation lightOverridedQ = new iExchange.Common.OverridedQuotation(); lightOverridedQ.QuotePolicyID = this.quotePolicy.ID; lightOverridedQ.InstrumentID = this.instrument.ID; lightOverridedQ.Timestamp = this.timestamp; lightOverridedQ.Ask = (string)this.ask; lightOverridedQ.Bid = (string)this.bid; lightOverridedQ.High = (this.high == null) ? string.Empty : (string)this.high; lightOverridedQ.Low = (this.low == null) ? string.Empty : (string)this.low; lightOverridedQ.Volume = this.volume; lightOverridedQ.TotalVolume = this.totalVolume; lightOverridedQ.Origin = (this.origin == null) ? string.Empty : this.origin.ToString(); lightOverridedQ.DealerID = this.dealerID; return lightOverridedQ; }