SupDocumentController.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.SupervisionManage;
  10. using EMIS.Utility.FormValidate;
  11. using EMIS.ViewModel.SupervisionManage;
  12. using EMIS.Utility;
  13. namespace EMIS.Web.Controllers.SupervisionManage
  14. {
  15. [Authorization]
  16. public class SupDocumentController : Controller
  17. {
  18. //
  19. // GET: /SupDocument/
  20. public ISupDocumentServices supDocumentServices { get; set; }
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. [HttpPost]
  26. public ActionResult List(QueryParamsModel pararms)
  27. {
  28. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  29. var collegeID = pararms.getExtraGuid("cgbCreateCollege");
  30. var documentType = pararms.getExtraInt("DocumentType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DocumentType");
  31. return base.Json(supDocumentServices.GetSupDocumentViewGrid(configuretView, documentType, collegeID, (int)pararms.page, (int)pararms.rows));
  32. }
  33. public ActionResult Edit(Guid? documentID)
  34. {
  35. var supDocumentView = new SupDocumentView();
  36. if (documentID.HasValue)
  37. {
  38. supDocumentView = supDocumentServices.GetSupDocumentView(documentID.Value);
  39. }
  40. else
  41. {
  42. supDocumentView.DocumentID = Guid.NewGuid();
  43. }
  44. return View(supDocumentView);
  45. }
  46. [HttpPost]
  47. public ActionResult Edit(SupDocumentView supDocumentView)
  48. {
  49. var sessionName = FileUploadHelper.GetFileUploadSessionName(supDocumentView.DocumentID);
  50. var fileList = (List<FileUploadView>)Session[sessionName];
  51. try
  52. {
  53. supDocumentServices.Save(supDocumentView, fileList);
  54. return Json(new ReturnMessage()
  55. {
  56. IsSuccess = true,
  57. Message = "保存成功。"
  58. });
  59. }
  60. catch (Exception ex)
  61. {
  62. return Json(new ReturnMessage()
  63. {
  64. IsSuccess = false,
  65. Message = "保存失败:" + ex.Message
  66. });
  67. }
  68. }
  69. [HttpPost]
  70. public ActionResult Delete(string documentIDs)
  71. {
  72. try
  73. {
  74. var documentIDList = documentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  75. supDocumentServices.Delete(documentIDList);
  76. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
  77. }
  78. catch (Exception ex)
  79. {
  80. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  81. }
  82. }
  83. [HttpPost]
  84. public ActionResult Download(Guid? documentID)
  85. {
  86. //List<FileUploadView> filelist = new List<FileUploadView>();
  87. var file = supDocumentServices.GetFileUploadViewByDocumentID(documentID);
  88. FileUploadHelper.RemoteFileInfo fileInfo = new FileUploadHelper.RemoteFileInfo();
  89. if (file != null)
  90. {
  91. fileInfo.FileName = file.FileName;
  92. fileInfo.RemotePath = (file.FileUrl.Trim().StartsWith("http://") ? file.FileUrl.Trim() : Url.Content(file.FileUrl.Trim()));
  93. }
  94. return base.Json(fileInfo);
  95. }
  96. }
  97. }