Updates to logging and v1.0.3 release.

This commit is contained in:
Patrick Fic
2020-12-03 10:41:57 -08:00
parent 12b095a406
commit 2acc8faa5b
9 changed files with 113 additions and 26 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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.3")]
//Setting Squirrel Aware Version.
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

View File

@@ -1,3 +1 @@
2170C39D054590A1CEFFBB68922BB3FBFF82A625 ImEXOnlinePartner-1.0.0-full.nupkg 4987861
6AC5040BEFF741735A2A6497D5BA5C0E1DB247C9 ImEXOnlinePartner-1.0.1-delta.nupkg 32948
59F79A6A3C31AB03C297E40648B468F62424C03B ImEXOnlinePartner-1.0.1-full.nupkg 4988035
27267F96DE441041026E9EE4292798734572912A ImEXOnlinePartner-1.0.3-full.nupkg 4989160

View File

@@ -9,6 +9,7 @@ using Newtonsoft;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using BodyshopPartner.Models;
using ToastNotifications.Messages;
namespace BodyshopPartner.Utils
{
@@ -33,9 +34,31 @@ namespace BodyshopPartner.Utils
logger.Trace("Starting HTTP server...");
hlog = HttpLogger;
hlog("Starting HTTP server...");
//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...");
}
catch (Exception Ex)
{
logger.Fatal("Unable to start HTTP server. " + Ex.ToString());
App.Current.Dispatcher.Invoke(() =>
{
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();
//Growler.AddNotification(new Notification()
//{
// Title = Properties.Resources.Msg_NewJobUploaded,
// Subtitle = item.Job?.ownr_fn?.Value + " " + item.Job?.ownr_ln?.Value + " | " + item.Job?.clm_no?.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
//});
});
}
}
private static void HandleQbPost(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)

View File

@@ -10,6 +10,19 @@ namespace BodyshopPartner.Utils
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
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();
}
public static void InitializeSquirrelAware()
{
using (var mgr = new UpdateManager(Utils.UpdateHandler.UpdatePath))
@@ -22,15 +35,8 @@ namespace BodyshopPartner.Utils
logger.Debug("Installing via Squirrel Aware Helper. ", v);
try
{
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();
bool successful = AddHttpExcetion();
if (successful)
{

View File

@@ -29,6 +29,9 @@ namespace BodyshopPartner.Utils
logger.Debug("No releases to apply.");
return false;
}
updateInfo.ReleasesToApply.ForEach(release => logger.Debug("Release to apply " + release.Version));
return true;
}
}
@@ -52,12 +55,24 @@ namespace BodyshopPartner.Utils
}
using (var updateManager = new UpdateManager(UpdatePath))
{
try
{
var updateInfo = await updateManager.CheckForUpdate();
var releases = updateInfo.ReleasesToApply;
logger.Debug("Applying releases", releases.ToString());
await updateManager.DownloadReleases(releases, _ => { DownloadProgress = _; });
await updateManager.ApplyReleases(updateInfo, _ => { InstallProgress = _; });
await updateManager.DownloadReleases(releases, _ => {
logger.Debug("Download Release Progress " + _.ToString());
DownloadProgress = _; });
await updateManager.ApplyReleases(updateInfo, _ => {
logger.Debug("Install Progress " + _.ToString());
InstallProgress = _; });
}
catch (Exception Ex)
{
logger.Error("Error updating Partner App. " + Ex.ToString());
}
}
}

View File

@@ -135,6 +135,26 @@ namespace BodyshopPartner.ViewModels
}
}
private ICommand _installUpdatesCommand;
public ICommand InstallUpdatesCommand
{
get
{
if (_installUpdatesCommand == null)
{
_installUpdatesCommand = new RelayCommand(
p => UpdateAvailable,
async p =>
{
await InstallUpdates();
});
}
return _installUpdatesCommand;
}
}
private ICommand _quitCommand;
public ICommand QuitCommand
{

View File

@@ -91,11 +91,18 @@ namespace BodyshopPartner.ViewModels
private async Task updateCheck()
{
logger.Debug("Checking if updates are available.");
if (await Utils.UpdateHandler.AreUpdatesAvailable())
UpdateAvailable = await Utils.UpdateHandler.AreUpdatesAvailable();
if (UpdateAvailable)
{
string msg = "An update to ImEX Online Partner is Available";
Utils.Notifications.notifier.ShowInformation(msg);
}
}
private async Task InstallUpdates()
{
logger.Debug("Updates are available! Installing.");
await Utils.UpdateHandler.ApplyUpdates(Progress, Progress);
}
await Utils.UpdateHandler.ApplyUpdates(UpdateProgress, UpdateProgress);
}
private async void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)

View File

@@ -63,5 +63,19 @@ namespace BodyshopPartner.ViewModels
get { return _appVersion; }
set { SetProperty(ref _appVersion, value); }
}
private bool _updateAvailable = false;
public bool UpdateAvailable
{
get { return _updateAvailable; }
set { SetProperty(ref _updateAvailable, value); }
}
private int _updateProgress;
public int UpdateProgress
{
get { return _updateProgress; }
set { SetProperty(ref _updateProgress, value); }
}
}
}

View File

@@ -11,7 +11,7 @@
xmlns:vm="clr-namespace:BodyshopPartner.ViewModels"
mc:Ignorable="d"
Title="{x:Static p:Resources.Title_Main}"
Height="489.819"
Height="600"
Width="800"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
@@ -28,6 +28,7 @@
<Window.Resources>
<util:OpenMainWindowCommand x:Key="OpenMainWindowCommand" />
<util:MonitorStatusConverter x:Key="MonitorStatusConverter" />
<util:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
<Style TargetType="StackPanel">
<Setter Property="Margin"
Value="8" />
@@ -152,7 +153,10 @@
<Label DockPanel.Dock="Top"
Margin="8"
Content="{Binding AppVersion}" />
<StackPanel Visibility="{Binding UpdateAvailable, Converter={StaticResource BoolVisibilityConverter}}">
<Button Content="Update" Command="{Binding InstallUpdatesCommand}" />
<ProgressBar Margin="8" Value="{Binding UpdateProgress}"/>
</StackPanel>
</StackPanel>
<Grid>
<Grid.RowDefinitions>