Esempio n. 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;
        }
Esempio n. 2
0
        private void OnLoad()
        {
            try
            {
                var loadDate = _sessionHolder.StartDate;

                EnqueueGenerators(_tradeGenerators, MarketDataTypes.Trades);
                EnqueueGenerators(_depthGenerators, MarketDataTypes.MarketDepth);
                EnqueueGenerators(_orderLogGenerators, MarketDataTypes.OrderLog);

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

                while (loadDate.Date <= _sessionHolder.StopDate.Date && _running)
                {
                    if (Boards.Any(b => b.IsTradeDate(loadDate, true)))
                    {
                        SessionHolder.AddInfoLog("Loading {0} Events: {1}", loadDate.Date, LoadedEventCount);

                        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 = _sessionHolder.StopDate.LocalDateTime
                });
            }
            catch (Exception ex)
            {
                SendOutError(ex);
                SendOutMessage(new LastMessage {
                    IsError = true
                });
            }

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

            _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();
        }
Esempio n. 4
0
        private async Task GetCircuitsForCurrentBoard()
        {
            try
            {
                _inCode = true;

                if (Boards != null && Boards.Any() && CurrentBoardPosition == -1)
                {
                    CurrentBoardPosition = 0;
                }

                if (Boards != null)
                {
                    SelectedBoard = Boards[CurrentBoardPosition];
                }
                var result = await _boardsService.GetTestedCircuits(CertificateId, SelectedBoard.BoardId);

                if (!result.Success)
                {
                    Dialogs.Toast(result.Message);
                    return;
                }

                var circuitTest = result.ResultObject as List <CircuitTest>;
                if (circuitTest == null)
                {
                    return;
                }

                CurrentCircuitPosition = 0;
                Circuits.Clear();

                var circuits = new List <CircuitTest>();

                if (SelectedBoard.BoardPhase == "3" || SelectedBoard.BoardPhase == "TP&N")
                {
                    var numberToSkip       = 0;
                    var numbers            = circuitTest.Select(x => x.CircuitReference).Distinct();
                    var threePhaseCircutes = new List <int>();

                    foreach (var number in numbers)
                    {
                        if (circuitTest.Any(x => x.CircuitReference == number && x.CircuitIs3Phase == "Y"))
                        {
                            threePhaseCircutes.Add(number);
                        }
                    }

                    if (!threePhaseCircutes.Any())
                    {
                        circuits.AddRange(circuitTest);
                    }
                    else
                    {
                        foreach (var circuit in circuitTest)
                        {
                            if (circuit.CircuitReference == numberToSkip)
                            {
                                continue;
                            }

                            if (threePhaseCircutes.Contains(circuit.CircuitReference))
                            {
                                if (circuit.CircuitIs3Phase == "Y")
                                {
                                    circuit.NotBelongsToThreePhase = false;
                                    circuit.ThreePhase             = circuit.CircuitReference + SelectedBoard.BoardCircuitPhaseNaming;
                                    circuits.Add(circuit);
                                    numberToSkip = circuit.CircuitReference;
                                }
                                continue;
                            }
                            circuit.NotBelongsToThreePhase = true;
                            circuits.Add(circuit);
                        }
                    }
                }
                else
                {
                    circuits.AddRange(circuitTest);
                }

                Circuits = new ObservableCollectionFast <CircuitTest>(circuits.OrderBy(x => x.ThreePhaseRepresentation));

                //Circuits.AddRange(new List<CircuitTest>(circuitTest.OrderBy(x => x.CircuitIdentity)));

                GetPointsForCurrentCircuit();

                _inCode = false;
            }
            catch (ServiceAuthenticationException e)
            {
                var result = await TryToLogin();

                if (!result)
                {
                    await NavigationService.NavigateToAsync <LoginViewModel>();
                }
                else
                {
                    await GetCircuitsForCurrentBoard();
                }
            }
            catch (Exception e)
            {
                //await ShowErrorAlert(e.Message);
            }
        }
Esempio n. 5
0
        private async Task GetBoards()
        {
            try
            {
                using (var dlg = this.Dialogs.Loading("Progress (No Cancel)"))
                {
                    Boards.Clear();

                    var testedBoardsResult = await _boardsService.GetTestedBoards(CertificateId);

                    if (!testedBoardsResult.Success)
                    {
                        Dialogs.Toast(testedBoardsResult.Message);
                        return;
                    }

                    var relatedBoards = testedBoardsResult.ResultObject as List <BoardTest>;

                    if (relatedBoards != null)
                    {
                        TestedBoards = relatedBoards;

                        var downloadedBoardsResult = await _boardsService.GetAllDownloadedBoards(BuildingId);

                        if (!downloadedBoardsResult.Success)
                        {
                            Dialogs.Toast(downloadedBoardsResult.Message);
                            return;
                        }

                        var boards = downloadedBoardsResult.ResultObject as List <Board>;

                        if (boards != null && boards.Any())
                        {
                            foreach (var board in boards)
                            {
                                var selectableBoard = new BoardDetailsSelect {
                                    Board = board, IsSelected = false
                                };

                                if (relatedBoards.Any(x => x.BoardId == board.BoardId))
                                {
                                    selectableBoard.IsSelected = true;
                                }
                                Boards.Add(selectableBoard);
                            }

                            foreach (var board in relatedBoards)
                            {
                                if (Boards.Any(x => x.Board.BoardId == board.BoardId))
                                {
                                    continue;
                                }

                                var testedBoard     = AutoMapper.Mapper.Map <Board>(board);
                                var selectableBoard = new BoardDetailsSelect {
                                    Board = testedBoard, IsSelected = true
                                };
                                Boards.Add(selectableBoard);
                            }
                        }
                    }
                }
            }
            catch (ServiceAuthenticationException e)
            {
                var result = await TryToLogin();

                if (!result)
                {
                    await NavigationService.NavigateToAsync <LoginViewModel>();
                }
                else
                {
                    await GetBoards();
                }
            }
            catch (Exception e)
            {
                await ShowErrorAlert(e.Message);
            }
        }