Ejemplo n.º 1
0
        public static void InitRemoteEngine(string engine)
        {
            EngineManager = new EngineManager(_FrontendConfig,
                                              _MainWindow.UI);
            try {
                try {
                    Console.WriteLine(
                        _("Connecting to remote engine '{0}'..."), engine
                        );
                    EngineManager.Connect(engine);
                    Console.WriteLine(_("Connection established"));
                } catch (Exception ex) {
#if LOG4NET
                    _Logger.Error(ex);
#endif
                    Console.WriteLine(
                        _("Connection failed! Error: {1}"),
                        engine,
                        ex.Message
                        );
                    Environment.Exit(1);
                }

                Session     = EngineManager.Session;
                _UserConfig = EngineManager.UserConfig;
                ConnectEngineToGUI();
            } catch (Exception ex) {
#if LOG4NET
                _Logger.Error(ex);
#endif
                EngineManager.Disconnect();
                throw;
            }
        }
Ejemplo n.º 2
0
        public static void Quit()
        {
            if (_FrontendManager != null)
            {
                _FrontendManager.IsFrontendDisconnecting = true;
                if (IsLocalEngine)
                {
                    try {
                        // we don't shutdown the remote session
                        Session.Shutdown();
                    } catch (Exception ex) {
#if LOG4NET
                        _Logger.Error("Quit(): Exception", ex);
#endif
                    }
                }
                else if (EngineManager != null)
                {
                    EngineManager.Disconnect();
                }
            }

            /*
             * BUG: don't do this, the access to config is lost and the entry will
             * throw an exception then.
             * if (_FrontendManager != null) {
             *  DisconnectEngineFromGUI();
             * }
             */

            MainWindow.Reset();
            Environment.Exit(0);
        }
Ejemplo n.º 3
0
        public static void InitRemoteEngine(string engine)
        {
            var manager = new EngineManager(_FrontendConfig,
                                            _MainWindow.UI);
            try {
                try {
                    Console.WriteLine(
                        _("Connecting to remote engine '{0}'..."), engine
                    );
                    manager.Connect(engine);
                    Console.WriteLine(_("Connection established"));
                } catch (Exception ex) {
            #if LOG4NET
                    _Logger.Error(ex);
            #endif
                    Console.WriteLine(
                        _("Connection failed! Error: {1}"),
                        engine,
                        ex.Message
                    );
                    Environment.Exit(1);
                }

                _Session = manager.Session;
                _UserConfig = manager.UserConfig;
                _EngineVersion = manager.EngineVersion;
                ConnectEngineToGUI();
            } catch (Exception ex) {
            #if LOG4NET
                _Logger.Error(ex);
            #endif
                manager.Disconnect();
                throw;
            }
        }
Ejemplo n.º 4
0
        private void _OnConnectButtonPressed()
        {
            if (_SelectedEngine == null || _SelectedEngine == String.Empty)
            {
                Gtk.MessageDialog md = new Gtk.MessageDialog(this,
                                                             Gtk.DialogFlags.Modal, Gtk.MessageType.Error,
                                                             Gtk.ButtonsType.Close, _("Please select an engine!"));
                md.Run();
                md.Destroy();
                // Re-run the Dialog
                Run();
                return;
            }

            if (_SelectedEngine == "<" + _("Local Engine") + ">")
            {
                Frontend.InitLocalEngine();
                Frontend.ConnectEngineToGUI();
                Destroy();
                return;
            }

            string engine = _SelectedEngine;

            try {
                _EngineManager.Connect(engine);
                var engineVersion   = _EngineManager.EngineVersion;
                var frontendVersion = Frontend.Version;
                if ((engineVersion >= new Version("0.8") &&
                     engineVersion.Major != frontendVersion.Major) ||
                    (engineVersion < new Version("0.8") &&
                     (engineVersion.Major != frontendVersion.Major ||
                      engineVersion.Minor != frontendVersion.Minor)))
                {
                    throw new ApplicationException(String.Format(
                                                       _("Your frontend version ({0}) does not match the engine version ({1})!"),
                                                       Frontend.Version, _EngineManager.EngineVersion));
                }

                Frontend.Session       = _EngineManager.Session;
                Frontend.UserConfig    = _EngineManager.UserConfig;
                Frontend.EngineVersion = _EngineManager.EngineVersion;
                Frontend.ConnectEngineToGUI();
            } catch (Exception ex) {
#if LOG4NET
                _Logger.Error(ex);
#endif
                // clean-up
                try {
                    _EngineManager.Disconnect();
                } catch (Exception disEx) {
#if LOG4NET
                    _Logger.Error(disEx);
#endif
                }

                string error_msg = ex.Message + "\n";
                if (ex.InnerException != null)
                {
                    error_msg += " [" + ex.InnerException.Message + "]\n";
                }

                string msg;
                msg  = _("An error occurred while connecting to the engine!") + "\n\n";
                msg += String.Format(_("Engine URL: {0}") + "\n",
                                     _EngineManager.EngineUrl);

                msg += String.Format(_("Error: {0}"), error_msg);

                Gtk.MessageDialog md = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal,
                                                             Gtk.MessageType.Error, Gtk.ButtonsType.Close, msg);
                md.Run();
                md.Destroy();

                // Re-run the Dialog
                Run();
            }
        }