Ejemplo n.º 1
0
        private void ProcessMethod()
        {
            try
            {
                //if (Process.GetProcessesByName("communicator").Length > 0)//RAM goes up and down when using Process.GetProcessesByName

                //var processList = enumProcesses.ShowAllProcessName();
                //if (processList.Contains("communicator.exe"))

                if (OCAutomation.CheckCommunicatorUpAndRunning())
                {
                    if ((this.ocState == OCStatus.Unknown) || (this.ocState == OCStatus.NotRunning))
                    {
                        this.ocState = OCStatus.Running;
                        this.OnCommunicatorRuning(this, OCStatus.Running);
                    }
                }
                else
                {
                    ocState = OCStatus.NotRunning;

                    if (OnCommunicatorNotRuning != null)
                    {
                        this.OnCommunicatorNotRuning(this, OCStatus.NotRunning);
                    }
                }
            }
            catch (Exception exception)
            {
                logger.Error(exception);
            }

            Thread.Sleep(sleepTime);
        }
Ejemplo n.º 2
0
        private void BindOCAutomationEvent()
        {
            if (isEventBinded)
            {
                return;
            }

            try
            {
                automation = OCAutomation.GetInstance();

                automation.ConnectionStateChanged -= new EventHandler <ConnectionStateChangedEventArgs>(ConnectionStateChanged);
                automation.IMWindowContactAdded   -= new EventHandler <IMWindowContactAddedEventArgs>(IMWindowContactAdded);
                automation.IMWindowCreated        -= new EventHandler <IMWindowCreatedEventArgs>(IMWindowCreated);
                automation.IMWindowDestroyed      -= new EventHandler <IMWindowDestroyedEventArgs>(IMWindowDestroyed);
                automation.Signin  -= new EventHandler <SigninEventArgs>(Signin);
                automation.Signout -= new EventHandler <EventArgs>(Signout);

                automation.ConnectionStateChanged += new EventHandler <ConnectionStateChangedEventArgs>(ConnectionStateChanged);
                automation.IMWindowContactAdded   += new EventHandler <IMWindowContactAddedEventArgs>(IMWindowContactAdded);
                automation.IMWindowCreated        += new EventHandler <IMWindowCreatedEventArgs>(IMWindowCreated);
                automation.IMWindowDestroyed      += new EventHandler <IMWindowDestroyedEventArgs>(IMWindowDestroyed);
                automation.Signin  += new EventHandler <SigninEventArgs>(Signin);
                automation.Signout += new EventHandler <EventArgs>(Signout);

                isEventBinded = true;
            }
            catch (Exception exception)
            {
                isEventBinded = false;
                logger.Error(exception);
            }
        }