示例#1
0
        protected override void Run()
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += (s, a) => Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {a.ExceptionObject}");

                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
                BootstrapperDispatcher.UnhandledException += (s, a) => Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {a.Exception}");

                RootView         = new MainWindowView(this);
                RootView.Closed += (s, a) => BootstrapperDispatcher.InvokeShutdown();

                Engine.Detect();

                if (Command.Display == Display.Passive || Command.Display == Display.Full)
                {
                    RootView.Show();
                    Dispatcher.Run();
                }

                Engine.Quit(RootView.ViewModel.Status);
            }
            catch (Exception e)
            {
                Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {e}");
                throw e;
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        protected override void Run()
        {
            // To get the command line arguments

            /*foreach (var commandLineArgs in this.Command.GetCommandLineArgs())
             * {
             *
             * }*/

            MessageBox.Show(BundleName);

            try
            {
                this.Engine.CloseSplashScreen();

                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

                BootstrapperDispatcher.UnhandledException +=
                    (sender, args) =>
                {
                    this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {args.Exception}");
                };

                RootView         = new SetupWizard(this);
                RootView.Closed += (sender, args) => BootstrapperDispatcher.InvokeShutdown();
                this.Engine.Detect();

                RootView.Show();
                Dispatcher.Run();
            }
            catch (Exception e)
            {
                this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {e}");
                throw e;
            }
        }
示例#3
0
        protected override void Run()
        {
            try
            {
                string[] args = this.Command.GetCommandLineArgs();

                bool runIpc      = false;
                bool showPrompts = true;

                Engine.Log(LogLevel.Standard, $"Arguments: {string.Join(", ", args)}");
                foreach (string arg in args)
                {
                    if (arg == "/ipc")
                    {
                        runIpc = true;
                    }
                    else if (arg == "/nomodals")
                    {
                        showPrompts = false;
                    }
                    else if (arg == "/waitforexit")
                    {
                        WaitForFilterExit = true;
                    }
                }

                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

                Application app = new Application();

                ISetupUI           setupUi = null;
                InstallerViewModel model   = new InstallerViewModel(this);

                // NOTE: This runIpc check can be removed if our current system proves itself.
                if (runIpc)
                {
                    if (server == null)
                    {
                        server = new UpdateIPCServer(UpdateIPCServer.PipeName);

                        server.MessageReceived += CheckExit;

                        server.RegisterObject("InstallerViewModel", model);

                        server.Start();
                    }

                    setupUi = new IpcWindow(server, model, showPrompts);
                    server.RegisterObject("SetupUI", setupUi);

                    server.MessageReceived += CheckStartCommand; // Wait for the first start command to begin installing.

                    setupUi.Closed += (sender, e) => SignalExit();

                    server.ClientConnected += () =>
                    {
                        Engine.Log(LogLevel.Standard, "Resynchronizing UI with new client.");
                        (setupUi as IpcWindow)?.ResynchronizeUI();
                    };

                    model.SetSetupUi(setupUi);

                    model.PropertyChanged += (sender, e) =>
                    {
                        server.PushMessage(new Message()
                        {
                            Command  = IPC.Command.PropertyChanged,
                            Property = e.PropertyName
                        });
                    };

                    this.Engine.Detect();
                }
                else
                {
                    setupUi         = new MainWindow(model, showPrompts);
                    setupUi.Closed += (sender, e) =>
                    {
                        Engine.Log(LogLevel.Standard, "Closing installer.");
                        BootstrapperDispatcher.BeginInvokeShutdown(DispatcherPriority.Normal);
                        Engine.Log(LogLevel.Standard, "Shutdown invoked.");
                    };

                    model.SetSetupUi(setupUi);

                    Engine.Detect();

                    if (Command.Display != Display.None && Command.Display != Display.Embedded)
                    {
                        setupUi.Show();
                    }

                    Dispatcher.Run();

                    this.Engine.Quit(0);
                }
            }
            catch (Exception ex)
            {
                Engine.Log(LogLevel.Error, "A .NET error occurred while running CloudVeilInstallerUI");
                Engine.Log(LogLevel.Error, $"Error Type: {ex.GetType().Name}");
                Engine.Log(LogLevel.Error, $"Error info: {ex}");

                this.Engine.Quit(1);
            }
        }
示例#4
0
        protected override void Run()
        {
            // On an English system, the user can change the language to Japanese, so
            // detect the user language, and not the system.
            var code        = int.Parse(this.Engine.FormatString("[UserUILanguageID]"));
            var cultureInfo = CultureInfo.GetCultureInfo(code);

            Thread.CurrentThread.CurrentCulture   = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
            Localisation.Culture = cultureInfo;

            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
                                                                   XmlLanguage.GetLanguage(cultureInfo.IetfLanguageTag)));
            try
            {
                this.Engine.CloseSplashScreen();

                InitializeP4Variables();

                FormatVersionForPage();

                var rebootPending = this.Engine.StringVariables["RebootPending"];
                if (!string.IsNullOrEmpty(rebootPending) && rebootPending != "0")
                {
                    if (this.Command.Display == Display.Full)
                    {
                        MessageBox.Show(
                            string.Format(Localisation.WixBootstrapper_RestartPendingDialogBody, this.BundleName),
                            string.Format(Localisation.WixBootstrapper_RestartPendingDialogTitle, this.BundleName),
                            MessageBoxButton.OK,
                            MessageBoxImage.Error);
                    }
                    this.Engine.Quit(3010);
                }

                this.Engine.Log(LogLevel.Verbose, "Launching Burn frontend");
                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
                AppDomain.CurrentDomain.UnhandledException +=
                    (sender, args) =>
                {
                    this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {args.ExceptionObject}");
                };
                BootstrapperDispatcher.UnhandledException +=
                    (sender, args) =>
                {
                    this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {args.Exception}");
                };

                RootView         = new WizardWindow(this);
                RootView.Closed += (sender, args) => BootstrapperDispatcher.InvokeShutdown();

                this.Engine.Detect();

                //System.Diagnostics.Debugger.Launch();
                if (this.Command.Display == Display.Passive || this.Command.Display == Display.Full)
                {
                    RootView.Show();
                    Dispatcher.Run();
                }

                this.Engine.Quit(RootView.ViewModel.Status);
            }
            catch (Exception e)
            {
                this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {e}");
                throw e;
            }
        }
