You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.8 KiB

3 weeks ago
  1. using NFine.Application.DHAY;
  2. using NFine.Application.WMS;
  3. using NFine.Code;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection.Emit;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace NFine.Web.Areas.WMS.Controllers
  13. {
  14. public class SystemUpdateController : ControllerBase
  15. {
  16. SystemUpdateApp App = new SystemUpdateApp();
  17. // GET: DHAY/ICSCustomerSuppliedReturn
  18. public ActionResult Index()
  19. {
  20. return View();
  21. }
  22. /// <summary>
  23. /// 获取更新文件信息
  24. /// </summary>
  25. /// <param name="type"></param>
  26. /// <returns></returns>
  27. [HttpGet]
  28. [HandlerAjaxOnly]
  29. public ActionResult GetFileList()
  30. {
  31. string dt = App.GetFileList();
  32. return Content(dt);
  33. }
  34. /// <summary>
  35. /// 获取更新文件信息
  36. /// </summary>
  37. /// <param name="type"></param>
  38. /// <returns></returns>
  39. [HttpGet]
  40. [HandlerAjaxOnly]
  41. public ActionResult GetFilesDetail(string FaBuNum)
  42. {
  43. string dt = App.GetFilesDetail(FaBuNum);
  44. return Content(dt);
  45. }
  46. public ActionResult InitialImportUpLoad()
  47. {
  48. return View();
  49. }
  50. [HttpPost]
  51. /// <summary>
  52. /// 文件上传到本地
  53. /// </summary>
  54. public ActionResult UploadFile(string keyValue)
  55. {
  56. try
  57. {
  58. string msg=App.UpdateFiles(keyValue);
  59. if (string.IsNullOrEmpty(msg))
  60. {
  61. return Success("更新成功");
  62. }
  63. else
  64. {
  65. return Error("更新失败" + msg);
  66. }
  67. }
  68. catch (Exception ex)
  69. {
  70. return Error("更新失败"+ex.Message);
  71. }
  72. }
  73. [HttpPost]
  74. [HandlerAjaxOnly]
  75. /// <summary>
  76. /// 文件上传到本地
  77. /// </summary>
  78. public ActionResult UploadFile2()
  79. {
  80. try
  81. {
  82. HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files; //访问客户端通过HTTP请求上传的文件集合
  83. if (Request.Files.Count != 1)
  84. {
  85. throw new Exception("每次只能上传一个文件");
  86. }
  87. HttpPostedFileBase uploadedFile = Request.Files[0]; // 获取第一个上传的文件
  88. // string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + UPLoadType + IsXls; //获取Execle文件名 DateTime日期函数
  89. var tmp = uploadedFile.FileName.Split('~');
  90. if (tmp.Length <= 1)
  91. throw new Exception("上传文件名格式不正确");
  92. string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + tmp[1]);//Server.MapPath 获得虚拟服务器相对路径
  93. string msg = App.UpdateFiles(uploadedFile.FileName, uploadedFile.InputStream, savePath);
  94. if (System.IO.File.Exists(savePath))//删除文件
  95. {
  96. System.IO.File.Delete(savePath);
  97. }
  98. if (string.IsNullOrEmpty(msg))
  99. {
  100. return Success("更新成功");
  101. }
  102. else
  103. {
  104. return Error("更新失败" + msg);
  105. }
  106. }
  107. catch (Exception ex)
  108. {
  109. return Error("更新失败" + ex.Message);
  110. }
  111. }
  112. }
  113. }