Ejemplo n.º 1
0
        private static void doShowSplash()
        {
            if (splash == null)
                splash = new Splash();

            splash.lVersion.Text = "v" + Application.ProductVersion;
            String completedSyncs = XMLManager.ImportElement("CompletedSyncs", Program.SettingsFile) ?? "0";
            if (completedSyncs == "0")
                splash.lSyncCount.Visible = false;
            else {
                splash.lSyncCount.Text = splash.lSyncCount.Text.Replace("{syncs}", String.Format("{0:n0}", completedSyncs));
                splash.lSyncCount.Left = (splash.panel1.Width - (splash.lSyncCount.Width)) / 2;
            }
            log.Debug("Showing splash screen.");
            Application.Run(splash);
            log.Debug("Disposed of splash screen.");
            splashThread.Abort();
        }
Ejemplo n.º 2
0
        private static void Main(string[] args) {
            initialiseFiles();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            #region SplashScreen
            Form splash = new Splash();
            splash.Show();
            DateTime splashed = DateTime.Now;
            while (DateTime.Now < splashed.AddSeconds((System.Diagnostics.Debugger.IsAttached ? 1 : 2)) && !splash.IsDisposed) {
                Application.DoEvents();
                System.Threading.Thread.Sleep(100);
            }
            if (!splash.IsDisposed) splash.Close();
            #endregion

            log.Debug("Loading settings from file.");
            Settings.Load();
            isNewVersion();
            checkForUpdate();

            try {
                Application.Run(new MainForm(startingTab));
                OutlookCalendar.Instance.IOutlook.Disconnect();
            } catch (ApplicationException ex) {
                log.Fatal(ex.Message);
                MessageBox.Show(ex.Message, "Application terminated!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            } catch (Exception ex) {
                log.Fatal("Application unexpectedly terminated!");
                log.Fatal(ex.Message);
                log.Fatal(ex.StackTrace);
                MessageBox.Show(ex.Message, "Application unexpectedly terminated!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                OutlookCalendar.Instance.IOutlook.Disconnect();
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();
            log.Info("Application closed.");
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            initialiseFiles();

            Updater.MakeSquirrelAware();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            delayStartup();
            Splash.ShowMe();

            log.Debug("Loading settings from file.");
            Settings.Load();

            Updater = new Updater();
            isNewVersion(Program.IsInstalled);
            Updater.CheckForUpdate();

            TimezoneDB.Instance.CheckForUpdate();

            try {
                try {
                    Application.Run(new MainForm(startingTab));
                } catch (ApplicationException ex) {
                    log.Fatal(ex.Message);
                    MessageBox.Show(ex.Message, "Application terminated!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    throw new ApplicationException(ex.Message.StartsWith("COM error") ? "Suggest startup delay" : "");
                } catch (System.Runtime.InteropServices.COMException ex) {
                    OGCSexception.Analyse(ex);
                    throw new ApplicationException("Suggest startup delay");
                } catch (System.Exception ex) {
                    OGCSexception.Analyse(ex);
                    log.Fatal("Application unexpectedly terminated!");
                    MessageBox.Show(ex.Message, "Application unexpectedly terminated!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new ApplicationException();
                }
            } catch (ApplicationException aex) {
                if (aex.Message == "Suggest startup delay")
                {
                    if (isCLIstartup() && Settings.Instance.StartOnStartup)
                    {
                        log.Debug("Suggesting to set a startup delay.");
                        MessageBox.Show("If this error only happens when logging in to Windows, try " +
                                        ((Settings.Instance.StartupDelay == 0) ? "setting a" : "increasing the") + " delay for OGCS on startup.",
                                        "Set a delay on startup", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                log.Warn("Tidying down any remaining Outlook references, as OGCS crashed out.");
                try {
                    if (!OutlookOgcs.Calendar.IsInstanceNull)
                    {
                        OutlookOgcs.Calendar.InstanceConnect = false;
                        OutlookOgcs.Calendar.Instance.IOutlook.Disconnect();
                    }
                } catch { }
            }
            Splash.CloseMe();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            while (Updater.IsBusy)
            {
                Application.DoEvents();
                System.Threading.Thread.Sleep(100);
            }
            log.Info("Application closed.");
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            initialiseFiles();

            Updater.MakeSquirrelAware();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            delayStartup();
            Splash.ShowMe();

            log.Debug("Loading settings from file.");
            Settings.Load();

            Updater = new Updater();
            isNewVersion(Updater.IsSquirrelInstall());
            Updater.CheckForUpdate();

            TimezoneDB.Instance.CheckForUpdate();

            try {
                try {
                    Application.Run(new MainForm(startingTab));
                } catch (ApplicationException ex) {
                    log.Fatal(ex.Message);
                    MessageBox.Show(ex.Message, "Application terminated!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    throw new ApplicationException();
                } catch (System.Runtime.InteropServices.COMException ex) {
                    if (OGCSexception.GetErrorCode(ex, 0x000FFFFF) == "0x00040115")
                    {
                        log.Error(ex.Message);
                        MessageBox.Show("OGCS is not able to run as Outlook is not properly connected to the Exchange server.\r\n" +
                                        "Please try again later.", "Application cannot initialise!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        OGCSexception.Analyse(ex);
                    }
                    throw new ApplicationException();
                } catch (System.Exception ex) {
                    OGCSexception.Analyse(ex);
                    log.Fatal("Application unexpectedly terminated!");
                    MessageBox.Show(ex.Message, "Application unexpectedly terminated!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw new ApplicationException();
                }
            } catch (ApplicationException) {
                log.Warn("Tidying down any remaining Outlook references, as OGCS crashed out.");
                try {
                    OutlookCalendar.InstanceConnect = false;
                    OutlookCalendar.Instance.IOutlook.Disconnect();
                } catch { }
            }
            Splash.CloseMe();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            while (Updater.IsBusy)
            {
                Application.DoEvents();
                System.Threading.Thread.Sleep(100);
            }
            log.Info("Application closed.");
        }