commit 02/09/2025
This commit is contained in:
@@ -1,25 +1,10 @@
|
||||
package database
|
||||
|
||||
@Suppress("unused")
|
||||
data class Log(
|
||||
val index: ULong,
|
||||
val datenya: String,
|
||||
val timenya: String,
|
||||
val machine: String,
|
||||
val description : String
|
||||
) {
|
||||
@Suppress("unused")
|
||||
companion object {
|
||||
|
||||
fun ValidDate(date: String): Boolean {
|
||||
// Simple date validation (DD/MM/YYYY)
|
||||
val regex = Regex("""^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/\d{4}$""")
|
||||
return regex.matches(date)
|
||||
}
|
||||
|
||||
fun validTime(time: String): Boolean {
|
||||
// Simple time validation (HH:MM:SS)
|
||||
val regex = Regex("""^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$""")
|
||||
return regex.matches(time)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -217,7 +217,7 @@ class MariaDB (
|
||||
/**
|
||||
* Reloads the ScheduleBank list from the database.
|
||||
*/
|
||||
private fun Reload_Schedulebank() {
|
||||
fun Reload_Schedulebank() {
|
||||
SchedulebankList.clear()
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
@@ -266,22 +266,24 @@ class MariaDB (
|
||||
/**
|
||||
* Clears all entries from the schedulebank table in the database and the local list.
|
||||
*/
|
||||
fun Clear_Schedulebank() {
|
||||
fun Clear_Schedulebank() : Boolean {
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
// use TRUNCATE to reset auto increment index
|
||||
statement?.executeUpdate("TRUNCATE TABLE schedulebank")
|
||||
Logger.info("Schedulebank table cleared" as Any)
|
||||
SchedulebankList.clear()
|
||||
return true
|
||||
} catch (e : Exception) {
|
||||
Logger.error("Error clearing schedulebank table: ${e.message}" as Any)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the language link list from the database.
|
||||
*/
|
||||
private fun Reload_LanguageLink() {
|
||||
fun Reload_LanguageLink() {
|
||||
LanguageLinkList.clear()
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
@@ -324,22 +326,24 @@ class MariaDB (
|
||||
/**
|
||||
* Clears all entries from the language link table in the database and the local list.
|
||||
*/
|
||||
fun Clear_LanguageLink() {
|
||||
fun Clear_LanguageLink() : Boolean {
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
// use TRUNCATE to reset auto increment index
|
||||
statement?.executeUpdate("TRUNCATE TABLE languagelink")
|
||||
Logger.info("LanguageLink table cleared" as Any)
|
||||
LanguageLinkList.clear()
|
||||
return true
|
||||
} catch (e : Exception) {
|
||||
Logger.error("Error clearing LanguageLink table: ${e.message}" as Any)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the soundbank list from the database.
|
||||
*/
|
||||
private fun Reload_Soundbank() {
|
||||
fun Reload_Soundbank() {
|
||||
|
||||
SoundbankList.clear()
|
||||
try {
|
||||
@@ -387,22 +391,24 @@ class MariaDB (
|
||||
/**
|
||||
* Clears all entries from the soundbank table in the database and the local list.
|
||||
*/
|
||||
fun Clear_Soundbank() {
|
||||
fun Clear_Soundbank() : Boolean{
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
// use TRUNCATE to reset auto increment index
|
||||
statement?.executeUpdate("TRUNCATE TABLE soundbank")
|
||||
Logger.info("Soundbank table cleared" as Any)
|
||||
SoundbankList.clear()
|
||||
return true
|
||||
} catch (e : Exception) {
|
||||
Logger.error("Error clearing soundbank table: ${e.message}" as Any)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the messagebank list from the database.
|
||||
*/
|
||||
private fun Reload_Messagebank() {
|
||||
fun Reload_Messagebank() {
|
||||
MessagebankList.clear()
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
@@ -450,16 +456,18 @@ class MariaDB (
|
||||
/**
|
||||
* Clears all entries from the messagebank table in the database and the local list.
|
||||
*/
|
||||
fun Clear_Messagebank() {
|
||||
fun Clear_Messagebank() : Boolean{
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
// use TRUNCATE to reset auto increment index
|
||||
statement?.executeUpdate("TRUNCATE TABLE messagebank")
|
||||
Logger.info("Messagebank table cleared" as Any)
|
||||
MessagebankList.clear()
|
||||
return true
|
||||
} catch (e : Exception) {
|
||||
Logger.error("Error clearing messagebank table: ${e.message}" as Any)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,15 +524,17 @@ class MariaDB (
|
||||
/**
|
||||
* Clears all entries from the queue_table in the database.
|
||||
*/
|
||||
fun Clear_Queue_Table() {
|
||||
fun Clear_Queue_Table() : Boolean {
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
// use TRUNCATE to reset auto increment index
|
||||
statement?.executeUpdate("TRUNCATE TABLE queue_table")
|
||||
Logger.info("Queue table cleared" as Any)
|
||||
return true
|
||||
} catch (e : Exception) {
|
||||
Logger.error("Error clearing queue table: ${e.message}" as Any)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,15 +588,17 @@ class MariaDB (
|
||||
/**
|
||||
* Clears all entries from the queue_paging in the database.
|
||||
*/
|
||||
fun Clear_Queue_Paging(){
|
||||
fun Clear_Queue_Paging() : Boolean{
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
// use TRUNCATE to reset auto increment index
|
||||
statement?.executeUpdate("TRUNCATE TABLE queue_paging")
|
||||
Logger.info("Queue paging table cleared" as Any)
|
||||
return true
|
||||
} catch (e : Exception) {
|
||||
Logger.error("Error clearing queue paging table: ${e.message}" as Any)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -639,15 +651,17 @@ class MariaDB (
|
||||
/**
|
||||
* Clears all entries from the broadcast_zones in the database.
|
||||
*/
|
||||
fun Clear_BroadcastZones() {
|
||||
fun Clear_BroadcastZones() : Boolean {
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
// use TRUNCATE to reset auto increment index
|
||||
statement?.executeUpdate("TRUNCATE TABLE broadcast_zones")
|
||||
Logger.info("Broadcast zones table cleared" as Any)
|
||||
return true
|
||||
} catch (e : Exception) {
|
||||
Logger.error("Error clearing broadcast zones table: ${e.message}" as Any)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user