wabbajack/Wabbajack.BuildServer/Models/JobQueue/AJobPayload.cs

42 lines
1.2 KiB
C#
Raw Normal View History

2020-01-08 04:41:50 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Bson.Serialization.Attributes;
using Wabbajack.BuildServer.Models.Jobs;
namespace Wabbajack.BuildServer.Models.JobQueue
{
public abstract class AJobPayload
{
public static List<Type> KnownSubTypes = new List<Type>
{
2020-01-09 04:42:25 +00:00
typeof(IndexJob),
2020-01-09 12:14:48 +00:00
typeof(GetNexusUpdatesJob),
2020-01-10 13:16:41 +00:00
typeof(UpdateModLists),
typeof(EnqueueAllArchives),
2020-01-13 04:04:46 +00:00
typeof(EnqueueAllGameFiles),
2020-01-21 12:49:49 +00:00
typeof(EnqueueRecentFiles),
typeof(UploadToCDN)
2020-01-08 04:41:50 +00:00
};
public static Dictionary<Type, string> TypeToName { get; set; }
public static Dictionary<string, Type> NameToType { get; set; }
[BsonIgnore]
public abstract string Description { get; }
public virtual bool UsesNexus { get; } = false;
2020-01-09 04:42:25 +00:00
public abstract Task<JobResult> Execute(DBContext db, AppSettings settings);
2020-01-08 04:41:50 +00:00
static AJobPayload()
{
NameToType = KnownSubTypes.ToDictionary(t => t.FullName.Substring(t.Namespace.Length + 1), t => t);
TypeToName = NameToType.ToDictionary(k => k.Value, k => k.Key);
}
}
}