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
{
///
/// 主页
///
///
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();
}
///
///
///
///
///
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()
{
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);
}
///
///
///
///
public ActionResult test001()
{
//var dt = new List()
//{
// 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 { "LoginID", "UserName" });
//var fileInfo = new List
//{
// 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() });
}
///
///
///
///
///
[HttpPost]
public ActionResult test001(string id)
{
return Json(new List {
new DraggableItem { Title = "物件1", Value = "item1" },
new DraggableItem { Title = "物件2", Value = "item2" },
new DraggableItem { Title = "物件3", Value = "item3" }
});
}
}
}