This commit is contained in:
2021-08-11 18:05:02 +00:00
parent 5c0c09beb1
commit 168eaf8e37
2 changed files with 20 additions and 11 deletions

View File

@@ -139,7 +139,7 @@ namespace AyaNova.PlugIn.V8
}
//#endif
util.Initialized = false;
Auth d = new Auth();
var res = d.ShowDialog(); ;
if (res == DialogResult.Cancel)

View File

@@ -21,7 +21,7 @@ namespace AyaNova.PlugIn.V8
public static GZTW.AyaNova.BLL.LocalizedTextTable LocaleText = null;
const string TEST_ROUTE = "notify/hello";
const string API_BASE_ROUTE = "api/v8/";
static HttpClient client = new HttpClient();
public static HttpClient client = null;
//url once known to be good
internal static string ApiBaseUrl { get; set; }
internal static string JWT { get; set; }
@@ -40,6 +40,10 @@ namespace AyaNova.PlugIn.V8
private static void InitClient()
{
if (Initialized) return;
if (client != null)
client.Dispose();
client = null;
client = new HttpClient();
client.BaseAddress = new Uri(ApiBaseUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
@@ -63,22 +67,27 @@ namespace AyaNova.PlugIn.V8
}
if (!serverUrl.StartsWith("http")) serverUrl = "http://" + serverUrl;
ApiBaseUrl = serverUrl;
InitClient();
//try to connect, ping the server api
if (!Initialized)
{
client.BaseAddress = new Uri(serverUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Initialized = true;
}
//if (!Initialized)
//{
// client.BaseAddress = new Uri(serverUrl);
// client.DefaultRequestHeaders.Accept.Clear();
// client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Initialized = true;
//}
try
{
// TimeSpan tsDefault = client.Timeout;
// client.Timeout = new TimeSpan(0, 0, 20);
HttpResponseMessage response = await client.GetAsync(serverUrl + TEST_ROUTE);
// client.Timeout = tsDefault;
if (response.IsSuccessStatusCode)
{
ApiBaseUrl = serverUrl;
return "OK";
}
else
@@ -775,7 +784,7 @@ Locale Français is customized [signature: 804154061] exporting
//<path d="M 79.400,15.300 C 82.236,17.326 82.400,16.800 85.400,18.300" stroke-width="5.525" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path>
//<path d="M 85.400,18.300 C 88.884,19.030 88.736,19.326 92.400,19.300" stroke-wke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path><path d="M 510.400,91.300 C 513.725,93.769 513.448,93.840 517.400,95.300" stroke-width="4.888" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path><path d="M 517.400,95.300 C 519.870,96.105 519.725,96.269 522.400,96.300" stroke-width="5.121" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path></svg>
//https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
System.Text.StringBuilder sb = new System.Text.StringBuilder();
//open