diff --git a/AyaNovaQBI/Map.cs b/AyaNovaQBI/Map.cs index 761f036..1b90796 100644 --- a/AyaNovaQBI/Map.cs +++ b/AyaNovaQBI/Map.cs @@ -1,9 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Data; -using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -28,7 +26,7 @@ namespace AyaNovaQBI public Map() { InitializeComponent(); - this.Icon = AyaNovaQBI.Properties.Resources.logo; + Icon = AyaNovaQBI.Properties.Resources.logo; _aya = new DataTable("AyaNova"); _aya.Columns.Add("name", typeof(string)); @@ -183,7 +181,7 @@ namespace AyaNovaQBI private async Task ImportToQuickBooks() { - this.Refresh(); + Refresh(); Cursor.Current = Cursors.WaitCursor; ArrayList alErrors = new ArrayList(); Waiting w = new Waiting(); @@ -258,6 +256,8 @@ namespace AyaNovaQBI } } + await util.SaveIntegrationObject(); + //display errors if any if (alErrors.Count != 0) { diff --git a/AyaNovaQBI/devinfo.txt b/AyaNovaQBI/devinfo.txt index 7318118..d0f5f3c 100644 --- a/AyaNovaQBI/devinfo.txt +++ b/AyaNovaQBI/devinfo.txt @@ -1,4 +1,5 @@ TODO: +Screenshots before expires!!!! REFRESH / UPDATE was previously done in v7 plugin in clients, parts grids etc, now needs to be added into qbi itself, maybe in the link form and then also need to rename the link form in the UI as it's doing a *lot* of stuff, maybe just "Linking and updating", "Linked objects"? Test persisted form settings for server url (ONCE POSTED NEW BUILD OF AYANOVA TO TEST SERVER) @@ -7,5 +8,4 @@ DOCS UI use "Link" and do not use "map" anywhere TEST auto-linking not tested due to import not coded yet so would be fuckery to do Integration object is saved too often as copied the code from v7, oncce working change that to save when ops are done only as it's a much more potentially expensive operation now e.g.Util.ImportAyaCustomer at bottom -unselect first item in map for both grids as they currently open with the first tiem highlighted -link -> import from qb should re-initialize grids, also other direction too so that imported items appear in grid showing it worked \ No newline at end of file +unselect first item in map for both grids as they currently open with the first tiem highlighted \ No newline at end of file diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index ff7f5b0..a54478e 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -3542,22 +3542,22 @@ namespace AyaNovaQBI #region Import / refresh to AyaNova - public static async Task RefreshAyaNovaClientFromQB(List objectIDList) - { - await PopulateQBClientCacheAsync(); - foreach (long id in objectIDList) - { - try - { - var r = await GetAsync($"customer/{id}"); - var c = r.ObjectResponse["data"].ToObject(); - RefreshAyaNovaClientFromQB(c); - r = await PutAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c)); - } - catch { }; - } + //public static async Task RefreshAyaNovaClientFromQB(List objectIDList) + //{ + // await PopulateQBClientCacheAsync(); + // foreach (long id in objectIDList) + // { + // try + // { + // var r = await GetAsync($"customer/{id}"); + // var c = r.ObjectResponse["data"].ToObject(); + // RefreshAyaNovaClientFromQB(c); + // r = await PutAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c)); + // } + // catch { }; + // } - } + //} public static async void RefreshAyaNovaClientFromQB(Customer c) { @@ -4472,39 +4472,39 @@ namespace AyaNovaQBI - public static async Task ImportAyaCustomer(List objectIDList) - { - ArrayList alErrors = new ArrayList(); - foreach (long ayid in objectIDList) - { - try - { + //public static async Task ImportAyaCustomer(List objectIDList) + //{ + // ArrayList alErrors = new ArrayList(); + // foreach (long ayid in objectIDList) + // { + // try + // { - await ImportAyaCustomer(ayid, alErrors); + // await ImportAyaCustomer(ayid, alErrors); - } - catch { }; - } + // } + // catch { }; + // } - if (alErrors.Count != 0) - { + // if (alErrors.Count != 0) + // { - StringBuilder sb = new StringBuilder(); - sb.Append("Export completed with some errors:\r\n\r\n"); - foreach (object o in alErrors) - { - sb.Append((string)o); - sb.Append("\r\n************\r\n"); + // StringBuilder sb = new StringBuilder(); + // sb.Append("Export completed with some errors:\r\n\r\n"); + // foreach (object o in alErrors) + // { + // sb.Append((string)o); + // sb.Append("\r\n************\r\n"); - } + // } - CopyableMessageBox cb = new CopyableMessageBox(sb.ToString()); - cb.ShowDialog(); - cb.Dispose(); + // CopyableMessageBox cb = new CopyableMessageBox(sb.ToString()); + // cb.ShowDialog(); + // cb.Dispose(); - } - } + // } + //} /// @@ -4716,14 +4716,6 @@ namespace AyaNovaQBI //Link var m = new IntegrationItem { AType = AyaType.Customer, IntegrationItemName = sName, IntegrationItemId = sNewCustID, LastSync = DateTime.Now, ObjectId = c.Id }; QBIntegration.Items.Add(m); - await util.SaveIntegrationObject(); - //IntegrationMap m = QBI.Maps.Add(QBI); - //m.Name = sName; - //m.RootObjectID = c.ID; - //m.RootObjectType = RootObjectTypes.Client; - //m.LastSync = DateTime.Now; - //m.ForeignID = sNewCustID; - //QBI = (Integration)QBI.Save(); } catch (Exception ex) { @@ -4933,14 +4925,7 @@ namespace AyaNovaQBI //Link var m = new IntegrationItem { AType = AyaType.Vendor, IntegrationItemName = sName, IntegrationItemId = sNewCustID, LastSync = DateTime.Now, ObjectId = c.Id }; QBIntegration.Items.Add(m); - await util.SaveIntegrationObject(); - //IntegrationMap m = QBI.Maps.Add(QBI); - //m.Name = sName; - //m.RootObjectID = c.ID; - //m.RootObjectType = RootObjectTypes.Vendor; - //m.LastSync = DateTime.Now; - //m.ForeignID = sNewCustID; - //QBI = (Integration)QBI.Save(); + } catch (Exception ex) { @@ -4963,25 +4948,25 @@ namespace AyaNovaQBI - /// - /// Refresh the list of AyaNova parts to their linked QuickBooks item records - /// - /// - public static async Task RefreshQBPartFromAyaNova(List objectIDList) - { - foreach (long id in objectIDList) - { - try - { - var r = await GetAsync($"part/{id}"); - var c = r.ObjectResponse["data"].ToObject(); - await RefreshQBPartFromAyaNova(c); + ///// + ///// Refresh the list of AyaNova parts to their linked QuickBooks item records + ///// + ///// + //public static async Task RefreshQBPartFromAyaNova(List objectIDList) + //{ + // foreach (long id in objectIDList) + // { + // try + // { + // var r = await GetAsync($"part/{id}"); + // var c = r.ObjectResponse["data"].ToObject(); + // await RefreshQBPartFromAyaNova(c); - } - catch { }; - } + // } + // catch { }; + // } - } + //} /// /// Refresh the indicated AyaNova part @@ -5333,14 +5318,7 @@ namespace AyaNovaQBI //Link var m = new IntegrationItem { AType = AyaType.Part, IntegrationItemName = sName, IntegrationItemId = sNewID, LastSync = DateTime.Now, ObjectId = c.Id }; QBIntegration.Items.Add(m); - await util.SaveIntegrationObject(); - //IntegrationMap m = QBI.Maps.Add(QBI); - //m.Name = sName; - //m.RootObjectID = c.ID; - //m.RootObjectType = RootObjectTypes.Part; - //m.LastSync = DateTime.Now; - //m.ForeignID = sNewID; - //QBI = (Integration)QBI.Save(); + } catch (Exception ex) { @@ -5492,14 +5470,7 @@ namespace AyaNovaQBI //Link var m = new IntegrationItem { AType = AyaType.ServiceRate, IntegrationItemName = sName, IntegrationItemId = sNewID, LastSync = DateTime.Now, ObjectId = c.Id }; QBIntegration.Items.Add(m); - await util.SaveIntegrationObject(); - //IntegrationMap m = QBI.Maps.Add(QBI); - //m.Name = sName; - //m.RootObjectID = c.ID; - //m.RootObjectType = RootObjectTypes.Rate; - //m.LastSync = DateTime.Now; - //m.ForeignID = sNewID; - //QBI = (Integration)QBI.Save(); + } catch (Exception ex) { @@ -5649,14 +5620,7 @@ namespace AyaNovaQBI //Link var m = new IntegrationItem { AType = AyaType.TravelRate, IntegrationItemName = sName, IntegrationItemId = sNewID, LastSync = DateTime.Now, ObjectId = c.Id }; QBIntegration.Items.Add(m); - await util.SaveIntegrationObject(); - //IntegrationMap m = QBI.Maps.Add(QBI); - //m.Name = sName; - //m.RootObjectID = c.ID; - //m.RootObjectType = RootObjectTypes.Rate; - //m.LastSync = DateTime.Now; - //m.ForeignID = sNewID; - //QBI = (Integration)QBI.Save(); + } catch (Exception ex) {