private void OkBt_Click(object sender, EventArgs e) { if (TimeBox.Text.ToString() == string.Empty) { MessageBox.Show("信息为空"); return; } if (int.Parse(TimeBox.Text.ToString()) == 0) { MessageBox.Show("不能输入0"); TimeBox.Text = ""; return; } else { dic["period"] = TimeBox.Text.ToString().Trim(); } string msgbody = MsgHelper.Serializer <Dictionary <string, object> >(dic); request.MessageBody.addString((short)3, msgbody); request.MessageBody.addString((short)4, "JSON"); request.MessageBody.addInt((short)5, 0); request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss")); sentMsg(); }
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("连接失败,无法获取最大页数"); } }
private bool getMessage(string startdate, string enddate, string eventlevel, string content, int offset) { string s, e; s = string.Format("{0}-{1}-{2} ", startdate.Substring(0, 4), startdate.Substring(4, 2), startdate.Substring(6, 2)); e = string.Format("{0}-{1}-{2} ", enddate.Substring(0, 4), enddate.Substring(4, 2), enddate.Substring(6, 2)); if (DateTime.Compare(DateTime.Parse(s), DateTime.Parse(e)) > 0) { MessageBox.Show("日期选择错误"); return false; } else { dic["startdate"] = startdate; dic["enddate"] = enddate; dic["eventlevel"] = eventlevel; dic["content"] = content; // dic.Add("count", 20); dic["startdate"] = startdate; dic["offset"] = offset; msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic); request.MessageBody.addString((short)3, msgbody); request.MessageBody.addString((short)4, "JSON"); request.MessageBody.addInt((short)5, 0); request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss")); return true; } }
private void last_Click(object sender, EventArgs e) { i = maxpage; page.Text = i.ToString(); dic["offset"] = (maxpage-1)*20; msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic); request.MessageBody.addString((short)3, msgbody); sentMsg(); }
private void next_Click(object sender, EventArgs e) { if (i + 1 > maxpage) { MessageBox.Show("已经到最后一页了,再向后,臣妾做不到啊"); } else { i = i + 1; page.Text = i.ToString(); dic["offset"] = (i - 1) * 20; msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic); request.MessageBody.addString((short)3, msgbody); sentMsg();} }
private void Previous_Click(object sender, EventArgs e) { if (i - 1 <= 0) { MessageBox.Show("已经是首页了,不能往前了呢"); } else { i = i - 1; page.Text = i.ToString(); dic["offset"] = (i - 1) * 20; msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic); request.MessageBody.addString((short)3, msgbody); sentMsg(); } }
private void jump_Click(object sender, EventArgs e) { try { string s = page.Text; int.TryParse(s, out i); } catch { MessageBox.Show("请输入正确的数字"); } if (i <= maxpage && i >= 0) { page.Text = i.ToString(); dic["offset"] = (i - 1) * 20; msgbody = MsgHelper.Serializer<Dictionary<string, object>>(dic); request.MessageBody.addString((short)3, msgbody); sentMsg(); } else { MessageBox.Show("输入数字过大或过小,请重新输入"); } }
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); }
//连接服务器,并订阅目标消息 private void ConnectionServer() { //MessageBox.Show("kaishilianjie"); _cedaSubscribe = new CedaManager(logHelper); _cedaSubscribe.OnCedaMessage += new Action <com.adaptiveMQ2.message.Message>(_cedaSubscribe_OnCedaMessage); _clientInfo = new ClientInfo(); _clientInfo.setAddress(ip, port); _clientInfo.setUser("monitor", "monitor"); _clientInfo.Protocol = ClientInfo.PROTOCOL_TCP; //MessageBox.Show("启动线程,并订阅消息"); try { ThreadPool.QueueUserWorkItem(o => { _cedaSubscribe.Connect(_clientInfo); if (_cedaSubscribe == null) { return; } if (_cedaSubscribe.IsConnected) { string msgbody = MsgHelper.Serializer <Dictionary <string, object> >(dic); request.MessageBody.addString((short)3, msgbody); request.MessageBody.addString((short)4, "JSON"); request.MessageBody.addInt((short)5, 0); request.MessageBody.addString(7, DateTime.Now.ToString("yyyyMMdd HH:mm:ss")); sentMsg(); _cedaSubscribe.Subscribe("monitor.event.*"); } }); } catch { txtMsg.Text = "连接失败,请检查链接。SerID:" + serId + " IP:" + ip + " PORT:" + port; } }
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); }
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); }