public IHttpContext ResponseIn(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            Dictionary <string, string> action = new Dictionary <string, string>();

            if (isAdmin)
            {
                action.Add("/blocked/create", "Ausgewählte Nachricht sperren");
            }

            DataTable     dt      = Program.Sql.GetViewMsgRec();
            StringBuilder builder = new StringBuilder();

            builder.Append(MelBoxWeb.HtmlTablePlain(dt, isAdmin));
            builder.Append(MelBoxWeb.HtmlEditor(action));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
        public IHttpContext ResponseShift(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            #region Tabelle anzeigen
            Dictionary <string, string> action = new Dictionary <string, string>
            {
                { "/shift/edit", "Bereitschaft bearbeiten" }
            };

            if (isAdmin)
            {
                action.Add("/shift/delete", "Bereitschaft löschen");
            }

            DataTable     dt      = Program.Sql.GetViewShift();
            StringBuilder builder = new StringBuilder();

            builder.Append(MelBoxWeb.HtmlTableShift(dt, 0, logedInUserId, isAdmin));
            builder.Append(MelBoxWeb.HtmlEditor(action));
            #endregion
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
        public IHttpContext ResponseOverdue(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            DataTable     dt      = Program.Sql.GetViewMsgOverdue();
            StringBuilder builder = new StringBuilder();

            if (dt.Rows.Count == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(3, "Keine Zeitüberschreitungen festgestellt", "Zur Zeit ist kein überwachter Sender in Verzug."));

                dt = Program.Sql.GetMonitoredContactList();
                builder.Append(MelBoxWeb.HtmlTablePlain(dt, false));
            }
            else
            {
                builder.Append(MelBoxWeb.HtmlTablePlain(dt, false));
            }

            const string info = "Den einzelnen Benutzern kann ein Wert 'Max_Inaktiv' [in Stunden] zugewiesen werden. " +
                                "Kommt von diesen Benutzern innherhalb der eingestellten Zeit keine Meldung, sollte der Meldeweg (SMS, Email) geprüft werden.";

            builder.Append(MelBoxWeb.HtmlInfoSidebar("Überwachte Meldungen", info));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
        public IHttpContext ResponseOut(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            DataTable     dt      = Program.Sql.GetViewMsgSent();
            StringBuilder builder = new StringBuilder();

            builder.Append(MelBoxWeb.HtmlTablePlain(dt, false));

            string info = "<i class='w3-xxlarge w3-disabled material-icons-outlined'>storage</i> Nur Datenbank<br>" +
                          "<i class='w3-xxlarge w3-disabled material-icons-outlined'>not_started</i> bereit zum Versenden<br>" +
                          "<i class='w3-xxlarge w3-disabled material-icons-outlined'>radar</i> Warte auf Empfangsbestätigung<br>" +
                          "<i class='w3-xxlarge w3-disabled material-icons-outlined'>replay</i> wird nochmal gesendet<br>" +
                          "<i class='w3-xxlarge w3-disabled material-icons-outlined'>unpublished</i> Nachverfolgung abgebrochen<br>" +
                          "<i class='w3-xxlarge w3-disabled material-icons-outlined'>check_circle</i> Empfangsbestätigung erhalten<br>";

            builder.Append(MelBoxWeb.HtmlInfoSidebar("Sendestatus", info));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
        public static string ProcessFormCompany(Dictionary <string, string> args, bool createNewCompany)
        {
            StringBuilder builder = new StringBuilder();

            int    companyId = 0;
            string name      = "-KEIN NAME-";
            string address   = string.Empty;
            string city      = string.Empty;

            foreach (string arg in args.Keys)
            {
                switch (arg)
                {
                case "CompanyId":
                    companyId = int.Parse(args[arg]);
                    break;

                case "Name":
                    name = args[arg];    //.Replace('+', ' ');
                    break;

                case "Adresse":
                    address = args[arg];    //.Replace('+', ' ');
                    break;

                case "Ort":
                    city = args[arg];    //.Replace('+', ' ');
                    break;
                }
            }

            if (createNewCompany || companyId == 0)
            {
                bool success = Program.Sql.InsertCompany(name, address, city);
                if (!success)
                {
                    builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler beim Schreiben in die Datenbank", "Der Firmeneintrag für '" + name + "' konnte nicht erstellt werden."));
                }
                else
                {
                    builder.Append(MelBoxWeb.HtmlAlert(3, "Firma '" + name + "' erstellt", "Die Firma '" + name + "' wurde in der Datenbank neu erstellt."));
                }
            }
            else
            {
                if (!Program.Sql.UpdateCompany(companyId, name, address, city))
                {
                    builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Änderungen für Firma '" + name + "'", "Die Änderungen konnten nicht in die Datenbank übertragen werden."));
                }
                else
                {
                    builder.Append(MelBoxWeb.HtmlAlert(3, "Änderungen für Firma '" + name + "' übernommen", "Die Änderungen an Firma '" + name + "' wurden in der Datenbank gespeichert."));
                }
            }

            return(builder.ToString());
        }
        public static void StartWebServer(int port = 48040)
        {
            new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;
                Thread.CurrentThread.Priority     = ThreadPriority.BelowNormal;

                var _ = new MelBoxWeb(port);
            }).Start();
        }
        public IHttpContext ResponseAccount(IHttpContext context)
        {
            string caption = "Benutzerkonto";
            string payload = context.Request.Payload;

            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            Dictionary <string, string> action = new Dictionary <string, string>
            {
                { "/account/update", "Änderungen an Kontakt speichern" }
            };

            if (isAdmin)
            {
                action.Add("/account/create", "Neuen Kontakt mit diesen Angaben einrichten");
                action.Add("/account/delete", "Diesen Kontakt löschen");
            }

            StringBuilder builder = new StringBuilder();

            int chosenContactId = logedInUserId;

            if (requestingPage == caption && args.ContainsKey("selectedContactId")) //Ist Antwort von dieser Seite
            {
                int.TryParse(args["selectedContactId"].ToString(), out chosenContactId);
            }
            else if (chosenContactId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Ungültiger Aufruf", "Für Einsicht in das Benutzerkonto bitte einloggen."));
            }

            if (logedInUserId != 0)
            {
                DataTable dt;
                if (isAdmin)
                {
                    dt = Program.Sql.GetViewContactInfo();
                }
                else
                {
                    dt = Program.Sql.GetViewContactInfo(chosenContactId);
                }

                DataTable dtCompany = Program.Sql.GetCompany();

                builder.Append(MelBoxWeb.HtmlFormAccount(dt, dtCompany, chosenContactId, isAdmin));
            }
#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), caption, logedInUserName));
            return(context);
        }
        public IHttpContext ResponseBlockedDelete(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            #region Inhalt ermitteln
            int contentId = 0;
            if (args.ContainsKey("selectedRow"))
            {
                int.TryParse(args["selectedRow"].ToString(), out contentId);
            }
            #endregion

            StringBuilder builder = new StringBuilder();

            if (contentId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler", "Die übergebene Nachricht konnte nicht zugeordnet werden."));
            }
            else
            {
                if (!Program.Sql.DeleteMessageBlocked(contentId))
                {
                    builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler Nachricht entsperren", "Die Nachricht mit der Nr. " + contentId + " konnte nicht aus der Sperrliste freigegeben werden."));
                }
                else
                {
                    builder.Append(MelBoxWeb.HtmlAlert(3, "Nachricht aus der Sperrliste genommen", "Die gesperrte Nachricht mit der Nr. " + contentId + " wurde durch '" + logedInUserName + "' wieder freigegeben."));
                }
            }

            Dictionary <string, string> action = new Dictionary <string, string>();

            if (isAdmin)
            {
                action.Add("/blocked/update", "Gesperrte Nachricht bearbeiten");
                action.Add("/blocked/delete", "Aus Sperrliste entfernen");
            }

            DataTable dt = Program.Sql.GetViewMsgBlocked();
            builder.Append(MelBoxWeb.HtmlTableBlocked(dt, 0, isAdmin));
            builder.Append(MelBoxWeb.HtmlEditor(action));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
        public IHttpContext Login(IHttpContext context)
        {
            string caption = "Login";      //Überschrift der Seite
            string newGuid = string.Empty; //Nur füllen, wenn neue Benutzeranmeldung
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();

            if (args.ContainsKey("name") && args.ContainsKey("password"))
            {
                string name     = args["name"]; //.Replace('+', ' ');
                string password = args["password"];

                newGuid = MelBoxWeb.CheckLogin(name, password);

                if (newGuid.Length == 0)
                {
                    builder.Append(MelBoxWeb.HtmlAlert(2, "Login fehlgeschlagen", "Login für Benutzer '" + name + "' fehlgeschlagen.<br>Benutzer und Passwort korrekt?"));
                }
                else
                {
                    User newLogedInUser = MelBoxWeb.GetUserFromGuid(newGuid);
                    guid            = newGuid;
                    logedInUserName = newLogedInUser.Name;
                    logedInUserId   = newLogedInUser.Id;
                    isAdmin         = newLogedInUser.IsAdmin;
                }
            }

            if (guid.Length == 0 || logedInUserId == 0)
            {
                builder.Append(MelBoxWeb.HtmlLogin());
            }
            else
            {
                builder.Append(MelBoxWeb.HtmlAlert(4, isAdmin ? "Angemeldet als Administrator" : "Angemeldet als Benutzer", string.Format("[{0}] {1}", logedInUserId, logedInUserName)));
                builder.Append(MelBoxWeb.HtmlLogout());
            }
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), caption, logedInUserName, newGuid));
            return(context);
        }
