This commit is contained in:
2022-06-24 21:40:04 +00:00
parent 55ba8ac9ff
commit 0b6ef95c66
2 changed files with 51 additions and 18 deletions

View File

@@ -489,7 +489,20 @@ namespace AyaNovaQBI
//}
/*
██╗███╗ ██╗██╗████████╗██╗ █████╗ ██╗ ██╗███████╗███████╗
██║████╗ ██║██║╚══██╔══╝██║██╔══██╗██║ ██║╚══███╔╝██╔════╝
██║██╔██╗ ██║██║ ██║ ██║███████║██║ ██║ ███╔╝ █████╗
██║██║╚██╗██║██║ ██║ ██║██╔══██║██║ ██║ ███╔╝ ██╔══╝
██║██║ ╚████║██║ ██║ ██║██║ ██║███████╗██║███████╗███████╗
╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝╚══════╝╚══════╝
*/
public static async Task<bool> InitializeQBI(StringBuilder initErrors)
{
@@ -890,6 +903,26 @@ namespace AyaNovaQBI
return retvalue;
}
/// <summary>
/// returns an empty string if passed in value is null or empty
/// else returns Prepend plus passed in string followed by append string
/// </summary>
/// <param name="sPrepend">Text to return to the left of sText</param>
/// <param name="sText">string to return if not null or empty</param>
/// <param name="sAppend">Text to return to the right of sText</param>
/// <returns></returns>
public static string SS(string sPrepend, string sText, string sAppend)
{
if (sText == null)
return "";
if (sText == "")
return "";
return sPrepend + sText + sAppend;
}
#endregion qb specific utils
#region QB API helper methods/ attributes/cached lists
@@ -913,13 +946,13 @@ namespace AyaNovaQBI
w.Step = "Classes";
PopulateQBClassCache();
await PopulateQBClassCacheAsync();
w.Step = "Vendors";
PopulateQBVendorCache();
await PopulateQBVendorCacheAsync();
w.Step = "Customers";
PopulateQBClientCache();
await PopulateQBClientCacheAsync();
w.Step = "Items";
await PopulateQBItemCache();
@@ -927,16 +960,16 @@ namespace AyaNovaQBI
if (!(QVersion < 3))//qbXML 3.0 or higher (QB 2004 any country or newer)
{
w.Step = "Invoice templates";
PopulateQBInvoiceTemplates();
await PopulateQBInvoiceTemplatesAsync();
}
//case 632
w.Step = "Accounts";
PopulateQBAccountCache();
await PopulateQBAccountCacheAsync();
//case 519
w.Step = "Terms";
PopulateQBTermsCache();
await PopulateQBTermsCache();
w.Close();
}
@@ -1402,7 +1435,7 @@ namespace AyaNovaQBI
/// Populate the cached qb data
/// billable
/// </summary>
private static void PopulateQBClassCache()
private static async Task PopulateQBClassCacheAsync()
{
if (_dtQBClasses == null)
{
@@ -1535,7 +1568,7 @@ namespace AyaNovaQBI
/// Populate the cached qb data
/// Invoice templates
/// </summary>
private static void PopulateQBInvoiceTemplates()
private static async Task PopulateQBInvoiceTemplatesAsync()
{
if (_dtQBInvoiceTemplates == null)
{
@@ -1657,7 +1690,7 @@ namespace AyaNovaQBI
#region QuickBooks "Customers"
private static string GetQBCustomerEditSequence(string customerid)
private static async Task<string> GetQBCustomerEditSequenceAsync(string customerid)
{
string strEditSequence = "";
@@ -1776,7 +1809,7 @@ namespace AyaNovaQBI
/// Populate the cached qb data
/// of customers / clients
/// </summary>
private static void PopulateQBClientCache()
private static async Task PopulateQBClientCacheAsync()
{
if (_dtQBClients == null)
{
@@ -1945,12 +1978,12 @@ namespace AyaNovaQBI
//the first line
//Assumption: First line always has *something* in it
b.DeliveryAddress = ProcessQBString(a.Addr1);
b.DeliveryAddress += AyaBizUtils.SS("\r\n", ProcessQBString(a.Addr2), "");
b.DeliveryAddress += AyaBizUtils.SS("\r\n", ProcessQBString(a.Addr3), "");
b.DeliveryAddress += SS("\r\n", ProcessQBString(a.Addr2), "");
b.DeliveryAddress += SS("\r\n", ProcessQBString(a.Addr3), "");
//Address line 4 is a qbxml 2 or higher feature
if (QVersion > 1.1)
b.DeliveryAddress += AyaBizUtils.SS("\r\n", ProcessQBString(a.Addr4), "");
b.DeliveryAddress += SS("\r\n", ProcessQBString(a.Addr4), "");
//Country specific:
b.City = ProcessQBString(a.City);
@@ -2006,7 +2039,7 @@ namespace AyaNovaQBI
/// Populate the cached qb data
/// of Vendors
/// </summary>
private static void PopulateQBVendorCache()
private static async Task PopulateQBVendorCacheAsync()
{
if (_dtQBVendors == null)
{
@@ -2173,7 +2206,7 @@ namespace AyaNovaQBI
/// <summary>
/// Populate the cached qb account list data
/// </summary>
private static void PopulateQBAccountCache()
private static async Task PopulateQBAccountCacheAsync()
{
if (_dtQBAccounts == null)
{
@@ -2267,7 +2300,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();
@@ -2304,7 +2337,7 @@ namespace AyaNovaQBI
/// <summary>
/// Populate the cached qb terms list data
/// </summary>
private async static void PopulateQBTermsCache()
private async static Task PopulateQBTermsCache()
{
if (_dtQBTerms == null)
{