Beispiel #1
0
        public int c;  //用于改变最大显示点数

        //请求订阅
        private void cedaManagaer_OnCedaMessage(Message obj)
        {
            CedaObject     co  = CedaObject.ToCedaObject(obj);
            MonitorMessage ts  = MsgHelper.Deserialize <MonitorMessage>(co.MessageBody, MsgSerializerType.Json);
            string         key = ts.type;
            DateTime       dt  = zedgraphHelper.stringToDateTime(ts.date + " " + ts.time);
            XDate          xd  = new XDate(dt);
            double         d   = Convert.ToDouble(ts.amount);

            if (d != 0)
            {
                PointPair pointPair = new PointPair((double)xd, d);
                addPointData(key, pointPair);
                if (pointData.getPointPairListByKey(key).Count <= 0)
                {
                    this.createLines();
                }

                if (pointData.getPointPairListByKey(key).Count > c)
                {
                    pointData.getPointPairListByKey(key).RemoveRange(0, pointData.getPointPairListByKey(key).Count - c);
                    this.refreshPane();
                }
                else
                {
                    this.refreshPane();
                }
            }
        }
Beispiel #2
0
        private void getPageCount(string startdate, string enddate, string eventlevel, string content)
        {
            dic["startdate"] = startdate;
            dic["enddate"] = enddate;
            dic["eventlevel"] = eventlevel;
            dic["content"] = content;
            
            msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic);
            request1.MessageBody.addString((short)3, msgbody);

            request1.MessageBody.addString((short)4, "JSON");
            request1.MessageBody.addInt((short)5, 0);
            request1.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));

            if (_cedaSubscribe.IsConnected)
            {
                com.adaptiveMQ2.message.Message reply1 = _cedaSubscribe.Request(request1);
                if (reply1 != null)
                {
                    CedaObject co = CedaObject.ToCedaObject(reply1);
                    Page result1 = MsgHelper.Deserialize<Page>(co.MessageBody, MsgSerializerType.Json);
                    maxpage = result1.Data;
                    
                    pageCount.Text = "共" + maxpage + "页";
                }
                else { MessageBox.Show("响应信息异常"); }
            }
            else
            {
                MessageBox.Show("连接失败,无法获取最大页数");
            }


        }
Beispiel #3
0
 private void sentMsg()
 {
     if (demo.cedaManager.IsConnected)
     {
         com.adaptiveMQ2.message.Message reply = demo.cedaManager.Request(request);
         if (reply != null)
         {
             CedaObject co     = CedaObject.ToCedaObject(reply);
             TimeChange result = MsgHelper.Deserialize <TimeChange>(co.MessageBody, MsgSerializerType.Json);
             if (result.Code == "0000")
             {
                 label4.Text = "现在时间间隔是" + result.period + "秒,在这里输入时间:";
             }
             else
             {
                 MessageBox.Show("出错啦,没有设置成功哦"); label4.Text = "出错了";
             }
         }
         else
         {
             MessageBox.Show("响应信息异常");
         }
     }
     else
     {
         MessageBox.Show("连接失败");
     }
 }
Beispiel #4
0
        private void cedaClient_OnCedaMessage(Message obj)
        {
            CedaObject co = CedaObject.ToCedaObject(obj);

            MonitorMessage ts  = MsgHelper.Deserialize <MonitorMessage>(co.MessageBody, MsgSerializerType.Json);
            string         key = ts.MKey;



            if (string.IsNullOrEmpty(ts.MUpdatetime))
            {
                return;
            }

            DateTime dt = zedgraphHelper.stringToDateTime(ts.MUpdatetime);
            XDate    xd = new XDate(dt);
            //XDate xd = new XDate(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);
            //xd.AddSeconds((double)dt.Second);
            PointPair pointPair = new PointPair((double)xd, (double)ts.MValue);

            if (pointData.isContain(key))
            {
                addPointData(key, pointPair);

                //this.refreshPane();
            }
        }
Beispiel #5
0
        public void onMessage(com.adaptiveMQ2.message.Message msg)
        {
            string stopic = msg.Destination.getName();

            if (stopic.Equals(ConstsMessage.TOPIC_ATS_LOGIN))
            {
                Dictionary <string, object> map = CedaObject.GetLoginResult(msg);
                if (map != null)
                {
                    foreach (string key in map.Keys)
                    {
                        switch (key.ToLower())
                        {
                        case "sid":
                            sid = map[key] + "";
                            if (clientInfo != null)
                            {
                                clientInfo.SID = sid;
                            }
                            break;
                        }
                    }
                }
            }

            if (OnCedaMessage != null)
            {
                OnCedaMessage(msg);
            }
        }