示例#5
0
        protected override void Run()
        {
            var code        = int.Parse(this.Engine.FormatString("[SystemLanguageID]"));
            var cultureInfo = CultureInfo.GetCultureInfo(code);

            Thread.CurrentThread.CurrentCulture   = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
            Localisation.Culture = cultureInfo;

            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
                                                                   XmlLanguage.GetLanguage(cultureInfo.IetfLanguageTag)));
            try
            {
                this.Engine.CloseSplashScreen();

                var rebootPending = this.Engine.StringVariables["RebootPending"];
                if (!string.IsNullOrEmpty(rebootPending) && rebootPending != "0")
                {
                    if (this.Command.Display == Display.Full)
                    {
                        MessageBox.Show(
                            string.Format(Localisation.WixBootstrapper_RestartPendingDialogBody, this.BundleName),
                            string.Format(Localisation.WixBootstrapper_RestartPendingDialogTitle, this.BundleName),
                            MessageBoxButton.OK,
                            MessageBoxImage.Error);
                    }
                    this.Engine.Quit(3010);
                }

                this.Engine.Log(LogLevel.Verbose, "Launching Burn frontend");
                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
                AppDomain.CurrentDomain.UnhandledException +=
                    (sender, args) =>
                {
                    this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {args.ExceptionObject}");
                };
                BootstrapperDispatcher.UnhandledException +=
                    (sender, args) =>
                {
                    this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {args.Exception}");
                };

                RootView         = new WizardWindow(this);
                RootView.Closed += (sender, args) => BootstrapperDispatcher.InvokeShutdown();

                this.Engine.Detect();

                foreach (var commandLineArg in this.Command.GetCommandLineArgs())
                {
                    if (commandLineArg.StartsWith("InstallationType=", StringComparison.InvariantCultureIgnoreCase))
                    {
                        var param = commandLineArg.Split(new[] { '=' }, 2);
                        RootView.ViewModel.PackageCombinationConfiguration.InstallationType =
                            (InstallationType)Enum.Parse(typeof(InstallationType), param[1]);
                    }
                }
                if (this.Command.Display == Display.Passive || this.Command.Display == Display.Full)
                {
                    RootView.Show();
                    Dispatcher.Run();
                }

                this.Engine.Quit(RootView.ViewModel.Status);
            }
            catch (Exception e)
            {
                this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {e}");
                throw e;
            }
        }