Esempio n. 10
0
        public IHttpContext ResponseShiftEdit(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            int           shiftId     = 0;
            DateTime      date        = DateTime.MinValue;
            int           shiftUserId = logedInUserId;
            DataTable     dt          = Program.Sql.GetViewShift();
            StringBuilder builder     = new StringBuilder();

            if (args.ContainsKey("selectedRow"))
            {
                if (args["selectedRow"].StartsWith("Datum_"))
                {
                    DateTime.TryParse(args["selectedRow"].ToString().Substring(6), out date);
                }
                else
                {
                    int.TryParse(args["selectedRow"].ToString(), out shiftId);
                }
            }

            if (args.ContainsKey("selectedContact"))
            {
                int.TryParse(args["selectedContact"].ToString(), out shiftUserId);
            }
            else if (args.ContainsKey("ContactId"))
            {
                int.TryParse(args["ContactId"].ToString(), out shiftUserId);
            }

            builder.Append(MelBoxWeb.HtmlFormShift(date, shiftId, shiftUserId, isAdmin));

            const string infoTitel = "Info Bereitschaft";
            const string infoText  = "Eine Einheit Bereitschaft findet immer über einen Tageswechsel statt.<br> Am ausgewählten Datum zur Stunde 'Beginn' werden Nachrichten weitergeleitet bis zur Stunde 'Ende' am Folgetag.<br>" +
                                     "Ist beim Erstellen einer neuen Bereitschaft das Kästchen 'Bereitschaftswoche' angehakt wird die Bereitschaft für die komplette Kalenderwoche erstellt, in der das ausgewählte Datum liegt.";

            builder.Append(MelBoxWeb.HtmlInfoSidebar(infoTitel, infoText));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
Esempio n. 11
0
        public IHttpContext ResponseCompany(IHttpContext context)
        {
            string caption   = "Firmenkonto";
            int    companyId = 0;
            string payload   = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            if (args.ContainsKey("CompanyId"))
            {
                int.TryParse(args["CompanyId"].ToString(), out companyId);
            }

            //Dictionary<string, string> action = new Dictionary<string, string>();
            //if (isAdmin)
            //{
            //    action.Add("/company/create", "Firma neu anlegen");
            //    action.Add("/company/update", "Firmeninformationen ändern");
            //    action.Add("/company/delete", "Firma löschen");
            //}

            DataTable dtCompany = Program.Sql.GetCompany();

            StringBuilder builder = new StringBuilder();

            builder.Append(MelBoxWeb.HtmlFormCompany(dtCompany, companyId, isAdmin));
            //builder.Append(MelBoxWeb.HtmlEditor(action));

            int chosenContactId = logedInUserId;

            if (requestingPage == caption && args.ContainsKey("selectedContactId")) //Ist Antwort von dieser Seite
            {
                int.TryParse(args["selectedContactId"].ToString(), out chosenContactId);
            }
            else if (chosenContactId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Ungültiger Aufruf", "Für Einsicht Benutzerkonto bitte einloggen."));
            }

#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), caption, logedInUserName));
            return(context);
        }
Esempio n. 12
0
        public IHttpContext ResponseBlockedCreate(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            #region Inhalt ermitteln
            int recMsgId = MelBoxWeb.GetArgInt(args, "selectedRow");

            int contentId = Program.Sql.GetContentId(recMsgId);
            #endregion

            StringBuilder builder = new StringBuilder();

            if (contentId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler", "Die übergebene Nachricht konnte nicht zugeordnet werden."));
            }
            else
            {
                Program.Sql.InsertMessageBlocked(contentId);
                string msg = "Die Weiterleitung der Nachricht Nr. " + contentId + " wurde durch den Benutzer '" + logedInUserName + "' zu bestimmten Zeiten gesperrt.";

                builder.Append(MelBoxWeb.HtmlAlert(3, "Nachricht in die Sperrliste aufgenommen", msg));

                Program.Sql.Log(MelBoxSql.LogTopic.Shift, MelBoxSql.LogPrio.Warning, msg);
            }

            Dictionary <string, string> action = new Dictionary <string, string>();

            if (isAdmin)
            {
                action.Add("/blocked/update", "Gesperrte Nachricht bearbeiten");
                action.Add("/blocked/delete", "Aus Sperrliste entfernen");
            }

            DataTable dt = Program.Sql.GetViewMsgBlocked();
            builder.Append(MelBoxWeb.HtmlTableBlocked(dt, 0, isAdmin));
            builder.Append(MelBoxWeb.HtmlEditor(action));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
Esempio n. 13
0
        public IHttpContext ResponseRegister(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();

            builder.Append(MelBoxWeb.HtmlAlert(4, "Registrierung", "Anfragen zur Registrierung gehen an den Administrator, der sie händisch freigeschaltet. <br>Bei Anfrage bitte den gewünschten Nutzernamen angeben. <br>Nach Freischaltung bitte selbst unter 'Account' ein Passwort vergeben."));
            builder.Append(MelBoxWeb.HtmlAlert(2, "Bitte beachten", "Es ist zur Zeit keine Registrierungs-Prozedur implementiert. <a href='mailto:[email protected]'>Email</a>"));

#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Registrierung", logedInUserName));
            return(context);
        }
Esempio n. 14
0
        public IHttpContext ResponseAccountUpdate(IHttpContext context)
        {
            string payload = context.Request.Payload;

            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder         = new StringBuilder();
            int           chosenContactId = MelBoxWeb.GetArgInt(args, "ContactId");

            if (!isAdmin && chosenContactId != logedInUserId)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Berechtigung", "Sie haben keine Berechtigung den Benutzer zu ändern."));
            }
            else
            {
                builder.Append(MelBoxWeb.ProcessFormAccount(args, false));
            }

            if (logedInUserId != 0)
            {
                DataTable dt;
                if (isAdmin)
                {
                    dt = Program.Sql.GetViewContactInfo();
                }
                else
                {
                    dt = Program.Sql.GetViewContactInfo(chosenContactId);
                }

                DataTable dtCompany = Program.Sql.GetCompany();

                builder.Append(MelBoxWeb.HtmlFormAccount(dt, dtCompany, chosenContactId, isAdmin));
            }

#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Benutzerkonto ändern", logedInUserName));
            return(context);
        }
Esempio n. 15
0
        public IHttpContext ResponseAccountDelete(IHttpContext context)
        {
            string payload = context.Request.Payload;

            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();

            if (!isAdmin)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Berechtigung", "Sie haben keine Berechtigung den Benutzer zu löschen."));
            }
            else
            {
                int.TryParse(args["ContactId"].ToString(), out int contactId);
                string name = args["Name"];

                if (contactId == 0)
                {
                    builder.Append(MelBoxWeb.HtmlAlert(2, "Fehler", "Der Benutzer '" + name + "' konnte nicht gelöscht werden. Der Aufruf war fehlerhaft."));
                }
                else
                {
                    if (!Program.Sql.DeleteContact(contactId))
                    {
                        builder.Append(MelBoxWeb.HtmlAlert(2, "Fehler beim löschen von '" + name + "'", "Der Benutzer " + contactId + " '" + name + "' konnte nicht aus der Datenbank gelöscht werden."));
                    }
                    else
                    {
                        builder.Append(MelBoxWeb.HtmlAlert(3, "Benutzer '" + name + "' gelöscht", "Der Benutzer " + contactId + " '" + name + "' wurde aus der Datenbank gelöscht."));
                    }
                }
            }
#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Benutzerkonto löschen", logedInUserName));
            return(context);
        }
