Пример #1
0
        public async Task SaveMessageAsync(MessageLogDto message)
        {
            if (message.Source == null)
            {
                throw new ArgumentNullException("src");
            }
            if (message.MessArea == null)
            {
                throw new ArgumentNullException("area");
            }
            if (message.MessArea == null)
            {
                throw new ArgumentNullException("msg");
            }
            CheckTable();
            var command = connection.CreateCommand();

            command.CommandText = "INSERT INTO " + GetCurrentTable() + " (dt, level, source, message, area) " +
                                  $"VALUES ($p1, 0, $p3, '{message.Message}', '{message.MessArea}')";
            command.Parameters.AddWithValue("p1", message.DT.ToString("yyyy-MM-dd HH:mm:ss.ms"));
            command.Parameters.AddWithValue("p2", 0);
            command.Parameters.AddWithValue("p3", message.Source);
            command.Parameters.AddWithValue("p4", message.Message);
            command.Parameters.AddWithValue("p5", message.MessArea);
            Console.WriteLine(command.CommandText);
            await command.ExecuteNonQueryAsync();
        }
Пример #2
0
 public void Create(MessageLogDto log)
 {
     _repository.Create(new MessageLog
     {
         From             = log.From,
         To               = log.To,
         Message          = log.Message,
         TwilioMessageSid = log.TwilioMessageSid,
         Status           = log.Status
     });
 }