public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the
                String[] PowerSensorConfigFileContent = File.ReadAllLines(Configfilename);
                Int32    LineNumber = 0;

                foreach (String LineElement in PowerSensorConfigFileContent)
                {
                    String[] TokenizedLine = LineElement.Split(new char[1] {
                        ' '
                    });
                    LineNumber++;

                    if (!LineElement.StartsWith("#"))
                    {
                        PowerConsumptionSensor NewElement = new PowerConsumptionSensor();

                        if (TokenizedLine.Length == 4)
                        {
                            NewElement.PowerSensorName         = TokenizedLine[0];
                            NewElement.InitialPowerSensorValue = Convert.ToDouble(TokenizedLine[2]);
                            NewElement.Corrector = Convert.ToDouble(TokenizedLine[3]);

                            if (DateTime.TryParse(TokenizedLine[1].Replace('_', ' '), out NewElement.InitialPowerSensorDate))
                            {
                                PowerConsumptionSensors.Add(NewElement);
                            }
                            else
                            {
                                throw (new Exception("Power Sensor Configuration File - Error in line " + LineNumber + " - Could not parse DateTime"));
                            }
                        }
                        else
                        {
                            throw (new Exception("Power Sensor Configuration File - Error in line " + LineNumber));
                        }
                    }
                }
            }
            else
            {
                throw (new Exception("Power Sensor Configuration File not found!"));
            }
        }
Exemple #2
0
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the
                String[] ProxyConfigFileContent = File.ReadAllLines(Configfilename);
                Int32    LineNumber             = 0;

                foreach (String LineElement in ProxyConfigFileContent)
                {
                    String[] TokenizedLine = LineElement.Split(new char[1] {
                        ' '
                    });
                    LineNumber++;

                    if (!LineElement.StartsWith("#"))
                    {
                        ProxyElement NewElement = new ProxyElement();

                        if (TokenizedLine.Length == 2)
                        {
                            NewElement.ActivationURL      = TokenizedLine[0];
                            NewElement.OutgoingMappingURL = TokenizedLine[1];

                            ProxyElements.Add(NewElement);
                        }
                        else
                        {
                            throw (new Exception("HTTPProxy Configuration File - Error in line " + LineNumber));
                        }
                    }
                }
            }
            else
            {
                throw (new Exception("HTTPProxy Configuration File not found!"));
            }
        }
Exemple #3
0
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the
                String[] ConfigFileContent = File.ReadAllLines(Configfilename);
                Int32    LineNumber        = 0;

                foreach (String LineElement in ConfigFileContent)
                {
                    String[] TokenizedLine = LineElement.Split(new char[1] {
                        ' '
                    });
                    LineNumber++;

                    if (!LineElement.StartsWith("#"))
                    {
                        NetworkMonitoringHost NewElement = new NetworkMonitoringHost();

                        if (TokenizedLine.Length == 2)
                        {
                            NewElement.IPAdressOrHostname = TokenizedLine[0];
                            NewElement.Descriptor         = TokenizedLine[1];

                            NetworkHosts.Add(NewElement);
                        }
                        else
                        {
                            throw (new Exception("NetworkMonitoring Host Configuration File - Error in line " + LineNumber));
                        }
                    }
                }
            }
            else
            {
                throw (new Exception("NetworkMonitoring Host Configuration File  not found!"));
            }
        }
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the
                String[] ActorConfigFileContent = File.ReadAllLines(Configfilename);
                Int32    LineNumber             = 0;

                foreach (String LineElement in ActorConfigFileContent)
                {
                    String[] TokenizedLine = LineElement.Split(new char[1] {
                        ' '
                    });
                    LineNumber++;

                    if (!LineElement.StartsWith("#"))
                    {
                        ScriptingActorElement NewElement = new ScriptingActorElement();

                        if (TokenizedLine.Length == 4)
                        {
                            NewElement.SensorToWatchName = TokenizedLine[0];
                            NewElement.SensorValue       = Convert.ToDouble(TokenizedLine[1]);
                            NewElement.ActorToSwitchName = TokenizedLine[2];
                            if (TokenizedLine[3].ToUpper() == "ON")
                            {
                                NewElement.ActionToRunName = actor_status.On;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "OFF")
                            {
                                NewElement.ActionToRunName = actor_status.Off;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "ONOFF")
                            {
                                NewElement.ActionToRunName = actor_status.OnOff;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "ONWAITOFF")
                            {
                                NewElement.ActionToRunName = actor_status.OnWaitOff;
                            }
                            else
                            if (TokenizedLine[3].ToUpper() == "URL")
                            {
                                NewElement.ActionToRunName = actor_status.URL;
                            }

                            ScriptingActorActions.Add(NewElement);
                        }
                        else
                        {
                            throw (new Exception("Scripting Actor Configuration File - Error in line " + LineNumber));
                        }
                    }
                }
            }
            else
            {
                throw (new Exception("Scripting Actor Configuration File not found! (" + Configfilename + ")"));
            }
        }
Exemple #5
0
        public static void ReadConfiguration(String Configfilename)
        {
            if (File.Exists(Configfilename))
            {
                // get all lines from the
                String[] TimerConfigFileContent = File.ReadAllLines(Configfilename);
                Int32    LineNumber             = 0;

                foreach (String LineElement in TimerConfigFileContent)
                {
                    String[] TokenizedLine = LineElement.Split(new char[1] {
                        ' '
                    });
                    LineNumber++;

                    if (!LineElement.StartsWith("#"))
                    {
                        ScriptingTimerElement NewElement = new ScriptingTimerElement();

                        if (TokenizedLine.Length == 9)
                        {
                            NewElement.TimerName = TokenizedLine[0];

                            if (!DateTime.TryParse(TokenizedLine[1].Replace('_', ' '), out NewElement.Start))
                            {
                                throw (new Exception("Scripting Timers Configuration File - Error in line " + LineNumber + " - Could not parse Start DateTime"));
                            }
                            if (!DateTime.TryParse(TokenizedLine[2].Replace('_', ' '), out NewElement.End))
                            {
                                throw (new Exception("Scripting Timers Configuration File - Error in line " + LineNumber + " - Could not parse End DateTime"));
                            }

                            NewElement.Duration_Start = Convert.ToInt32(TokenizedLine[3]);
                            NewElement.Duration_End   = Convert.ToInt32(TokenizedLine[4]);

                            if (TokenizedLine[5].ToUpper() == "ONOFF")
                            {
                                NewElement.OperationMode = scripting_timer_operation_modes.OnOff;
                            }

                            NewElement.SwitchName = TokenizedLine[6];

                            if (TokenizedLine[7].ToUpper() == "YES")
                            {
                                NewElement.Jitter = true;
                            }
                            else
                            {
                                NewElement.Jitter = false;
                            }

                            NewElement.MinimumOnTime = Convert.ToInt32(TokenizedLine[8]);

                            ScriptingTimerActions.Add(NewElement);
                        }
                        else
                        {
                            throw (new Exception("Scripting Timer Configuration File - Error in line " + LineNumber));
                        }
                    }
                }
            }
            else
            {
                throw (new Exception("Scripting Timer Configuration File not found!"));
            }
        }