using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.SupervisionManage; using EMIS.Utility.FormValidate; using EMIS.ViewModel.SupervisionManage; using EMIS.Utility; namespace EMIS.Web.Controllers.SupervisionManage { [Authorization] public class SupDocumentController : Controller { // // GET: /SupDocument/ public ISupDocumentServices supDocumentServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var collegeID = pararms.getExtraGuid("cgbCreateCollege"); var documentType = pararms.getExtraInt("DocumentType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DocumentType"); return base.Json(supDocumentServices.GetSupDocumentViewGrid(configuretView, documentType, collegeID, (int)pararms.page, (int)pararms.rows)); } public ActionResult Edit(Guid? documentID) { var supDocumentView = new SupDocumentView(); if (documentID.HasValue) { supDocumentView = supDocumentServices.GetSupDocumentView(documentID.Value); } else { supDocumentView.DocumentID = Guid.NewGuid(); } return View(supDocumentView); } [HttpPost] public ActionResult Edit(SupDocumentView supDocumentView) { var sessionName = FileUploadHelper.GetFileUploadSessionName(supDocumentView.DocumentID); var fileList = (List)Session[sessionName]; try { supDocumentServices.Save(supDocumentView, fileList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult Delete(string documentIDs) { try { var documentIDList = documentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); supDocumentServices.Delete(documentIDList); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" }); } catch (Exception ex) { return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message }); } } [HttpPost] public ActionResult Download(Guid? documentID) { //List filelist = new List(); var file = supDocumentServices.GetFileUploadViewByDocumentID(documentID); FileUploadHelper.RemoteFileInfo fileInfo = new FileUploadHelper.RemoteFileInfo(); if (file != null) { fileInfo.FileName = file.FileName; fileInfo.RemotePath = (file.FileUrl.Trim().StartsWith("http://") ? file.FileUrl.Trim() : Url.Content(file.FileUrl.Trim())); } return base.Json(fileInfo); } } }