private void btnSendUpdate_Click(object sender, EventArgs e) { string parkingCode = Convert.ToString(this.cbParking.SelectedValue); if (string.IsNullOrEmpty(parkingCode)) { MessageBox.Show("请先选择停车场", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } CheckedListViewItemCollection checkedItem = this.listCamera.CheckedItems; if (checkedItem == null || checkedItem.Count <= 0) { MessageBox.Show("请选择需要更新的相机", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string inputUrl = this.txtUpdateUrl.Text; string inputMd5 = this.txtUpdateMd5.Text; string inputVersion = this.txtVersion.Text; if (string.IsNullOrEmpty(inputUrl) || string.IsNullOrEmpty(inputMd5) || string.IsNullOrEmpty(inputVersion)) { MessageBox.Show("请将更新信息填写完整", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult tipResult = MessageBox.Show("请仔细核对更新内容?\n该操作可能导致现场相机无法正常使用", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (tipResult != DialogResult.OK) { return; } CameraUpdateModel updateModel = new CameraUpdateModel(); updateModel.UpdateUrl = inputUrl; updateModel.UpdateMd5 = inputMd5; updateModel.UpdateVersion = inputVersion; foreach (ListViewItem item in checkedItem) { string macAddress = item.SubItems["deviceMacAddress"].Text; if (string.IsNullOrEmpty(macAddress)) { continue; } updateModel.DeviceIdentify = macAddress; CarNumberRepushToCamera(updateModel, parkingCode); } //暂不参考mq返回结果 MessageBox.Show("更新命令发送成功", "提示", MessageBoxButtons.OK); }
public bool CarNumberRepushToCamera(CameraUpdateModel model, string parkingCode) { CommandEntity <CameraUpdateModel> entity = new CommandEntity <CameraUpdateModel>() { command = BussineCommand.CameraUpdate, idMsg = Convert.ToBase64String(Guid.NewGuid().ToByteArray()), message = model }; ILogger logger = new Logger(); ISerializer serializer = new JsonSerializer(logger); RabbitMQSender m_rabbitMQ = new RabbitMQSender(logger, serializer); return(m_rabbitMQ.SendMessageForRabbitMQ("发送相机升级命令", serializer.Serialize(entity), entity.idMsg, parkingCode)); }