This commit is contained in:
2020-05-19 21:16:47 +00:00
parent 7b963c60c3
commit 2b61791f2a
2 changed files with 33 additions and 19 deletions

View File

@@ -75,7 +75,7 @@ namespace AyaNova.Biz
log.LogInformation($"CALLING BACKUP COMMAND: {BackupUtilityCommand} {Arguments}"); log.LogInformation($"CALLING BACKUP COMMAND: {BackupUtilityCommand} {Arguments}");
//RUN THE BACKUP //RUN THE BACKUP
var Result= RunProgram.Run(BackupUtilityCommand,Arguments); var Result = RunProgram.Run(BackupUtilityCommand, Arguments, log);
log.LogInformation($"BACKUP RESULT: {Result}"); log.LogInformation($"BACKUP RESULT: {Result}");

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft.Extensions.Logging;
namespace AyaNova.Util namespace AyaNova.Util
{ {
@@ -8,7 +9,9 @@ namespace AyaNova.Util
{ {
public static string Run(string cmd, string arguments) public static string Run(string cmd, string arguments, ILogger log = null)
{
try
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
@@ -23,10 +26,21 @@ namespace AyaNova.Util
{ {
return RunLinuxBash(cmd, arguments); return RunLinuxBash(cmd, arguments);
} }
else
{
throw new PlatformNotSupportedException();
} }
catch (Exception ex)
{
if (log != null)
{
log.LogError(ex, $"RunProgram error running command:{cmd} {arguments}");
}
throw ex;
}
throw new PlatformNotSupportedException();
} }