Office deployment wizard for InstaSoft customers: - Install Office 2019/2021/2024 (Standard, Professional Plus, Home & Business) - Auto-download ODT from Microsoft, generate config XML, run setup - Remove existing Office installations (C2R + MSI) - License troubleshooting via ospp.vbs (dstatus, unpkey) - Fluent Design UI (WPF .NET Framework 4.8, Win7+ compatible) - Hungarian interface, multi-language Office installation - Product key input with auto-activation support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
141 sor
4.9 KiB
C#
141 sor
4.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using InstaSoftOfficeTool.Models;
|
|
using InstaSoftOfficeTool.Services;
|
|
|
|
namespace InstaSoftOfficeTool.Pages
|
|
{
|
|
public partial class ProgressPage : Page
|
|
{
|
|
private readonly MainWindow _main;
|
|
private readonly InstallConfig _config;
|
|
|
|
public ProgressPage(MainWindow main, InstallConfig config)
|
|
{
|
|
InitializeComponent();
|
|
_main = main;
|
|
_config = config;
|
|
}
|
|
|
|
public async void StartInstallation()
|
|
{
|
|
try
|
|
{
|
|
// Step 1: Download ODT
|
|
SetStepActive(Step1Icon, Step1Text);
|
|
AppendLog("ODT let\u00f6lt\u00e9se indul...");
|
|
|
|
var downloader = new OdtDownloader();
|
|
downloader.StatusChanged += msg => Dispatcher.Invoke(() => AppendLog(msg));
|
|
|
|
bool downloaded = await downloader.DownloadAndExtractAsync();
|
|
if (!downloaded)
|
|
{
|
|
SetStepError(Step1Icon, Step1Text);
|
|
ShowDone(false, "Az ODT let\u00f6lt\u00e9se sikertelen.");
|
|
return;
|
|
}
|
|
SetStepDone(Step1Icon, Step1Text);
|
|
|
|
// Step 2: Generate config XML
|
|
SetStepActive(Step2Icon, Step2Text);
|
|
AppendLog("Konfigur\u00e1ci\u00f3s XML gener\u00e1l\u00e1sa...");
|
|
|
|
string xml = OdtXmlGenerator.Generate(_config);
|
|
string xmlPath = Path.Combine(downloader.OdtFolder, "configuration.xml");
|
|
File.WriteAllText(xmlPath, xml);
|
|
AppendLog("XML mentve: " + xmlPath);
|
|
|
|
SetStepDone(Step2Icon, Step2Text);
|
|
|
|
// Step 3: Run setup.exe /configure
|
|
SetStepActive(Step3Icon, Step3Text);
|
|
AppendLog("Office telep\u00edt\u00e9s ind\u00edt\u00e1sa...");
|
|
AppendLog("setup.exe /configure \"" + xmlPath + "\"");
|
|
|
|
int exitCode = await downloader.RunSetupAsync(xmlPath, msg =>
|
|
Dispatcher.Invoke(() => AppendLog(msg)));
|
|
|
|
if (exitCode == 0)
|
|
{
|
|
SetStepDone(Step3Icon, Step3Text);
|
|
ShowDone(true, "Az Office sikeresen telep\u00fclt!");
|
|
}
|
|
else
|
|
{
|
|
SetStepError(Step3Icon, Step3Text);
|
|
ShowDone(false, "A telep\u00edt\u00e9s hibak\u00f3ddal fejez\u0151d\u00f6tt be: " + exitCode);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
AppendLog("HIBA: " + ex.Message);
|
|
ShowDone(false, "V\u00e1ratlan hiba t\u00f6rt\u00e9nt.");
|
|
}
|
|
}
|
|
|
|
private void AppendLog(string text)
|
|
{
|
|
LogText.Text += DateTime.Now.ToString("HH:mm:ss") + " " + text + "\n";
|
|
LogText.ScrollToEnd();
|
|
}
|
|
|
|
private void SetStepActive(TextBlock icon, TextBlock text)
|
|
{
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
icon.Text = "\uE72A";
|
|
icon.Foreground = (Brush)FindResource("AccentBrush");
|
|
text.Foreground = (Brush)FindResource("TextPrimaryBrush");
|
|
text.FontWeight = FontWeights.SemiBold;
|
|
});
|
|
}
|
|
|
|
private void SetStepDone(TextBlock icon, TextBlock text)
|
|
{
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
icon.Text = "\uE73E";
|
|
icon.Foreground = (Brush)FindResource("SuccessBrush");
|
|
text.Foreground = (Brush)FindResource("SuccessBrush");
|
|
text.FontWeight = FontWeights.Normal;
|
|
});
|
|
}
|
|
|
|
private void SetStepError(TextBlock icon, TextBlock text)
|
|
{
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
icon.Text = "\uE711";
|
|
icon.Foreground = (Brush)FindResource("ErrorBrush");
|
|
text.Foreground = (Brush)FindResource("ErrorBrush");
|
|
text.FontWeight = FontWeights.Normal;
|
|
});
|
|
}
|
|
|
|
private void ShowDone(bool success, string message)
|
|
{
|
|
Dispatcher.Invoke(() =>
|
|
{
|
|
MainProgress.IsIndeterminate = false;
|
|
MainProgress.Value = 100;
|
|
TitleText.Text = success ? "Telep\u00edt\u00e9s befejezve" : "Telep\u00edt\u00e9s sikertelen";
|
|
|
|
DoneIcon.Text = success ? "\uE73E" : "\uE711";
|
|
DoneIcon.Foreground = success
|
|
? (Brush)FindResource("SuccessBrush")
|
|
: (Brush)FindResource("ErrorBrush");
|
|
DoneText.Text = message;
|
|
DoneText.Foreground = DoneIcon.Foreground;
|
|
DonePanel.Visibility = Visibility.Visible;
|
|
|
|
_main.ShowCloseButton();
|
|
});
|
|
}
|
|
}
|
|
}
|