Esempio n. 16
0
        public IHttpContext ResponseCompanyDelete(IHttpContext context)
        {
            string payload = context.Request.Payload;

            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();

            if (!isAdmin)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Berechtigung", "Sie haben keine Berechtigung den Firmeneintrag zu löschen."));
            }
            else
            {
                int companyId = MelBoxWeb.GetArgInt(args, "CompanyId");
                if (companyId != 0)
                {
                    string name = MelBoxWeb.GetArgStr(args, "Name");//.Replace('+', ' ');
                    if (!Program.Sql.DeleteCompany(companyId))
                    {
                        builder.Append(MelBoxWeb.HtmlAlert(2, "Fehler beim Löschen von Firma '" + name + "'", "Die Firma '" + name + "' konnte nicht aus der Datenbank gelöscht werden."));
                    }
                    else
                    {
                        builder.Append(MelBoxWeb.HtmlAlert(3, "Firma '" + name + "'gelöscht", "Die Firma '" + name + "' wurde aus der Datenbank gelöscht."));
                    }
                }
                else
                {
                    builder.Append(MelBoxWeb.HtmlAlert(1, "Ungültiger Aufruf", "Die Firmeninformationen konnten nicht zugewiesen werden."));
                }
            }
#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Firmenkonto löschen", logedInUserName));
            return(context);
        }
