protected override void Run() { try { Logger.Initialize(Engine); Logger.Verbose("Launching bootstrapper engine"); Logger.Verbose("Initializing base model"); var baseModel = new BaseModel(this); Logger.Verbose("Initializing view model"); var viewModel = new PagedViewModel(baseModel); //baseModel.UploadLogEntry("Install", "Starting install; version={0}", string.Format("{0}", Assembly.GetExecutingAssembly().GetName().Version)); Logger.Verbose("Starting Detect"); Engine.Detect(); baseModel.Result = 1602; // assume result = cancel if (baseModel.Command.Display == Display.Passive || baseModel.Command.Display == Display.Full) { Logger.Verbose("Showing view"); viewModel.View.Show(); } Dispatcher.Run(); Engine.Quit(baseModel.Result); } catch (Exception e) { Engine.Log(LogLevel.Error, string.Format("An exception occurred while attempting to initialize the engine: {0}", e.StackTrace)); Engine.Quit(-1); } }
private static void StartUtility(PagedViewModel model, bool newInstall) { try { if (string.IsNullOrWhiteSpace(model.BaseModel.InstallFolder)) { Logger.Error("Cannot launch engine; InstallFolder not set"); return; } var installFolder = model.BaseModel.InstallFolder; var enginePath = Path.Combine(installFolder, "engine.exe"); if (!File.Exists(enginePath)) { Logger.Error("Cannot launch engine; invalid path {0}", enginePath); return; } var pipeName = Guid.NewGuid().ToString(); var info = new ProcessStartInfo(enginePath) { Verb = "runas", Arguments = string.Format("-echo=ready -pipe=\"{0}\"", pipeName) }; Process.Start(info); model.BaseModel.UploadLogEntry("Install", "Launching engine"); model.InstallationState = newInstall ? InstallationState.LaunchingNewInstall : InstallationState.LaunchingAlreadyInstalled; var waitTask = new Task(() => WaitForExitMessage(15, pipeName)); waitTask.Start(); waitTask.WaitWithPumping(); model.Dispatcher.BeginInvoke((Action)(() => model.View.Close())); } catch (Exception e) { model.BaseModel.UploadLogEntry("InstallError", "An exception occurred while attempting to launch the engine: {0}", e.Message); Logger.Error("An exception occurred while attempting to launch the engine: {0}", e.Message); } }
public LaunchEngineCommand(PagedViewModel model, bool newInstall) : base(param=>StartUtility(model, newInstall), param=>true) { }
public ExternalUtilityEngine(PagedViewModel model, string utilityPath) { _model = model; UtilityPath = utilityPath; PipeName = Guid.NewGuid().ToString(); }