Пример #1
0
        private static bool ParseConsoleInput(string request)
        {
            bool run = true;

            string[] words = request.Split(' ', StringSplitOptions.RemoveEmptyEntries);
            if (words.Length < 1)
            {
                return(run);
            }

            switch (words[0].ToLower())
            {
            case "exit":
                run = false;
                break;

            case "email":
                if (words[1].ToLower() == "test")
                {
                    Email.Send(Email.Admin, "Test-Email von MelBox2");
                }
                break;

            case "sms":
                if (words[1].ToLower() == "sim")
                {
                    Console.WriteLine("Simuliere SMS-Empfang...");
                    ParseSms sms = new ParseSms
                    {
                        Message = "Dies ist eine MelBox2-Testnachricht. Bitte ignorieren.",
                        TimeUtc = DateTime.Now,
                        Sender  = Environment.MachineName
                    };

                    Gsm_SmsRecievedEvent(null, sms);
                }
                else
                {
                    string msg = string.Empty;

                    for (int i = 2; i < words.Length; i++)
                    {
                        msg += words[i];
                    }

                    Gsm.Ask_SmsSend(words[1], msg);
                }
                break;

            case "debug":
                if (words.Length > 1)
                {
                    if (int.TryParse(words[1], out int debug))
                    {
                        Gsm.Debug = debug;
                        Console.WriteLine("Debug = " + Gsm.Debug);
                    }
                }
                break;

            case "decode":
                if (words.Length > 1)
                {
                    string ucs2 = words[1].Trim();
                    Console.WriteLine(Gsm.DecodeUcs2(ucs2));
                }
                break;

            case "help":
                ShowHelp();
                break;

            default:
                if (request.Length > 1)
                {
                    Gsm.Write(request);
                }
                break;
            }

            return(run);
        }