Esempio n. 1
0
        static Core()
        {
            Ready    = false;
            mutex    = new System.Threading.Mutex(false, "MASGAU");
            settings = new Settings.Settings();

            try {
                if (!mutex.WaitOne(1000))
                {
                    //                    MVC.Translator.TranslatingMessageHandler.SendError("NoMultipleInstances");
                    MutexAlreadyTaken = true;
                    switch (AppMode)
                    {
                    case MASGAU.AppMode.Restore:
                        //SendArchivesToMainWindow();
                        break;

                    case MASGAU.AppMode.Main:
                        OpenMainWindow();
                        System.Windows.Forms.Application.Exit();
                        return;

                    default:
                        throw new NotImplementedException(AppMode.ToString());
                    }
                }
            } catch (AbandonedMutexException) {
                Console.Out.Write("Boo-hoo, I'm an abandoned mutex. Suck it up.");
            } catch (Exception) {
                throw new TranslateableException("NoMultipleInstances");
            }



            Assembly temp = Assembly.GetEntryAssembly();

            ExecutableName = temp.Location;


            CommunicationWatcher                     = new FileSystemWatcher();
            CommunicationWatcher.Path                = Core.settings.SourcePath;
            CommunicationWatcher.Changed            += new FileSystemEventHandler(CommunicationWatcher_Changed);
            CommunicationWatcher.Created            += new FileSystemEventHandler(CommunicationWatcher_Changed);
            CommunicationWatcher.EnableRaisingEvents = true;


            email   = new Email.EmailHandler(Core.settings.EmailSender, Core.submission_email);
            startup = new StartupHelper("MASGAU", Core.ExecutableName);
            Ready   = true;
        }
Esempio n. 2
0
        static Core()
        {
            Ready = false;
            mutex = new System.Threading.Mutex(false, "MASGAU");
            settings = new Settings.Settings();

            try {
                if (!mutex.WaitOne(1000)) {
                    //                    MVC.Translator.TranslatingMessageHandler.SendError("NoMultipleInstances");
                    MutexAlreadyTaken = true;
                    switch (AppMode) {
                        case MASGAU.AppMode.Restore:
                            //SendArchivesToMainWindow();
                            break;
                        case MASGAU.AppMode.Main:
                            OpenMainWindow();
                            System.Windows.Forms.Application.Exit();
                            return;
                        default:
                            throw new NotImplementedException(AppMode.ToString());
                    }
                }
            } catch (AbandonedMutexException) {
                Console.Out.Write("Boo-hoo, I'm an abandoned mutex. Suck it up.");
            } catch (Exception) {
                throw new TranslateableException("NoMultipleInstances");

            }

            Assembly temp = Assembly.GetEntryAssembly();

            ExecutableName = temp.Location;

            CommunicationWatcher = new FileSystemWatcher();
            CommunicationWatcher.Path = Core.settings.SourcePath;
            CommunicationWatcher.Changed += new FileSystemEventHandler(CommunicationWatcher_Changed);
            CommunicationWatcher.Created += new FileSystemEventHandler(CommunicationWatcher_Changed);
            CommunicationWatcher.EnableRaisingEvents = true;

            email = new Email.EmailHandler(Core.settings.EmailSender, Core.submission_email);
            startup = new StartupHelper("MASGAU", Core.ExecutableName);
            Ready = true;
        }