public static void LoadConfiguration()
        {
            string config;
            string configFile = string.Format("{0}", Assembly.GetEntryAssembly().Location.Replace("Bus.exe", "config.json"));

            if (!File.Exists(configFile))
            {
                File.Create(configFile);
            }

            using (StreamReader configReader = new StreamReader(configFile))
            {
                config = configReader.ReadToEnd();
                try
                {
                    Bus.Model   = JsonConvert.DeserializeObject <BusConfig>(config);
                    validConfig = true;
                }
                catch (Exception e)
                {
                    Console.WriteLine(ConsoleFunctions.WriteWithColour(ConsoleColor.Red, "INVALID CONFIGURATION FILE"));
                    BusLogger.LogException(e);
                    validConfig = false;
                }
                finally
                {
                    configReader.Close();
                }
            }

            BusCCTV.CheckHDDUsage();
            BusCCTV.CheckDriveHealth();
        }
Ejemplo n.º 2
0
 private static void CheckWindows()
 {
     Bus.Model.Windows.ForEach(window =>
     {
         Console.Write(string.Format("{0, -1} | {1,-12} |  ", ConsoleFunctions.WriteWithColour(ConsoleColor.Cyan, "Window"), window.Name));
         ConsoleFunctions.WriteWithColour(StateColour(window.State), $"{openingStatuses[window.State]}\n");
     });
 }
Ejemplo n.º 3
0
 private static void CheckSensors()
 {
     Bus.Model.Sensors.ForEach(sensor =>
     {
         Console.Write(string.Format("{0, -1} | {1,-12} |  ", ConsoleFunctions.WriteWithColour(ConsoleColor.Cyan, "Sensor"), sensor.Name));
         ConsoleFunctions.WriteWithColour(StateColour(sensor.State), $"{openingStatuses[sensor.State]}\n");
     });
 }
Ejemplo n.º 4
0
 private static void CheckCameras()
 {
     Bus.Model.Cameras.ForEach(camera =>
     {
         Console.Write(string.Format("{0, -3} | {1,-12} |  ", ConsoleFunctions.WriteWithColour(ConsoleColor.Cyan, "CCTV"), camera.Name));
         ConsoleFunctions.WriteWithColour(StateColour(camera.State), $"{cameraStatuses[camera.State]}\n");
     });
 }