using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
using WIDESEA_Core;
using WIDESEA_IStockService;
using WIDESEA_StockService;
namespace WIDESEA_WMSServer.Controllers.Stock
{
[Route("api/MaterielnfoStatistics")]
[Authorize,ApiController]
public class MaterielnfoStatisticsController : Controller
{
private readonly IMaterielnfoStatisticsService _materielnfoStatisticsService;
public MaterielnfoStatisticsController (IMaterielnfoStatisticsService materielnfoStatisticsService)
{
_materielnfoStatisticsService = materielnfoStatisticsService;
}
[HttpPost,Route("GetPageData")]
public object GetPageData([FromBody] PageDataOptions options)
{
return _materielnfoStatisticsService.GetPageGridData(options);
}
///
/// 导出数据
///
///
///
[HttpPost, Route("Export")]
public virtual ActionResult Export([FromBody] PageDataOptions loadData)
{
WebResponseContent result = InvokeService("Export", new object[] { loadData }) as WebResponseContent;
if (result.Status)
return File(
System.IO.File.ReadAllBytes(result.Data.ToString()),
System.Net.Mime.MediaTypeNames.Application.Octet,
Path.GetFileName(result.Data.ToString())
);
return Json(result);
}
private object InvokeService(string methodName, object[] parameters)
{
Type t = _materielnfoStatisticsService.GetType();
List types = new List();
foreach (var param in parameters)
{
types.Add(param.GetType());
}
MethodInfo method = t.GetMethod(methodName, types.ToArray());
return method.Invoke(_materielnfoStatisticsService, parameters);
}
}
}