This commit is contained in:
2021-08-13 18:24:14 +00:00
parent 5a155c11fd
commit 5ea07cd003
4 changed files with 151 additions and 146 deletions

View File

@@ -19,8 +19,8 @@ namespace AyaNova.PlugIn.V8
public static string PRE_RELEASE_VERSION_STRING { get; set; }
public static GZTW.AyaNova.BLL.LocalizedTextTable LocaleText = null;
const string TEST_ROUTE = "notify/hello";
const string API_BASE_ROUTE = "api/v8/";
public const string TEST_ROUTE = "notify/hello";
public const string API_BASE_ROUTE = "api/v8/";
public static HttpClient client = new HttpClient();
//url once known to be good
internal static string ApiBaseUrl { get; set; }
@@ -59,27 +59,8 @@ namespace AyaNova.PlugIn.V8
/// <returns></returns>
public static async Task<string> TestUrlAsync(string serverUrl)
{
if (string.IsNullOrEmpty(serverUrl)) return "Server url required";
if (!serverUrl.Contains("/api/"))
{
if (!serverUrl.EndsWith("/")) serverUrl += "/";
serverUrl += API_BASE_ROUTE;
}
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;
//}
try
{
// TimeSpan tsDefault = client.Timeout;
@@ -87,14 +68,9 @@ namespace AyaNova.PlugIn.V8
HttpResponseMessage response = await client.GetAsync(serverUrl + TEST_ROUTE);
// client.Timeout = tsDefault;
if (response.IsSuccessStatusCode)
{
return "OK";
}
else
{
return "Failed: " + response.StatusCode.ToString();
}
}
catch (Exception ex)
{
@@ -102,9 +78,6 @@ namespace AyaNova.PlugIn.V8
ex = ex.InnerException;
return "Failed exception: \n" + ex.Message;
}
// return "failed";
}