109 lines
2.7 KiB
C#
109 lines
2.7 KiB
C#
using Newtonsoft.Json;
|
|
using System.Diagnostics;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
namespace iFileProxy.Models
|
|
{
|
|
public class TaskInfo
|
|
{
|
|
[JsonProperty("id")]
|
|
[JsonPropertyName("id")]
|
|
public uint Id { get; set; }
|
|
|
|
[JsonProperty("tid")]
|
|
[JsonPropertyName("tid")]
|
|
public string TaskId { get; set; }
|
|
|
|
[JsonProperty("file_name")]
|
|
[JsonPropertyName("file_name")]
|
|
public string FileName { get; set; }
|
|
|
|
[JsonProperty("client_ip")]
|
|
[JsonPropertyName("client_ip")]
|
|
public string? ClientIp { get; set; }
|
|
|
|
[JsonProperty("add_time")]
|
|
[JsonPropertyName("add_time")]
|
|
public DateTime AddTime { get; set; }
|
|
|
|
[JsonProperty("update_time")]
|
|
[JsonPropertyName("update_time")]
|
|
public DateTime UpdateTime { get; set; }
|
|
|
|
[JsonProperty("status")]
|
|
[JsonPropertyName("status")]
|
|
public TaskState Status { get; set; }
|
|
|
|
[JsonProperty("url")]
|
|
[JsonPropertyName("url")]
|
|
public string Url { get; set; }
|
|
|
|
[JsonProperty("size")]
|
|
[JsonPropertyName("size")]
|
|
public long Size { get; set; }
|
|
|
|
[JsonProperty("hash")]
|
|
[JsonPropertyName("hash")]
|
|
public string Hash { get; set; }
|
|
|
|
[JsonProperty("tag")]
|
|
[JsonPropertyName("tag")]
|
|
public string Tag { get; set; } = string.Empty;
|
|
|
|
[JsonProperty("queue_position")]
|
|
[JsonPropertyName("queue_position")]
|
|
public int QueuePosition { get; set; }
|
|
|
|
[System.Text.Json.Serialization.JsonIgnore]
|
|
[Newtonsoft.Json.JsonIgnore]
|
|
public Process Process { get; set; }
|
|
|
|
// Helper to get the tags as a list
|
|
private List<string> GetTagList()
|
|
{
|
|
return string.IsNullOrWhiteSpace(Tag) ? [] : [.. Tag.Split(';')];
|
|
}
|
|
|
|
// Add a new tag
|
|
public void AddTag(string tag)
|
|
{
|
|
var tags = GetTagList();
|
|
if (!tags.Contains(tag))
|
|
{
|
|
tags.Add(tag);
|
|
Tag = string.Join(";", tags);
|
|
}
|
|
}
|
|
|
|
// Remove a tag
|
|
public bool RemoveTag(string tag)
|
|
{
|
|
var tags = GetTagList();
|
|
if (tags.Remove(tag))
|
|
{
|
|
Tag = string.Join(";", tags);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Find a tag
|
|
public bool FindTag(string tag)
|
|
{
|
|
return GetTagList().Contains(tag);
|
|
}
|
|
|
|
// Get all tags as a list
|
|
public List<string> GetTags()
|
|
{
|
|
return GetTagList();
|
|
}
|
|
}
|
|
|
|
|
|
public class DbConfigName
|
|
{
|
|
public static string iFileProxy = "iFileProxy_Db";
|
|
|
|
}
|
|
}
|