/// <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); }
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 OrchardException(T("Unable to backup existing local package directory."), exception); } if (previousInstalled) { // 2. If extension is installed, need to un-install first try { UninstallExtensionIfNeeded(package); } catch (Exception exception) { throw new OrchardException(T("Unable to un-install local package before updating."), exception); } } var packageInfo = ExecuteInstall(package, packageRepository, location, applicationPath); // check the new package is compatible with current Orchard version var descriptor = package.GetExtensionDescriptor(packageInfo.ExtensionType); if (descriptor != null) { if (new FlatPositionComparer().Compare(descriptor.OrchardVersion, typeof(ContentItem).Assembly.GetName().Version.ToString()) >= 0) { if (previousInstalled) { // restore the previous version RestoreExtensionFolder(package.ExtensionFolder(), package.ExtensionId()); } else { // just uninstall the new package Uninstall(package.Id, _virtualPathProvider.MapPath("~\\")); } Logger.Error(String.Format("The package is compatible with version {0} and above. Please update Orchard or install another version of this package.", descriptor.OrchardVersion)); throw new OrchardException(T("The package is compatible with version {0} and above. Please update Orchard or install another version of this package.", descriptor.OrchardVersion)); } } return(packageInfo); }
public ActionResult InstallGallery(string packageId, string version, int sourceId, string redirectUrl) { if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources"))) { return(new HttpUnauthorizedResult()); } var source = _packagingSourceManager.GetSources().FirstOrDefault(s => s.Id == sourceId); if (source == null) { return(HttpNotFound()); } try { PackageInfo packageInfo = _packageManager.Install(packageId, version, source.FeedUrl, MapAppRoot()); if (DefaultExtensionTypes.IsTheme(packageInfo.ExtensionType)) { Services.Notifier.Information(T("The theme has been successfully installed. It can be enabled in the \"Themes\" page accessible from the menu.")); } else if (DefaultExtensionTypes.IsModule(packageInfo.ExtensionType)) { Services.Notifier.Information(T("The module has been successfully installed.")); IPackageRepository packageRepository = PackageRepositoryFactory.Default.CreateRepository(new PackageSource(source.FeedUrl, "Default")); IPackage package = packageRepository.FindPackage(packageId); ExtensionDescriptor extensionDescriptor = package.GetExtensionDescriptor(packageInfo.ExtensionType); return(InstallPackageDetails(extensionDescriptor, redirectUrl)); } } catch (OrchardException e) { Services.Notifier.Error(T("Package installation failed: {0}", e.Message)); return(View("InstallPackageFailed")); } catch (Exception) { Services.Notifier.Error(T("Package installation failed.")); return(View("InstallPackageFailed")); } return(Redirect(redirectUrl)); }
/// <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 SmartStore version var descriptor = package.GetExtensionDescriptor(packageInfo.Type); if (descriptor != null) { 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", SmartStoreVersion.CurrentFullVersion); _logger.Error(msg); throw new SmartException(msg); } } return packageInfo; }
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 OrchardException(T("Unable to backup existing local package directory."), exception); } if (previousInstalled) { // 2. If extension is installed, need to un-install first try { UninstallExtensionIfNeeded(package); } catch (Exception exception) { throw new OrchardException(T("Unable to un-install local package before updating."), exception); } } var packageInfo = ExecuteInstall(package, packageRepository, location, applicationPath); // check the new package is compatible with current Orchard version var descriptor = package.GetExtensionDescriptor(packageInfo.ExtensionType); if(descriptor != null) { if(new FlatPositionComparer().Compare(descriptor.OrchardVersion, typeof(ContentItem).Assembly.GetName().Version.ToString()) >= 0) { if (previousInstalled) { // restore the previous version RestoreExtensionFolder(package.ExtensionFolder(), package.ExtensionId()); } else { // just uninstall the new package Uninstall(package.Id, _virtualPathProvider.MapPath("~\\")); } Logger.Error(String.Format("The package is compatible with version {0} and above. Please update Orchard or install another version of this package.", descriptor.OrchardVersion)); throw new OrchardException(T("The package is compatible with version {0} and above. Please update Orchard or install another version of this package.", descriptor.OrchardVersion)); } } return packageInfo; }