2018-03-29 11:31:33 +02:00
|
|
|
|
using System;
|
2019-01-11 14:30:04 +11:00
|
|
|
|
using System.Threading.Tasks;
|
2020-02-17 14:58:34 +01:00
|
|
|
|
using Umbraco.Core;
|
2018-03-29 11:31:33 +02:00
|
|
|
|
using Umbraco.Core.Configuration;
|
2014-03-04 19:20:36 +11:00
|
|
|
|
using Umbraco.Web.Install.Models;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Install.InstallSteps
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This step is purely here to show the button to commence the upgrade
|
|
|
|
|
|
/// </summary>
|
2018-03-27 10:04:07 +02:00
|
|
|
|
[InstallSetupStep(InstallationType.Upgrade, "Upgrade", "upgrade", 1, "Upgrading Umbraco to the latest and greatest version.")]
|
2014-03-05 14:30:17 +11:00
|
|
|
|
internal class UpgradeStep : InstallSetupStep<object>
|
2014-03-04 19:20:36 +11:00
|
|
|
|
{
|
2018-03-29 11:31:33 +02:00
|
|
|
|
public override bool RequiresExecution(object model) => true;
|
2019-11-19 23:15:11 +00:00
|
|
|
|
private readonly IUmbracoVersion _umbracoVersion;
|
2020-02-17 14:58:34 +01:00
|
|
|
|
private readonly IRuntimeState _runtimeState;
|
2019-11-19 23:15:11 +00:00
|
|
|
|
|
2020-02-17 14:58:34 +01:00
|
|
|
|
public UpgradeStep(IUmbracoVersion umbracoVersion, IRuntimeState runtimeState)
|
2019-11-19 23:15:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
_umbracoVersion = umbracoVersion;
|
2020-02-17 14:58:34 +01:00
|
|
|
|
_runtimeState = runtimeState;
|
2019-11-19 23:15:11 +00:00
|
|
|
|
}
|
2014-03-04 19:20:36 +11:00
|
|
|
|
|
2019-01-11 14:30:04 +11:00
|
|
|
|
public override Task<InstallSetupResult> ExecuteAsync(object model) => Task.FromResult<InstallSetupResult>(null);
|
2016-07-12 15:57:48 +01:00
|
|
|
|
|
|
|
|
|
|
public override object ViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2019-01-27 01:17:32 -05:00
|
|
|
|
// TODO: if UmbracoVersion.Local is null?
|
2018-10-22 10:34:04 +02:00
|
|
|
|
// it means that there is a database but the web.config version is cleared
|
|
|
|
|
|
// that was a "normal" way to force the upgrader to execute, and we would detect the current
|
|
|
|
|
|
// version via the DB like DatabaseSchemaResult.DetermineInstalledVersion - magic, do we really
|
|
|
|
|
|
// need this now?
|
2019-11-19 23:15:11 +00:00
|
|
|
|
var currentVersion = (_umbracoVersion.LocalVersion ?? new Semver.SemVersion(0)).ToString();
|
2018-06-15 15:51:37 +10:00
|
|
|
|
|
2019-11-19 23:15:11 +00:00
|
|
|
|
var newVersion = _umbracoVersion.SemanticVersion.ToString();
|
2018-03-29 11:31:33 +02:00
|
|
|
|
|
2018-03-30 10:16:21 +02:00
|
|
|
|
string FormatGuidState(string value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(value)) value = "unknown";
|
|
|
|
|
|
else if (Guid.TryParse(value, out var currentStateGuid))
|
|
|
|
|
|
value = currentStateGuid.ToString("N").Substring(0, 8);
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-17 14:58:34 +01:00
|
|
|
|
|
|
|
|
|
|
var currentState = FormatGuidState(_runtimeState.CurrentMigrationState);
|
|
|
|
|
|
var newState = FormatGuidState(_runtimeState.FinalMigrationState);
|
2018-03-29 11:31:33 +02:00
|
|
|
|
|
2018-07-31 14:57:20 +10:00
|
|
|
|
var reportUrl = $"https://our.umbraco.com/contribute/releases/compare?from={currentVersion}&to={newVersion}¬es=1";
|
2016-07-26 16:19:17 +02:00
|
|
|
|
|
2018-03-29 11:31:33 +02:00
|
|
|
|
return new { currentVersion, newVersion, currentState, newState, reportUrl };
|
2016-07-12 15:57:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-03-04 19:20:36 +11:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|