Ejemplo n.º 1
0
        private static void Gsm_SmsSentEvent(object sender, ParseSms e)
        {
            if ((Gsm.Debug & (int)Gsm.DebugCategory.GsmRequest) > 0)
            {
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.WriteLine("Versendet " + e.Sender + ":\r\n" + e.Message);
                Console.ForegroundColor = ConsoleColor.Gray;
            }

            string msg       = e.Message.ToLower().StartsWith(SmsWayValidationTrigger.ToLower()) ? SmsWayValidationTrigger : e.Message; //Bei "SmsAbruf" ist SendeText und Empfangstect verschieden.
            int    contentId = MelBoxSql.Tab_Message.SelectOrCreateMessageId(msg);
            int    toId      = GetSmsSenderID(e.Sender, e.Message);

            //'SMS gesendet' in Datenbank schreiben
            MelBoxSql.Sent sent = new MelBoxSql.Sent(toId, contentId, MelBoxSql.Tab_Contact.Communication.Sms)
            {
                Reference    = e.InternalReference,
                Confirmation = Tab_Sent.Confirmation.AwaitingRefernece,
                SentTime     = e.TimeUtc
            };

            if (sent.SentTime == DateTime.MinValue)
            {
                sent.SentTime = DateTime.UtcNow;
            }

            MelBoxSql.Tab_Sent.Insert(sent);
        }
Ejemplo n.º 2
0
        private static Dictionary <string, object> ToDictionary(Sent sent)
        {
            Dictionary <string, object> set = new Dictionary <string, object>();

            if (sent.Id > 0)
            {
                set.Add(nameof(sent.Id), sent.Id);
            }
            if (sent.SentTime != null)
            {
                set.Add(nameof(sent.SentTime), sent.SentTime);
            }
            if (sent.ToVia != Tab_Contact.Communication.NaN)
            {
                set.Add(nameof(sent.ToVia), sent.ToVia);
            }
            if (sent.ToId > 0)
            {
                set.Add(nameof(sent.ToId), sent.ToId);
            }
            if (sent.ContentId > 0)
            {
                set.Add(nameof(sent.ContentId), sent.ContentId);
            }
            if (sent.Reference > 0)
            {
                set.Add(nameof(sent.Reference), sent.Reference);
            }
            if (sent.Confirmation != Confirmation.NaN)
            {
                set.Add(nameof(sent.Confirmation), sent.Confirmation);
            }

            return(set);
        }
Ejemplo n.º 3
0
        public static System.Data.DataTable Select(Sent where)
        {
            Dictionary <string, object> columns = ToDictionary(where);

            string query = "SELECT * FROM " + TableName + " WHERE ";

            query += Sql.ColNameAlias(columns.Keys, " AND ");

            return(Sql.SelectDataTable("Versendet", query, Sql.Alias(columns)));
        }
