This commit is contained in:
@@ -43,7 +43,7 @@ namespace AyaNova.PlugIn.V8
|
||||
client.BaseAddress = new Uri(ApiBaseUrl);
|
||||
client.DefaultRequestHeaders.Accept.Clear();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
// client.DefaultRequestHeaders.Add("X-AY-Import-Mode", "true");
|
||||
// client.DefaultRequestHeaders.Add("X-AY-Import-Mode", "true");
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace AyaNova.PlugIn.V8
|
||||
catch { return "Failed"; }
|
||||
|
||||
|
||||
// return "failed";
|
||||
// return "failed";
|
||||
}
|
||||
|
||||
|
||||
@@ -110,16 +110,17 @@ namespace AyaNova.PlugIn.V8
|
||||
|
||||
if (a.HttpResponse.IsSuccessStatusCode)
|
||||
{
|
||||
JWT=a.ObjectResponse["data"]["token"].Value<string>();
|
||||
JWT = a.ObjectResponse["data"]["token"].Value<string>();
|
||||
//Must be *the* SuperUser to continue:
|
||||
a = await GetAsync("user/amsu");
|
||||
var IsSuperUser = a.ObjectResponse["data"].Value<bool>();
|
||||
if (!IsSuperUser) {
|
||||
JWT = string.Empty;
|
||||
return false;
|
||||
}
|
||||
a = await GetAsync("user/amsu");
|
||||
var IsSuperUser = a.ObjectResponse["data"].Value<bool>();
|
||||
if (!IsSuperUser)
|
||||
{
|
||||
JWT = string.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -343,7 +344,8 @@ namespace AyaNova.PlugIn.V8
|
||||
// v7 to v8 Date conversion
|
||||
//
|
||||
//
|
||||
public static string StringDateToV8(string s, bool neverEmpty=false)
|
||||
public static string DateToV8(object o, bool neverEmpty = false) { return DateToV8(o.ToString(), neverEmpty); }
|
||||
public static string DateToV8(string s, bool neverEmpty = false)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
@@ -351,17 +353,18 @@ namespace AyaNova.PlugIn.V8
|
||||
{
|
||||
return DateTime.UtcNow.ToString("o");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
DateTime result=new DateTime();
|
||||
DateTime result = new DateTime();
|
||||
if (DateTime.TryParse(s, out result))
|
||||
return result.ToUniversalTime().ToString("o");
|
||||
|
||||
//couldn't be parsed
|
||||
if(neverEmpty)
|
||||
if (neverEmpty)
|
||||
return DateTime.UtcNow.ToString("o");
|
||||
return string.Empty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user