Esempio n. 17
0
        public IHttpContext ResponseShiftCreateOrUpdate(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();

            if (logedInUserId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler", "Der eingeloggte Benutzer konnte nicht zugeordnet werden."));
            }
            else
            {
                builder.Append(MelBoxWeb.ProcessFormShift(args, logedInUserId, isAdmin));
            }

            #region Tabelle anzeigen
            Dictionary <string, string> action = new Dictionary <string, string>
            {
                { "/shift/edit", "Bereitschaft bearbeiten" }
            };

            if (isAdmin)
            {
                action.Add("/shift/delete", "Bereitschaft löschen");
            }

            DataTable dt = Program.Sql.GetViewShift();
            builder.Append(MelBoxWeb.HtmlTableShift(dt, 0, logedInUserId, isAdmin));
            builder.Append(MelBoxWeb.HtmlEditor(action));
            #endregion
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Bereitschaft erstellen", logedInUserName));
            return(context);
        }
Esempio n. 18
0
        private void ReadGlobalFields(Dictionary <string, string> args)
        {
            if (args.ContainsKey("guid"))
            {
                guid = args["guid"];
                User user = MelBoxWeb.GetUserFromGuid(guid);

                if (user != null)
                {
                    logedInUserName = user.Name;
                    logedInUserId   = user.Id;
                    isAdmin         = user.IsAdmin;
                }
            }

            if (args.ContainsKey("pageTitle"))
            {
                requestingPage = args["pageTitle"];
            }
#if DEBUG
            // Console.WriteLine("Aufruf von {0} durch: [{1}] {2} - Admin: {3} | {4}", requestingPage, logedInUserId, logedInUserName, isAdmin, guid);
#endif
        }
