|
@@ -10,6 +10,8 @@ using Xamarin.Forms;
|
|
|
using Xamarin.Forms.Xaml;
|
|
|
using System.Net;
|
|
|
using InABox.Core;
|
|
|
+using Comal.Classes;
|
|
|
+using Email = Xamarin.Essentials.Email;
|
|
|
|
|
|
namespace ConnectionTest
|
|
|
{
|
|
@@ -20,6 +22,8 @@ namespace ConnectionTest
|
|
|
public event RemoveURL OnRemoveURL;
|
|
|
string URL = "";
|
|
|
string log = "";
|
|
|
+ double interval = 1000;
|
|
|
+ static JsonClient<User> client;
|
|
|
public ConnectionTestUnit(string url)
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -32,6 +36,7 @@ namespace ConnectionTest
|
|
|
});
|
|
|
Resolve();
|
|
|
ResolveTimer();
|
|
|
+ UpdateInterval();
|
|
|
}
|
|
|
|
|
|
private void ResolveTimer()
|
|
@@ -97,20 +102,45 @@ namespace ConnectionTest
|
|
|
|
|
|
private void StartTest()
|
|
|
{
|
|
|
- int count = 1;
|
|
|
+ int count = 0;
|
|
|
int crashcount = 0;
|
|
|
while (true)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- Thread.Sleep(500);
|
|
|
- var client = new JsonClient<User>(URL, false, false, BinarySerializationSettings.Latest);
|
|
|
- var result = client.Validate("TAN", "nictan", Guid.Empty);
|
|
|
+
|
|
|
+ Thread.Sleep((int)interval);
|
|
|
+
|
|
|
+ if(client == null)
|
|
|
+ client = new JsonClient<User>(URL, false, true, BinarySerializationSettings.Latest);
|
|
|
+
|
|
|
+ if(ClientFactory.ClientType == null)
|
|
|
+ ClientFactory.SetClientType(typeof(JsonClient<>), "Test connection App", "1.0", URL, true);
|
|
|
+ var result = ClientFactory.Validate("TAN", "nictan");
|
|
|
+
|
|
|
+ //var request = WebRequest.Create("http://" + URL);
|
|
|
+ //var response = request.GetResponse();
|
|
|
+ //var cmd = string.Format(
|
|
|
+ // "{0}{1}?format={2}&responseFormat={3}&serializationVersion={4}",
|
|
|
+ // "validate",
|
|
|
+ // "User",
|
|
|
+ // "Json",
|
|
|
+ // "Json",
|
|
|
+ // "1.0"
|
|
|
+ // );
|
|
|
|
|
|
Device.BeginInvokeOnMainThread(() =>
|
|
|
{
|
|
|
- attemptNoLbl.Text = "Attempt: " + count;
|
|
|
count++;
|
|
|
+ attemptNoLbl.Text = "Attempt: " + count;
|
|
|
+ });
|
|
|
+
|
|
|
+ CoreTable table = new Client<Product>().Query();
|
|
|
+
|
|
|
+ Device.BeginInvokeOnMainThread(() =>
|
|
|
+ {
|
|
|
+ count++;
|
|
|
+ attemptNoLbl.Text = "Attempt: " + count;
|
|
|
});
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -123,8 +153,11 @@ namespace ConnectionTest
|
|
|
+ ex.Message + ex.StackTrace;
|
|
|
crashcount++;
|
|
|
count++;
|
|
|
- Device.BeginInvokeOnMainThread(() => { crashNoLbl.Text = "Crash Count: " + crashcount; });
|
|
|
-
|
|
|
+ Device.BeginInvokeOnMainThread(() =>
|
|
|
+ {
|
|
|
+ attemptNoLbl.Text = "Attempt: " + count;
|
|
|
+ crashNoLbl.Text = "Crash Count: " + crashcount;
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -133,5 +166,38 @@ namespace ConnectionTest
|
|
|
{
|
|
|
OnRemoveURL?.Invoke(this);
|
|
|
}
|
|
|
+
|
|
|
+ void MinusBtn_Clicked(System.Object sender, System.EventArgs e)
|
|
|
+ {
|
|
|
+ if (interval > 500)
|
|
|
+ {
|
|
|
+ interval = interval - 500;
|
|
|
+ UpdateInterval();
|
|
|
+ }
|
|
|
+ else if(interval == 500)
|
|
|
+ {
|
|
|
+ interval = 100;
|
|
|
+ UpdateInterval();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void PlusButton_Clicked(System.Object sender, System.EventArgs e)
|
|
|
+ {
|
|
|
+ if (interval >= 500)
|
|
|
+ {
|
|
|
+ interval = interval + 500;
|
|
|
+ UpdateInterval();
|
|
|
+ }
|
|
|
+ else if(interval == 100)
|
|
|
+ {
|
|
|
+ interval = 500;
|
|
|
+ UpdateInterval();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UpdateInterval()
|
|
|
+ {
|
|
|
+ intervalLbl.Text = "Interval: " + (interval / 1000) + "s";
|
|
|
+ }
|
|
|
}
|
|
|
}
|