Esempio n. 1
0
        private void RecadastrarInstrumentosMDS()
        {
            DateTime dataHoraCadastro = DateTime.Now;

            HashSet <String> instrumentosCadastrados = gerenciadorAlertas.ObterInstrumentos();

            logger.Debug("Recadastrando instrumentos no MDS: " + instrumentosCadastrados.Count + " itens");

            foreach (String instrumento in instrumentosCadastrados)
            {
                if (!instrumentosMonitorados.Keys.Contains(instrumento))
                {
                    DadosInstrumento dadosInstrumento = new DadosInstrumento();
                    dadosInstrumento.minimo = Decimal.MaxValue;
                    dadosInstrumento.maximo = Decimal.MinValue;
                    instrumentosMonitorados.Add(instrumento, dadosInstrumento);

                    StringBuilder requisicaoAlerta = new StringBuilder();

                    requisicaoAlerta.Append("AL");
                    requisicaoAlerta.Append("  ");
                    requisicaoAlerta.Append(dataHoraCadastro.ToString(string.Format("{0}{1}", "yyyyMMddHHmmssmmm", "0")));
                    string instrumentoFormatado = String.Format("{0,-20}", instrumento);
                    requisicaoAlerta.Append(instrumentoFormatado);
                    requisicaoAlerta.Append("1");

                    logger.Info("Vai recadastrar Alerta [" + requisicaoAlerta.ToString() + "]");
                    if (mdsSocket.IsConectado())
                    {
                        logger.Info("Recadastrando Alerta [" + requisicaoAlerta.ToString() + "]");
                        mdsSocket.Send(requisicaoAlerta.ToString());
                    }
                }
            }
        }
Esempio n. 2
0
        private void RecadastrarInstrumentosMDS(SocketPackage mdsSocket)
        {
            DateTime dataHoraCadastro = DateTime.Now;

            HashSet <String> instrumentosCadastrados = gerenciadorAlertas.ObterInstrumentos();

            foreach (String instrumento in instrumentosCadastrados)
            {
                if (!instrumentosMonitorados.Keys.Contains(instrumento))
                {
                    DadosInstrumento dadosInstrumento = new DadosInstrumento();
                    dadosInstrumento.minimo = Decimal.MaxValue;
                    dadosInstrumento.maximo = Decimal.MinValue;
                    instrumentosMonitorados.Add(instrumento, dadosInstrumento);

                    StringBuilder requisicaoAlerta = new StringBuilder();

                    requisicaoAlerta.Append("AL");
                    requisicaoAlerta.Append("  ");
                    requisicaoAlerta.Append(dataHoraCadastro.ToString(string.Format("{0}{1}", "yyyyMMddHHmmssmmm", "0")));
                    string instrumentoFormatado = String.Format("{0,-20}", instrumento);
                    requisicaoAlerta.Append(instrumentoFormatado);
                    requisicaoAlerta.Append("1");

                    try
                    {
                        if (mdsSocket != null && mdsSocket.IsConectado())
                        {
                            mdsSocket.Send(requisicaoAlerta.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("RecadastrarInstrumentosMDS():" + ex.Message, ex);
                    }
                }
            }
        }