2017-07-20 11:21:28 +02:00
|
|
|
|
using System;
|
2014-02-26 16:01:31 +01:00
|
|
|
|
using System.Runtime.Serialization;
|
2019-01-11 14:30:04 +11:00
|
|
|
|
using System.Threading.Tasks;
|
2014-02-26 16:01:31 +01:00
|
|
|
|
using Umbraco.Core;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Install.Models
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Model to give to the front-end to collect the information for each step
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[DataContract(Name = "step", Namespace = "")]
|
|
|
|
|
|
public abstract class InstallSetupStep<T> : InstallSetupStep
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Defines the step model type on the server side so we can bind it
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[IgnoreDataMember]
|
2019-01-11 14:30:04 +11:00
|
|
|
|
public override Type StepType => typeof(T);
|
2014-02-26 16:01:31 +01:00
|
|
|
|
|
2014-03-04 11:16:42 +11:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The step execution method
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-01-11 14:30:04 +11:00
|
|
|
|
public abstract Task<InstallSetupResult> ExecuteAsync(T model);
|
2014-03-05 14:30:17 +11:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determines if this step needs to execute based on the current state of the application and/or install process
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public abstract bool RequiresExecution(T model);
|
2014-02-26 16:01:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[DataContract(Name = "step", Namespace = "")]
|
|
|
|
|
|
public abstract class InstallSetupStep
|
|
|
|
|
|
{
|
2014-02-26 16:30:25 +01:00
|
|
|
|
protected InstallSetupStep()
|
|
|
|
|
|
{
|
|
|
|
|
|
var att = GetType().GetCustomAttribute<InstallSetupStepAttribute>(false);
|
|
|
|
|
|
if (att == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new InvalidOperationException("Each step must be attributed");
|
|
|
|
|
|
}
|
|
|
|
|
|
Name = att.Name;
|
|
|
|
|
|
View = att.View;
|
2014-03-04 11:16:42 +11:00
|
|
|
|
ServerOrder = att.ServerOrder;
|
2014-03-03 08:57:00 +01:00
|
|
|
|
Description = att.Description;
|
2014-03-04 19:20:36 +11:00
|
|
|
|
InstallTypeTarget = att.InstallTypeTarget;
|
2014-03-05 11:34:42 +11:00
|
|
|
|
PerformsAppRestart = att.PerformsAppRestart;
|
2014-02-26 16:30:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-02-26 16:01:31 +01:00
|
|
|
|
[DataMember(Name = "name")]
|
2014-02-26 16:30:25 +01:00
|
|
|
|
public string Name { get; private set; }
|
2014-02-26 16:01:31 +01:00
|
|
|
|
|
|
|
|
|
|
[DataMember(Name = "view")]
|
2014-02-26 16:30:25 +01:00
|
|
|
|
public virtual string View { get; private set; }
|
2014-02-26 16:01:31 +01:00
|
|
|
|
|
2014-03-06 12:11:14 +11:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The view model used to render the view, by default is null but can be populated
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[DataMember(Name = "model")]
|
|
|
|
|
|
public virtual object ViewModel { get; private set; }
|
|
|
|
|
|
|
2014-03-03 08:57:00 +01:00
|
|
|
|
[DataMember(Name = "description")]
|
|
|
|
|
|
public string Description { get; private set; }
|
2014-03-04 19:20:36 +11:00
|
|
|
|
|
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
|
public InstallationType InstallTypeTarget { get; private set; }
|
2014-03-05 11:34:42 +11:00
|
|
|
|
|
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
|
public bool PerformsAppRestart { get; private set; }
|
2017-07-20 11:21:28 +02:00
|
|
|
|
|
2014-02-26 16:01:31 +01:00
|
|
|
|
/// <summary>
|
2017-07-20 11:21:28 +02:00
|
|
|
|
/// Defines what order this step needs to execute on the server side since the
|
2014-02-26 16:01:31 +01:00
|
|
|
|
/// steps might be shown out of order on the front-end
|
|
|
|
|
|
/// </summary>
|
2014-03-04 16:21:45 +11:00
|
|
|
|
[DataMember(Name = "serverOrder")]
|
2014-03-04 11:16:42 +11:00
|
|
|
|
public int ServerOrder { get; private set; }
|
2014-02-26 16:01:31 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Defines the step model type on the server side so we can bind it
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
|
public abstract Type StepType { get; }
|
2017-07-20 11:21:28 +02:00
|
|
|
|
|
2014-03-04 11:16:42 +11:00
|
|
|
|
[IgnoreDataMember]
|
2019-01-11 14:30:04 +11:00
|
|
|
|
public bool HasUIElement => View.IsNullOrWhiteSpace() == false;
|
2014-02-26 16:01:31 +01:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|