Beispiel #6
0
        //接受信息并处理信息的方法
        void _cedaSubscribe_OnCedaMessage(com.adaptiveMQ2.message.Message msg)
        {
            //MessageBox.Show("收到消息");
            CedaObject co = CedaObject.ToCedaObject(msg);

            EventMessage listRes = MsgHelper.Deserialize <EventMessage>(co.MessageBody);

            SetLevel(listRes);
        }
Beispiel #7
0
        private void _cedaSubscribe_OnCedaMessage(Message obj)
        {
            CedaObject co = CedaObject.ToCedaObject(obj);

            string str = WarnInfo(co);

            str = SvrRunInfo(co);

            logHelper.Debug(str);
        }
Beispiel #8
0
        //主动请求建立连接
        private Message getMessage()
        {
            Message request = request = new Message();

            request.Destination = new Destination(topichistoryStr);//主动请求建立连接,获取缓存数据
            request.SvrID       = svrId;
            request.MessageBody.addString((short)3, "{}");
            request.MessageBody.addString((short)4, "JSON");
            request.MessageBody.addInt((short)5, 0);
            request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
            return(request);
        }
Beispiel #9
0
        //建立连接
        public void connect()
        {
            initialize_ip_port_svrID();
            ClientInfo clientInfo = new ClientInfo();

            clientInfo.setAddress(ip, port);
            clientInfo.setUser("monitor", "monitor");
            clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;
            ThreadPool.QueueUserWorkItem(o =>
            {
                cedaManager.Connect(clientInfo);
                if (cedaManager == null)
                {
                    return;
                }
                if (cedaManager.IsConnected)
                {
                    //string msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic);
                    cedaManager.SubscribeWithImage(topicStr, svrId);
                    List <String> topicList = new List <String>();
                    topicList.Add(topicStr);
                    cedaManager.Subscribe(topicStr);
                    while (cedaManager.IsConnected)
                    {
                        if (cedaManager.IsConnected)
                        {
                            Message reply = cedaManager.Request(getMessage());
                            CedaObject co = CedaObject.ToCedaObject(reply);
                            if (co != null)
                            {
                                LogHelper.Debug(co.Topic + ":" + co.MessageBody);

                                HisMonitorMessages result = MsgHelper.Deserialize <HisMonitorMessages>(co.MessageBody, MsgSerializerType.Json);
                                lock (pointData)
                                {
                                    setLinesData(result.Data);
                                    createLines();
                                }
                                LogHelper.Debug("init end.");
                                break;
                            }
                            else
                            {
                                LogHelper.Error("reply is null.");
                            }
                        }
                        Thread.Sleep(1000);
                    }
                }
            });
        }
Beispiel #10
0
 public void onMessage(com.adaptiveMQ2.message.Message msg)
 {
     if (msg.Destination.getName().Equals(ConstsMessage.TOPIC_ATS_LOGIN))
     {
         try
         {
             LogHelper.Debug("--------------------->" + msg.MessageBody.getString((short)3));
         }
         catch (Exception e)
         {
             LogHelper.Error(e);
         }
         return;
     }
     doMsg(msg);
 }
Beispiel #11
0
        public void connect()
        {
            ClientInfo clientInfo = new ClientInfo();

            clientInfo.setAddress(Ip, Port);
            clientInfo.setUser("zedgraph", "zedgraph");
            clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;

            ThreadPool.QueueUserWorkItem(o =>
            {
                cedaClient.Connect(clientInfo);
                if (cedaClient == null)
                {
                    return;
                }
                if (cedaClient.IsConnected)
                {
                    while (cedaClient != null)
                    {
                        if (cedaClient.IsConnected)
                        {
                            Message reply = cedaClient.Request(getMessage());
                            CedaObject co = CedaObject.ToCedaObject(reply);
                            if (co != null)
                            {
                                LogHelper.Debug(co.Topic + ":" + co.MessageBody);

                                ServerTopicRef result = MsgHelper.Deserialize <ServerTopicRef>(co.MessageBody,
                                                                                               MsgSerializerType.Json);

                                setLinesData(result.TSvrTopicRefs);
                                createLines();

                                LogHelper.Debug("init end.");

                                break;
                            }
                            else
                            {
                                LogHelper.Error("reply is null.");
                            }
                        }
                        Thread.Sleep(repeatRequestTime);
                    }
                }
            });
        }
Beispiel #12
0
        private Message getMessage()
        {
            Message request = request = new Message();

            LogHelper.Debug("request initTopic:" + initTopic);
            request.Destination = new Destination(initTopic);
            request.SvrID       = svrId;
            string param = "{\"RequestSvrId\":\"" + RequestSvrId + "\"}";

            request.MessageBody.addString((short)3, param);
            //request.MessageBody.addString((short)3, "{}");
            request.MessageBody.addString((short)4, "JSON");
            request.MessageBody.addInt((short)5, 0);
            request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));

            return(request);
        }