Esempio n. 19
0
        public IHttpContext ResponseLog(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            DateTime von = DateTime.UtcNow.AddDays(-2);
            DateTime bis = DateTime.UtcNow;

            string vonStr = MelBoxWeb.GetArgStr(args, "von");
            string bisStr = MelBoxWeb.GetArgStr(args, "bis");

            if (vonStr.Length > 9)
            {
                DateTime.TryParse(vonStr, out von);
            }

            if (bisStr.Length > 9)
            {
                DateTime.TryParse(bisStr, out bis);
            }

            DataTable dt = Program.Sql.GetViewLog(von, bis.AddDays(1));

            StringBuilder builder = new StringBuilder();


            builder.Append(MelBoxWeb.HtmlFormLog(von, bis));
            builder.Append(MelBoxWeb.HtmlTablePlain(dt, false));

#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
Esempio n. 20
0
        public IHttpContext ResponseCompanyUpdate(IHttpContext context)
        {
            string payload = context.Request.Payload;

            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();

            if (!isAdmin)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Berechtigung", "Sie haben keine Berechtigung den Firmeneintrag zu ändern."));
            }
            else
            {
                builder.Append(MelBoxWeb.ProcessFormCompany(args, false));
            }
#if DEBUG
            builder.Append("<p class='w3-pink w3-mobile'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Firmenkonto ändern", logedInUserName));
            return(context);
        }
        public static string ProcessFormShift(Dictionary <string, string> args, int logedInUserId, bool isAdmin)
        {
            StringBuilder builder = new StringBuilder();

            int      shiftUserId     = logedInUserId;
            int      shiftId         = 0;
            string   name            = "-KEIN NAME-";
            DateTime date            = DateTime.MinValue;
            int      beginHour       = 17;
            int      endHour         = 7;
            bool     createWeekShift = false;

            //  bool createNewShift = false;

            foreach (string arg in args.Keys)
            {
                switch (arg)
                {
                case "selectedRow":
                    if (args[arg].StartsWith("Datum_"))
                    {
                        DateTime.TryParse(args["selectedRow"].ToString().Substring(6), out date);
                    }
                    else
                    {
                        int.TryParse(args["selectedRow"].ToString(), out shiftId);
                    }
                    break;

                case "ContactId":
                    int.TryParse(args[arg].ToString(), out shiftUserId);
                    break;

                case "Name":
                    name = args[arg];    //.Replace('+', ' ');
                    break;

                case "Datum":
                    if (date == DateTime.MinValue)
                    {
                        date = DateTime.Parse(args["Datum"].ToString()).Date;
                    }
                    break;

                case "Beginn":
                    beginHour = int.Parse(args[arg]);
                    break;

                case "Ende":
                    endHour = int.Parse(args[arg]);
                    break;

                case "CreateWeekShift":
                    // if (args[arg].ToLower() == "on")
                    createWeekShift = true;
                    break;
                }
            }

            if (shiftUserId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler Zuordnung", string.Format("Der Benutzer konnte der Bereitschaft nicht zugewiesen werden.")));
                return(builder.ToString());
            }

            if (shiftId == 0)
            {
                //Neu erstellen
                DateTime firstStartTime = DateTime.Now;
                DateTime lastEndTime    = DateTime.Now;

                if (createWeekShift)
                {
                    date = date.AddDays(DayOfWeek.Monday - date.DayOfWeek);

                    for (int i = 0; i < 7; i++)
                    {
                        DateTime StartTime = MelBoxSql.ShiftStandardStartTime(date);
                        DateTime EndTime   = MelBoxSql.ShiftStandardEndTime(date);

                        if (i == 0)
                        {
                            firstStartTime = StartTime;
                        }
                        if (i == 6)
                        {
                            lastEndTime = EndTime;
                        }

                        Program.Sql.InsertShift(shiftUserId, StartTime, EndTime);
                        date = date.AddDays(1);
                    }
                }
                else
                {
                    DateTime StartTime = date.AddHours(beginHour);
                    DateTime EndTime   = date.AddDays(1).AddHours(endHour);

                    firstStartTime = StartTime;
                    lastEndTime    = EndTime;

                    Program.Sql.InsertShift(shiftUserId, StartTime, EndTime);
                }

                builder.Append(MelBoxWeb.HtmlAlert(3, "Neue Bereitschaft erstellt", string.Format("Neue Bereitschaft für '{0}' vom {1} bis {2} erstellt.", name, firstStartTime, lastEndTime)));
            }
            else
            {
                //Update
                if (shiftUserId != logedInUserId && !isAdmin)
                {
                    builder.Append(MelBoxWeb.HtmlAlert(2, "Nicht änderbar", string.Format("Sie können nur ihre eigenen Bereitschaftszeiten bearbeiten.")));
                }

                ////Admin: Darstellung anderer User
                //if (shiftUserId == 0) contactId = logedInContactId;
                //else logedInContactId = contactId;

                DateTime StartTime = date.AddHours(beginHour);
                DateTime EndTime   = date.AddDays(1).AddHours(endHour);

                if (!Program.Sql.UpdateShift(shiftId, shiftUserId, StartTime, EndTime))
                {
                    builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler Bereitschaft  Nr. " + shiftId + " bearbeiten",
                                                       string.Format("Die Bereitschaft konnte nicht in der Datenbank geändert werden.")));
                }
                else
                {
                    builder.Append(MelBoxWeb.HtmlAlert(3, "Bereitschaft Nr. " + shiftId + " geändert",
                                                       string.Format("Die Bereitschaft Nr. {0} wurde geändert auf {1} im Zeitraum {2} bis {3}.", shiftId, name, StartTime, EndTime)));
                }
            }


            return(builder.ToString());
        }
