Пример #1
0
        private bool InstallPackage()
        {
            //check if it's already installed
            //var allInstalled = InstalledPackage.GetAllInstalledPackages();

            //need to save the package manifest to a temp folder since that is how this package installer logic works
            var tempFile = Path.Combine(IOHelper.MapPath("~/App_Data/TEMP/Articulate"), Guid.NewGuid().ToString(), "package.xml");
            var tempDir  = Path.GetDirectoryName(tempFile);

            Directory.CreateDirectory(tempDir);

            try
            {
                System.IO.File.WriteAllText(tempFile, ArticulateResources.packageManifest);
                var ins = new global::umbraco.cms.businesslogic.packager.Installer(_userId);

                ins.LoadConfig(tempDir);

                int  packageId;
                bool sameVersion;
                if (IsPackageVersionAlreadyInstalled(ins.Name, ins.Version, out sameVersion, out packageId))
                {
                    //if it's the same version, we don't need to install anything
                    if (!sameVersion)
                    {
                        var pckId = ins.CreateManifest(tempDir, Guid.NewGuid().ToString(), "65194810-1f85-11dd-bd0b-0800200c9a66");
                        ins.InstallBusinessLogic(pckId, tempDir);
                        return(true);
                    }
                    return(false);
                }
                else
                {
                    var pckId = ins.CreateManifest(tempDir, Guid.NewGuid().ToString(), "65194810-1f85-11dd-bd0b-0800200c9a66");
                    ins.InstallBusinessLogic(pckId, tempDir);
                    return(true);
                }
            }
            finally
            {
                if (System.IO.File.Exists(tempFile))
                {
                    System.IO.File.Delete(tempFile);
                }
                if (System.IO.Directory.Exists(tempDir))
                {
                    System.IO.Directory.Delete(tempDir, true);
                }
            }
        }
        public PackageInstallModel InstallData(PackageInstallModel model)
        {
            var ins = new global::umbraco.cms.businesslogic.packager.Installer(Security.CurrentUser.Id);

            ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
            ins.InstallBusinessLogic(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));
            return(model);
        }
