feat: restore two-step legacy launcher workflow
This commit is contained in:
@@ -1,47 +1,56 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Launcher.Next.Application;
|
||||
using Launcher.Next.Autodesk;
|
||||
|
||||
namespace Launcher.Next.App;
|
||||
|
||||
public partial class MainWindow : System.Windows.Window
|
||||
{
|
||||
private readonly LegacyConfigurationAdapter adapter=new();
|
||||
private sealed record LauncherProduct(string Id,string Name,string? Executable,string Diagnostic);
|
||||
private readonly LocalParityLaunchProfile? localProfile;
|
||||
private readonly LocalParityLaunchService localService=new();
|
||||
private LocalParityPrepared? prepared;
|
||||
public MainWindow() { InitializeComponent(); RefreshDiscovery(); Status.Text="Ready: choose a legacy Settings.xml to inspect approved configurations."; }
|
||||
internal MainWindow(LocalParityLaunchProfile profile) { localProfile=profile; InitializeComponent(); RefreshDiscovery(); LoadLocalProfile(profile); }
|
||||
private void RefreshDiscovery()
|
||||
private readonly LegacyConfigurationAdapter adapter=new();
|
||||
private LauncherProduct? selected;
|
||||
private string? projectPath;
|
||||
public MainWindow() { InitializeComponent(); Initialize(); }
|
||||
internal MainWindow(LocalParityLaunchProfile profile) { localProfile=profile; InitializeComponent(); Initialize(); }
|
||||
private void Initialize()
|
||||
{
|
||||
var product=new PlantProductDiscovery(new WindowsRegistryReader()).DiscoverPlant3D(2026);
|
||||
AutodeskStatus.Text=product is null?"Autodesk Plant 3D 2026: Not found":"Autodesk Plant 3D 2026: Found";
|
||||
ExecutableStatus.Text=product is null?"Discovery diagnostic: ACAD-9117 Plant 3D registry entry or executable unavailable.":$"Executable: {product.ExecutablePath}";
|
||||
var plant=new PlantProductDiscovery(new WindowsRegistryReader()).DiscoverPlant3D(2026);
|
||||
var navisworks=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),"Autodesk","Navisworks Manage 2026","Roamer.exe");
|
||||
Products.ItemsSource=new[]{new LauncherProduct("navisworks","Navisworks Manage 2026",File.Exists(navisworks)?navisworks:null,File.Exists(navisworks)?"Найден":"Navisworks Manage 2026 не найден"),new LauncherProduct("pnid","Plant P&ID 2026",plant?.ExecutablePath,plant is null?"Plant P&ID 2026 не найден":"Используется установленный Plant 3D 2026 runtime"),new LauncherProduct("plant3d","Plant 3D 2026",plant?.ExecutablePath,plant is null?"Plant 3D 2026 не найден":"Найден")};
|
||||
Version.Text="Версия: "+typeof(MainWindow).Assembly.GetName().Version;
|
||||
Status.Text="Выберите программное обеспечение.";
|
||||
if(localProfile is not null) { Products.SelectedIndex=2; Status.Text="Выберите controlled non-production папку проекта."; }
|
||||
}
|
||||
private void Refresh_Click(object sender,System.Windows.RoutedEventArgs e)=>RefreshDiscovery();
|
||||
private void OpenSettings_Click(object sender,System.Windows.RoutedEventArgs e)
|
||||
private void Products_SelectionChanged(object sender,System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{ selected=Products.SelectedItem as LauncherProduct; projectPath=null; ProjectPath.Text=selected is null?"Выберите программное обеспечение":"Папка проекта не выбрана"; SelectProjectButton.IsEnabled=selected?.Executable is not null; StartButton.IsEnabled=false; Plugins.ItemsSource=null; Plugins.IsEnabled=false; ProductStatus.Text=selected?.Diagnostic??""; Status.Text=selected?.Executable is null?selected?.Diagnostic??"Выберите программное обеспечение":"Выберите папку проекта."; }
|
||||
private void SelectProject_Click(object sender,System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
var dialog=new Microsoft.Win32.OpenFileDialog { Filter="Settings.xml|Settings.xml|XML files|*.xml" };
|
||||
if(dialog.ShowDialog()!=true)return;
|
||||
try { var settings=adapter.ParseSettings(System.IO.File.ReadAllText(dialog.FileName)); Patterns.ItemsSource=settings.Patterns; ConfigurationStatus.Text=$"Loaded {settings.Patterns.Count} configuration(s) from {System.IO.Path.GetFileName(dialog.FileName)}"; Status.Text="Select a configuration. Exact package preparation remains blocked until an approved compatibility overlay and local verified catalog are supplied."; }
|
||||
catch(System.Exception ex) { ConfigurationStatus.Text="Configuration invalid";Status.Text=$"Blocked: {ex.Message}";Patterns.ItemsSource=null; }
|
||||
if(selected is null)return; var dialog=new Microsoft.Win32.OpenFolderDialog { Title="Выберите папку проекта" }; if(dialog.ShowDialog()!=true)return;
|
||||
var path=Path.GetFullPath(dialog.FolderName); if(!Directory.Exists(path)){Status.Text="Выбранная папка недоступна.";return;} if(selected.Id is "plant3d" or "pnid" && !File.Exists(Path.Combine(path,"Project.xml"))){Status.Text="Выбранная папка не является проектом Plant 3D.";return;}
|
||||
projectPath=path; ProjectPath.Text=path; ResolvePlugins();
|
||||
}
|
||||
private void Patterns_SelectionChanged(object sender,System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{ if(Patterns.SelectedItem is not LegacyProductPattern pattern)return;PatternDetails.Text=$"Filter: {pattern.Filter}\nRoster: {pattern.Roster}\nLegacy plugins: {pattern.Plugins.Count}";PackageStatus.Text="Exact package requirements are derived only after approved overlay + ordered download_list.xml join.";Status.Text="Configuration selected; provide approved local compatibility inputs to prepare packages."; }
|
||||
private void Diagnostics_Click(object sender,System.Windows.RoutedEventArgs e)=>System.Windows.MessageBox.Show($"{AutodeskStatus.Text}\n{ConfigurationStatus.Text}\n{Status.Text}","Launcher Next diagnostics");
|
||||
private void LoadLocalProfile(LocalParityLaunchProfile profile)
|
||||
private void LoadMode_Changed(object sender,System.Windows.RoutedEventArgs e) { if(projectPath is not null)ResolvePlugins(); }
|
||||
private void ResolvePlugins()
|
||||
{
|
||||
try { var settings=adapter.ParseSettings(System.IO.File.ReadAllText(profile.SettingsPath)); Patterns.ItemsSource=settings.Patterns; Patterns.SelectedItem=settings.Patterns.Single(x=>x.Name==profile.PatternName); ConfigurationStatus.Text="Controlled Local PXP-OA"; PrepareButton.IsEnabled=true; LaunchButton.IsEnabled=false; Status.Text="Ready: local verified package preparation is available; Launch is disabled until activation succeeds."; }
|
||||
catch(Exception ex) { Status.Text="Blocked: "+ex.Message; }
|
||||
if(selected is null||projectPath is null)return;
|
||||
if(localProfile is not null && selected.Id=="plant3d")
|
||||
{
|
||||
var settings=adapter.ParseSettings(File.ReadAllText(localProfile.SettingsPath)); var pattern=settings.Patterns.Single(x=>x.Name==localProfile.PatternName); Plugins.ItemsSource=pattern.Plugins; Plugins.IsEnabled=ListMode.IsChecked==true; foreach(var item in Plugins.Items)Plugins.SelectedItems.Add(item); PluginStatus.Text=AutomaticMode.IsChecked==true?"Плагины определены автоматически для выбранного проекта.":"Выберите допустимый список плагинов."; StartButton.IsEnabled=true; Status.Text="Готово к запуску."; return;
|
||||
}
|
||||
PluginStatus.Text="Для выбранного продукта нет approved local mapping пакетов."; Plugins.ItemsSource=null; Plugins.IsEnabled=false; StartButton.IsEnabled=false; Status.Text="Источник пакета недоступен для выбранного продукта.";
|
||||
}
|
||||
private async void Prepare_Click(object sender,System.Windows.RoutedEventArgs e)
|
||||
private async void Start_Click(object sender,System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
if(localProfile is null) { Status.Text="Blocked: choose an explicit controlled local configuration."; return; }
|
||||
try { PrepareButton.IsEnabled=false; Status.Text="Preparing verified local package…"; prepared=await localService.PrepareAsync(localProfile,CancellationToken.None); PackageStatus.Text=$"Package: {prepared.Package.PackageId} {prepared.Package.Version}\nState: Active\nValidation: Passed"; LaunchButton.IsEnabled=true; Status.Text="Package active and verified. Launch Plant 3D is enabled."; }
|
||||
catch(Exception ex) { Status.Text="Prepare blocked: "+ex.Message; PrepareButton.IsEnabled=true; }
|
||||
}
|
||||
private async void Launch_Click(object sender,System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
if(prepared is null) { Status.Text="Launch blocked: package is not active."; return; }
|
||||
try { LaunchButton.IsEnabled=false; Status.Text="Launching interactive Plant 3D 2026…"; var result=await localService.LaunchAsync(prepared,CancellationToken.None); Status.Text=result.TerminalState=="Succeeded"?$"Plant 3D started (PID {result.ProcessId}); PXP-OA load confirmed.":$"Launch blocked; evidence written. PID {result.ProcessId}."; LaunchButton.IsEnabled=true; }
|
||||
catch(Exception ex) { Status.Text="Launch failed: "+ex.Message; LaunchButton.IsEnabled=true; }
|
||||
if(localProfile is null||selected?.Id!="plant3d"||projectPath is null){Status.Text="Не удалось определить список плагинов.";return;}
|
||||
try { StartButton.IsEnabled=false; Status.Text="Подготовка плагинов…"; var prepared=await localService.PrepareAsync(localProfile,CancellationToken.None); Status.Text="Запуск Autodesk…"; var result=await localService.LaunchAsync(prepared,CancellationToken.None); Status.Text=result.TerminalState=="Succeeded"?$"Autodesk запущен (PID {result.ProcessId}).":"Не удалось подтвердить загрузку пакета; диагностика сохранена."; StartButton.IsEnabled=true; }
|
||||
catch(Exception ex){Status.Text="Ошибка: "+UserMessage(ex.Message);StartButton.IsEnabled=true;}
|
||||
}
|
||||
private static string UserMessage(string code)=>code.Contains("NOT_FOUND",StringComparison.Ordinal)?"Не найден Plant 3D 2026":code.Contains("MANIFEST",StringComparison.Ordinal)?"Пакет повреждён":code.Contains("ACTIVATION",StringComparison.Ordinal)?"Не удалось активировать пакет":"Не удалось запустить Autodesk";
|
||||
private void Help_Click(object sender,System.Windows.RoutedEventArgs e)=>System.Windows.MessageBox.Show("Выберите ПО, затем папку проекта. В автоматическом режиме Launcher сам подготовит допустимые пакеты и запустит Autodesk.","Справка");
|
||||
private void Diagnostics_Click(object sender,System.Windows.RoutedEventArgs e)=>System.Windows.MessageBox.Show($"{selected?.Diagnostic}\n{ProjectPath.Text}\n{Status.Text}","Диагностика Launcher Next");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user