/// <summary> /// 输出应答数据的结果 /// </summary> /// <param name="lpFastMsg">应答数据包</param> /// <param name="savePath">文件保存路径</param> public static unsafe void OutPutResult(LDFastMessageAdapter lpFastMsg, string savePath) { StringBuilder outPutInfo = new StringBuilder(); outPutInfo.Append("\r\n**************************************************************"); try { if (lpFastMsg.Record != null) { int errorNo = lpFastMsg.GetInt32(LDBizTag.LDBIZ_ERROR_NO_INT); if (errorNo != 0) { return; } //打印包头信息 LDRecordAdapter headRecord = lpFastMsg.GetHeadRecord(); if (headRecord.Record != null) { string tempHeadRecord = ShowRecord(headRecord); outPutInfo.Append(tempHeadRecord); } //打印包体信息 LDGroupAdapter lpGroup = lpFastMsg.GetGroup(1000); if (lpGroup.ld == null) //非结果集 { LDRecordAdapter record = lpFastMsg.GetBizBodyRecord(); if (record.Record != null) { string tempInfo = ShowRecord(record); outPutInfo.Append(tempInfo); } } else //结果集 { int recordCount = lpGroup.GetRecordCount(); outPutInfo.AppendLine($"\r\nrow_count : {recordCount}"); for (int i = 0; i < recordCount; i++) { LDRecordAdapter record = lpGroup.GetRecord(i); if (record.Record != null) { string tempInfo = ShowRecord(record); outPutInfo.Append(tempInfo); } } } CSVFileHelper.AppendSaveScript(savePath, outPutInfo.ToString()); } } catch (Exception error) { outPutInfo.Append($"{error.Message}\r\n{error.StackTrace}"); CSVFileHelper.AppendSaveScript(savePath, outPutInfo.ToString()); } }