/// <summary>
        /// Protokolliert die Weiterleitung einer Nachricht
        /// </summary>
        /// <param name="contentId">Id für den Inhalt (Text) der Nachricht</param>
        /// <param name="sentToId">Id für den Empfänger der Nachricht</param>
        /// <param name="sendVia">Sendeweg 1 = SMS, 2 = Email</param>
        /// <param name="smsReference">Index aus GSM Modem bei SMS</param>
        /// <param name="confirmStatus">Statuscode 0=Eintrag erstellt, 1=Versendet, 2=Warten auf Sendebericht, 4=Nochmal senden, 8=Senden abgebrochen, 16=senden erfolgreich</param>
        /// <returns></returns>
        private int InsertMessageSent(int contentId, int sentToId, SendWay sendVia, int smsReference, SendStatus confirmStatus = 0)
        {
            try
            {
                const string query = "INSERT INTO \"LogSent\" (\"SentToId\", \"ContentId\", \"SentVia\", \"SmsRef\", \"ConfirmStatus\" ) " +
                               "VALUES (@sentToId, @contentId, @sendVia, @smsRef, @confirmStatus);" +
                               "SELECT Id FROM \"LogSent\" ORDER BY \"SentTime\" DESC LIMIT 1";

                Dictionary<string, object> args = new Dictionary<string, object>
                {
                    { "@sentToId", sentToId },
                    { "@contentId", contentId },
                    { "@sendVia", sendVia },
                    { "@smsRef", smsReference },
                    { "@confirmStatus", confirmStatus }
                };

                return SqlSelectInteger(query, args);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Sql-Fehler InsertMessageSent()\r\n" +
                    ex.GetType().ToString() + ": " + ex.Message + "\r\n" + ex.InnerException);
                throw ex;
            }
        }
        /// <summary>
        /// BAUSTELLE funktioniert noch nicht
        /// </summary>
        /// <param name="sendVia"></param>
        /// <param name="smsReference"></param>
        /// <param name="sendTime"></param>
        /// <param name="smsSendStatus"></param>
        public bool UpdateMessageSentStatus(SendWay sendVia, int smsReference, DateTime sendTime, byte smsSendStatus = 255)
        {
            SendStatus sendStatus = SendStatus.SetToSent;

            if (smsSendStatus < 32)
            {
                sendStatus = SendStatus.SentSuccess;
            }
            else if (smsSendStatus < 64)
            {
                sendStatus = SendStatus.Pending;
            }
            else if (smsSendStatus < 128)
            {
                sendStatus = SendStatus.SendAbborted;
            }
            try
            {
                const string query = "UPDATE \"LogSent\" " +
                                     "SET \"ConfirmStatus\" = @confirmStatus " +
                                     "WHERE ID = (SELECT ID FROM \"LogSent\" " +
                                     "WHERE \"SmsRef\" = @smsRef " +
                                     "AND \"SendVia\" = @sendVia " +
                                     "AND \"ConfirmStatus\" = @confirmStatusOld " +
                                     "AND \"SentTime\" BETWEEN datetime(@sentTime, '-5 minutes') AND datetime(@sentTime)" +
                                     "ORDER BY \"SentTime\" DESC LIMIT 1); ";

                Dictionary <string, object> args = new Dictionary <string, object>
                {
                    { "@sendVia", sendVia },
                    { "@smsRef", smsReference },
                    { "@confirmStatus", sendStatus },
                    { "@confirmStatusOld", SendStatus.SetToSent },
                    { "@sentTime", MelBoxSql.SqlTime(sendTime) },
                };

                return(SqlNonQuery(query, args));
            }
            catch (Exception ex)
            {
                throw new Exception("Sql-Fehler UpdateMessageSent() " + ex.GetType() + "\r\n" + ex.Message);
            }
        }
        /// <summary>
        /// PROVISORISCH: Schreibt zur Kontrolle die Empfangsbestätigung vom Modem in die Datenbank ggf. später die ganze Tabelle entfernen.
        /// </summary>
        /// <param name="sendVia"></param>
        /// <param name="smsReference"></param>
        /// <param name="confirmStatus"></param>
        /// <returns></returns>
        private int InsertMessageStatus(SendWay sendVia, int smsReference, SendStatus confirmStatus = 0)
        {
            try
            {
                const string query = "INSERT INTO \"LogStatus\" (\"SentVia\", \"SmsRef\", \"ConfirmStatus\" ) " +
                               "VALUES ( @sendVia, @smsRef, @confirmStatus);" +
                               "SELECT Id FROM \"LogStatus\" ORDER BY \"SentTime\" DESC LIMIT 1";

                Dictionary<string, object> args = new Dictionary<string, object>
                {
                    { "@sendVia", sendVia },
                    { "@smsRef", smsReference },
                    { "@confirmStatus", confirmStatus }
                };

                return SqlSelectInteger(query, args);
            }
            catch (Exception ex)
            {
                throw new Exception("InsertMessageStatus() " + ex.GetType().Name + "\r\n" + ex.Message);
            }
        }