ImportController.cs
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Hh.Mes.Service;
using Hh.Mes.Service.Planned;
using Hh.Mes.Service.SystemAuth;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace WebMvc.Areas.Planned.Controllers
{
/// <summary>
/// Excel导入 注意 Excel 页签名称和表名要求一致
/// </summary>
[Area("Planned")]
public class ImportController : BaseController
{
private readonly ImportService importService;
private readonly IWebHostEnvironment hostingEnvironment;
public ImportController(IAuth authUtil,ImportService import, IWebHostEnvironment hosting) : base(authUtil)
{
this.importService = import;
hostingEnvironment = hosting;
}
[ResponseCache(Duration = 60)]
public IActionResult Index()
{
return View();
}
/// <summary>
/// 导入数据
/// </summary>
/// <param name="excelfile">表单提交的文件信息</param>
/// <returns></returns>
[HttpPost]
public string Import(IFormFileCollection excelfile)
{
var response = importService.ImportIn(excelfile, hostingEnvironment.ContentRootPath);
return Serialize(response);
}
[ResponseCache(Duration = 60)]
public IActionResult IndexQRCode()
{
return View();
}
}
}