예제 #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");
        }
예제 #2
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");
        }
예제 #3
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());
            }
        }