Merge branch 'master' of https://gitea.rdkartono.my.id/rdkartono/ErhaCam
# Conflicts: # out/artifacts/ErhaCam_jar/ErhaCam.jar
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#Thu Apr 10 16:17:13 ICT 2025
|
#Tue May 13 14:43:52 WIB 2025
|
||||||
AudioPhase1=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase1.mp3
|
AudioPhase1=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase1.mp3
|
||||||
AudioPhase2=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase2.mp3
|
AudioPhase2=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase2.mp3
|
||||||
AudioPhase3=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase3.mp3
|
AudioPhase3=C\:\\Users\\Erha\\IdeaProjects\\ErhaCam\\audio\\phase3.mp3
|
||||||
@@ -21,7 +21,7 @@ FTPPort=21
|
|||||||
FTPUser=user
|
FTPUser=user
|
||||||
FlipCamera=true
|
FlipCamera=true
|
||||||
MirrorCamera=true
|
MirrorCamera=true
|
||||||
PhotoDirectory=C\:\\Users\\Erha\\Desktop\\ErhaCapture
|
PhotoDirectory=C\:\\Users\\rdkar\\OneDrive\\Desktop\\Erha Capture
|
||||||
SharpnessThreshold=1000.0
|
SharpnessThreshold=1000.0
|
||||||
cascadeMaxSize=500
|
cascadeMaxSize=500
|
||||||
cascadeMinNeighbors=3
|
cascadeMinNeighbors=3
|
||||||
|
|||||||
BIN
database.db
BIN
database.db
Binary file not shown.
@@ -47,6 +47,16 @@
|
|||||||
2024-10-21 15:28:21 INFO: GetAll success, result count: 36
|
2024-10-21 15:28:21 INFO: GetAll success, result count: 36
|
||||||
2024-10-21 15:28:25 INFO: Not loading empty fxml file
|
2024-10-21 15:28:25 INFO: Not loading empty fxml file
|
||||||
2024-10-21 15:28:25 INFO: Application closed
|
2024-10-21 15:28:25 INFO: Application closed
|
||||||
|
2025-03-24 16:03:28 INFO: Config.ConfigFile.<init>() Current working directory in Java : C:\Users\rdkar\OneDrive\Documents\IntelliJ Project\ErhaCam
|
||||||
|
2025-03-24 16:03:28 INFO: Config.ConfigFile.Load() Load config file at C:\Users\rdkar\OneDrive\Documents\IntelliJ Project\ErhaCam\config.properties
|
||||||
|
2025-03-24 16:03:28 INFO: Config.ConfigFile.Load() Config Loaded
|
||||||
|
2025-03-24 16:03:29 INFO: Config.SomeCodes.LoadQRReader() QRReader loaded
|
||||||
|
2025-03-24 16:03:30 INFO: Config.SomeCodes.LoadFaceDetector() FaceDetector loaded
|
||||||
|
2025-03-24 16:03:30 INFO: id.co.gtc.erhacam.MainApplication.start() Application started
|
||||||
|
2025-03-24 16:03:31 INFO: Database.Sqlite.CreateDatabase() Database created successfully
|
||||||
|
2025-03-24 16:03:31 INFO: Database.Sqlite.GetAll() GetAll success, result count: 55
|
||||||
|
2025-03-24 16:04:08 INFO: id.co.gtc.erhacam.MainView.loadContent() Not loading empty fxml file
|
||||||
|
2025-03-24 16:04:08 INFO: id.co.gtc.erhacam.MainApplication.lambda$start$0() Application closed
|
||||||
2025-03-21 14:43:56 INFO: Config.ConfigFile.<init>() Current working directory in Java : C:\Users\Erha\IdeaProjects\ErhaCam
|
2025-03-21 14:43:56 INFO: Config.ConfigFile.<init>() Current working directory in Java : C:\Users\Erha\IdeaProjects\ErhaCam
|
||||||
2025-03-21 14:43:56 INFO: Config.ConfigFile.Load() Load config file at C:\Users\Erha\IdeaProjects\ErhaCam\config.properties
|
2025-03-21 14:43:56 INFO: Config.ConfigFile.Load() Load config file at C:\Users\Erha\IdeaProjects\ErhaCam\config.properties
|
||||||
2025-03-21 14:43:56 INFO: id.co.gtc.erhacam.Detectors.setFaceMaxSize() FaceMaxSize created with value : 500
|
2025-03-21 14:43:56 INFO: id.co.gtc.erhacam.Detectors.setFaceMaxSize() FaceMaxSize created with value : 500
|
||||||
@@ -426,3 +436,59 @@
|
|||||||
2025-03-21 16:08:12 ERROR: id.co.gtc.erhacam.CaptureView.call() Record associated with barcode
|
2025-03-21 16:08:12 ERROR: id.co.gtc.erhacam.CaptureView.call() Record associated with barcode
|
||||||
2025-03-21 16:08:33 INFO: id.co.gtc.erhacam.CaptureView.onPlaybackStarted() Audio Positikan Muka Started
|
2025-03-21 16:08:33 INFO: id.co.gtc.erhacam.CaptureView.onPlaybackStarted() Audio Positikan Muka Started
|
||||||
2025-03-21 16:08:40 INFO: id.co.gtc.erhacam.CaptureView.onPlaybackFinished() Audio Positikan Muka Finished
|
2025-03-21 16:08:40 INFO: id.co.gtc.erhacam.CaptureView.onPlaybackFinished() Audio Positikan Muka Finished
|
||||||
|
2025-03-24 16:05:16 INFO: Config.ConfigFile.<init>() Current working directory in Java : C:\Users\rdkar\OneDrive\Documents\IntelliJ Project\ErhaCam
|
||||||
|
2025-03-24 16:05:16 INFO: Config.ConfigFile.Load() Load config file at C:\Users\rdkar\OneDrive\Documents\IntelliJ Project\ErhaCam\config.properties
|
||||||
|
2025-03-24 16:05:16 INFO: id.co.gtc.erhacam.Detectors.setFaceMaxSize() FaceMaxSize created with value : 500
|
||||||
|
2025-03-24 16:05:16 INFO: id.co.gtc.erhacam.Detectors.setFaceMaxSize() EyeMaxSize created with value : 83
|
||||||
|
2025-03-24 16:05:16 INFO: id.co.gtc.erhacam.Detectors.setFaceMinSize() FaceMinSize created with value : 250
|
||||||
|
2025-03-24 16:05:16 INFO: id.co.gtc.erhacam.Detectors.setFaceMinSize() EyeMinSize created with value : 41
|
||||||
|
2025-03-24 16:05:16 INFO: Config.ConfigFile.Load() Config Loaded
|
||||||
|
2025-03-24 16:05:16 INFO: Config.SomeCodes.MakeDirectory() Error creating directory: C:\Users\Erha\Desktop\ErhaCapture\FullQuality, Msg : C:\Users\Erha
|
||||||
|
2025-03-24 16:05:16 INFO: Config.SomeCodes.MakeDirectory() Error creating directory: C:\Users\Erha\Desktop\ErhaCapture\FullQualityCrop, Msg : C:\Users\Erha
|
||||||
|
2025-03-24 16:05:16 INFO: Config.SomeCodes.MakeDirectory() Error creating directory: C:\Users\Erha\Desktop\ErhaCapture\Compressed, Msg : C:\Users\Erha
|
||||||
|
2025-03-24 16:05:16 INFO: Config.SomeCodes.MakeDirectory() Error creating directory: C:\Users\Erha\Desktop\ErhaCapture\CompressedCrop, Msg : C:\Users\Erha
|
||||||
|
2025-03-24 16:05:16 INFO: Config.SomeCodes.MakeDirectory() Error creating directory: C:\Users\Erha\Desktop\ErhaCapture\thumbs, Msg : C:\Users\Erha
|
||||||
|
2025-03-24 16:05:17 INFO: id.co.gtc.erhacam.MainApplication.start() Secure Dongle UserID valid
|
||||||
|
2025-03-24 16:05:18 INFO: id.co.gtc.erhacam.CaptureView.initialize() Audio Player : Inited
|
||||||
|
2025-03-24 16:05:19 INFO: Config.SomeCodes.LoadQRReader() QRReader loaded
|
||||||
|
2025-03-24 16:05:19 INFO: id.co.gtc.erhacam.Detectors.LoadFrontalFaceDetector() Face Detector file : C:\Users\rdkar\OneDrive\Documents\IntelliJ Project\ErhaCam\haarcascade_frontalface_alt.xml
|
||||||
|
2025-03-24 16:05:19 INFO: id.co.gtc.erhacam.Detectors.LoadFrontalFaceDetector() FaceDetector loaded
|
||||||
|
2025-03-24 16:05:19 INFO: id.co.gtc.erhacam.Detectors.LoadEyeDetector() Eye Detector file : C:\Users\rdkar\OneDrive\Documents\IntelliJ Project\ErhaCam\haarcascade_eye.xml
|
||||||
|
2025-03-24 16:05:19 INFO: id.co.gtc.erhacam.Detectors.LoadEyeDetector() EyeDetector loaded
|
||||||
|
2025-03-24 16:05:19 INFO: id.co.gtc.erhacam.Detectors.LoadProfileFaceDetector() Profile Face Detector file : C:\Users\rdkar\OneDrive\Documents\IntelliJ Project\ErhaCam\haarcascade_profileface.xml
|
||||||
|
2025-03-24 16:05:19 INFO: id.co.gtc.erhacam.Detectors.LoadProfileFaceDetector() ProfileFaceDetector loaded
|
||||||
|
2025-03-24 16:05:20 INFO: id.co.gtc.erhacam.MainApplication.start() Application started
|
||||||
|
2025-03-24 16:05:20 INFO: id.co.gtc.erhacam.CaptureView.lambda$initialize$13() Left90 Index: 1
|
||||||
|
2025-03-24 16:05:20 INFO: SecureDongle.SecureDongle.lambda$StartMonitor$0() Start Monitoring UserID=14022025
|
||||||
|
2025-03-24 16:05:20 INFO: id.co.gtc.erhacam.CaptureView.onLog() [01] : QR Reader loaded
|
||||||
|
2025-03-24 16:05:20 INFO: id.co.gtc.erhacam.CaptureView.onLog() [01] : Face detector loaded
|
||||||
|
2025-03-24 16:05:24 INFO: id.co.gtc.erhacam.SettingView.initialize() Found 3 Cameras
|
||||||
|
2025-03-24 16:05:24 INFO: id.co.gtc.erhacam.SettingView.lambda$initialize$2() adding camera : ACER QHD User Facing to camera list
|
||||||
|
2025-03-24 16:05:24 INFO: id.co.gtc.erhacam.SettingView.lambda$initialize$2() adding camera : OBSBOT Meet 2 StreamCamera to camera list
|
||||||
|
2025-03-24 16:05:24 INFO: id.co.gtc.erhacam.SettingView.lambda$initialize$2() adding camera : OBSBOT Virtual Camera to camera list
|
||||||
|
2025-03-24 16:05:31 INFO: Database.Sqlite.CreateDatabase() Database created successfully
|
||||||
|
2025-03-24 16:05:31 INFO: Database.Sqlite.GetAll() GetAll success, result count: 90
|
||||||
|
2025-03-24 16:05:32 INFO: id.co.gtc.erhacam.CaptureView.initialize() Audio Player : Inited
|
||||||
|
2025-03-24 16:05:32 INFO: id.co.gtc.erhacam.CaptureView.lambda$initialize$13() Left90 Index: 1
|
||||||
|
2025-03-24 16:05:32 INFO: id.co.gtc.erhacam.CaptureView.onLog() [01] : QR Reader loaded
|
||||||
|
2025-03-24 16:05:32 INFO: id.co.gtc.erhacam.CaptureView.onLog() [01] : Face detector loaded
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\IdeaProjects\ErhaCam\thumbs\240980 2025-3-24_12-38-45 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_13-50-34 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_14-41-17 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_14-49-11 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_14-50-41 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_15-12-36 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_15-26-18 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_15-36-34 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:05:33 ERROR: id.co.gtc.erhacam.PhotoRow.loadImage() Error loading image: C:\Users\Erha\Desktop\ErhaCapture\thumbs\240980 2025-3-24_15-37-53 01.png, Msg : OpenCV(4.9.0) D:\a\javacpp-presets\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-4.9.0\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
|
||||||
|
|
||||||
|
2025-03-24 16:07:13 ERROR: id.co.gtc.erhacam.MainView.loadContent() loadContent Not loading empty fxml file
|
||||||
|
2025-03-24 16:07:13 INFO: id.co.gtc.erhacam.MainApplication.lambda$start$0() Application closed
|
||||||
|
|||||||
Binary file not shown.
@@ -12,6 +12,7 @@ import javafx.scene.control.TextField;
|
|||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.PixelFormat;
|
import javafx.scene.image.PixelFormat;
|
||||||
import javafx.scene.image.WritableImage;
|
import javafx.scene.image.WritableImage;
|
||||||
|
import lombok.NonNull;
|
||||||
import org.bytedeco.javacv.Frame;
|
import org.bytedeco.javacv.Frame;
|
||||||
import org.bytedeco.javacv.Java2DFrameConverter;
|
import org.bytedeco.javacv.Java2DFrameConverter;
|
||||||
import org.bytedeco.javacv.OpenCVFrameConverter;
|
import org.bytedeco.javacv.OpenCVFrameConverter;
|
||||||
@@ -34,9 +35,12 @@ import java.net.InetAddress;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.nio.file.attribute.FileTime;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.bytedeco.opencv.global.opencv_core.CV_64F;
|
import static org.bytedeco.opencv.global.opencv_core.CV_64F;
|
||||||
@@ -182,6 +186,74 @@ public class SomeCodes {
|
|||||||
return x.format(dtf);
|
return x.format(dtf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDateTime StringToLocalDateTime(String x){
|
||||||
|
if (ValidString(x)){
|
||||||
|
try{
|
||||||
|
return LocalDateTime.parse(x, dtf);
|
||||||
|
} catch (Exception e){
|
||||||
|
Logger.error("Error parsing date: "+x+", Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocalDateTime GetCreationTime(Path p){
|
||||||
|
try{
|
||||||
|
BasicFileAttributes attr = Files.readAttributes(p, BasicFileAttributes.class);
|
||||||
|
FileTime ft = attr.creationTime();
|
||||||
|
return LocalDateTime.ofInstant(ft.toInstant(), java.time.ZoneId.systemDefault());
|
||||||
|
} catch (Exception e){
|
||||||
|
Logger.error("Error getting creation time: "+p+", Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @NonNull Path[] GetFilesInDirectory(String path) {
|
||||||
|
if (ValidDirectory(path)) {
|
||||||
|
try{
|
||||||
|
return Files.list(Path.of(path))
|
||||||
|
.filter(Files::isRegularFile)
|
||||||
|
.toArray(Path[]::new);
|
||||||
|
} catch (Exception ignored){}
|
||||||
|
}
|
||||||
|
return new Path[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean Delete(String... path){
|
||||||
|
if (path!=null && path.length>0){
|
||||||
|
Boolean[] result = new Boolean[path.length];
|
||||||
|
for(int i=0; i<path.length; i++){
|
||||||
|
try{
|
||||||
|
result[i] = Files.deleteIfExists(Path.of(path[i]));
|
||||||
|
if (result[i]) System.out.println("Delete: "+path[i]);
|
||||||
|
} catch (Exception e){
|
||||||
|
result[i] = false;
|
||||||
|
System.out.println("Error deleting file: "+path[i]+", Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Arrays.stream(result).allMatch(x->x);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean Delete(Path... path){
|
||||||
|
if (path!=null && path.length>0){
|
||||||
|
Boolean[] result = new Boolean[path.length];
|
||||||
|
for(int i=0; i<path.length; i++){
|
||||||
|
try{
|
||||||
|
result[i] = Files.deleteIfExists(path[i]);
|
||||||
|
if (result[i]) System.out.println("Delete: "+path[i]);
|
||||||
|
} catch (Exception e){
|
||||||
|
result[i] = false;
|
||||||
|
System.out.println("Error deleting file: "+path[i]+", Msg : "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Arrays.stream(result).allMatch(x->x);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract resource file to current directory
|
* Extract resource file to current directory
|
||||||
* @param filename resource file name
|
* @param filename resource file name
|
||||||
|
|||||||
130
src/main/java/Database/PhotoCleaner.java
Normal file
130
src/main/java/Database/PhotoCleaner.java
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
package Database;
|
||||||
|
|
||||||
|
import Config.SomeCodes;
|
||||||
|
import org.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PhotoCleaner class
|
||||||
|
* Responsible for deleting photos older than a certain number of days
|
||||||
|
*/
|
||||||
|
public class PhotoCleaner {
|
||||||
|
private final int days;
|
||||||
|
private final boolean[] started;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PhotoCleaner constructor
|
||||||
|
* @param days how many days old photos to delete
|
||||||
|
*/
|
||||||
|
public PhotoCleaner(int days){
|
||||||
|
this.days = days;
|
||||||
|
this.started = new boolean[]{false};
|
||||||
|
System.out.println("PhotoCleaner created, days: "+days);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start PhotoCleaner Thread
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("BusyWait")
|
||||||
|
public void Start(){
|
||||||
|
Thread thread = new Thread(() -> {
|
||||||
|
started[0] = true;
|
||||||
|
System.out.println("PhotoCleaner started");
|
||||||
|
while (started[0]) {
|
||||||
|
try {
|
||||||
|
System.out.println("Rechecking Database for older photos...");
|
||||||
|
// Delete photos older than the specified number of days
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
// delete from database
|
||||||
|
Thread sqldelete = new Thread(()->{
|
||||||
|
Sqlite sql = new Sqlite();
|
||||||
|
PhotoReviewClass[] prcs = sql.GetAll();
|
||||||
|
System.out.println("Database contains "+prcs.length+" PhotoReviewClass");
|
||||||
|
for (PhotoReviewClass prc : prcs) {
|
||||||
|
if (!started[0]) break;
|
||||||
|
if (prc != null && prc.getDateTime() != null) {
|
||||||
|
LocalDateTime ldt = SomeCodes.StringToLocalDateTime(prc.getDateTime());
|
||||||
|
if (ldt!=null){
|
||||||
|
if (ldt.isBefore(now.minusDays(days))) {
|
||||||
|
SomeCodes.Delete(prc.fullres());
|
||||||
|
SomeCodes.Delete(prc.cropped());
|
||||||
|
SomeCodes.Delete(prc.compressed());
|
||||||
|
SomeCodes.Delete(prc.compressedcrop());
|
||||||
|
SomeCodes.Delete(prc.thumbnails());
|
||||||
|
sql.Delete(prc);
|
||||||
|
System.out.println("Deleted PhotoReviewClass: " + prc.getDateTime() + " " + prc.getPrefix());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RunThread(sqldelete, "DeleteFromDatabase");
|
||||||
|
|
||||||
|
// delete from disk
|
||||||
|
Thread deletefullres = new Thread(new DiskDeleter(SomeCodes.config.getFullQualityDirectory()));
|
||||||
|
RunThread(deletefullres, "DeleteFullRes");
|
||||||
|
Thread deletefullrescrop = new Thread(new DiskDeleter(SomeCodes.config.getFullQualityCropDirectory()));
|
||||||
|
RunThread(deletefullrescrop, "DeleteFullResCrop");
|
||||||
|
Thread deletecompressed = new Thread(new DiskDeleter(SomeCodes.config.getCompressedDirectory()));
|
||||||
|
RunThread(deletecompressed, "DeleteCompressed");
|
||||||
|
Thread deletecompressedcrop = new Thread(new DiskDeleter(SomeCodes.config.getCompressedCropDirectory()));
|
||||||
|
RunThread(deletecompressedcrop, "DeleteCompressedCrop");
|
||||||
|
Thread deletethumbnails = new Thread(new DiskDeleter(SomeCodes.config.getThumbsDirectory()));
|
||||||
|
RunThread(deletethumbnails, "DeleteThumbnails");
|
||||||
|
|
||||||
|
|
||||||
|
// Sleep for 1 hour
|
||||||
|
Thread.sleep(60 * 60 * 1000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error("Error in PhotoCleaner Thread: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("PhotoCleaner stopped");
|
||||||
|
});
|
||||||
|
thread.setName("PhotoCleaner Thread");
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunThread(Thread thread, String name){
|
||||||
|
thread.setName(name);
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiskDeleter implements Runnable{
|
||||||
|
private final String path;
|
||||||
|
private final LocalDateTime now ;
|
||||||
|
public DiskDeleter(String path){
|
||||||
|
this.path = path;
|
||||||
|
this.now = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
public void run(){
|
||||||
|
System.out.println("DiskDeleter started, path: "+path);
|
||||||
|
Path[] ppp = SomeCodes.GetFilesInDirectory(path);
|
||||||
|
if (ppp != null){
|
||||||
|
System.out.println("DiskDeleter found "+ppp.length+" files in path: "+path);
|
||||||
|
for(Path p : ppp){
|
||||||
|
if (!started[0]) break;
|
||||||
|
LocalDateTime ldt = SomeCodes.GetCreationTime(p);
|
||||||
|
if (ldt != null) {
|
||||||
|
if (ldt.isBefore(now.minusDays(days))) {
|
||||||
|
SomeCodes.Delete(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop PhotoCleaner Thread
|
||||||
|
*/
|
||||||
|
public void Stop(){
|
||||||
|
started[0] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ package Database;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static Config.SomeCodes.MakeArray;
|
import static Config.SomeCodes.MakeArray;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -40,13 +40,32 @@ public class Sqlite {
|
|||||||
*/
|
*/
|
||||||
public void Insert(PhotoReviewClass pr){
|
public void Insert(PhotoReviewClass pr){
|
||||||
if (pr!=null){
|
if (pr!=null){
|
||||||
// System.out.println("Inserting PhotoReviewClass");
|
|
||||||
// System.out.println(pr);
|
|
||||||
Insert(pr.getPrefix(), pr.getFileLeft90(), pr.getFileLeft45(), pr.getFileCenter(), pr.getFileRight45(), pr.getFileRight90(), pr.getThumbLeft90(), pr.getThumbLeft45(), pr.getThumbCenter(), pr.getThumbRight45(), pr.getThumbRight90());
|
Insert(pr.getPrefix(), pr.getFileLeft90(), pr.getFileLeft45(), pr.getFileCenter(), pr.getFileRight45(), pr.getFileRight90(), pr.getThumbLeft90(), pr.getThumbLeft45(), pr.getThumbCenter(), pr.getThumbRight45(), pr.getThumbRight90());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete PhotoReviewClass object from database
|
||||||
|
* @param pr PhotoReviewClass objects
|
||||||
|
*/
|
||||||
|
public void Delete(PhotoReviewClass... pr){
|
||||||
|
if (pr!=null && pr.length>0){
|
||||||
|
try{
|
||||||
|
Connection conn = GetConnection();
|
||||||
|
if (conn != null){
|
||||||
|
for (PhotoReviewClass photo : pr) {
|
||||||
|
PreparedStatement stmt = conn.prepareStatement("DELETE FROM photos WHERE id = ?");
|
||||||
|
stmt.setInt(1, photo.getId());
|
||||||
|
stmt.execute();
|
||||||
|
}
|
||||||
|
conn.close();
|
||||||
|
Logger.info("Data deleted successfully");
|
||||||
|
} else Logger.info("Delete failed, connection is null");
|
||||||
|
} catch (Exception e){
|
||||||
|
Logger.error("Error deleting data: "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all PhotoReviewClass object from database
|
* Get all PhotoReviewClass object from database
|
||||||
@@ -108,14 +127,6 @@ public class Sqlite {
|
|||||||
try{
|
try{
|
||||||
Connection conn = GetConnection();
|
Connection conn = GetConnection();
|
||||||
if (conn != null){
|
if (conn != null){
|
||||||
// System.out.println("Inserting data");
|
|
||||||
// System.out.println("prefix: "+prefix);
|
|
||||||
// System.out.println("fileLeft90: "+fileLeft90);
|
|
||||||
// System.out.println("fileLeft45: "+fileLeft45);
|
|
||||||
// System.out.println("fileCenter: "+fileCenter);
|
|
||||||
// System.out.println("fileRight45: "+fileRight45);
|
|
||||||
// System.out.println("fileRight90: "+fileRight90);
|
|
||||||
|
|
||||||
PreparedStatement stmt = conn.prepareStatement("INSERT INTO photos (DateTime, Prefix, FileLeft90, FileLeft45, FileCenter, FileRight45, FileRight90, ThumbLeft90, ThumbLeft45, ThumbCenter, ThumbRight45, ThumbRight90 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
PreparedStatement stmt = conn.prepareStatement("INSERT INTO photos (DateTime, Prefix, FileLeft90, FileLeft45, FileCenter, FileRight45, FileRight90, ThumbLeft90, ThumbLeft45, ThumbCenter, ThumbRight45, ThumbRight90 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
stmt.setString(1, LocalDateTimeToString(LocalDateTime.now()));
|
stmt.setString(1, LocalDateTimeToString(LocalDateTime.now()));
|
||||||
stmt.setString(2, ValidString(prefix)?prefix:"");
|
stmt.setString(2, ValidString(prefix)?prefix:"");
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package id.co.gtc.erhacam;
|
package id.co.gtc.erhacam;
|
||||||
|
|
||||||
import Config.SomeCodes;
|
import Config.SomeCodes;
|
||||||
|
import Database.PhotoCleaner;
|
||||||
import SecureDongle.SecureDongle;
|
import SecureDongle.SecureDongle;
|
||||||
import SecureDongle.SecureDongleEvent;
|
import SecureDongle.SecureDongleEvent;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
@@ -21,6 +22,8 @@ import static Config.SomeCodes.config;
|
|||||||
|
|
||||||
|
|
||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
|
|
||||||
|
PhotoCleaner photoCleaner;
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage stage) throws IOException {
|
||||||
|
|
||||||
@@ -31,6 +34,7 @@ public class MainApplication extends Application {
|
|||||||
System.out.println("Thread: " + thread.getName()+", State: " + thread.getState()+", Daemon: " + thread.isDaemon());
|
System.out.println("Thread: " + thread.getName()+", State: " + thread.getState()+", Daemon: " + thread.isDaemon());
|
||||||
//thread.interrupt();
|
//thread.interrupt();
|
||||||
}
|
}
|
||||||
|
if (photoCleaner!=null) photoCleaner.Stop();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
@@ -46,7 +50,7 @@ public class MainApplication extends Application {
|
|||||||
Screen screen = Screen.getPrimary();
|
Screen screen = Screen.getPrimary();
|
||||||
Rectangle2D screenbound = screen.getBounds();
|
Rectangle2D screenbound = screen.getBounds();
|
||||||
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
|
Scene scene = new Scene(fxmlLoader.load(), screenbound.getWidth(), screenbound.getHeight());
|
||||||
stage.setTitle("MultiCam Capture App for ERHA 09052025-001");
|
stage.setTitle("MultiCam Capture App for ERHA 13052025-001");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setResizable(true);
|
stage.setResizable(true);
|
||||||
stage.setMaximized(true);
|
stage.setMaximized(true);
|
||||||
@@ -82,6 +86,9 @@ public class MainApplication extends Application {
|
|||||||
});
|
});
|
||||||
sd.StartMonitor();
|
sd.StartMonitor();
|
||||||
|
|
||||||
|
photoCleaner = new PhotoCleaner(90);
|
||||||
|
photoCleaner.Start();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ShowAlert(Alert.AlertType.ERROR, "Secure Dongle UserID not valid", "Secure Dongle UserID not valid", "Secure Dongle UserID not valid");
|
ShowAlert(Alert.AlertType.ERROR, "Secure Dongle UserID not valid", "Secure Dongle UserID not valid", "Secure Dongle UserID not valid");
|
||||||
Logger.error("Secure Dongle UserID not valid");
|
Logger.error("Secure Dongle UserID not valid");
|
||||||
|
|||||||
Reference in New Issue
Block a user