123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- 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 = EMIS.Utility.FormValidate.CustomPrincipal.Current.IsStudent;
- 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 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<FileUploadView>();
- }
- ((List<FileUploadView>)Session[sessionName]).Add(upfile);
- return Json(upfile, JsonRequestBehavior.AllowGet);
- }
- catch
- {
- }
- return Json(new FileUploadView(), JsonRequestBehavior.AllowGet);
- }
- }
- }
|