private void NewCommand(CommandClass commandClass) { StringBuilder sb = new StringBuilder(); sb.AppendLine("命令来源: " + commandClass.StationSrc); sb.AppendLine("巡逻路线: " + commandClass.PatrolRoute); sb.AppendLine("巡逻时间: " + commandClass.PatrolTime); sb.AppendLine("描述: " + commandClass.Description); MessageBox.Show(sb.ToString(), "收到上级下达的巡逻命令", MessageBoxButtons.OK); }
private void btn_SendCommand_Click(object sender, EventArgs e) { CommandClass cc = new CommandClass(); cc.StationSrc = lb_StationName.Text; cc.StationDes = cbx_Station.Text; cc.PatrolRoute = tbx_PatrolRoute.Text; cc.PatrolTime = tbx_PatrolTime.Text; cc.Description = tbx_Description.Text; string sendMsg = "SVMCommand" + " " + JsonConvert.SerializeObject(cc) + "\r\n"; SVMServerCommunicate.SendMsgToServer(sendMsg); }
protected override void ProcessProtocol(object arg) { string content = string.Empty; string protocol = arg as string; if (protocol.StartsWith("SVMCommand")) { content = protocol.Substring("SVMCommand".Length).Trim(); try { CommandClass cc = JsonConvert.DeserializeObject <CommandClass>(content); OnNewCommand(cc); } catch { } } else if (protocol.StartsWith("DispatchMsg")) { content = protocol.Substring("DispatchMsg".Length).Trim(); try { string[] dispatchMsg = content.Split(','); OnNewDispatchMsg(dispatchMsg[0], dispatchMsg[1]); } catch { } } else if (protocol.StartsWith("SVMMsg")) { content = protocol.Substring("SVMMsg".Length).Trim(); try { try { BaseDataClass.DutyRecordInfoList dutyRecordInfo = JsonConvert.DeserializeObject <BaseDataClass.DutyRecordInfoList>(content); OnNewDuty(dutyRecordInfo); } catch { } } catch { } } }