Remove tray functionality from Partner App.

This commit is contained in:
Patrick Fic
2020-12-03 14:51:23 -08:00
parent 2acc8faa5b
commit 27960e9418
7 changed files with 56 additions and 51 deletions

View File

@@ -10,6 +10,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using BodyshopPartner.Models;
using ToastNotifications.Messages;
using System.Threading;
namespace BodyshopPartner.Utils
{
@@ -18,6 +19,9 @@ namespace BodyshopPartner.Utils
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public delegate void HttpLogger(string s);
private static HttpLogger hlog;
public static CancellationTokenSource tokenSource = new CancellationTokenSource();
public static CancellationToken token = tokenSource.Token;
public static void InitHttpServer(HttpLogger HttpLogger)
{
Route.Add("/qb/", (req, res, props) =>
@@ -34,12 +38,13 @@ namespace BodyshopPartner.Utils
logger.Trace("Starting HTTP server...");
hlog = HttpLogger;
//TODO As a part of the installer, add netsh http add urlacl url=http://+:1337/ user="Everyone
try
{
HttpServer.ListenAsync(1337, System.Threading.CancellationToken.None, Route.OnHttpRequestAsync).Wait();
hlog("ImEX Online connection server started...");
hlog("ImEX Online connection server starting...");
HttpServer.ListenAsync(1337, token, Route.OnHttpRequestAsync).Wait();
}
catch (Exception Ex)
{
@@ -49,8 +54,8 @@ namespace BodyshopPartner.Utils
string msg = "Unable to connect to ImEX Online Web App. Please ensure your firewall allows the connection.";
hlog("ImEX Online connection server could not start. Please restart the partner to try again.");
Utils.Notifications.notifier.ShowError(msg);
bool AddedException = Utils.SquirrelAwareHelper.AddHttpExcetion();
bool AddedException = Utils.SquirrelAwareHelper.AddHttpExcetion();
//Growler.AddNotification(new Notification()
//{
// Title = Properties.Resources.Msg_NewJobUploaded,
@@ -58,6 +63,7 @@ namespace BodyshopPartner.Utils
// //Message = item.Job?.vehicle?.data?.v_model_yr?.Value + " " + item.Job?.vehicle?.data?.v_make_desc?.Value + " " + item.Job?.vehicle?.data?.v_model_desc?.Value
//});
});
Utils.SquirrelAwareHelper.AddHttpExcetion();
}
}

View File

@@ -32,7 +32,7 @@ namespace BodyshopPartner.Utils.Queries
try
{
var d = await Utils.GraphQL.ExecuteQuery(r);
return d.jobs?[0].id;
return d?.jobs?[0]?.id;
}
catch (ArgumentOutOfRangeException Ex)

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -13,14 +14,35 @@ namespace BodyshopPartner.Utils
public static bool AddHttpExcetion()
{
logger.Debug("Attempting to add HTTP Exclusion for web-server");
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "netsh http add urlacl url=http://+:1337/ user=\"Everyone\"";
startInfo.Verb = "runas";
process.StartInfo = startInfo;
return process.Start();
string args = string.Format(@"http add urlacl url={0} user={1}", "http://+:1337/", "Everyone");
ProcessStartInfo psi = new ProcessStartInfo("netsh", args);
psi.Verb = "runas";
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = true;
try
{
Process.Start(psi).WaitForExit();
logger.Debug("Attempting to add HTTP Exclusion for web-server");
return true;
}
catch (Exception Ex)
{
logger.Error("Unable to register exception " + Ex.ToString());
return false;
}
// System.Diagnostics.Process process = new System.Diagnostics.Process();
// System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
// startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// startInfo.FileName = "cmd.exe";
// startInfo.Arguments = "netsh http add urlacl url=http://+:1337/ user=\"Everyone\"";
// startInfo.Verb = "runas";
// process.StartInfo = startInfo;
//return process.Start();
}
public static void InitializeSquirrelAware()
@@ -35,7 +57,7 @@ namespace BodyshopPartner.Utils
logger.Debug("Installing via Squirrel Aware Helper. ", v);
try
{
bool successful = AddHttpExcetion();
if (successful)