Esempio n. 1
0
        private static void Main()
        {
            Logger.Debug("Checking to see if there is an instance running.");
            if (IsAlreadyRunning())
            {
                // let the user know the program is already running.
                Logger.Warn("Instance is already running, exiting.");
                MessageBox.Show(Resources.ProgramIsAlreadyRunning, Resources.ProgramIsAlreadyRunningCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                if (!IsOutlook2003OrHigherInstalled())
                {
                    Logger.Debug("Outlook is not avaliable or installed.");
                    MessageBox.Show(
                        Resources.Office2000Requirement + Environment.NewLine +
                        Resources.InstallOutlookMsg, Resources.MissingRequirementsCapation, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    OutlookApp       = new Application();
                    OutlookNameSpace = OutlookApp.GetNamespace("MAPI");

                    // Before we do anything else, wait for the RPC server to be available, as the program will crash if it's not.
                    // This is especially likely when OotD is set to start with windows.
                    if (!IsRPCServerAvailable(OutlookNameSpace))
                    {
                        return;
                    }

                    OutlookFolder = OutlookNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

                    // WORKAROUND: Beginning wih Outlook 2007 SP2, Microsoft decided to kill all outlook instances
                    // when opening and closing an item from the view control, even though the view control was still running.
                    // The only way I've found to work around it and keep the view control from crashing after opening an item,
                    // is to get this global instance of the active explorer and keep it going until the user closes the app.
                    OutlookExplorer = OutlookFolder.GetExplorer();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Resources.ErrorInitializingApp + ' ' + ex, Resources.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                System.Windows.Forms.Application.EnableVisualStyles();

                Logger.Info("Starting the instance manager and loading instances.");
                var instanceManager = new InstanceManager();

                try
                {
                    instanceManager.LoadInstances();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Could not load instances");
                    return;
                }

                System.Windows.Forms.Application.Run(instanceManager);
            }
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args).WithParsed(ProcessCommandLineArgs);

            _logger.Debug("Checking to see if there is an instance running.");

            using (new Mutex(true, AppDomain.CurrentDomain.FriendlyName, out var createdNew))
            {
                if (createdNew)
                {
                    try
                    {
                        OutlookApp       = new Application();
                        OutlookNameSpace = OutlookApp.GetNamespace("MAPI");

                        // Before we do anything else, wait for the RPC server to be available, as the program will crash if it's not.
                        // This is especially likely when OotD is set to start with windows.
                        if (!IsRPCServerAvailable(OutlookNameSpace))
                        {
                            return;
                        }

                        OutlookFolder = OutlookNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

                        // WORKAROUND: Beginning with Outlook 2007 SP2, Microsoft decided to kill all outlook instances
                        // when opening and closing an item from the view control, even though the view control was still running.
                        // The only way I've found to work around it and keep the view control from crashing after opening an item,
                        // is to get this global instance of the active explorer and keep it going until the user closes the app.
                        OutlookExplorer = OutlookFolder.GetExplorer();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Resources.ErrorInitializingApp + ' ' + ex, Resources.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    System.Windows.Forms.Application.EnableVisualStyles();

                    _logger.Info("Starting the instance manager and loading instances.");
                    var instanceManager = new InstanceManager();

                    try
                    {
                        instanceManager.LoadInstances();
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(ex, "Could not load instances");
                        return;
                    }

                    System.Windows.Forms.Application.Run(instanceManager);
                }
                else
                {
                    // let the user know the program is already running.
                    _logger.Warn("Instance is already running, exiting.");
                    MessageBox.Show(Resources.ProgramIsAlreadyRunning, Resources.ProgramIsAlreadyRunningCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }
            }
        }
Esempio n. 3
0
        private static void Main()
        {
            ConfigLogger.Instance.LogDebug("Checking to see if there is an instance running.");
            if (IsAlreadyRunning())
            {
                // let the user know the program is already running.
                ConfigLogger.Instance.LogWarning("Instance is already running, exiting.");
                MessageBox.Show(Resources.ProgramIsAlreadyRunning, Resources.ProgramIsAlreadyRunningCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                if (!IsOutlook2003OrHigherInstalled())
                {
                    ConfigLogger.Instance.LogDebug("Outlook is not avaliable or installed.");
                    MessageBox.Show(
                        Resources.Office2000Requirement + Environment.NewLine +
                        Resources.InstallOutlookMsg, Resources.MissingRequirementsCapation, MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    OutlookApp = new Application();
                    OutlookNameSpace = OutlookApp.GetNamespace("MAPI");
                    OutlookFolder = OutlookNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

                    // WORKAROUND: Beginning wih Outlook 2007 SP2, Microsoft decided to kill all outlook instances
                    // when opening and closing an item from the view control, even though the view control was still running.
                    // The only way I've found to work around it and keep the view control from crashing after opening an item,
                    // is to get this global instance of the active explorer and keep it going until the user closes the app.
                    OutlookExplorer = OutlookFolder.GetExplorer();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Resources.ErrorInitializingApp + ' ' + ex, Resources.ErrorCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                System.Windows.Forms.Application.EnableVisualStyles();

                ConfigLogger.Instance.LogInfo("Starting the instance manager and loading instances.");
                var instanceManager = new InstanceManager();
                instanceManager.LoadInstances();

                System.Windows.Forms.Application.Run(instanceManager);
            }
        }