using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Data; using EMIS.Web.Controls; using EMIS.Utility.FormValidate; using Bowin.Web.Controls.Mvc; using EMIS.Entities; using EMIS.Utility; using EMIS.ViewModel; using Bowin.Common.Utility; using EMIS.CommonLogic.Students; using EMIS.CommonLogic.SystemServices; namespace EMIS.Web.Controllers { [Authorization] public class HomeController : Controller { public IStudentsServices studentsServices { get; set; } public IAnnouncementServices AnnouncementServices { get; set; } public ActionResult Index() { var IsStudent = CustomPrincipal.Current != null ? CustomPrincipal.Current.IsStudent : false; ViewBag.IsStudent = IsStudent; if (IsStudent) { if (!studentsServices.CheckNecessary(EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID)) { return RedirectToAction("FinishInfomation", "Account"); } } return View(); } public ActionResult SwitchRole(Guid hdnSelectedRole) { this.SwitchUserRole(hdnSelectedRole); return RedirectToAction("Index"); } public ActionResult About() { ViewBag.Message = "你的应用程序说明页。"; return View(); } public ActionResult Contact() { ViewBag.Message = "你的联系方式页。"; return View(); } public ActionResult Main() { var typeList = AnnouncementServices.GetAnnouncementTypeViewHaveSourseList(); var typeIDList = typeList.Select(x => x.AnnouncementTypeID).ToList(); ViewBag.TypeIDList = typeIDList; ViewBag.TypeList = typeList; return View(); } public ActionResult MainChangePwd() { return View(); } public ActionResult UploaderSave(FormCollection form) { Response.Cache.SetNoStore(); try { FileUploadView upfile = new FileUploadView(); var files = Request.Files; var formID = (!string.IsNullOrEmpty(Request["v"])) ? new Guid(Request["v"]) : (Guid?)null; string sessionName = FileUploadHelper.GetFileUploadSessionName(formID.Value); //检查文件扩展名字 var postedFile = files["Filedata"]; //得到要上传文件 if (postedFile.FileName == null) { return Json(new FileUploadView(), JsonRequestBehavior.AllowGet); } upfile.FileID = Function.NewPKGuid(); string fileUrl = FileUploadHelper.UploadFile(postedFile); upfile.FileUrl = fileUrl; upfile.FileName = postedFile.FileName; upfile.FormID = formID; if (Session[sessionName] == null) { Session[sessionName] = new List(); } ((List)Session[sessionName]).Add(upfile); return Json(upfile, JsonRequestBehavior.AllowGet); } catch { } return Json(new FileUploadView(), JsonRequestBehavior.AllowGet); } } }