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.

DTImgBLL.cs 5.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using Learun.Util;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Learun.Application.AppMagager
  5. {
  6. /// <summary>
  7. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  8. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  9. /// 创 建:超级管理员
  10. /// 日 期:2018-07-02 15:31
  11. /// 描 述:App首页图片管理
  12. /// </summary>
  13. public class DTImgBLL : DTImgIBLL
  14. {
  15. private DTImgService dTImgService = new DTImgService();
  16. #region 获取数据
  17. /// <summary>
  18. /// 获取列表数据
  19. /// <summary>
  20. /// <returns></returns>
  21. public IEnumerable<DTImgEntity> GetList()
  22. {
  23. try
  24. {
  25. return dTImgService.GetList();
  26. }
  27. catch (Exception ex)
  28. {
  29. if (ex is ExceptionEx)
  30. {
  31. throw;
  32. }
  33. else
  34. {
  35. throw ExceptionEx.ThrowBusinessException(ex);
  36. }
  37. }
  38. }
  39. /// <summary>
  40. /// 获取列表分页数据
  41. /// <param name="pagination">分页参数</param>
  42. /// <summary>
  43. /// <returns></returns>
  44. public IEnumerable<DTImgEntity> GetPageList(Pagination pagination, string queryJson)
  45. {
  46. try
  47. {
  48. return dTImgService.GetPageList(pagination, queryJson);
  49. }
  50. catch (Exception ex)
  51. {
  52. if (ex is ExceptionEx)
  53. {
  54. throw;
  55. }
  56. else
  57. {
  58. throw ExceptionEx.ThrowBusinessException(ex);
  59. }
  60. }
  61. }
  62. /// <summary>
  63. /// 获取实体数据
  64. /// <param name="keyValue">主键</param>
  65. /// <summary>
  66. /// <returns></returns>
  67. public DTImgEntity GetEntity(string keyValue)
  68. {
  69. try
  70. {
  71. return dTImgService.GetEntity(keyValue);
  72. }
  73. catch (Exception ex)
  74. {
  75. if (ex is ExceptionEx)
  76. {
  77. throw;
  78. }
  79. else
  80. {
  81. throw ExceptionEx.ThrowBusinessException(ex);
  82. }
  83. }
  84. }
  85. #endregion
  86. #region 提交数据
  87. /// <summary>
  88. /// 删除实体数据
  89. /// <param name="keyValue">主键</param>
  90. /// <summary>
  91. /// <returns></returns>
  92. public void DeleteEntity(string keyValue)
  93. {
  94. try
  95. {
  96. DTImgEntity entity = GetEntity(keyValue);
  97. if (entity != null)
  98. {
  99. if (!string.IsNullOrEmpty(entity.F_FileName))
  100. {
  101. string fileHeadImg = Config.GetValue("fileAppDTImg");
  102. string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_Id, entity.F_FileName);
  103. if (DirFileHelper.IsExistFile(fileImg))
  104. {
  105. System.IO.File.Delete(fileImg);
  106. }
  107. }
  108. }
  109. dTImgService.DeleteEntity(keyValue);
  110. }
  111. catch (Exception ex)
  112. {
  113. if (ex is ExceptionEx)
  114. {
  115. throw;
  116. }
  117. else
  118. {
  119. throw ExceptionEx.ThrowBusinessException(ex);
  120. }
  121. }
  122. }
  123. /// <summary>
  124. /// 保存实体数据(新增、修改)
  125. /// <param name="keyValue">主键</param>
  126. /// <summary>
  127. /// <returns></returns>
  128. public void SaveEntity(string keyValue, DTImgEntity entity)
  129. {
  130. try
  131. {
  132. dTImgService.SaveEntity(keyValue, entity);
  133. }
  134. catch (Exception ex)
  135. {
  136. if (ex is ExceptionEx)
  137. {
  138. throw;
  139. }
  140. else
  141. {
  142. throw ExceptionEx.ThrowBusinessException(ex);
  143. }
  144. }
  145. }
  146. /// <summary>
  147. /// 更新数据状态
  148. /// </summary>
  149. /// <param name="keyValue">主键</param>
  150. /// <param name="state">状态1启用2禁用</param>
  151. public void UpdateState(string keyValue, int state)
  152. {
  153. DTImgEntity entity = new DTImgEntity();
  154. entity.F_EnabledMark = state;
  155. SaveEntity(keyValue, entity);
  156. }
  157. #endregion
  158. #region 扩展方法
  159. /// <summary>
  160. /// 获取图片 当webapi与web不在同一台服务器上时,isDistributed应为true
  161. /// </summary>
  162. /// <param name="keyValue"></param>
  163. public void GetImg(string keyValue)
  164. {
  165. DTImgEntity entity = GetEntity(keyValue);
  166. string img = "";
  167. if (entity != null)
  168. {
  169. if (!string.IsNullOrEmpty(entity.F_FileName))
  170. {
  171. string fileHeadImg = Config.GetValue("fileAppDTImg");
  172. string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_Id, entity.F_FileName);
  173. if (DirFileHelper.IsExistFile(fileImg))
  174. {
  175. img = fileImg;
  176. FileDownHelper.DownLoadnew(img);
  177. return;
  178. }
  179. }
  180. }
  181. else
  182. {
  183. img = "/Content/images/add.jpg";
  184. }
  185. if (string.IsNullOrEmpty(img))
  186. {
  187. img = "/Content/images/add.jpg";
  188. }
  189. FileDownHelper.DownLoad(img);
  190. }
  191. #endregion
  192. }
  193. }