/// <summary> /// 保存接收到的车辆通行数据 /// </summary> /// <param name="data"></param> public static void SaveReceiveData(T_ReceiveData data) { using (PathIdentifyEquipDemoDBEntities db = new PathIdentifyEquipDemoDBEntities()) { db.T_ReceiveData.Attach(data); db.Entry(data).State = EntityState.Added; db.SaveChanges(); } }
private static void OnVehicleInfoNotify(object sender, VehicleInfoReceiveEventArgs arg) { string path = ImageSavePath + arg.Device.Id.ToString() + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string nameid = string.Format("{0}{1}", string.IsNullOrEmpty(arg.VehiclePlateNo) ? "无牌" : arg.VehiclePlateNo, arg.ReachTime.ToString("HHmmss")); T_ReceiveData data = new T_ReceiveData(); data.EquipId = arg.Device.Id; #region 保存图片 if (arg.PanoramaPhoto != null && arg.PanoramaPhoto.Length > 0) { string PanoramaPhotoPath = path + nameid + "_All.jpg"; FileIOUtil.SaveFileByByteArray(PanoramaPhotoPath, arg.PanoramaPhoto); data.ImageAllPath = PanoramaPhotoPath; } if (arg.CloseShotPhoto != null && arg.CloseShotPhoto.Length > 0) { string CloseShotPhotoPath = path + nameid + "_Near.jpg"; FileIOUtil.SaveFileByByteArray(CloseShotPhotoPath, arg.CloseShotPhoto); data.ImageNearPath = CloseShotPhotoPath; } if (arg.VehiclePlatePhoto != null && arg.VehiclePlatePhoto.Length > 0) { string VehiclePlatePhotoPath = path + nameid + "_VehiclePlate.jpg"; FileIOUtil.SaveFileByByteArray(VehiclePlatePhotoPath, arg.VehiclePlatePhoto); data.ImagePlateNoPath = VehiclePlatePhotoPath; } if (arg.VehiclePlateBinPhoto != null && arg.VehiclePlateBinPhoto.Length > 0) { string BinVehiclePlatePhotoPath = path + nameid + "_Bin.jpg"; FileIOUtil.SaveFileByByteArray(BinVehiclePlatePhotoPath, arg.VehiclePlateBinPhoto); data.ImageBinPlateNoPath = BinVehiclePlatePhotoPath; } #endregion 保存图片 data.ReachTime = arg.ReachTime; data.VehicleLength = arg.VehicleLength; data.VehicleSpeed = arg.VehicleSpeed; data.VehPlateColor = string.IsNullOrEmpty(arg.VehiclePlateColor) ? "未知" : arg.VehiclePlateColor; data.VehPlateNo = arg.VehiclePlateNo; DAL_ReceiveData.SaveReceiveData(data); arg.DbData = data; if (VehicleInfoReceiveNotifyHandler != null) { VehicleInfoReceiveNotifyHandler.Invoke(sender, arg); } }