This commit is contained in:
2020-12-16 20:11:41 +00:00
parent 695192c056
commit 0a2ae1f992
2 changed files with 24 additions and 16 deletions

View File

@@ -1002,7 +1002,7 @@ namespace AyaNova.PlugIn.V8
d = new JObject();
d.customerId = RavenId;
d.userId = SafeGetUserMap(cn.Creator);
d.noteDate = util.StringDateToV8(cn.Created, true);
d.noteDate = util.DateToV8(cn.Created, true);
d.notes = cn.Notes;
Tagit(cn.ClientNoteTypeID, tags);
SetTags(d, tags);
@@ -1454,6 +1454,11 @@ namespace AyaNova.PlugIn.V8
progress.Op(ObjectTypeName + " " + d.name);
d.active = c.Active;
d.notes = c.Notes;
d.dateStarted = util.DateToV8(c.DateStarted,true);
d.dateCompleted = util.DateToV8(c.DateCompleted, false);
d.accountNumber = c.AccountNumber;
d.projectOverseerId = SafeGetUserMap(c.ProjectOverseerID);
Tagit(c.RegionID, tags);
SetTags(d, tags);
@@ -1882,7 +1887,7 @@ namespace AyaNova.PlugIn.V8
dmemo.replied = mem.Replied;
var RavenFromId=SafeGetUserMap(mem.FromID);
dmemo.fromId = RavenFromId;
dmemo.sent = util.StringDateToV8(mem.Created, true);
dmemo.sent = util.DateToV8(mem.Created, true);
dmemo.toId=SafeGetUserMap(mem.ToID);
SetTags(dmemo, tags);
duserid.Add(-7);//special code to server to treat as an import single

View File

@@ -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;