Пример #1
0
        protected void _sendMDSLoginMSG(MDSPackageSocket mdsSocket)
        {
            string msg = "QLPP";

            try
            {
                if (ConfigurationManager.AppSettings["EfetuarLogonMDS"] == null)
                {
                    logger.Warn("Chave 'EfetuarLogonMDS' nao declarada no appsettings. Nao efetua login");
                    return;
                }

                if (!ConfigurationManager.AppSettings["EfetuarLogonMDS"].ToString().Equals("true"))
                {
                    logger.Warn("Nao efetua login no MDS, EfetuarLogonMDS=false.");
                    return;
                }

                msg += DateTime.Now.ToString("yyyyMMddHHmmssfff");
                msg += System.Environment.MachineName.PadRight(20);

                logger.Info("Efetuando login no MDS [" + msg + "]");

                if (mdsSocket != null && mdsSocket.IsConectado())
                {
                    mdsSocket.SendData(msg, true);
                }

                logger.Info("Mensagem de login enviada ao MDS");
            }
            catch (Exception ex)
            {
                logger.Info("_sendMDSLoginMSG():" + ex.Message, ex);
            }
        }
Пример #2
0
        public virtual void IniciarServico()
        {
            //composicaoIndice = new ComposicaoIndice();
            indiceGradual = new IndiceGradual();
            lIndiceGradualQuantidadeTeorica = new IndiceGradualQuantidadeTeorica();

            // Verifica se deve ser ativado o tratamento de delay da cotação
            MemoriaCotacaoDelay.GetInstance().DelayTickerOn = false;
            if (ConfigurationManager.AppSettings["DelayTicker"] != null &&
                ConfigurationManager.AppSettings["DelayTicker"].ToString().ToUpper().Equals("TRUE"))
            {
                MemoriaCotacaoDelay.GetInstance().DelayTickerOn = true;

                // Obtem o valor do Delay do sinal de cotação, em minutos
                MemoriaCotacaoDelay.GetInstance().DelayTickerAmount = 15 * 60 * 1000;
                if (ConfigurationManager.AppSettings["DelayTickerAmount"] != null)
                {
                    int delayAmount = Convert.ToInt32(ConfigurationManager.AppSettings["DelayTickerAmount"].ToString());
                    MemoriaCotacaoDelay.GetInstance().DelayTickerAmount = delayAmount * 60 * 1000;
                }

                MemoriaCotacaoDelay.GetInstance().StartProcessamento();
            }

            if (ConfigurationManager.AppSettings["FiltraIndiceCheio"] != null &&
                ConfigurationManager.AppSettings["FiltraIndiceCheio"].ToString().ToUpper().Equals("TRUE"))
            {
                _filtraIndiceCheio = true;
            }

            QueueManager.Instance.Start();
            //QueueManager.Instance.ComposicaoIndice = composicaoIndice;
            QueueManager.Instance.IndiceGradual = indiceGradual;

            logger.Info("MDS modelo tradicional");
            lSocket = new MDSPackageSocket();
            lSocket.FiltraIndiceCheio = _filtraIndiceCheio;
            lSocket.IpAddr            = ConfigurationManager.AppSettings["ASConnMDSIp"].ToString();
            lSocket.Port = ConfigurationManager.AppSettings["ASConnMDSPort"].ToString();
            //lSocket.setComposicaoIndice(composicaoIndice);
            lSocket.setIndiceGradual(indiceGradual);

            lSocket.OpenConnection();

            _sendMDSLoginMSG(lSocket);

            thrMonitorConexao = new Thread(new ThreadStart(MonitorConexaoMDS));
            thrMonitorConexao.Start();

            gTimer = new Timer(new TimerCallback(IniciarThread), null, 0, 5000);


            // Obtem o parametro de maxima diferenca de horario da ultima mensagem com a bolsa
            // para envio de alertas
            MaxDifHorarioBolsa = 75;
            if (ConfigurationManager.AppSettings["MaxDifHorarioBolsa"] != null)
            {
                MaxDifHorarioBolsa = Convert.ToDouble(ConfigurationManager.AppSettings["MaxDifHorarioBolsa"].ToString());
            }
            MaxDifHorarioBolsa *= 1000;

            // 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;

            logger.Info("Servico cotacao iniciado");

            this.Status = ServicoStatus.EmExecucao;
        }
Пример #3
0
        public override void IniciarServico()
        {
            logger.Info("Iniciando servico Cotacao com UMDF");

            //composicaoIndice = new ComposicaoIndice();

            _umdfconfig = Gradual.OMS.Library.GerenciadorConfig.ReceberConfig <UMDFConfig>();

            // Verifica se deve ser ativado o tratamento de delay da cotação
            MemoriaCotacaoDelay.GetInstance().DelayTickerOn = false;
            if (ConfigurationManager.AppSettings["DelayTicker"] != null &&
                ConfigurationManager.AppSettings["DelayTicker"].ToString().ToUpper().Equals("TRUE"))
            {
                MemoriaCotacaoDelay.GetInstance().DelayTickerOn = true;

                // Obtem o valor do Delay do sinal de cotação, em minutos
                MemoriaCotacaoDelay.GetInstance().DelayTickerAmount = 15 * 60 * 1000;
                if (ConfigurationManager.AppSettings["DelayTickerAmount"] != null)
                {
                    int delayAmount = Convert.ToInt32(ConfigurationManager.AppSettings["DelayTickerAmount"].ToString());
                    MemoriaCotacaoDelay.GetInstance().DelayTickerAmount = delayAmount * 60 * 1000;
                }

                MemoriaCotacaoDelay.GetInstance().StartProcessamento();
            }

            if (ConfigurationManager.AppSettings["FiltraIndiceCheio"] != null &&
                ConfigurationManager.AppSettings["FiltraIndiceCheio"].ToString().ToUpper().Equals("TRUE"))
            {
                _filtraIndiceCheio = true;
            }

            if (_umdfconfig == null)
            {
                logger.Fatal("Erro ao carregar configuracoes do UMDF");

                return;
            }

            umdfSockets = new MDSPackageSocket[_umdfconfig.Portas.Count];
            int i = 0;

            foreach (string host in _umdfconfig.Portas)
            {
                string[] hostporta = host.Split(':');
                umdfSockets[i] = new MDSPackageSocket();
                umdfSockets[i].FiltraIndiceCheio = _filtraIndiceCheio;
                umdfSockets[i].IpAddr            = hostporta[0];
                umdfSockets[i].Port = hostporta[1];
                //umdfSockets[i].setComposicaoIndice(composicaoIndice);
                umdfSockets[i].OpenConnection();

                _sendMDSLoginMSG(umdfSockets[i]);

                i++;
            }


            thrMonitorConexao = new Thread(new ThreadStart(MonitorConexaoMDS));
            thrMonitorConexao.Start();

            gTimer = new Timer(new TimerCallback(IniciarThread), null, 0, 5000);


            // Obtem o parametro de maxima diferenca de horario da ultima mensagem com a bolsa
            // para envio de alertas
            MaxDifHorarioBolsa = 75;
            if (ConfigurationManager.AppSettings["MaxDifHorarioBolsa"] != null)
            {
                MaxDifHorarioBolsa = Convert.ToDouble(ConfigurationManager.AppSettings["MaxDifHorarioBolsa"].ToString());
            }
            MaxDifHorarioBolsa *= 1000;

            // 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;

            logger.Info("Servico cotacao iniciado");

            this.Status = ServicoStatus.EmExecucao;
        }