星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DownloadInfoModel.cs 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System.Collections.Generic;
  2. namespace Common.Model
  3. {
  4. using System;
  5. /// <summary>
  6. /// 下载模型
  7. /// 创建人:赵耀
  8. /// 创建时间:2018年10月30日
  9. /// </summary>
  10. public class DownloadInfoModel
  11. {
  12. /// <summary>
  13. /// 子线程数量
  14. /// </summary>
  15. private int _taskCount = 1;
  16. /// <summary>
  17. /// 子线程数量
  18. /// </summary>
  19. public int taskCount
  20. {
  21. get => _taskCount;
  22. set => _taskCount = value;
  23. }
  24. /// <summary>
  25. /// 保存的临时文件名
  26. /// </summary>
  27. public string tempFileName { get; set; }
  28. /// <summary>
  29. /// 是否是新任务,如果不是新任务则通过配置去分配线程
  30. /// 一开始要设为true,在初始化完成后会被设为true,此时可以对这个 DownloadInfo 进行序列化后保存,进而实现退出程序加载配置继续下载。
  31. /// </summary>
  32. private bool _isNewTask = true;
  33. /// <summary>
  34. /// 是否是新任务,如果不是新任务则通过配置去分配线程
  35. /// 一开始要设为true,在初始化完成后会被设为true,此时可以对这个 DownloadInfo 进行序列化后保存,进而实现退出程序加载配置继续下载。
  36. /// </summary>
  37. public bool isNewTask
  38. {
  39. get => _isNewTask;
  40. set => _isNewTask = value;
  41. }
  42. /// <summary>
  43. /// 是否重新下载
  44. /// </summary>
  45. private bool _isReStart;
  46. /// <summary>
  47. /// 是否重新下载
  48. /// </summary>
  49. public bool isReStart
  50. {
  51. get => _isReStart;
  52. set => _isReStart = value;
  53. }
  54. /// <summary>
  55. /// 任务总大小
  56. /// </summary>
  57. public long count { get; set; }
  58. /// <summary>
  59. /// 保存的目录
  60. /// </summary>
  61. public string saveDir { get; set; }
  62. /// <summary>
  63. /// 请求方法
  64. /// </summary>
  65. private string _method = "get";
  66. /// <summary>
  67. /// 请求方法
  68. /// </summary>
  69. public string method
  70. {
  71. get => _method;
  72. set => _method = value;
  73. }
  74. /// <summary>
  75. /// 文件名
  76. /// </summary>
  77. public string fileName { get; set; }
  78. public List<string> _downloadUrlList;
  79. /// <summary>
  80. /// 下载地址,
  81. /// 这里是列表形式,如果同一个文件有不同来源则可以通过不同来源取数据
  82. /// 来源的有消息需另外判断
  83. /// </summary>
  84. public List<string> downloadUrlList
  85. {
  86. get => _downloadUrlList;
  87. set
  88. {
  89. List<string> utf8ValueList = new List<string>();
  90. foreach (string val in value)
  91. {
  92. string path = val.Substring(0, val.LastIndexOf("/", StringComparison.Ordinal) + 1);
  93. string name = val.Substring(val.LastIndexOf("/", StringComparison.Ordinal) + 1);
  94. string utf8Name = System.Web.HttpUtility.UrlEncode(name);
  95. string utf8Url = path + utf8Name;
  96. utf8ValueList.Add(utf8Url);
  97. _downloadUrlList = utf8ValueList;
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// 是否支持断点续传
  103. /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持
  104. /// 默认设为false
  105. /// </summary>
  106. private bool _isSupportMultiThreading;
  107. /// <summary>
  108. /// 是否支持断点续传
  109. /// 在任务开始后,如果需要暂停,应先通过这个判断是否支持
  110. /// 默认设为false
  111. /// </summary>
  112. public bool IsSupportMultiThreading
  113. {
  114. get => _isSupportMultiThreading;
  115. set => _isSupportMultiThreading = value;
  116. }
  117. /// <summary>
  118. /// 线程任务列表
  119. /// </summary>
  120. public List<TaskInfoModel> TaskInfoList { get; set; }
  121. /// <summary>
  122. /// 保存文件名
  123. /// </summary>
  124. public string saveFileName { get; set; }
  125. }
  126. /// <summary>
  127. /// 任务模型
  128. /// </summary>
  129. public class TaskInfoModel
  130. {
  131. /// <summary>
  132. /// 请求方法
  133. /// </summary>
  134. public string method { get; set; }
  135. public string downloadUrl { get; set; }
  136. public string filePath { get; set; }
  137. /// <summary>
  138. /// 分片起点
  139. /// </summary>
  140. public long fromIndex { get; set; }
  141. /// <summary>
  142. /// 分片终点
  143. /// </summary>
  144. public long toIndex { get; set; }
  145. /// <summary>
  146. /// 分片的总大小
  147. /// </summary>
  148. public long count => toIndex - fromIndex + 1;
  149. }
  150. /// <summary>
  151. /// 解压书模型
  152. /// </summary>
  153. public class BookDecompressionModel
  154. {
  155. /// <summary>
  156. /// 书的文件名
  157. /// </summary>
  158. public string BookFileName { get; set; }
  159. /// <summary>
  160. /// 解压书籍的控件
  161. /// </summary>
  162. public object UcBookCover { get; set; }
  163. }
  164. }