Esempio n. 1
0
 public override void Enqueue(ISms sms)
 {
     using (var db = new SmsLogDataContext())
     {
         db.SmsQueue_Enqueue(sms);
     }
 }
Esempio n. 2
0
 public static void DeliveryStatusUpdate(string providerReference, string recipient, DateTime notifiedOn, int notificationCode, string notificationMessage)
 {
     using (var db = new SmsLogDataContext())
     {
         db.SmsLog_DeliveryStatusUpdate(providerReference, recipient, notifiedOn, notificationCode, notificationMessage);
         db.SubmitChanges();
     }
 }
Esempio n. 3
0
 public static void DeliveryFailure(string providerReference, string recipient, DateTime failedOn, int errorCode, string errorMessage)
 {
     using (var db = new SmsLogDataContext())
     {
         db.SmsLog_DeliveryFailureNotification(providerReference, recipient, failedOn, errorCode, errorMessage);
         db.SubmitChanges();
     }
 }
Esempio n. 4
0
 public static void DeliveryConfirmation(string providerReference, string recipient, DateTime deliveredOn, int notificationCode)
 {
     using (var db = new SmsLogDataContext())
     {
         db.SmsLog_DeliveryConfirmation(providerReference, recipient, deliveredOn, notificationCode);
         db.SubmitChanges();
     }
 }
Esempio n. 5
0
 public override void OnAcceptance(ISms sms, DateTime timeStamp)
 {
     using (var db = new SmsLogDataContext())
     {
         db.SmsLog_Insert(sms, timeStamp);
         db.SubmitChanges();
     }
 }
Esempio n. 6
0
        public static void SmsLog_Submitted(ISms sms, ISmsStatusCollection status, DateTime timeStamp)
        {
            using (var db = new SmsLogDataContext())
            {
                for (int count = 0; count < status.Count; ++count)
                    db.SmsLog_Forwarded(sms.ReferenceId, status[count].ProviderReference, timeStamp, sms.Recipients[count], status[count].Status < 0, status[count].ErrorCode, status[count].ErrorMessage);

                db.SubmitChanges();
            }
        }
Esempio n. 7
0
        public override bool IsEmpty()
        {
            int? queueSize;

            using (var db = new SmsLogDataContext())
            {
                queueSize = db.SmsQueue_GetQueueSize();
            }

            return ((queueSize != null) && (queueSize == 0));
        }
Esempio n. 8
0
 public void Dispose()
 {
     if (_db != null)
     {
         if (_db.Connection.State != ConnectionState.Closed)
         {
             _db.Connection.Close();
         }
         _db.Dispose();
         _db = null;
     }
 }
Esempio n. 9
0
        public static SmsLog GetSmsLog(string providerReference)
        {
            SmsLogDataContext db;

            db = new SmsLogDataContext();

            var smsLog = from log in db.SmsLogs
                                     join recipient in db.SmsLogRecipients on log.SmsLogId equals recipient.SmsLogId
                                     where recipient.ProviderReference == providerReference
                                     select log;

            return smsLog.Single();
        }
Esempio n. 10
0
        public void InsertMultipleToLog()
        {
            ISmsc smsc;
            ISms sms;
            SmsLog loggedSms;
            ISmsStatusCollection status;
            SmsLogDataContext db;

            db = new SmsLogDataContext();

            smsc = SmsFactory.GetSmsc();
            sms = SmsFactory.NewSms(TestConstants.Default_ApplicationId);

            sms.Sender = TestConstants.Default_Sender;
            sms.AddRecipient(TestConstants.Default_Recipient);
            sms.AddRecipient(TestConstants.Default_Recipient_2);
            sms.AddRecipient(TestConstants.Default_Recipient_3);
            sms.Message = "Test Message";

            status = smsc.SendMultipleImmediate(sms);
            Assert.IsTrue(status.Successful);
            foreach (ISmsStatus stat in status)
                Assert.AreEqual(EnMtStatus.Accepted, stat.Status);

            var smsLog = from log in db.SmsLogs
                                     where log.SmsLogId == sms.ReferenceId
                                     select log;

            loggedSms = smsLog.Single();
            Helpers.CompareSms(sms, loggedSms);

            Assert.IsNotNull(loggedSms.AcceptedOn);
            Assert.IsNotNull(loggedSms.ForwardedOn);
            Assert.AreEqual(0, loggedSms.Failures);
            Assert.AreEqual(3, loggedSms.Successes);
            Assert.IsNull(loggedSms.ErrorCode);
            Assert.IsNull(loggedSms.ErrorMessage);

            foreach (SmsLogRecipient recipient in loggedSms.SmsLogRecipients)
            {
                Assert.IsNull(recipient.NotifiedOn);
                Assert.IsNull(recipient.NotificationCode);
                Assert.IsNull(recipient.NotificationMessage);
            }
        }
Esempio n. 11
0
        public void InsertToLog_WithFailure()
        {
            ISmsc smsc;
            ISms sms;
            SmsLog loggedSms;
            ISmsStatus status;
            SmsLogDataContext db;

            db = new SmsLogDataContext();

            smsc = SmsFactory.GetSmsc();
            sms = SmsFactory.NewSms(TestConstants.Default_ApplicationId);

            sms.Sender = TestConstants.Default_Sender;
            sms.AddRecipient(TestConstants.Default_Recipient);
            sms.Message = "Test Message";
            sms.CustomProperties["FailCode"] = "-15";

            status = smsc.SendImmediate(sms);
            Assert.AreEqual(EnMtStatus.Failure, status.Status);

            var smsLog = from log in db.SmsLogs
                                     where log.SmsLogId == sms.ReferenceId
                                     select log;

            loggedSms = smsLog.Single();
            Helpers.CompareSms(sms, loggedSms);

            Assert.IsNotNull(loggedSms.AcceptedOn);
            Assert.IsNotNull(loggedSms.ForwardedOn);
            Assert.IsNotNull(loggedSms.SmsLogRecipients[0].NotifiedOn);
            Assert.AreEqual(1, loggedSms.Failures);
            Assert.AreEqual(0, loggedSms.Successes);
            Assert.AreEqual(-15, loggedSms.SmsLogRecipients[0].NotificationCode);
            Assert.IsNotNull(loggedSms.SmsLogRecipients[0].NotificationMessage);
        }