Пример #3
0
        public JsonResult InstallBusinessLogic(Guid kitGuid, int manifestId, string packageFile)
        {
            packageFile = Server.UrlDecode(packageFile);
            var installer = new global::umbraco.cms.businesslogic.packager.Installer();

            installer.LoadConfig(packageFile);
            installer.InstallBusinessLogic(manifestId, packageFile);
            return(Json(new
            {
                success = true,
                manifestId,
                packageFile,
                percentage = 70,
                message = "Installing starter kit files"
            }));
        }
        public HttpResponseMessage InstallBusinessLogic(InstallPackageModel model)
        {
            model.PackageFile = HttpUtility.UrlDecode(model.PackageFile);
            var installer = new global::umbraco.cms.businesslogic.packager.Installer(UmbracoContext.Current.Security.CurrentUser.Id);

            installer.LoadConfig(model.PackageFile);
            installer.InstallBusinessLogic(model.ManifestId, model.PackageFile);
            return(Json(new
            {
                success = true,
                model.ManifestId,
                model.PackageFile,
                percentage = 70,
                message = "Installing starter kit files"
            }, HttpStatusCode.OK));
        }
		public JsonResult InstallBusinessLogic(Guid kitGuid, int manifestId, string packageFile)
		{
			packageFile = Server.UrlDecode(packageFile);
			var installer = new global::umbraco.cms.businesslogic.packager.Installer();
			installer.LoadConfig(packageFile);
			installer.InstallBusinessLogic(manifestId, packageFile);
			return Json(new
			{
				success = true,
				manifestId,
				packageFile,
				percentage = 70,
				message = "Installing starter kit files"
			});
		}
		protected void SelectStarterKitDesign(object sender, EventArgs e)
		{
            InstallHelper.ClearProgress();

			var kitGuid = new Guid(((LinkButton)sender).CommandArgument);

            if (!global::umbraco.cms.businesslogic.skinning.Skinning.IsSkinInstalled(kitGuid))
			{

				InstallHelper.SetProgress(5, "Fetching starting kit from the repository", "");

                var installer = new global::umbraco.cms.businesslogic.packager.Installer();

				if (_repo.HasConnection())
				{
                    var p = new global::umbraco.cms.businesslogic.packager.Installer();

                    InstallHelper.SetProgress(15, "Connected to repository", "");

					string tempFile = p.Import(_repo.fetch(kitGuid.ToString()));
					p.LoadConfig(tempFile);
					int pID = p.CreateManifest(tempFile, kitGuid.ToString(), RepoGuid);

                    InstallHelper.SetProgress(30, "Installing skin files", "");
					p.InstallFiles(pID, tempFile);

                    InstallHelper.SetProgress(50, "Installing skin system objects", "");
					p.InstallBusinessLogic(pID, tempFile);

                    InstallHelper.SetProgress(60, "Finishing skin installation", "");
					p.InstallCleanUp(pID, tempFile);

					library.RefreshContent();

                    InstallHelper.SetProgress(80, "Activating skin", "");
                    if (global::umbraco.cms.businesslogic.skinning.Skinning.GetAllSkins().Count > 0)
					{
                        global::umbraco.cms.businesslogic.skinning.Skinning.ActivateAsCurrentSkin(
                            global::umbraco.cms.businesslogic.skinning.Skinning.GetAllSkins()[0]);
					}


                    InstallHelper.SetProgress(100, "Skin installation has been completed", "");

					try
					{


						if (string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus))
						{
                            GlobalSettings.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
							Application["umbracoNeedConfiguration"] = false;
						}
					}
					catch
					{

					}

					try
					{
						InstallHelper.RedirectToNextStep(Page, GetCurrentStep());
					}
					catch
					{
						OnStarterKitDesignInstalled();
					}
				}
				else
				{
					ShowConnectionError();
				}

			}
		}
        protected void SelectStarterKitDesign(object sender, EventArgs e)
        {
            InstallHelper.ClearProgress();

            var kitGuid = new Guid(((LinkButton)sender).CommandArgument);

            if (!global::umbraco.cms.businesslogic.skinning.Skinning.IsSkinInstalled(kitGuid))
            {
                InstallHelper.SetProgress(5, "Fetching starting kit from the repository", "");

                var installer = new global::umbraco.cms.businesslogic.packager.Installer();

                if (_repo.HasConnection())
                {
                    var p = new global::umbraco.cms.businesslogic.packager.Installer();

                    InstallHelper.SetProgress(15, "Connected to repository", "");

                    string tempFile = p.Import(_repo.fetch(kitGuid.ToString()));
                    p.LoadConfig(tempFile);
                    int pID = p.CreateManifest(tempFile, kitGuid.ToString(), RepoGuid);

                    InstallHelper.SetProgress(30, "Installing skin files", "");
                    p.InstallFiles(pID, tempFile);

                    InstallHelper.SetProgress(50, "Installing skin system objects", "");
                    p.InstallBusinessLogic(pID, tempFile);

                    InstallHelper.SetProgress(60, "Finishing skin installation", "");
                    p.InstallCleanUp(pID, tempFile);

                    library.RefreshContent();

                    InstallHelper.SetProgress(80, "Activating skin", "");
                    if (global::umbraco.cms.businesslogic.skinning.Skinning.GetAllSkins().Count > 0)
                    {
                        global::umbraco.cms.businesslogic.skinning.Skinning.ActivateAsCurrentSkin(
                            global::umbraco.cms.businesslogic.skinning.Skinning.GetAllSkins()[0]);
                    }


                    InstallHelper.SetProgress(100, "Skin installation has been completed", "");

                    try
                    {
                        if (string.IsNullOrEmpty(GlobalSettings.ConfigurationStatus))
                        {
                            GlobalSettings.ConfigurationStatus      = UmbracoVersion.Current.ToString(3);
                            Application["umbracoNeedConfiguration"] = false;
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        InstallHelper.RedirectToNextStep(Page, GetCurrentStep());
                    }
                    catch
                    {
                        OnStarterKitDesignInstalled();
                    }
                }
                else
                {
                    ShowConnectionError();
                }
            }
        }