Esempio n. 1
0
        public MonitorarCotacoesResponse MonitorarCotacoes(MonitorarCotacoesRequest request)
        {
            MonitorarCotacoesResponse response = new MonitorarCotacoesResponse();

            try
            {
                PersistenciaDB db = new PersistenciaDB();

                AlgoStruct algo = new AlgoStruct();
                if (!String.IsNullOrEmpty(request.IDAlgoritmo))
                {
                    algo.IDRegistro = request.IDAlgoritmo;
                }

                algo.IDLogin          = request.IDLogin;
                algo.Instrumento1     = request.Instrumento1;
                algo.Instrumento2     = request.Instrumento2;
                algo.Qtde1            = request.Qtde1;
                algo.Qtde2            = request.Qtde2;
                algo.SentidoAlgoritmo = request.SentidoAlgoritmo;
                algo.TipoAlgoritmo    = request.TipoAlgoritmo;

                response.IDRegistro = db.SalvarAlgoritmo(algo);

                ThreadPoolManager.Instance.AddAlgoritmo(algo);
            }
            catch (Exception ex)
            {
                logger.Error("MonitorarCotacoes(): " + ex.Message);
            }

            return(response);
        }
Esempio n. 2
0
        public void IniciarServico()
        {
            _bKeepRunning = true;
            logger.Info("Iniciando servico SpreadMonitor");

            //Obtendo configuracoes
            // Obtem o timeout de mensagem com o MDS, em segundos
            TimeoutMDS = 300;
            if (ConfigurationManager.AppSettings["TimeoutMDS"] != null)
            {
                TimeoutMDS = Convert.ToDouble(ConfigurationManager.AppSettings["TimeoutMDS"].ToString());
            }
            TimeoutMDS *= 1000;

            // Inicia o gerenciador das threads
            ThreadPoolManager.Instance.Start();

            // Carregar algos do DB
            PersistenciaDB    db    = new PersistenciaDB();
            List <AlgoStruct> algos = db.CarregarAlgoritmos();

            foreach (AlgoStruct algo in algos)
            {
                ThreadPoolManager.Instance.AddAlgoritmo(algo);
            }

            // Conectar ao MDS
            thMonitorMds = new Thread(new ThreadStart(this.MonitorConexaoMDS));
            thMonitorMds.Start();

            // Aguardar conexoes do streamer
            int streamerPort = 6565;

            if (ConfigurationManager.AppSettings["StreamerListenPort"] != null)
            {
                streamerPort = Convert.ToInt32(ConfigurationManager.AppSettings["StreamerListenPort"].ToString());
            }

            //
            _sockServer = new SocketPackage();
            _sockServer.StartListen(streamerPort);

            //_sockServer.
        }