Example #1
0
        static void Main()
        {
            // Set the window title to something a bit more interesting.
            if (!Console.IsOutputRedirected)
            {
                Console.Title = "LogFeed V0.1";
            }

            // Check the credentials are provided in the application's configuration file.
            if (ConfigurationManager.AppSettings["Username"] == null || ConfigurationManager.AppSettings["Password"] == null || ConfigurationManager.AppSettings["Host"] == null)
            {
                Console.WriteLine("Program cannot start, some credentials were missing in the program's configuration file.");

                // Exit the application.
                Environment.Exit(1610);
            }

            // The WebClient allows us to get a valid SessionID to then use with the StatsConnection.
            using (WebClient webClient = new WebClient("https://" + ConfigurationManager.AppSettings["Host"] + "/"))
            {
                // This method will be invoked each time the timer has elapsed.
                sessionHeartbeatTimer.Elapsed += (s, a) => webClient.Heartbeat();

                // Ignore TLS certificate errors if there is a ".crt" file present that matches this host.
                webClient.AllowLocalCertificates();

                // Login to the router.
                webClient.Login(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]);

                // Share a valid SessionID with a new StatsConnection object.
                statsConnection = new StatsConnection(webClient.SessionID);

                // Ignore TLS certificate errors if there is a ".crt" file present that matches this host.
                statsConnection.AllowLocalCertificates();

                // Connect to the router.
                statsConnection.ConnectAsync(new Uri("wss://" + ConfigurationManager.AppSettings["Host"] + "/ws/stats"));

                // Setup an event handler for when data is received.
                statsConnection.DataReceived += Connection_DataReceived;

                // Setup an event handler for when the connection state changes.
                statsConnection.ConnectionStatusChanged += Connection_ConnectionStatusChanged;

                // We want the user (and the program itself) to be able to choose to exit.
                Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs eventArgs)
                {
                    // Mark as handled by us, as we will want to clean up.
                    eventArgs.Cancel = true;

                    // Signal to the program that the user wishes to quit.
                    WantToQuit.Set();
                };

                // Wait for something (user requested to quit, program finished..) to signal we should resume.
                WantToQuit.WaitOne();
            }
        }
Example #2
0
        static void Main()
        {
            // Set the window title to something a bit more interesting.
            if (!Console.IsOutputRedirected)
            {
                Console.Title = "WebClient Demo V0.1";
            }

            // Check the credentials are provided in the application's configuration file.
            if (ConfigurationManager.AppSettings["Username"] == null || ConfigurationManager.AppSettings["Password"] == null || ConfigurationManager.AppSettings["Host"] == null)
            {
                Console.WriteLine("Program cannot start, some credentials were missing in the program's configuration file.");

                // Exit the application.
                Environment.Exit(1610);
            }

            // EdgeOS requires logins and session heartbeats to be sent via the REST API.
            WebClient webClient = new WebClient("https://" + ConfigurationManager.AppSettings["Host"] + "/");

            // Ignore TLS certificate errors if there is a ".crt" file present that matches this host.
            webClient.AllowLocalCertificates();

            // Login to the router.
            webClient.Login(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]);

            // Edge - General
            //EdgeGeneralTests(webClient);

            // Edge - Configuration
            //EdgeConfigurationTests(webClient);

            // Edge - Optical Network Unit (ONU)
            //EdgeONUTests(webClient);

            // Edge - Operations
            //EdgeOperationsTests(webClient);

            // Optical Line Terminal (OLT) - General
            //OLTGeneralTests(webClient);

            // Optical Line Terminal (OLT) - Optical Network Unit (ONU)
            //OLTConnectedONUTests(webClient);

            // Wizards

            // Logout of the router.
            webClient.Logout();
        }
Example #3
0
        /// <summary>Method which dynamically adds some series of data to the chart and connects to the EdgeOS device once the form is ready.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">THe <see cref="EventArgs"/> instance containing the event data.</param>
        private void FormBandwidthChart_Load(object sender, EventArgs e)
        {
            // Check the credentials are provided in the application's configuration file.
            if (ConfigurationManager.AppSettings["Username"] == null || ConfigurationManager.AppSettings["Password"] == null || ConfigurationManager.AppSettings["Host"] == null)
            {
                MessageBox.Show("Program cannot start, some credentials were missing in the program's configuration file.", "Missing Credentials", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            // We want to control the ordering of some of the series so we can control the colours.
            for (int count = 0; count < NumberOfEthInterfaces; count++)
            {
                bandwidthChart.Series.Add(new Series("eth" + count + "Rx")
                {
                    ChartArea = "ChartAreaRx", ChartType = SeriesChartType.StackedColumn, Color = paletteColors[count]
                });
                bandwidthChart.Series.Add(new Series("eth" + count + "Tx")
                {
                    ChartArea = "ChartAreaTx", ChartType = SeriesChartType.StackedColumn, Color = paletteColors[count]
                });
            }

            // This method will be invoked each time the timer has elapsed.
            sessionHeartbeatTimer.Elapsed += (s, a) => webClient.Heartbeat();

            // The WebClient allows us to get a valid SessionID to then use with the StatsConnection.
            webClient = new WebClient("https://" + ConfigurationManager.AppSettings["Host"] + "/");

            // Ignore TLS certificate errors if there is a ".crt" file present that matches this host.
            webClient.AllowLocalCertificates();

            // Login to the Router.
            webClient.Login(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]);

            // Share a valid SessionID with a new StatsConnection object.
            statsConnection = new StatsConnection(webClient.SessionID);

            // Ignore TLS certificate errors if there is a ".crt" file present that matches this host.
            statsConnection.AllowLocalCertificates();

            // Connect to the router.
            statsConnection.ConnectAsync(new Uri("wss://" + ConfigurationManager.AppSettings["Host"] + "/ws/stats"));

            // Setup an event handler for when data is received.
            statsConnection.DataReceived += Connection_DataReceived;

            // Setup an event handler for when the connection state changes.
            statsConnection.ConnectionStatusChanged += Connection_ConnectionStatusChanged;
        }
Example #4
0
        static void Main(string[] args)
        {
            // Set the window title to something a bit more interesting.
            if (!Console.IsOutputRedirected)
            {
                Console.Title = "ConfigurationTreeWalker V0.1";
            }

            // Check the credentials are provided in the application's configuration file.
            if (ConfigurationManager.AppSettings["Username"] == null || ConfigurationManager.AppSettings["Password"] == null || ConfigurationManager.AppSettings["Host"] == null)
            {
                Console.WriteLine("Program cannot start, some credentials were missing in the program's configuration file.");

                // Exit the application.
                Environment.Exit(1610);
            }

            // EdgeOS requires logins and session heartbeats to be sent via the REST API.
            using (WebClient webClient = new WebClient("https://" + ConfigurationManager.AppSettings["Host"] + "/"))
            {
                // Ignore TLS certificate errors if there is a ".crt" file present that matches this host.
                webClient.AllowLocalCertificates();

                // Login to the router.
                webClient.Login(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]);

                // If the folder exists, delete it then recreate it.
                if (Directory.Exists("Configuration"))
                {
                    Console.WriteLine("Deleting old configuration; please wait.");
                    Directory.Delete("Configuration", true);
                }

                // Start walking the classes.
                CreateClass(webClient, null);

                // Create the Configuration Boolean helper class.
                CreateConfigurationBoolClass();
            }
        }