예제 #1
0
        public async Task ProcessQueueAsync(ISmsProcessor processor)
        {
            var queue = await TextMessageQueue.GetMailInQueueAsync(this.Database).ConfigureAwait(false);

            var config = new SmsConfig(this.Database, this.Processor);

            this.Processor = processor;

            if (this.IsEnabled())
            {
                foreach (var mail in queue)
                {
                    var message = SmsHelper.GetMessage(config, mail);

                    await processor.SendAsync(message).ConfigureAwait(false);

                    if (message.Status == Status.Completed)
                    {
                        mail.Delivered   = true;
                        mail.DeliveredOn = DateTimeOffset.UtcNow;

                        await TextMessageQueue.SetSuccessAsync(this.Database, mail.QueueId).ConfigureAwait(false);
                    }
                }
            }
        }
예제 #2
0
        public async Task AddAsync()
        {
            this.Processor = SmsProcessor.GetDefault(this.Database);

            if (!this.IsEnabled())
            {
                return;
            }

            var config = new SmsConfig(this.Database, this.Processor);


            if (string.IsNullOrWhiteSpace(this.Sms.FromName))
            {
                this.Sms.FromName = config.FromName;
            }

            if (string.IsNullOrWhiteSpace(this.Sms.FromNumber))
            {
                this.Sms.FromNumber = config.FromNumber;
            }

            var sysConfig = MessagingConfig.Get(this.Database);

            if (sysConfig.TestMode)
            {
                this.Sms.IsTest = true;
            }

            await TextMessageQueue.AddToQueueAsync(this.Database, this.Sms).ConfigureAwait(false);
        }
예제 #3
0
 public SmsConfig(string tenant, ISmsProcessor processor)
 {
     if (processor != null)
     {
         this.Tenant     = tenant;
         this.Enabled    = processor.IsEnabled;
         this.FromName   = processor.Config.FromName;
         this.FromNumber = processor.Config.FromNumber;
     }
 }
예제 #4
0
        public ViewModel()
        {
            CreateTestDataForDebug();

            IsSimulation = Environment.GetCommandLineArgs().Any(n => n == "-simulator");

            // Assign all of the implementations for the interfaces
            Storage                   = new ArrivalsFileSystemStorage(IsSimulation);
            Settings.Save             = new SaveSettingsCommand(Storage);
            Settings.Reload           = new ReloadSettingsCommand(Storage);
            Settings.TestSms          = new TestSmsSettingsCommand(Storage);
            SaveRoomMappings          = new SaveRoomMappingsCommand(Storage);
            ReloadRoomMappings        = new ReloadRoomMappingsCommand(Storage);
            SaveTemplates             = new SaveTemplatesCommand(Storage);
            ReloadTemplates           = new ReloadTemplatesCommand(Storage);
            SeeTemplateDocumentation  = new SeeTemplateDocumentationCommand();
            ClearUnproccessedMessages = new ClearUnproccessedMessagesCommand(Storage);

            // Simulator for the PMS
            PmsSimulator.CreateNewAppointment = new SimulatePmsCommand(PmsSimulator, IsSimulation);
            PmsSimulator.UpdateAppointment    = new SimulatePmsCommand(PmsSimulator, IsSimulation);
            PmsSimulator.DeleteAppointment    = new SimulatePmsCommand(PmsSimulator, IsSimulation);

            // Simulator for the SMS message processor
            SimulationSmsProcessor.QueueIncomingMessage = new SimulateProcessorCommand(SimulationSmsProcessor, IsSimulation);

            if (IsSimulation)
            {
                SmsProcessor    = SimulationSmsProcessor;
                FhirApptReader  = PmsSimulator;
                FhirApptUpdater = PmsSimulator;
            }
            else
            {
                FhirApptReader  = new FhirAppointmentReader(FhirAppointmentReader.GetServerConnection);
                FhirApptUpdater = new FhirAppointmentUpdater(FhirAppointmentReader.GetServerConnection);
                SmsProcessor    = new TwilioSmsProcessor();
            }
        }
예제 #5
0
        public async System.Threading.Tasks.Task CheckForMessages(ArrivalsModel model)
        {
            ISmsProcessor sms = GetSmsProcessor();
            // sms.Initialize();
            // TODO: Thread this into the background, but report errors back to the status screen
            // TODO: If this needs paging or something, repeat this call till its complete, or similar
            var messages = sms.ReceiveMessages();

            foreach (var item in messages)
            {
                var appts = MatchPatient(model, item.phone);
                foreach (var appt in appts)
                {
                    if (ActionForMessage(item.message) == "arrived")
                    {
                        await ArriveAppointment(appt);

                        appt.LastPatientMessage = item.message;
                    }
                }
            }
        }
 public NotificationConsumer(ISmsProcessor processor)
 {
     _processor = processor;
 }
 public SMSConsumer(ISmsProcessor processor)
 {
     _processor = processor;
 }