コード例 #1
0
        private void ProcessarSmsNaoEnviado()
        {
            eventLog1.WriteEntry("ECJ_WS05 - Processa sms nao enviado", EventLogEntryType.Information, 2);

            SmsService smsService = new SmsService();

            smsService.LimpaSmsEnviado();
            eventLog1.WriteEntry("ECJ_WS05 - Deleta sms enviado", EventLogEntryType.Information, 200);

            var tww = new TWW();

            var listaSmsNaoEnviado = smsService.BuscarNaoEnviados();

            if (listaSmsNaoEnviado.Count == 0)
            {
                return;
            }

            foreach (var sms in listaSmsNaoEnviado)
            {
                try
                {
                    ServicePointManager.Expect100Continue = true;
                    ServicePointManager.SecurityProtocol  = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
                    sms.DataInicioProcesso = DateTime.Now;
                    sms.Status             = StatusSms.Processando;
                    smsService.Salvar(sms);

                    var response = tww.Send(sms.Id, sms.Numero, sms.Mensagem);
                    //emailService.EnviaEmail(ParametrosAppConfig.EmailSms, sms.Mensagem + "@" + idMsg, sms.Numero);
                    if (response != "OK")
                    {
                        LogarErroSms(sms.Id, StatusSms.TentarNovamente, $"créditos: {tww.Creditos()}, validade: {tww.ValidadeCreditos()}");
                        continue;
                    }

                    sms.Status = StatusSms.Enviado;
                    smsService.Salvar(sms);
                }
                catch (Exception ex)
                {
                    eventLog1.WriteEntry("ECJ_WS05 - Processa sms nao enviado" + ex.Message, EventLogEntryType.Error, 1);
                    LogarErroSms(sms.Id, StatusSms.Erro, ex.Message);
                }
            }

            eventLog1.WriteEntry("ECJ_WS05 - Fim Processa sms nao enviado", EventLogEntryType.Information, 3);
        }
コード例 #2
0
        public HttpResponseMessage SMS(HttpRequestMessage request)
        {
            return(CreateHttpResponse(request, () =>
            {
                //necessatio para consumir webservice
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;


                var tww = new TWW();

                var data = new { Creditos = tww.Creditos(), Validade = tww.ValidadeCreditos() };

                var response = request.CreateResponse(HttpStatusCode.OK, data);

                return response;
            }));
        }
コード例 #3
0
        private void ProcessarSmsPendente()
        {
            eventLog1.WriteEntry("ECJ_WS05 - Processar Sms Pendente", EventLogEntryType.Information, 4);
            var smsService = new SmsService();
            //var emailService = new EmailService();
            var tww = new TWW();

            var listaSmsPendente = smsService.BuscarPendentes();

            if (listaSmsPendente.Count == 0)
            {
                return;
            }

            foreach (var sms in listaSmsPendente)
            {
                try
                {
                    sms.DataInicioProcesso = DateTime.Now;
                    sms.Status             = StatusSms.Processando;
                    smsService.Salvar(sms);

                    var response = tww.Send(sms.Id, sms.Numero, sms.Mensagem);
                    //emailService.EnviaEmail(ParametrosAppConfig.EmailSms, sms.Mensagem + "@" + idMsg, sms.Numero);
                    if (response != "OK")
                    {
                        LogarErroSms(sms.Id, StatusSms.TentarNovamente, $"créditos: {tww.Creditos()}, validade: {tww.ValidadeCreditos()}");
                        continue;
                    }

                    sms.Status = StatusSms.Enviado;
                    smsService.Salvar(sms);
                }
                catch (Exception ex)
                {
                    eventLog1.WriteEntry("ECJ_WS05 - Processar Sms Pendente" + ex.Message, EventLogEntryType.Error, 2);
                    LogarErroSms(sms.Id, StatusSms.Erro, ex.Message);
                }
            }

            eventLog1.WriteEntry("ECJ_WS05 - Fim Processar Sms Pendente", EventLogEntryType.Information, 5);
        }