Esempio n. 22
0
        public IHttpContext ResponseBlockedUpdate(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            #region Inhalt ermitteln
            int recMsgId  = MelBoxWeb.GetArgInt(args, "selectedRow");
            int beginHour = MelBoxWeb.GetArgInt(args, "Beginn");
            int endHour   = MelBoxWeb.GetArgInt(args, "Ende");
            int contentId = recMsgId;
            #endregion

            StringBuilder builder = new StringBuilder();

            if (args.ContainsKey("Beginn") && args.ContainsKey("Ende"))
            {
                //int beginHour = int.Parse(args["Beginn"].ToString());
                //int endHour = int.Parse(args["Ende"].ToString());

                MelBoxSql.BlockedDays days = MelBoxSql.BlockedDays.None;
                if (args.ContainsKey("Mo"))
                {
                    days |= MelBoxSql.BlockedDays.Monday;
                }
                if (args.ContainsKey("Di"))
                {
                    days |= MelBoxSql.BlockedDays.Tuesday;
                }
                if (args.ContainsKey("Mi"))
                {
                    days |= MelBoxSql.BlockedDays.Wendsday;
                }
                if (args.ContainsKey("Do"))
                {
                    days |= MelBoxSql.BlockedDays.Thursday;
                }
                if (args.ContainsKey("Fr"))
                {
                    days |= MelBoxSql.BlockedDays.Friday;
                }
                if (args.ContainsKey("Sa"))
                {
                    days |= MelBoxSql.BlockedDays.Saturday;
                }
                if (args.ContainsKey("So"))
                {
                    days |= MelBoxSql.BlockedDays.Sunday;
                }

                if (Program.Sql.UpdateMessageBlocked(contentId, beginHour, endHour, days))
                {
                    builder.Append(MelBoxWeb.HtmlAlert(3, "Sperrzeiten geändert", "Die Sperrzeiten für Nachricht Nr. " + contentId + " wurden geändert."));
                }
                else
                {
                    builder.Append(MelBoxWeb.HtmlAlert(2, "Sperrzeiten nicht geändert", "Die Sperrzeiten für Nachricht Nr. " + contentId + " konnten nicht geändert werden."));
                }
            }

            Dictionary <string, string> action = new Dictionary <string, string>();

            if (isAdmin)
            {
                action.Add("/blocked/update", "Änderungen speichern");
                action.Add("/blocked/delete", "Aus Sperrliste entfernen");
            }

            DataTable dt = Program.Sql.GetViewMsgBlocked();
            builder.Append(MelBoxWeb.HtmlTableBlocked(dt, contentId, isAdmin));
            builder.Append(MelBoxWeb.HtmlEditor(action));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), dt.TableName, logedInUserName));
            return(context);
        }
        /// <summary>
        /// Verarbeitet die Anfrage aus dem Formular 'Benutzerkonto'
        /// </summary>
        /// <param name="args"></param>
        /// <param name="createNewAccount">Soll ein neuer Benutzer erstellt werden?</param>
        /// <returns>html - Rückmeldung der ausgeführten Operation</returns>
        public static string ProcessFormAccount(Dictionary <string, string> args, bool createNewAccount)
        {
            StringBuilder builder = new StringBuilder();

            int    contactId     = 0;
            string name          = "-KEIN NAME-";
            string password      = null;
            int    companyId     = -1;
            string email         = null;
            ulong  phone         = 0;
            int    sendSms       = 0; //Hinweis: <input type='checkbox' > wird nur übertragen, wenn angehakt => immer zurücksetzten, wenn nicht gesetzt
            int    sendEmail     = 0;
            int    maxInactivity = -1;

            foreach (string arg in args.Keys)
            {
                switch (arg)
                {
                //case "pageTitle":
                //    if (args[arg] != "Benutzerkonto")
                //    {
                //        builder.Append(MelBoxWeb.HtmlAlert(1, "Ungültiger Aufruf", "Aufruf von ungültiger Stelle."));
                //    }
                //    break;
                case "ContactId":
                    contactId = int.Parse(args[arg]);
                    break;

                case "Name":
                    name = args[arg];    //.Replace('+', ' ');
                    break;

                case "Passwort":
                    if (args[arg].Length > 1)
                    {
                        password = args[arg];
                    }
                    break;

                case "CompanyId":
                    companyId = int.Parse(args[arg]);
                    break;

                case "Email":
                    email = args[arg];
                    break;

                case "Telefon":
                    phone = GsmConverter.StrToPhone(args[arg]);
                    break;

                case "Max_Inaktiv":
                    maxInactivity = int.Parse(args[arg]);
                    break;

                case "SendSms":
                    if (args[arg].ToLower() == "on")
                    {
                        sendSms = 1;
                    }
                    else
                    {
                        sendSms = 0;
                    }
                    break;

                case "SendEmail":
                    if (args[arg].ToLower() == "on")
                    {
                        sendEmail = 1;
                    }
                    else
                    {
                        sendEmail = 0;
                    }
                    break;

                default:
                    break;
                }
            }

            if (createNewAccount)
            {
                if (password == null || password.Length < 4)
                {
                    builder.Append(MelBoxWeb.HtmlAlert(2, "Fehler - Passwort ungültig", "Das vergebene Passwort entspricht nicht den Vorgaben. Der Benutzer wird nicht erstellt."));
                }
                else
                {
                    int newId = Program.Sql.InsertContact(name, password, companyId, email, phone, maxInactivity, sendSms == 1, sendEmail == 1);
                    if (newId == 0)
                    {
                        builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler beim Schreiben in die Datenbank", "Der Benutzer '" + name + "' konnte nicht erstellt werden."));
                    }
                    else
                    {
                        builder.Append(MelBoxWeb.HtmlAlert(3, "Benutzer '" + name + "' erstellt", "Der Benutzer '" + name + "' wurde in der Datenbank neu erstellt."));
                    }
                }
            }
            else
            {
                if (!Program.Sql.UpdateContact(contactId, name, password, companyId, phone, sendSms, email, sendEmail, string.Empty, maxInactivity))
                {
                    builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Änderungen für Benutzer '" + name + "'", "Die Änderungen konnten nicht in die Datenbank übertragen werden."));
                }
                else
                {
                    builder.Append(MelBoxWeb.HtmlAlert(3, "Änderungen für Benutzer '" + name + "' übernommen", "Die Änderungen an Benutzer '" + name + "' wurden in der Datenbank gespeichert."));
                }
            }

            return(builder.ToString());
        }
