//根据信息的种类 ,进行处理:1.数据信息,发送给DTU 2.控制命令,发送给WEB 3.设备列表,更新显示表格 private void proxyProcess(DataTransfer transfer) { switch (transfer.TransferType) { case DataTransferType.DataTransferDataInfo: { DataTransferInfo info = transfer.TransferDataInfo; DeviceInfo di = new DeviceInfo(); di.Parse(info.DeviceNo); string DeviceFullNo = DeviceModule.DeviceNo_Hex2Normal(di.SerialString); string DeviceFullNoMain = DeviceModule.GetDeviceNoMain(DeviceFullNo); bridge.sendToDtu(DeviceFullNo, DeviceFullNoMain, info.Data, info.Offset, info.Length); break; } case DataTransferType.DataTransferCommand: { DTU.GateWay.Protocol.Command command = transfer.TransferCommand; bridge.sendToWeb(command.DeviceInfo.SerialLong, command); break; } case DataTransferType.DataTransferDeviceList: { Device deviceList = transfer.DeviceList; DeviceEvent deviceEvent = transfer.DeviceEvent; updateDeviceListInGridView(deviceList, deviceEvent); break; } case DataTransferType.DataTransferLog: { break; } case DataTransferType.DataTransferUpdateDevice: { string kt = transfer.KeyType; string key = transfer.Key; if (SysCache.ShowInfoLog) { ShowLogData.add("更新设备缓存:" + kt + "," + key); logHelper.Info("更新设备缓存:" + kt + "," + key); } if (kt == "01") { Device device = DeviceModule.GetDeviceByFullDeviceNo_DB(key); if (device != null) { DeviceModule.UpdateDeviceInfo(device); if (dtuServer != null) { dtuServer.updateDevice(device); } updateDeviceListInGridView(device, null); } else { if (SysCache.ShowInfoLog) { ShowLogData.add("更新设备缓存:" + kt + "," + key + " 无法更新设备不存在"); logHelper.Info("更新设备缓存:" + kt + "," + key + " 无法更新设备不存在"); } } } else if (kt == "02") { DeviceModule.RemoveDeviceInfo(key); lock (this.deviceListsDataGridView) { int rows = this.deviceListsDataGridView.Rows.Count; for (int i = 0; i < rows; i++) { object obj = this.deviceListsDataGridView.Rows[i].Cells[1].Value; if (obj != null) { string val = obj.ToString(); if (val.Equals(key)) { this.deviceListsDataGridView.Rows.Remove(this.deviceListsDataGridView.Rows[i]); return; } } } } } break; } case DataTransferType.DataTransferUpdateCardUser: { string kt = transfer.KeyType; string key = transfer.Key; ShowLogData.add("更新用户卡缓存:" + kt + "," + key); if (kt == "01") { CardUser cardUser = CardUserModule.GetCardUserBySerialNumber_DB(key); if (cardUser != null) { CardUserModule.UpdateCardUserInfo(cardUser); } } else if (kt == "02") { CardUserModule.RemoveCardUserInfo(key); } break; } case DataTransferType.DataTransferUpdateDistrict: { ShowLogData.add("更新地区缓存"); initDistrictTree(); break; } } }