Beispiel #13
0
        public static Message GetLoginMessage(string userName, string pwd, string roleName, string sessionId, bool encryption)
        {
            var ht = new Dictionary <string, object>();

            ht.Add("method", "login");
            var args = new Dictionary <string, object>();

            if (string.IsNullOrEmpty(userName))
            {
                userName = "******";
            }
            args.Add("userName", userName);
            args.Add("location", "PINGO");
            if (string.IsNullOrEmpty(pwd))
            {
                pwd = "111111";
            }
            args.Add("password", pwd);
            if (string.IsNullOrEmpty(roleName))
            {
                roleName = "1";
            }
            args.Add("roleName", roleName);
            if (string.IsNullOrEmpty(sessionId))
            {
                sessionId = "CCB" + random.Next(10000, 20000);
            }
            args.Add("st", sessionId);
            args.Add("loginType", "PC");
            args.Add("clientType", "E");
            if (encryption)
            {
                string loginInfo = MsgHelper.Serializer <Dictionary <string, object> >(args);
                args = EncryptHelper.getLoginInfo(loginInfo);
            }

            ht.Add("parameter", args);
            string str = MsgHelper.Serializer <Dictionary <string, object> >(ht);
            var    msg = new com.adaptiveMQ2.message.Message();

            msg.MessageBody.addString((short)3, str);
            return(msg);
        }
Beispiel #14
0
        private MSD getMSD()
        {
            MSD msd = new MSD();

            msd.svrinfos.Add(new TSvrinfo()
            {
                ServiceName = "Asvr"
            });
            msd.svrinfos.Add(new TSvrinfo()
            {
                ServiceName = "AMQ1"
            });
            msd.svrinfos.Add(new TSvrinfo()
            {
                ServiceName = "AMQ2"
            });
            msd.svrrefs.Add(new TSvrRef()
            {
                Servername_From = "AMQ1", Servername_To = "Asvr"
            });
            msd.svrrefs.Add(new TSvrRef()
            {
                Servername_From = "AMQ2", Servername_To = "Asvr"
            });

            Message request = new Message();

            request.Destination = new Destination("YM.M.SD");
            request.SvrID       = svrId;
            request.MessageBody.addString((short)3, "{}");
            request.MessageBody.addString((short)4, "JSON");
            request.MessageBody.addInt((short)5, 0);
            request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
            Message    reply = _cedaSubscribe.Request(request);
            CedaObject co    = CedaObject.ToCedaObject(reply);

            if (co.MessageBody != null)
            {
                msd = MsgHelper.Deserialize <MSDResult>(co.MessageBody).MSD;
            }
            return(msd);
        }
Beispiel #15
0
 private void sentMsg() 
 {
     
     if (_cedaSubscribe.IsConnected)
     {
         
         com.adaptiveMQ2.message.Message reply = _cedaSubscribe.Request(request);
         if (reply != null)
         {
             CedaObject co = CedaObject.ToCedaObject(reply);
             HistoryMsg result = MsgHelper.Deserialize<HistoryMsg>(co.MessageBody, MsgSerializerType.Json);
             _cedaSubscribe_OnCedaMessage(result);
         }
         else { MessageBox.Show("响应信息异常"); }
     }
     else
     {
         MessageBox.Show("连接失败");
     }
 }
Beispiel #16
0
        private Message getLoginMsg(string userName, string location, string password, string newPassword)
        {
            com.adaptiveMQ2.message.Message msgRequest = new com.adaptiveMQ2.message.Message();
            msgRequest.MessageBody = new com.adaptiveMQ2.message.MessageBody();
            Dictionary <string, object> args = new Dictionary <string, object>();

            args.Add("method", "login");
            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("userName", userName);
            parameter.Add("location", location);
            parameter.Add("password", password);
            if (!string.IsNullOrEmpty(newPassword))
            {
                parameter.Add("newPassword", newPassword);
            }
            args.Add("parameter", parameter);
            string jsonArgs = MsgHelper.Serializer <Dictionary <string, object> >(args);

            msgRequest.MessageBody.addString((short)3, jsonArgs);


            return(msgRequest);
        }
