/// <summary> /// 处理接收到的OMC消息 /// </summary> /// <param name="buffer"></param> void receiveMsg(byte[] buffer) { Message omcMsg = Message.parse(buffer); if (omcMsg.MsgType == 0) { //realTimeAlarm AlarmVo almObj = AlarmVo.ParseFromJson(omcMsg); almObj.LogTime = DateTime.Now.ToLongTimeString(); //如果告警时间与当前时间相差超过5s,则认为延迟问题 TimeSpan time = DateTime.Now - Util.getTime(almObj.EventTime); if (time.TotalSeconds >= 5) { log.Info("exceed 5 sec:" + "time is :" + time.TotalMilliseconds + " user:"******" msg:" + almObj.toString()); } else { log.Info("time is :" + time.TotalSeconds + " user:"******" msg:" + almObj.toString()); } if (!isLogModel) { this.rtAlmList.Add(almObj); mainFrame.RefrashRtAlmGrid(this.Id, this.rtAlmList); } } else { OperInfo operObj = OperInfo.Parse(omcMsg); this.operInfoList.Add(operObj); log.Info("user:"******" msg:" + operObj.toString()); mainFrame.RefrashOperInfoGrid(this.Id, this.operInfoList); } }
public void sendMessage(Message message) { if (socketClient.Connected) { NetworkStream clientStream = socketClient.GetStream(); byte[] buffer = message.ToBytes(); if (clientStream.CanWrite) { clientStream.Write(buffer, 0, buffer.Length); clientStream.Flush(); OperInfo operObj = OperInfo.Parse(message); this.operInfoList.Add(operObj); log.Info(operObj.toString()); mainFrame.RefrashOperInfoGrid(this.Id, this.operInfoList); } } }