This commit is contained in:
2022-06-24 19:43:01 +00:00
parent 976b551c43
commit 55ba8ac9ff

View File

@@ -541,7 +541,7 @@ namespace AyaNovaQBI
//QB CONNECTION validation and setup
try
{
if(await QBValidate() == pfstat.Cancel)
if (await QBValidate() == pfstat.Cancel)
{
await IntegrationLog("PFC: Unable to validate QuickBooks connection, user selected cancel");
return false;
@@ -549,7 +549,7 @@ namespace AyaNovaQBI
else
{
await IntegrationLog($"PFC: QB Company name= {QCompanyName}, QB Country version={QCountry}, QBVersion={QVersion}, Companyfile={QCompanyFile}");
//PFC - PopulateQBListCache()
await PopulateQBListCache();
//PFC - PopulateAyaListCache()
@@ -560,7 +560,7 @@ namespace AyaNovaQBI
//DONE
}
}
catch(Exception ex)
catch (Exception ex)
{
initErrors.AppendLine($"QuickBooks connection validation failed before connecting\r\n{ex.Message}");
@@ -896,7 +896,14 @@ namespace AyaNovaQBI
/// <summary>
/// Populate or repopulate the list of
/// </summary>
public static void PopulateQBListCache()
#endregion qb specific utils
#region QB API helper methods/ attributes/cached lists
/// <summary>
/// Populate or repopulate the list of
/// </summary>
public static async Task PopulateQBListCache()
{
//Get the cached QB data
Waiting w = new Waiting();
@@ -915,7 +922,7 @@ namespace AyaNovaQBI
PopulateQBClientCache();
w.Step = "Items";
PopulateQBItemCache();
await PopulateQBItemCache();
if (!(QVersion < 3))//qbXML 3.0 or higher (QB 2004 any country or newer)
{
@@ -963,23 +970,24 @@ namespace AyaNovaQBI
/// Given a QB Item ID, return the
/// AyaNova Vendor ID linked to that items
/// QB preferred Vendor ID or
/// Guid empty on any problem or not found
/// 0 on any problem or not found
/// </summary>
/// <param name="QBItemID"></param>
/// <returns></returns>
public static Guid AyaVendorForQBItem(string QBItemID)
public static long AyaVendorForQBItem(string QBItemID)
{
if (QBItemID == null || QBItemID == "") return Guid.Empty;
if (string.IsNullOrWhiteSpace(QBItemID)) return 0;
DataRow dr = _dtQBItems.Rows.Find(QBItemID);
if (dr == null || dr["VendorID"] == null || dr["VendorID"].ToString() == "") return Guid.Empty;
if (dr == null || dr["VendorID"] == null || dr["VendorID"].ToString() == "") return 0;
DataRow drVendor = _dtQBVendors.Rows.Find(dr["VendorID"].ToString());
if (drVendor == null) return Guid.Empty;
if (drVendor == null) return 0;
if (!QBI.Maps.Contains(drVendor["ID"].ToString(), RootObjectTypes.Vendor)) return Guid.Empty;
var item = QBIntegration.Items.FirstOrDefault(z => z.IntegrationItemId == drVendor["ID"].ToString());
if (item == null) return 0;
//Ok we have a matching vendor in the list, return the guid of it
return QBI.Maps[drVendor["ID"].ToString(), RootObjectTypes.Vendor].RootObjectID;
//Ok we have a matching vendor in the list, return the id of it
return item.Id;
}
@@ -987,7 +995,7 @@ namespace AyaNovaQBI
/// Populate the cached qb data
/// billable
/// </summary>
private static void PopulateQBItemCache()
private async static Task PopulateQBItemCache()
{
if (_dtQBItems == null)
{
@@ -1059,7 +1067,7 @@ namespace AyaNovaQBI
//Added: 21-June-2006 nonzero status codes 500 and higher are serious errors, less than 500 could just mean no matching items in list
if (response.StatusCode > 499)
{
throw new ApplicationException(response.StatusMessage + " Code: " + response.StatusCode);
throw new ApplicationException($"{response.StatusMessage} Code: {response.StatusCode}");
}
@@ -1187,7 +1195,7 @@ namespace AyaNovaQBI
}
catch (Exception ex)
{
await IntegrationLog( "PopulateQBItems: Failed with exception:" + ex.Message);
await IntegrationLog("PopulateQBItems: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();
@@ -1372,7 +1380,7 @@ namespace AyaNovaQBI
#endregion quickbooks items
#region QuickBooks "Transactionclasses"
public static string TRANSACTION_CLASS_NO_CLASS_SELECTED = "<GZNOCLASS>";
private static DataTable _dtQBClasses = null;
@@ -1489,7 +1497,7 @@ namespace AyaNovaQBI
}
catch (Exception ex)
{
await IntegrationLog( "PopulateQBClasses: Failed with exception:" + ex.Message);
await IntegrationLog("PopulateQBClasses: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();
@@ -1632,7 +1640,7 @@ namespace AyaNovaQBI
catch (Exception ex)
{
await IntegrationLog( "PopulateQBInvoiceTemplates: Failed with exception:" + ex.Message);
await IntegrationLog("PopulateQBInvoiceTemplates: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();
@@ -1723,7 +1731,7 @@ namespace AyaNovaQBI
}
catch (Exception ex)
{
await IntegrationLog( "GetClientEditSequence: Failed with exception:" + ex.Message);
await IntegrationLog("GetClientEditSequence: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();
@@ -1906,7 +1914,7 @@ namespace AyaNovaQBI
}
catch (Exception ex)
{
await IntegrationLog( "PopulateQBClients: Failed with exception:" + ex.Message);
await IntegrationLog("PopulateQBClients: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();
@@ -1973,16 +1981,7 @@ namespace AyaNovaQBI
return b;
}
/// <summary>
/// Handle null qb string types with "aplomb" :)
/// </summary>
/// <param name="qs"></param>
/// <returns></returns>
private static string ProcessQBString(IQBStringType qs)
{
if (qs == null) return "";
return qs.GetValue();
}
#endregion quickbooks transaction Clients
@@ -2135,7 +2134,7 @@ namespace AyaNovaQBI
}
catch (Exception ex)
{
await IntegrationLog( "PopulateQBVendors: Failed with exception:" + ex.Message);
await IntegrationLog("PopulateQBVendors: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();
@@ -2268,7 +2267,7 @@ namespace AyaNovaQBI
}
catch (Exception ex)
{
await IntegrationLog( "PopulateQBAccounts: Failed with exception:" + ex.Message);
await IntegrationLog("PopulateQBAccounts: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();
@@ -2398,7 +2397,7 @@ namespace AyaNovaQBI
}
catch (Exception ex)
{
await IntegrationLog( "PopulateQBTerms: Failed with exception:" + ex.Message);
await IntegrationLog("PopulateQBTerms: Failed with exception:" + ex.Message);
if (booSessionBegun)
{
sessionManager.EndSession();