using System.Collections.Generic; namespace Common.Model { /// /// 下载模型 /// 创建人:赵耀 /// 创建时间:2018年10月30日 /// public class DownloadInfoModel { /// /// 子线程数量 /// private int _taskCount = 1; /// /// 子线程数量 /// public int taskCount { get => _taskCount; set => _taskCount = value; } /// /// 保存的临时文件名 /// public string tempFileName { get; set; } /// /// 是否是新任务,如果不是新任务则通过配置去分配线程 /// 一开始要设为true,在初始化完成后会被设为true,此时可以对这个 DownloadInfo 进行序列化后保存,进而实现退出程序加载配置继续下载。 /// private bool _isNewTask = true; /// /// 是否是新任务,如果不是新任务则通过配置去分配线程 /// 一开始要设为true,在初始化完成后会被设为true,此时可以对这个 DownloadInfo 进行序列化后保存,进而实现退出程序加载配置继续下载。 /// public bool isNewTask { get => _isNewTask; set => _isNewTask = value; } /// /// 是否重新下载 /// private bool _isReStart = false; /// /// 是否重新下载 /// public bool isReStart { get => _isReStart; set => _isReStart = value; } /// /// 任务总大小 /// public long count { get; set; } /// /// 保存的目录 /// public string saveDir { get; set; } /// /// 请求方法 /// private string _method = "get"; /// /// 请求方法 /// public string method { get => _method; set => _method = value; } /// /// 文件名 /// public string fileName { get; set; } public List _downloadUrlList; /// /// 下载地址, /// 这里是列表形式,如果同一个文件有不同来源则可以通过不同来源取数据 /// 来源的有消息需另外判断 /// public List downloadUrlList { get => _downloadUrlList; set { List UTF8ValueList = new List(); foreach (string val in value) { string path = val.Substring(0, val.LastIndexOf("/") + 1); string name = val.Substring(val.LastIndexOf("/") + 1); string UTF8Name = System.Web.HttpUtility.UrlEncode(name); string UTF8Url = path + UTF8Name; UTF8ValueList.Add(UTF8Url); _downloadUrlList = UTF8ValueList; } ; } } /// /// 是否支持断点续传 /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持 /// 默认设为false /// private bool _IsSupportMultiThreading = false; /// /// 是否支持断点续传 /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持 /// 默认设为false /// public bool IsSupportMultiThreading { get => _IsSupportMultiThreading; set => _IsSupportMultiThreading = value; } /// /// 线程任务列表 /// public List TaskInfoList { get; set; } /// /// 保存文件名 /// public string saveFileName { get; set; } } /// /// 任务模型 /// public class TaskInfoModel { /// /// 请求方法 /// public string method { get; set; } public string downloadUrl { get; set; } public string filePath { get; set; } /// /// 分片起点 /// public long fromIndex { get; set; } /// /// 分片终点 /// public long toIndex { get; set; } /// /// 分片的总大小 /// public long count => toIndex - fromIndex + 1; } /// /// 解压书模型 /// public class BookDecompressionModel { /// /// 书的文件名 /// public string BookFileName { get; set; } /// /// 解压书籍的控件 /// public object UcBookCover { get; set; } } }