Added processing of XML.
This commit is contained in:
@@ -17,14 +17,19 @@ namespace BodyshopPartner.Utils
|
|||||||
{
|
{
|
||||||
res.WithCORS();
|
res.WithCORS();
|
||||||
//res.AddHeader("Access-Control-Allow-Origin", "http://localhost:3000 https://localhost:3000 http://localhost:5000 https://localhost:5000 https://*.imex.online,imex.online");
|
//res.AddHeader("Access-Control-Allow-Origin", "http://localhost:3000 https://localhost:3000 http://localhost:5000 https://localhost:5000 https://*.imex.online,imex.online");
|
||||||
res.Close() ;
|
res.Close();
|
||||||
}, "OPTIONS");
|
}, "OPTIONS");
|
||||||
|
|
||||||
Route.Add("/qb/receivables", (req, res, props) =>
|
Route.Add("/qb/receivables", (req, res, props) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine("Got a hit.");
|
logger.Debug("/qb/receivables - POST");
|
||||||
|
string AuthToken = req.Headers.Get("Authorization");
|
||||||
|
string requestXML = ParseBody(req);
|
||||||
|
logger.Trace("Incoming Request XML", requestXML);
|
||||||
|
|
||||||
//res.WithCORS();
|
//res.WithCORS();
|
||||||
Utils.QuickBooksInterop.ConnectToQuickBooks();
|
Utils.QuickBooksInterop.ConnectToQuickBooks();
|
||||||
|
string result = Utils.QuickBooksInterop.processRequestFromQB(requestXML);
|
||||||
Utils.QuickBooksInterop.DisconnectFromQuickBooks();
|
Utils.QuickBooksInterop.DisconnectFromQuickBooks();
|
||||||
|
|
||||||
|
|
||||||
@@ -36,5 +41,25 @@ namespace BodyshopPartner.Utils
|
|||||||
//TODO As a part of the installer, add netsh http add urlacl url=http://+:1337/ user="Everyone
|
//TODO As a part of the installer, add netsh http add urlacl url=http://+:1337/ user="Everyone
|
||||||
HttpServer.ListenAsync(1337, System.Threading.CancellationToken.None, Route.OnHttpRequestAsync).Wait();
|
HttpServer.ListenAsync(1337, System.Threading.CancellationToken.None, Route.OnHttpRequestAsync).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ParseBody(System.Net.HttpListenerRequest req)
|
||||||
|
{
|
||||||
|
System.IO.Stream body = req.InputStream;
|
||||||
|
System.Text.Encoding encoding = req.ContentEncoding;
|
||||||
|
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
|
||||||
|
if (req.ContentType != null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Client data content type {0}", req.ContentType);
|
||||||
|
}
|
||||||
|
Console.WriteLine("Client data content length {0}", req.ContentLength64);
|
||||||
|
|
||||||
|
Console.WriteLine("Start of client data:");
|
||||||
|
// Convert the data to a string and display it on the console.
|
||||||
|
string s = reader.ReadToEnd();
|
||||||
|
Console.WriteLine(s);
|
||||||
|
Console.WriteLine("End of client data:");
|
||||||
|
body.Close();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,17 +16,25 @@ namespace BodyshopPartner.Utils
|
|||||||
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 = "ImEXBSP";
|
||||||
private static string appName = "BodyshopPartner";
|
private static string appName = "BodyshopPartner";
|
||||||
|
|
||||||
public static void ConnectToQuickBooks()
|
public static void ConnectToQuickBooks()
|
||||||
{
|
{
|
||||||
|
|
||||||
rp = new RequestProcessor2Class();
|
try
|
||||||
rp.OpenConnection(appID, appName);
|
{
|
||||||
ticket = rp.BeginSession(companyFile, mode);
|
rp = new RequestProcessor2Class();
|
||||||
string[] versions = rp.get_QBXMLVersionsForSession(ticket);
|
rp.OpenConnection(appID, appName);
|
||||||
maxVersion = versions[versions.Length - 1];
|
ticket = rp.BeginSession(companyFile, mode);
|
||||||
|
string[] versions = rp.get_QBXMLVersionsForSession(ticket);
|
||||||
|
maxVersion = versions[versions.Length - 1];
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.Error(ex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DisconnectFromQuickBooks()
|
public static void DisconnectFromQuickBooks()
|
||||||
@@ -45,5 +53,18 @@ namespace BodyshopPartner.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static string processRequestFromQB(string request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return rp.ProcessRequest(ticket, request);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.Error(e.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace BodyshopPartner.ViewModels
|
|||||||
public partial class MainViewModel : BaseViewModel
|
public partial class MainViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
public GrowlNotification Growler;
|
public GrowlNotification Growler;
|
||||||
private System.Timers.Timer _updateCheckTimer = new System.Timers.Timer(60 * 1000);
|
private System.Timers.Timer _updateCheckTimer = new System.Timers.Timer(60 * 1000 * 60);
|
||||||
|
|
||||||
private ObservableCollection<Monitor> _monitoringPaths = new ObservableCollection<Monitor>();
|
private ObservableCollection<Monitor> _monitoringPaths = new ObservableCollection<Monitor>();
|
||||||
public ObservableCollection<Monitor> MonitoringPaths
|
public ObservableCollection<Monitor> MonitoringPaths
|
||||||
|
|||||||
Reference in New Issue
Block a user