/// <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); }
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); } } return(ExecuteInstall(package, packageRepository, location, applicationPath)); }
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; }
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); } } return ExecuteInstall(package, packageRepository, location, applicationPath); }
/// <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; }