private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtVehCode.Text.Trim())) { MessageBox.Show("请输入车辆 GPSCode !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List<string> gpscodeList = txtVehCode.Text.Trim().Split(',').ToList(); if (gpscodeList.IsEmpty()) { MessageBox.Show("请输入车辆 GPSCode !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ShowLoadding(); foreach (var item in gpscodeList) { var obj = _MemcachedClient.Get(item + "_movo"); if (obj != null) { var result = obj as byte[]; listBox1.Items.Add(string.Format("缓存数据:{0} \r\n", result)); if (null != result && result.Length > 0) { GpsDataCachedEntity entity = new GpsDataCachedEntity(); entity.ReadBuffer(result); var res = ConvertNewEntityToOldEntity(entity); if (res != null) { listBox1.Items.Add(string.Format("转换数据:vCode:{0}, StartStopCarTime:{1}\r\n", res.VehicleCode, res.StartStopCarTime)); } else { listBox1.Items.Add(string.Format("转换数据失败, GPSCode:{0}", item)); } } else { listBox1.Items.Add(string.Format("读取Memcached缓存数据为空, GPSCode:{0}", item)); } } else { listBox1.Items.Add(string.Format("连接Memcached失败, GPSCode:{0}", item)); } } CloseLoadding(); }
public PES.GPS.GpsEntityBase.GPSDataEntity Get(string gpsCode) { try { string k = Key(gpsCode); object o = iCacheProvider.Get(k); var result= o as byte[]; if (null != result&&result.Length>0) { GpsDataCachedEntity entity = new GpsDataCachedEntity(); entity.ReadBuffer(result); //Logger.Fatal("取出新实体成功"); return ConvertNewEntityToOldEntity(entity); } return null; } catch (Exception ex) { Logger.Error(ex, null); return null; } }