using Dapper;
|
using FastReport;
|
using Microsoft.AspNetCore.Mvc;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Management;
|
using System.Net;
|
using System.Net.Http;
|
using System.Threading.Tasks;
|
using System.Web;
|
using System.Web.Http;
|
using VueWebApi.DLL.BLL;
|
using VueWebApi.Tools;
|
|
namespace VueWebApi.Controllers
|
{
|
[RoutePrefix(prefix: "api/GridReport")]
|
[ControllerGroup("单据打印", "在线接口")]
|
public class GridReportController : ApiController
|
{
|
//定义全局信息返回变量
|
ToMessage mes = new ToMessage();
|
RedisHelper redis = new RedisHelper();
|
|
|
#region[MES工单打印]
|
/// <summary>
|
/// MES工单打印
|
/// </summary>
|
/// <param name="username">登录用户</param>
|
/// <param name="mesordercode">工单编号</param>
|
[Route(template: "MesOrderPrintSearch")]
|
[HttpPost]
|
public HttpResponseMessage MesOrderPrintSearch(string username,string mesordercode)
|
{
|
mes = GridReportBLL.MesOrderPrintSearch(username,mesordercode);
|
return TJson.toJson(mes);
|
}
|
#endregion
|
|
#region[MES工单打印1]
|
/// <summary>
|
/// MES工单打印1
|
/// </summary>
|
/// <param name="obj">提交数据</param>
|
/// <returns></returns>
|
[Route(template: "MesOrderPrintSearch1")]
|
[HttpPost]
|
public HttpResponseMessage MesOrderPrintSearch1([FromBody] JObject obj)
|
{
|
string username = obj["username"].ToString(); //登录用户
|
string mesordercode = obj["mesordercode"].ToString(); //工单状态码
|
mes = GridReportBLL.MesOrderPrintSearch(username, mesordercode);
|
return TJson.toJson(mes);
|
}
|
#endregion
|
|
#region[FastReport打印]
|
[Route(template: "PrintOrder")]
|
[HttpPost]
|
[HiddenApi]
|
public void PrintOrder([FromBody] JObject obj)
|
{
|
try
|
{
|
string username = obj["username"].ToString(); //登录用户
|
string mesordercode = obj["mesordercode"].ToString(); //工单状态码
|
PrintMessage dt = GridReportBLL.MesOrderFastReportPrintSearch(username, mesordercode);
|
if (dt.data == null)
|
{
|
throw new Exception(dt.Message);
|
}
|
Report report = new Report();
|
//report.PrintSettings.Printer = ((String)report.GetColumnValue("Microsoft XPS Document Writer"));
|
//默认不显示打印机选择页面
|
//string filename = this.Server.MapPath("~/bin/YLDH.frx");//调用报表
|
//report.PrintSettings.Printer = ((String)report.GetColumnValue("Microsoft XPS Document Writer"));
|
//report.PrintSettings.Printer = ((String)report.GetColumnValue("192.168.1.109/Canon G2010 series"));
|
report.PrintSettings.Printer = ((String)report.GetColumnValue("")); //获取本地默认打印机
|
string reportLabel = System.Web.HttpContext.Current.Server.MapPath("/grf/Rework.frx");
|
LogHelper.WriteLogData("文件地址:"+ reportLabel);
|
//FastReport.EnvironmentSettings eSet = new EnvironmentSettings();
|
//eSet.ReportSettings.ShowProgress = false;
|
report.Load(reportLabel);
|
report.PrintSettings.ShowDialog = true;
|
//report.Load(filename);
|
dt.data.TableName = "Table1"; // 一定要设置表名称
|
DataSet ds = new DataSet();
|
ds.Tables.Add(dt.data);
|
report.RegisterData(ds);
|
report.Print();
|
report.Dispose();
|
LogHelper.WriteLogData("序列化通过5");
|
}
|
catch (Exception e)
|
{
|
|
throw;
|
}
|
|
}
|
#endregion
|
}
|
}
|