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