示例#1
0
        static void Main(string[] args)
        {
            inicio  ini = new inicio();
            termino fim = new termino();
            erro    err = new erro();

            //ROBO QUANDO PRECISAMOS DE ORQUESTRACAO
            Thread newThreadINI = new Thread(ini.monitorar);

            newThreadINI.Start();
            Thread newThreadFIM = new Thread(fim.monitorar);

            newThreadFIM.Start();

            Settings             configs = new Settings();
            ConfiguracoesValores erros   = configs.ResgataParametro();

            foreach (ErroParametro erro in erros.Parametros.Erro)
            {
                Thread newThreadERRO = new Thread(err.Monitorar);

                ErroParametros parametros = new ErroParametros();

                parametros.Topico                  = erro.Topico;
                parametros.EnderecoFila            = erros.Parametros.EnderecoFila;
                parametros.Descricao               = erro.Descricao;
                parametros.EndpointElasticSearchOK = erros.Parametros.EndpointElasticSearch.DoctoOK;
                parametros.PassoRetorno            = erro.PassoRetorno;
                newThreadERRO.Start(parametros); //FALTA MAPEAR
            }
        }
示例#2
0
        public void monitorar()
        {
            Console.WriteLine("TERMINO DA OPERACAO");
            Connection connection = null;

            try
            {
                Settings             configs   = new Settings();
                ConfiguracoesValores config    = configs.ResgataParametro();
                string EndpointElasticSearchOK = config.Parametros.EndpointElasticSearch.DoctoOK;
                string enderecoFila            = config.Parametros.EnderecoFila;

                Address address = new Address(enderecoFila);
                connection = new Connection(address);
                Session      session           = new Session(connection);
                string       topicoEntrada     = config.Parametros.Termino.TopicoEntrada;
                ReceiverLink receiver          = new ReceiverLink(session, NOME_FILA_CONSUMIDOR_MQ, topicoEntrada);
                ElasticSearch.ElasticSearch ES = new ElasticSearch.ElasticSearch();

                while (true)
                {
                    Message request       = receiver.Receive(new TimeSpan(0, 30, 0));
                    string  replyTo       = request.Properties.ReplyTo;
                    string  correlationID = request.Properties.CorrelationId;

                    if (null != request)
                    {
                        //                        Console.WriteLine(request.Body);
                        string  stringData = request.Body.ToString();
                        dynamic results    = JsonConvert.DeserializeObject <dynamic>(stringData);

                        results.passo        = "TerminoProcesso";
                        results.dataExecucao = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                        string codigoTicket = correlationID;

                        stringData = JsonConvert.SerializeObject(results);

                        var contentDataES = new StringContent(stringData, System.Text.Encoding.UTF8, MIME_TYPE_JSON);

                        //                        Console.WriteLine("Gravando no ElasticSearch: {0}", EndpointElasticSearchOK + codigoTicket);
                        ES.executa(EndpointElasticSearchOK, contentDataES);


                        Console.WriteLine("FIM de operacao");
                        //                        Console.WriteLine(stringData);
                        receiver.Accept(request);
                    }
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Exception {0}.", e);
                if (null != connection)
                {
                    connection.Close();
                }
            }
        }
示例#3
0
        public ConfiguracoesValores ResgataParametro()
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .Build();
            ConfiguracoesValores settings = config.Get <ConfiguracoesValores>();

            return(settings);
        }