示例#6
0
        private void SetLaunchAction(Display gui)
        {
            if (launchAction == LaunchAction.Install) // Install
            {
                Log($"What have I to do? : {launchAction}");

                PlanPackageBegin += SetInstallPackagePlannedState;

                ApplyComplete += (o, e) =>
                {
                    ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure;
                    MainViewModel.Instance.NavigateFromOffset(1);
                };

                try
                {
                    BootstrapperDispatcher.Invoke(() =>
                    {
                        MainView view = new MainView();
                        view.Closed  += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                        view.Show();
                    });
                }
                catch (Exception ex)
                {
                    LogExceptionWithInner(ex);
                }
            }
            else if (launchAction == LaunchAction.UpdateReplace) // Update
            {
                Log($"What have I to do? : {launchAction}");

                PlanPackageBegin += SetUpdatePackagePlannedState;

                ApplyComplete += (o, e) =>
                {
                    ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure;
                    UninstallViewModel.Instance.NavigateFromOffset(1);
                };

                try
                {
                    BootstrapperDispatcher.Invoke(() =>
                    {
                        UninstallView view = new UninstallView();
                        view.Closed       += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                        view.Show();
                    });
                }
                catch (Exception ex)
                {
                    LogExceptionWithInner(ex);
                }
            }
            else if (launchAction == LaunchAction.Repair) // Repair
            {
                Log($"What have I to do? : {launchAction}");

                PlanPackageBegin += SetRepairPackagePlannedState;

                ApplyComplete += (o, e) =>
                {
                    ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure;
                    UninstallViewModel.Instance.NavigateFromOffset(1);
                };

                try
                {
                    BootstrapperDispatcher.Invoke(() =>
                    {
                        UninstallView view = new UninstallView();
                        view.Closed       += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                        view.Show();
                    });
                }
                catch (Exception ex)
                {
                    LogExceptionWithInner(ex);
                }
            }
            else if (launchAction == LaunchAction.Uninstall) // Uninstall
            {
                Log($"What have I to do? : {launchAction}");

                PlanPackageBegin += SetUninstallPackagePlannedState;

                ApplyComplete += (o, e) =>
                {
                    ActionResult = e.Status >= 0 ? ActionResult.Success : ActionResult.Failure;
                    if (gui == Display.None || gui == Display.Embedded)
                    {
                        BootstrapperDispatcher.Invoke(() => Engine.Quit((int)ActionResult));
                    }
                    else
                    {
                        UninstallViewModel.Instance.NavigateFromOffset(1);
                    }
                };

                if (gui == Display.None || gui == Display.Embedded)
                {
                    Engine.Plan(LaunchAction.Uninstall);
                    Engine.Apply(IntPtr.Zero);
                }
                else
                {
                    try
                    {
                        BootstrapperDispatcher.Invoke(() =>
                        {
                            UninstallView view = new UninstallView();
                            view.Closed       += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                            view.Show();
                        });
                    }
                    catch (Exception ex)
                    {
                        LogExceptionWithInner(ex);
                    }
                }
            }
        }
        protected override void Run()
        {
            try
            {
                sentry = SentrySdk.Init(CloudVeil.Windows.CompileSecrets.SentryDsn);
            } catch
            {
                sentry = null;
            }
            try
            {
                string[] args = this.Command.GetCommandLineArgs();

                bool runIpc      = false;
                bool showPrompts = true;

                Engine.Log(LogLevel.Standard, $"Arguments: {string.Join(", ", args)}");
                foreach (string arg in args)
                {
                    if (arg == "/ipc")
                    {
                        runIpc = true;
                    }
                    else if (arg == "/nomodals")
                    {
                        showPrompts = false;
                    }
                    else if (arg == "/waitforexit")
                    {
                        WaitForFilterExit = true;
                    }
                    else if (arg == "/upgrade")
                    {
                        Updating = true;
                    }
                    else if (arg.Contains("/userid="))
                    {
                        UserId = arg.Replace("/userid=", "");
                    }
                }

                if (Updating == false && WaitForFilterExit == true)
                {
                    Updating = true;
                }
                if (UserId.Length == 0)
                {
                    try
                    {
                        var email       = new RegistryAuthenticationStorage().UserEmail;
                        var fingerPrint = new WindowsFingerprint().Value;
                        UserId = email + ":" + fingerPrint;
                        Engine.Log(LogLevel.Standard, $"My autoset id: {UserId}");
                    }
                    catch
                    {
                        Engine.Log(LogLevel.Error, "Can't set User id, probably fresh install");
                    }
                }

                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

                Application app = new Application();

                ISetupUI           setupUi = null;
                InstallerViewModel model   = new InstallerViewModel(this);

                // NOTE: This runIpc check can be removed if our current system proves itself.
                if (runIpc)
                {
                    if (server == null)
                    {
                        server = new UpdateIPCServer(UpdateIPCServer.PipeName);

                        server.MessageReceived += CheckExit;

                        server.RegisterObject("InstallerViewModel", model);

                        server.Start();
                    }

                    setupUi = new IpcWindow(server, model, showPrompts);
                    server.RegisterObject("SetupUI", setupUi);

                    server.MessageReceived += CheckStartCommand; // Wait for the first start command to begin installing.

                    setupUi.Closed += (sender, e) => SignalExit();

                    server.ClientConnected += () =>
                    {
                        Engine.Log(LogLevel.Standard, "Resynchronizing UI with new client.");
                        (setupUi as IpcWindow)?.ResynchronizeUI();
                    };

                    model.SetSetupUi(setupUi);

                    model.PropertyChanged += (sender, e) =>
                    {
                        server.PushMessage(new Message()
                        {
                            Command  = IPC.Command.PropertyChanged,
                            Property = e.PropertyName
                        });
                    };

                    this.Engine.Detect();
                }
                else
                {
                    setupUi         = new MainWindow(model, showPrompts);
                    setupUi.Closed += (sender, e) =>
                    {
                        Engine.Log(LogLevel.Standard, "Closing installer.");
                        BootstrapperDispatcher.BeginInvokeShutdown(DispatcherPriority.Normal);
                        Engine.Log(LogLevel.Standard, "Shutdown invoked.");
                    };

                    model.SetSetupUi(setupUi);

                    Engine.Detect();

                    if (Command.Display != Display.None && Command.Display != Display.Embedded)
                    {
                        setupUi.Show();
                    }

                    Dispatcher.Run();

                    if (sentry != null)
                    {
                        sentry.Dispose();
                    }
                    this.Engine.Quit(0);
                }
            }
            catch (Exception ex)
            {
                Engine.Log(LogLevel.Error, "A .NET error occurred while running CloudVeilInstallerUI");
                Engine.Log(LogLevel.Error, $"Error Type: {ex.GetType().Name}");
                Engine.Log(LogLevel.Error, $"Error info: {ex}");

                this.Engine.Quit(1);
            }
        }