using NFine.Application.DHAY; using NFine.Application.WMS; using NFine.Code; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Reflection.Emit; using System.Web; using System.Web.Mvc; namespace NFine.Web.Areas.WMS.Controllers { public class SystemUpdateController : ControllerBase { SystemUpdateApp App = new SystemUpdateApp(); // GET: DHAY/ICSCustomerSuppliedReturn public ActionResult Index() { return View(); } /// /// 获取更新文件信息 /// /// /// [HttpGet] [HandlerAjaxOnly] public ActionResult GetFileList() { string dt = App.GetFileList(); return Content(dt); } /// /// 获取更新文件信息 /// /// /// [HttpGet] [HandlerAjaxOnly] public ActionResult GetFilesDetail(string FaBuNum) { string dt = App.GetFilesDetail(FaBuNum); return Content(dt); } public ActionResult InitialImportUpLoad() { return View(); } [HttpPost] /// /// 文件上传到本地 /// public ActionResult UploadFile(string keyValue) { try { string msg=App.UpdateFiles(keyValue); if (string.IsNullOrEmpty(msg)) { return Success("更新成功"); } else { return Error("更新失败" + msg); } } catch (Exception ex) { return Error("更新失败"+ex.Message); } } [HttpPost] [HandlerAjaxOnly] /// /// 文件上传到本地 /// public ActionResult UploadFile2() { try { HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files; //访问客户端通过HTTP请求上传的文件集合 if (Request.Files.Count != 1) { throw new Exception("每次只能上传一个文件"); } HttpPostedFileBase uploadedFile = Request.Files[0]; // 获取第一个上传的文件 // string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + UPLoadType + IsXls; //获取Execle文件名 DateTime日期函数 var tmp = uploadedFile.FileName.Split('~'); if (tmp.Length <= 1) throw new Exception("上传文件名格式不正确"); string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + tmp[1]);//Server.MapPath 获得虚拟服务器相对路径 string msg = App.UpdateFiles(uploadedFile.FileName, uploadedFile.InputStream, savePath); if (System.IO.File.Exists(savePath))//删除文件 { System.IO.File.Delete(savePath); } if (string.IsNullOrEmpty(msg)) { return Success("更新成功"); } else { return Error("更新失败" + msg); } } catch (Exception ex) { return Error("更新失败" + ex.Message); } } } }