Пример #1
0
        public void TestFailedMessage()
        {
            var msg = new FailedMessage(
                FailedEventType.NotFoundWorker, "UploadAttendanceHandler",
                new EventMessage(EventType.AttTransactionEx, new AttendanceLog("1", 1, 1, 2018, 1, 13, 8, 0, 0, 1, 1, "gate01", DeviceType.OnlyIn)));

            Assert.IsTrue(msg.IncreaseFailedCount());
            Assert.IsTrue(msg.IncreaseFailedCount());
            Assert.IsTrue(msg.RetryTimes == 2);
            Assert.IsTrue(msg.IncreaseFailedCount());
            Assert.IsTrue(msg.IncreaseFailedCount());
            Assert.IsTrue(msg.RetryTimes == 4);
            Assert.IsFalse(msg.IncreaseFailedCount());

            var json = msg.DataToJSON();

            Assert.IsNotNull(json);
            var arg = JsonConvert.DeserializeObject <ArgumentItem>(json);

            Assert.AreEqual(arg.Id, msg.Data.Id);
        }
Пример #2
0
 private void IncreaseFailedTimes(FailedMessage msg)
 {
     if (msg.IncreaseFailedCount())
     {
         Bundle.Database.Execute("UPDATE failed_queue SET retry_times=@retry_times WHERE id=@id;",
                                 new Dictionary <string, object>
         {
             { "@id", msg.Id },
             { "@retry_times", msg.RetryTimes }
         });
     }
     Logger.DebugFormat("Increase failed message({id}) at {times} time.", msg.Id, msg.RetryTimes);
 }