protected void Page_Load(object sender, EventArgs e) { if(!string.IsNullOrEmpty(Request["guid"])){ Guid guid = new Guid(Request["guid"]); if (this.repo.HasConnection()) { Installer installer = new Installer(); string tempDir = installer.Import(this.repo.fetch(guid.ToString())); installer.LoadConfig(tempDir); int packageId = installer.CreateManifest(tempDir, guid.ToString(), this.repoGuid); installer.InstallFiles(packageId, tempDir); installer.InstallBusinessLogic(packageId, tempDir); installer.InstallCleanUp(packageId, tempDir); library.RefreshContent(); if (cms.businesslogic.skinning.Skinning.IsPackageInstalled(new Guid(Request["guid"])) || cms.businesslogic.skinning.Skinning.IsPackageInstalled(Request["name"])) { Response.Write(cms.businesslogic.skinning.Skinning.GetModuleAlias(Request["name"])); } else { Response.Write("error"); } } else { Response.Write("error"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request["guid"])) { var guid = new Guid(Request["guid"]); if (_repo.HasConnection()) { var installer = new Installer(); var tempDir = installer.Import(_repo.fetch(guid.ToString())); installer.LoadConfig(tempDir); var packageId = installer.CreateManifest(tempDir, guid.ToString(), RepoGuid); installer.InstallFiles(packageId, tempDir); installer.InstallBusinessLogic(packageId, tempDir); installer.InstallCleanUp(packageId, tempDir); //NOTE: This seems excessive to have to re-load all content from the database here!? library.RefreshContent(); if (cms.businesslogic.skinning.Skinning.IsPackageInstalled(new Guid(Request["guid"])) || cms.businesslogic.skinning.Skinning.IsPackageInstalled(Request["name"])) { Response.Write(cms.businesslogic.skinning.Skinning.GetModuleAlias(Request["name"])); } else { Response.Write("error"); } } else { Response.Write("error"); } } }
protected void btnGoogleMapsDataType_Click(object sender, EventArgs e) { IList<string> successList = new List<string>(); IList<string> failedList = new List<string>(); var url = "http://our.umbraco.org/FileDownload?id=4425&release=1"; try { var tmpFileName = Guid.NewGuid().ToString() + ".umb"; var tmpFilePath = IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + tmpFileName); // Download file new WebClient().DownloadFile(url, tmpFilePath); // Extract package guid from zip var packageGuid = GetPackageGuidFromZip(tmpFilePath); if (packageGuid == default(Guid)) packageGuid = Guid.NewGuid(); var packageGuidString = packageGuid.ToString("D"); // Check package isn't already installed if (!InstalledPackage.isPackageInstalled(packageGuidString)) { // Rename file var packageFileName = packageGuidString + ".umb"; var packageFilePath = IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + packageFileName); System.IO.File.Move(tmpFilePath, packageFilePath); // Install package var installer = new umbraco.cms.businesslogic.packager.Installer(); var tempDir = installer.Import(packageFileName); installer.LoadConfig(tempDir); var packageId = installer.CreateManifest(tempDir, packageGuidString, REPO_GUID); installer.InstallFiles(packageId, tempDir); installer.InstallBusinessLogic(packageId, tempDir); installer.InstallCleanUp(packageId, tempDir); // Append package to success list successList.Add("Google maps datatype"); } else { // Append package to failed list failedList.Add("Google maps datatype"); } } catch (Exception) { // Append package to failed list failedList.Add("Google maps datatype"); } // Show message if (successList.Count > 0) { //Successfull feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success; feedback.Text = string.Format("{0} installed successfully", successList.First()); } else { //Failed feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error; feedback.Text = string.Format("{0} failed to install", successList.First()); } }
protected void SelectStarterKitDesign(object sender, EventArgs e) { if (((Button)sender).CommandName == "apply") { Skinning.ActivateAsCurrentSkin(Skin.CreateFromName(((Button)sender).CommandArgument)); this.Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString())) + "?umbSkinning=true"); } else if (((Button)sender).CommandName == "remove") { Template template = new Template(Node.GetCurrent().template); Skinning.RollbackSkin(template.Id); this.Page.Response.Redirect( library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString())) +"?umbSkinning=true" ); } else { Guid guid = new Guid(((Button)sender).CommandArgument); InstalledPackage p = InstalledPackage.GetByGuid(guid.ToString()); if (p.Data.SkinRepoGuid != null && p.Data.SkinRepoGuid != Guid.Empty && p.Data.SkinRepoGuid.ToString() != repoGuid) this.repo = cms.businesslogic.packager.repositories.Repository.getByGuid(p.Data.SkinRepoGuid.ToString()); Installer installer = new Installer(); if (this.repo.HasConnection()) { Installer installer2 = new Installer(); string tempDir = installer2.Import(this.repo.fetch(guid.ToString())); installer2.LoadConfig(tempDir); int packageId = installer2.CreateManifest(tempDir, guid.ToString(), this.repoGuid); installer2.InstallFiles(packageId, tempDir); installer2.InstallBusinessLogic(packageId, tempDir); installer2.InstallCleanUp(packageId, tempDir); //NOTE: This seems excessive to have to re-load all content from the database here!? library.RefreshContent(); Skinning.ActivateAsCurrentSkin(Skin.CreateFromName(((Button)sender).CommandName)); this.Page.Response.Redirect(library.NiceUrl(int.Parse(UmbracoContext.Current.PageId.ToString())) + "?umbSkinning=true"); } else { this.ShowConnectionError(); } } }
/// <summary> /// reads packages from the uSync/Packages folder and installs them. /// -- will probibly restart the installation a few times /// </summary> public void InstallPackages() { /// // 1. load packages from disk... // string path = IOHelper.MapPath("~/uSync/Packages"); if ( File.Exists( Path.Combine(path, "halt.txt")) ) { LogHelper.Info(typeof(PackageSync), "Halt stopping") ; return ; } if (Directory.Exists(path)) { LogHelper.Info(typeof(PackageSync), "Reading packages from disk"); List<uSyncPackageInfo> uSyncPackages = new List<uSyncPackageInfo>(); Installer _installer = new Installer(); foreach (string packageFile in Directory.GetFiles(path, "*.config")) { uSyncPackageInfo package = uSyncPackageInfo.Import(packageFile); if ((package.Status == "new") && (InstalledPackage.isPackageInstalled(package.PackageGuid))) { // this isn't new. we should mark it as installed. LogHelper.Info(typeof(PackageSync), String.Format("{0} is already installed setting complete", package.Name)); package.Status = "complete" ; package.Save(); } if (package.Status != "complete") { uSyncPackages.Add(package); LogHelper.Info(typeof(PackageSync), String.Format("Added {0} to list", package.Name)); } } // // 2: process the packages. // // logic, we do the stages backwards.. (it does mean multiple loops.. but they should always be small) LogHelper.Info(typeof(PackageSync), "Installing packages"); foreach (uSyncPackageInfo pack in uSyncPackages) { LogHelper.Info(typeof(PackageSync), String.Format("Installion steps for {0}", pack.Name)); if (pack.Status == "business") { PackageBusinessActions(pack, _installer); } } bool reboot = false; foreach (uSyncPackageInfo pack in uSyncPackages) { LogHelper.Info(typeof(PackageSync), String.Format("Package actions for {0}", pack.Name)); if (reboot == false) { if (pack.Status == "new") { reboot = PackageFileActions(pack, _installer); } } } } }
public bool PackageBusinessActions(uSyncPackageInfo pack, Installer _installer) { LogHelper.Info(typeof(PackageSync), String.Format("performing business logic for {0}", pack.Name)); _installer.LoadConfig(pack.TempPackageFolder); _installer.InstallBusinessLogic(pack.PackageId, pack.TempPackageFolder); pack.Status = "custom"; pack.Save(); if (!String.IsNullOrEmpty(_installer.Control)) { // custom bit - not sure how this is going to work ? // because you can't really do it silently } pack.Status = "complete"; pack.Save(); // clean up... _installer.InstallCleanUp(pack.PackageId, pack.TempPackageFolder); BizLogicAction.ReRegisterActionsAndHandlers(); return true; }
public bool PackageFileActions(uSyncPackageInfo pack, Installer _installer) { LogHelper.Info(typeof(PackageSync), String.Format("Performing File Actions for {0}", pack.Name)); bool reboot = false; Repository _repo = Repository.getByGuid(pack.RepoGuid); if (_repo.HasConnection()) { LogHelper.Info(typeof(PackageSync), "Repo Has Connection"); umbraco.cms.businesslogic.packager.repositories.Package p = _repo.Webservice.PackageByGuid(pack.PackageGuid); string file = _repo.fetch(pack.PackageGuid); LogHelper.Info(typeof(PackageSync), String.Format("Fetched {0}", file)); if (!String.IsNullOrEmpty(file)) { string import = _installer.Import(file); LogHelper.Info(typeof(PackageSync), String.Format("Install {0}", import)); _installer.LoadConfig(import); int pId = _installer.CreateManifest(import, pack.PackageGuid, pack.RepoGuid); LogHelper.Info(typeof(PackageSync), String.Format("Installing Files for {0}", pack.Name)); _installer.InstallFiles(pId, import); pack.PackageId = pId; pack.TempPackageFolder = import; pack.Status = "business"; pack.Save(); if (_installer.ContainsUnsecureFiles) { LogHelper.Info(typeof(PackageSync), String.Format("Package {0} has dll's will reboot...", pack.Name)); // we are going to reboot, because things have changed. // best thing to do is wait System.Threading.Thread.Sleep(2000); reboot = true; // we'll set this true, we don't want to do any more packages this pass. } else { // do the buisness stuff... PackageBusinessActions(pack, _installer); } } } return reboot; }
protected void btnInstall_Click(object sender, EventArgs e) { IList<string> successList = new List<string>(); IList<string> failedList = new List<string>(); // Loop through selected providers foreach (ListItem li in chkProviders.Items) { if (li.Selected) { var url = li.Value; try { var tmpFileName = Guid.NewGuid().ToString() + ".umb"; var tmpFilePath = IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + tmpFileName); // Download file new WebClient().DownloadFile(url, tmpFilePath); // Extract package guid from zip var packageGuid = GetPackageGuidFromZip(tmpFilePath); if (packageGuid == default(Guid)) packageGuid = Guid.NewGuid(); var packageGuidString = packageGuid.ToString("D"); // Check package isn't already installed if (!InstalledPackage.isPackageInstalled(packageGuidString)) { // Rename file var packageFileName = packageGuidString + ".umb"; var packageFilePath = IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + packageFileName); File.Move(tmpFilePath, packageFilePath); // Install package var installer = new umbraco.cms.businesslogic.packager.Installer(); var tempDir = installer.Import(packageFileName); installer.LoadConfig(tempDir); var packageId = installer.CreateManifest(tempDir, packageGuidString, REPO_GUID); installer.InstallFiles(packageId, tempDir); installer.InstallBusinessLogic(packageId, tempDir); installer.InstallCleanUp(packageId, tempDir); // Append package to success list successList.Add(li.Text); // Deselect and disable option li.Enabled = li.Selected = false; } else { // Append package to failed list failedList.Add(li.Text); } } catch (Exception) { // Append package to failed list failedList.Add(li.Text); } } } library.RefreshContent(); // Show message if (successList.Count > 0) { if (failedList.Count > 0) { // Some providers installed, some failed feedback.type = umbraco.uicontrols.Feedback.feedbacktype.notice; feedback.Text = string.Format("{0} provider(s) installed successfully, however {1} provider(s) failed to install. Please see the <strong>Installed packages</strong> section to see which provider(s) were installed.", successList.Count, failedList.Count); } else { // All successfull feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success; feedback.Text = string.Format("{0} provider(s) installed successfully", successList.Count); } } else { if (failedList.Count > 0) { // All failed feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error; feedback.Text = string.Format("{0} provider(s) failed to install", failedList.Count); } else { // None selected feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error; feedback.Text = "Please select one or more providers to install"; } } }
protected void btnInstall_Click(object sender, EventArgs e) { IList <string> successList = new List <string>(); IList <string> failedList = new List <string>(); // Loop through selected providers foreach (ListItem li in chkProviders.Items) { if (li.Selected) { var url = li.Value; try { var tmpFileName = Guid.NewGuid().ToString() + ".umb"; var tmpFilePath = IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + tmpFileName); // Download file new WebClient().DownloadFile(url, tmpFilePath); // Extract package guid from zip var packageGuid = GetPackageGuidFromZip(tmpFilePath); if (packageGuid == default(Guid)) { packageGuid = Guid.NewGuid(); } var packageGuidString = packageGuid.ToString("D"); // Check package isn't already installed if (!InstalledPackage.isPackageInstalled(packageGuidString)) { // Rename file var packageFileName = packageGuidString + ".umb"; var packageFilePath = IOHelper.MapPath(SystemDirectories.Data + Path.DirectorySeparatorChar + packageFileName); File.Move(tmpFilePath, packageFilePath); // Install package var installer = new umbraco.cms.businesslogic.packager.Installer(); var tempDir = installer.Import(packageFileName); installer.LoadConfig(tempDir); var packageId = installer.CreateManifest(tempDir, packageGuidString, REPO_GUID); installer.InstallFiles(packageId, tempDir); installer.InstallBusinessLogic(packageId, tempDir); installer.InstallCleanUp(packageId, tempDir); // Append package to success list successList.Add(li.Text); // Deselect and disable option li.Enabled = li.Selected = false; } else { // Append package to failed list failedList.Add(li.Text); } } catch (Exception) { // Append package to failed list failedList.Add(li.Text); } } } library.RefreshContent(); // Show message if (successList.Count > 0) { if (failedList.Count > 0) { // Some providers installed, some failed feedback.type = umbraco.uicontrols.Feedback.feedbacktype.notice; feedback.Text = string.Format("{0} provider(s) installed successfully, however {1} provider(s) failed to install. Please see the <strong>Installed packages</strong> section to see which provider(s) were installed.", successList.Count, failedList.Count); } else { // All successfull feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success; feedback.Text = string.Format("{0} provider(s) installed successfully", successList.Count); } } else { if (failedList.Count > 0) { // All failed feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error; feedback.Text = string.Format("{0} provider(s) failed to install", failedList.Count); } else { // None selected feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error; feedback.Text = "Please select one or more providers to install"; } } }