Пример #1
0
 public ActionExecuteResult(ActionResultEventArgs resultEventArgs, ActionFaultEventArgs faultEventArgs)
 {
     this._resultEventArgs = resultEventArgs;
     this._faultEventArgs = faultEventArgs;
 }
Пример #2
0
        /// <summary>
        /// 复位运行时数据。
        /// </summary>
        private void ResetRuntimeData()
        {
            try
            {
                _activateTime = null;
                _deactivateTime = null;

                if (timeoutObserver != null)
                {
                    timeoutObserver.Stop();
                    timeoutObserver = null;
                }

                resultEventArgs = null;
                faultEventArgs = null;
            }
            catch
            {
                //不处理。
            }
        }
Пример #3
0
 protected override void ClearManagedResources()
 {
     _activateTime = null;
     _deactivateTime = null;
     resultEventArgs = null;
     faultEventArgs = null;
 }
Пример #4
0
 /// <summary>
 /// 内部失败。可以覆盖并扩展。
 /// </summary>
 /// <param name="eventArgs"></param>
 protected virtual void InnerFault(ActionFaultEventArgs eventArgs)
 {
     //交由子类处理。
 }
Пример #5
0
        /// <summary>
        /// 失败。因为存在状态判断,未防止子类覆盖后出现状态漏判,故不允许子类覆盖改方法。
        /// </summary>
        /// <param name="eventArgs">事件参数</param>
        public virtual void Fault(ActionFaultEventArgs eventArgs)
        {
            if (_state == ActionState.Processing || _state == ActionState.Hangup)
            {
                _state = ActionState.Fault;
                _deactivateTime = DateTime.Now;

                if (timeoutObserver != null)
                {
                    timeoutObserver.Stop();
                    timeoutObserver = null;
                }

                faultEventArgs = eventArgs;

                if (light != null)
                {
                    light.TurnOn();
                }

                if (OnFault != null)
                {
                    OnFault(this, faultEventArgs);
                }

                InnerFault(eventArgs);
            }
        }