示例#1
0
        static void Main(string[] args)
        {
            // Teste apenas para validar SID
            TwilioService teste = new TwilioService();

            teste.SendSms(new Domain.Twilio.Models.SMSSendRequest {
                AccountSID  = "AC24fbef3fcf741f0521e6d0df93018695",
                AuthToken   = "214f491ff03f4e6c41adab29af022a16",
                FromNumber  = "+13215172198",
                MessageText = "Teste",
                ToNumber    = "+5516981311699"
            });
        }
        public ActionResult DetalleCategory(DetalleCategoryModel detalle)
        {
            if (ModelState.IsValid)
            {
                var contt = new ContactUserInfo
                {
                    Nombre  = detalle.Nombre,
                    Correo  = detalle.Correo,
                    Mensaje = detalle.Mensaje
                };
                _writeOnlyRepository.Create(contt);
                var clas = _readOnlyRepository.GetById <Classified>(detalle.IdClasificado);
                detalle.Usuario = _readOnlyRepository.GetById <User>(clas.IdUsuario);
                MailService.SendContactMessageToUser(detalle.Correo, detalle.Nombre, detalle.Mensaje, detalle.Usuario.Correo);
                TwilioService.SendSms(detalle.Mensaje, detalle.Correo, detalle.Nombre, clas.Titulo);
                this.AddNotification("Se ha enviado el mensaje.", NotificationType.Success);
                return(RedirectToAction("DetalleCategory", detalle.IdClasificado));
            }

            this.AddNotification("No se pudo enviar mensaje a vendedor.", NotificationType.Warning);
            return(RedirectToAction("DetalleCategory", detalle.IdClasificado));
        }
        public async Task Run(
            [QueueTrigger(Queues.Notifications)] StageChanged stageChanged,
            [Blob(Blobs.Schedule)] string scheduleBlob,
            [Blob(Blobs.StageChangedPeopleToNotify)] string peopleToNotifyBlob,
            ILogger log)
        {
            var schedule       = JsonConvert.DeserializeObject <List <ScheduleEntry> >(scheduleBlob);
            var peopleToNotify = JsonConvert.DeserializeObject <List <Person> >(peopleToNotifyBlob);

            log.LogInformation($"Notifying {peopleToNotify.Count} people");
            var currentDay  = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(2)).Day;
            var currentHour = DateTimeOffset.UtcNow.ToOffset(TimeSpan.FromHours(2)).Hour;

            // send sms's
            foreach (var person in peopleToNotify)
            {
                var personsSchedule = schedule
                                      .Where(s => s.Stage == stageChanged.CurrentStage && s.Area == person.Area && s.Day == currentDay && s.StartingHour >= currentHour)
                                      .OrderBy(x => x.StartingHour)
                                      .ToList();
                var message = $"Loadshedding is now stage {stageChanged.CurrentStage} (was {stageChanged.PreviousStage}). ";
                if (stageChanged.CurrentStage > 0)
                {
                    if (personsSchedule.Any())
                    {
                        message += $"Area {person.Area} at {string.Join(", ", personsSchedule.Select(p => $"{p.StartingHour}:00"))}";
                    }
                    else
                    {
                        message += $"No more loadsheeding for area {person.Area}";
                    }
                }

                await _twilioService.SendSms(person.Number, message);
            }
        }
示例#4
0
 public void SendMessage(Send send)
 {
     TwilioService.SendSms(send.Msg);
 }