Ejemplo n.º 1
0
        public void MyTestInitialize()
        {
            // Stop profiler if we are profiling.  The unit test will start profiling explicitly when it wants to.
            DotTraceProfile.Stop(true);

            SecurityProtocolInitializer.Initialize(); // Enable maximum available HTTPS security level, esp. for Chorus

//            var log = new Log<AbstractUnitTest>();
//            log.Info(TestContext.TestName + " started");

            Settings.Init();

            TestSmallMolecules = GetBoolValue("TestSmallMolecules", false);

            STOPWATCH.Restart();
            Initialize();
        }
Ejemplo n.º 2
0
        public void MyTestInitialize()
        {
            Program.UnitTest = true;

            // Stop profiler if we are profiling.  The unit test will start profiling explicitly when it wants to.
            DotTraceProfile.Stop(true);

            SecurityProtocolInitializer.Initialize(); // Enable maximum available HTTPS security level

//            var log = new Log<AbstractUnitTest>();
//            log.Info(TestContext.TestName + " started");

            Settings.Init();

            STOPWATCH.Restart();
            Initialize();
        }
Ejemplo n.º 3
0
        public void MyTestInitialize()
        {
            // Stop profiler if we are profiling.  The unit test will start profiling explicitly when it wants to.
            DotTraceProfile.Stop(true);

            SecurityProtocolInitializer.Initialize(); // Enable maximum available HTTPS security level, esp. for Chorus

//            var log = new Log<AbstractUnitTest>();
//            log.Info(TestContext.TestName + " started");

            Settings.Init();

            // ReSharper disable once UnusedVariable
            var dummy = TestSmallMolecules; // First access turns on the non-proteomic test node behavior if needed

            STOPWATCH.Restart();
            Initialize();
        }
