2024-08-07 18:48:13 -05:00
|
|
|
|
using LANCommander.SDK.Enums;
|
2026-04-17 22:24:47 -05:00
|
|
|
|
using LANCommander.SDK.Models;
|
2024-05-25 15:40:31 -05:00
|
|
|
|
|
2024-08-04 17:53:19 -05:00
|
|
|
|
namespace LANCommander.Launcher.Models
|
2024-05-25 15:40:31 -05:00
|
|
|
|
{
|
2024-10-26 15:48:47 -05:00
|
|
|
|
public class DownloadQueueRedistributable : IInstallQueueItem
|
2024-05-25 15:40:31 -05:00
|
|
|
|
{
|
|
|
|
|
|
public Guid Id { get; set; }
|
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
public string Version { get; set; }
|
2024-09-12 19:09:13 -05:00
|
|
|
|
public string InstallDirectory { get; set; }
|
2024-06-08 23:38:55 -05:00
|
|
|
|
public Guid CoverId { get; set; }
|
|
|
|
|
|
public Guid IconId { get; set; }
|
2024-05-25 15:40:31 -05:00
|
|
|
|
public DateTime QueuedOn { get; set; }
|
|
|
|
|
|
public DateTime? CompletedOn { get; set; }
|
2024-06-01 22:47:22 -05:00
|
|
|
|
public bool IsUpdate { get; set; }
|
2024-05-25 15:40:31 -05:00
|
|
|
|
public bool State
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (Status)
|
|
|
|
|
|
{
|
2026-04-17 22:24:47 -05:00
|
|
|
|
case InstallStatus.Starting:
|
2025-01-31 00:34:37 -06:00
|
|
|
|
case InstallStatus.Downloading:
|
|
|
|
|
|
case InstallStatus.InstallingRedistributables:
|
|
|
|
|
|
case InstallStatus.RunningScripts:
|
2024-05-25 15:40:31 -05:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-31 00:34:37 -06:00
|
|
|
|
public InstallStatus Status { get; set; }
|
2024-05-25 15:40:31 -05:00
|
|
|
|
public SDK.Models.Redistributable Redistributable { get; set; }
|
2026-04-17 22:24:47 -05:00
|
|
|
|
public InstallPlanItemType ItemType => InstallPlanItemType.Redistributable;
|
|
|
|
|
|
public Guid? DependsOnId { get; set; }
|
|
|
|
|
|
public List<InstallTaskDefinition> Tasks { get; set; } = new();
|
|
|
|
|
|
public Guid? CurrentTaskId { get; set; }
|
|
|
|
|
|
public float Progress
|
|
|
|
|
|
{
|
|
|
|
|
|
get => BytesDownloaded / (float)Math.Max(TotalBytes, 1);
|
|
|
|
|
|
set { }
|
|
|
|
|
|
}
|
|
|
|
|
|
public double TransferSpeed { get; set; }
|
|
|
|
|
|
public long BytesDownloaded { get; set; }
|
|
|
|
|
|
public long TotalBytes { get; set; }
|
2025-10-15 21:26:40 -05:00
|
|
|
|
public CancellationTokenSource CancellationToken { get; set; } = new();
|
2024-05-25 15:40:31 -05:00
|
|
|
|
|
|
|
|
|
|
public DownloadQueueRedistributable(SDK.Models.Redistributable redistributable)
|
|
|
|
|
|
{
|
|
|
|
|
|
Redistributable = redistributable;
|
|
|
|
|
|
Id = redistributable.Id;
|
|
|
|
|
|
Title = redistributable.Name;
|
2026-04-17 22:24:47 -05:00
|
|
|
|
Version = redistributable.Archives?.OrderByDescending(a => a.CreatedOn).FirstOrDefault()?.Version;
|
|
|
|
|
|
QueuedOn = DateTime.Now;
|
|
|
|
|
|
Status = InstallStatus.Queued;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DownloadQueueRedistributable(InstallPlanItem planItem, SDK.Models.Redistributable redistributable) : this(redistributable)
|
|
|
|
|
|
{
|
|
|
|
|
|
InstallDirectory = planItem.InstallDirectory;
|
|
|
|
|
|
DependsOnId = planItem.DependsOnId;
|
|
|
|
|
|
Tasks = planItem.Tasks;
|
2024-05-25 15:40:31 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|