This commit is contained in:
@@ -22,7 +22,7 @@ namespace AyaNovaQBI
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Do not modify the definition of BuildAt as your changes will be discarded.
|
/// Do not modify the definition of BuildAt as your changes will be discarded.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static DateTime BuildAt { get { return new DateTime(637915984703608685); } } //--**
|
public static DateTime BuildAt { get { return new DateTime(637916008895872612); } } //--**
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The program that time stamped it.
|
/// The program that time stamped it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -76,13 +76,13 @@ namespace AyaNovaQBI
|
|||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
return "OK";
|
return "OK";
|
||||||
else
|
else
|
||||||
return "Failed: " + response.StatusCode.ToString();
|
return $"Failed: {response.StatusCode.ToString()}";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
while (ex.InnerException != null)
|
while (ex.InnerException != null)
|
||||||
ex = ex.InnerException;
|
ex = ex.InnerException;
|
||||||
return "Failed exception: \r\n" + ex.Message;
|
return $"Failed exception: \r\n{ex.Message}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ namespace AyaNovaQBI
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
InnerErr = ex.InnerException.Message;
|
InnerErr = ex.InnerException.Message;
|
||||||
|
|
||||||
throw new Exception("Authentication error, route: AUTH\r\nError:" + Err + "\r\nInner error:" + InnerErr);
|
throw new Exception($"Authentication error, route: AUTH\r\nError:{Err}\r\nInner error:{InnerErr}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var a = new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
|
var a = new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
|
||||||
@@ -217,7 +217,7 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//no luck re-throw the exception
|
//no luck re-throw the exception
|
||||||
throw new Exception("API call failed after " + MAX_TRIES.ToString() + " attempts", FirstException);
|
throw new Exception($"API call failed after {MAX_TRIES.ToString()} attempts", FirstException);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async static Task<ApiResponse> TryGetAsync(string route)
|
private async static Task<ApiResponse> TryGetAsync(string route)
|
||||||
@@ -238,14 +238,14 @@ namespace AyaNovaQBI
|
|||||||
var InnerErr = "";
|
var InnerErr = "";
|
||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
InnerErr = ex.InnerException.Message;
|
InnerErr = ex.InnerException.Message;
|
||||||
throw new Exception("GET error, route: " + route + "\r\nError:" + Err + "\r\nInner error:" + InnerErr + "\r\nStack:" + ex.StackTrace);
|
throw new Exception($"GET error, route: {route}\r\nError:{Err}\r\nInner error:{InnerErr}\r\nStack:{ex.StackTrace}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var responseAsString = await response.Content.ReadAsStringAsync();
|
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
throw new Exception("GET error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase);
|
throw new Exception($"GET error, code: {(int)response.StatusCode}, route: {route}\r\n{responseAsString}\r\n{response.ReasonPhrase}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||||
@@ -273,7 +273,7 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//no luck re-throw the exception
|
//no luck re-throw the exception
|
||||||
throw new Exception("API call failed after " + MAX_TRIES.ToString() + " attempts", FirstException);
|
throw new Exception($"API call failed after {MAX_TRIES.ToString()} attempts", FirstException);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async static Task<ApiResponse> PostAsync(string route, string s = null)
|
public async static Task<ApiResponse> PostAsync(string route, string s = null)
|
||||||
@@ -295,7 +295,7 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//no luck re-throw the exception
|
//no luck re-throw the exception
|
||||||
throw new Exception("API call failed after " + MAX_TRIES.ToString() + " attempts", FirstException);
|
throw new Exception($"API call failed after {MAX_TRIES.ToString()} attempts", FirstException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,14 +320,14 @@ namespace AyaNovaQBI
|
|||||||
var InnerErr = "";
|
var InnerErr = "";
|
||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
InnerErr = ex.InnerException.Message;
|
InnerErr = ex.InnerException.Message;
|
||||||
throw new Exception("POST error, route: " + route + "\r\nError:" + Err + "\r\nInner error:" + InnerErr + "\r\nStack:" + ex.StackTrace + "\r\nPOSTED OBJECT:\r\n" + postJson);
|
throw new Exception($"POST error, route: {route}\r\nError:{Err}\r\nInner error:{InnerErr}\r\nStack:{ex.StackTrace}\r\nPOSTED OBJECT:\r\n{postJson}");
|
||||||
}
|
}
|
||||||
var responseAsString = await response.Content.ReadAsStringAsync();
|
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(postJson))
|
if (string.IsNullOrWhiteSpace(postJson))
|
||||||
postJson = "n/a";
|
postJson = "n/a";
|
||||||
throw new Exception("POST error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase + "\r\nPOSTED OBJECT:\r\n" + postJson);
|
throw new Exception($"POST error, code: {(int)response.StatusCode}, route: {route}\r\n{responseAsString}\r\n{response.ReasonPhrase}\r\nPOSTED OBJECT:\r\n{postJson}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||||
@@ -382,7 +382,7 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//no luck re-throw the exception
|
//no luck re-throw the exception
|
||||||
throw new Exception("API call failed after " + MAX_TRIES.ToString() + " attempts", FirstException);
|
throw new Exception($"API call failed after {MAX_TRIES.ToString()} attempts", FirstException);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async static Task<ApiResponse> PutAsync(string route)
|
public async static Task<ApiResponse> PutAsync(string route)
|
||||||
@@ -404,7 +404,7 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//no luck re-throw the exception
|
//no luck re-throw the exception
|
||||||
throw new Exception("API call failed after " + MAX_TRIES.ToString() + " attempts", FirstException);
|
throw new Exception($"API call failed after {MAX_TRIES.ToString()} attempts", FirstException);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async static Task<ApiResponse> TryPutAsync(string route, string putJson = null)
|
public async static Task<ApiResponse> TryPutAsync(string route, string putJson = null)
|
||||||
@@ -427,14 +427,14 @@ namespace AyaNovaQBI
|
|||||||
var InnerErr = "";
|
var InnerErr = "";
|
||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
InnerErr = ex.InnerException.Message;
|
InnerErr = ex.InnerException.Message;
|
||||||
throw new Exception("PUT error, route: " + route + "\r\nError:" + Err + "\r\nInner error:" + InnerErr + "\r\nStack:" + ex.StackTrace + "\r\nPOSTED OBJECT:\r\n" + putJson);
|
throw new Exception($"PUT error, route: {route}\r\nError:{Err}\r\nInner error:{InnerErr}\r\nStack:{ex.StackTrace}\r\nPOSTED OBJECT:\r\n{putJson}");
|
||||||
}
|
}
|
||||||
var responseAsString = await response.Content.ReadAsStringAsync();
|
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(putJson))
|
if (string.IsNullOrWhiteSpace(putJson))
|
||||||
putJson = "n/a";
|
putJson = "n/a";
|
||||||
throw new Exception("PUT error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase + "\r\nPUT OBJECT:\r\n" + putJson);
|
throw new Exception($"PUT error, code: {(int)response.StatusCode}, route: {route}\r\n{responseAsString}\r\n{response.ReasonPhrase}\r\nPUT OBJECT:\r\n{putJson}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||||
@@ -528,11 +528,7 @@ namespace AyaNovaQBI
|
|||||||
//BUILD DATE VERSION ALLOWED?
|
//BUILD DATE VERSION ALLOWED?
|
||||||
if (ALicense.maintenanceExpiration < Timestamp.BuildAt)
|
if (ALicense.maintenanceExpiration < Timestamp.BuildAt)
|
||||||
{
|
{
|
||||||
initErrors.AppendLine("NOT LICENSED!\r\n\r\nThis QBI plugin was built " +
|
initErrors.AppendLine($"NOT LICENSED!\r\n\r\nThis QBI plugin was built {Timestamp.BuildAt.ToString("g")}\r\nbut the licensed support and updates subscription has ended on {ALicense.maintenanceExpiration.ToLocalTime().ToString("g")}\r\n\r\nDowngrade back to your previous licensed QBI version or\r\npurchase a support and updates subscription to continue using this version of QBI.");
|
||||||
Timestamp.BuildAt.ToString("g") + "\r\n" +
|
|
||||||
"but the licensed support and updates subscription has ended on " +
|
|
||||||
ALicense.maintenanceExpiration.ToLocalTime().ToString("g") + "\r\n" +
|
|
||||||
"\r\nDowngrade back to your previous licensed QBI version or\r\npurchase a support and updates subscription to continue using this version of QBI.");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,18 +539,19 @@ namespace AyaNovaQBI
|
|||||||
LOG_AVAILABLE = true;
|
LOG_AVAILABLE = true;
|
||||||
|
|
||||||
|
|
||||||
//Validate QB connection can be made and open connection and start session with QB (see Util.QBValidate in v7
|
await IntegrationLog($"PFC: AyaNova user \"{AyaNovaUserName}\" starting QBI, pre-flight check (PFC) commencing");
|
||||||
|
|
||||||
|
//QB CONNECTION validation and setup
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if(await QBValidate() == pfstat.Cancel)
|
||||||
var pfstatus = await QBValidate();
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
{
|
||||||
initErrors.AppendLine($"QuickBooks connection validation failed before connecting\r\n{ex.Message}");
|
await IntegrationLog("PFC: Unable to validate QuickBooks connection, user selected cancel");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await IntegrationLog($"PFC: QB Company name= {QCompanyName}, QB Country version={QCountry}, QBVersion={QVersion}, Companyfile={QCompanyFile}");
|
||||||
//once connected collect the country, version we are dealing with (Util.qbValidate)
|
//once connected collect the country, version we are dealing with (Util.qbValidate)
|
||||||
//confirm qb is 2008 or newer and bail if not (util.qbvalidate)
|
//confirm qb is 2008 or newer and bail if not (util.qbvalidate)
|
||||||
//cache company name and other qb info
|
//cache company name and other qb info
|
||||||
@@ -567,6 +564,15 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
//PFC - verify integration mapped objects still exist at each end (Util.PreFlightCheck() line 199)
|
//PFC - verify integration mapped objects still exist at each end (Util.PreFlightCheck() line 199)
|
||||||
//DONE
|
//DONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
initErrors.AppendLine($"QuickBooks connection validation failed before connecting\r\n{ex.Message}");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -594,7 +600,8 @@ namespace AyaNovaQBI
|
|||||||
QBIntegration.Active = true;
|
QBIntegration.Active = true;
|
||||||
QBIntegration.Name = "QBI - QuickBooks Desktop integration";
|
QBIntegration.Name = "QBI - QuickBooks Desktop integration";
|
||||||
r = await PostAsync("integration", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
r = await PostAsync("integration", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
||||||
var id = IdFromResponse(r);
|
QBIntegration.Id = IdFromResponse(r);
|
||||||
|
await IntegrationLog("AyaNova QBI Integration installed to AyaNova");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -661,17 +668,28 @@ namespace AyaNovaQBI
|
|||||||
sessionManager.CloseConnection();
|
sessionManager.CloseConnection();
|
||||||
if (ex.ErrorCode == -2147220458 || ex.ErrorCode == -2147220472 || ex.Message.Contains("Could not start"))
|
if (ex.ErrorCode == -2147220458 || ex.ErrorCode == -2147220472 || ex.Message.Contains("Could not start"))
|
||||||
{
|
{
|
||||||
|
var msg = "QuickBooks doesn't appear to be running on this computer.\r\n" +
|
||||||
|
"Start QuickBooks and open your company file now before proceeding.";
|
||||||
|
|
||||||
|
await IntegrationLog($"PFC: {msg}");
|
||||||
|
|
||||||
if (MessageBox.Show(
|
if (MessageBox.Show(
|
||||||
"QuickBooks doesn't appear to be running on this computer.\r\n" +
|
msg,
|
||||||
"Start QuickBooks and open your company file now before proceeding.",
|
|
||||||
"AyaNova QBI: Pre flight check",
|
"AyaNova QBI: Pre flight check",
|
||||||
MessageBoxButtons.RetryCancel, MessageBoxIcon.Information) == DialogResult.Cancel) return pfstat.Cancel;
|
MessageBoxButtons.RetryCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
|
||||||
|
{
|
||||||
|
await IntegrationLog($"PFC: User opted to cancel");
|
||||||
|
return pfstat.Cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
await IntegrationLog($"PFC: User opted to retry");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await IntegrationLog("PFC: QBValidate connect unanticipated exception: " + ex.Message + "\r\nError code:" + ex.ErrorCode.ToString());
|
await IntegrationLog($"PFC: QBValidate connect unanticipated exception: {ex.Message}\r\nError code:{ex.ErrorCode.ToString()}");
|
||||||
MessageBox.Show(ex.Message + "\r\nError code:" + string.Format("(HRESULT:0x{0:X8})", ex.ErrorCode));
|
MessageBox.Show($"{ex.Message}\r\nError code:{string.Format("(HRESULT:0x{0:X8})", ex.ErrorCode)}");
|
||||||
return pfstat.Cancel;
|
return pfstat.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -718,18 +736,10 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
if (QVersion < 6.0)
|
if (QVersion < 6.0)
|
||||||
{
|
{
|
||||||
await IntegrationLog("PFC: Failed, QuickBooks found is too old, 2008 or higher is required, prompted user to run QB update utility to be able to proceed");
|
var msg = $"You seem to be running QuickBooks older than 2008\r\nYou must update to 2008 or higher before you can use AyaNova QBI.\r\n\r\n(If you are running QuickBooks 2008 or higher and still getting this error, ensure that you are also using QBFC15 or higher)\r\n\r\nVERSION FOUND = {QVersion}";
|
||||||
CopyableMessageBox cp = new CopyableMessageBox(
|
await IntegrationLog($"PFC: Failed - {msg}");
|
||||||
|
CopyableMessageBox cp = new CopyableMessageBox(msg);
|
||||||
"You seem to be running QuickBooks older than 2008\r\n" +
|
|
||||||
"You must update to 2008 or higher before you can use AyaNova QBI.\r\n\r\n" +
|
|
||||||
"(If you are running QuickBooks 2008 or higher and still getting this error, ensure that you are also using QBFC7 or higher)\r\n\r\n" +
|
|
||||||
"VERSION FOUND = " + QVersion
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
cp.ShowDialog();
|
cp.ShowDialog();
|
||||||
|
|
||||||
return pfstat.Failed;
|
return pfstat.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,8 +763,8 @@ namespace AyaNovaQBI
|
|||||||
IResponse response = responseSet.ResponseList.GetAt(0);
|
IResponse response = responseSet.ResponseList.GetAt(0);
|
||||||
if (response.StatusCode != 0)
|
if (response.StatusCode != 0)
|
||||||
{
|
{
|
||||||
await IntegrationLog("PFC: Failed Company query:" + response.StatusMessage + ", " + response.StatusCode.ToString());
|
await IntegrationLog($"PFC: Failed Company query:{response.StatusMessage}, {response.StatusCode.ToString()}");
|
||||||
throw new ApplicationException("PFC: Failed Company query:" + response.StatusMessage + ", " + response.StatusCode.ToString());
|
throw new ApplicationException($"PFC: Failed Company query:{response.StatusMessage}, {response.StatusCode.ToString()}");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,9 +772,7 @@ namespace AyaNovaQBI
|
|||||||
QCompanyName = ProcessQBString(cl.CompanyName);
|
QCompanyName = ProcessQBString(cl.CompanyName);
|
||||||
requestSet.ClearRequests();
|
requestSet.ClearRequests();
|
||||||
//----------------
|
//----------------
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// QCompanyName=QCompanyFile;
|
|
||||||
|
|
||||||
// Close the session and connection with QuickBooks
|
// Close the session and connection with QuickBooks
|
||||||
sessionManager.EndSession();
|
sessionManager.EndSession();
|
||||||
@@ -776,7 +784,7 @@ namespace AyaNovaQBI
|
|||||||
{
|
{
|
||||||
//MessageBox.Show(ex.Message.ToString() + "\nStack Trace: \n" + ex.StackTrace + "\nExiting the application");
|
//MessageBox.Show(ex.Message.ToString() + "\nStack Trace: \n" + ex.StackTrace + "\nExiting the application");
|
||||||
|
|
||||||
await IntegrationLog("PFC: Failed with exception:" + ex.Message);
|
await IntegrationLog($"PFC: Failed with exception:{ex.Message}");
|
||||||
if (booSessionBegun)
|
if (booSessionBegun)
|
||||||
{
|
{
|
||||||
sessionManager.EndSession();
|
sessionManager.EndSession();
|
||||||
@@ -880,11 +888,9 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
catch (System.FormatException)
|
catch (System.FormatException)
|
||||||
{
|
{
|
||||||
CopyableMessageBox cp = new CopyableMessageBox("SafeToDouble: Can't parse QB string double version number:\r\n[" +
|
CopyableMessageBox cp = new CopyableMessageBox($"SafeToDouble: Can't parse QB string double version number:\r\n[{s}]\r\nPlease copy and send this message to AyaNova tech support at support@ayanova.com");
|
||||||
s +
|
|
||||||
"]\r\nPlease copy and send this message to AyaNova tech support at support@ayanova.com");
|
|
||||||
cp.ShowDialog();
|
cp.ShowDialog();
|
||||||
throw new System.ApplicationException("SafeToDouble: Can't parse QB string double value number: \"" + s + "\"");
|
throw new System.ApplicationException($"SafeToDouble: Can't parse QB string double value number: \"{s}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retvalue;
|
return retvalue;
|
||||||
|
|||||||
Reference in New Issue
Block a user