Example #1
0
        //The event-invoking method that derived classes can override.


        public virtual void OnStatusChanged(RobotWorkerStatusChangeEventArgs e)
        {
            this._Status = e.RobotWorkerStatus;
            // Make a temporary copy of the event to avoid possibility of
            // a race condition if the last subscriber unsubscribes
            // immediately after the null check and before the event is raised.
            EventHandler <RobotWorkerStatusChangeEventArgs> handler = StatusChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Example #2
0
        void FormRobotWorker_StatusChanged(object sender, RobotWorkerStatusChangeEventArgs e)
        {
            string Message;

            if (e.RobotWorkerStatus == RobotWorker.RobotWorkerStatus.RunningJob && e.CurrentJob != null)
            {
                Message = string.Format("{0}-{1}({2}), parameters:{3}) ,{4}", e.RobotWorkerStatus, e.CurrentJob.ScriptName, e.CurrentJob.UniqueID, e.CurrentJob.RobotJobDisplayParameters, e.Message);
            }
            else
            {
                Message = string.Format("{0} - {1}", e.RobotWorkerStatus, e.Message);
            }
            Notify(new LoggingEntery("OctoTipPlus Appilcation", "RobotWorker", "RunningJob", Message, LoggingEntery.EnteryTypes.Debug));


            if (e.CurrentJob == null)
            {
                RuningJob = null;
                UpdateRunningJob();
            }
            else
            {
                RuningJob = e.CurrentJob;
                UpdateRunningJob();
            }

            bool buttonPauseEnabled;
            bool buttonStartEnabled;
            bool buttonStopEnabled;

            string textBoxRuningJobStatusText = string.Empty;
            string textRobotWorkerStatusText  = string.Empty;

            textRobotWorkerStatusText = RobotWorker.GetRobotWorkerStatusText(e.RobotWorkerStatus);

            switch (e.RobotWorkerStatus)
            {
            case (RobotWorker.RobotWorkerStatus.Stopped):
                buttonPauseEnabled = false;
                buttonStartEnabled = true;
                buttonStopEnabled  = false;
                break;

            case (RobotWorker.RobotWorkerStatus.Paused):
                buttonPauseEnabled = false;
                buttonStartEnabled = true;
                buttonStopEnabled  = true;
                break;

            case (RobotWorker.RobotWorkerStatus.Stopping):
                buttonPauseEnabled = false;
                buttonStartEnabled = false;
                buttonStopEnabled  = false;
                break;

            case (RobotWorker.RobotWorkerStatus.Pausing):
                buttonPauseEnabled = false;
                buttonStartEnabled = false;
                buttonStopEnabled  = false;
                break;

            default:
                buttonPauseEnabled = true;
                buttonStartEnabled = false;
                buttonStopEnabled  = true;
                break;
            }

            if (!this.IsDisposed)
            {
                MethodInvoker buttonPauseInvoker = delegate
                {
                    buttonRobotPause.Enabled = buttonPauseEnabled;
                };
                buttonRobotPause.BeginInvoke(buttonPauseInvoker);

                MethodInvoker buttonStartInvoker = delegate
                {
                    buttonRobotStart.Enabled = buttonStartEnabled;
                };
                buttonRobotStart.BeginInvoke(buttonStartInvoker);

                MethodInvoker buttonStopInvoker = delegate
                {
                    buttonRobotStop.Enabled = buttonStopEnabled;
                };
                buttonRobotStop.BeginInvoke(buttonStopInvoker);

                MethodInvoker textBoxRuningJobStatusInvoker = delegate
                {
                    RunningJobStatus.Text = textBoxRuningJobStatusText;
                };
                RunningJobStatus.BeginInvoke(textBoxRuningJobStatusInvoker);

                MethodInvoker textRobotWorkerStatusInvoker = delegate
                {
                    RobotStatuslabel.Text = textRobotWorkerStatusText;
                };
                RunningJobStatus.BeginInvoke(textRobotWorkerStatusInvoker);
            }
        }
Example #3
0
 //The event-invoking method that derived classes can override.
 public virtual void OnStatusChanged(RobotWorkerStatusChangeEventArgs e)
 {
     this._Status = e.RobotWorkerStatus;
     // Make a temporary copy of the event to avoid possibility of
     // a race condition if the last subscriber unsubscribes
     // immediately after the null check and before the event is raised.
     EventHandler<RobotWorkerStatusChangeEventArgs> handler = StatusChanged;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Example #4
0
        void FormRobotWorker_StatusChanged(object sender, RobotWorkerStatusChangeEventArgs e)
        {
            string Message;
            if(e.RobotWorkerStatus==RobotWorker.RobotWorkerStatus.RunningJob && e.CurrentJob!=null)
            {
                Message  = string.Format("{0}-{1}({2}), parameters:{3}) ,{4}" , e.RobotWorkerStatus,e.CurrentJob.ScriptName,e.CurrentJob.UniqueID,e.CurrentJob.RobotJobDisplayParameters,e.Message);
            }
            else
            {

                Message  = string.Format("{0} - {1}" , e.RobotWorkerStatus,e.Message);
            }
            Notify(new LoggingEntery("OctoTipPlus Appilcation","RobotWorker","RunningJob",Message,LoggingEntery.EnteryTypes.Debug));

            if (e.CurrentJob == null)
            {
                RuningJob = null;
                UpdateRunningJob();
            }
            else
            {

                RuningJob = e.CurrentJob;
                UpdateRunningJob();
            }

            bool buttonPauseEnabled ;
            bool buttonStartEnabled ;
            bool buttonStopEnabled;

            string textBoxRuningJobStatusText = string.Empty;
            string textRobotWorkerStatusText = string.Empty;

            textRobotWorkerStatusText = RobotWorker.GetRobotWorkerStatusText(e.RobotWorkerStatus);

            switch(e.RobotWorkerStatus)
            {
                case(RobotWorker.RobotWorkerStatus.Stopped):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = true;
                    buttonStopEnabled = false;
                    break;
                case(RobotWorker.RobotWorkerStatus.Paused):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = true;
                    buttonStopEnabled = true;
                    break;
                case(RobotWorker.RobotWorkerStatus.Stopping ):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = false;
                    buttonStopEnabled = false;
                    break;
                case( RobotWorker.RobotWorkerStatus.Pausing):
                    buttonPauseEnabled = false;
                    buttonStartEnabled = false;
                    buttonStopEnabled = false;
                    break;
                default:
                    buttonPauseEnabled = true;
                    buttonStartEnabled = false;
                    buttonStopEnabled = true;
                    break;

            }

            if (!this.IsDisposed)
            {
                MethodInvoker buttonPauseInvoker = delegate
                {
                    buttonRobotPause.Enabled = buttonPauseEnabled ;
                };
                buttonRobotPause.BeginInvoke(buttonPauseInvoker);

                MethodInvoker buttonStartInvoker = delegate
                {
                    buttonRobotStart.Enabled = buttonStartEnabled ;
                };
                buttonRobotStart.BeginInvoke(buttonStartInvoker);

                MethodInvoker buttonStopInvoker = delegate
                {
                    buttonRobotStop.Enabled = buttonStopEnabled ;
                };
                buttonRobotStop.BeginInvoke(buttonStopInvoker);

                MethodInvoker textBoxRuningJobStatusInvoker = delegate
                {
                    RunningJobStatus.Text = textBoxRuningJobStatusText ;
                };
                RunningJobStatus.BeginInvoke(textBoxRuningJobStatusInvoker);

                MethodInvoker textRobotWorkerStatusInvoker = delegate
                {
                    RobotStatuslabel.Text = textRobotWorkerStatusText ;
                };
                RunningJobStatus.BeginInvoke(textRobotWorkerStatusInvoker);
            }
        }