yl
2022-08-23 0dd2c49c7123f177338985686fe5a0a00a851fbc
VueWebApi/Controllers/GridReportController.cs
@@ -1,10 +1,15 @@
using Newtonsoft.Json.Linq;
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;
@@ -52,5 +57,51 @@
            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
    }
}