IO-1739 IO-1735 Updated partner script location, paint manager, and remove unnecessary startup script
This commit is contained in:
@@ -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.31.0")]
|
||||
[assembly: AssemblyVersion("1.0.32.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
//Setting Squirrel Aware Version.
|
||||
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.IO;
|
||||
|
||||
namespace BodyshopPartner.Utils
|
||||
{
|
||||
@@ -19,6 +20,9 @@ namespace BodyshopPartner.Utils
|
||||
public static string graphQlEndpoint;
|
||||
public static string FirebaseAPIKey;
|
||||
public static Boolean IsTest = false;
|
||||
private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
public static string globalScriptsPath = @"C:\ImEX\PartnerScripts";
|
||||
public static void CreateEndpoints()
|
||||
{
|
||||
logger.Debug("Creating endpoints for graphql.");
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace BodyshopPartner.Utils
|
||||
try
|
||||
{
|
||||
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection");
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection Export");
|
||||
if (existingTask != null)
|
||||
{
|
||||
TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - Paint Scale Connection");
|
||||
TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - Paint Scale Connection Export");
|
||||
}
|
||||
Microsoft.Win32.TaskScheduler.Task newTask = TaskService.Instance.AddTask("ImEX Online Partner - Paint Scale Connection", QuickTriggerType.Hourly, "powershell.exe", @"-ExecutionPolicy Bypass -File " + workingDirectory + @"\Utils\Scripts\PaintScaleExport.ps1");
|
||||
Microsoft.Win32.TaskScheduler.Task newTask = TaskService.Instance.AddTask("ImEX Online Partner - Paint Scale Connection Export", QuickTriggerType.Hourly, "powershell.exe", @"-ExecutionPolicy Bypass -File " + AppMetaData.globalScriptsPath + @"\PaintScaleExport.ps1");
|
||||
newTask.Run();
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace BodyshopPartner.Utils
|
||||
{
|
||||
TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - ARMS");
|
||||
}
|
||||
Microsoft.Win32.TaskScheduler.Task newTask = TaskService.Instance.AddTask("ImEX Online Partner - ARMS", QuickTriggerType.Daily, "powershell.exe", @"-ExecutionPolicy Bypass -File " + workingDirectory + @"\Utils\Scripts\ArmsExport.ps1");
|
||||
Microsoft.Win32.TaskScheduler.Task newTask = TaskService.Instance.AddTask("ImEX Online Partner - ARMS", QuickTriggerType.Daily, "powershell.exe", @"-ExecutionPolicy Bypass -File " + AppMetaData.globalScriptsPath + @"\ArmsExport.ps1");
|
||||
newTask.Run();
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Squirrel;
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
using System.IO;
|
||||
|
||||
|
||||
namespace BodyshopPartner.Utils
|
||||
@@ -13,6 +14,7 @@ namespace BodyshopPartner.Utils
|
||||
public static class SquirrelAwareHelper
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
public static bool AddHttpExcetion()
|
||||
{
|
||||
@@ -38,6 +40,47 @@ namespace BodyshopPartner.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CopyScripts()
|
||||
{
|
||||
logger.Debug("Attempting to copy scripts to global dir.");
|
||||
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(AppMetaData.globalScriptsPath))
|
||||
{
|
||||
Directory.CreateDirectory(AppMetaData.globalScriptsPath);
|
||||
}
|
||||
foreach (var srcPath in Directory.GetFiles(workingDirectory + @"\Utils\Scripts"))
|
||||
{
|
||||
File.Copy(srcPath, srcPath.Replace(workingDirectory + @"\Utils\Scripts", AppMetaData.globalScriptsPath), true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
logger.Error("Unable to copy scripts " + Ex.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void RemoveOldPaintScaleScript()
|
||||
{
|
||||
//The paint scale accidentally got added to all people running v31. This was added to remove it.
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection");
|
||||
if (existingTask != null)
|
||||
{
|
||||
TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - Paint Scale Connection");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Error removing old paint scale task.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitializeSquirrelAware()
|
||||
{
|
||||
using (var mgr = new UpdateManager(Utils.UpdateHandler.UpdatePath))
|
||||
@@ -48,9 +91,33 @@ namespace BodyshopPartner.Utils
|
||||
onInitialInstall: v =>
|
||||
{
|
||||
logger.Debug("Installing via Squirrel Aware Helper. ", v);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//Copy scripts from util directory to ImEX Utils.
|
||||
|
||||
bool successful = CopyScripts();
|
||||
if (successful)
|
||||
{
|
||||
logger.Debug("Successfully copied scripts");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error("Unable to copy scripts.");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
logger.Fatal(Ex, "Unable to copy scripts.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//Copy scripts from util directory to ImEX Utils.
|
||||
|
||||
bool successful = AddHttpExcetion();
|
||||
if (successful)
|
||||
{
|
||||
@@ -74,14 +141,16 @@ namespace BodyshopPartner.Utils
|
||||
mgr.CreateShortcutForThisExe();
|
||||
Utils.UpdateHandler.RestoreSettings();
|
||||
Utils.UpdateHandler.ToggleStartWithWindows(Properties.Settings.Default.StartWithWindows);
|
||||
Utils.ScheduledTaskConfig.RegisterPaintScale();
|
||||
CopyScripts();
|
||||
RemoveOldPaintScaleScript();
|
||||
|
||||
},
|
||||
onAppUninstall: v =>
|
||||
{
|
||||
mgr.RemoveShortcutForThisExe();
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection");
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection Export"); //This is the old scale path. This was accidentally added for everyone.
|
||||
if (existingTask != null)
|
||||
{
|
||||
TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - Paint Scale Connection");
|
||||
@@ -91,6 +160,30 @@ namespace BodyshopPartner.Utils
|
||||
{
|
||||
logger.Error(ex, "Error removing task while uninstalling.");
|
||||
}
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - Paint Scale Connection Export");
|
||||
if (existingTask != null)
|
||||
{
|
||||
TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - Paint Scale Connection Export");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Error removing task while uninstalling.");
|
||||
}
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - ARMS");
|
||||
if (existingTask != null)
|
||||
{
|
||||
TaskService.Instance.RootFolder.DeleteTask("ImEX Online Partner - ARMS");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Error removing task while uninstalling.");
|
||||
}
|
||||
},
|
||||
|
||||
onFirstRun: () =>
|
||||
|
||||
@@ -369,7 +369,7 @@ namespace BodyshopPartner.ViewModels
|
||||
public async Task TestGql()
|
||||
{
|
||||
|
||||
Utils.SquirrelAwareHelper.AddHttpExcetion();
|
||||
Utils.SquirrelAwareHelper.CopyScripts();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user