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("连接失败"); } }
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("连接失败,无法获取最大页数"); } }
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(); } } }
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(); } }
//接受信息并处理信息的方法 void _cedaSubscribe_OnCedaMessage(com.adaptiveMQ2.message.Message msg) { //MessageBox.Show("收到消息"); CedaObject co = CedaObject.ToCedaObject(msg); EventMessage listRes = MsgHelper.Deserialize <EventMessage>(co.MessageBody); SetLevel(listRes); }
private void _cedaSubscribe_OnCedaMessage(Message obj) { CedaObject co = CedaObject.ToCedaObject(obj); string str = WarnInfo(co); str = SvrRunInfo(co); logHelper.Debug(str); }
void _cedaSubscribe_OnCedaMessage(com.adaptiveMQ2.message.Message msg) { CedaObject co = CedaObject.ToCedaObject(msg); ListMONSvr listRes = MsgHelper.Deserialize <ListMONSvr>(co.MessageBody); setGridView(listRes); string str = string.Format("地址:{2}:{3} Topic={0},MessageBody=\n{1}", co.Topic, co.MessageBody, ip, port); LogHelper.Info(str); }
void _cedaSubscribe_OnCedaMessage(com.adaptiveMQ2.message.Message msg) { // MessageBox.Show("Receive Message..."); CedaObject co = CedaObject.ToCedaObject(msg); listRes = MsgHelper.Deserialize <MonitorUserCount>(co.MessageBody, MsgSerializerType.Json); // MessageBox.Show(listRes.Time + " listRes.Time "); string str = string.Format("地址:{2}:{3} Topic={0},MessageBody=\n{1}", co.Topic, co.MessageBody, ip, port); LogHelper.Info(str); //消息窗口显示E dealwith_msg(listRes); }
//建立连接 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); } } }); }
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); } } }); }
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); }
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("连接失败"); } }