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

@@ -51,7 +51,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4")] [assembly: AssemblyVersion("1.0.4.0")]
[assembly: AssemblyFileVersion("1.0.3")] [assembly: AssemblyFileVersion("1.0.4.0")]
//Setting Squirrel Aware Version. //Setting Squirrel Aware Version.
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

View File

@@ -10,6 +10,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using BodyshopPartner.Models; using BodyshopPartner.Models;
using ToastNotifications.Messages; using ToastNotifications.Messages;
using System.Threading;
namespace BodyshopPartner.Utils namespace BodyshopPartner.Utils
{ {
@@ -18,6 +19,9 @@ namespace BodyshopPartner.Utils
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public delegate void HttpLogger(string s); public delegate void HttpLogger(string s);
private static HttpLogger hlog; private static HttpLogger hlog;
public static CancellationTokenSource tokenSource = new CancellationTokenSource();
public static CancellationToken token = tokenSource.Token;
public static void InitHttpServer(HttpLogger HttpLogger) public static void InitHttpServer(HttpLogger HttpLogger)
{ {
Route.Add("/qb/", (req, res, props) => Route.Add("/qb/", (req, res, props) =>
@@ -34,12 +38,13 @@ namespace BodyshopPartner.Utils
logger.Trace("Starting HTTP server..."); logger.Trace("Starting HTTP server...");
hlog = HttpLogger; hlog = HttpLogger;
//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
try try
{ {
HttpServer.ListenAsync(1337, System.Threading.CancellationToken.None, Route.OnHttpRequestAsync).Wait(); hlog("ImEX Online connection server starting...");
hlog("ImEX Online connection server started..."); HttpServer.ListenAsync(1337, token, Route.OnHttpRequestAsync).Wait();
} }
catch (Exception Ex) 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."; 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."); hlog("ImEX Online connection server could not start. Please restart the partner to try again.");
Utils.Notifications.notifier.ShowError(msg); Utils.Notifications.notifier.ShowError(msg);
bool AddedException = Utils.SquirrelAwareHelper.AddHttpExcetion(); bool AddedException = Utils.SquirrelAwareHelper.AddHttpExcetion();
//Growler.AddNotification(new Notification() //Growler.AddNotification(new Notification()
//{ //{
// Title = Properties.Resources.Msg_NewJobUploaded, // 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 // //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 try
{ {
var d = await Utils.GraphQL.ExecuteQuery(r); var d = await Utils.GraphQL.ExecuteQuery(r);
return d.jobs?[0].id; return d?.jobs?[0]?.id;
} }
catch (ArgumentOutOfRangeException Ex) catch (ArgumentOutOfRangeException Ex)

View File

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

View File

@@ -208,7 +208,7 @@ namespace BodyshopPartner.ViewModels
if (string.IsNullOrEmpty(SettingsSelectedShopUuid)) if (string.IsNullOrEmpty(SettingsSelectedShopUuid))
{ {
ActiveShop = ShopData[0] ?? null; ActiveShop = ShopData[0] ?? null;
Properties.Settings.Default.LastSelectedShop = ShopData[0].Id ?? null; Properties.Settings.Default.LastSelectedShop = ShopData[0]?.Id ?? null;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
} }
else else
@@ -262,33 +262,7 @@ namespace BodyshopPartner.ViewModels
public async Task TestGql() public async Task TestGql()
{ {
try Utils.SquirrelAwareHelper.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 = "add netsh http add urlacl url=http://+:1337/ user=\"Everyone\"";
startInfo.Verb = "runas";
process.StartInfo = startInfo;
bool successful = process.Start();
if (successful)
{
logger.Debug("Successfully added exception.");
}
else
{
logger.Fatal("Unable to set exception for http port");
AddHttpStatus("Unable to add exception for the port! Please run as an administrator.");
}
}
catch (Exception Ex)
{
logger.Fatal("Unable to set exception for http port", Ex.ToString());
}
} }
} }

View File

@@ -4,7 +4,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:p="clr-namespace:BodyshopPartner.Properties" xmlns:p="clr-namespace:BodyshopPartner.Properties"
xmlns:properties="clr-namespace:BodyshopPartner.Properties" xmlns:properties="clr-namespace:BodyshopPartner.Properties"
xmlns:util="clr-namespace:BodyshopPartner.Utils" xmlns:util="clr-namespace:BodyshopPartner.Utils"
@@ -21,7 +20,8 @@
Background="{DynamicResource MaterialDesignPaper}" Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}" FontFamily="{DynamicResource MaterialDesignFont}"
Loaded="Window_Loaded" Loaded="Window_Loaded"
Closing="Window_Closing"> Closing="Window_Closing"
>
<Window.DataContext> <Window.DataContext>
<vm:MainViewModel /> <vm:MainViewModel />
</Window.DataContext> </Window.DataContext>
@@ -54,7 +54,7 @@
IsIndeterminate="{Binding IndeterminateLoading}" IsIndeterminate="{Binding IndeterminateLoading}"
Height="8" /> Height="8" />
<tb:TaskbarIcon DockPanel.Dock="Top" <!--<tb:TaskbarIcon DockPanel.Dock="Top"
IconSource="../favicon.ico" IconSource="../favicon.ico"
DoubleClickCommand="{StaticResource OpenMainWindowCommand}" DoubleClickCommand="{StaticResource OpenMainWindowCommand}"
PopupActivation="LeftClick" PopupActivation="LeftClick"
@@ -106,7 +106,7 @@
Command="{Binding QuitCommand}" /> Command="{Binding QuitCommand}" />
</ContextMenu> </ContextMenu>
</tb:TaskbarIcon.ContextMenu> </tb:TaskbarIcon.ContextMenu>
</tb:TaskbarIcon> </tb:TaskbarIcon>-->
<StackPanel DockPanel.Dock="Right"> <StackPanel DockPanel.Dock="Right">

View File

@@ -32,8 +32,10 @@ namespace BodyshopPartner.Views
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
e.Cancel = true ; //e.Cancel = true ;
this.Hide(); //this.Hide();
Utils.HTTPServer.tokenSource.Cancel();
Application.Current.Shutdown();
} }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
@@ -41,5 +43,6 @@ namespace BodyshopPartner.Views
Properties.Settings.Default.QuickBooksFilePath = ((System.Windows.Controls.TextBox)sender).Text; Properties.Settings.Default.QuickBooksFilePath = ((System.Windows.Controls.TextBox)sender).Text;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
} }
} }
} }