コード例 #1
0
        public static void SendPaymentReminders()
        {
            const string SmsMessagePt1 = "Your next Blue Motor Finance loan repayment is due in 3 days on ";
            const string SmsMessagePt2 = ". Please ensure funds are available. If you have any issues please call 020 3005 9332";

            Console.WriteLine("Sending Payment Reminders. System Time: " + DateTime.Now.ToString("d MMM yyyy"));
            Db.DbConnectionString = Config.DatabaseConnString;
            TwilioLib.AccountSid  = Config.TwilioAccountSid;
            TwilioLib.AuthToken   = Config.TwilioAuthToken;
            TwilioLib.FromNumber  = Config.TwilioFromNumber;

            var    BatchGuid  = Guid.NewGuid();
            string smsMessage = "";
            string smsNumber  = "";
            var    reminders  = Db.GetPaymentReminders();

            foreach (var item in reminders)
            {
                smsMessage = SmsMessagePt1 + item.NextDueDate.ToString("d MMM yyyy") + SmsMessagePt2;
                smsNumber  = item.MobilePhoneStdCode.Trim() + item.MobilePhoneNumber.Trim();

                // Override To number if we are not in the live environment
                if (Config.Environment != "LIVE")
                {
                    smsNumber = "+44770928922";
                }

                var msg = TwilioLib.SendSms(smsMessage, smsNumber);
                Console.WriteLine("Message Sent to: " + smsNumber + ", Message: " + smsMessage);
                Db.SaveOutboundMessage(BatchGuid, item.AgreementReference.Trim(), msg.Sid, msg.Uri.OriginalString, msg.From, msg.To, msg.Body, msg.Status);
            }
        }
コード例 #2
0
        public static void TestSms(string text)
        {
            Console.WriteLine(text);
            Console.WriteLine("Sending Test SMS Message");

            Db.DbConnectionString = Config.DatabaseConnString;
            TwilioLib.AccountSid  = Config.TwilioAccountSid;
            TwilioLib.AuthToken   = Config.TwilioAuthToken;
            TwilioLib.FromNumber  = Config.TwilioFromNumber;

            const string SendToNumber = "+447770928922";

            TwilioLib.SendSms(TestMessage, SendToNumber);
        }
コード例 #3
0
        public static void CheckMessageStatuses()
        {
            Db.DbConnectionString = Config.DatabaseConnString;

            var activeOutboundMessages = Db.GetActiveOutboundMessages();

            TwilioLib.AccountSid = Config.TwilioAccountSid;
            TwilioLib.AuthToken  = Config.TwilioAuthToken;
            foreach (var item in activeOutboundMessages)
            {
                var msg = TwilioLib.RetrieveMessage(item.Sid);
                if (item.Status != msg.Status)
                {
                    string error = msg.ErrorCode.ToString() ?? "" + " : " + msg.ErrorMessage ?? "";
                    Db.AppendToMessageLog(msg.Sid, error, msg.Status);
                }
            }
        }