using System.Collections;
using Microsoft.AspNetCore.Mvc;
using Estsh.Core.Services.IServices;
using Estsh.Core.Controllers;
using NPOI.Util;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:采购周计划导入
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
///
/// 采购周计划导入
///
public class PurchaseNoteController : BaseController
{
private IPurchaseNoteService service;
private IWebHostEnvironment hostingEnvironment;
public PurchaseNoteController(IPurchaseNoteService _service, IWebHostEnvironment _hostingEnvironment)
{
service = _service;
hostingEnvironment = _hostingEnvironment;
}
//
// GET: /PurchaseNote/
public ActionResult Index()
{
return View();
}
///
/// 导入采购周计划
///
///
public ActionResult importData()
{
Hashtable result = new Hashtable();
IFormFile file = Request.Form.Files[0];
var filename = file.FileName;
filename = hostingEnvironment.WebRootPath + @"\UpLoad\" + filename;
if (!Directory.Exists(hostingEnvironment.WebRootPath + @"\UpLoad"))
{
Directory.CreateDirectory(hostingEnvironment.WebRootPath + @"\UpLoad");
}
using (FileStream fileStream = System.IO.File.Create(filename))
{
file.CopyTo(fileStream);
fileStream.Flush();
result = service.ReadExcelFile(fileStream, CurrentEmp.EmpId);
return Json(result);
}
}
}
}