From 0a2ae1f992fc96e7e3cfa6ca414f58f9c9d1d4be Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 16 Dec 2020 20:11:41 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 9 +++++-- source/Plugins/AyaNova.Plugin.V8/util.cs | 31 +++++++++++++----------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 250d0ff..511a173 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -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 diff --git a/source/Plugins/AyaNova.Plugin.V8/util.cs b/source/Plugins/AyaNova.Plugin.V8/util.cs index 94c57bc..f352a23 100644 --- a/source/Plugins/AyaNova.Plugin.V8/util.cs +++ b/source/Plugins/AyaNova.Plugin.V8/util.cs @@ -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(); + JWT = a.ObjectResponse["data"]["token"].Value(); //Must be *the* SuperUser to continue: - a = await GetAsync("user/amsu"); - var IsSuperUser = a.ObjectResponse["data"].Value(); - if (!IsSuperUser) { - JWT = string.Empty; - return false; - } + a = await GetAsync("user/amsu"); + var IsSuperUser = a.ObjectResponse["data"].Value(); + 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;