You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
7.4 KiB
139 lines
7.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Report.Entity;
|
|
using FastReport;
|
|
using PdfSharp;
|
|
using PdfSharp.Drawing;
|
|
using PdfSharp.Pdf;
|
|
using ReportLibrary;
|
|
namespace PeisStart.WInForm.ReportTest
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private async void button1_Click(object sender, EventArgs e)
|
|
{
|
|
string reqStr = @"{""ReportCode"":""0001"",""TemplatePath"":""D:\\peis-vue\\extensions\\fastReport\\template\\0001.frx"",""DataJsonPath"":""D:\\peis-vue\\extensions\\fastReport\\template\\dataJson.json"",""Parameters"":[{""Name"":""printer"",""Value"":""admin""},{""Name"":""hisLog"",""Value"":""pic/hisLog.jpg""}],""WebsiteUrl"":""http://10.1.12.140:8081/"",""ApiUrl"":""http://10.1.12.140:9529/"",""IsUploadPdf"":""N"",""Printer"":""ZDesigner ZD888-203dpi ZPL""}";
|
|
RequestPrint req = ClientConfig.DeserializeObject<RequestPrint>(reqStr);
|
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
|
foreach (var item in req.Parameters)
|
|
{
|
|
dict.Add(item.Name, item.Value);
|
|
}
|
|
DataSet ds = await ConvertHelper.OccuptionDiseaseDetailToDataSetAsync(req.DataJsonPath, dict, req.WebsiteUrl, req.ApiUrl,false);
|
|
FastReport.Report rpt = new FastReport.Report();
|
|
rpt.Load(req.TemplatePath);
|
|
rpt.RegisterData(ds);
|
|
foreach (var item in req.Parameters)
|
|
{
|
|
rpt.SetParameterValue(item.Name, item.Value);
|
|
}
|
|
//rpt.Prepare();
|
|
//rpt.PrintPrepared();4
|
|
rpt.Design();
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
string reqStr = @"{""ReportCode"":""0001"",""TemplatePath"":""c:\\peis-vue\\extensions\\fastReport\\template\\0001.frx"",""DataJsonPath"":""c:\\peis-vue\\extensions\\fastReport\\template\\dataJson.json"",""Parameters"":[{""Name"":""printer"",""Value"":""admin""},{""Name"":""LTS"",""Value"":""Y""},{""Name"":""firstPage"",""Value"":""pic/peisReportFirstPage.jpg""},{""Name"":""pageHeader"",""Value"":""pic/peisReportPageHeader.jpg""},{""Name"":""pageFooter"",""Value"":""pic/peisReportPageFooter.jpg""},{""Name"":""orgSign"",""Value"":""pic/orgSign.png""},{""Name"":""picExtOne"",""Value"":""pic/hisLog.jpg""}],""WebsiteUrl"":""http://140.143.162.39:8081/"",""ApiUrl"":""http://140.143.162.39:9529/"",""ImageUrl"":""http://192.168.2.74:9529/"",""FilePath"":""""}";
|
|
RequestPrintPre req = ClientConfig.DeserializeObject<RequestPrintPre>(reqStr);
|
|
FastReport.Report rpt = new FastReport.Report();
|
|
string json = FileHelper.ReadAllText(req.DataJsonPath);
|
|
var obj = ClientConfig.DeserializeObject<Rpt0005>(json);
|
|
string dataSetJson = ClientConfig.SerializeObject(obj);
|
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
|
foreach (var item in req.Parameters)
|
|
{
|
|
dict.Add(item.Name, item.Value);
|
|
}
|
|
var list = ReportHelper.ToPicTable(dict, req.WebsiteUrl);
|
|
DataTable dt = list.ToDataTable();
|
|
dt.TableName = "pic";
|
|
string paramJson = ClientConfig.SerializeObject(list);
|
|
json = json.Replace("/", "\\/");
|
|
string DataJsonPath = ClientConfig.UpdateJson(json, paramJson);
|
|
|
|
DataSet ds = ClientConfig.ConvertJsonToDataSet(json, "http://192.168.2.74/", "http://192.168.2.67/"); ;
|
|
// FileHelper.WriteAllText("c:\\11.json", DataJsonPath);
|
|
//ds.Tables.Add(dt);
|
|
rpt.Load(req.TemplatePath);
|
|
rpt.RegisterData(ds);
|
|
foreach (var item in req.Parameters)
|
|
{
|
|
rpt.SetParameterValue(item.Name, item.Value);
|
|
}
|
|
rpt.Design();
|
|
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
var a= Math.Round(4234.343, 2);
|
|
}
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
string file = @"E:\WeChat Files\wxid_w8dax2ois8gw22\FileStorage\File\2024-11\\1731997242000.pdf";
|
|
PdfDocument document = new PdfDocument(file);
|
|
document.Options.FlateEncodeMode = PdfFlateEncodeMode.BestCompression;
|
|
document.Options.UseFlateDecoderForJpegImages = PdfUseFlateDecoderForJpegImages.Automatic;
|
|
document.Options.NoCompression = false;
|
|
// Defaults to false in debug build, so we set it to true.
|
|
document.Options.CompressContentStreams = true;
|
|
const string filename = "HelloWorld.pdf";
|
|
document.Save(filename);
|
|
|
|
}
|
|
|
|
private void button5_Click(object sender, EventArgs e)
|
|
{
|
|
string jsonPath = "D:\\peis-vue\\release\\0.3.7\\win-ia32-unpacked\\resources\\app\\extensions\\fastReport\\template\\dataJson.json";
|
|
string json = FileHelper.ReadAllText(jsonPath);
|
|
DataSet ds = ClientConfig.ConvertJsonToDataSet(json,"http://192.168.2.74/", "http://192.168.2.67/");
|
|
DataTable dt = new DataTable();
|
|
}
|
|
|
|
private void button6_Click(object sender, EventArgs e)
|
|
{
|
|
string reqStr = @"{""ReportCode"":""0005"",""TemplatePath"":""c:\\peis-vue\\extensions\\fastReport\\template\\0005.frx"",""DataJsonPath"":""c:\\peis-vue\\extensions\\fastReport\\template\\dataJson.json"",""Parameters"":[{""Name"":""printer"",""Value"":""admin""},{""Name"":""LTS"",""Value"":""Y""},{""Name"":""firstPage"",""Value"":""pic/peisReportFirstPage.jpg""},{""Name"":""pageHeader"",""Value"":""pic/peisReportPageHeader.jpg""},{""Name"":""pageFooter"",""Value"":""pic/peisReportPageFooter.jpg""},{""Name"":""orgSign"",""Value"":""pic/orgSign.png""},{""Name"":""picExtOne"",""Value"":""pic/hisLog.jpg""}],""WebsiteUrl"":""http://140.143.162.39:8081/"",""ApiUrl"":""http://140.143.162.39:9529/"",""ImageUrl"":""http://192.168.2.74:9529/"",""FilePath"":""""}";
|
|
RequestPrintPre req = ClientConfig.DeserializeObject<RequestPrintPre>(reqStr);
|
|
FastReport.Report rpt = new FastReport.Report();
|
|
string json = FileHelper.ReadAllText(req.DataJsonPath);
|
|
var obj = ClientConfig.DeserializeObject<Rpt0005>(json);
|
|
string dataSetJson = ClientConfig.SerializeObject(obj);
|
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
|
foreach (var item in req.Parameters)
|
|
{
|
|
dict.Add(item.Name, item.Value);
|
|
}
|
|
var list = ReportHelper.ToPicTable(dict, req.WebsiteUrl);
|
|
DataTable dt = list.ToDataTable();
|
|
dt.TableName = "pic";
|
|
string paramJson = ClientConfig.SerializeObject(list);
|
|
json = json.Replace("/", "\\/");
|
|
string DataJsonPath = ClientConfig.UpdateJson(json, paramJson);
|
|
|
|
DataSet ds = ClientConfig.ConvertJsonToDataSet(json, "http://192.168.2.74/", "http://192.168.2.67/"); ;
|
|
FileHelper.WriteAllText("d:\\11.json", DataJsonPath);
|
|
//ds.Tables.Add(dt);
|
|
rpt.Load(req.TemplatePath);
|
|
rpt.RegisterData(ds);
|
|
foreach (var item in req.Parameters)
|
|
{
|
|
rpt.SetParameterValue(item.Name, item.Value);
|
|
}
|
|
rpt.Design();
|
|
}
|
|
}
|
|
}
|