1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using MES.Production.Service.IService;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace ChangFa.Machinery.WebPage.Controllers
- {
- public class HomeController : Controller
- {
- static string urlPath = string.Empty;
- ISystemManage SystemManage { get; set; }
- public ActionResult Index()
- {
- //var str = SystemManage.LoadAll(null);
- string url = Request.Url.AbsoluteUri;
- return Redirect(url + "sys/Account/index");
- }
- public HomeController()
- {
- var applicationPath = VirtualPathUtility.ToAbsolute("~") == "/" ? "" : VirtualPathUtility.ToAbsolute("~");
- urlPath = applicationPath + "/Upload";
- }
- public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
- {
- string filePathName = string.Empty;
- string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, "Upload");
- if (Request.Files.Count == 0)
- {
- return Json(new { jsonrpc = 2.0, error = new { code = 102, message = "保存失败" }, id = "id" });
- }
- string ex = Path.GetExtension(file.FileName);
- filePathName = Guid.NewGuid().ToString("N") + ex;
- if (!System.IO.Directory.Exists(localPath))
- {
- System.IO.Directory.CreateDirectory(localPath);
- }
- file.SaveAs(Path.Combine(localPath, filePathName));
- return Json(new
- {
- jsonrpc = "2.0",
- id = id,
- filePath = urlPath + "/" + filePathName
- });
- }
- }
- }
|