2023-05-11 23:11:39 -04:00
|
|
|
|
using SPTInstaller.Interfaces;
|
|
|
|
|
using SPTInstaller.Models;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
namespace SPTInstaller.Installer_Tasks;
|
|
|
|
|
|
|
|
|
|
internal class TestTask : InstallerTaskBase
|
2023-05-11 23:11:39 -04:00
|
|
|
|
{
|
2023-07-12 09:19:33 +02:00
|
|
|
|
public static TestTask FromRandomName() => new TestTask($"Test Task #{new Random().Next(0, 9999)}");
|
|
|
|
|
|
|
|
|
|
public TestTask(string name) : base(name)
|
2023-05-11 23:11:39 -04:00
|
|
|
|
{
|
2023-07-12 09:19:33 +02:00
|
|
|
|
}
|
2023-05-11 23:11:39 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
public async override Task<IResult> TaskOperation()
|
|
|
|
|
{
|
|
|
|
|
var total = 4;
|
|
|
|
|
var interval = TimeSpan.FromSeconds(1);
|
2023-05-11 23:11:39 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
for(var i = 0; i < total; i++)
|
2023-05-11 23:11:39 -04:00
|
|
|
|
{
|
2023-07-12 09:19:33 +02:00
|
|
|
|
var count = i + 1;
|
|
|
|
|
var progressMessage = $"Running Task: {Name}";
|
|
|
|
|
var progress = (int)Math.Floor((double)count / total * 100);
|
2023-05-11 23:11:39 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
SetStatus(progressMessage, $"Details: ({count}/{total})", progress);
|
2023-05-11 23:11:39 -04:00
|
|
|
|
|
2023-07-12 09:19:33 +02:00
|
|
|
|
await Task.Delay(interval);
|
2023-05-11 23:11:39 -04:00
|
|
|
|
}
|
2023-07-12 09:19:33 +02:00
|
|
|
|
|
|
|
|
|
return Result.FromSuccess();
|
2023-05-11 23:11:39 -04:00
|
|
|
|
}
|
2023-07-12 09:19:33 +02:00
|
|
|
|
}
|