星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

DownloadInfoModel.cs 5.3KB

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