posts - 124,  comments - 29,  trackbacks - 0

  private void MQRecieve()   //MQ接收函数
        {
            try
            {
                bool isWebServiceSuccess = WebServiceStart(); //通过WebService传请求条件
                if (isWebServiceSuccess == false)
                {
                    System.Windows.Forms.MessageBox.Show("调用webservice出错...", "提示", MessageBoxButtons.OK);
                    ThreadClose();
                    return;
                }
                using (MqConsumer mqConsumer = new MqConsumer(uri, curLogRequestCondition.destination, false, false))
                {
                    TMsgHandler callback = new TMsgHandler(RecieveData); //回调函数绑定处理接收数据的函数
                    mqConsumer.SetMsgHandler(callback);

                    mqConsumer.runConsumer();
                    while (!isStopped)
                    {
                        Thread.Sleep(5000);
                    }
                    mqConsumer.CloseMq();
                }
            }
            catch
            {
                isStopped = true;
            }
        }

protected void RecieveData(string message) //处理接收数据的函数
        {
            try
            {
                iflag++;
                if (message.IndexOf("END_") == -1)//不是END_
                {
                    dataList.Add(message);
                }
                if (message.IndexOf("END_") != -1)//接收结束
                {
                    GetLogDataEvent.Invoke(dataList);
                    dataList.Clear();
                    if (iflag == 1)
                    {
                        MessageBox.Show("没有查到符号条件的日志信息");
                    }
                }
                else if (iflag % 1000 == 0)
                {
                    GetLogDataEvent.Invoke(dataList);
                    dataList.Clear();
                }
            }
            catch
            {
                isStopped = true;
            }
        }



 private bool WebServiceStart()
        {
            try
            {
                OSSDOM.CMT.CommonUse.LogService.LogRequest curCondition = curLogRequestCondition;
                OSSDOM.CMT.CommonUse.LogService.Service1 logService1 = new OSSDOM.CMT.CommonUse.LogService.Service1();
                logService1.Url = OSSDOM.Common.Function.PubFunction.ReadXmlFileNode("Config\\WebServiceConfig.xml", "/configuration/LogService");
                if (ServerConnState.serverConnected == false)
                {
                    logService1.Url = logService1.Url.Replace(MakeOptionDatas.MakeOptionDataInstance.proxy.strProxyIP, MakeOptionDatas.MakeOptionDataInstance.StandbyProxy.strProxyIP);
                }
                bool isTranSuccess = logService1.GetLogRequest(curCondition);
                return isTranSuccess;
            }
            catch
            {
                return false;
            }
        }
  1using System;
  2using System.Collections.Generic;
  3using MqWrapper;
  4using System.Threading;
  5using System.Text;
  6using OSSDOM.Common;
  7using System.Windows.Forms;
  8using OSSDOM.CMT.ConfigData;
  9
 10namespace OSSDOM.CMT.CommonUse.MQ
 11{
 12    public delegate void GetLogDataHandle(List<string> logRecData);
 13    public class MQReceive_Log
 14    {
 15        variable
 26
 27        property
 40
 41        Method
144    }

145}

146
posted on 2010-02-08 09:04 天书 阅读(570) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2010年2月>
31123456
78910111213
14151617181920
21222324252627
28123456
78910111213

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