--- /dev/null
+using System;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Controls;
+
+namespace SpeedportHybridControl.Implementations
+{
+ // https://social.msdn.microsoft.com/Forums/vstudio/en-US/fb0745f0-6c26-4a9e-b792-3f7e8484b243/allow-only-number-in-textbox?forum=wpf#8acf76ea-7667-4763-a837-473ea2b03fa5
+ public class NumberTextBox : TextBox
+ {
+ static NumberTextBox()
+ {
+ EventManager.RegisterClassHandler(
+ typeof(NumberTextBox),
+ DataObject.PastingEvent,
+ (DataObjectPastingEventHandler)((sender, e) =>
+ {
+ if (!IsDataValid(e.DataObject))
+ {
+ DataObject data = new DataObject();
+ data.SetText(String.Empty);
+ e.DataObject = data;
+ e.Handled = false;
+ }
+ }));
+ }
+
+ protected override void OnDrop(DragEventArgs e)
+ {
+ e.Handled = !IsDataValid(e.Data);
+ base.OnDrop(e);
+ }
+
+ protected override void OnDragOver(DragEventArgs e)
+ {
+ if (!IsDataValid(e.Data))
+ {
+ e.Handled = true;
+ e.Effects = DragDropEffects.None;
+ }
+
+ base.OnDragEnter(e);
+ }
+
+ private static Boolean IsDataValid(IDataObject data)
+ {
+ Boolean isValid = false;
+ if (data != null)
+ {
+ String text = data.GetData(DataFormats.Text) as String;
+ if (!String.IsNullOrEmpty(text == null ? null : text.Trim()))
+ {
+ Int32 result = -1;
+ if (Int32.TryParse(text, out result))
+ {
+ if (result > 0)
+ {
+ isValid = true;
+ }
+ }
+ }
+ }
+
+ return isValid;
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ if (e.Key < Key.D0 || e.Key > Key.D9)
+ {
+ if (e.Key < Key.NumPad0 || e.Key > Key.NumPad9)
+ {
+ if (e.Key != Key.Back)
+ {
+ e.Handled = true;
+ }
+ }
+ }
+ }
+ }
+}
<Compile Include="Cryptography.cs" />
<Compile Include="DelegateCommand.cs" />
<Compile Include="LogManager.cs" />
+ <Compile Include="NumberTextBox.cs" />
<Compile Include="PasswordHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
return;
DslPageModel dsl = Application.Current.FindResource("DslPageModel") as DslPageModel;
-
+
string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/dsl.json");
if (response.IsNullOrEmpty())
return;
return;
SyslogPageModel syslog = Application.Current.FindResource("SyslogPageModel") as SyslogPageModel;
-
- string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/SystemMessages.json");
+ string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/Syslog.json", string.Concat("csrf_token=",SpeedportHybridAPI.getInstance().getToken(), "&exporttype=0"));
if (response.IsNullOrEmpty())
return;
- JToken jArray = JToken.Parse(response);
- response = null;
-
+ string[] lines = response.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
List<SyslogList> syslogList = new List<SyslogList>();
- foreach (JToken jToken in jArray)
+ foreach (string line in lines)
{
- JToken varid = jToken["varid"];
- if (varid.ToString().Equals("addmessage"))
- {
- var a = jToken["varvalue"];
- var stamp = a[1]["varvalue"];
- var msg = a[2]["varvalue"];
-
- // login
- if (msg.ToString().Contains("(G101)").Equals(true))
- continue;
+ // first line / last line
+ if ((line.Contains("Datum/Uhrzeit") && line.Contains("Meldung")) || line.IsNullOrEmpty())
+ continue;
- // logout
- if (msg.ToString().Contains("(G102)").Equals(true))
- continue;
+ // login
+ if (line.Contains("(G101)").Equals(true))
+ continue;
- // session timeout
- if (msg.ToString().Contains("(G103)").Equals(true))
- continue;
+ // logout
+ if (line.Contains("(G102)").Equals(true))
+ continue;
- // dnsv6 error
- if (msg.ToString().Contains("(P008)").Equals(true))
- continue;
+ // session timeout
+ if (line.Contains("(G103)").Equals(true))
+ continue;
- // Funkzellen Info
- if (msg.ToString().Contains("(LT004)") && isLTE.Equals(true))
- {
- LteInfoModel lte = Application.Current.FindResource("LteInfoModel") as LteInfoModel;
+ // dnsv6 error
+ if (line.Contains("(P008)").Equals(true))
+ continue;
- string[] parts = msg.ToString().Split(',');
- string frequenz = parts[2];
+ string[] parts;
- if (frequenz.Equals("20"))
- {
- frequenz = "800 MHz";
- }
- else if (frequenz.Equals("3"))
- {
- frequenz = "1800 MHz";
- }
- else if (frequenz.Equals("7"))
- {
- frequenz = "2600 MHz";
- }
+ // Funkzellen Info
+ if (line.Contains("(LT004)") && isLTE.Equals(true))
+ {
+ LteInfoModel lte = Application.Current.FindResource("LteInfoModel") as LteInfoModel;
- lte.frequenz = frequenz;
+ parts = line.Split(',');
+ string frequenz = parts[2];
- varid = null;
- jArray = null;
- a = null;
- stamp = null;
- msg = null;
- syslogList = null;
- return;
+ if (frequenz.Equals("20"))
+ {
+ frequenz = "800 MHz";
+ }
+ else if (frequenz.Equals("3"))
+ {
+ frequenz = "1800 MHz";
+ }
+ else if (frequenz.Equals("7"))
+ {
+ frequenz = "2600 MHz";
}
- syslogList.Add(new SyslogList() { timestamp = stamp.ToString(), message = msg.ToString() });
+ lte.frequenz = frequenz;
- a = null;
- stamp = null;
- msg = null;
+ syslogList = null;
+ return;
}
- varid = null;
+
+ parts = line.Split(new string[] { " " }, 3, StringSplitOptions.None);
+ syslogList.Add(new SyslogList() { timestamp = string.Concat(parts[0], " ", parts[1]), message = parts[2] });
}
syslog.syslogList = syslogList;
syslogList = null;
- jArray = null;
DateTime time = DateTime.Now;
string format = "dd.MM.yyyy HH:mm:ss";
syslog.datetime = time.ToString(format);
syslog = null;
+
}
catch (Exception ex)
{
JToken jArray = JToken.Parse(response);
if (jArray.getVar("status").Equals("ok"))
{
- if (isLoggedin().Equals(true))
- {
- logout = false;
- }
- else {
- logout = true;
- _password = "";
- _challenge = "";
- _cookie = new CookieContainer();
- _lastReboot = DateTime.MinValue;
- _hash = "";
- _derivedk = "";
- }
+ logout = true;
+ _password = "";
+ _challenge = "";
+ _cookie = new CookieContainer();
+ _lastReboot = DateTime.MinValue;
+ _hash = "";
+ _derivedk = "";
}
jArray = null;
*/
public bool isLoggedin()
{
- string response = sendRequest("data/SecureStatus.json");
+ string response = sendRequest("data/heartbeat.json");
if (response.IsNullOrEmpty())
return false;
{
JToken jArray = JToken.Parse(response);
- if (jArray.getVar("loginstate").Equals("1")/* && jArray.getVar("login").Equals("true")*/)
+ if (jArray.getVar("loginstate").Equals("1"))
{
login = true;
}
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
+ xmlns:Implementations="clr-namespace:SpeedportHybridControl.Implementations;assembly=SpeedportHybridControl.Implementations"
mc:Ignorable="d"
Width="Auto" Height="Auto"
Title="TR181Page">
<GroupBox Header="Einstellungen" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="335,0,0,0" Height="76">
<Grid>
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="QueueSkbTimeOut:" VerticalAlignment="Top" Margin="0,3,0,0"/>
- <TextBox x:Name="tbQueue" HorizontalAlignment="Left" Margin="115,2,0,0" TextWrapping="Wrap" Text="{Binding QueueSkbTimeOut}" VerticalAlignment="Top" Width="42" />
+ <Implementations:NumberTextBox x:Name="tbQueue" HorizontalAlignment="Left" Margin="115,2,0,0" TextWrapping="Wrap" Text="{Binding QueueSkbTimeOut}" VerticalAlignment="Top" Width="42" />
<Button Command="{Binding Path=SaveCommand}" x:Name="btnSave" Content="Speichern" HorizontalAlignment="Left" Margin="44,34,0,0" VerticalAlignment="Top" Width="75" />
</Grid>
</GroupBox>