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.
 
 
 
 
 
 

256 lines
8.5 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.LR_Desktop;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using Learun.Application.OA.File.FilePreview;
  7. using Learun.Application.Base.SystemModule;
  8. namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-02-24 16:59
  15. /// 描 述:招生数据
  16. /// </summary>
  17. public class EnrollDataController : MvcControllerBase
  18. {
  19. private EnrollDataIBLL enrollDataIBLL = new EnrollDataBLL();
  20. private FilePreviewIBLL filePreviewIBLL = new FilePreviewBLL();
  21. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  22. #region 视图功能
  23. /// <summary>
  24. /// 主页面
  25. /// <summary>
  26. /// <returns></returns>
  27. [HttpGet]
  28. public ActionResult Index()
  29. {
  30. return View();
  31. }
  32. /// <summary>
  33. /// 表单页
  34. /// <summary>
  35. /// <returns></returns>
  36. [HttpGet]
  37. public ActionResult Form()
  38. {
  39. return View();
  40. }
  41. /// <summary>
  42. ///
  43. /// <summary>
  44. /// <returns></returns>
  45. [HttpGet]
  46. public ActionResult IndexPersonnel()
  47. {
  48. return View();
  49. }
  50. #endregion
  51. #region 获取数据
  52. /// <summary>
  53. /// 获取页面显示列表数据
  54. /// </summary>
  55. /// <param name="pagination">分页参数</param>
  56. /// <param name="queryJson">查询参数</param>
  57. /// <returns></returns>
  58. [HttpGet]
  59. [AjaxOnly]
  60. public ActionResult GetPageList(string pagination, string queryJson)
  61. {
  62. Pagination paginationobj = pagination.ToObject<Pagination>();
  63. var data = enrollDataIBLL.GetPageList(paginationobj, queryJson);
  64. var jsonData = new
  65. {
  66. rows = data,
  67. total = paginationobj.total,
  68. page = paginationobj.page,
  69. records = paginationobj.records
  70. };
  71. return Success(jsonData);
  72. }
  73. /// <summary>
  74. /// 获取表单数据
  75. /// </summary>
  76. /// <param name="keyValue">主键</param>
  77. /// <returns></returns>
  78. [HttpGet]
  79. [AjaxOnly]
  80. public ActionResult GetFormData(string keyValue)
  81. {
  82. var EnrollDataData = enrollDataIBLL.GetEnrollDataEntity(keyValue);
  83. var jsonData = new
  84. {
  85. EnrollData = EnrollDataData,
  86. };
  87. return Success(jsonData);
  88. }
  89. #endregion
  90. #region 提交数据
  91. /// <summary>
  92. /// 删除实体数据
  93. /// </summary>
  94. /// <param name="keyValue">主键</param>
  95. /// <returns></returns>
  96. [HttpPost]
  97. [AjaxOnly]
  98. public ActionResult DeleteForm(string keyValue)
  99. {
  100. enrollDataIBLL.DeleteEntity(keyValue);
  101. return Success("删除成功!");
  102. }
  103. /// <summary>
  104. /// 保存实体数据(新增、修改)
  105. /// </summary>
  106. /// <param name="keyValue">主键</param>
  107. /// <param name="strEntity">实体</param>
  108. /// <returns></returns>
  109. [HttpPost]
  110. [ValidateAntiForgeryToken]
  111. [AjaxOnly]
  112. public ActionResult SaveForm(string keyValue, string strEntity)
  113. {
  114. EnrollDataEntity entity = strEntity.ToObject<EnrollDataEntity>();
  115. enrollDataIBLL.SaveEntity(keyValue, entity);
  116. if (string.IsNullOrEmpty(keyValue))
  117. {
  118. }
  119. return Success("保存成功!");
  120. }
  121. #endregion
  122. #region MyRegion
  123. /// <summary>
  124. /// 下载文件
  125. /// </summary>
  126. /// <param name="keyValue">主键</param>
  127. /// <returns></returns>
  128. [HttpPost]
  129. public void DownloadFile(string folderid)
  130. {
  131. var data = annexesFileIBLL.GetEntityByFolderId(folderid);
  132. string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称
  133. string filepath = data.F_FilePath;//this.Server.MapPath(data.F_FilePath);
  134. if (FileDownHelper.FileExists(filepath))
  135. {
  136. FileDownHelper.DownLoadold(filepath, filename);
  137. }
  138. }
  139. /// <summary>
  140. /// 文件预览
  141. /// </summary>
  142. /// <param name="fileId">文件ID</param>
  143. /// <returns></returns>
  144. public void PreviewFile(string folderid)
  145. {
  146. var data = annexesFileIBLL.GetEntityByFolderId(folderid);
  147. if (data == null)
  148. {
  149. return;
  150. }
  151. string filename = Server.UrlDecode(data.F_FileName);//客户端保存的文件名
  152. data.F_FilePath ="/"+ data.F_FilePath.Substring(data.F_FilePath.IndexOf("Resource"));
  153. string filepath = DirFileHelper.GetAbsolutePath(data.F_FilePath);//路径
  154. if (data.F_FileType == "xlsx" || data.F_FileType == "xls")
  155. {
  156. filepath = filepath.Substring(0, filepath.LastIndexOf(".")) + ".pdf";//文件名
  157. if (!DirFileHelper.IsExistFile(filepath))
  158. {
  159. filePreviewIBLL.GetExcelData(DirFileHelper.GetAbsolutePath(data.F_FilePath));
  160. }
  161. }
  162. if (data.F_FileType == "docx" || data.F_FileType == "doc")
  163. {
  164. filepath = filepath.Substring(0, filepath.LastIndexOf(".")) + ".pdf";//文件名
  165. if (!DirFileHelper.IsExistFile(filepath))
  166. {
  167. filePreviewIBLL.GetWordData(DirFileHelper.GetAbsolutePath(data.F_FilePath));
  168. }
  169. }
  170. if (data.F_FileType == "ppt" || data.F_FileType == "pptx")
  171. {
  172. filepath = filepath.Substring(0, filepath.LastIndexOf(".")) + ".pdf";//文件名
  173. if (!DirFileHelper.IsExistFile(filepath))
  174. {
  175. filePreviewIBLL.GetPptData(DirFileHelper.GetAbsolutePath(data.F_FilePath));
  176. }
  177. }
  178. //FileDownHelper.DownLoadold(filepath, filename);
  179. //FileStream files = new FileStream(filepath, FileMode.Open);
  180. //byte[] fileByte = new byte[files.Length];
  181. //files.Read(fileByte, 0, fileByte.Length);
  182. //files.Close();
  183. //System.IO.MemoryStream ms = new MemoryStream(fileByte, 0, fileByte.Length);
  184. Response.ClearContent();
  185. switch (data.F_FileType)
  186. {
  187. case "jpg":
  188. Response.ContentType = "image/jpeg";
  189. break;
  190. case "gif":
  191. Response.ContentType = "image/gif";
  192. break;
  193. case "png":
  194. Response.ContentType = "image/png";
  195. break;
  196. case "bmp":
  197. Response.ContentType = "application/x-bmp";
  198. break;
  199. case "jpeg":
  200. Response.ContentType = "image/jpeg";
  201. break;
  202. case "doc":
  203. Response.ContentType = "application/pdf";
  204. break;
  205. case "docx":
  206. Response.ContentType = "application/pdf";
  207. break;
  208. case "ppt":
  209. Response.ContentType = "application/x-ppt";
  210. break;
  211. case "pptx":
  212. Response.ContentType = "application/x-ppt";
  213. break;
  214. case "xls":
  215. Response.ContentType = "application/pdf";
  216. break;
  217. case "xlsx":
  218. Response.ContentType = "application/pdf";
  219. break;
  220. case "pdf":
  221. Response.ContentType = "application/pdf";
  222. break;
  223. case "txt":
  224. Response.ContentType = "text/plain";
  225. break;
  226. case "csv":
  227. Response.ContentType = "";
  228. break;
  229. default:
  230. Response.ContentType = "application/pdf";
  231. break;
  232. }
  233. Response.Charset = "GB2312";
  234. Response.WriteFile(filepath);
  235. //Response.BinaryWrite(ms.ToArray());
  236. }
  237. #endregion
  238. }
  239. }