示例#1
0
        /// <summary>
        /// 按优先级获得命令
        /// </summary>
        /// <param name="priority"></param>
        /// <returns></returns>
        public byte[] Get(Priority priority)
        {
            if (this._CmdCache.Count <= 0)
            {
                return(new byte[] {});
            }

            rwLock.AcquireReaderLock(lockTimeOut);
            try
            {
                byte[] data = new byte[] { };
                if (priority == Priority.Normal)
                {
                    data = this._CmdCache[0].Bytes;
                    this._CmdCache.RemoveAt(0);
                }
                else if (priority == Priority.High)
                {
                    ISendCommand cmd = this._CmdCache.FirstOrDefault(c => c.Priority == Priority.High);
                    if (cmd != null)
                    {
                        data = cmd.Bytes;
                        this._CmdCache.Remove(cmd);
                    }
                }
                return(data);
            }
            finally
            {
                rwLock.ReleaseReaderLock();
            }
        }
示例#2
0
        public byte[] Get(string cmdkey)
        {
            if (this._CmdCache.Count <= 0)
            {
                return(new byte[] { });
            }

            rwLock.AcquireReaderLock(lockTimeOut);
            try
            {
                ISendCommand cmd = this._CmdCache.FirstOrDefault(c => c.Key == cmdkey);
                if (cmd == null)
                {
                    return(new byte[] { });
                }
                else
                {
                    byte[] data = cmd.Bytes;
                    this._CmdCache.Remove(cmd);
                    return(data);
                }
            }
            finally
            {
                rwLock.ReleaseReaderLock();
            }
        }
 protected EventHandler(ILogger log, ICorrelation correlation, ISendCommand commandSender, ISendQuery querySender)
 {
     Log            = log;
     Correlation    = correlation;
     _commandSender = commandSender;
     _querySender   = querySender;
 }
示例#4
0
        /// <summary>
        /// Send a command asynchronously.
        /// </summary>
        /// <param name="commad">The command to send.</param>
        /// <returns>A task completion source for the command.</returns>
        public Task <IReceivedCommand> SendAsync(ISendCommand commad)
        {
            var tcs = new CommandWarper();

            if (commad.AckCommandId.HasValue)
            {
                if (this.inflightCommands.ContainsKey(commad.AckCommandId.Value))
                {
                    this.inflightCommands[commad.AckCommandId.Value] = tcs;
                }
                else
                {
                    this.inflightCommands.Add(commad.AckCommandId.Value, tcs);
                }
            }
            else
            {
                tcs.TrySetResult(null);
            }

            try
            {
                this.client.Send(commad);
            }
            catch (Exception ex)
            {
                tcs.Task.TrySetException(ex);
            }

            return(tcs.Task.Task);
        }
示例#5
0
        /// <summary>
        /// Send a command synchronously
        /// </summary>
        /// <param name="command">The command to send.</param>
        /// <returns>The commands response.</returns>
        public IReceivedCommand Send(ISendCommand command)
        {
            Task <IReceivedCommand> t = this.SendAsync(command);

            try
            {
                return(t.Result);
            }
            catch (AggregateException ex)
            {
                throw ex.InnerException;
            }
        }
示例#6
0
        public void Add(ISendCommand cmd)
        {
            rwLock.AcquireWriterLock(lockTimeOut);
            try
            {
                if (cmd == null)
                {
                    return;
                }

                this._CmdCache.Add(cmd);
            }
            finally { rwLock.ReleaseWriterLock(); }
        }
示例#7
0
        /// <summary>
        /// 删除命令
        /// </summary>
        /// <param name="cmdkey"></param>
        public void Remove(string cmdkey)
        {
            if (_CmdCache.Count <= 0)
            {
                return;
            }

            rwLock.AcquireWriterLock(lockTimeOut);
            try
            {
                ISendCommand cmd = this._CmdCache.FirstOrDefault(c => c.Key == cmdkey);
                if (cmd != null)
                {
                    this._CmdCache.Remove(cmd);
                }
            }
            finally { rwLock.ReleaseWriterLock(); }
        }
示例#8
0
        private void miResendCommand_Click(object sender, RoutedEventArgs e)
        {
            QueueItem    itm = ((MenuItem)sender).Tag as QueueItem;
            ISendCommand mgr = _sys.Manager as ISendCommand;

            if (itm.Messages.Length == 1)
            {
                object cmd = mgr.DeserializeCommand(GetQueueItemContent(itm), Type.GetType(itm.Messages[0].AssemblyQualifiedName));

                if (cmd != null)
                {
                    var dlg = new SendCommandWindow(_sys);

                    dlg.Show();
                    dlg.SetCommand(cmd);
                }
            }
            else
            {
                MessageBox.Show("ServiceBus MQ Manager Don't support messages with multiple commands yet.", "Resend Command", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }
        }
示例#9
0
 public Controller(ISendCommand command, IExecuteQuery query) {
   Command = command;
   Query = query;
 }
示例#10
0
 public Controller(ISendCommand command) {
   Command = command;
 }
        public void RecieveCommand(ISendCommand man)
        {
            string cmd = man.GetCmd();

            Console.WriteLine(_name + " recieved command : " + cmd);
        }
 public WeatherForecastController(ILogger <WeatherForecastController> logger, ISendCommand commandSender, Correlation correlation)
 {
     _logger        = logger;
     _commandSender = commandSender;
     _correlation   = correlation;
 }
 public TestEventHandler2(ILogger log, ICorrelation correlation, ISendCommand commandSender, ISendQuery querySender) : base(log, correlation, commandSender, querySender)
 {
 }
示例#14
0
 public CommandService(IRepository <OperationInfo> opertionRepository, ISendCommand netMQManage)
 {
     _opertionRepository = opertionRepository;
     _netMQManage        = netMQManage;
 }
示例#15
0
 public Controller(ISendCommand command, IExecuteQuery query, IServeWebSockets webSockets) {
   Command = command;
   Query = query;
   WebSockets = webSockets;
 }