Esempio n. 24
0
        public IHttpContext ResponseShiftDelete(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();
            int           shiftId = 0;

            if (args.ContainsKey("selectedRow"))
            {
                int.TryParse(args["selectedRow"].ToString(), out shiftId);
            }

            if (logedInUserId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler", "Der eingeloggte Benutzer konnte nicht zugeordnet werden."));
            }
            else if (!isAdmin)
            {
                builder.Append(MelBoxWeb.HtmlAlert(2, "Keine Berechtigung", "Sie besitzen nicht die notwendigen Rechte für diese Aktion."));
            }
            else if (shiftId == 0)
            {
                builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler Bereitschaft löschen", "Fehlerhafter Aufruf. Die zu löschende Bereitschaft konnte nicht zugeordnet werden."));
            }
            else
            {
                if (!Program.Sql.DeleteShift(shiftId))
                {
                    builder.Append(MelBoxWeb.HtmlAlert(1, "Fehler Bereitschaft  Nr. " + shiftId + " löschen",
                                                       string.Format("Die Bereitschaft konnte nicht aus der Datenbank gelöscht werden.")));
                }
                else
                {
                    string msg = string.Format("Die Bereitschaft Nr. {0} wurde durch den Benutzer '{1}' gelöscht.", shiftId, logedInUserName);

                    builder.Append(MelBoxWeb.HtmlAlert(3, "Bereitschaft Nr. " + shiftId + " gelöscht", msg));

                    Program.Sql.Log(MelBoxSql.LogTopic.Shift, MelBoxSql.LogPrio.Warning, msg);
                }
            }

            #region Tabelle anzeigen
            Dictionary <string, string> action = new Dictionary <string, string>
            {
                { "/shift/edit", "Bereitschaft bearbeiten" }
            };

            if (isAdmin)
            {
                action.Add("/shift/delete", "Bereitschaft löschen");
            }

            DataTable dt = Program.Sql.GetViewShift();

            builder.Append(MelBoxWeb.HtmlTableShift(dt, 0, logedInUserId, isAdmin));
            builder.Append(MelBoxWeb.HtmlEditor(action));
            #endregion

#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Bereitschaft löschen", logedInUserName));
            return(context);
        }
Esempio n. 25
0
        public IHttpContext ResponseGsm(IHttpContext context)
        {
            string payload = context.Request.Payload;
            Dictionary <string, string> args = MelBoxWeb.ReadPayload(payload);

            ReadGlobalFields(args);

            StringBuilder builder = new StringBuilder();

            #region Tabelle füllen
            DataTable dt = new DataTable();
            dt.Columns.Add("Parameter", typeof(string));
            dt.Columns.Add("Wert", typeof(string));

            string para  = "Status GSM-Modem";
            string value = GlobalProperty.ConnectedToModem ? "angeschlossen" : "keine Verbindung";
            dt.Rows.Add(para, value);

            //para = "Hersteller"; //Modem-Antort ohne +CNMI
            //value = GlobalProperty.ModemManufacturer;
            //dt.Rows.Add(para, value);

            para  = "SIM-Schubfach erkannt";
            value = GlobalProperty.SimHolderDetected ? "erkannt" : "nicht erkannt";
            dt.Rows.Add(para, value);

            para  = "Eigene Telefonnummer";
            value = "+" + GlobalProperty.OwnPhone;
            dt.Rows.Add(para, value);

            para  = "Registrierung Mobilfunknetz";
            value = GlobalProperty.NetworkRegistrationStatus;
            dt.Rows.Add(para, value);

            para  = "Mobilfunkanbieter";
            value = GlobalProperty.NetworkProviderName;
            dt.Rows.Add(para, value);

            para  = "SMS Service Center";
            value = GlobalProperty.NetworkServiceCenterNumber;
            dt.Rows.Add(para, value);

            para  = "Mobilfunknetz Empfangsqualität";
            value = string.Format("{0:0}%", GlobalProperty.GsmSignalQuality);
            dt.Rows.Add(para, value);

            para  = "Fehlende Empfangsbestätigungen";
            value = string.Format("{0}", GlobalProperty.SmsPendingReports);
            dt.Rows.Add(para, value);

            para  = "SMS-Text für Meldeweg Test";
            value = GlobalProperty.SmsRouteTestTrigger;
            dt.Rows.Add(para, value);

            para  = "Zuletzt gesendete SMS";
            value = GlobalProperty.LastSmsSend;
            dt.Rows.Add(para, value);
            #endregion

            builder.Append(MelBoxWeb.HtmlTablePlain(dt, false));
#if DEBUG
            builder.Append("<p class='w3-pink'>" + payload + "</p>");
#endif
            context.Response.SendResponse(MelBoxWeb.HtmlCanvas(builder.ToString(), "Status Modem", logedInUserName));
            return(context);
        }
