This commit is contained in:
2019-10-07 18:54:29 +00:00
parent 4be88f3b08
commit b7c810c800

View File

@@ -582,7 +582,7 @@ namespace AyaNova.PlugIn.QBOI
} }
} }
todo: call this from all over the place (i.e. before every api call) //and remove logging //todo: call this from all over the place (i.e. before every api call) //and remove logging
RefreshTokens(); RefreshTokens();
IntegrationLog.Log(QBID, "PFC: Authentication completed, validating company data"); IntegrationLog.Log(QBID, "PFC: Authentication completed, validating company data");
@@ -1714,6 +1714,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
Waiting w = new Waiting(); Waiting w = new Waiting();
w.Show(); w.Show();
w.Ops = "Reading from QuickBooks Online..."; w.Ops = "Reading from QuickBooks Online...";
RefreshTokens();
w.Step = "Company preferences"; w.Step = "Company preferences";
PopulateQBPreferencesCache(); PopulateQBPreferencesCache();
@@ -1809,6 +1810,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBItemCache() private static void PopulateQBItemCache()
{ {
RefreshTokens();
if (_dtQBItems == null) if (_dtQBItems == null)
{ {
_dtQBItems = new DataTable("QBItems"); _dtQBItems = new DataTable("QBItems");
@@ -1930,6 +1932,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBClassCache() private static void PopulateQBClassCache()
{ {
RefreshTokens();
if (_dtQBClasses == null) if (_dtQBClasses == null)
{ {
_dtQBClasses = new DataTable("QBClasses"); _dtQBClasses = new DataTable("QBClasses");
@@ -2007,6 +2010,8 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBInvoiceTemplates() private static void PopulateQBInvoiceTemplates()
{ {
RefreshTokens();
if (_dtQBInvoiceTemplates == null) if (_dtQBInvoiceTemplates == null)
{ {
_dtQBInvoiceTemplates = new DataTable("QBInvoiceTemplates"); _dtQBInvoiceTemplates = new DataTable("QBInvoiceTemplates");
@@ -2043,6 +2048,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
#region SyncToken fetching #region SyncToken fetching
private static string GetQBCustomerSyncToken(string customerid) private static string GetQBCustomerSyncToken(string customerid)
{ {
RefreshTokens();
try try
{ {
QueryService<q.Customer> qs = new QueryService<q.Customer>(SC); QueryService<q.Customer> qs = new QueryService<q.Customer>(SC);
@@ -2096,6 +2102,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBClientCache() private static void PopulateQBClientCache()
{ {
RefreshTokens();
if (_dtQBClients == null) if (_dtQBClients == null)
{ {
_dtQBClients = new DataTable("QBClients"); _dtQBClients = new DataTable("QBClients");
@@ -2320,6 +2327,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBVendorCache() private static void PopulateQBVendorCache()
{ {
RefreshTokens();
if (_dtQBVendors == null) if (_dtQBVendors == null)
{ {
_dtQBVendors = new DataTable("QBVendors"); _dtQBVendors = new DataTable("QBVendors");
@@ -2419,6 +2427,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBAccountCache() private static void PopulateQBAccountCache()
{ {
RefreshTokens();
if (_dtQBAccounts == null) if (_dtQBAccounts == null)
{ {
_dtQBAccounts = new DataTable("QBAccounts"); _dtQBAccounts = new DataTable("QBAccounts");
@@ -2495,6 +2504,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBTermsCache() private static void PopulateQBTermsCache()
{ {
RefreshTokens();
if (_dtQBTerms == null) if (_dtQBTerms == null)
{ {
_dtQBTerms = new DataTable("QBTerms"); _dtQBTerms = new DataTable("QBTerms");
@@ -2572,6 +2582,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBTaxCodesCache() private static void PopulateQBTaxCodesCache()
{ {
RefreshTokens();
if (_dtQBTaxCodes == null) if (_dtQBTaxCodes == null)
{ {
_dtQBTaxCodes = new DataTable("QBTaxCodes"); _dtQBTaxCodes = new DataTable("QBTaxCodes");
@@ -2661,6 +2672,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
/// </summary> /// </summary>
private static void PopulateQBPreferencesCache() private static void PopulateQBPreferencesCache()
{ {
RefreshTokens();
try try
{ {
QueryService<q.Preferences> qs = new QueryService<q.Preferences>(SC); QueryService<q.Preferences> qs = new QueryService<q.Preferences>(SC);
@@ -2733,6 +2745,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
public static void RefreshAyaNovaClientFromQB(List<Guid> objectIDList) public static void RefreshAyaNovaClientFromQB(List<Guid> objectIDList)
{ {
PopulateQBClientCache(); PopulateQBClientCache();
foreach (Guid g in objectIDList) foreach (Guid g in objectIDList)
{ {
@@ -2750,6 +2763,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
public static void RefreshAyaNovaClientFromQB(Client c) public static void RefreshAyaNovaClientFromQB(Client c)
{ {
PopulateQBClientCache(); PopulateQBClientCache();
IntegrationMap im = QBOIntegration.Maps[c.ID]; IntegrationMap im = QBOIntegration.Maps[c.ID];
if (im == null) return;//this client is not linked if (im == null) return;//this client is not linked
@@ -2780,6 +2794,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
public static void ImportQBCustomer(string QuickBooksID, ArrayList alErrors) public static void ImportQBCustomer(string QuickBooksID, ArrayList alErrors)
{ {
DataRow dr = _dtQBClients.Rows.Find(QuickBooksID); DataRow dr = _dtQBClients.Rows.Find(QuickBooksID);
//QBListID not found in client list? //QBListID not found in client list?
if (dr == null) if (dr == null)
@@ -3325,6 +3340,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
ca.SalesTermRef.Value = QDat.TermsDefault; ca.SalesTermRef.Value = QDat.TermsDefault;
//----------- UPDATE VIA API ------------- //----------- UPDATE VIA API -------------
RefreshTokens();
DataService service = new DataService(SC); DataService service = new DataService(SC);
q.Customer resultCustomer = service.Update(ca) as q.Customer; q.Customer resultCustomer = service.Update(ca) as q.Customer;
@@ -3585,6 +3601,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
} }
//============ ADD VIA API================================ //============ ADD VIA API================================
RefreshTokens();
DataService service = new DataService(SC); DataService service = new DataService(SC);
q.Customer resultCustomer = service.Add(ca) as q.Customer; q.Customer resultCustomer = service.Add(ca) as q.Customer;
//======================================================== //========================================================
@@ -3786,6 +3803,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
//============ ADD VIA API================================ //============ ADD VIA API================================
RefreshTokens();
DataService service = new DataService(SC); DataService service = new DataService(SC);
q.Vendor resultVendor = service.Add(ca) as q.Vendor; q.Vendor resultVendor = service.Add(ca) as q.Vendor;
//======================================================== //========================================================
@@ -3890,6 +3908,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
CopyAyPartToQBOItem(c, ca); CopyAyPartToQBOItem(c, ca);
//----------- UPDATE VIA API ------------- //----------- UPDATE VIA API -------------
RefreshTokens();
DataService service = new DataService(SC); DataService service = new DataService(SC);
q.Item resultItem = service.Update(ca) as q.Item; q.Item resultItem = service.Update(ca) as q.Item;
@@ -4071,6 +4090,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
} }
//============ ADD VIA API================================ //============ ADD VIA API================================
RefreshTokens();
DataService service = new DataService(SC); DataService service = new DataService(SC);
q.Item resultItem = service.Add(ca) as q.Item; q.Item resultItem = service.Add(ca) as q.Item;
@@ -4194,6 +4214,7 @@ KEY: AssignedTime, VALUE: 12/08/2017 18:52:04
//============ ADD VIA API================================ //============ ADD VIA API================================
RefreshTokens();
DataService service = new DataService(SC); DataService service = new DataService(SC);
q.Item resultItem = service.Add(ca) as q.Item; q.Item resultItem = service.Add(ca) as q.Item;
//======================================================== //========================================================