123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <title>DLL问题诊断工具</title>
- <style>
- body { font-family: Arial, sans-serif; margin: 20px; }
- .test-btn { padding: 10px 20px; margin: 10px; font-size: 16px; background: #dc3545; color: white; border: none; border-radius: 5px; }
- .test-btn:hover { background: #c82333; }
- .result { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
- .success { background: #d4edda; border-color: #c3e6cb; }
- .error { background: #f8d7da; border-color: #f5c6cb; }
- .warning { background: #fff3cd; border-color: #ffeaa7; }
- pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; }
- </style>
- </head>
- <body>
- <h1>🔧 DLL问题专项诊断</h1>
- <p>基于前面的测试,我们已经确认问题出现在DLL调用阶段。</p>
-
- <div class="result warning">
- <h3>📋 已确认的信息</h3>
- <ul>
- <li>✅ HTTP通信正常</li>
- <li>✅ C#基础代码正常</li>
- <li>✅ JSON序列化正常</li>
- <li>❌ DLL调用导致连接中断</li>
- </ul>
- </div>
-
- <h2>🚨 危险测试(可能导致进程崩溃)</h2>
- <button class="test-btn" onclick="testDllCall()">测试DLL调用(带增强保护)</button>
- <button class="test-btn" onclick="clearResults()">清空结果</button>
-
- <div id="results"></div>
- <script>
- const API_URL = 'http://localhost:8321/api/entry/workinjury';
-
- function clearResults() {
- document.getElementById('results').innerHTML = '';
- }
-
- function showResult(title, status, data, time) {
- const resultsDiv = document.getElementById('results');
- const resultDiv = document.createElement('div');
- resultDiv.className = `result ${status === 200 ? 'success' : 'error'}`;
-
- resultDiv.innerHTML = `
- <h3>${title}</h3>
- <p><strong>HTTP状态:</strong> ${status}</p>
- <p><strong>时间:</strong> ${time}</p>
- <p><strong>响应数据:</strong></p>
- <pre>${JSON.stringify(data, null, 2)}</pre>
- `;
-
- resultsDiv.appendChild(resultDiv);
- }
-
- async function makeRequest(title, requestData) {
- const startTime = new Date();
-
- try {
- console.log(`发送请求: ${title}`, requestData);
-
- // 设置较短的超时时间,避免长时间等待
- const controller = new AbortController();
- const timeoutId = setTimeout(() => controller.abort(), 10000); // 10秒超时
-
- const response = await fetch(API_URL, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(requestData),
- signal: controller.signal
- });
-
- clearTimeout(timeoutId);
- const endTime = new Date();
- const duration = endTime - startTime;
-
- console.log(`收到响应: ${response.status}`, response);
-
- let responseData = null;
- const contentType = response.headers.get('content-type');
-
- if (contentType && contentType.includes('application/json')) {
- try {
- responseData = await response.json();
- console.log('解析JSON成功:', responseData);
- } catch (jsonError) {
- responseData = {
- error: 'JSON解析失败',
- details: jsonError.message,
- contentType: contentType
- };
- console.error('JSON解析失败:', jsonError);
- }
- } else {
- const text = await response.text();
- responseData = {
- error: '非JSON响应',
- contentType: contentType,
- text: text
- };
- console.log('非JSON响应:', text);
- }
-
- showResult(title, response.status, responseData, `${duration}ms`);
-
- // 分析DLL相关的错误信息
- if (responseData && responseData.debug_init_step) {
- showResult('🔍 DLL调用分析', 'INFO', {
- 最后执行步骤: responseData.debug_init_step,
- DLL路径: responseData.debug_dll_path,
- DLL大小: responseData.debug_dll_size,
- 调用时间: responseData.debug_si_init_call_time,
- 完成时间: responseData.debug_si_init_return_time,
- 调用耗时: responseData.debug_si_init_duration,
- 分析: getDllAnalysis(responseData)
- }, '');
- }
-
- } catch (networkError) {
- const endTime = new Date();
- const duration = endTime - startTime;
-
- console.error('网络错误:', networkError);
-
- let errorType = '未知错误';
- let suggestion = '';
-
- if (networkError.name === 'AbortError') {
- errorType = '请求超时(10秒)';
- suggestion = 'DLL调用可能导致进程阻塞或崩溃';
- } else if (networkError.message.includes('fetch')) {
- errorType = '连接中断';
- suggestion = 'DLL调用可能导致ThCardReader.exe进程崩溃';
- }
-
- showResult(`❌ ${title} - ${errorType}`, 'ERROR', {
- error: networkError.message,
- type: networkError.name,
- duration: `${duration}ms`,
- suggestion: suggestion,
- '可能原因': [
- 'JSSiInterface.dll版本不兼容',
- 'DLL依赖库缺失',
- 'DLL内存访问冲突',
- 'DLL需要特定的运行环境'
- ]
- }, `${duration}ms`);
- }
- }
-
- function getDllAnalysis(responseData) {
- if (responseData.debug_init_step === 'Si_INIT调用完成') {
- return 'DLL调用成功完成';
- } else if (responseData.debug_init_step === '即将调用Si_INIT - 这里可能发生异常') {
- return 'DLL调用时发生异常,进程可能崩溃';
- } else if (responseData.debug_init_step.includes('DLL文件')) {
- return 'DLL文件相关问题';
- } else {
- return '未知状态';
- }
- }
-
- function testDllCall() {
- showResult('⚠️ 警告', 'WARNING', {
- 说明: '即将测试DLL调用,这可能导致ThCardReader.exe进程崩溃',
- 建议: '如果进程崩溃,请重启ThCardReader.exe后继续测试',
- '预期行为': '如果看到请求超时或连接中断,说明DLL调用有问题'
- }, '');
-
- setTimeout(() => {
- makeRequest('DLL调用测试(增强保护)', {
- action: 'init',
- config: {
- fixmedinsCode: 'SQ201348',
- fixmedinsName: '沭阳铭和医院',
- interfaceVersion: 'V2.1'
- }
- });
- }, 2000); // 2秒后执行,给用户时间看到警告
- }
-
- // 页面加载完成后的说明
- document.addEventListener('DOMContentLoaded', function() {
- showResult('📋 DLL问题诊断说明', 'INFO', {
- '问题确认': '前面的测试已经确认问题出现在DLL调用阶段',
- '当前状态': 'HTTP通信正常,C#基础代码正常',
- '问题位置': 'JiangSuWorkInjuryBusiness.Initialize() 中的 Si_INIT() 调用',
- '预期结果': '点击测试按钮后,如果出现超时或连接中断,确认是DLL问题',
- '解决方向': [
- '检查JSSiInterface.dll是否完整',
- '检查DLL依赖项(如VC++运行库)',
- '尝试在其他环境测试DLL',
- '联系DLL提供方获取支持'
- ]
- }, '');
- });
- </script>
- </body>
- </html>
|