Successful connection/disconnection from QB.
This commit is contained in:
@@ -24,7 +24,9 @@ namespace BodyshopPartner.Utils
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Got a hit.");
|
Console.WriteLine("Got a hit.");
|
||||||
//res.WithCORS();
|
//res.WithCORS();
|
||||||
Utils.QuickBooksInterop.connectToQuickBooks();
|
Utils.QuickBooksInterop.ConnectToQuickBooks();
|
||||||
|
Utils.QuickBooksInterop.DisconnectFromQuickBooks();
|
||||||
|
|
||||||
|
|
||||||
res.WithCORS().AsText("Hello.");
|
res.WithCORS().AsText("Hello.");
|
||||||
}, "POST");
|
}, "POST");
|
||||||
|
|||||||
@@ -10,22 +10,40 @@ namespace BodyshopPartner.Utils
|
|||||||
{
|
{
|
||||||
public static class QuickBooksInterop
|
public static class QuickBooksInterop
|
||||||
{
|
{
|
||||||
|
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
private static string ticket;
|
private static string ticket;
|
||||||
private static RequestProcessor2 rp;
|
private static RequestProcessor2 rp;
|
||||||
private static string maxVersion;
|
private static string maxVersion;
|
||||||
private static string companyFile = "";
|
private static string companyFile = "";
|
||||||
private static QBFileMode mode = QBFileMode.qbFileOpenDoNotCare;
|
private static QBFileMode mode = QBFileMode.qbFileOpenDoNotCare;
|
||||||
private static string appID = "IDN123";
|
private static string appID = "IDN123";
|
||||||
private static string appName = "BodyshopPartner";
|
private static string appName = "BodyshopPartner";
|
||||||
|
|
||||||
public static void connectToQuickBooks()
|
public static void ConnectToQuickBooks()
|
||||||
{
|
{
|
||||||
|
|
||||||
rp = new RequestProcessor2Class();
|
rp = new RequestProcessor2Class();
|
||||||
rp.OpenConnection(appID, appName);
|
rp.OpenConnection(appID, appName);
|
||||||
ticket = rp.BeginSession(companyFile, mode);
|
ticket = rp.BeginSession(companyFile, mode);
|
||||||
string[] versions = rp.get_QBXMLVersionsForSession(ticket);
|
string[] versions = rp.get_QBXMLVersionsForSession(ticket);
|
||||||
maxVersion = versions[versions.Length - 1];
|
maxVersion = versions[versions.Length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DisconnectFromQuickBooks()
|
||||||
|
{
|
||||||
|
if (ticket != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rp.EndSession(ticket);
|
||||||
|
ticket = null;
|
||||||
|
rp.CloseConnection();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user