Commit df44949d by zim78

no message

0 parents
# The 5 approved on boarding samples that need wwwroot/lib/ can add a local .gitignore that allows wwwroot/lib/.
# with 2.1 templates and excluding .min & .map -> 27 files and < 1 KB
# 3.0 templates should be even less
# wwwroot/lib/
# When wwwroot/lib/ is commented out, excluse .min and .map files
*.min.css
*.min.js
*.map
_build/
_site/
Properties/
# See #577
# Use git add -f to force override .sln when required. Not needed in most cases.
# git add -f myProj.sln
*.sln
Project_Readme.html
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
.vscode/
!.vscode/extensions.json
!.vscode/settings.json
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studo 2015 cache/options directory
.vs/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
*.[Cc]ache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
project.lock.json
__pycache__/
#Mac OSX
.DS_Store
# Windows thumbnail cache files
Thumbs.db
MTAntiFake/.config/dotnet-tools.json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PDFExportOpri_CLI
{
public class AutoModifyReprtClass
{
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>PDFExportOpri_CLI</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\PdfExportOpri\bin\Debug</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Reporting.Core" Version="20.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugarCore" Version="5.0.5.2" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.1" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<None Update="bmp\fm10.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm12.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm14.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm16.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm4.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm6.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm8.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\noimage.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\top.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="cli-appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
using System;
using System.Collections;
using System.IO;
using DevExpress.DataAccess.Native.Json;
using DevExpress.DataProcessing;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.Security;
using DevExpress.XtraReports.UI;
using Microsoft.Extensions.Configuration;
using PDFExportOpri_CLI.Modules.PdfExport;
using SqlSugar;
namespace PDFExportOpri_CLI
{
class Program
{
static void Main(string[] args)
{
try
{
if (args.Length < 2)
{
Console.WriteLine("Invalid Arguments...");
Environment.Exit(1);
}
ScriptPermissionManager.GlobalInstance = new ScriptPermissionManager(ExecutionMode.Unrestricted);
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName)
.AddJsonFile(AppDomain.CurrentDomain.BaseDirectory + "./cli-appsettings.json", false)
.Build();
var outputPath = args[0];
var reportId = args[1];
if (Directory.Exists(outputPath))
{
if (File.Exists(outputPath + "export_" + reportId + ".pdf"))
File.Delete(outputPath + "export_" + reportId + ".pdf");
}
else
{
Directory.CreateDirectory(outputPath);
}
using (ReportPrinter rpt = new ReportPrinter())
{
rpt.LoadModel(AppDomain.CurrentDomain.BaseDirectory + "./ModelTemp/IVEH_APP.xml");
SqlSugarClient dbClient = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.MySql,
ConnectionString = "SERVER=" + configuration["Database:Host"] + ";"
+ "DATABASE=" + configuration["Database:Name"] + ";"
+ "UID=" + configuration["Database:Username"] + ";"
+ "PASSWORD=" + configuration["Database:Password"] + ";"
+ "PORT="+configuration["Database:Port"]+";"
});
rpt.LoadData(dbClient, reportId);
//偏载测试图片
int partialloadid = Convert.ToInt32(rpt.ds.Tables["dt1"].Rows[0]["partialloadid"]);
if (partialloadid != -1)
{
string weightNumber = rpt.ds.Tables["dt3"].Rows[0]["weightnumber"].ToString();
XRPictureBox p1 = (XRPictureBox)rpt.FindControl("pb_1", true);
if (p1 != null)
{
p1.ImageUrl = $"./bmp/fm{weightNumber}.jpg";
}
SetPartialItem(rpt);
}
SetImage(rpt);
SetRemark(rpt);
PdfExportOptions opt = rpt.ExportOptions.Pdf;
opt.ConvertImagesToJpeg = false;
opt.Compressed = true;
opt.ImageQuality = PdfJpegImageQuality.High;
rpt.ExportToPdf(outputPath + "export_" + reportId + ".pdf", opt);
}
}
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
Environment.Exit(-1);
}
Environment.Exit(0);
}
private static void SetPartialItem(ReportPrinter rpt)
{
int loadNumber = Convert.ToInt32(rpt.ds.Tables["dt3"].Rows[0]["loadnumber"]);
int weightNumber = Convert.ToInt32(rpt.ds.Tables["dt3"].Rows[0]["weightnumber"]);
SetPartialRowUnvisiable(rpt, loadNumber);
SetPartialCellUnvisiable(rpt,loadNumber,weightNumber);
SetPartialValue(rpt,loadNumber,weightNumber);
}
private static void SetPartialRowUnvisiable(ReportPrinter rpt, int number)
{
for (int i = 5; i > number; i--)
{
rpt.FindControl($"tr{i}", true).Visible = false;
rpt.FindControl($"tr{i}_0_1", true).Visible = false;
rpt.FindControl($"tr{i}_0_2", true).Visible = false;
rpt.FindControl($"tr{i}_1", true).Visible = false;
rpt.FindControl($"tr{i}_2", true).Visible = false;
rpt.FindControl($"tr{i}_3", true).Visible = false;
rpt.FindControl($"tr{i}_4", true).Visible = false;
rpt.FindControl($"tr{i}_5", true).Visible = false;
rpt.FindControl($"tr{i}_6", true).Visible = false;
}
}
private static void SetPartialCellUnvisiable(ReportPrinter rpt,int loadNumber, int weightNumber)
{
int remainRow = Convert.ToInt32(Math.Ceiling((decimal)weightNumber / 3));
int maxCellNumber = remainRow * 3;
if (maxCellNumber > 16) maxCellNumber = 16;
for (int i = 1; i <= loadNumber; i++)
{
for (int j = 6; j > remainRow; j--)
{
rpt.FindControl($"tr{i}_{j}", true).Visible = false;
}
for (int j = maxCellNumber; j > weightNumber; j--)
{
rpt.FindControl($"tc{i}_{j}", true).Text = "";
rpt.FindControl($"caption_tc{i}_{j}", true).Text = "";
}
}
}
private static void SetPartialValue(ReportPrinter rpt, int loadNumber, int weightNumber)
{
for (int i = 1; i <= loadNumber; i++)
{
Newtonsoft.Json.Linq.JToken item = rpt.jPartial[i - 1];
string testweight = item["testweight"]?.ToString();
string loaderror = item["loaderror"]?.ToString();
string maxerror = item["maxerror"]?.ToString();
if (testweight != "") testweight += " kg";
if (loaderror != "") loaderror += " kg";
if (maxerror != "") maxerror += " kg";
rpt.FindControl($"tc{i}_zh",true).Text = testweight;
rpt.FindControl($"tc{i}_wc", true).Text = loaderror;
rpt.FindControl($"tc{i}_yc", true).Text = maxerror;
rpt.FindControl($"tc{i}_fh", true).Text = item["conformname"]?.ToString();
rpt.FindControl($"tc{i}_mx", true).Text = item["fillname"]?.ToString();
if (item["fillcode"]?.ToString() != "01")
{
for (int j = 1; j <= 6; j++)
{
rpt.FindControl($"tr{i}_{j}", true).Visible = false;
}
}
else
{
Newtonsoft.Json.Linq.JArray deviation = item["deviation"] as Newtonsoft.Json.Linq.JArray;
Newtonsoft.Json.Linq.JToken dItem = null;
for (int j = 1; j <= weightNumber; j++)
{
try
{
dItem = deviation[j - 1];
}
catch
{
dItem = null;
}
if (dItem != null)
{
string devString = dItem["deviation"]?.ToString();
if (devString != "") devString += " kg";
rpt.FindControl($"tc{i}_{j}", true).Text = devString;
}
}
}
}
}
private static void SetImage(ReportPrinter rpt)
{
ArrayList list = new ArrayList();
for (int i = 1; i < 7; i++)
{
string i1 = rpt.ds.Tables["dt1"].Rows[0]["i"+i].ToString().Replace("\"", "").Replace("[", "").Replace("]", "").Trim();
if (i1 != "")
{
string[] items = i1.Split(",");
foreach (string item in items)
{
ImageItemClass imageItem = new ImageItemClass();
switch (i)
{
case 1:
imageItem.groupName = "企业大门";
break;
case 2:
imageItem.groupName = "汽车衡全景";
break;
case 3:
imageItem.groupName = "基础引坡";
break;
case 4:
imageItem.groupName = "仪表近景";
break;
case 5:
imageItem.groupName = "传感器状况";
break;
case 6:
imageItem.groupName = "其他";
break;
}
imageItem.url = "http://image.mtmaster.release.360cbs.com/" + item;
list.Add(imageItem);
}
}
else
{
ImageItemClass imageItem = new ImageItemClass();
switch (i)
{
case 1:
imageItem.groupName = "企业大门";
break;
case 2:
imageItem.groupName = "汽车衡全景";
break;
case 3:
imageItem.groupName = "基础引坡";
break;
case 4:
imageItem.groupName = "仪表近景";
break;
case 5:
imageItem.groupName = "传感器状况";
break;
case 6:
imageItem.groupName = "其他";
break;
}
imageItem.url = $"./bmp/noimage.png";
imageItem.hasImage = false;
list.Add(imageItem);
}
}
int remainGroup = Convert.ToInt32(Math.Ceiling((decimal)list.Count / 6));
int maxRow = remainGroup * 3;
int remainRow = Convert.ToInt32(Math.Ceiling((decimal)list.Count / 2));
for (int i = 3; i > remainGroup; i--)
{
rpt.FindControl($"drp_{i}", true).Visible = false;
}
for (int i = maxRow; i > remainRow; i--)
{
rpt.FindControl($"p_{i}", true).Visible = false;
}
ImageItemClass myItem;
for (int i=1; i <= list.Count; i++)
{
XRPictureBox image = rpt.FindControl($"image_{i}", true) as XRPictureBox;
myItem = (ImageItemClass) list[i - 1];
image.ImageUrl = myItem.url;
if (!myItem.hasImage)
{
PaddingInfo padding = new PaddingInfo(96);
padding.All = 70;
image.Padding = padding;
}
rpt.FindControl($"imagecaption_{i}", true).Text = myItem.groupName;
}
}
private static void SetRemark(ReportPrinter rpt)
{
int completeid = Convert.ToInt32(rpt.ds.Tables["dt1"].Rows[0]["completeid"]);
int partialloadid = Convert.ToInt32(rpt.ds.Tables["dt1"].Rows[0]["partialloadid"]);
int linearid = Convert.ToInt32(rpt.ds.Tables["dt1"].Rows[0]["linearid"]);
int repeatid = Convert.ToInt32(rpt.ds.Tables["dt1"].Rows[0]["repeatid"]);
string remark_idx = "1";
if (completeid == -1)
{
rpt.FindControl("dr_complete", true).Visible = false;
}
else
{
remark_idx = "2";
}
if (partialloadid == -1)
{
rpt.FindControl("dr_partial", true).Visible = false;
}
else
{
remark_idx = "3";
}
if (linearid == -1)
{
rpt.FindControl("dr_linear", true).Visible = false;
}
else
{
remark_idx = "4";
}
if (repeatid == -1)
{
rpt.FindControl("dr_repeat", true).Visible = false;
}
else
{
remark_idx = "5";
}
rpt.FindControl("remark_"+remark_idx, true).Visible = true;
}
}
public class ImageItemClass
{
public string groupName;
public string url;
public bool hasImage = true;
}
}
namespace PDFExportOpri_CLI.Modules.PdfExport
{
partial class ReportPrinter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.Detail = new DevExpress.XtraReports.UI.DetailBand();
this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
this.BottomMargin = new DevExpress.XtraReports.UI.BottomMarginBand();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.TopMargin.Height = 100;
this.BottomMargin.Height = 100;
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
this.Detail,
this.TopMargin,
this.BottomMargin});
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
}
#endregion
private DevExpress.XtraReports.UI.DetailBand Detail;
private DevExpress.XtraReports.UI.TopMarginBand TopMargin;
private DevExpress.XtraReports.UI.BottomMarginBand BottomMargin;
}
}
using System;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Data;
using System.Drawing.Printing;
using System.IO;
using DevExpress.XtraPrinting;
using Newtonsoft.Json.Linq;
using SqlSugar;
namespace PDFExportOpri_CLI.Modules.PdfExport
{
public partial class ReportPrinter : DevExpress.XtraReports.UI.XtraReport
{
public DataSet ds = new DataSet();
public JArray jPartial = null;
public void LoadModel(string file)
{
this.LoadLayout(file);
this.Landscape = false;
this.PaperKind = PaperKind.A4;
}
public void LoadData(SqlSugarClient client,string id)
{
DataTable dt1 = client.Ado.GetDataTable(@$"SELECT
FROM_UNIXTIME( m.firstinspectiontime, '%Y%m%d日' ) years,
p1.NAME pf1name, p2.NAME pf2name, p3.NAME pf3name, p4.NAME pf4name, p5.NAME pf5name, p6.NAME pf6name, p7.NAME pf7name,
c1.NAME cf1name, c2.NAME cf2name, c3.NAME cf3name, o1.NAME ot1name, o2.NAME ot2name, o3.NAME ot3name, o4.NAME ot4name,
n.NAME axlename, o.NAME antiexplosionname, b.email reportusername, c.`name` categoryname, d.`name` classname, e.NAME testname,
g.NAME areaname, h.NAME provincename, i.`name` cityname, j.NAME countyname, k.NAME enterprisetypename, l.`name` issapname,
a.* , f.*, m.*
FROM
( SELECT * FROM opri_inspection WHERE id = {id} ) a
LEFT JOIN mt_user b ON ( a.reportuserid = b.id )
LEFT JOIN opri_dmb c ON ( a.categorycode = c.`code` AND c.type = 'categorytype' )
LEFT JOIN opri_dmb d ON ( a.classcode = d.`code` AND d.type = 'classtype' )
LEFT JOIN opri_dmb e ON ( a.testcode = e.`code` AND e.type = 'testtype' )
LEFT JOIN opri_client f ON ( a.clientid = f.id )
LEFT JOIN opri_dmb g ON ( f.areacode = g.`code` AND g.type = 'areatype' )
LEFT JOIN sys_xtqyb h ON ( f.provincecode = h.`code` )
LEFT JOIN sys_xtqyb i ON ( f.citycode = i.`code` )
LEFT JOIN sys_xtqyb j ON ( f.countycode = j.`code` )
LEFT JOIN opri_dmb k ON ( f.enterprisetypecode = k.`code` AND k.type = 'enterprisetype' )
LEFT JOIN opri_dmb l ON ( f.issapcode = l.`code` AND l.type = 'issaptype' )
LEFT JOIN opri_product m ON ( a.productid = m.id )
LEFT JOIN opri_dmb n ON ( m.axlecode = n.`code` AND n.type = 'axletype' )
LEFT JOIN opri_dmb o ON ( m.antiexplosioncode = o.`code` AND o.type = 'antiexplosiontype' )
LEFT JOIN opri_dmb p1 ON ( a.pf1code = p1.`code` AND p1.type = 'pf1type' )
LEFT JOIN opri_dmb p2 ON ( a.pf2code = p2.`code` AND p2.type = 'pf2type' )
LEFT JOIN opri_dmb p3 ON ( a.pf3code = p3.`code` AND p3.type = 'pf3type' )
LEFT JOIN opri_dmb p4 ON ( a.pf4code = p4.`code` AND p4.type = 'pf4type' )
LEFT JOIN opri_dmb p5 ON ( a.pf5code = p5.`code` AND p5.type = 'pf5type' )
LEFT JOIN opri_dmb p6 ON ( a.pf6code = p6.`code` AND p6.type = 'pf6type' )
LEFT JOIN opri_dmb p7 ON ( a.pf7code = p7.`code` AND p7.type = 'pf7type' )
LEFT JOIN opri_dmb c1 ON ( a.cf1code = c1.`code` AND c1.type = 'cf1type' )
LEFT JOIN opri_dmb c2 ON ( a.cf2code = c2.`code` AND c2.type = 'cf2type' )
LEFT JOIN opri_dmb c3 ON ( a.cf3code = c3.`code` AND c3.type = 'cf3type' )
LEFT JOIN opri_dmb o1 ON ( a.ot1code = o1.`code` AND o1.type = 'ot1type' )
LEFT JOIN opri_dmb o2 ON ( a.ot2code = o2.`code` AND o2.type = 'ot2type' )
LEFT JOIN opri_dmb o3 ON ( a.ot3code = o3.`code` AND o3.type = 'ot3type' )
LEFT JOIN opri_dmb o4 ON ( a.ot4code = o4.`code` AND o4.type = 'ot4type' )");
DataTable dt_new = dt1.Clone();
foreach (DataRow rowInsert in dt1.Rows)
{
dt_new.Rows.Add(rowInsert.ItemArray);
}
dt_new.TableName = "dt1";
ds.Tables.Add(dt_new);
DataTable dt2 = client.Ado.GetDataTable(@$"select a.inspectionid,a.proposal,b.name sensorname,c.name sensorcablename,
d.name sensorconnectorname,e.name elec1name,f.name elec2name,g.name elec3name,
h.name elec4name,i.name elec5name,j.name elec6name
from (select * from opri_inspection_complete where inspectionid = {id}) a
left join opri_dmb b on (a.sensorcode = b.code and b.type = 'sensortype')
left join opri_dmb c on (a.sensorcablecode = c.code and c.type = 'sensorcabletype')
left join opri_dmb d on (a.sensorconnectorcode = d.code and d.type = 'sensorconnectortype')
left join opri_dmb e on (a.elec1code = e.code and e.type = 'elec1type')
left join opri_dmb f on (a.elec2code = f.code and f.type = 'elec2type')
left join opri_dmb g on (a.elec3code = g.code and g.type = 'elec3type')
left join opri_dmb h on (a.elec4code = h.code and h.type = 'elec4type')
left join opri_dmb i on (a.elec5code = i.code and i.type = 'elec5type')
left join opri_dmb j on (a.elec6code = j.code and j.type = 'elec6type')");
DataTable dt_new2 = dt2.Clone();
foreach (DataRow rowInsert in dt2.Rows)
{
dt_new2.Rows.Add(rowInsert.ItemArray);
}
dt_new2.TableName = "dt2";
ds.Tables.Add(dt_new2);
DataTable dt3 = client.Ado.GetDataTable(@$"select a.id id,a.remark,a.`group` group_tmp,b.name weightnumber,c.name loadnumber
from (select id,weightnumbercode,loadnumbercode,remark,`group` from opri_inspection_partialload where inspectionid = {id}) a
left join opri_dmb b on (a.weightnumbercode = b.code and b.type = 'weightnumbertype')
left join opri_dmb c on (a.loadnumbercode = c.code and c.type = 'loadnumbertype')");
if (dt3.Rows.Count > 0)
{
jPartial = JArray.Parse(dt3.Rows[0]["group_tmp"].ToString());
}
DataTable dt_new3 = dt3.Clone();
foreach (DataRow rowInsert in dt3.Rows)
{
dt_new3.Rows.Add(rowInsert.ItemArray);
}
dt_new3.TableName = "dt3";
ds.Tables.Add(dt_new3);
DataTable dt4 = client.Ado.GetDataTable(@$"select id, remark,`group` group_tmp from opri_inspection_linear where inspectionid = {id}");
DataTable dt4_1 = new DataTable();
dt4_1.Columns.Add("no", typeof(string));
dt4_1.Columns.Add("mainid", typeof(int));
dt4_1.Columns.Add("testpoint", typeof(string));
dt4_1.Columns.Add("nominalvalue", typeof(string));
dt4_1.Columns.Add("showvalue", typeof(string));
dt4_1.Columns.Add("showerror", typeof(string));
dt4_1.Columns.Add("maxerror", typeof(string));
dt4_1.Columns.Add("conformcode", typeof(string));
dt4_1.Columns.Add("conformname", typeof(string));
if (dt4.Rows.Count > 0)
{
JArray jTmp = JArray.Parse(dt4.Rows[0]["group_tmp"].ToString());
int idx = 0;
foreach (JToken item in jTmp)
{
idx++;
DataRow newRow = dt4_1.NewRow();
newRow["mainid"] = Convert.ToInt32(dt4.Rows[0]["id"]);
newRow["no"] = idx.ToString();
newRow["testpoint"] = item["testpoint"].ToString();
newRow["nominalvalue"] = item["nominalvalue"].ToString();
newRow["showvalue"] = item["showvalue"].ToString();
newRow["showerror"] = item["showerror"].ToString();
newRow["maxerror"] = item["maxerror"].ToString();
newRow["conformcode"] = item["conformcode"].ToString();
newRow["conformname"] = item["conformname"].ToString();
dt4_1.Rows.Add(newRow);
}
}
DataTable dt_new4 = dt4.Clone();
foreach (DataRow rowInsert in dt4.Rows)
{
dt_new4.Rows.Add(rowInsert.ItemArray);
}
DataTable dt_new4_1 = dt4_1.Clone();
foreach (DataRow rowInsert in dt4_1.Rows)
{
dt_new4_1.Rows.Add(rowInsert.ItemArray);
}
dt_new4.TableName = "dt4";
dt_new4_1.TableName = "dt4_1";
ds.Tables.Add(dt_new4_1);
ds.Tables.Add(dt_new4);
ds.Relations.Add(new DataRelation("group2", ds.Tables["dt4"].Columns["id"], ds.Tables["dt4_1"].Columns["mainid"]));
DataTable dt5 = client.Ado.GetDataTable(@$"select id, remark,`data` data_tmp from opri_inspection_repeat where inspectionid = {id}");
DataTable dt5_1 = new DataTable();
dt5_1.Columns.Add("no", typeof(string));
dt5_1.Columns.Add("mainid", typeof(int));
dt5_1.Columns.Add("timescode", typeof(string));
dt5_1.Columns.Add("timesname", typeof(string));
dt5_1.Columns.Add("repeatloadcode", typeof(string));
dt5_1.Columns.Add("repeatloadname", typeof(string));
dt5_1.Columns.Add("fillcode", typeof(string));
dt5_1.Columns.Add("fillname", typeof(string));
dt5_1.Columns.Add("weight", typeof(string));
dt5_1.Columns.Add("repeaterror", typeof(string));
dt5_1.Columns.Add("maxerror", typeof(string));
dt5_1.Columns.Add("conformcode", typeof(string));
dt5_1.Columns.Add("conformname", typeof(string));
DataTable dt5_1_1 = new DataTable();
dt5_1_1.Columns.Add("no", typeof(string));
dt5_1_1.Columns.Add("mainid", typeof(string));
dt5_1_1.Columns.Add("testreading", typeof(string));
if (dt5.Rows.Count > 0)
{
JArray jTmp = JArray.Parse(dt5.Rows[0]["data_tmp"].ToString());
int idx = 0;
foreach (JToken item in jTmp)
{
idx++;
DataRow newRow = dt5_1.NewRow();
newRow["mainid"] = Convert.ToInt32(dt5.Rows[0]["id"]);
newRow["no"] = "重复性测试组"+idx.ToString();
newRow["timescode"] = item["timescode"]?.ToString();
newRow["timesname"] = item["timesname"]?.ToString();
newRow["repeatloadcode"] = item["repeatloadcode"]?.ToString();
newRow["repeatloadname"] = item["repeatloadname"]?.ToString();
newRow["fillcode"] = item["fillcode"]?.ToString();
newRow["fillname"] = item["fillname"]?.ToString();
newRow["weight"] = item["weight"]?.ToString();
newRow["repeaterror"] = item["repeaterror"]?.ToString();
newRow["maxerror"] = item["maxerror"]?.ToString();
newRow["conformcode"] = item["conformcode"]?.ToString();
newRow["conformname"] = item["conformname"]?.ToString();
dt5_1.Rows.Add(newRow);
JArray groupArray = (JArray) item["group"];
int idx2 = 0;
foreach (JToken groupItem in groupArray)
{
idx2++;
newRow = dt5_1_1.NewRow();
newRow["mainid"] = "重复性测试组" + idx.ToString();
newRow["no"] = $"第{idx2}次";
newRow["testreading"] = groupItem["testreading"];
dt5_1_1.Rows.Add(newRow);
}
}
}
DataTable dt_new5 = dt5.Clone();
foreach (DataRow rowInsert in dt5.Rows)
{
dt_new5.Rows.Add(rowInsert.ItemArray);
}
DataTable dt_new5_1 = dt5_1.Clone();
foreach (DataRow rowInsert in dt5_1.Rows)
{
dt_new5_1.Rows.Add(rowInsert.ItemArray);
}
DataTable dt_new5_1_1 = dt5_1_1.Clone();
foreach (DataRow rowInsert in dt5_1_1.Rows)
{
dt_new5_1_1.Rows.Add(rowInsert.ItemArray);
}
dt_new5.TableName = "dt5";
dt_new5_1.TableName = "dt5_1";
dt_new5_1_1.TableName = "dt5_1_1";
ds.Tables.Add(dt_new5);
ds.Tables.Add(dt_new5_1);
ds.Tables.Add(dt_new5_1_1);
ds.Relations.Add(new DataRelation("data", ds.Tables["dt5"].Columns["id"], ds.Tables["dt5_1"].Columns["mainid"]));
ds.Relations.Add(new DataRelation("group", ds.Tables["dt5_1"].Columns["no"], ds.Tables["dt5_1_1"].Columns["mainid"]));
this.DataSource = ds;
}
}
}
{
"Database": {
"Host": "beta.360cbs.com",
"Port": "8100",
"Name": "mtmaster",
"Username": "root",
"Password": "mysql.beta.360cbs"
},
"RPC": {
"WebHost": "http://admin.evaluate.alpha.360cbs.com:9090"
},
"AppSetting": {
"Debug": true
}
}
{
"runtimeOptions": {
"configProperties": { "System.Drawing.EnableUnixSupport": true }
}
}
\ No newline at end of file
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "6.0.1",
"commands": [
"dotnet-ef"
]
}
}
}
\ No newline at end of file
using System;
using Zircon.Base.Exceptions;
namespace PdfExportOpri.Common
{
public class BaseException : HttpException
{
public void SetException(int code, string number, string message)
{
this.HttpCode = code;
this.Number = number;
this.ErrorMessage = message;
}
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Controllers;
using Zircon.Base.Exceptions;
namespace PdfExportOpri.Common
{
public class CommonClass
{
public static Dictionary<string, object> DataRowToDictioniary(DataRow row)
{
Dictionary<string, object> dic = new Dictionary<string, object>();
for (int i = 0; i < row.ItemArray.Length; i++)
{
dic.Add(row.Table.Columns[i].ColumnName, row[i]);
}
return dic;
}
public static string Md5(string content)
{
//MD5类是抽象类
MD5 md5 = MD5.Create();
//需要将字符串转成字节数组
byte[] buffer = Encoding.Default.GetBytes(content);
//加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择
byte[] md5buffer = md5.ComputeHash(buffer);
string str = null;
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
foreach (byte b in md5buffer)
{
//得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
//但是在和对方测试过程中,发现我这边的MD5加密编码,经常出现少一位或几位的问题;
//后来分析发现是 字符串格式符的问题, X 表示大写, x 表示小写,
//X2和x2表示不省略首位为0的十六进制数字;
str += b.ToString("x2");
}
return str;
}
public static string GetRequest(HttpContext context, string key, object defaultValue, bool isRequired = false)
{
var endpoint = context.Features.Get<IEndpointFeature>()?.Endpoint; ;
var methodInfo = context.GetEndpoint()?.Metadata.GetMetadata<ControllerActionDescriptor>().MethodInfo;
string method = context.Request.Method.ToUpper();
if (method == "POST" || method == "PUT" || method == "PATCH")
{
if (context.Request.HasFormContentType && context.Request.Form.ContainsKey(key)) return context.Request.Form[key].ToString();
}
else
{
if (context.Request.Query.ContainsKey(key)) return context.Request.Query[key].ToString();
}
if (isRequired) throw new ClientException();
return defaultValue.ToString();
}
}
}
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using PdfExportOpri.Common;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Net.Http.Headers;
using Zircon.Base.Exceptions;
namespace PdfExportOpri.Modules.PdfExport
{
[ApiController]
public class PdfExportApi : ControllerBase
{
private readonly ILogger<PdfExportApi> _logger;
private readonly IConfiguration _config;
public PdfExportApi(ILogger<PdfExportApi> logger, IConfiguration config)
{
_logger = logger;
_config = config;
}
[HttpGet]
[Route("/pdf/web/api/v1/export")]
public async Task<FileResult> Get()
{
string id = CommonClass.GetRequest(HttpContext, "id", "", true);
ProcessStartInfo info = new ProcessStartInfo(OperatingSystem.IsWindows()?AppDomain.CurrentDomain.BaseDirectory+"./PDFExportOpri-CLI.exe": AppDomain.CurrentDomain.BaseDirectory + "./PDFExportOpri-CLI");
info.Arguments = $"{AppDomain.CurrentDomain.BaseDirectory}./output/ {id}";
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
Process p = new Process();
p.StartInfo = info;
p.Start();
await p.WaitForExitAsync();
if (p.ExitCode != 0)
throw new HttpException(){ErrorMessage =
p.StandardOutput.ReadToEnd(),
HttpCode = 500,
Number = "500.1"
};
Response.Headers.Add("Content-Disposition", "filename=export.pdf");
using (FileStream fsRead = new FileStream(AppDomain.CurrentDomain.BaseDirectory + $"./output/export_{id}.pdf", FileMode.Open))
{
int fsLen = (int)fsRead.Length;
byte[] heByte = new byte[fsLen];
int r = fsRead.Read(heByte, 0, heByte.Length);
Stream stream = new MemoryStream(heByte);
fsRead.Close();
System.IO.File.Delete(AppDomain.CurrentDomain.BaseDirectory + $"./output/export_{id}.pdf");
return new FileStreamResult(stream, "application/octet-stream");
}
// return new PhysicalFileResult(AppDomain.CurrentDomain.BaseDirectory + $"./output/export_{id}.pdf", "application/octet-stream");
}
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Sapphire.Core.Utils" Version="1.0.5" />
</ItemGroup>
<ItemGroup>
<Reference Include="Zircon.Base">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Base.dll</HintPath>
</Reference>
<Reference Include="Zircon.Log">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Log.dll</HintPath>
</Reference>
<Reference Include="Zircon.Log.File">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Log.File.dll</HintPath>
</Reference>
<Reference Include="Zircon.Request">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Request.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Modules\PdfExportAPI\" />
<Folder Include="Common\" />
</ItemGroup>
</Project>
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PdfExportOpri
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, builder) =>
{
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Rewrite;
using Zircon.Base.Middlewares;
using Zircon.Request.Middlewares;
namespace PdfExportOpri
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors((cors) =>
{
cors.AddPolicy("AllowAll",
builder =>
{
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCors("AllowAll");
app.UseStaticFiles();
app.UseRewriter(new RewriteOptions()
.Add(context =>
{
if (context.HttpContext.Request.Path.Value.StartsWith("//"))
{
context.HttpContext.Request.Path = context.HttpContext.Request.Path.Value.Substring(1);
}
})
);
app.UseRouting();
app.UseExceptionMiddleware();
app.UseRequestLogMiddleware();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
{
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://0.0.0.0:5000"
}
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Database": {
"Host": "beta.360cbs.com",
"Port": "8100",
"Name": "mtmaster",
"Username": "root",
"Password": "mysql.beta.360cbs"
},
"AppSetting": {
"Debug": true
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!