ARMS Uploader
This commit is contained in:
61
BodyshopUploader/Utils/ScheduledTaskConfig.cs
Normal file
61
BodyshopUploader/Utils/ScheduledTaskConfig.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
|
||||
|
||||
namespace BodyshopPartner.Utils
|
||||
{
|
||||
public static class ScheduledTaskConfig
|
||||
{
|
||||
private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static void RegisterPaintScale()
|
||||
{
|
||||
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");
|
||||
}
|
||||
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");
|
||||
newTask.Run();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Error when trying to register scheduled task.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void RegisterArms()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Microsoft.Win32.TaskScheduler.Task existingTask = TaskService.Instance.FindTask("ImEX Online Partner - ARMS");
|
||||
if (existingTask != null)
|
||||
{
|
||||
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");
|
||||
newTask.Run();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "Error when trying to register scheduled task.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user