protected void DoEventManagerDispatchCommandException(IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     if (OnEventManagerDispatchCommandException (eventManager, ex, command))
     {
         RaiseEventManagerDispatchCommandException (EMDispatchCommandException, eventManager, ex, command);
     }
 }
 protected void RaiseEventManagerDispatchCommandException(EventManagerDispatchCommandExceptionHandler handler, IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     if (handler != null)
     {
         handler (eventManager, ex, command);
     }
 }
示例#3
0
        private void cmd_SaveCompleted(IQSimpleCommand command, ILQHsmMemento memento)
        {
            SaveCmd cmd = (SaveCmd)command;

            using (StreamWriter sw = new StreamWriter(cmd.FileName))
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(sw.BaseStream, memento);
            }
        }
示例#4
0
 protected void Execute(IQSimpleCommand cmd)
 {
     try
     {
         cmd.Execute();
     }
     catch (Exception ex)
     {
         DoEventManagerDispatchCommandException(this, ex, cmd);
     }
 }
示例#5
0
 public void AsyncDispatch(IQSimpleCommand cmd)
 {
     lock (_QLock)
     {
         if (!(cmd is HsmEventHolder))
         {
             if (!(cmd is SimpleTransactionalCmd))
             {
                 cmd = new SimpleTransactionalCmd(cmd);
             }
         }
         _BottomQueue.Enqueue(cmd);
     }
     _WaitHandle.Set();
 }
 public void AsyncDispatch(IQSimpleCommand cmd)
 {
     lock (_QLock)
     {
         if (!(cmd is HsmEventHolder))
         {
             if (!(cmd is SimpleTransactionalCmd))
             {
                 cmd = new SimpleTransactionalCmd (cmd);
             }
         }
         _BottomQueue.Enqueue (cmd);
     }
     _WaitHandle.Set ();
 }
示例#7
0
        public bool PollOne()
        {
front:
            int count;
            object queueEntry = null;

            lock (_QLock)
            {
                count = _FrontStack.Count;
                if (count > 0)
                {
                    queueEntry = _FrontStack.Pop();
                }
                else
                {
                    count = _BottomQueue.Count;
                    if (count > 0)
                    {
                        queueEntry = _BottomQueue.Dequeue();
                    }
                }
            }

            if (count > 0)
            {
                if (queueEntry == null)
                {
                    Logger.Error("---- QueueEntry is null! ----");
                    goto front;
                }

                IQSimpleCommand command = queueEntry as IQSimpleCommand;
                if (command == null)
                {
                    Logger.Error("---- Command is null! ----");
                    goto front;
                }

                Execute(command);
                return(true);
            }
            return(false);
        }
示例#8
0
 private void cmd_RestoreCompleted(IQSimpleCommand command, ILQHsmMemento memento)
 {
     DoStateChange(_Book);
 }
 public SimpleTransactionalCmd(IQSimpleCommand cmd)
 {
     _Cmd = cmd;
     _Transaction = QEvent.GetThreadTransaction ();
 }
 protected virtual bool OnEventManagerDispatchCommandException(IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     return(true);
 }
 private void _EventManager_EMDispatchCommandException(IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     DoEventManagerDispatchCommandException (eventManager, ex, command);
 }
 protected void DoEventManagerDispatchCommandException(IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     if (OnEventManagerDispatchCommandException(eventManager, ex, command))
     {
         RaiseEventManagerDispatchCommandException(EMDispatchCommandException, eventManager, ex, command);
     }
 }
 private void _EventManager_EMDispatchCommandException(IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     DoEventManagerDispatchCommandException(eventManager, ex, command);
 }
 protected void RaiseEventManagerDispatchCommandException(EventManagerDispatchCommandExceptionHandler handler, IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     if (handler != null)
     {
         handler(eventManager, ex, command);
     }
 }
示例#15
0
 public SimpleTransactionalCmd(IQSimpleCommand cmd)
 {
     _Cmd         = cmd;
     _Transaction = QEvent.GetThreadTransaction();
 }
示例#16
0
 private void _EventManager_EMDispatchCommandException(IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     Logger.Error(ex, command.ToString());
 }
 protected virtual bool OnEventManagerDispatchCommandException(IQEventManager eventManager, Exception ex, IQSimpleCommand command)
 {
     return true;
 }
 protected void Execute(IQSimpleCommand cmd)
 {
     try
     {
         cmd.Execute ();
     }
     catch (Exception ex)
     {
         DoEventManagerDispatchCommandException (this, ex, cmd);
     }
 }