Beispiel #1
0
        private void btnVerificar_Click(object sender, EventArgs e)
        {
            if (txtIdClienteVerificar.Text.Length == 0)
            {
                return;
            }

            btnVerificar.Enabled = false;
            lstboxVerificar.Items.Clear();
            lstboxVerificar.Refresh();

            VerificarAlertasRequest request = new VerificarAlertasRequest();

            request.IdCliente = txtIdClienteVerificar.Text;

            IServicoAlertas servicoAlerta = Ativador.Get <IServicoAlertas>();

            VerificarAlertasResponse response = servicoAlerta.VerificarAlertas(request);

            if (response.StatusResposta == Gradual.OMS.Library.MensagemResponseStatusEnum.OK)
            {
                if (response.Alertas.Count == 0)
                {
                    lstboxVerificar.Items.Add("Não há alertas cadastrados para o Cliente [" + request.IdCliente + "]");
                    lstboxVerificar.Refresh();
                }
                else
                {
                    foreach (AlertaInfo alerta in response.Alertas)
                    {
                        StringBuilder info = new StringBuilder();
                        info.Append("IdAlerta=[" + alerta.IdAlerta + "]");
                        info.Append(" Instrumento=[" + alerta.Instrumento + "]");
                        info.Append(" TipoOperador=[" + alerta.TipoOperador + "]");
                        info.Append(" TipoOperando=[" + alerta.TipoOperando + "]");
                        info.Append(" Valor=[" + alerta.Valor + "]");
                        info.Append(" DataCadastro=[" + alerta.DataCadastro + "]");
                        info.Append(" Atingido=[" + (alerta.Atingido ? "Sim" : "Não") + "]");
                        info.Append(" Exibido=[" + (alerta.Exibido ? "Sim" : "Não") + "]");
                        info.Append(" Cotação=[" + alerta.Cotacao + "]");

                        lstboxVerificar.Items.Add(info.ToString());
                    }
                }

                btnVerificar.Enabled = true;
            }
        }
        public Alertas.Lib.Mensagens.VerificarAlertasResponse VerificarAlertas(Alertas.Lib.Mensagens.VerificarAlertasRequest request)
        {
            VerificarAlertasResponse response = new VerificarAlertasResponse();

            if (ConfigurationManager.AppSettings["DebugVerificacaoAlertas"] != null &&
                ConfigurationManager.AppSettings["DebugVerificacaoAlertas"].ToString().Equals("true"))
            {
                logger.Debug("VerificarAlertas: IdCliente=[" + request.IdCliente + "]");
            }

            List <AlertaInfo> listaAlertasResponse = new List <AlertaInfo>();

            Dictionary <String, DadosAlerta> listaAlertas =
                gerenciadorAlertas.VerificarAlertas(request.IdCliente);

            foreach (KeyValuePair <string, DadosAlerta> kvAlerta in listaAlertas)
            {
                if (kvAlerta.Value.IdCliente.Equals(request.IdCliente) &&
                    kvAlerta.Value.Atingido == true &&
                    kvAlerta.Value.Exibido == false)
                {
                    AlertaInfo respAlertaInfo = new AlertaInfo();
                    respAlertaInfo.IdAlerta        = kvAlerta.Key;
                    respAlertaInfo.IdCliente       = kvAlerta.Value.IdCliente;
                    respAlertaInfo.Instrumento     = kvAlerta.Value.Instrumento;
                    respAlertaInfo.TipoOperador    = kvAlerta.Value.TipoOperador;
                    respAlertaInfo.TipoOperando    = kvAlerta.Value.TipoOperando;
                    respAlertaInfo.Valor           = kvAlerta.Value.Valor;
                    respAlertaInfo.Atingido        = kvAlerta.Value.Atingido;
                    respAlertaInfo.Exibido         = kvAlerta.Value.Exibido;
                    respAlertaInfo.DataCadastro    = kvAlerta.Value.DataCadastro;
                    respAlertaInfo.DataAtingimento = kvAlerta.Value.DataAtingimento;
                    respAlertaInfo.Cotacao         = kvAlerta.Value.Cotacao;

                    listaAlertasResponse.Add(respAlertaInfo);
                }
            }

            if (ConfigurationManager.AppSettings["DebugVerificacaoAlertas"] != null &&
                ConfigurationManager.AppSettings["DebugVerificacaoAlertas"].ToString().Equals("true"))
            {
                logger.Debug("VerificarAlertas: IdCliente=[" + request.IdCliente + "] " + listaAlertasResponse.Count + " disparados");
            }

            response.Alertas = listaAlertasResponse;

            return(response);
        }
Beispiel #3
0
        public Lib.Mensagens.VerificarAlertasResponse VerificarAlertas(
            Lib.Mensagens.VerificarAlertasRequest request)
        {
            logger.Debug("VerificarAlertas iniciado");

            VerificarAlertasResponse response = new VerificarAlertasResponse();

            List <AlertaInfo> listaAlertasResponse = new List <AlertaInfo>();

            Dictionary <String, DadosAlerta> listaAlertas =
                gerenciadorAlertas.VerificarAlertas(request.IdCliente);

            foreach (KeyValuePair <string, DadosAlerta> kvAlerta in listaAlertas)
            {
                if (kvAlerta.Value.IdCliente.Equals(request.IdCliente) &&
                    kvAlerta.Value.Atingido == true &&
                    kvAlerta.Value.Exibido == false)
                {
                    AlertaInfo respAlertaInfo = new AlertaInfo();
                    respAlertaInfo.IdAlerta        = kvAlerta.Key;
                    respAlertaInfo.IdCliente       = kvAlerta.Value.IdCliente;
                    respAlertaInfo.Instrumento     = kvAlerta.Value.Instrumento;
                    respAlertaInfo.TipoOperador    = kvAlerta.Value.TipoOperador;
                    respAlertaInfo.TipoOperando    = kvAlerta.Value.TipoOperando;
                    respAlertaInfo.Valor           = kvAlerta.Value.Valor;
                    respAlertaInfo.Atingido        = kvAlerta.Value.Atingido;
                    respAlertaInfo.Exibido         = kvAlerta.Value.Exibido;
                    respAlertaInfo.DataCadastro    = kvAlerta.Value.DataCadastro;
                    respAlertaInfo.DataAtingimento = kvAlerta.Value.DataAtingimento;
                    respAlertaInfo.Cotacao         = kvAlerta.Value.Cotacao;

                    listaAlertasResponse.Add(respAlertaInfo);
                }
            }

            response.Alertas = listaAlertasResponse;

            return(response);
        }