private void AddToVideoList(DateAndDeleteFlag flag) { lock (_locker) { _daysSaved.Add(flag); } }
public void DeleteVideos(DateAndDeleteFlag videoToDelete) { if (Directory.Exists(videoToDelete.AbsoluteDirectory)) { Directory.Delete(videoToDelete.AbsoluteDirectory, true); videoToDelete.Deleted = true; } }
private DateAndDeleteFlag GetDayFromPath(string absolutePath) { var dirs = absolutePath.Split(Path.DirectorySeparatorChar).Select(s => s.ToUpper()).ToArray(); if (!dirs.Contains(DirNameNormal)) return null; int idx = -1; for (int i = 0; i < dirs.Length; i++) { if (dirs[i] == DirNameNormal) { idx = i; break; } } if (idx == -1) return null; if (idx == 0 || idx == dirs.Length - 1) return null; var cameraIdDirName = dirs[idx - 1]; var dayDirName = dirs[idx + 1].Trim(); if (dayDirName.Length < 8) return null; var cameraId = 0; if (!int.TryParse(cameraIdDirName, out cameraId)) return null; int y; if (!int.TryParse(dayDirName.Substring(0, 4), out y)) return null; int m; if (!int.TryParse(dayDirName.Substring(4, 2), out m)) return null; int d; if (!int.TryParse(dayDirName.Substring(6, 2), out d)) return null; var date = new DateTime(y, m, d, 0, 0, 0, 0, DateTimeKind.Utc).ToLocalTime(); var absoluteDayDir = string.Join(Path.DirectorySeparatorChar.ToString(), dirs, 0, idx + 2); var dateAndDeleteFlag = new DateAndDeleteFlag() { AbsoluteDirectory = absoluteDayDir, Date = date, Deleted = false, CameraId = cameraId }; return dateAndDeleteFlag; }
private void AddToVideoList(DateAndDeleteFlag flag) { lock (_locker) { _daysSaved.Add(flag); } }
public void DeleteVideos(DateAndDeleteFlag videoToDelete) { if (Directory.Exists(videoToDelete.AbsoluteDirectory)) { Directory.Delete(videoToDelete.AbsoluteDirectory, true); videoToDelete.Deleted = true; } }
private DateAndDeleteFlag GetDayFromPath(string absolutePath) { var dirs = absolutePath.Split(Path.DirectorySeparatorChar).Select(s => s.ToUpper()).ToArray(); if (!dirs.Contains(DirNameNormal)) { return(null); } int idx = -1; for (int i = 0; i < dirs.Length; i++) { if (dirs[i] == DirNameNormal) { idx = i; break; } } if (idx == -1) { return(null); } if (idx == 0 || idx == dirs.Length - 1) { return(null); } var cameraIdDirName = dirs[idx - 1]; var dayDirName = dirs[idx + 1].Trim(); if (dayDirName.Length < 8) { return(null); } var cameraId = 0; if (!int.TryParse(cameraIdDirName, out cameraId)) { return(null); } int y; if (!int.TryParse(dayDirName.Substring(0, 4), out y)) { return(null); } int m; if (!int.TryParse(dayDirName.Substring(4, 2), out m)) { return(null); } int d; if (!int.TryParse(dayDirName.Substring(6, 2), out d)) { return(null); } var date = new DateTime(y, m, d, 0, 0, 0, 0, DateTimeKind.Utc).ToLocalTime(); var absoluteDayDir = string.Join(Path.DirectorySeparatorChar.ToString(), dirs, 0, idx + 2); var dateAndDeleteFlag = new DateAndDeleteFlag() { AbsoluteDirectory = absoluteDayDir, Date = date, Deleted = false, CameraId = cameraId }; return(dateAndDeleteFlag); }