public ServerConnectionParamControl(ServiceBusMQ.Manager.ServerConnectionParameter p, object value = null)
        {
            InitializeComponent();

              Param = p;
              Text.Content = p.DisplayName + ":";

              if( p.Type == ServiceBusMQ.Manager.ParamType.String ) {
            cbValue.Visibility = System.Windows.Visibility.Hidden;

            tbValue.Init(value ?? p.DefaultValue, typeof(string), p.Optional);

            tbValue.ValueChanged += tbValue_ValueChanged;
            tbValue.LostFocus += tbValue_LostFocus;

              } else if( p.Type == ServiceBusMQ.Manager.ParamType.Bool ) {

            tbValue.Visibility = System.Windows.Visibility.Hidden;

            cbValue.IsChecked = ((bool)value);
            cbValue.Checked += cbValue_Checked;
            cbValue.Unchecked += cbValue_Unchecked;
              }

              Req.Visibility = p.Optional ? System.Windows.Visibility.Hidden : System.Windows.Visibility.Visible;
        }
        public ComplexDataTemplateControl(Type type, ServiceBusMQ.DataTemplateManager tempMgr)
        {
            InitializeComponent();

              _type = type;
              _tempMgr = tempMgr;

              BindItems();
        }
Ejemplo n.º 3
0
    /// <summary>
    ///     May throw a timeout exception if a message with the given id cannot be found.
    /// </summary>
    /// <param name="seqNumber"></param>
    public void ReturnMessageToSourceQueue(QueueClient queue, ServiceBusMQ.Model.QueueItem itm) {
      try {

        var msg = FindMessage(queue, itm); //queue.Receive((long)itm.MessageQueueItemId);

        string originQueueName = GetOriginQueue(msg);
        if( originQueueName.IsValid() ) {
          var q = GetInputQueue(originQueueName);
          q.Send(msg);
          
          msg.Complete();
        } else _log.Trace("No valid origin Queue for Message, " + itm.Id);

      } catch( Exception ex ) {
        _log.Trace(ex.ToString());
      }
    }
Ejemplo n.º 4
0
    /// <summary>
    ///     May throw a timeout exception if a message with the given id cannot be found.
    /// </summary>
    /// <param name="seqNumber"></param>
    public void ReturnMessageToSourceQueue(QueueClient queue, QueueClient deadLetterQueue, ServiceBusMQ.Model.QueueItem itm) {
      //var rec = MessagingFactory.Create()
      //rec.
      
      BrokeredMessage message;
      try {
        
        message = deadLetterQueue.Receive((long)itm.MessageQueueItemId);
      } catch(Exception e) { 
      
        message = queue.Receive((long)itm.MessageQueueItemId);
      }

        //message.Abandon();
        queue.Send(message.Clone());


      //} catch( Exception ex ) {
      //  TryFindMessage(itm);
      //}
    }
Ejemplo n.º 5
0
        private void sys_ItemsChanged(object sender, ServiceBusMQ.ItemsChangedEventArgs e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => {

            EnableListView();

            // Update button labels
            UpdateButtonLabel(btnCmd);
            UpdateButtonLabel(btnEvent);
            UpdateButtonLabel(btnMsg);
            UpdateButtonLabel(btnError);

            // Update List View
            lock( _sys.ItemsLock ) {
              lbItems.ItemsSource = _sys.Items;
              lbItems.Items.Refresh();

              if( !lbItems.IsEnabled )
            lbItems.IsEnabled = true;

            }

            SetupContextMenu();

            if( e.Origin == ItemChangeOrigin.Queue )
              ShowActivityTrayIcon();

            // Show Window
            if( _sys.Config.ShowOnNewMessages && !_firstLoad && !this.IsVisible ) {
              this.Show();

              if( !Topmost ) {
            Topmost = true;
            Thread.Sleep(100);
            Topmost = false;
              }
            }

            _firstLoad = false;

              }));
        }
Ejemplo n.º 6
0
        public void ReturnMessageToSourceQueue(string fromQueueName, ServiceBusMQ.Model.QueueItem itm)
        {
            var queue = QueueClient.CreateFromConnectionString(ConnectionString, fromQueueName);
              var deadLetterQueue = QueueClient.CreateFromConnectionString(ConnectionString, QueueClient.FormatDeadLetterPath(fromQueueName), ReceiveMode.ReceiveAndDelete);

              ReturnMessageToSourceQueue(queue, deadLetterQueue, itm);
        }
