Example #1
0
        private void btnListar_Click(object sender, EventArgs e)
        {
            if (txtIdClienteListar.Text.Length == 0)
            {
                return;
            }

            btnListar.Enabled = false;
            lstboxAlertas.Items.Clear();
            lstboxAlertas.Refresh();

            ListarAlertasRequest request = new ListarAlertasRequest();

            request.IdCliente = txtIdClienteListar.Text;

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

            ListarAlertasResponse response = servicoAlerta.ListarAlertas(request);

            if (response.StatusResposta == Gradual.OMS.Library.MensagemResponseStatusEnum.OK)
            {
                if (response.Alertas.Count == 0)
                {
                    lstboxAlertas.Items.Add("Não há alertas cadastrados para o Cliente [" + request.IdCliente + "]");
                    lstboxAlertas.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") + "]");

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

                btnListar.Enabled = true;
            }
        }
Example #2
0
        public Alertas.Lib.Mensagens.ListarAlertasResponse ListarAlertas(Alertas.Lib.Mensagens.ListarAlertasRequest request)
        {
            logger.Debug("ListarAlertas: IdCliente=[" + request.IdCliente + "]");

            ListarAlertasResponse response = new ListarAlertasResponse();

            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))
                {
                    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;

                    listaAlertasResponse.Add(respAlertaInfo);
                }
            }

            logger.Debug("ListarAlertas: IdCliente=[" + request.IdCliente + "] com " + listaAlertas.Count + " itens");

            response.Alertas = listaAlertasResponse;

            response.StatusResposta = Library.MensagemResponseStatusEnum.OK;

            return(response);
        }