2014-02-26 16:01:31 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
2014-03-04 19:20:36 +11:00
|
|
|
using umbraco.cms.businesslogic.packager;
|
2014-02-26 16:01:31 +01:00
|
|
|
using Umbraco.Core;
|
|
|
|
|
using Umbraco.Web.Install.Models;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Install.InstallSteps
|
|
|
|
|
{
|
2014-03-04 19:20:36 +11:00
|
|
|
[InstallSetupStep(InstallationType.NewInstall,
|
2014-03-05 20:03:45 +01:00
|
|
|
"StarterKitInstall", 31, "",
|
2014-03-05 11:34:42 +11:00
|
|
|
PerformsAppRestart = true)]
|
2014-02-26 16:01:31 +01:00
|
|
|
internal class StarterKitInstallStep : InstallSetupStep<object>
|
|
|
|
|
{
|
|
|
|
|
private readonly ApplicationContext _applicationContext;
|
|
|
|
|
private readonly HttpContextBase _httContext;
|
|
|
|
|
|
2014-03-04 19:20:36 +11:00
|
|
|
public StarterKitInstallStep(ApplicationContext applicationContext, HttpContextBase httContext)
|
2014-02-26 16:01:31 +01:00
|
|
|
{
|
|
|
|
|
_applicationContext = applicationContext;
|
|
|
|
|
_httContext = httContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-03-04 11:16:42 +11:00
|
|
|
public override InstallSetupResult Execute(object model)
|
2014-02-26 16:01:31 +01:00
|
|
|
{
|
2014-03-04 19:20:36 +11:00
|
|
|
var installSteps = InstallStatusTracker.GetStatus().ToArray();
|
2014-03-04 16:21:45 +11:00
|
|
|
var previousStep = installSteps.Single(x => x.Name == "StarterKitDownload");
|
2014-02-26 16:01:31 +01:00
|
|
|
var manifestId = Convert.ToInt32(previousStep.AdditionalData["manifestId"]);
|
|
|
|
|
var packageFile = (string)previousStep.AdditionalData["packageFile"];
|
|
|
|
|
|
|
|
|
|
InstallBusinessLogic(manifestId, packageFile);
|
|
|
|
|
|
|
|
|
|
_applicationContext.RestartApplicationPool(_httContext);
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InstallBusinessLogic(int manifestId, string packageFile)
|
|
|
|
|
{
|
|
|
|
|
packageFile = HttpUtility.UrlDecode(packageFile);
|
2014-03-04 19:20:36 +11:00
|
|
|
var installer = new Installer();
|
2014-02-26 16:01:31 +01:00
|
|
|
installer.LoadConfig(packageFile);
|
|
|
|
|
installer.InstallBusinessLogic(manifestId, packageFile);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-05 14:30:17 +11:00
|
|
|
public override bool RequiresExecution(object model)
|
2014-03-05 11:34:42 +11:00
|
|
|
{
|
2014-03-04 19:20:36 +11:00
|
|
|
var installSteps = InstallStatusTracker.GetStatus().ToArray();
|
|
|
|
|
//this step relies on the preious one completed - because it has stored some information we need
|
2014-03-05 11:49:07 +11:00
|
|
|
if (installSteps.Any(x => x.Name == "StarterKitDownload" && x.AdditionalData.ContainsKey("manifestId")) == false)
|
2014-03-04 19:20:36 +11:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2014-03-04 11:16:42 +11:00
|
|
|
}
|
2014-02-26 16:01:31 +01:00
|
|
|
}
|
|
|
|
|
}
|