Ejemplo n.º 7
0
        private void TryFindMessage(ServiceBusMQ.Model.QueueItem itm)
        {
            //if( ex.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout ) {

              //  foreach( var m in queue.GetAllMessages() ) {
              //    var tm = MsmqUtilities.Convert(m);

              //    string originalId = null;

              //    if( tm.Headers.ContainsKey(Headers.MessageId) ) {
              //      originalId = tm.Headers[Headers.MessageId];
              //    }

              //    if( string.IsNullOrEmpty(originalId) && tm.Headers.ContainsKey(Headers.CorrelationId) ) {
              //      originalId = tm.Headers[Headers.CorrelationId];
              //    }

              //    if( string.IsNullOrEmpty(originalId) || seqNumber != originalId ) {
              //      continue;
              //    }

              //    Console.WriteLine("Found message - going to return to queue.");

              //    using( var q = GetInputQueue(itm.Headers[FaultsHeaderKeys.FailedQ]) ) {
              //      q.Send(m);
              //    }

              //    queue.ReceiveByLookupId(MessageLookupAction.Current, m.LookupId,
              //        MessageQueueTransactionType.Automatic);

              //  }

              //  Console.WriteLine("Success.");

              //  return;
              //}
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     May throw a timeout exception if a message with the given id cannot be found.
        /// </summary>
        /// <param name="seqNumber"></param>
        public void ReturnMessageToSourceQueue(QueueClient queue, QueueClient deadLetterQueue, ServiceBusMQ.Model.QueueItem itm)
        {
            try {
            var message = deadLetterQueue.Receive((long)itm.MessageQueueItemId);

            message.Abandon();
            //queue.Send(message.Clone());

              } catch( Exception ex ) {
            TryFindMessage(itm);
              }
        }
        private void MessageMgr_ItemsChanged(object sender, ServiceBusMQ.ItemsChangedEventArgs e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => {

            // Update button labels
            UpdateButtonLabel(btnCmd);
            UpdateButtonLabel(btnEvent);
            UpdateButtonLabel(btnMsg);
            UpdateButtonLabel(btnError);

            // Update List View
            lbItems.ItemsSource = _sys.Items;
            lbItems.Items.Refresh();

            if( e.Origin == ItemChangeOrigin.Queue )
              ShowActivityTrayIcon();

            // Show Window
            if( _sys.Config.ShowOnNewMessages && !_firstLoad && !this.IsVisible )
              this.Show();

            _firstLoad = false;

              }));
        }
Ejemplo n.º 10
0
    public void ReturnMessageToSourceQueue(string fromQueueName, ServiceBusMQ.Model.QueueItem itm) {
      var queue = GetInputQueue(fromQueueName);

      ReturnMessageToSourceQueue(queue, itm);
    }
Ejemplo n.º 11
0
    private string GetOriginQueue(ServiceBusMQ.Model.QueueItem msg) {
      var name = string.Empty;

      if( msg.Headers.ContainsKey(KEY_FailedQueue) )
        name = msg.Headers[KEY_FailedQueue] as string;

      if( !string.IsNullOrEmpty(name) ) {
        var i = name.IndexOf('@');

        if( i > 0 )
          name = name.Substring(0, i);
      }

      return name;
    }
Ejemplo n.º 12
0
        /// <summary>
        ///     May throw a timeout exception if a message with the given id cannot be found.
        /// </summary>
        /// <param name="seqNumber"></param>
        public void ReturnMessageToSourceQueue(QueueClient queue, ServiceBusMQ.Model.QueueItem itm)
        {
            try {
            var message = queue.Receive((long)itm.MessageQueueItemId);

            string failedQ = null;
            if( itm.Headers.ContainsKey(KEY_FailedQueue) ) {
              failedQ = itm.Headers[KEY_FailedQueue];
            }

            if( string.IsNullOrEmpty(failedQ) ) {
              Console.WriteLine("ERROR: Message does not have a header indicating from which queue it came. Cannot be automatically returned to queue.");
              return;
            }

            var q = GetInputQueue(failedQ);
            q.Send(message);

              } catch( Exception ex ) {
              //} catch( MessageQueueException ex ) {
            TryFindMessage(itm);
              }
        }