HomeController.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Data;
  7. using EMIS.Web.Controls;
  8. using EMIS.Utility.FormValidate;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.Entities;
  11. using EMIS.Utility;
  12. using EMIS.ViewModel;
  13. using Bowin.Common.Utility;
  14. namespace EMIS.Web.Controllers
  15. {
  16. [Authorization]
  17. public class HomeController : Controller
  18. {
  19. /// <summary>
  20. /// 主页
  21. /// </summary>
  22. /// <returns></returns>
  23. public ActionResult Index()
  24. {
  25. var current = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  26. if (current == null)
  27. {
  28. ViewBag.IsStudent = null;
  29. }
  30. else
  31. {
  32. var IsStudent = EMIS.Utility.FormValidate.CustomPrincipal.Current.IsStudent;
  33. ViewBag.IsStudent = IsStudent;
  34. }
  35. return View();
  36. }
  37. /// <summary>
  38. ///
  39. /// </summary>
  40. /// <param name="hdnSelectedRole"></param>
  41. /// <returns></returns>
  42. public ActionResult SwitchRole(Guid hdnSelectedRole)
  43. {
  44. this.SwitchUserRole(hdnSelectedRole);
  45. return RedirectToAction("Index");
  46. }
  47. /// <summary>
  48. ///
  49. /// </summary>
  50. /// <returns></returns>
  51. public ActionResult About()
  52. {
  53. ViewBag.Message = "你的应用程序说明页。";
  54. return View();
  55. }
  56. /// <summary>
  57. ///
  58. /// </summary>
  59. /// <returns></returns>
  60. public ActionResult Contact()
  61. {
  62. ViewBag.Message = "你的联系方式页。";
  63. return View();
  64. }
  65. /// <summary>
  66. ///
  67. /// </summary>
  68. /// <returns></returns>
  69. public ActionResult Main()
  70. {
  71. return View();
  72. }
  73. /// <summary>
  74. ///
  75. /// </summary>
  76. /// <param name="form"></param>
  77. /// <returns></returns>
  78. public ActionResult UploaderSave(FormCollection form)
  79. {
  80. Response.Cache.SetNoStore();
  81. try
  82. {
  83. FileUploadView upfile = new FileUploadView();
  84. var files = Request.Files;
  85. var formID = (!string.IsNullOrEmpty(Request["v"])) ? new Guid(Request["v"]) : (Guid?)null;
  86. string sessionName = FileUploadHelper.GetFileUploadSessionName(formID.Value);
  87. //检查文件扩展名字
  88. var postedFile = files["Filedata"]; //得到要上传文件
  89. if (postedFile.FileName == null)
  90. {
  91. return Json(new FileUploadView(), JsonRequestBehavior.AllowGet);
  92. }
  93. upfile.FileID = Function.NewPKGuid();
  94. string fileUrl = FileUploadHelper.UploadFile(postedFile);
  95. upfile.FileUrl = fileUrl;
  96. upfile.FileName = postedFile.FileName;
  97. upfile.FormID = formID;
  98. if (Session[sessionName] == null)
  99. {
  100. Session[sessionName] = new List<FileUploadView>();
  101. }
  102. ((List<FileUploadView>)Session[sessionName]).Add(upfile);
  103. return Json(upfile, JsonRequestBehavior.AllowGet);
  104. }
  105. catch
  106. {
  107. }
  108. return Json(new FileUploadView(), JsonRequestBehavior.AllowGet);
  109. }
  110. /// <summary>
  111. ///
  112. /// </summary>
  113. /// <returns></returns>
  114. public ActionResult test001()
  115. {
  116. //var dt = new List<EMIS.ViewModel.Students.StudentsView>()
  117. //{
  118. // new EMIS.ViewModel.Students.StudentsView { LoginID = "1", UserName = "a", Sex = 1 },
  119. // new EMIS.ViewModel.Students.StudentsView { LoginID = "2", UserName = "b", Sex = 2 },
  120. // new EMIS.ViewModel.Students.StudentsView { LoginID = "3", UserName = "c", Sex = 2 },
  121. // new EMIS.ViewModel.Students.StudentsView { LoginID = "4", UserName = "d", Sex = 1 }
  122. //}.ToTable(new List<string> { "LoginID", "UserName" });
  123. //var fileInfo = new List<FileUploadHelper.RemoteFileInfo>
  124. //{
  125. // new FileUploadHelper.RemoteFileInfo { FileName = @"\dir1\file1.xls", RemotePath = @"http://localhost:26692/Content/DownFile/2018-12-27/8b6224ea-29f6-4043-8692-59cb3fd5ff63.xls" },
  126. // new FileUploadHelper.RemoteFileInfo { FileName = @"\dir2\file1.xls", RemotePath = @"http://localhost:26692/Content/DownFile/2018-12-27/b5217fe7-c0a4-4cbe-8893-b3c324aec121.xls" },
  127. // new FileUploadHelper.RemoteFileInfo { FileName = @"\dir2\file2.xls", RemotePath = @"http://localhost:26692/Content/DownFile/2018-12-27/d91e859f-bb09-49b6-aacb-5fc923da7c49.xls" }
  128. //};
  129. //FileUploadHelper.DownLoadFiles("测试包文件名", "测试包下载显示文件名", fileInfo);
  130. return View(new DQP_SOCTemplateDetail { SOCTemplateItemID = Guid.NewGuid() });
  131. }
  132. /// <summary>
  133. ///
  134. /// </summary>
  135. /// <param name="id"></param>
  136. /// <returns></returns>
  137. [HttpPost]
  138. public ActionResult test001(string id)
  139. {
  140. return Json(new List<DraggableItem> {
  141. new DraggableItem { Title = "物件1", Value = "item1" },
  142. new DraggableItem { Title = "物件2", Value = "item2" },
  143. new DraggableItem { Title = "物件3", Value = "item3" }
  144. });
  145. }
  146. }
  147. }