Ejemplo n.º 4
0
        public static int Main(string[] args = null)
        {
            if (String.IsNullOrEmpty(Settings.Default.InstallationId)) // Each instance to have GUID
            {
                Settings.Default.InstallationId = Guid.NewGuid().ToString();
            }

            // don't allow 64-bit Skyline to run in a 32-bit process
            if (Install.Is64Bit && !Environment.Is64BitProcess)
            {
                string installUrl   = Install.Url;
                string installLabel = (installUrl == string.Empty) ? string.Empty : string.Format(Resources.Program_Main_Install_32_bit__0__, Name);
                AlertLinkDlg.Show(null,
                                  string.Format(Resources.Program_Main_You_are_attempting_to_run_a_64_bit_version_of__0__on_a_32_bit_OS_Please_install_the_32_bit_version, Name),
                                  installLabel,
                                  installUrl);
                return(1);
            }

            SecurityProtocolInitializer.Initialize(); // Enable highest available security level for HTTPS connections, esp. Chorus

            CommonFormEx.TestMode      = FunctionalTest;
            CommonFormEx.Offscreen     = SkylineOffscreen;
            CommonFormEx.ShowFormNames = FormEx.ShowFormNames = ShowFormNames;

            // For testing and debugging Skyline command-line interface
            bool openDoc = args != null && args.Length > 0 && args[0] == OPEN_DOCUMENT_ARG;

            if (args != null && args.Length > 0 && !openDoc)
            {
                if (!CommandLineRunner.HasCommandPrefix(args[0]))
                {
                    TextWriter textWriter;
                    if (Debugger.IsAttached)
                    {
                        textWriter = new DebugWriter();
                    }
                    else
                    {
                        AttachConsole(-1);
                        textWriter = Console.Out;
                        Console.WriteLine();
                        Console.WriteLine();
                    }
                    var writer = new CommandStatusWriter(textWriter);
                    if (args[0].Equals("--ui", StringComparison.InvariantCultureIgnoreCase)) // Not L10N
                    {
                        // ReSharper disable once ObjectCreationAsStatement
                        new CommandLineUI(args, writer);
                    }
                    else
                    {
                        return(CommandLineRunner.RunCommand(args, writer));
                    }
                }
                else
                {
                    // For testing SkylineRunner without installation
                    CommandLineRunner clr = new CommandLineRunner();
                    clr.Start(args[0]);
                }

                return(EXIT_CODE_SUCCESS);
            }
            // The way Skyline command-line interface is run for an installation
            else if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null &&
                     AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null &&
                     AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0 &&
                     CommandLineRunner.HasCommandPrefix(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0])) // Not L10N
            {
                CommandLineRunner clr = new CommandLineRunner();
                clr.Start(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]);

                // HACK: until the "invalid string binding" error is resolved, this will prevent an error dialog at exit
                Process.GetCurrentProcess().Kill();
                return(EXIT_CODE_SUCCESS);
            }

            try
            {
                Init();
                if (!string.IsNullOrEmpty(Settings.Default.DisplayLanguage))
                {
                    try
                    {
                        LocalizationHelper.CurrentUICulture =
                            CultureInfo.GetCultureInfo(Settings.Default.DisplayLanguage);
                    }
                    catch (CultureNotFoundException)
                    {
                    }
                }
                LocalizationHelper.InitThread(Thread.CurrentThread);

                // Make sure the user has agreed to the current license version
                // or one more recent.
                int licenseVersion = Settings.Default.LicenseVersionAccepted;
                if (licenseVersion < LICENSE_VERSION_CURRENT && !NoSaveSettings)
                {
                    // If the user has never used the application before, then
                    // they must have agreed to the current license agreement during
                    // installation.  Otherwise, make sure they agree to the new
                    // license agreement.
                    if (Install.Type == Install.InstallType.release &&
                        (licenseVersion != 0 || !Settings.Default.MainWindowSize.IsEmpty))
                    {
                        using (var dlg = new UpgradeLicenseDlg(licenseVersion))
                        {
                            if (dlg.ShowDialog() == DialogResult.Cancel)
                            {
                                return(EXIT_CODE_FAILURE_TO_START);
                            }
                        }
                    }

                    try
                    {
                        // Make sure the user never sees this again for this license version
                        Settings.Default.LicenseVersionAccepted = LICENSE_VERSION_CURRENT;
                        Settings.Default.Save();
                    }
// ReSharper disable EmptyGeneralCatchClause
                    catch (Exception)
// ReSharper restore EmptyGeneralCatchClause
                    {
                        // Just try to update the license version next time.
                    }
                }

                try
                {
                    // If this is a new installation copy over installed external tools from previous installation location.
                    var toolsDirectory = ToolDescriptionHelpers.GetToolsDirectory();
                    if (!Directory.Exists(toolsDirectory))
                    {
                        using (var longWaitDlg = new LongWaitDlg
                        {
                            Text = Name,
                            Message = Resources.Program_Main_Copying_external_tools_from_a_previous_installation,
                            ProgressValue = 0
                        })
                        {
                            longWaitDlg.PerformWork(null, 1000 * 3, broker => CopyOldTools(toolsDirectory, broker));
                        }
                    }
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {
                }

                // Force live reports (though tests may reset this)
                //Settings.Default.EnableLiveReports = true;

                if (ReportShutdownDlg.HadUnexpectedShutdown())
                {
                    using (var reportShutdownDlg = new ReportShutdownDlg())
                    {
                        reportShutdownDlg.ShowDialog();
                    }
                }
                SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged;
                // Careful, a throw out of the SkylineWindow constructor without this
                // catch causes Skyline just to appear to silently never start.  Makes for
                // some difficult debugging.
                try
                {
                    var activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments;
                    if ((activationArgs != null &&
                         activationArgs.ActivationData != null &&
                         activationArgs.ActivationData.Length != 0) ||
                        openDoc ||
                        !Settings.Default.ShowStartupForm)
                    {
                        MainWindow = new SkylineWindow(args);
                    }
                    else
                    {
                        StartWindow = new StartPage();
                        try
                        {
                            if (StartWindow.ShowDialog() != DialogResult.OK)
                            {
                                Application.Exit();
                                return(EXIT_CODE_SUCCESS);
                            }

                            MainWindow = StartWindow.MainWindow;
                        }
                        finally
                        {
                            StartWindow.Dispose();
                            StartWindow = null;
                        }
                    }
                }
                catch (Exception x)
                {
                    ReportExceptionUI(x, new StackTrace(1, true));
                }

                ConcurrencyVisualizer.StartEvents(MainWindow);

                // Position window offscreen for stress testing.
                if (SkylineOffscreen)
                {
                    FormEx.SetOffscreen(MainWindow);
                }

                ActionUtil.RunAsync(() =>
                {
                    try {
                        SendAnalyticsHit();
                    } catch (Exception ex) {
                        Trace.TraceWarning("Exception sending analytics hit {0}", ex);  // Not L10N
                    }
                });
                MainToolServiceName = Guid.NewGuid().ToString();
                Application.Run(MainWindow);
                StopToolService();
            }
            catch (Exception x)
            {
                // Send unhandled exceptions to the console.
                Console.WriteLine(x.Message);
                Console.Write(x.StackTrace);
            }

            MainWindow = null;
            return(EXIT_CODE_SUCCESS);
        }