123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- 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;
- namespace EMIS.Web.Controllers
- {
- [Authorization]
- public class HomeController : Controller
- {
- /// <summary>
- /// 主页
- /// </summary>
- /// <returns></returns>
- public ActionResult Index()
- {
- var current = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (current == null)
- {
- ViewBag.IsStudent = null;
- }
- else
- {
- var IsStudent = EMIS.Utility.FormValidate.CustomPrincipal.Current.IsStudent;
- ViewBag.IsStudent = IsStudent;
- }
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="hdnSelectedRole"></param>
- /// <returns></returns>
- public ActionResult SwitchRole(Guid hdnSelectedRole)
- {
- this.SwitchUserRole(hdnSelectedRole);
- return RedirectToAction("Index");
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ActionResult About()
- {
- ViewBag.Message = "你的应用程序说明页。";
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ActionResult Contact()
- {
- ViewBag.Message = "你的联系方式页。";
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ActionResult Main()
- {
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="form"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ActionResult test001()
- {
- //var dt = new List<EMIS.ViewModel.Students.StudentsView>()
- //{
- // new EMIS.ViewModel.Students.StudentsView { LoginID = "1", UserName = "a", Sex = 1 },
- // new EMIS.ViewModel.Students.StudentsView { LoginID = "2", UserName = "b", Sex = 2 },
- // new EMIS.ViewModel.Students.StudentsView { LoginID = "3", UserName = "c", Sex = 2 },
- // new EMIS.ViewModel.Students.StudentsView { LoginID = "4", UserName = "d", Sex = 1 }
- //}.ToTable(new List<string> { "LoginID", "UserName" });
- //var fileInfo = new List<FileUploadHelper.RemoteFileInfo>
- //{
- // new FileUploadHelper.RemoteFileInfo { FileName = @"\dir1\file1.xls", RemotePath = @"http://localhost:26692/Content/DownFile/2018-12-27/8b6224ea-29f6-4043-8692-59cb3fd5ff63.xls" },
- // new FileUploadHelper.RemoteFileInfo { FileName = @"\dir2\file1.xls", RemotePath = @"http://localhost:26692/Content/DownFile/2018-12-27/b5217fe7-c0a4-4cbe-8893-b3c324aec121.xls" },
- // new FileUploadHelper.RemoteFileInfo { FileName = @"\dir2\file2.xls", RemotePath = @"http://localhost:26692/Content/DownFile/2018-12-27/d91e859f-bb09-49b6-aacb-5fc923da7c49.xls" }
- //};
- //FileUploadHelper.DownLoadFiles("测试包文件名", "测试包下载显示文件名", fileInfo);
- return View(new DQP_SOCTemplateDetail { SOCTemplateItemID = Guid.NewGuid() });
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult test001(string id)
- {
- return Json(new List<DraggableItem> {
- new DraggableItem { Title = "物件1", Value = "item1" },
- new DraggableItem { Title = "物件2", Value = "item2" },
- new DraggableItem { Title = "物件3", Value = "item3" }
- });
- }
- }
- }
|