using Estsh.Core.Controllers;
using Estsh.Core.Services.IServices;
using Microsoft.AspNetCore.Mvc;
using System.Collections;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:SAP指令导入模块控制类
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
///
/// SAP指令导入模块控制类
///
public class SAPOrderImportController : BaseController
{
private ISAPOrderImportService service;
private IWebHostEnvironment hostingEnvironment;
public SAPOrderImportController(ISAPOrderImportService _service, IWebHostEnvironment _hostingEnvironment)
{
service = _service;
hostingEnvironment = _hostingEnvironment;
}
public ActionResult Index()
{
return View();
}
#region SAP指令导入
///
/// 指令导入
///
///
public ActionResult importOrderInfo(int orderType)
{
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, orderType, CurrentEmp.EmpId);
return Json(result);
}
}
#endregion
}
}