From 9e12be1a15fecebafd83e5ef6e1871c24cc719b5 Mon Sep 17 00:00:00 2001 From: Stricted Date: Sat, 9 Jan 2016 19:24:08 +0100 Subject: [PATCH] add interface page --- SpeedportHybridControl/App.xaml | 1 + .../Data/SpeedportHybrid.cs | 41 +++++++++++++ SpeedportHybridControl/MainWindow.xaml | 1 + SpeedportHybridControl/Model/InterfaceList.cs | 58 +++++++++++++++++++ .../PageModel/InterfacePageModel.cs | 43 ++++++++++++++ .../PageModel/LoginPageModel.cs | 2 + .../PageModel/MainWindowModel.cs | 35 +++++++++++ .../SpeedportHybridControl.csproj | 10 +++- SpeedportHybridControl/ltepopup.xaml | 10 +--- SpeedportHybridControl/ltepopup.xaml.cs | 9 ++- .../page/InterfacePage.xaml | 35 +++++++++++ .../page/InterfacePage.xaml.cs | 25 ++++++++ 12 files changed, 260 insertions(+), 10 deletions(-) create mode 100644 SpeedportHybridControl/Model/InterfaceList.cs create mode 100644 SpeedportHybridControl/PageModel/InterfacePageModel.cs create mode 100644 SpeedportHybridControl/page/InterfacePage.xaml create mode 100644 SpeedportHybridControl/page/InterfacePage.xaml.cs diff --git a/SpeedportHybridControl/App.xaml b/SpeedportHybridControl/App.xaml index 17cacfb..160dd15 100644 --- a/SpeedportHybridControl/App.xaml +++ b/SpeedportHybridControl/App.xaml @@ -18,6 +18,7 @@ + diff --git a/SpeedportHybridControl/Data/SpeedportHybrid.cs b/SpeedportHybridControl/Data/SpeedportHybrid.cs index ac6a427..d1a061f 100644 --- a/SpeedportHybridControl/Data/SpeedportHybrid.cs +++ b/SpeedportHybridControl/Data/SpeedportHybrid.cs @@ -832,5 +832,46 @@ namespace SpeedportHybridControl.Data { LogManager.WriteToLog(ex.Message); } } + + public static void initInterface () { + try { + if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false)) + return; + + InterfacePageModel IPM = Application.Current.FindResource("InterfacePageModel") as InterfacePageModel; + + string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/interfaces.json"); + if (response.IsNullOrEmpty()) + return; + + JToken jArray = JToken.Parse(response); + response = null; + + List interfaceList = new List(); + foreach (JToken jToken in jArray.SelectToken("line_status")) { + string ifc = jToken.SelectToken("interface").ToString(); + string mtu = jToken.SelectToken("MTU").ToString(); + string tx_packets = jToken.SelectToken("tx_packets").ToString(); + string tx_errors = jToken.SelectToken("tx_errors").ToString(); + string rx_packets = jToken.SelectToken("rx_packets").ToString(); + string rx_errors = jToken.SelectToken("rx_errors").ToString(); + string collisions = jToken.SelectToken("collisions").ToString(); + + interfaceList.Add(new InterfaceList() { ifc = ifc, mtu = mtu, tx_packets = tx_packets, tx_errors = tx_errors, rx_packets = rx_packets, rx_errors = rx_errors, collisions = collisions }); + } + + IPM.interfaceList = interfaceList; + + interfaceList = null; + jArray = null; + + DateTime time = DateTime.Now; + string format = "dd.MM.yyyy HH:mm:ss"; + IPM.datetime = time.ToString(format); + } + catch (Exception ex) { + LogManager.WriteToLog(ex.Message); + } + } } } diff --git a/SpeedportHybridControl/MainWindow.xaml b/SpeedportHybridControl/MainWindow.xaml index 24a8ff9..88294ae 100644 --- a/SpeedportHybridControl/MainWindow.xaml +++ b/SpeedportHybridControl/MainWindow.xaml @@ -29,6 +29,7 @@