예제 #1
0
        private void OnLoad()
        {
            try
            {
                var loadDate = StartDate;

                var messageTypes = new[] { MessageTypes.Time, ExtendedMessageTypes.Clearing };

                while (loadDate.Date <= StopDate.Date && !_disconnecting)
                {
                    if (Boards.Any(b => b.IsTradeDate(loadDate, true)))
                    {
                        this.AddInfoLog("Loading {0} Events: {1}", loadDate.Date, LoadedMessageCount);

                        var enumerator = BasketStorage.Load(loadDate.Date);

                        // хранилище за указанную дату содержит только время и клиринг
                        var noData = !enumerator.DataTypes.Except(messageTypes).Any();

                        if (noData)
                        {
                            SendOutMessages(loadDate, GetSimpleTimeLine(loadDate).GetEnumerator());
                        }
                        else
                        {
                            SendOutMessages(loadDate, enumerator);
                        }
                    }

                    loadDate = loadDate.Date.AddDays(1);
                }

                SendOutMessage(new LastMessage {
                    LocalTime = StopDate.LocalDateTime
                });
            }
            catch (Exception ex)
            {
                SendOutError(ex);
                SendOutMessage(new LastMessage {
                    IsError = true
                });
            }

            if (_disconnecting)
            {
                SendOutMessage(new DisconnectMessage());
            }

            _disconnecting = false;

            if (_loadingThread == null)
            {
                SendOutMessage(new ResetMessage());
            }

            _loadingThread = null;
        }
        private void OnLoad()
        {
            try
            {
                var loadDate = StartDate;

                var messageTypes = new[] { MessageTypes.Time, ExtendedMessageTypes.Clearing };

                BasketStorage.InnerStorages.Add(new InMemoryMarketDataStorage <TimeMessage>(null, null, GetTimeLine));

                while (loadDate.Date <= StopDate.Date && !_disconnecting)
                {
                    if (Boards.Any(b => b.IsTradeDate(loadDate, true)))
                    {
                        this.AddInfoLog("Loading {0} Events: {1}", loadDate.Date, LoadedMessageCount);

                        using (var enumerator = BasketStorage.Load(loadDate.UtcDateTime.Date))
                        {
                            // storage for the specified date contains only time messages and clearing events
                            var noData = !enumerator.DataTypes.Except(messageTypes).Any();

                            if (noData)
                            {
                                SendOutMessages(loadDate, GetSimpleTimeLine(loadDate).GetEnumerator());
                            }
                            else
                            {
                                SendOutMessages(loadDate, enumerator);
                            }
                        }
                    }

                    loadDate = loadDate.Date.AddDays(1).ApplyTimeZone(loadDate.Offset);
                }

                SendOutMessage(new LastMessage {
                    LocalTime = StopDate.LocalDateTime
                });
            }
            catch (Exception ex)
            {
                SendOutError(ex);
                SendOutMessage(new LastMessage {
                    IsError = true
                });
            }

            if (_disconnecting)
            {
                SendOutMessage(new DisconnectMessage());
            }

            _disconnecting = false;

            if (_loadingThread == null)
            {
                SendOutMessage(new ResetMessage());
            }

            _loadingThread = null;
            BasketStorage.InnerStorages.Clear();
        }