private static void ExportPDF(string pdfFilePath, THistoryDataBasic hisInfo, string testSerial, DeviceConfig dconfig) { var detailData = QueryTestHisDetail(testSerial); using (Stream fs = new FileStream(pdfFilePath, FileMode.Create)) { PDFOperation pdf = new PDFOperation(); pdf.Open(fs); pdf.SetBaseFont(@"C:\Windows\Fonts\SIMHEI.TTF"); //pdf.AddParagraph(sb.ToString(), 15, 1, 20, 0, 0); if (dconfig.TestReportTitle == "") { dconfig.TestReportTitle = "线束测试报告"; } pdf.AddParagraph($"{dconfig.TestReportTitle}\r\n", 20); pdf.AddLine(71); pdf.AddParagraph($"线束名称:{hisInfo.TestCableName} 测试结果:{CalFinalTestResult(hisInfo.ProjectName, hisInfo.TestCableName, testSerial)}", 15); pdf.AddParagraph($"测试温度:{hisInfo.EnvironmentTemperature}℃ 环境湿度:{hisInfo.EnvironmentAmbientHumidity}%RH 测试人员:{hisInfo.TestOperator}\r\n", 15); pdf.AddParagraph($"测试日期:{hisInfo.TestStartDate} - {hisInfo.TestEndDate}\r\n", 15); pdf.AddLine(144); pdf.AddParagraph($"测试参数\r\n", 20); pdf.AddLine(171); pdf.AddParagraph($"导通测试阈值:{hisInfo.ConductThreshold}Ω 短路测试阈值:{hisInfo.ShortCircuitThreshold}Ω", 15); pdf.AddParagraph($"绝缘测试阈值:{hisInfo.InsulateThreshold}MΩ 绝缘保持时间:{hisInfo.InsulateHoldTime}S", 15); pdf.AddParagraph($"绝缘电压:{hisInfo.InsulateVoltage}V", 15); pdf.AddLine(241); pdf.AddParagraph($"异常明细\r\n\n", 20); var exceptData = QueryCableTestExceptTable(detailData); pdf.AddParagraph("线束测试异常明细", exceptData, 15); if (exceptData.Rows.Count <= 0) { pdf.AddParagraph($"无\r\n\n", 20); } //pdf.AddParagraph("\r\n", 15); pdf.AddParagraph("测试数据\r\n\r", 20); var normalData = QueryCableTestPassTable(detailData); if (normalData.Rows.Count > 0) { pdf.AddParagraph("线束测试合格明细", normalData, 15); } else { pdf.AddParagraph($"无\r\n\n", 20); } pdf.Close(); } }
public static THistoryDataBasic QueryProTestHisBasicInfo(string testSerial) { THistoryDataBasic hisBasicInfo = new THistoryDataBasic(); if (testSerial == "") { return(hisBasicInfo); } THistoryDataBasicManager infoManager = new THistoryDataBasicManager(); var dt = infoManager.GetDataSetByWhere($"where TestSerialNumber='{testSerial}'").Tables[0]; if (dt.Rows.Count <= 0) { return(hisBasicInfo); } foreach (DataRow dr in dt.Rows) { hisBasicInfo.TestSerialNumber = testSerial; hisBasicInfo.ProjectName = dr["ProjectName"].ToString(); hisBasicInfo.TestCableName = dr["TestCableName"].ToString(); hisBasicInfo.TestStartDate = dr["TestStartDate"].ToString(); hisBasicInfo.TestEndDate = dr["TestEndDate"].ToString(); hisBasicInfo.TestOperator = dr["TestOperator"].ToString(); hisBasicInfo.EnvironmentTemperature = dr["EnvironmentTemperature"].ToString(); hisBasicInfo.EnvironmentAmbientHumidity = dr["EnvironmentAmbientHumidity"].ToString(); hisBasicInfo.FinalTestResult = dr["FinalTestResult"].ToString(); hisBasicInfo.ConductTestResult = dr["ConductTestResult"].ToString(); hisBasicInfo.ConductThreshold = double.Parse(dr["ConductThreshold"].ToString()); hisBasicInfo.ShortCircuitTestResult = dr["ShortCircuitTestResult"].ToString(); hisBasicInfo.ShortCircuitThreshold = double.Parse(dr["ShortCircuitThreshold"].ToString()); hisBasicInfo.InsulateTestResult = dr["InsulateTestResult"].ToString(); hisBasicInfo.InsulateThreshold = double.Parse(dr["InsulateThreshold"].ToString()); hisBasicInfo.InsulateVoltage = double.Parse(dr["InsulateVoltage"].ToString()); hisBasicInfo.InsulateHoldTime = double.Parse(dr["InsulateHoldTime"].ToString()); hisBasicInfo.VoltageWithStandardTestResult = dr["VoltageWithStandardTestResult"].ToString(); hisBasicInfo.VoltageWithStandardThreshold = double.Parse(dr["VoltageWithStandardThreshold"].ToString()); hisBasicInfo.ConductTestExceptCount = int.Parse(dr["ConductTestExceptCount"].ToString()); hisBasicInfo.ShortcircuitTestExceptCount = int.Parse(dr["ShortcircuitTestExceptCount"].ToString()); hisBasicInfo.InsulateTestExceptCount = int.Parse(dr["InsulateTestExceptCount"].ToString()); hisBasicInfo.VoltageWithStandardTestExceptCount = int.Parse(dr["VoltageWithStandardTestExceptCount"].ToString()); } return(hisBasicInfo); }