diff --git a/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchAttendanceJob.java b/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchAttendanceJob.java index 1f4b1e0e..98e0dcfc 100644 --- a/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchAttendanceJob.java +++ b/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchAttendanceJob.java @@ -10,10 +10,12 @@ import org.quartz.JobExecutionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.quartz.SchedulerException; +import com.axelor.app.AppSettings; public class FetchAttendanceJob implements Job { private final Logger log = LoggerFactory.getLogger(FetchCheckInOutJob.class); + private final String pythonScriptDir = AppSettings.get().get("services.dir"); @Override public void execute(JobExecutionContext context) throws JobExecutionException{ @@ -22,9 +24,14 @@ public class FetchAttendanceJob implements Job { return; } + if (pythonScriptDir == null || pythonScriptDir.isEmpty()) { + log.error("Python script path is not configured in AppSettings."); + return; + } + try { // Define the command to run the Python script with the correct path (V3) - String[] args = {"python", "C:\\Users\\administrator\\Desktop\\Scrape\\main.py"}; + String[] args = {"python", pythonScriptDir + "\\Scrape\\main.py"}; // Execute the command Process p = Runtime.getRuntime().exec(args); diff --git a/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchCheckInOutJob.java b/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchCheckInOutJob.java index 4f054382..d340235b 100644 --- a/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchCheckInOutJob.java +++ b/modules/axelor-open-suite/axelor-human-resource/src/main/java/com/axelor/apps/hr/job/FetchCheckInOutJob.java @@ -14,10 +14,12 @@ import org.slf4j.LoggerFactory; import com.axelor.inject.Beans; import java.time.LocalDate; import org.quartz.SchedulerException; +import com.axelor.app.AppSettings; public class FetchCheckInOutJob implements Job { private final Logger log = LoggerFactory.getLogger(FetchCheckInOutJob.class); + private final String pythonScriptDir = AppSettings.get().get("services.dir"); @Override public void execute(JobExecutionContext context) throws JobExecutionException { @@ -26,6 +28,11 @@ public class FetchCheckInOutJob implements Job { return; } + if (pythonScriptDir == null || pythonScriptDir.isEmpty()) { + log.error("Python script path is not configured in AppSettings."); + return; + } + try { LocalDate today = LocalDate.now(); @@ -35,11 +42,10 @@ public class FetchCheckInOutJob implements Job { .all() .filter("self.date_attendance = :today") .bind("today", today) - .fetch() - .size(); + .fetch().size(); // Define the command to run the Python script with the correct path (V3) - String[] args = {"python", "C:\\Users\\administrator\\Desktop\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)}; + String[] args = {"python", pythonScriptDir + "\\Scrape\\main2.py", String.valueOf(lenCheckInOutList)}; // Execute the command Process p = Runtime.getRuntime().exec(args); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 170e4afa..67937ddb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,16 +8,20 @@ # ~~~~~ db.default.driver = org.postgresql.Driver db.default.ddl = update -db.default.url = jdbc:postgresql://localhost:5432/postgres5 +db.default.url = jdbc:postgresql://localhost:5432/bdd_test2 db.default.user = postgres db.default.password = Mal@Ben$$23 -# API +# Api # ~~~~~ portail.api.baseurl = http://127.0.0.1:8000/api/ portail.api.user = admin portail.api.password = 0000 +# Services file directory +# ~~~~~~~~~~~~~~~~~~~~~~ +services.dir = {user.home}/axelor/services + # Application Information # ~~~~~ application.name = SOPHAL SPA @@ -193,8 +197,8 @@ logging.level.com.axelor = DEBUG # Quartz scheduler # ~~~~~ -quartz.enable = false -# quartz.threadCount = 5 +quartz.enable = true +quartz.threadCount = 1 # Allows to open maximum 10 Tabs view.tabs.max = 10