Example #1
0
        private void button7_Click(object sender, EventArgs e)
        {
            //const string queueName = @"FormatName:DIRECT=TCP:123.56.129.104\private$\RobOrderQueue";
            const string queueName = @".\private$\RobOrderQueue";

            Model.InputDispatch model = new Model.InputDispatch();
            model.ConstId = 3826;
            model.RoleId  = 11;
            model.UserId  = 26154; //13640  13501 13641

            try
            {
                //将异步消息发往指定的消息队列  
                using (MessageQueue msmq = new MessageQueue(queueName))
                {
                    msmq.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
                    System.Messaging.Message msg = new System.Messaging.Message()
                    {
                        Label = "业务模块异步消息", Body = JsonConvert.SerializeObject(model)
                    };
                    msmq.Send(msg);
                }
            }
            catch (Exception ee)
            {
                //Console.WriteLine(String.Format("消息发送失败,原因是:{0}", ee.Message));
            }
        }
Example #2
0
        private void button8_Click(object sender, EventArgs e)
        {
            IDispatchInterface s = new DispatchService();

            Model.InputDispatch model = new Model.InputDispatch();

            model.ConstId = 7091;
            model.RoleId  = 9;
            model.UserId  = 13640; //13640  13501 13641
            s.InsertDispatch(model);
        }
Example #3
0
        public void Start()
        {
            MessageQueue       myQueue = new MessageQueue(".\\private$\\RobOrderQueue");
            IDispatchInterface servier = new DispatchService();

            while (true)
            {
                //连接到本地队列
                System.Messaging.Message message   = myQueue.Receive();
                XmlMessageFormatter      formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

                message.Formatter = formatter;
                string jsonData           = message.Body.ToString();
                Model.InputDispatch model = JsonConvert.DeserializeObject <Model.InputDispatch>(jsonData);

                servier.InsertDispatch(model);
            }
        }
Example #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                Createqueue(@".\private$\RobOrderQueue");
                System.Messaging.Message myMessage = new System.Messaging.Message();

                Model.InputDispatch model = new Model.InputDispatch();
                model.ConstId = 7091;
                model.RoleId  = 9;
                model.UserId  = 13641;

                myMessage.Body      = JsonConvert.SerializeObject(model);
                myMessage.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

                //发送消息到队列中
                myQueue.Send(myMessage);
            }
            catch (Exception ex)
            {
            }
        }