Example #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            CommandLineArgs = e.Args;

            //Check to see if there are other instance running, if so exit
            var blnOtherInstancesRunning = this.CheckForOtherApplicationInstances();

            if (blnOtherInstancesRunning)
            {
                return;
            }

            this.SpawnSplashScreen();

            EnsureContainerExists();

            this.MessagingService.SendPosEventMessage(new PosStartupCompletedEventData(PosApplication));
            MessagingService?.SendLogMessage("Pos application started.", CloudRetailerTraceLevel.Info);
            //Create MainView, set it to be the Application's MainWindow, add a event surrogate to close SplashScreen when MainView loads, then show MainView
            this.MessagingService.SendPosStartupMessage("Loading POS View...");
            this.ConfigureAndDisplayMainView();

            this.CustomerDisplayService.StartService();

            SetWebBrowserIEMode();

            if (ServiceSettings.IsDebug())
            {
                this.MessagingService.SendPosStartupMessage("Firing runtime tests...");
                var runtimeTester = new RuntimeTester(PosApplication);
                var invalidTests  = runtimeTester.RunAll().Where(t => !t.IsValid).ToArray();
                if (invalidTests.Any())
                {
                    var testText = string.Join("\n", invalidTests.Select(t => $"{t.Test.GetType().Name}: {t.Message}"));
                    PosApplication.MessagingService.SendNotificationMessage("Debug Runtime Test", "The following runtime tests resulted in errors:\n" + testText + "\n\n" + "<b color='#f00000'>Please verify your latest code changes and find out why the runtime tests stopped working.</b>");
                }
            }

            //Call the base class method
            base.OnStartup(e);
        }