去掉了测试按钮,修改了环境检测按钮的位置
This commit is contained in:
parent
dd62a6dce4
commit
f32c367fd0
@ -2317,69 +2317,6 @@ namespace NavisworksTransport
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 简化的环境诊断方法 - 快速检查API是否可用
|
||||
/// </summary>
|
||||
/// <returns>诊断报告</returns>
|
||||
public string DiagnoseEnvironment()
|
||||
{
|
||||
var report = new System.Text.StringBuilder();
|
||||
report.AppendLine("=== Navisworks API环境诊断报告 ===");
|
||||
|
||||
try
|
||||
{
|
||||
// 1. 线程状态
|
||||
var apartmentState = System.Threading.Thread.CurrentThread.GetApartmentState();
|
||||
report.AppendLine($"线程状态: {apartmentState} {(apartmentState == System.Threading.ApartmentState.STA ? "✓" : "✗")}");
|
||||
|
||||
// 2. API可用性
|
||||
try
|
||||
{
|
||||
var app = NavisApplication.ActiveDocument;
|
||||
report.AppendLine("API可用性: 可用 ✓");
|
||||
}
|
||||
catch (Exception apiEx)
|
||||
{
|
||||
report.AppendLine($"API可用性: 异常 - {apiEx.Message} ✗");
|
||||
}
|
||||
|
||||
// 3. 文档状态
|
||||
try
|
||||
{
|
||||
var document = NavisApplication.ActiveDocument;
|
||||
if (document != null)
|
||||
{
|
||||
report.AppendLine($"活动文档: {document.FileName ?? "未命名"} ✓");
|
||||
report.AppendLine($"模型数量: {document.Models?.Count ?? 0}");
|
||||
}
|
||||
else
|
||||
{
|
||||
report.AppendLine("活动文档: 无 ✗");
|
||||
}
|
||||
}
|
||||
catch (Exception docEx)
|
||||
{
|
||||
report.AppendLine($"活动文档: 异常 - {docEx.Message} ✗");
|
||||
}
|
||||
|
||||
// 4. 内存状态
|
||||
long memoryMB = GC.GetTotalMemory(false) / 1024 / 1024;
|
||||
report.AppendLine($"当前内存: {memoryMB} MB");
|
||||
|
||||
report.AppendLine("=== 诊断完成 ===");
|
||||
|
||||
string result = report.ToString();
|
||||
LogManager.Info($"[SimplifiedModelSplitter] 环境诊断报告:\n{result}");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string error = $"诊断过程出错: {ex.Message}";
|
||||
report.AppendLine(error);
|
||||
LogManager.Error($"[SimplifiedModelSplitter] {error}");
|
||||
return report.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试导出功能:导出少量模型项以验证基础功能
|
||||
|
||||
@ -2122,7 +2122,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 2. 纯业务逻辑执行(后台线程)
|
||||
string diagnosticReport = await Task.Run(() =>
|
||||
{
|
||||
return _modelSplitterManager.DiagnoseEnvironment();
|
||||
return CreateDiagnosticReport();
|
||||
});
|
||||
|
||||
// 3. 结果UI更新
|
||||
@ -2160,6 +2160,70 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建环境诊断报告
|
||||
/// </summary>
|
||||
/// <returns>诊断报告</returns>
|
||||
private string CreateDiagnosticReport()
|
||||
{
|
||||
var report = new System.Text.StringBuilder();
|
||||
report.AppendLine("=== Navisworks API环境诊断报告 ===");
|
||||
|
||||
try
|
||||
{
|
||||
// 1. 线程状态
|
||||
var apartmentState = System.Threading.Thread.CurrentThread.GetApartmentState();
|
||||
report.AppendLine($"线程状态: {apartmentState} {(apartmentState == System.Threading.ApartmentState.STA ? "✓" : "✗")}");
|
||||
|
||||
// 2. API可用性
|
||||
try
|
||||
{
|
||||
var app = Autodesk.Navisworks.Api.Application.ActiveDocument;
|
||||
report.AppendLine("API可用性: 可用 ✓");
|
||||
}
|
||||
catch (Exception apiEx)
|
||||
{
|
||||
report.AppendLine($"API可用性: 异常 - {apiEx.Message} ✗");
|
||||
}
|
||||
|
||||
// 3. 文档状态
|
||||
try
|
||||
{
|
||||
var document = Autodesk.Navisworks.Api.Application.ActiveDocument;
|
||||
if (document != null)
|
||||
{
|
||||
report.AppendLine($"活动文档: {document.FileName ?? "未命名"} ✓");
|
||||
report.AppendLine($"模型数量: {document.Models?.Count ?? 0}");
|
||||
}
|
||||
else
|
||||
{
|
||||
report.AppendLine("活动文档: 无 ✗");
|
||||
}
|
||||
}
|
||||
catch (Exception docEx)
|
||||
{
|
||||
report.AppendLine($"活动文档: 异常 - {docEx.Message} ✗");
|
||||
}
|
||||
|
||||
// 4. 内存状态
|
||||
long memoryMB = GC.GetTotalMemory(false) / 1024 / 1024;
|
||||
report.AppendLine($"当前内存: {memoryMB} MB");
|
||||
|
||||
report.AppendLine("=== 诊断完成 ===");
|
||||
|
||||
string result = report.ToString();
|
||||
LogManager.Info($"[LayerManagement] 环境诊断报告:\n{result}");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string error = $"诊断过程出错: {ex.Message}";
|
||||
report.AppendLine(error);
|
||||
LogManager.Error($"[LayerManagement] {error}");
|
||||
return report.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示环境诊断结果对话框
|
||||
/// </summary>
|
||||
|
||||
@ -224,6 +224,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
public ICommand ImportConfigCommand { get; private set; }
|
||||
public ICommand CheckUpdateCommand { get; private set; }
|
||||
public ICommand GeneratePerformanceReportCommand { get; private set; }
|
||||
public ICommand DiagnosticCommand { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@ -284,6 +285,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
ImportConfigCommand = new RelayCommand(() => ExecuteImportConfig());
|
||||
CheckUpdateCommand = new RelayCommand(() => ExecuteCheckUpdate());
|
||||
GeneratePerformanceReportCommand = new RelayCommand(() => ExecuteGeneratePerformanceReport());
|
||||
DiagnosticCommand = new RelayCommand(() => ExecuteDiagnostic());
|
||||
|
||||
LogManager.Info("系统管理命令初始化完成");
|
||||
}
|
||||
@ -752,6 +754,110 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}, "生成性能报告");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行环境诊断
|
||||
/// </summary>
|
||||
private void ExecuteDiagnostic()
|
||||
{
|
||||
SafeExecute(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
LogManager.Info("开始环境诊断");
|
||||
|
||||
// 直接调用本地的环境诊断方法
|
||||
string diagnosticReport = DiagnoseEnvironment();
|
||||
|
||||
// 显示诊断结果对话框
|
||||
System.Windows.MessageBox.Show(
|
||||
diagnosticReport,
|
||||
"环境诊断结果",
|
||||
System.Windows.MessageBoxButton.OK,
|
||||
System.Windows.MessageBoxImage.Information);
|
||||
|
||||
LogManager.Info("环境诊断完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"环境诊断失败: {ex.Message}", ex);
|
||||
System.Windows.MessageBox.Show(
|
||||
$"环境诊断失败: {ex.Message}",
|
||||
"错误",
|
||||
System.Windows.MessageBoxButton.OK,
|
||||
System.Windows.MessageBoxImage.Error);
|
||||
}
|
||||
}, "环境诊断");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 环境诊断方法 - 快速检查API是否可用
|
||||
/// </summary>
|
||||
/// <returns>诊断报告</returns>
|
||||
private string DiagnoseEnvironment()
|
||||
{
|
||||
var report = new System.Text.StringBuilder();
|
||||
report.AppendLine("=== Navisworks API环境诊断报告 ===");
|
||||
|
||||
try
|
||||
{
|
||||
// 1. 线程状态
|
||||
var apartmentState = System.Threading.Thread.CurrentThread.GetApartmentState();
|
||||
report.AppendLine($"线程状态: {apartmentState} {(apartmentState == System.Threading.ApartmentState.STA ? "✓" : "✗")}");
|
||||
|
||||
// 2. API可用性
|
||||
try
|
||||
{
|
||||
var app = Autodesk.Navisworks.Api.Application.ActiveDocument;
|
||||
report.AppendLine("API可用性: 可用 ✓");
|
||||
}
|
||||
catch (Exception apiEx)
|
||||
{
|
||||
report.AppendLine($"API可用性: 异常 - {apiEx.Message} ✗");
|
||||
}
|
||||
|
||||
// 3. 文档状态
|
||||
try
|
||||
{
|
||||
var document = Autodesk.Navisworks.Api.Application.ActiveDocument;
|
||||
if (document != null)
|
||||
{
|
||||
report.AppendLine($"活动文档: {document.FileName ?? "未命名"} ✓");
|
||||
report.AppendLine($"模型数量: {document.Models?.Count ?? 0}");
|
||||
}
|
||||
else
|
||||
{
|
||||
report.AppendLine("活动文档: 无 ✗");
|
||||
}
|
||||
}
|
||||
catch (Exception docEx)
|
||||
{
|
||||
report.AppendLine($"活动文档: 异常 - {docEx.Message} ✗");
|
||||
}
|
||||
|
||||
// 4. 内存状态
|
||||
long memoryMB = GC.GetTotalMemory(false) / 1024 / 1024;
|
||||
report.AppendLine($"当前内存: {memoryMB} MB");
|
||||
|
||||
// 5. 系统信息
|
||||
report.AppendLine($"插件版本: {PluginVersion}");
|
||||
report.AppendLine($"Navisworks版本: {NavisworksVersion}");
|
||||
report.AppendLine($"系统状态: {SystemStatus}");
|
||||
|
||||
report.AppendLine("=== 诊断完成 ===");
|
||||
|
||||
string result = report.ToString();
|
||||
LogManager.Info($"[SystemManagement] 环境诊断报告:\n{result}");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string error = $"诊断过程出错: {ex.Message}";
|
||||
report.AppendLine(error);
|
||||
LogManager.Error($"[SystemManagement] {error}");
|
||||
return report.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 辅助方法
|
||||
|
||||
@ -332,16 +332,6 @@ NavisworksTransport 分层管理页签视图 - 重构优化版本
|
||||
Style="{StaticResource ActionButtonStyle}"
|
||||
Command="{Binding SaveSelectedItemsCommand}"
|
||||
IsEnabled="{Binding HasSelectedItems}"/>
|
||||
<Button Content="环境检查"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding DiagnosticCommand}"
|
||||
ToolTip="检查Navisworks API环境和线程状态"
|
||||
Background="#FFFFD700"/>
|
||||
<Button Content="复杂导出测试"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding TestExportToNwdCommand}"
|
||||
ToolTip="测试复杂导出:选择二级节点+隐藏其他+ExportToNwd"
|
||||
Background="#FFDDAAFF"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@ -215,6 +215,10 @@ NavisworksTransport 系统管理页签视图 - 采用与其他页签一致的Nav
|
||||
<Button Content="生成性能报告"
|
||||
Command="{Binding GeneratePerformanceReportCommand}"
|
||||
Style="{StaticResource ActionButtonStyle}"/>
|
||||
<Button Content="环境检查"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding DiagnosticCommand}"
|
||||
ToolTip="检查Navisworks API环境和线程状态"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user