Exemple #1
0
        public HBRelogHelper()
        {
            Instance = this;
            try
            {
                AppDomain.CurrentDomain.ProcessExit        += CurrentDomainProcessExit;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

                HbProcId     = Process.GetCurrentProcess().Id;
                _pipeFactory = new ChannelFactory <IRemotingApi>(new NetNamedPipeBinding(),
                                                                 new EndpointAddress("net.pipe://localhost/HBRelog/Server"));

                HBRelogRemoteApi = _pipeFactory.CreateChannel();
                //instead of spawning a new thread use the GUI one.
                Application.Current.Dispatcher.Invoke(new Action(
                                                          delegate
                {
                    _monitorTimer          = new DispatcherTimer();
                    _monitorTimer.Tick    += MonitorTimerCb;
                    _monitorTimer.Interval = TimeSpan.FromSeconds(10);
                    _monitorTimer.Start();
                }));
                IsConnected = HBRelogRemoteApi.Init(HbProcId);
                if (IsConnected)
                {
                    Logging.Write("HBRelogHelper: Connected with HBRelog");
                    CurrentProfileName = HBRelogRemoteApi.GetCurrentProfileName(HbProcId);
                }
                else
                {
                    Logging.Write("HBRelogHelper: Could not connect to HBRelog");
                }
            }
            catch (Exception ex)
            {
                // fail silently.
                Logging.Write(Colors.Red, ex.ToString());
            }
            // since theres no point of this plugin showing up in plugin list lets just throw an exception.
            // new HB doesn't catch exceptions
            //  throw new Exception("Ignore this exception");
        }
Exemple #2
0
        public HBRelogHelper()
        {
            Instance = this;
            try
            {
                AppDomain.CurrentDomain.ProcessExit        += CurrentDomainProcessExit;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

                HbProcId = Process.GetCurrentProcess().Id;
                var pipeInfoPath = Path.Combine(Utilities.AssemblyDirectory, "Plugins", "HBRelogHelper", "pipeName.txt");
                var pipeName     = File.ReadAllText(pipeInfoPath);
                _pipeFactory = new ChannelFactory <IRemotingApi>(new NetNamedPipeBinding(),
                                                                 new EndpointAddress($"net.pipe://localhost/{pipeName}/Server"));
                HBRelogRemoteApi = _pipeFactory.CreateChannel();

                IsConnected = HBRelogRemoteApi.Init(HbProcId);
                if (IsConnected)
                {
                    Log("Connected with HBRelog");
                    //instead of spawning a new thread use the GUI one.
                    Application.Current.Dispatcher.Invoke(new Action(
                                                              delegate
                    {
                        _monitorTimer          = new DispatcherTimer();
                        _monitorTimer.Tick    += MonitorTimerCb;
                        _monitorTimer.Interval = TimeSpan.FromSeconds(10);
                        _monitorTimer.Start();
                    }));

                    CurrentProfileName = HBRelogRemoteApi.GetCurrentProfileName(HbProcId);
                }
                else
                {
                    Log("Could not connect to HBRelog");
                }
            }
            catch (Exception ex)
            {
                // fail silently.
                Logging.Write(Colors.Red, ex.ToString());
            }
        }
Exemple #3
0
        public override void OnStart()
        {
            // Let QuestBehaviorBase do basic initializaion of the behavior, deal with bad or deprecated attributes,
            // capture configuration state, install BT hooks, etc.  This will also update the goal text.
            var isBehaviorShouldRun = OnStart_QuestBehaviorCore();

            // If the quest is complete, this behavior is already done...
            // So we don't want to falsely inform the user of things that will be skipped.
            if (isBehaviorShouldRun)
            {
                HbProcId     = System.Diagnostics.Process.GetCurrentProcess().Id;
                _pipeFactory = new ChannelFactory <IRemotingApi>(new NetNamedPipeBinding(),
                                                                 new EndpointAddress("net.pipe://localhost/HBRelog/Server"));
                try
                {
                    HBRelogRemoteApi = _pipeFactory.CreateChannel();

                    IsConnected = HBRelogRemoteApi.Init(HbProcId);
                    if (IsConnected)
                    {
                        QBCLog.DeveloperInfo("Connected to HBRelog Server");
                        CurrentProfileName = HBRelogRemoteApi.GetCurrentProfileName(HbProcId);
                        QBCLog.DeveloperInfo(string.Format("HBRelog Current Profile: {0}", CurrentProfileName));
                    }
                    else
                    {
                        QBCLog.Error("Could Not Connect to HBRelog Server at net.pipe://localhost/HBRelog/Server");
                    }
                }
                catch (Exception ex)
                {
                    QBCLog.Error(
                        "Could not make endpoint connection to HBRelog Application.  You may not be running under HBRelog. Ignoring");
                    CurrentProfileName = string.Empty;
                }
            }
        }