Example #1
0
 public Shift(int contactId, DateTime date)
 {
     EntryTime = System.DateTime.UtcNow;
     ContactId = contactId;
     Start     = Tab_Shift.ShiftStart(date);
     End       = Tab_Shift.ShiftEnd(date);
 }
Example #2
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);
            }
        }
Example #3
0
        //BAUSTELLE
        public static bool IsMessageBlockedNow(int messageId)
        {
            Message msg = SelectMessage(messageId);

            Console.WriteLine($"Gesperrt? Nachricht [{messageId}] {msg.Content}");

            bool      blockedDay = false;
            DayOfWeek today      = DateTime.Now.DayOfWeek;

            if (Tab_Shift.IsHolyday(DateTime.Now))
            {
                today = DayOfWeek.Sunday;
            }

            switch (today)
            {
            case DayOfWeek.Monday:
                if ((msg.BlockedDays & BlockedDays.Mo) > 0)
                {
                    blockedDay = true;
                }
                break;

            case DayOfWeek.Tuesday:
                if ((msg.BlockedDays & BlockedDays.Di) > 0)
                {
                    blockedDay = true;
                }
                break;

            case DayOfWeek.Wednesday:
                if ((msg.BlockedDays & BlockedDays.Mi) > 0)
                {
                    blockedDay = true;
                }
                break;

            case DayOfWeek.Thursday:
                if ((msg.BlockedDays & BlockedDays.Do) > 0)
                {
                    blockedDay = true;
                }
                break;

            case DayOfWeek.Friday:
                if ((msg.BlockedDays & BlockedDays.Fr) > 0)
                {
                    blockedDay = true;
                }
                break;

            case DayOfWeek.Saturday:
                if ((msg.BlockedDays & BlockedDays.Sa) > 0)
                {
                    blockedDay = true;
                }
                break;

            case DayOfWeek.Sunday:
                if ((msg.BlockedDays & BlockedDays.So) > 0)
                {
                    blockedDay = true;
                }
                break;
            }

            if (blockedDay)
            {
                if (DateTime.Now.Hour >= msg.StartBlockHour || (msg.EndBlockHour > 0 && DateTime.Now.Hour < msg.EndBlockHour))
                {
                    return(true);
                }
            }

            return(false);
        }