/// <summary> /// Tries to install the package /// </summary> /// <param name="package">The package to install</param> /// <param name="packageRepository">The repository</param> /// <param name="location">The virtual location of the package file, usually <c>~/App_Data</c></param> /// <param name="applicationPath">The virtual app root path, usually <c>~/</c></param> /// <returns>An instance of <see cref="PackageInfo"/> type</returns> protected PackageInfo InstallPackage(IPackage package, IPackageRepository packageRepository, string location, string applicationPath) { bool previousInstalled; // 1. See if extension was previous installed and backup its folder if so try { previousInstalled = BackupExtensionFolder(package.ExtensionFolder(), package.ExtensionId()); } catch (Exception exception) { throw new SmartException(T("Admin.Packaging.BackupError"), exception); } if (previousInstalled) { // 2. If extension is installed, need to un-install first try { UninstallExtensionIfNeeded(package); } catch (Exception exception) { throw new SmartException(T("Admin.Packaging.UninstallError"), exception); } } var packageInfo = ExecuteInstall(package, packageRepository, location, applicationPath); // check if the new package is compatible with current cloudCommerce version var descriptor = package.GetExtensionDescriptor(packageInfo.Type); if (descriptor != null) { packageInfo.ExtensionDescriptor = descriptor; if (!PluginManager.IsAssumedCompatible(descriptor.MinAppVersion)) { if (previousInstalled) { // restore the previous version RestoreExtensionFolder(package.ExtensionFolder(), package.ExtensionId()); } else { // just uninstall the new package Uninstall(package.Id, _virtualPathProvider.MapPath("~\\")); } var msg = T("Admin.Packaging.IsIncompatible", cloudCommerceVersion.CurrentFullVersion); _logger.Error(msg); throw new SmartException(msg); } } return(packageInfo); }
public void Log(MessageLevel level, string message, params object[] args) { switch (level) { case MessageLevel.Debug: //_logger.Debug(String.Format(message, args)); break; case MessageLevel.Error: _logger.Error(String.Format(message, args)); break; case MessageLevel.Info: _logger.Information(String.Format(message, args)); break; case MessageLevel.Warning: _logger.Warning(String.Format(message, args)); break; } }