Exemplo n.º 1
0
        private void DivideIncomingMessage(byte[] context, Socket socket)
        {
            string command = Encoding.ASCII.GetString(context);
            //Console.WriteLine("Received: " + command);
            string cleanCommand = command.Substring(0, command.IndexOf(';'));

            Console.WriteLine("Received: " + cleanCommand);
            Database db = new Database();

            if (cleanCommand.StartsWith("DB"))
            {
                DbCheck check = db.IsDatabaseReachable();
                if (check.Reachable)
                {
                    CommandHandling handling = new CommandHandling(cleanCommand, socket);
                    handling.DatabaseCommandsHandler();
                }
                else
                {
                    Console.WriteLine($"{prefix}Received command for Database-data, but can not reach Database.\nServer is not connected to 'vdi.fhict.nl' via a VPN connection.\n{check.SqlException.Message}");
                }
            }
            else if (cleanCommand.StartsWith("ARD"))
            {
            }
        }
Exemplo n.º 2
0
 public void InitializeSerialProcessing()
 {
     serialMessenger.Connect();
     Console.WriteLine($"{prefix}Waiting for Serial communication on: {portname}");
     while (true)
     {
         string[] messages = serialMessenger.ReadMessages();
         if (messages != null)
         {
             foreach (string message in messages)
             {
                 Console.WriteLine(prefix + message);
                 if (message.StartsWith("DB"))
                 {
                     handling = new CommandHandling(message, serialMessenger);
                     handling.DatabaseCommandsHandler();
                 }
             }
         }
         else if (serialMessenger.IsDisconnected)
         {
             Console.WriteLine($"{prefix}Port: {portname} was disconnected.");
         }
     }
 }