Beispiel #17
0
        private void ConnectionServer()
        {
            _cedaSubscribe = new CedaManager(logHelper);
            _cedaSubscribe.OnCedaMessage += new Action <com.adaptiveMQ2.message.Message>(_cedaSubscribe_OnCedaMessage);
            string host = txtHost.Text.Trim();
            int    port = 0;

            if (!Int32.TryParse(txtPort.Text.Trim(), out port))
            {
                logHelper.Warn("port is error!");
                return;
            }

            _clientInfo = new ClientInfo();

            if ("ACS".Equals(cbType.Text.Trim()))
            {
                if (!host.EndsWith(".httpMQTunnel"))
                {
                    host = string.Format("{0}/mq.httpMQTunnel", host);
                }
                _clientInfo.setAddress(host, port);
                if (ckSSL.Checked)
                {
                    _clientInfo.Protocol = ClientInfo.PROTOCOL_HTTPS;
                }
                else
                {
                    _clientInfo.Protocol = ClientInfo.PROTOCOL_HTTP;
                }
                if (cbVS.Checked)
                {
                    _clientInfo.LoginMessage = CedaObject.GetLoginMessage(txtUserName.Text, txtPwd.Text, txtRole.Text, null, encryption, clientType);
                }
            }
            else if ("CEDA".Equals(cbType.Text.Trim()))
            {
                _clientInfo.setAddress(host, port);
                _clientInfo.setUser("test", "test");
                if (ckSSL.Checked)
                {
                    _clientInfo.Protocol = ClientInfo.PROTOCOL_TCPS;
                }
                else
                {
                    _clientInfo.Protocol = ClientInfo.PROTOCOL_TCP;
                }
                if (cbVS.Checked)
                {
                    _clientInfo.LoginMessage = CedaObject.GetLoginMessage(txtUserName.Text, txtPwd.Text, txtRole.Text, null, encryption, clientType);
                }
            }

            string temp = string.Format("Address:{0}:{1},Topic:{2}", _clientInfo.AddressHost, _clientInfo.AddressPort,
                                        txtTopic.Text);

            logHelper.Info(temp);

            request             = new Message();
            request.Destination = new Destination(txtTopic.Text.Trim());
            request.SvrID       = cbServiceName.Text;
            request.MessageBody.addString((short)3, txtRequest.Text.Trim());
            request.MessageBody.addString((short)4, "JSON");
            request.MessageBody.addInt((short)5, 0);
            request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
            ThreadPool.QueueUserWorkItem(o =>
            {
                _cedaSubscribe.Connect(_clientInfo);
                //if (false)
                //{
                //    if (_cedaSubscribe != null)
                //    {
                //        _cedaSubscribe.Disconnect();
                //        _cedaSubscribe.OnCedaMessage -= new Action<com.adaptiveMQ2.message.Message>(_cedaSubscribe_OnCedaMessage);
                //        _cedaSubscribe = null;
                //    }
                //}

                if (_cedaSubscribe != null && _cedaSubscribe.IsConnected)
                {
                    _cedaSubscribe.isStopRequest = false;
                    while (_cedaSubscribe != null && !_cedaSubscribe.isStopRequest)
                    {
                        if (_cedaSubscribe.IsConnected)
                        {
                            Message reply = _cedaSubscribe.Request(request);

                            CedaObject co = CedaObject.ToCedaObject(reply);
                            if (co != null)
                            {
                                logHelper.Info(co.Topic + ":" + co.MessageBody);
                            }
                            else
                            {
                                logHelper.Error("reply is null");
                            }
                        }
                        Thread.Sleep(1000);
                    }
                }
            });
            SetButtonEnable("0111");
        }
Beispiel #18
0
        public static Message GetLoginMessage(string userName, string pwd, string roleName, string sessionId, bool encryption, string clientType)
        {
            var ht = new Dictionary <string, object>();

            ht.Add("method", "login");
            var args = new Dictionary <string, object>();

            if (string.IsNullOrEmpty(userName))
            {
                userName = "******";
            }
            args.Add("userName", userName);
            args.Add("location", "PINGO");
            if (string.IsNullOrEmpty(pwd))
            {
                pwd = "111111";
            }
            args.Add("password", pwd);
            if (string.IsNullOrEmpty(roleName))
            {
                roleName = "1";
            }
            args.Add("roleName", roleName);
            if (string.IsNullOrEmpty(sessionId))
            {
                sessionId = "CCB" + random.Next(10000, 20000);
            }
            args.Add("st", sessionId);
            //args.Add("location", "Midea");
            args.Add("loginType", "PC");
            args.Add("clientType", clientType);
            args.Add("clientInfo", "MDT Smart Kit");
            string ip = "";

            if (string.IsNullOrEmpty(ip))
            {
                var v = Dns.GetHostAddresses(Dns.GetHostName());
                if (v != null)
                {
                    foreach (var ipAddress in v)
                    {
                        if (ipAddress.AddressFamily == AddressFamily.InterNetwork)
                        {
                            ip = ipAddress.ToString();
                        }
                    }
                }
            }
            args.Add("ip", ip);
            if (encryption)
            {
                string loginInfo = MsgHelper.Serializer <Dictionary <string, object> >(args);
                args = EncryptHelper.getLoginInfo(loginInfo);
            }

            ht.Add("parameter", args);
            string str = MsgHelper.Serializer <Dictionary <string, object> >(ht);
            var    msg = new com.adaptiveMQ2.message.Message();

            msg.MessageBody.addString((short)3, str);
            return(msg);
        }