dll_test.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>DLL问题诊断工具</title>
  6. <style>
  7. body { font-family: Arial, sans-serif; margin: 20px; }
  8. .test-btn { padding: 10px 20px; margin: 10px; font-size: 16px; background: #dc3545; color: white; border: none; border-radius: 5px; }
  9. .test-btn:hover { background: #c82333; }
  10. .result { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
  11. .success { background: #d4edda; border-color: #c3e6cb; }
  12. .error { background: #f8d7da; border-color: #f5c6cb; }
  13. .warning { background: #fff3cd; border-color: #ffeaa7; }
  14. pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; }
  15. </style>
  16. </head>
  17. <body>
  18. <h1>🔧 DLL问题专项诊断</h1>
  19. <p>基于前面的测试,我们已经确认问题出现在DLL调用阶段。</p>
  20. <div class="result warning">
  21. <h3>📋 已确认的信息</h3>
  22. <ul>
  23. <li>✅ HTTP通信正常</li>
  24. <li>✅ C#基础代码正常</li>
  25. <li>✅ JSON序列化正常</li>
  26. <li>❌ DLL调用导致连接中断</li>
  27. </ul>
  28. </div>
  29. <h2>🚨 危险测试(可能导致进程崩溃)</h2>
  30. <button class="test-btn" onclick="testDllCall()">测试DLL调用(带增强保护)</button>
  31. <button class="test-btn" onclick="clearResults()">清空结果</button>
  32. <div id="results"></div>
  33. <script>
  34. const API_URL = 'http://localhost:8321/api/entry/workinjury';
  35. function clearResults() {
  36. document.getElementById('results').innerHTML = '';
  37. }
  38. function showResult(title, status, data, time) {
  39. const resultsDiv = document.getElementById('results');
  40. const resultDiv = document.createElement('div');
  41. resultDiv.className = `result ${status === 200 ? 'success' : 'error'}`;
  42. resultDiv.innerHTML = `
  43. <h3>${title}</h3>
  44. <p><strong>HTTP状态:</strong> ${status}</p>
  45. <p><strong>时间:</strong> ${time}</p>
  46. <p><strong>响应数据:</strong></p>
  47. <pre>${JSON.stringify(data, null, 2)}</pre>
  48. `;
  49. resultsDiv.appendChild(resultDiv);
  50. }
  51. async function makeRequest(title, requestData) {
  52. const startTime = new Date();
  53. try {
  54. console.log(`发送请求: ${title}`, requestData);
  55. // 设置较短的超时时间,避免长时间等待
  56. const controller = new AbortController();
  57. const timeoutId = setTimeout(() => controller.abort(), 10000); // 10秒超时
  58. const response = await fetch(API_URL, {
  59. method: 'POST',
  60. headers: {
  61. 'Content-Type': 'application/json',
  62. },
  63. body: JSON.stringify(requestData),
  64. signal: controller.signal
  65. });
  66. clearTimeout(timeoutId);
  67. const endTime = new Date();
  68. const duration = endTime - startTime;
  69. console.log(`收到响应: ${response.status}`, response);
  70. let responseData = null;
  71. const contentType = response.headers.get('content-type');
  72. if (contentType && contentType.includes('application/json')) {
  73. try {
  74. responseData = await response.json();
  75. console.log('解析JSON成功:', responseData);
  76. } catch (jsonError) {
  77. responseData = {
  78. error: 'JSON解析失败',
  79. details: jsonError.message,
  80. contentType: contentType
  81. };
  82. console.error('JSON解析失败:', jsonError);
  83. }
  84. } else {
  85. const text = await response.text();
  86. responseData = {
  87. error: '非JSON响应',
  88. contentType: contentType,
  89. text: text
  90. };
  91. console.log('非JSON响应:', text);
  92. }
  93. showResult(title, response.status, responseData, `${duration}ms`);
  94. // 分析DLL相关的错误信息
  95. if (responseData && responseData.debug_init_step) {
  96. showResult('🔍 DLL调用分析', 'INFO', {
  97. 最后执行步骤: responseData.debug_init_step,
  98. DLL路径: responseData.debug_dll_path,
  99. DLL大小: responseData.debug_dll_size,
  100. 调用时间: responseData.debug_si_init_call_time,
  101. 完成时间: responseData.debug_si_init_return_time,
  102. 调用耗时: responseData.debug_si_init_duration,
  103. 分析: getDllAnalysis(responseData)
  104. }, '');
  105. }
  106. } catch (networkError) {
  107. const endTime = new Date();
  108. const duration = endTime - startTime;
  109. console.error('网络错误:', networkError);
  110. let errorType = '未知错误';
  111. let suggestion = '';
  112. if (networkError.name === 'AbortError') {
  113. errorType = '请求超时(10秒)';
  114. suggestion = 'DLL调用可能导致进程阻塞或崩溃';
  115. } else if (networkError.message.includes('fetch')) {
  116. errorType = '连接中断';
  117. suggestion = 'DLL调用可能导致ThCardReader.exe进程崩溃';
  118. }
  119. showResult(`❌ ${title} - ${errorType}`, 'ERROR', {
  120. error: networkError.message,
  121. type: networkError.name,
  122. duration: `${duration}ms`,
  123. suggestion: suggestion,
  124. '可能原因': [
  125. 'JSSiInterface.dll版本不兼容',
  126. 'DLL依赖库缺失',
  127. 'DLL内存访问冲突',
  128. 'DLL需要特定的运行环境'
  129. ]
  130. }, `${duration}ms`);
  131. }
  132. }
  133. function getDllAnalysis(responseData) {
  134. if (responseData.debug_init_step === 'Si_INIT调用完成') {
  135. return 'DLL调用成功完成';
  136. } else if (responseData.debug_init_step === '即将调用Si_INIT - 这里可能发生异常') {
  137. return 'DLL调用时发生异常,进程可能崩溃';
  138. } else if (responseData.debug_init_step.includes('DLL文件')) {
  139. return 'DLL文件相关问题';
  140. } else {
  141. return '未知状态';
  142. }
  143. }
  144. function testDllCall() {
  145. showResult('⚠️ 警告', 'WARNING', {
  146. 说明: '即将测试DLL调用,这可能导致ThCardReader.exe进程崩溃',
  147. 建议: '如果进程崩溃,请重启ThCardReader.exe后继续测试',
  148. '预期行为': '如果看到请求超时或连接中断,说明DLL调用有问题'
  149. }, '');
  150. setTimeout(() => {
  151. makeRequest('DLL调用测试(增强保护)', {
  152. action: 'init',
  153. config: {
  154. fixmedinsCode: 'SQ201348',
  155. fixmedinsName: '沭阳铭和医院',
  156. interfaceVersion: 'V2.1'
  157. }
  158. });
  159. }, 2000); // 2秒后执行,给用户时间看到警告
  160. }
  161. // 页面加载完成后的说明
  162. document.addEventListener('DOMContentLoaded', function() {
  163. showResult('📋 DLL问题诊断说明', 'INFO', {
  164. '问题确认': '前面的测试已经确认问题出现在DLL调用阶段',
  165. '当前状态': 'HTTP通信正常,C#基础代码正常',
  166. '问题位置': 'JiangSuWorkInjuryBusiness.Initialize() 中的 Si_INIT() 调用',
  167. '预期结果': '点击测试按钮后,如果出现超时或连接中断,确认是DLL问题',
  168. '解决方向': [
  169. '检查JSSiInterface.dll是否完整',
  170. '检查DLL依赖项(如VC++运行库)',
  171. '尝试在其他环境测试DLL',
  172. '联系DLL提供方获取支持'
  173. ]
  174. }, '');
  175. });
  176. </script>
  177. </body>
  178. </html>