public ActionResult InstallAvailablePackage(string FileName, string Type) { ActionResult actionResult = new ActionResult(); try { string installFolder = Managers.ExtensionsManager.GetPackageInstallFolder(Type); if (string.IsNullOrEmpty(installFolder) || string.IsNullOrEmpty(FileName)) { actionResult.AddError("InvalidPackage", "InvalidPackage"); return(actionResult); } string packagePath = Path.Combine(Globals.ApplicationMapPath, "Install", installFolder, FileName); if (!File.Exists(packagePath)) { actionResult.AddError("NotFound", "NotFound"); return(actionResult); } using (FileStream stream = new FileStream(packagePath, FileMode.Open)) { InstallResultDto InstallResultDto = InstallController.Instance.InstallPackage(PortalSettings, UserInfo, null, packagePath, stream); actionResult.Data = InstallResultDto; actionResult.IsSuccess = true; return(actionResult); } } catch (Exception ex) { actionResult.AddError("", "", ex); return(actionResult); } }
public ActionResult InstallPackage() { string legacySkin = null; bool isPortalPackage = false; ActionResult actionResult = new ActionResult(); dynamic files = HttpContext.Current.Request.Files; HttpPostedFile file = files[0]; InstallResultDto InstallResultDto = InstallController.Instance.InstallPackage(PortalSettings, UserInfo, legacySkin, file.FileName, file.InputStream, isPortalPackage); actionResult.Data = InstallResultDto; DataCache.ClearCache(); actionResult.IsSuccess = true; return(actionResult); }
public InstallResultDto InstallPackage(PortalSettings portalSettings, UserInfo user, string legacySkin, string filePath, Stream stream, bool isPortalPackage = false) { var installResult = new InstallResultDto(); var fileName = Path.GetFileName(filePath); var extension = Path.GetExtension(fileName ?? "").ToLowerInvariant(); if (extension != ".zip" && extension != ".resources") { installResult.Failed("InvalidExt"); } else { try { var installer = GetInstaller(stream, fileName, portalSettings.PortalId, legacySkin, isPortalPackage); try { if (installer.IsValid) { //Reset Log installer.InstallerInfo.Log.Logs.Clear(); //Set the IgnnoreWhiteList flag installer.InstallerInfo.IgnoreWhiteList = true; //Set the Repair flag installer.InstallerInfo.RepairInstall = true; //Install installer.Install(); installResult.AddLogs(installer.InstallerInfo.Log.Logs); if (!installer.IsValid) { installResult.Failed("InstallError"); } else { installResult.NewPackageId = installer.Packages.Count == 0 ? Null.NullInteger : installer.Packages.First().Value.Package.PackageID; installResult.Succeed(); DeleteInstallFile(filePath); } } else { installResult.Failed("InstallError"); } } finally { DeleteTempInstallFiles(installer); } } catch (SharpZipBaseException) { installResult.Failed("ZipCriticalError"); } } return(installResult); }