public CameraAlarmInfo GetCameraAlarm(int id) { CameraAlarmService service = new CameraAlarmService(db); var info = service.GetCameraAlarmDetail(id); return(info); }
private void SaveJsonToFile(long timeStamp, string json) { DateTime now = GetDataTime(timeStamp); FileInfo fi = CameraAlarmService.GetJsonFile(now); File.WriteAllText(fi.FullName, json);//yyyy_mm_dd_HH_MM_ss_fff=>yyyy_MM_dd_HH_mm_ss_fff }
public void AlarmSaveToJson(CameraAlarmJson camera) { byte[] byte1 = camera.Json; string json = Encoding.UTF8.GetString(byte1); CameraAlarmInfo info = CameraAlarmInfo.Parse(json); info.id = camera.Id; //增加了id,这样能够获取到详情 string pic = info.pic_data; DateTime now = GetDataTime(info.time_stamp); FileInfo fi = CameraAlarmService.GetJsonFile(now); }
public void LoadAlarmFromJson() { try { var list2 = GetAllCameraAlarms(false); Dictionary <string, CameraAlarmInfo> dict = new Dictionary <string, CameraAlarmInfo>(); foreach (var item in list2) { string picName = item.pic_name; //picName = picName.Replace(".jpg", ""); if (dict.ContainsKey(picName)) { var itemOld = dict[picName]; dict[picName] = item; } else { dict.Add(picName, item); } } DirectoryInfo dir = CameraAlarmService.GetJsonDir(); FileInfo[] files = dir.GetFiles(); int count = 0; foreach (var item in files) { string json = File.ReadAllText(item.FullName); CameraAlarmInfo cameraAlarmInfo = CameraAlarmInfo.Parse(json); if (dict.ContainsKey(cameraAlarmInfo.pic_name))//已经存在了 { } else { Log.Info(LogTags.ExtremeVision, "添加到数据库:" + cameraAlarmInfo.pic_name); SaveToCameraAlarmJson(json);//保存到数据库中 count++; } } Log.Info(LogTags.ExtremeVision, "LoadAlarmFromJson count:" + count); } catch (System.Exception ex) { Log.Error(LogTags.ExtremeVision, "LoadAlarmFromJson", ex.ToString()); } }