This commit is contained in:
2022-07-06 18:08:15 +00:00
parent 9da03e4f7d
commit dda1bb096e
3 changed files with 67 additions and 103 deletions

View File

@@ -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)
{

View File

@@ -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)
@@ -8,4 +9,3 @@ TEST auto-linking not tested due to import not coded yet so would be fuckery to
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

View File

@@ -3542,22 +3542,22 @@ namespace AyaNovaQBI
#region Import / refresh to AyaNova
public static async Task RefreshAyaNovaClientFromQB(List<long> objectIDList)
{
await PopulateQBClientCacheAsync();
foreach (long id in objectIDList)
{
try
{
var r = await GetAsync($"customer/{id}");
var c = r.ObjectResponse["data"].ToObject<Customer>();
RefreshAyaNovaClientFromQB(c);
r = await PutAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c));
}
catch { };
}
//public static async Task RefreshAyaNovaClientFromQB(List<long> objectIDList)
//{
// await PopulateQBClientCacheAsync();
// foreach (long id in objectIDList)
// {
// try
// {
// var r = await GetAsync($"customer/{id}");
// var c = r.ObjectResponse["data"].ToObject<Customer>();
// 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<long> objectIDList)
{
ArrayList alErrors = new ArrayList();
foreach (long ayid in objectIDList)
{
try
{
//public static async Task ImportAyaCustomer(List<long> 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();
}
}
// }
//}
/// <summary>
@@ -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
/// <summary>
/// Refresh the list of AyaNova parts to their linked QuickBooks item records
/// </summary>
/// <param name="objectIDList"></param>
public static async Task RefreshQBPartFromAyaNova(List<long> objectIDList)
{
foreach (long id in objectIDList)
{
try
{
var r = await GetAsync($"part/{id}");
var c = r.ObjectResponse["data"].ToObject<Part>();
await RefreshQBPartFromAyaNova(c);
///// <summary>
///// Refresh the list of AyaNova parts to their linked QuickBooks item records
///// </summary>
///// <param name="objectIDList"></param>
//public static async Task RefreshQBPartFromAyaNova(List<long> objectIDList)
//{
// foreach (long id in objectIDList)
// {
// try
// {
// var r = await GetAsync($"part/{id}");
// var c = r.ObjectResponse["data"].ToObject<Part>();
// await RefreshQBPartFromAyaNova(c);
}
catch { };
}
// }
// catch { };
// }
}
//}
/// <summary>
/// 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)
{