Added ping handler. IO-406

This commit is contained in:
Patrick Fic
2021-02-22 17:04:13 -08:00
parent 50279d34ac
commit 1a364c91ef
4 changed files with 40 additions and 6 deletions

View File

@@ -101,6 +101,8 @@ namespace BodyshopPartner.Utils.Decoder
{
var reader = new DBFReader(fis);
var type = reader.GetType();
reader.SetSelectFields(new string[] { "INS_CO_ID","INS_CO_NM","INS_ADDR1","INS_ADDR2","INS_CITY","INS_ST","INS_ZIP","INS_CTRY",
"INS_EA","POLICY_NO","DED_AMT","DED_STATUS","ASGN_NO","ASGN_DATE","ASGN_TYPE","CLM_NO","CLM_OFC_ID","CLM_OFC_NM","CLM_ADDR1",

View File

@@ -27,7 +27,7 @@ namespace BodyshopPartner.Utils
using (var g = Utils.GraphQL.CreateGQLClient())
{
logger.Trace("Firing a GQL Query!");
// logger.Trace("Firing GQL Query: {0} {1}", r.Query.ToString(), r.Variables);
logger.Trace("Firing GQL Query: {0} {1}", r.Query.ToString(), r.Variables);
var graphQLResponse = await g.SendQueryAsync<dynamic>(r);
if (graphQLResponse.Errors == null)
{

View File

@@ -11,6 +11,7 @@ using Newtonsoft.Json.Linq;
using BodyshopPartner.Models;
using ToastNotifications.Messages;
using System.Threading;
using System.Reflection;
namespace BodyshopPartner.Utils
{
@@ -36,6 +37,19 @@ namespace BodyshopPartner.Utils
(req, res, props) => { HandleQbPost(req, res); }
, "POST");
Route.Add("/ping/", (req, res, props) =>
{
hlog("Received a ping from ImEX.online");
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.Close();
}, "OPTIONS");
Route.Add("/ping/",
(req, res, props) => { HandlePing(req, res); }
, "POST");
logger.Trace("Starting HTTP server...");
hlog = HttpLogger;
@@ -125,6 +139,22 @@ namespace BodyshopPartner.Utils
}
private static void HandlePing(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
{
logger.Trace("/ping/ - POST");
hlog("Received QuickBooks Receivable request.");
//Input will be an array of objects containing XMLs.
dynamic response = new JObject();
response.appver = Assembly.GetExecutingAssembly().GetName().Version.ToString();
response.qbpath = Properties.Settings.Default.QuickBooksFilePath;
var t = JsonConvert.SerializeObject(response);
res.WithCORS().AsText((string)t.ToString());
}
public static List<QbRequestItem> ParseRequest(System.Net.HttpListenerRequest req)
{
System.IO.Stream body = req.InputStream;

View File

@@ -223,9 +223,11 @@ namespace BodyshopPartner.ViewModels
ShopData = Data.bodyshops.ToObject<ObservableCollection<Bodyshop>>();
}
ActiveShop = ShopData.Where(_ => _.AssociationActive == true).FirstOrDefault();
Properties.Settings.Default.LastSelectedShop = ActiveShop.Id ?? null;
Properties.Settings.Default.Save();
ActiveShop = ShopData.Where(_ => _.AssociationActive == true).FirstOrDefault();
Utils.AppMetaData.ActiveShopId = ActiveShop?.Id;
Utils.AppMetaData.ShopRegion = ActiveShop?.RegionConfig;
Properties.Settings.Default.LastSelectedShop = ActiveShop.Id ?? null;
Properties.Settings.Default.Save();
}