50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Interop.QBFC13;
|
|
using Interop.QBXMLRP2;
|
|
|
|
namespace BodyshopPartner.Utils
|
|
{
|
|
public static class QuickBooksInterop
|
|
{
|
|
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
private static string ticket;
|
|
private static RequestProcessor2 rp;
|
|
private static string maxVersion;
|
|
private static string companyFile = "";
|
|
private static QBFileMode mode = QBFileMode.qbFileOpenDoNotCare;
|
|
private static string appID = "IDN123";
|
|
private static string appName = "BodyshopPartner";
|
|
|
|
public static void ConnectToQuickBooks()
|
|
{
|
|
|
|
rp = new RequestProcessor2Class();
|
|
rp.OpenConnection(appID, appName);
|
|
ticket = rp.BeginSession(companyFile, mode);
|
|
string[] versions = rp.get_QBXMLVersionsForSession(ticket);
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|