static void Main() { Process.GetCurrentProcess().PriorityBoostEnabled = true; Application.EnableVisualStyles(); var fsf = new FormSplashFOCA("Open Source"); var t = new Thread(new ThreadStart(delegate { Application.Run(fsf); })); t.Start(); //Load the FOCA Running = true; if (!IsSQLServerRunning()) { var f = MessageBox.Show( "A SQL server must be installed and running. We recommend you to use SQL Server Express Edition", "Missing SQL Server", MessageBoxButtons.OK, MessageBoxIcon.Error); if (f == DialogResult.OK) { try { Process.Start("https://www.microsoft.com/en-us/sql-server/sql-server-editions-express"); } catch (Exception) { } Environment.Exit(0); } } data = new Data(); InitializeErrorLog(); FormMainInstance = new FormMain(); FormOptionsInstance = new FormOptions(); var canStart = false; do { try { fsf.Invoke(new MethodInvoker(delegate { fsf.Close(); canStart = true; })); } catch { Thread.Sleep(900); canStart = false; } } while (canStart == false); Application.Run(FormMainInstance); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FormSplashFOCA splashScreen = new FormSplashFOCA("Open Source"); splashScreen.Show(); Application.DoEvents(); //Load the FOCA Running = true; SqlConnectionStringBuilder connectionStringBuilder = null; bool csUpdated = false; try { ConnectionStringSettings csFromConfig = ConfigurationManager.ConnectionStrings[nameof(FocaContextDb)]; //If there is no connection string configured, try with SQLEXPRESS instance if (csFromConfig == null || String.IsNullOrEmpty(csFromConfig.ConnectionString)) { connectionStringBuilder = new SqlConnectionStringBuilder(SQLExpressConnectionString); csUpdated = true; } else { connectionStringBuilder = new SqlConnectionStringBuilder(csFromConfig.ConnectionString); if (String.IsNullOrWhiteSpace(connectionStringBuilder.InitialCatalog)) { connectionStringBuilder.InitialCatalog = FocaDatabaseName; } } } catch (ArgumentException) { csUpdated = true; connectionStringBuilder = new SqlConnectionStringBuilder(SQLExpressConnectionString); } while (!FocaContextDb.IsDatabaseAvailable(connectionStringBuilder.ToString())) { MessageBox.Show("FOCA needs a SQL database. Please setup your connection and try again.", "Database not found", MessageBoxButtons.OK, MessageBoxIcon.Error); // Display the connection dialog using (DataConnectionDialog dlg = new DataConnectionDialog(connectionStringBuilder)) { if (DialogResult.OK != dlg.ShowDialog(splashScreen)) { Environment.Exit(0); } } csUpdated = true; } if (csUpdated) { UpdateConnectionString(connectionStringBuilder.ToString()); } data = new Data(); FormMainInstance = new FormMain(); FormOptionsInstance = new FormOptions(); splashScreen.Close(); splashScreen.Dispose(); InitializeServicePointManager(); Application.Run(FormMainInstance); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); System.Threading.Thread splashThread = new System.Threading.Thread(new System.Threading.ThreadStart(() => { splashScreen = new FormSplashFOCA(ProgramVersion); Application.Run(splashScreen); Application.ExitThread(); })); splashThread.SetApartmentState(System.Threading.ApartmentState.STA); splashThread.Start(); Application.DoEvents(); //Load the FOCA Running = true; SqlConnectionStringBuilder connectionStringBuilder = null; bool csUpdated = false; try { ConnectionStringSettings csFromConfig = ConfigurationManager.ConnectionStrings[nameof(FocaContextDb)]; //If there is no connection string configured, try with SQLEXPRESS instance if (csFromConfig == null || String.IsNullOrEmpty(csFromConfig.ConnectionString)) { connectionStringBuilder = new SqlConnectionStringBuilder(SQLExpressConnectionString); csUpdated = true; } else { connectionStringBuilder = new SqlConnectionStringBuilder(csFromConfig.ConnectionString); if (String.IsNullOrWhiteSpace(connectionStringBuilder.InitialCatalog)) { connectionStringBuilder.InitialCatalog = FocaDatabaseName; } } } catch (ArgumentException) { csUpdated = true; connectionStringBuilder = new SqlConnectionStringBuilder(SQLExpressConnectionString); } while (!FocaContextDb.IsDatabaseAvailable(connectionStringBuilder.ToString())) { splashScreen.Invoke((MethodInvoker)(() => MessageBox.Show(splashScreen, "FOCA needs a SQL database. Please setup your connection and try again.", "Database not found", MessageBoxButtons.OK, MessageBoxIcon.Error))); // Display the connection dialog using (DataConnectionDialog dlg = new DataConnectionDialog(connectionStringBuilder)) { DialogResult connectionResult = DialogResult.Cancel; splashScreen.Invoke((MethodInvoker)(() => connectionResult = dlg.ShowDialog(splashScreen))); if (DialogResult.OK != connectionResult) { Environment.Exit(0); } } csUpdated = true; } if (csUpdated) { UpdateConnectionString(connectionStringBuilder.ToString()); } data = new Data(); FormMainInstance = new FormMain(); FormMainInstance.TopMost = true; FormMainInstance.Shown += FormMainInstance_Shown; FormOptionsInstance = new FormOptions(); InitializeServicePointManager(); Application.Run(FormMainInstance); }