Esempio n. 26
0
        private static void Main()
        {
            try
            {
                Console.BufferHeight = 1000; //Max. Zeilen in Konsole, bei Überlauf werden älteste Zeilen entfernt
                Console.WriteLine("Programm gestartet. Konsole mit max. {0} Zeilen.", Console.BufferHeight);

                Email.PermanentEmailRecievers = Properties.Settings.Default.PermanentEmailRecievers.Cast <string>().ToList();
                Email.MelBox2Admin            = new System.Net.Mail.MailAddress("*****@*****.**", "MelBox2 Admin"); //Properties gehen nicht?

                Gsm_Basics.ComPortName   = Properties.Settings.Default.ComPort;
                Gsm_Basics.BaudRate      = Properties.Settings.Default.BaudRate;
                Gsm_Basics.GsmConnected += HandleGsmEvent;
                Gsm_Basics.GsmEvent     += HandleGsmEvent;

                Gsm.GsmSignalQualityEvent += HandleGsmEvent;
                Gsm.SmsRecievedEvent      += HandleSmsRecievedEvent;
                Gsm.SmsSentEvent          += HandleSmsSentEvent;
                Gsm.SmsStatusreportEvent  += HandleSmsStatusReportEvent;

                MelBoxWeb.StartWebServer();

                Sql.Log(MelBoxSql.LogTopic.Start, MelBoxSql.LogPrio.Info, string.Format("MelBox2 - Anwendung gestartet. {0}, {1} Baud", Gsm_Basics.ComPortName, Gsm_Basics.BaudRate));

                InitDailyCheck(Properties.Settings.Default.HourOfDailyCheck);   //Führt täglich morgens um 8 Uhr Routinecheck aus

                //TEST
                Sql.InsertMessageRec("Testnachricht am " + DateTime.Now.Date, 4915142265412);

                //Auskommentiert für Test WebServer
                Gsm.Connect();

#if DEBUG
                Console.WriteLine("\r\nDEBUG Mode: es wird keine StartUp-Info an MelBox2-Admin gesendet.");
                //Email.Send(Email.MelBox2Admin, "MelBox2 - Anwendung neu gestartet um " + DateTime.Now);
#else
                //Gsm.SmsSend(Properties.Settings.Default.MelBoxAdminPhone, "MelBox2 - Anwendung neu gestartet um " + DateTime.Now); //besser Email
                Email.Send(Email.MelBox2Admin, "MelBox2 - Anwendung neu gestartet um " + DateTime.Now);
#endif

                const string help = "\r\n- ENTF zum Aufräumen der Anzeige\r\n" +
                                    "- EINF für AT-Befehl\r\n" +
                                    "- ESC Taste zum beenden...\r\n";

                Console.WriteLine(help);

                while (true)
                {
                    ConsoleKeyInfo pressed = Console.ReadKey();
                    //Console.WriteLine("Gedrückt: " + pressed.KeyChar);

                    if (pressed.Key == ConsoleKey.Escape)
                    {
                        break;
                    }

                    if (pressed.Key == ConsoleKey.Delete)
                    {
                        Console.Clear();
                        GlobalProperty.ShowOnConsole();
                        Console.WriteLine(help);
                    }

                    //if (pressed.Key == ConsoleKey.O)
                    //{
                    //    Console.Clear();
                    //    GlobalProperty.ShowOnConsole();
                    //    //Console.WriteLine("\r\nOPTIONEN:\r\n\tModem: Umschalten eingehend");
                    //    //Console.WriteLine((byte)GsmEventArgs.Telegram.GsmError + ":\t" + GsmEventArgs.Telegram.GsmError);
                    //    //Console.WriteLine((byte)GsmEventArgs.Telegram.GsmSystem + ":\t" + GsmEventArgs.Telegram.GsmSystem);
                    //    //Console.WriteLine((byte)GsmEventArgs.Telegram.GsmConnection + ":\t" + GsmEventArgs.Telegram.GsmConnection);
                    //    //Console.WriteLine((byte)GsmEventArgs.Telegram.GsmSignal + ":\t" + GsmEventArgs.Telegram.GsmSignal);
                    //    //Console.WriteLine((byte)GsmEventArgs.Telegram.GsmOwnPhone + ":\t" + GsmEventArgs.Telegram.GsmOwnPhone);
                    //    //Console.WriteLine((byte)GsmEventArgs.Telegram.GsmOwnPhone + ":\t" + GsmEventArgs.Telegram.GsmOwnPhone);

                    //    //Console.WriteLine("Konsolenanzeige: Bitweise Filter setzten (sperren):");
                    //    //Console.WriteLine("\r\n\tBitte Nummer auswählen.");

                    //    //string input = Console.ReadLine();
                    //    //if (byte.TryParse(input, out byte a))
                    //    //{
                    //    //    ConsoleDisplayBlock = a;
                    //    //}

                    //    Console.Clear();
                    //    Console.WriteLine(help);
                    //}

                    if (pressed.Key == ConsoleKey.Insert)
                    {
                        Console.WriteLine("AT-Befehl eingeben:");
                        string at = Console.ReadLine();
                        Gsm_Basics.AddAtCommand(at);
                    }
                }
            }
            finally
            {
                Console.WriteLine("Programm wird geschlossen...");
                MelBoxWeb.StopWebServer();
                Gsm_Basics.ClosePort();
                System.Threading.Thread.Sleep(3000);
            }
        }