Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Admin panel - save to the log information about the restarted app, clear cache, install and uninstall plugin, upload and remove the plugin

KrzysztofPajak8379af886fd0
diff --git a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
index 4825a0b4a..02e6dcb6e 100644
--- a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
@@ -192,6 +192,8 @@ namespace Grand.Web.Admin.Controllers
Success(_translationService.GetResource("Admin.Plugins.Installed"));
+ _ = _logger.InsertLog(Domain.Logging.LogLevel.Information, $"The plugin has been installed by the user {_workContext.CurrentCustomer.Email}");
+
//stop application
_applicationLifetime.StopApplication();
}
@@ -229,6 +231,8 @@ namespace Grand.Web.Admin.Controllers
Success(_translationService.GetResource("Admin.Plugins.Uninstalled"));
+ _ = _logger.InsertLog(Domain.Logging.LogLevel.Information, $"The plugin has been uninstalled by the user {_workContext.CurrentCustomer.Email}");
+
//stop application
_applicationLifetime.StopApplication();
}
@@ -275,6 +279,8 @@ namespace Grand.Web.Admin.Controllers
//uninstall plugin
Success(_translationService.GetResource("Admin.Plugins.Removed"));
+ _ = _logger.InsertLog(Domain.Logging.LogLevel.Information, $"The plugin has been removed by the user {_workContext.CurrentCustomer.Email}");
+
//stop application
_applicationLifetime.StopApplication();
}
@@ -288,6 +294,8 @@ namespace Grand.Web.Admin.Controllers
public IActionResult ReloadList()
{
+ _ = _logger.InsertLog(Domain.Logging.LogLevel.Information, $"Reload list of plugins by the user {_workContext.CurrentCustomer.Email}");
+
//stop application
_applicationLifetime.StopApplication();
return RedirectToAction("List");
@@ -335,6 +343,8 @@ namespace Grand.Web.Admin.Controllers
System.IO.File.Delete(zipFilePath);
}
+ _ = _logger.InsertLog(Domain.Logging.LogLevel.Information, $"The plugin has been uploaded by the user {_workContext.CurrentCustomer.Email}");
+
//stop application
_applicationLifetime.StopApplication();
diff --git a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs b/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
index 324c37ecb..ab975b4fa 100644
--- a/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/SystemController.cs
@@ -3,6 +3,7 @@ using Grand.Business.Checkout.Interfaces.Payments;
using Grand.Business.Checkout.Interfaces.Shipping;
using Grand.Business.Common.Interfaces.Directory;
using Grand.Business.Common.Interfaces.Localization;
+using Grand.Business.Common.Interfaces.Logging;
using Grand.Business.Common.Services.Security;
using Grand.Business.Storage.Interfaces;
using Grand.Business.System.Interfaces.MachineNameProvider;
@@ -41,7 +42,7 @@ namespace Grand.Web.Admin.Controllers
private readonly ITranslationService _translationService;
private readonly IMachineNameProvider _machineNameProvider;
private readonly IHostApplicationLifetime _applicationLifetime;
- private readonly IMediaFileStore _mediaFileStore;
+ private readonly ILogger _logger;
private readonly CurrencySettings _currencySettings;
private readonly MeasureSettings _measureSettings;
@@ -59,7 +60,7 @@ namespace Grand.Web.Admin.Controllers
ITranslationService translationService,
IMachineNameProvider machineNameProvider,
IHostApplicationLifetime applicationLifetime,
- IMediaFileStore mediaFileStore,
+ ILogger logger,
CurrencySettings currencySettings,
MeasureSettings measureSettings,
AppConfig appConfig)
@@ -74,9 +75,9 @@ namespace Grand.Web.Admin.Controllers
_workContext = workContext;
_translationService = translationService;
_applicationLifetime = applicationLifetime;
+ _logger = logger;
_appConfig = appConfig;
_machineNameProvider = machineNameProvider;
- _mediaFileStore = mediaFileStore;
}
#endregion
@@ -271,6 +272,8 @@ namespace Grand.Web.Admin.Controllers
public async Task<IActionResult> ClearCache(string returnUrl, [FromServices] ICacheBase cacheBase)
{
+ _ = _logger.InsertLog(Domain.Logging.LogLevel.Information, $"Clear cache has been done by the user: {_workContext.CurrentCustomer.Email}");
+
await cacheBase.Clear();
//home page
@@ -285,6 +288,8 @@ namespace Grand.Web.Admin.Controllers
public IActionResult RestartApplication(string returnUrl = "")
{
+ _ = _logger.InsertLog(Domain.Logging.LogLevel.Information, $"The application has been restarted by the user {_workContext.CurrentCustomer.Email}");
+
//stop application
_applicationLifetime.StopApplication();