Пример #1
0
        private bool SaveOld()
        {
            try
            {
                if (_lastSelectedIndex == -1 || _lastSelectedIndex >= _modifiedConfiguration.subscribes.Count)
                {
                    return(true);
                }
                var item = new SubscribeConfig {
                    name = NameTextBox.Text, url = UrlTextBox.Text, useProxy = UseProxyCheckBox.Checked
                };
                if (!oldNames.ContainsKey(_lastSelectedIndex))
                {
                    oldNames.Add(_lastSelectedIndex, _modifiedConfiguration.subscribes[_lastSelectedIndex].name);
                }
                else
                {
                    oldNames[_lastSelectedIndex] = _modifiedConfiguration.subscribes[_lastSelectedIndex].name;
                }
                _modifiedConfiguration.subscribes[_lastSelectedIndex] = item;

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(false);
        }
Пример #2
0
        public SubscribeConfig GetSubscribe(int index)
        {
            List <SubscribeConfig> list      = new List <SubscribeConfig>();
            SubscribeConfig        Subscribe = null;

            if (_config.subscribe.Count - 1 >= index)
            {
                Subscribe = _config.subscribe[index];
            }
            return(Subscribe);
        }
Пример #3
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var item = new SubscribeConfig {
                name = "New"
            };

            _modifiedConfiguration.subscribes.Add(item);
            LoadConfiguration(_modifiedConfiguration);
            SubscribeListBox.SelectedIndex = _modifiedConfiguration.subscribes.Count - 1;
            _lastSelectedIndex             = SubscribeListBox.SelectedIndex;
        }
Пример #4
0
        /// <summary>
        /// Subscribes the specified queue name.
        /// </summary>
        /// <param name="queueName">Name of the queue.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="configAction">The configuration action.</param>
        /// <returns></returns>
        public virtual IFluentRabbit Subscribe(string queueName, Action <BasicDeliverEventArgs> callback, Action <SubscribeConfig> configAction = null)
        {
            return(TryCatch_Trace(MethodBase.GetCurrentMethod(),
                                  () =>
            {
                var config = new SubscribeConfig();
                configAction?.Invoke(config);

                Subscribe(queueName, callback, config);
            }));
        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            string          title     = "";
            SubscribeConfig subscribe = new SubscribeConfig();

            textUrl.Text   = defaultUrl;
            textGroup.Text = "";

            title = textGroup.Text + " - " + textUrl.Text;

            subscribe.title = textGroup.Text;
            subscribe.url   = textUrl.Text;
            SubscribeList.Add(subscribe);

            SubscribeListBox.Items.Add(title);
            SubscribeListBox.SelectedIndex = SubscribeListBox.Items.Count - 1;
        }
        private void SubscribeListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int SelectedIndex = SubscribeListBox.SelectedIndex;

            if (SelectedIndex == -1)
            {
                return;
            }

            SubscribeConfig subscribe = SubscribeList[SelectedIndex];

            if (subscribe == null)
            {
                return;
            }
            textUrl.Text = subscribe.url;

            textGroup.Text = subscribe.title;
        }
Пример #7
0
        public List <SubscribeConfig> ListSubscribe()
        {
            List <SubscribeConfig> list = new List <SubscribeConfig>();

            try
            {
                foreach (var item in _config.subscribe)
                {
                    var buf = new SubscribeConfig();
                    buf.title = item.title;
                    buf.url   = item.url;
                    list.Add(buf);
                }
            }
            catch
            {
                return(list);
            }
            return(list);
        }
Пример #8
0
        public void AddSubscribe(string title, string url)
        {
            bool isMatch = false;

            foreach (var item in _config.subscribe)
            {
                if (item.url == url)
                {
                    var index = _config.subscribe.IndexOf(item);
                    _config.subscribe[index].title = title;
                    isMatch = true;
                    break;
                }
            }

            if (!isMatch)
            {
                SubscribeConfig subscribe = new SubscribeConfig();
                subscribe.title = title;
                subscribe.url   = url;
                _config.subscribe.Add(subscribe);
            }
            Configuration.Save(_config);
        }
Пример #9
0
        /// <summary>
        /// Subscribes the specified queue name.
        /// </summary>
        /// <param name="queueName">Name of the queue.</param>
        /// <param name="callback">The callback.</param>
        /// <param name="config">The configuration.</param>
        /// <returns></returns>
        public virtual IFluentRabbit Subscribe(string queueName, Action <BasicDeliverEventArgs> callback, SubscribeConfig config)
        {
            return(TryCatch_Trace(MethodBase.GetCurrentMethod(),
                                  () =>
            {
                config.ThrowExceptionIfNull <ArgumentNullException>(nameof(config));
                RabbitMqClient.Model.ThrowExceptionIfNull <ModelIsNullException>();

                var consumer = new EventingBasicConsumer(RabbitMqClient.Model);
                consumer.Received += (ch, ea) =>
                {
                    callback?.Invoke(ea);

                    if (!config.AutoAck)
                    {
                        RabbitMqClient.Model.BasicAck(ea.DeliveryTag, false);
                        FireTraceOccured(MethodBase.GetCurrentMethod(), "BasicAck called.");
                    }

                    FireTraceOccured(MethodBase.GetCurrentMethod(), "Message Received.");
                };

                config.ConsumerTag = RabbitMqClient.Model.BasicConsume(queueName, config.AutoAck, config.ConsumerTag, config.NoLocal, config.Exclusive, config.Arguments, consumer);
            }));
        }
Пример #10
0
 public SubscribeCommand()
 {
     config               = Configuration.GetConfig <SubscribeConfig>();
     YCM.OnNewCar        += car => OnNewCar(CarType.Bandori, car);
     CarHandler.OnNewCar += car => OnNewCar(CarType.Sekai, car);
 }