Ejemplo n.º 4
0
        private static void CreateNewDataBase()
        {
            Console.WriteLine("Erstelle eine neue Datenbank.");
            try
            {
                //Erstelle Datenbank-Datei und öffne einmal zum Testen
                Directory.CreateDirectory(Path.GetDirectoryName(DbPath));
                FileStream stream = File.Create(DbPath);
                stream.Close();

                //Erzeuge Tabellen in neuer Datenbank-Datei
                //Zeiten in UTC im Format TEXT (Lesbarkeit Rohdaten)

                #region Log

                Tab_Log.CreateTable();

                Log log = new Log(Tab_Log.Topic.Startup, 3, "Datenbank neu erstellt.");

                Tab_Log.Insert(log);

                #endregion

                #region Company

                Tab_Company.CreateTable();

                Company company1 = new Company("Kreutzträger Kältetechnik GmbH & Co. KG", "Theodor-Barth-Str. 21", "28307 Bremen");

                Tab_Company.Insert(company1);

                #endregion

                #region Contact

                Tab_Contact.CreateTable();

                Contact contact = new Contact
                {
                    Id               = 1,
                    Name             = "SMSZentrale",
                    Password         = Tab_Contact.Encrypt("7307"),
                    Accesslevel      = 9000,
                    CompanyId        = 1,
                    Email            = "*****@*****.**",
                    Phone            = 4915142265412,
                    Via              = Tab_Contact.Communication.Email,
                    MaxInactiveHours = 4
                };

                Tab_Contact.Insert(contact);

                contact = new Contact
                {
                    Id          = 2,
                    Name        = "Bereitschaftshandy",
                    Password    = Tab_Contact.Encrypt("7307"),
                    Accesslevel = 2000,
                    CompanyId   = 1,
                    Email       = "*****@*****.**",
                    Phone       = 491728362586,
                    Via         = Tab_Contact.Communication.Sms
                };

                Tab_Contact.Insert(contact);

                contact = new Contact
                {
                    Id          = 3,
                    Name        = "Kreutzträger Service",
                    Password    = Tab_Contact.Encrypt("7307"),
                    Accesslevel = 9000,
                    CompanyId   = 1,
                    Email       = "*****@*****.**",
                    Via         = Tab_Contact.Communication.Email
                };

                Tab_Contact.Insert(contact);

                contact = new Contact
                {
                    Name        = "Henry Kreutzträger",
                    Password    = Tab_Contact.Encrypt("7307"),
                    Accesslevel = 9000,
                    CompanyId   = 1,
                    Email       = "*****@*****.**",
                    Phone       = 491727889419,
                    Via         = Tab_Contact.Communication.Sms
                };

                Tab_Contact.Insert(contact);

                contact = new Contact
                {
                    Name        = "Bernd Kreutzträger",
                    Password    = Tab_Contact.Encrypt("7307"),
                    Accesslevel = 9000,
                    CompanyId   = 1,
                    Email       = "*****@*****.**",
                    Phone       = 491727875067,
                    Via         = Tab_Contact.Communication.Sms
                };

                Tab_Contact.Insert(contact);

                #endregion

                #region Message

                Tab_Message.CreateTable();

                Message message1 = new Message
                {
                    Content        = "Datenbank neu erstellt.",
                    BlockedDays    = Tab_Message.BlockWeek(),
                    StartBlockHour = 8,
                    EndBlockHour   = 8
                };

                Tab_Message.Insert(message1);

                #endregion

                #region Recieved

                Tab_Recieved.CreateTable();

                Recieved recieved1 = new Recieved(1, 1)
                {
                    RecTime = DateTime.UtcNow
                };

                Tab_Recieved.Insert(recieved1);

                #endregion

                #region Sent

                Tab_Sent.CreateTable();

                Sent sent1 = new Sent(1, 1, Tab_Contact.Communication.Unknown)
                {
                    SentTime = DateTime.UtcNow
                };

                Tab_Sent.Insert(sent1);

                #endregion

                #region Bereitschaft

                Tab_Shift.CreateTable();

                Shift shift1 = new Shift(1, DateTime.Now);
                Tab_Shift.Insert(shift1);

                #endregion

                Views_Create();

                #region Hilfstabelle

                Dictionary <string, string> columns = new Dictionary <string, string>
                {
                    { "Id", "INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT" },
                    { "DischargeTime", "TEXT" },
                    { "InternalReference", "INTEGER" }
                };

                Sql.CreateTable("Reports", columns);

                #endregion
            }
            catch (Exception ex)
            {
                throw new Exception("Sql-Fehler CreateNewDataBase()\r\n" + ex.Message + "\r\n" + ex.InnerException);
            }
        }
Ejemplo n.º 5
0
 public static bool Update(Sent set, Sent where)
 {
     return(Sql.Update(TableName, ToDictionary(set), ToDictionary(where)));
 }
Ejemplo n.º 6
0
 public static bool Insert(Sent sent)
 {
     return(Sql.Insert(TableName, ToDictionary(sent)));
 }
Ejemplo n.º 7
0
 public static bool Delete(Sent where)
 {
     return(Sql.Delete(TableName, ToDictionary(where)));
 }