commit 13/02/2026
This commit is contained in:
35
src/Main.kt
35
src/Main.kt
@@ -16,10 +16,13 @@ import content.Language
|
|||||||
import content.VoiceType
|
import content.VoiceType
|
||||||
import database.data.Log
|
import database.data.Log
|
||||||
import database.MariaDB
|
import database.MariaDB
|
||||||
|
import database.data.QueueTable
|
||||||
import database.table.Table_Adzan
|
import database.table.Table_Adzan
|
||||||
import database.table.Table_BroadcastZones
|
import database.table.Table_BroadcastZones
|
||||||
import database.table.Table_Logs
|
import database.table.Table_Logs
|
||||||
import database.table.Table_Messagebank
|
import database.table.Table_Messagebank
|
||||||
|
import database.table.Table_QueuePaging
|
||||||
|
import database.table.Table_QueueSoundbank
|
||||||
import database.table.Table_SoundChannel
|
import database.table.Table_SoundChannel
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -55,6 +58,8 @@ val apptick : Long = System.currentTimeMillis()
|
|||||||
lateinit var broadcastDB: Table_BroadcastZones
|
lateinit var broadcastDB: Table_BroadcastZones
|
||||||
lateinit var soundchannelDB: Table_SoundChannel
|
lateinit var soundchannelDB: Table_SoundChannel
|
||||||
lateinit var messageDB: Table_Messagebank
|
lateinit var messageDB: Table_Messagebank
|
||||||
|
lateinit var queuetableDB: Table_QueueSoundbank
|
||||||
|
lateinit var queuepagingDB: Table_QueuePaging
|
||||||
lateinit var logDB: Table_Logs
|
lateinit var logDB: Table_Logs
|
||||||
|
|
||||||
lateinit var adzanTable : Table_Adzan
|
lateinit var adzanTable : Table_Adzan
|
||||||
@@ -182,6 +187,7 @@ fun main(args: Array<String>) {
|
|||||||
longitude = config.Get(configKeys.LONGITUDE.key).toDouble(),
|
longitude = config.Get(configKeys.LONGITUDE.key).toDouble(),
|
||||||
timezone = TimeZone.getTimeZone(config.Get(configKeys.TIMEZONE.key))
|
timezone = TimeZone.getTimeZone(config.Get(configKeys.TIMEZONE.key))
|
||||||
)
|
)
|
||||||
|
adzanTable.GetTodayPrayerTimes()
|
||||||
|
|
||||||
|
|
||||||
val subcode01 = MainExtension01()
|
val subcode01 = MainExtension01()
|
||||||
@@ -190,18 +196,35 @@ fun main(args: Array<String>) {
|
|||||||
CoroutineScope(Dispatchers.Default).launch {
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
delay(1000)
|
delay(1000)
|
||||||
|
|
||||||
|
adzanTable.CheckTime()?.let{ adz ->
|
||||||
|
Logger.info { "It's time for Adzan ${adz.prayerName} at ${adz.timeString}" }
|
||||||
|
val qt = QueueTable(
|
||||||
|
Source = "AAS",
|
||||||
|
Type = "ADZAN",
|
||||||
|
Message = adz.message,
|
||||||
|
Language = adzanTable.adzan_language,
|
||||||
|
SB_TAGS = adz.sb_tags,
|
||||||
|
BroadcastZones = adzanTable.adzan_broadcastzones
|
||||||
|
)
|
||||||
|
queuetableDB.Add(qt)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// prioritas 1 , habisin queue paging
|
// prioritas 1 , habisin queue paging
|
||||||
if (subcode01.Read_Queue_Paging()){
|
if (subcode01.Read_Queue_Paging()){
|
||||||
// processing paging, skip selanjutnya
|
// processing paging, skip selanjutnya
|
||||||
delay(2000)
|
delay(2000)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// prioritas 2, habisin queue shalat
|
// // prioritas 2, habisin queue shalat
|
||||||
if (subcode01.Read_Queue_Shalat()){
|
// if (subcode01.Read_Queue_Shalat()){
|
||||||
// processing shalat, skip selanjutnya
|
// // processing shalat, skip selanjutnya
|
||||||
delay(2000)
|
// delay(2000)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// prioritas 3, habisin queue timer
|
// prioritas 3, habisin queue timer
|
||||||
if (subcode01.Read_Queue_Timer()){
|
if (subcode01.Read_Queue_Timer()){
|
||||||
// processing timer, skip selanjutnya
|
// processing timer, skip selanjutnya
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import codes.Somecodes.Companion.SoundbankResult_directory
|
|||||||
import codes.Somecodes.Companion.ValidFile
|
import codes.Somecodes.Companion.ValidFile
|
||||||
import codes.Somecodes.Companion.ValidString
|
import codes.Somecodes.Companion.ValidString
|
||||||
import codes.Somecodes.Companion.dateformat1
|
import codes.Somecodes.Companion.dateformat1
|
||||||
import codes.Somecodes.Companion.datetimeformat1
|
|
||||||
import codes.Somecodes.Companion.timeformat2
|
import codes.Somecodes.Companion.timeformat2
|
||||||
import codes.configKeys
|
import codes.configKeys
|
||||||
import content.Category
|
import content.Category
|
||||||
@@ -22,7 +21,6 @@ import database.data.Soundbank
|
|||||||
import org.tinylog.Logger
|
import org.tinylog.Logger
|
||||||
import java.time.DayOfWeek
|
import java.time.DayOfWeek
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.LocalDateTime
|
|
||||||
import java.time.LocalTime
|
import java.time.LocalTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -676,8 +674,8 @@ class MainExtension01 {
|
|||||||
* @return true if a paging job is processed and started streaming, false otherwise
|
* @return true if a paging job is processed and started streaming, false otherwise
|
||||||
*/
|
*/
|
||||||
fun Read_Queue_Paging(): Boolean {
|
fun Read_Queue_Paging(): Boolean {
|
||||||
db.queuepagingDB.Get()
|
queuepagingDB.Get()
|
||||||
val qp = db.queuepagingDB.List.firstOrNull { it.Type.equals("PAGING", true) }
|
val qp = queuepagingDB.List.firstOrNull { it.Type.equals("PAGING", true) }
|
||||||
if (qp == null) return false
|
if (qp == null) return false
|
||||||
try {
|
try {
|
||||||
if (!ValidFile(qp.Message)) throw Exception("Invalid audio file ${qp.Message}")
|
if (!ValidFile(qp.Message)) throw Exception("Invalid audio file ${qp.Message}")
|
||||||
@@ -722,14 +720,14 @@ class MainExtension01 {
|
|||||||
"Broadcast started PAGING with Filename '${qp.Message}' to zones: ${qp.BroadcastZones}"
|
"Broadcast started PAGING with Filename '${qp.Message}' to zones: ${qp.BroadcastZones}"
|
||||||
Logger.info { logmessage }
|
Logger.info { logmessage }
|
||||||
logDB.Add("AAS", logmessage)
|
logDB.Add("AAS", logmessage)
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
db.queuepagingDB.Resort()
|
queuepagingDB.Resort()
|
||||||
return true
|
return true
|
||||||
} else throw Exception("Audio file ${qp.Message} is not valid")
|
} else throw Exception("Audio file ${qp.Message} is not valid")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
db.queuepagingDB.Resort()
|
queuepagingDB.Resort()
|
||||||
val msg = "Canceled paging message $qp due to exception: ${e.message}"
|
val msg = "Canceled paging message $qp due to exception: ${e.message}"
|
||||||
logDB.Add("AAS", msg)
|
logDB.Add("AAS", msg)
|
||||||
Logger.error { msg }
|
Logger.error { msg }
|
||||||
@@ -742,8 +740,8 @@ class MainExtension01 {
|
|||||||
* @return true if a shalat job is processed and started streaming, false otherwise
|
* @return true if a shalat job is processed and started streaming, false otherwise
|
||||||
*/
|
*/
|
||||||
fun Read_Queue_Shalat(): Boolean {
|
fun Read_Queue_Shalat(): Boolean {
|
||||||
db.queuepagingDB.Get()
|
queuepagingDB.Get()
|
||||||
val qp = db.queuepagingDB.List.firstOrNull { it.Type.equals("SHALAT", true) }
|
val qp = queuepagingDB.List.firstOrNull { it.Type.equals("SHALAT", true) }
|
||||||
if (qp == null) return false
|
if (qp == null) return false
|
||||||
try {
|
try {
|
||||||
val ann_id = Get_ANN_ID(qp.Message)
|
val ann_id = Get_ANN_ID(qp.Message)
|
||||||
@@ -829,14 +827,14 @@ class MainExtension01 {
|
|||||||
"Broadcast started SHALAT message with generated file '$targetfile' to zones: ${qp.BroadcastZones}"
|
"Broadcast started SHALAT message with generated file '$targetfile' to zones: ${qp.BroadcastZones}"
|
||||||
Logger.info { logmsg }
|
Logger.info { logmsg }
|
||||||
logDB.Add("AAS", logmsg)
|
logDB.Add("AAS", logmsg)
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
db.queuepagingDB.Resort()
|
queuepagingDB.Resort()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
db.queuepagingDB.Resort()
|
queuepagingDB.Resort()
|
||||||
val msg = "Canceled shalat message $qp due to exception: ${e.message}"
|
val msg = "Canceled shalat message $qp due to exception: ${e.message}"
|
||||||
logDB.Add("AAS", msg)
|
logDB.Add("AAS", msg)
|
||||||
Logger.error { msg }
|
Logger.error { msg }
|
||||||
@@ -849,8 +847,8 @@ class MainExtension01 {
|
|||||||
* @return true if a timer job is processed and started streaming, false otherwise
|
* @return true if a timer job is processed and started streaming, false otherwise
|
||||||
*/
|
*/
|
||||||
fun Read_Queue_Timer(): Boolean {
|
fun Read_Queue_Timer(): Boolean {
|
||||||
db.queuetableDB.Get()
|
queuetableDB.Get()
|
||||||
val qa = db.queuetableDB.List.firstOrNull { it.Type.equals("TIMER", true) }
|
val qa = queuetableDB.List.firstOrNull { it.Type.equals("TIMER", true) }
|
||||||
if (qa == null) return false
|
if (qa == null) return false
|
||||||
try {
|
try {
|
||||||
val ann_id = Get_ANN_ID(qa.SB_TAGS)
|
val ann_id = Get_ANN_ID(qa.SB_TAGS)
|
||||||
@@ -928,14 +926,14 @@ class MainExtension01 {
|
|||||||
"Broadcast started TIMER message with generated file '$targetfile' to zones: ${qa.BroadcastZones}"
|
"Broadcast started TIMER message with generated file '$targetfile' to zones: ${qa.BroadcastZones}"
|
||||||
Logger.info { logmsg }
|
Logger.info { logmsg }
|
||||||
logDB.Add("AAS", logmsg)
|
logDB.Add("AAS", logmsg)
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
db.queuetableDB.Resort()
|
queuetableDB.Resort()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
db.queuetableDB.Resort()
|
queuetableDB.Resort()
|
||||||
val msg = "Canceled TIMER message $qa due to exception: ${e.message}"
|
val msg = "Canceled TIMER message $qa due to exception: ${e.message}"
|
||||||
logDB.Add("AAS", msg)
|
logDB.Add("AAS", msg)
|
||||||
Logger.error { msg }
|
Logger.error { msg }
|
||||||
@@ -949,8 +947,8 @@ class MainExtension01 {
|
|||||||
* @return true if a soundbank job is processed and started streaming, false otherwise
|
* @return true if a soundbank job is processed and started streaming, false otherwise
|
||||||
*/
|
*/
|
||||||
fun Read_Queue_Soundbank(): Boolean {
|
fun Read_Queue_Soundbank(): Boolean {
|
||||||
db.queuetableDB.Get()
|
queuetableDB.Get()
|
||||||
val qa = db.queuetableDB.List.firstOrNull { it.Type.equals("SOUNDBANK", true) }
|
val qa = queuetableDB.List.firstOrNull { it.Type.equals("SOUNDBANK", true) }
|
||||||
if (qa == null) return false
|
if (qa == null) return false
|
||||||
//println("Processing $qa")
|
//println("Processing $qa")
|
||||||
try {
|
try {
|
||||||
@@ -1084,8 +1082,8 @@ class MainExtension01 {
|
|||||||
"Broadcast started SOUNDBANK message with generated file '$targetfile' to zones: ${qa.BroadcastZones}"
|
"Broadcast started SOUNDBANK message with generated file '$targetfile' to zones: ${qa.BroadcastZones}"
|
||||||
Logger.info { logmsg }
|
Logger.info { logmsg }
|
||||||
logDB.Add("AAS", logmsg)
|
logDB.Add("AAS", logmsg)
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
db.queuetableDB.Resort()
|
queuetableDB.Resort()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1094,8 +1092,8 @@ class MainExtension01 {
|
|||||||
val msg = "Canceled SOUNDBANK message $qa due to exception: ${e.message}"
|
val msg = "Canceled SOUNDBANK message $qa due to exception: ${e.message}"
|
||||||
logDB.Add("AAS", msg)
|
logDB.Add("AAS", msg)
|
||||||
Logger.error { msg }
|
Logger.error { msg }
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
db.queuetableDB.Resort()
|
queuetableDB.Resort()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -1125,17 +1123,14 @@ class MainExtension01 {
|
|||||||
}
|
}
|
||||||
if (specialdate != null) {
|
if (specialdate != null) {
|
||||||
val qt = QueueTable(
|
val qt = QueueTable(
|
||||||
0u,
|
Source="AAS",
|
||||||
LocalDateTime.now().format(datetimeformat1),
|
Type="TIMER",
|
||||||
"AAS",
|
Message=specialdate.Description,
|
||||||
"TIMER",
|
SB_TAGS = specialdate.Soundpath,
|
||||||
specialdate.Description,
|
BroadcastZones = specialdate.BroadcastZones,
|
||||||
specialdate.Soundpath,
|
Language = specialdate.Language
|
||||||
specialdate.BroadcastZones,
|
|
||||||
1.toUInt(),
|
|
||||||
specialdate.Language
|
|
||||||
)
|
)
|
||||||
db.queuetableDB.Add(qt)
|
queuetableDB.Add(qt)
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1153,17 +1148,14 @@ class MainExtension01 {
|
|||||||
}
|
}
|
||||||
if (weekly != null) {
|
if (weekly != null) {
|
||||||
val qt = QueueTable(
|
val qt = QueueTable(
|
||||||
0u,
|
Source="AAS",
|
||||||
LocalDateTime.now().format(datetimeformat1),
|
Type="TIMER",
|
||||||
"AAS",
|
Message=weekly.Description,
|
||||||
"TIMER",
|
SB_TAGS = weekly.Soundpath,
|
||||||
weekly.Description,
|
BroadcastZones = weekly.BroadcastZones,
|
||||||
weekly.Soundpath,
|
Language = weekly.Language
|
||||||
weekly.BroadcastZones,
|
|
||||||
1.toUInt(),
|
|
||||||
weekly.Language
|
|
||||||
)
|
)
|
||||||
db.queuetableDB.Add(qt)
|
queuetableDB.Add(qt)
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1173,17 +1165,14 @@ class MainExtension01 {
|
|||||||
}
|
}
|
||||||
if (daily != null) {
|
if (daily != null) {
|
||||||
val qt = QueueTable(
|
val qt = QueueTable(
|
||||||
0u,
|
Source="AAS",
|
||||||
LocalDateTime.now().format(datetimeformat1),
|
Type="TIMER",
|
||||||
"AAS",
|
Message = daily.Description,
|
||||||
"TIMER",
|
SB_TAGS = daily.Soundpath,
|
||||||
daily.Description,
|
BroadcastZones = daily.BroadcastZones,
|
||||||
daily.Soundpath,
|
Language = daily.Language
|
||||||
daily.BroadcastZones,
|
|
||||||
1.toUInt(),
|
|
||||||
daily.Language
|
|
||||||
)
|
)
|
||||||
db.queuetableDB.Add(qt)
|
queuetableDB.Add(qt)
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -710,7 +710,13 @@ class Somecodes {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all available time zones.
|
||||||
|
* @return A list of strings representing the available time zones.
|
||||||
|
*/
|
||||||
|
fun Get_TimeZones() : List<String>{
|
||||||
|
return ZoneId.getAvailableZoneIds().sorted()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a schedule day by its name.
|
* Find a schedule day by its name.
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import kotlinx.coroutines.launch
|
|||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import messageDB
|
import messageDB
|
||||||
import org.tinylog.Logger
|
import org.tinylog.Logger
|
||||||
|
import queuepagingDB
|
||||||
|
import queuetableDB
|
||||||
import tcpreceiver
|
import tcpreceiver
|
||||||
import udpreceiver
|
import udpreceiver
|
||||||
import java.net.ServerSocket
|
import java.net.ServerSocket
|
||||||
@@ -234,8 +236,8 @@ class TCP_Android_Command_Server {
|
|||||||
pj.broadcastzones
|
pj.broadcastzones
|
||||||
)
|
)
|
||||||
Logger.info{"Inserting paging audio to queue paging table from Android $key, data=$qp"}
|
Logger.info{"Inserting paging audio to queue paging table from Android $key, data=$qp"}
|
||||||
if (db.queuepagingDB.Add(qp)) {
|
if (queuepagingDB.Add(qp)) {
|
||||||
db.queuepagingDB.Resort()
|
queuepagingDB.Resort()
|
||||||
logcb.accept("Paging audio inserted to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
logcb.accept("Paging audio inserted to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
||||||
cb.accept("PCMFILE_STOP;OK@")
|
cb.accept("PCMFILE_STOP;OK@")
|
||||||
return
|
return
|
||||||
@@ -289,8 +291,8 @@ class TCP_Android_Command_Server {
|
|||||||
pj.filePath.absolutePathString(),
|
pj.filePath.absolutePathString(),
|
||||||
pj.broadcastzones
|
pj.broadcastzones
|
||||||
)
|
)
|
||||||
if (db.queuepagingDB.Add(qp)){
|
if (queuepagingDB.Add(qp)){
|
||||||
db.queuepagingDB.Resort()
|
queuepagingDB.Resort()
|
||||||
logcb.accept("Paging audio inserted to queue paging table from IPM $key, file ${pj.filePath.absolutePathString()}")
|
logcb.accept("Paging audio inserted to queue paging table from IPM $key, file ${pj.filePath.absolutePathString()}")
|
||||||
cb.accept("STOPPAGINGAND;OK@")
|
cb.accept("STOPPAGINGAND;OK@")
|
||||||
return
|
return
|
||||||
@@ -579,18 +581,15 @@ class TCP_Android_Command_Server {
|
|||||||
if (ValidString(tags)){
|
if (ValidString(tags)){
|
||||||
if (ValidString(zone)){
|
if (ValidString(zone)){
|
||||||
val qt = QueueTable(
|
val qt = QueueTable(
|
||||||
0u,
|
Source="ANDROID",
|
||||||
LocalDateTime.now().format(datetimeformat1),
|
Type="SOUNDBANK",
|
||||||
"ANDROID",
|
Message=desc,
|
||||||
"SOUNDBANK",
|
SB_TAGS = tags,
|
||||||
desc,
|
BroadcastZones = zone,
|
||||||
tags,
|
Language = lang
|
||||||
zone,
|
|
||||||
1u,
|
|
||||||
lang
|
|
||||||
)
|
)
|
||||||
if (db.queuetableDB.Add(qt)){
|
if (queuetableDB.Add(qt)){
|
||||||
db.queuetableDB.Resort()
|
queuetableDB.Resort()
|
||||||
logcb.accept("Broadcast request from Android $key username=${listUserLogin.find { it.ip==key }?.username ?: "UNKNOWN"} inserted. Message: $desc;$lang;$tags;$zone")
|
logcb.accept("Broadcast request from Android $key username=${listUserLogin.find { it.ip==key }?.username ?: "UNKNOWN"} inserted. Message: $desc;$lang;$tags;$zone")
|
||||||
cb.accept("BROADCASTAND;OK@")
|
cb.accept("BROADCASTAND;OK@")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import database.table.Table_Users
|
|||||||
import messageDB
|
import messageDB
|
||||||
import broadcastDB
|
import broadcastDB
|
||||||
import logDB
|
import logDB
|
||||||
|
import queuepagingDB
|
||||||
|
import queuetableDB
|
||||||
import soundchannelDB
|
import soundchannelDB
|
||||||
|
|
||||||
class MariaDB {
|
class MariaDB {
|
||||||
@@ -32,8 +34,7 @@ class MariaDB {
|
|||||||
lateinit var soundDB: Table_Soundbank
|
lateinit var soundDB: Table_Soundbank
|
||||||
lateinit var languageDB: Table_LanguageLink
|
lateinit var languageDB: Table_LanguageLink
|
||||||
lateinit var scheduleDB: Table_Schedule
|
lateinit var scheduleDB: Table_Schedule
|
||||||
lateinit var queuetableDB: Table_QueueSoundbank
|
|
||||||
lateinit var queuepagingDB: Table_QueuePaging
|
|
||||||
|
|
||||||
|
|
||||||
lateinit var userDB: Table_Users
|
lateinit var userDB: Table_Users
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import codes.Somecodes.Companion.datetimeformat1
|
|||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
data class QueueTable(var index: UInt, var Date_Time: String, var Source: String, var Type: String, var Message: String, var SB_TAGS: String, var BroadcastZones: String, var Repeat: UInt, var Language: String){
|
data class QueueTable(var index: UInt=0u, var Date_Time: String =LocalDateTime.now().format(datetimeformat1), var Source: String, var Type: String, var Message: String, var SB_TAGS: String, var BroadcastZones: String, var Repeat: UInt=1u, var Language: String){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if all fields are not empty
|
* Check if all fields are not empty
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
package database.table
|
package database.table
|
||||||
|
|
||||||
|
import codes.Somecodes.Companion.timeformat2
|
||||||
import com.batoulapps.adhan.CalculationMethod
|
import com.batoulapps.adhan.CalculationMethod
|
||||||
import com.batoulapps.adhan.CalculationParameters
|
import com.batoulapps.adhan.CalculationParameters
|
||||||
import com.batoulapps.adhan.Coordinates
|
import com.batoulapps.adhan.Coordinates
|
||||||
import com.batoulapps.adhan.Madhab
|
import com.batoulapps.adhan.Madhab
|
||||||
import com.batoulapps.adhan.PrayerTimes
|
import com.batoulapps.adhan.PrayerTimes
|
||||||
import com.batoulapps.adhan.data.DateComponents
|
import com.batoulapps.adhan.data.DateComponents
|
||||||
|
import content.Language
|
||||||
|
import messageDB
|
||||||
|
import org.tinylog.Logger
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
import java.time.LocalTime
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
|
|
||||||
@@ -16,7 +21,6 @@ import java.util.TimeZone
|
|||||||
* @param longitude The longitude of the location. Default is Monas, Jakarta (longitude: 106.8272).
|
* @param longitude The longitude of the location. Default is Monas, Jakarta (longitude: 106.8272).
|
||||||
* @param timezone The time zone for formatting prayer times. Default is "Asia/Jakarta".
|
* @param timezone The time zone for formatting prayer times. Default is "Asia/Jakarta".
|
||||||
*/
|
*/
|
||||||
@Suppress("unused")
|
|
||||||
class Table_Adzan(val latitude: Double = -6.1751, val longitude: Double = 106.8272, val timezone : TimeZone = TimeZone.getTimeZone("Asia/Jakarta")) {
|
class Table_Adzan(val latitude: Double = -6.1751, val longitude: Double = 106.8272, val timezone : TimeZone = TimeZone.getTimeZone("Asia/Jakarta")) {
|
||||||
|
|
||||||
var coordinate: Coordinates = Coordinates(latitude, longitude)
|
var coordinate: Coordinates = Coordinates(latitude, longitude)
|
||||||
@@ -30,11 +34,21 @@ class Table_Adzan(val latitude: Double = -6.1751, val longitude: Double = 106.82
|
|||||||
var maghrib_enable = false
|
var maghrib_enable = false
|
||||||
var isya_enable = false
|
var isya_enable = false
|
||||||
|
|
||||||
var fajar_sound = ""
|
var fajar_message = ""
|
||||||
var dzuhur_sound = ""
|
var dzuhur_message = ""
|
||||||
var ashar_sound = ""
|
var ashar_message = ""
|
||||||
var maghrib_sound = ""
|
var maghrib_message = ""
|
||||||
var isya_sound = ""
|
var isya_message = ""
|
||||||
|
|
||||||
|
var fajar_time = ""
|
||||||
|
var dzuhur_time = ""
|
||||||
|
var ashar_time = ""
|
||||||
|
var maghrib_time = ""
|
||||||
|
var isya_time = ""
|
||||||
|
|
||||||
|
var adzan_broadcastzones = ""
|
||||||
|
|
||||||
|
var adzan_language = Language.DEFAULT.value
|
||||||
|
|
||||||
init{
|
init{
|
||||||
// sumber chatgpt Kemenag
|
// sumber chatgpt Kemenag
|
||||||
@@ -44,14 +58,93 @@ class Table_Adzan(val latitude: Double = -6.1751, val longitude: Double = 106.82
|
|||||||
timeformatter.timeZone = timezone
|
timeformatter.timeZone = timezone
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
data class AdzanTask(
|
||||||
* Change the time zone used for formatting prayer times.
|
val prayerName : String,
|
||||||
* @param timezone The new AdzanTimeZone.
|
val timeString : String,
|
||||||
*/
|
val message : String,
|
||||||
fun ChangeTimezone(timezone: AdzanTimeZone) {
|
val sb_tags : String
|
||||||
ChangeTimeZone(timezone.toTimeZoneString())
|
)
|
||||||
|
|
||||||
|
fun CheckTime() : AdzanTask?{
|
||||||
|
val hhmm = LocalTime.now().format(timeformat2)
|
||||||
|
if (hhmm == fajar_time){
|
||||||
|
if (fajar_enable){
|
||||||
|
val mb = messageDB.Find_Messagebank(fajar_message, adzan_language)
|
||||||
|
if (mb!=null){
|
||||||
|
return AdzanTask(
|
||||||
|
"Fajar",
|
||||||
|
fajar_time,
|
||||||
|
mb.Description,
|
||||||
|
mb.Message_TAGS
|
||||||
|
)
|
||||||
|
} else Logger.error { "Skipped Adzan Fajar because Unable to find $fajar_message in messageDB" }
|
||||||
|
} else Logger.info{"Skipped Adzan Fajar because fajr_enable is false"}
|
||||||
|
}
|
||||||
|
if (hhmm == dzuhur_time){
|
||||||
|
if (dzuhur_enable){
|
||||||
|
val mb = messageDB.Find_Messagebank(dzuhur_message, adzan_language)
|
||||||
|
if (mb!=null){
|
||||||
|
return AdzanTask(
|
||||||
|
"Dzuhur",
|
||||||
|
dzuhur_time,
|
||||||
|
mb.Description,
|
||||||
|
mb.Message_TAGS
|
||||||
|
)
|
||||||
|
} else Logger.error { "Skipped Adzan Dzuhur because Unable to find $dzuhur_message in messageDB" }
|
||||||
|
} else Logger.info{"Skipped Adzan Dzuhur because dzuhur_enable is false"}
|
||||||
|
}
|
||||||
|
if (hhmm == ashar_time) {
|
||||||
|
if (ashar_enable){
|
||||||
|
val mb = messageDB.Find_Messagebank(ashar_message, adzan_language)
|
||||||
|
if (mb!=null){
|
||||||
|
return AdzanTask(
|
||||||
|
"Ashar",
|
||||||
|
ashar_time,
|
||||||
|
mb.Description,
|
||||||
|
mb.Message_TAGS
|
||||||
|
)
|
||||||
|
} else Logger.error { "Skipped Adzan Ashar because Unable to find $ashar_message in messageDB" }
|
||||||
|
} else Logger.info{"Skipped Adzan Ashar because ashar_enable is false"}
|
||||||
|
}
|
||||||
|
if (hhmm == maghrib_time){
|
||||||
|
if (maghrib_enable){
|
||||||
|
val mb = messageDB.Find_Messagebank(maghrib_message, adzan_language)
|
||||||
|
if (mb!=null){
|
||||||
|
return AdzanTask(
|
||||||
|
"Maghrib",
|
||||||
|
maghrib_time,
|
||||||
|
mb.Description,
|
||||||
|
mb.Message_TAGS
|
||||||
|
)
|
||||||
|
} else Logger.error { "Skipped Adzan Maghrib because Unable to find $maghrib_message in messageDB" }
|
||||||
|
|
||||||
|
} else Logger.info{"Skipped Adzan Maghrib because maghrib_enable is false"}
|
||||||
|
}
|
||||||
|
if (hhmm == isya_time) {
|
||||||
|
if (isya_enable){
|
||||||
|
val mb = messageDB.Find_Messagebank(isya_message, adzan_language)
|
||||||
|
if (mb!=null){
|
||||||
|
return AdzanTask(
|
||||||
|
"Isya",
|
||||||
|
isya_time,
|
||||||
|
mb.Description,
|
||||||
|
mb.Message_TAGS
|
||||||
|
)
|
||||||
|
} else Logger.error { "Skipped Adzan Isya because Unable to find $isya_message in messageDB" }
|
||||||
|
|
||||||
|
} else Logger.info{"Skipped Adzan Isya because isya_enable is false"}
|
||||||
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Change the time zone used for formatting prayer times.
|
||||||
|
// * @param timezone The new AdzanTimeZone.
|
||||||
|
// */
|
||||||
|
// fun ChangeTimezone(timezone: AdzanTimeZone) {
|
||||||
|
// ChangeTimeZone(timezone.toTimeZoneString())
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the time zone used for formatting prayer times.
|
* Change the time zone used for formatting prayer times.
|
||||||
* @param timezoneString The new time zone string (e.g., "Asia/Jakarta").
|
* @param timezoneString The new time zone string (e.g., "Asia/Jakarta").
|
||||||
@@ -60,29 +153,29 @@ class Table_Adzan(val latitude: Double = -6.1751, val longitude: Double = 106.82
|
|||||||
timeformatter.timeZone = TimeZone.getTimeZone(timezoneString)
|
timeformatter.timeZone = TimeZone.getTimeZone(timezoneString)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Set prayer time adjustments in minutes.
|
// * Set prayer time adjustments in minutes.
|
||||||
* @param fajrMinute Adjustment for Fajr prayer time in minutes.
|
// * @param fajrMinute Adjustment for Fajr prayer time in minutes.
|
||||||
* @param dhuhrMinute Adjustment for Dhuhr prayer time in minutes.
|
// * @param dhuhrMinute Adjustment for Dhuhr prayer time in minutes.
|
||||||
* @param asrMinute Adjustment for Asr prayer time in minutes.
|
// * @param asrMinute Adjustment for Asr prayer time in minutes.
|
||||||
* @param maghribMinute Adjustment for Maghrib prayer time in minutes.
|
// * @param maghribMinute Adjustment for Maghrib prayer time in minutes.
|
||||||
* @param ishaMinute Adjustment for Isha prayer time in minutes.
|
// * @param ishaMinute Adjustment for Isha prayer time in minutes.
|
||||||
*/
|
// */
|
||||||
fun SetPrayerAdjustment(fajrMinute: Int = 0, dhuhrMinute: Int = 0, asrMinute: Int = 0,maghribMinute: Int = 0, ishaMinute: Int = 0) {
|
// fun SetPrayerAdjustment(fajrMinute: Int = 0, dhuhrMinute: Int = 0, asrMinute: Int = 0,maghribMinute: Int = 0, ishaMinute: Int = 0) {
|
||||||
params.adjustments.fajr = fajrMinute
|
// params.adjustments.fajr = fajrMinute
|
||||||
params.adjustments.dhuhr = dhuhrMinute
|
// params.adjustments.dhuhr = dhuhrMinute
|
||||||
params.adjustments.asr = asrMinute
|
// params.adjustments.asr = asrMinute
|
||||||
params.adjustments.maghrib = maghribMinute
|
// params.adjustments.maghrib = maghribMinute
|
||||||
params.adjustments.isha = ishaMinute
|
// params.adjustments.isha = ishaMinute
|
||||||
}
|
// }
|
||||||
/**
|
// /**
|
||||||
* Change the coordinates used for Adzan calculations.
|
// * Change the coordinates used for Adzan calculations.
|
||||||
* @param lat The new latitude.
|
// * @param lat The new latitude.
|
||||||
* @param long The new longitude.
|
// * @param long The new longitude.
|
||||||
*/
|
// */
|
||||||
fun ChangeCoordinate(lat: Double, long: Double) {
|
// fun ChangeCoordinate(lat: Double, long: Double) {
|
||||||
coordinate = Coordinates(lat, long)
|
// coordinate = Coordinates(lat, long)
|
||||||
}
|
// }
|
||||||
|
|
||||||
fun ChangeLatitude(lat: Double) {
|
fun ChangeLatitude(lat: Double) {
|
||||||
coordinate = Coordinates(lat, coordinate.longitude)
|
coordinate = Coordinates(lat, coordinate.longitude)
|
||||||
@@ -92,19 +185,19 @@ class Table_Adzan(val latitude: Double = -6.1751, val longitude: Double = 106.82
|
|||||||
coordinate = Coordinates(coordinate.latitude, long)
|
coordinate = Coordinates(coordinate.latitude, long)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Get prayer times for a specific date string in the format "dd/MM/yyyy".
|
// * Get prayer times for a specific date string in the format "dd/MM/yyyy".
|
||||||
* @param date_string The date string for which to get prayer times.
|
// * @param date_string The date string for which to get prayer times.
|
||||||
* @return An AdzanPrayerTime object containing the prayer times, or null if the date string is invalid.
|
// * @return An AdzanPrayerTime object containing the prayer times, or null if the date string is invalid.
|
||||||
*/
|
// */
|
||||||
fun GetPrayerTimes(date_string: String) : AdzanPrayerTime?{
|
// fun GetPrayerTimes(date_string: String) : AdzanPrayerTime?{
|
||||||
try{
|
// try{
|
||||||
val date = dateformatter.parse(date_string)
|
// val date = dateformatter.parse(date_string)
|
||||||
return GetPrayerTimes(date)
|
// return GetPrayerTimes(date)
|
||||||
} catch (e: Exception){
|
// } catch (_: Exception){
|
||||||
return null
|
// return null
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get prayer times for a specific date.
|
* Get prayer times for a specific date.
|
||||||
@@ -125,31 +218,38 @@ class Table_Adzan(val latitude: Double = -6.1751, val longitude: Double = 106.82
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get prayer times for the current date.
|
* Get prayer times for the current date.
|
||||||
|
* this will update fajar_time, dzuhur_time, ashar_time, maghrib_time, isya_time properties
|
||||||
* @return An AdzanPrayerTime object containing the prayer times for today.
|
* @return An AdzanPrayerTime object containing the prayer times for today.
|
||||||
*/
|
*/
|
||||||
fun GetTodayPrayerTimes() : AdzanPrayerTime{
|
fun GetTodayPrayerTimes() : AdzanPrayerTime{
|
||||||
return GetPrayerTimes(Date())
|
val result = GetPrayerTimes(Date())
|
||||||
|
fajar_time = result.fajr
|
||||||
|
dzuhur_time = result.dhuhr
|
||||||
|
ashar_time = result.asr
|
||||||
|
maghrib_time = result.maghrib
|
||||||
|
isya_time = result.isha
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Get prayer times for all days in a specific month and year.
|
// * Get prayer times for all days in a specific month and year.
|
||||||
* @param month The month (1-12) for which to get prayer times.
|
// * @param month The month (1-12) for which to get prayer times.
|
||||||
* @param year The year for which to get prayer times.
|
// * @param year The year for which to get prayer times.
|
||||||
* @return A list of AdzanPrayerTime objects for each day in the specified month and year.
|
// * @return A list of AdzanPrayerTime objects for each day in the specified month and year.
|
||||||
*/
|
// */
|
||||||
fun GetMonthlyPrayerTimes(month: Int, year: Int) : List<AdzanPrayerTime>{
|
// fun GetMonthlyPrayerTimes(month: Int, year: Int) : List<AdzanPrayerTime>{
|
||||||
val prayerTimesList = mutableListOf<AdzanPrayerTime>()
|
// val prayerTimesList = mutableListOf<AdzanPrayerTime>()
|
||||||
val calendar = java.util.Calendar.getInstance()
|
// val calendar = java.util.Calendar.getInstance()
|
||||||
calendar.set(year, month - 1, 1) // Month is 0-based in Calendar
|
// calendar.set(year, month - 1, 1) // Month is 0-based in Calendar
|
||||||
val daysInMonth = calendar.getActualMaximum(java.util.Calendar.DAY_OF_MONTH)
|
// val daysInMonth = calendar.getActualMaximum(java.util.Calendar.DAY_OF_MONTH)
|
||||||
|
//
|
||||||
for (day in 1..daysInMonth) {
|
// for (day in 1..daysInMonth) {
|
||||||
calendar.set(year, month - 1, day)
|
// calendar.set(year, month - 1, day)
|
||||||
val date = calendar.time
|
// val date = calendar.time
|
||||||
val prayerTimes = GetPrayerTimes(date)
|
// val prayerTimes = GetPrayerTimes(date)
|
||||||
prayerTimesList.add(prayerTimes)
|
// prayerTimesList.add(prayerTimes)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return prayerTimesList
|
// return prayerTimesList
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package database.table
|
package database.table
|
||||||
|
|
||||||
import StreamerOutputs
|
import StreamerOutputs
|
||||||
import broadcastDB
|
|
||||||
import codes.Somecodes.Companion.ValidIPV4
|
import codes.Somecodes.Companion.ValidIPV4
|
||||||
import codes.Somecodes.Companion.ValidString
|
import codes.Somecodes.Companion.ValidString
|
||||||
import database.data.BroadcastZones
|
import database.data.BroadcastZones
|
||||||
@@ -223,8 +222,8 @@ class Table_BroadcastZones(connection: Connection) : dbFunctions<BroadcastZones>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if all broadcast zones in a comma-separated string are valid
|
* Check if all broadcast zones in a comma-separated string are valid,
|
||||||
* Valid means the broadcast zone name exists in the BroadcastZones table, its SoundChannel exists in the SoundChannel table, and its IP is valid
|
* means the broadcast zone name exists in the BroadcastZones table, its SoundChannel exists in the SoundChannel table, and its IP is valid
|
||||||
* @param zones Comma-separated string of broadcast zones
|
* @param zones Comma-separated string of broadcast zones
|
||||||
* @param checkOnline Whether to check if the sound channel is really online, recorded in StreamerOutputs map
|
* @param checkOnline Whether to check if the sound channel is really online, recorded in StreamerOutputs map
|
||||||
* @return true if all broadcast zones are valid, false otherwise
|
* @return true if all broadcast zones are valid, false otherwise
|
||||||
|
|||||||
@@ -258,4 +258,25 @@ class Table_Messagebank(connection: Connection) : dbFunctions<Messagebank>("mess
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a messagebank entry based on messagedetail and language
|
||||||
|
* @param messagedetail the messagedetail in format "message_name [ann_id]"
|
||||||
|
* @param language the language to find
|
||||||
|
* @return the messagebank entry if found, null otherwise
|
||||||
|
*/
|
||||||
|
fun Find_Messagebank(messagedetail: String, language: String) : Messagebank?{
|
||||||
|
return try{
|
||||||
|
val match = messageDetailRegex.find(messagedetail)
|
||||||
|
if (match != null){
|
||||||
|
val msg = match.groupValues[1].trim()
|
||||||
|
val annid = match.groupValues[2].toUIntOrNull() ?: return null // kalau bukan number, return null
|
||||||
|
List.firstOrNull{ it.ANN_ID == annid && it.Description == msg && it.Language.equals(language, ignoreCase = true) }
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
} catch (_: Exception){
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -55,12 +55,13 @@ import io.javalin.websocket.WsCloseStatus
|
|||||||
import logDB
|
import logDB
|
||||||
import messageDB
|
import messageDB
|
||||||
import org.tinylog.Logger
|
import org.tinylog.Logger
|
||||||
|
import queuepagingDB
|
||||||
|
import queuetableDB
|
||||||
import soundchannelDB
|
import soundchannelDB
|
||||||
import version
|
import version
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.util.TimeZone
|
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
|
|
||||||
@@ -221,7 +222,7 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
SendReply(
|
SendReply(
|
||||||
wsMessageContext,
|
wsMessageContext,
|
||||||
cmd.command,
|
cmd.command,
|
||||||
objectmapper.writeValueAsString(db.queuepagingDB.List)
|
objectmapper.writeValueAsString(queuepagingDB.List)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +230,7 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
SendReply(
|
SendReply(
|
||||||
wsMessageContext,
|
wsMessageContext,
|
||||||
cmd.command,
|
cmd.command,
|
||||||
objectmapper.writeValueAsString(db.queuetableDB.List)
|
objectmapper.writeValueAsString(queuetableDB.List)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +363,7 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
SendReply(
|
SendReply(
|
||||||
wsMessageContext,
|
wsMessageContext,
|
||||||
cmd.command,
|
cmd.command,
|
||||||
objectmapper.writeValueAsString(db.queuepagingDB.List)
|
objectmapper.writeValueAsString(queuepagingDB.List)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,7 +371,7 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
SendReply(
|
SendReply(
|
||||||
wsMessageContext,
|
wsMessageContext,
|
||||||
cmd.command,
|
cmd.command,
|
||||||
objectmapper.writeValueAsString(db.queuetableDB.List)
|
objectmapper.writeValueAsString(queuetableDB.List)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2180,8 +2181,8 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
|
|
||||||
path("QueuePaging") {
|
path("QueuePaging") {
|
||||||
get("List") { ctx ->
|
get("List") { ctx ->
|
||||||
db.queuepagingDB.Get({
|
queuepagingDB.Get({
|
||||||
ctx.json(db.queuepagingDB.List)
|
ctx.json(queuepagingDB.List)
|
||||||
}, { msgFail ->
|
}, { msgFail ->
|
||||||
ctx.status(500).result(objectmapper.writeValueAsString(resultMessage(msgFail)))
|
ctx.status(500).result(objectmapper.writeValueAsString(resultMessage(msgFail)))
|
||||||
})
|
})
|
||||||
@@ -2189,8 +2190,8 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
}
|
}
|
||||||
delete("List") {
|
delete("List") {
|
||||||
// truncate queue paging table
|
// truncate queue paging table
|
||||||
if (db.queuepagingDB.Clear()) {
|
if (queuepagingDB.Clear()) {
|
||||||
db.queuepagingDB.Get()
|
queuepagingDB.Get()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
} else {
|
} else {
|
||||||
it.status(500)
|
it.status(500)
|
||||||
@@ -2204,8 +2205,8 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
it.status(400)
|
it.status(400)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid index")))
|
.result(objectmapper.writeValueAsString(resultMessage("Invalid index")))
|
||||||
} else {
|
} else {
|
||||||
if (db.queuepagingDB.DeleteByIndex(index.toInt())) {
|
if (queuepagingDB.DeleteByIndex(index.toInt())) {
|
||||||
db.queuepagingDB.Resort()
|
queuepagingDB.Resort()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
logDB.Add("AAS", "Deleted queue paging with index $index")
|
logDB.Add("AAS", "Deleted queue paging with index $index")
|
||||||
} else {
|
} else {
|
||||||
@@ -2218,8 +2219,8 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
}
|
}
|
||||||
path("QueueTable") {
|
path("QueueTable") {
|
||||||
get("List") { ctx ->
|
get("List") { ctx ->
|
||||||
db.queuetableDB.Get({
|
queuetableDB.Get({
|
||||||
ctx.json(db.queuetableDB.List)
|
ctx.json(queuetableDB.List)
|
||||||
}, { msgFail ->
|
}, { msgFail ->
|
||||||
ctx.status(500).result(objectmapper.writeValueAsString(resultMessage(msgFail)))
|
ctx.status(500).result(objectmapper.writeValueAsString(resultMessage(msgFail)))
|
||||||
})
|
})
|
||||||
@@ -2227,8 +2228,8 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
}
|
}
|
||||||
delete("List") {
|
delete("List") {
|
||||||
// truncate queue table
|
// truncate queue table
|
||||||
if (db.queuetableDB.Clear()) {
|
if (queuetableDB.Clear()) {
|
||||||
db.queuetableDB.Get()
|
queuetableDB.Get()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
} else {
|
} else {
|
||||||
it.status(500)
|
it.status(500)
|
||||||
@@ -2242,8 +2243,8 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
it.status(400)
|
it.status(400)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid index")))
|
.result(objectmapper.writeValueAsString(resultMessage("Invalid index")))
|
||||||
} else {
|
} else {
|
||||||
if (db.queuetableDB.DeleteByIndex(index.toInt())) {
|
if (queuetableDB.DeleteByIndex(index.toInt())) {
|
||||||
db.queuetableDB.Resort()
|
queuetableDB.Resort()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
logDB.Add("AAS", "Deleted queue sound with index $index")
|
logDB.Add("AAS", "Deleted queue sound with index $index")
|
||||||
|
|
||||||
@@ -2470,28 +2471,30 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
path("Settings") {
|
path("Settings") {
|
||||||
|
get("TimezoneList"){
|
||||||
|
it.json(Somecodes.Get_TimeZones())
|
||||||
|
}
|
||||||
path("AdzanSetting"){
|
path("AdzanSetting"){
|
||||||
get{
|
get{
|
||||||
val todayadzan = adzanTable.GetTodayPrayerTimes()
|
|
||||||
val value = AdzanSetting(
|
val value = AdzanSetting(
|
||||||
latitude = _config.Get(configKeys.LATITUDE.key).toDoubleOrNull() ?: 0.0,
|
latitude = _config.Get(configKeys.LATITUDE.key).toDoubleOrNull() ?: 0.0,
|
||||||
longitude = _config.Get(configKeys.LONGITUDE.key).toDoubleOrNull() ?: 0.0,
|
longitude = _config.Get(configKeys.LONGITUDE.key).toDoubleOrNull() ?: 0.0,
|
||||||
timezone = _config.Get(configKeys.TIMEZONE.key),
|
timezone = _config.Get(configKeys.TIMEZONE.key),
|
||||||
fajar_sound = _config.Get(configKeys.ADZAN_FAJR_SOUND.key),
|
fajar_sound = _config.Get(configKeys.ADZAN_FAJR_SOUND.key),
|
||||||
fajar_enable = _config.Get(configKeys.ADZAN_FAJR_ENABLED.key).toBoolean(),
|
fajar_enable = _config.Get(configKeys.ADZAN_FAJR_ENABLED.key).toBoolean(),
|
||||||
fajar_time = todayadzan.fajr,
|
fajar_time = adzanTable.fajar_time,
|
||||||
dzuhur_sound = _config.Get(configKeys.ADZAN_DHUHR_SOUND.key),
|
dzuhur_sound = _config.Get(configKeys.ADZAN_DHUHR_SOUND.key),
|
||||||
dzuhur_enable = _config.Get(configKeys.ADZAN_DHUHR_ENABLED.key).toBoolean(),
|
dzuhur_enable = _config.Get(configKeys.ADZAN_DHUHR_ENABLED.key).toBoolean(),
|
||||||
dzuhur_time = todayadzan.dhuhr,
|
dzuhur_time = adzanTable.dzuhur_time,
|
||||||
ashar_sound = _config.Get(configKeys.ADZAN_ASR_SOUND.key),
|
ashar_sound = _config.Get(configKeys.ADZAN_ASR_SOUND.key),
|
||||||
ashar_enable = _config.Get(configKeys.ADZAN_FAJR_ENABLED.key).toBoolean(),
|
ashar_enable = _config.Get(configKeys.ADZAN_FAJR_ENABLED.key).toBoolean(),
|
||||||
ashar_time = todayadzan.asr,
|
ashar_time = adzanTable.ashar_time,
|
||||||
maghrib_sound = _config.Get(configKeys.ADZAN_MAGHRIB_SOUND.key),
|
maghrib_sound = _config.Get(configKeys.ADZAN_MAGHRIB_SOUND.key),
|
||||||
maghrib_enable = _config.Get(configKeys.ADZAN_MAGHRIB_ENABLED.key).toBoolean(),
|
maghrib_enable = _config.Get(configKeys.ADZAN_MAGHRIB_ENABLED.key).toBoolean(),
|
||||||
maghrib_time = todayadzan.maghrib,
|
maghrib_time = adzanTable.maghrib_time,
|
||||||
isya_sound = _config.Get(configKeys.ADZAN_ISHA_SOUND.key),
|
isya_sound = _config.Get(configKeys.ADZAN_ISHA_SOUND.key),
|
||||||
isya_enable = _config.Get(configKeys.ADZAN_ISHA_ENABLED.key).toBoolean(),
|
isya_enable = _config.Get(configKeys.ADZAN_ISHA_ENABLED.key).toBoolean(),
|
||||||
isya_time = todayadzan.isha
|
isya_time = adzanTable.isya_time
|
||||||
)
|
)
|
||||||
it.json(value)
|
it.json(value)
|
||||||
}
|
}
|
||||||
@@ -2499,6 +2502,7 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
val json: JsonNode = objectmapper.readTree(it.body())
|
val json: JsonNode = objectmapper.readTree(it.body())
|
||||||
try{
|
try{
|
||||||
val newsetting = AdzanSetting.FromJsonNode(json)
|
val newsetting = AdzanSetting.FromJsonNode(json)
|
||||||
|
var need_recalculate_adzan_today = false
|
||||||
_config.CompareWithAdzanSetting(newsetting).let { changes ->
|
_config.CompareWithAdzanSetting(newsetting).let { changes ->
|
||||||
if (changes.isNotEmpty()){
|
if (changes.isNotEmpty()){
|
||||||
// something changes
|
// something changes
|
||||||
@@ -2506,19 +2510,28 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
_config.Set(change.key, change.newValue)
|
_config.Set(change.key, change.newValue)
|
||||||
Logger.info{"AdzanSetting change: ${change.key} from ${change.oldValue} to ${change.newValue}"}
|
Logger.info{"AdzanSetting change: ${change.key} from ${change.oldValue} to ${change.newValue}"}
|
||||||
when(change.key){
|
when(change.key){
|
||||||
configKeys.LATITUDE.key -> adzanTable.ChangeLatitude(change.newValue.toDouble())
|
configKeys.LATITUDE.key -> {
|
||||||
configKeys.LONGITUDE.key -> adzanTable.ChangeLongitude(change.newValue.toDouble())
|
adzanTable.ChangeLatitude(change.newValue.toDouble())
|
||||||
configKeys.TIMEZONE.key -> adzanTable.ChangeTimeZone(change.newValue)
|
need_recalculate_adzan_today = true
|
||||||
|
}
|
||||||
|
configKeys.LONGITUDE.key -> {
|
||||||
|
adzanTable.ChangeLongitude(change.newValue.toDouble())
|
||||||
|
need_recalculate_adzan_today = true
|
||||||
|
}
|
||||||
|
configKeys.TIMEZONE.key -> {
|
||||||
|
adzanTable.ChangeTimeZone(change.newValue)
|
||||||
|
need_recalculate_adzan_today = true
|
||||||
|
}
|
||||||
configKeys.ADZAN_FAJR_ENABLED.key -> adzanTable.fajar_enable = change.newValue.toBoolean()
|
configKeys.ADZAN_FAJR_ENABLED.key -> adzanTable.fajar_enable = change.newValue.toBoolean()
|
||||||
configKeys.ADZAN_DHUHR_ENABLED.key -> adzanTable.dzuhur_enable = change.newValue.toBoolean()
|
configKeys.ADZAN_DHUHR_ENABLED.key -> adzanTable.dzuhur_enable = change.newValue.toBoolean()
|
||||||
configKeys.ADZAN_ASR_ENABLED.key -> adzanTable.ashar_enable = change.newValue.toBoolean()
|
configKeys.ADZAN_ASR_ENABLED.key -> adzanTable.ashar_enable = change.newValue.toBoolean()
|
||||||
configKeys.ADZAN_MAGHRIB_ENABLED.key -> adzanTable.maghrib_enable = change.newValue.toBoolean()
|
configKeys.ADZAN_MAGHRIB_ENABLED.key -> adzanTable.maghrib_enable = change.newValue.toBoolean()
|
||||||
configKeys.ADZAN_ISHA_ENABLED.key -> adzanTable.isya_enable = change.newValue.toBoolean()
|
configKeys.ADZAN_ISHA_ENABLED.key -> adzanTable.isya_enable = change.newValue.toBoolean()
|
||||||
configKeys.ADZAN_FAJR_SOUND.key -> adzanTable.fajar_sound = change.newValue
|
configKeys.ADZAN_FAJR_SOUND.key -> adzanTable.fajar_message = change.newValue
|
||||||
configKeys.ADZAN_DHUHR_SOUND.key -> adzanTable.dzuhur_sound = change.newValue
|
configKeys.ADZAN_DHUHR_SOUND.key -> adzanTable.dzuhur_message = change.newValue
|
||||||
configKeys.ADZAN_ASR_SOUND.key -> adzanTable.ashar_sound = change.newValue
|
configKeys.ADZAN_ASR_SOUND.key -> adzanTable.ashar_message = change.newValue
|
||||||
configKeys.ADZAN_MAGHRIB_SOUND.key -> adzanTable.maghrib_sound = change.newValue
|
configKeys.ADZAN_MAGHRIB_SOUND.key -> adzanTable.maghrib_message = change.newValue
|
||||||
configKeys.ADZAN_ISHA_SOUND.key -> adzanTable.isya_sound = change.newValue
|
configKeys.ADZAN_ISHA_SOUND.key -> adzanTable.isya_message = change.newValue
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
@@ -2531,9 +2544,28 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
Logger.info { "No changes detected in AdzanSetting"}
|
Logger.info { "No changes detected in AdzanSetting"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (need_recalculate_adzan_today) {
|
||||||
|
adzanTable.GetTodayPrayerTimes()
|
||||||
|
}
|
||||||
|
if (newsetting.fajar_time != adzanTable.fajar_time){
|
||||||
|
adzanTable.fajar_time = newsetting.fajar_time
|
||||||
|
}
|
||||||
|
if (newsetting.dzuhur_time != adzanTable.dzuhur_time){
|
||||||
|
adzanTable.dzuhur_time = newsetting.dzuhur_time
|
||||||
|
}
|
||||||
|
if (newsetting.ashar_time != adzanTable.ashar_time){
|
||||||
|
adzanTable.ashar_time = newsetting.ashar_time
|
||||||
|
}
|
||||||
|
if (newsetting.maghrib_time != adzanTable.maghrib_time){
|
||||||
|
adzanTable.maghrib_time = newsetting.maghrib_time
|
||||||
|
}
|
||||||
|
if (newsetting.isya_time != adzanTable.isya_time){
|
||||||
|
adzanTable.isya_time = newsetting.isya_time
|
||||||
|
}
|
||||||
|
Logger.info{"AdzanSetting updated successfully"}
|
||||||
|
Logger.info{"Today's Prayer Times: Fajar=${adzanTable.fajar_time}, Dzuhur=${adzanTable.dzuhur_time}, Ashar=${adzanTable.ashar_time}, Maghrib=${adzanTable.maghrib_time}, Isya=${adzanTable.isya_time}"}
|
||||||
|
Logger.info{"Fajar Enabled=${adzanTable.fajar_enable}, Dzuhur Enabled=${adzanTable.dzuhur_enable}, Ashar Enabled=${adzanTable.ashar_enable}, Maghrib Enabled=${adzanTable.maghrib_enable}, Isya Enabled=${adzanTable.isya_enable}"}
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
|
|
||||||
|
|
||||||
} catch (e : Exception){
|
} catch (e : Exception){
|
||||||
it.status(400)
|
it.status(400)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Incomplete AdzanSetting data: ${e.message}")))
|
.result(objectmapper.writeValueAsString(resultMessage("Incomplete AdzanSetting data: ${e.message}")))
|
||||||
@@ -2804,18 +2836,15 @@ class WebApp(val listenPort: Int, var userlist: List<Pair<String, String>>, val
|
|||||||
if (tags.isNotEmpty()) {
|
if (tags.isNotEmpty()) {
|
||||||
if (broadcastzones.isNotEmpty()) {
|
if (broadcastzones.isNotEmpty()) {
|
||||||
val qt = QueueTable(
|
val qt = QueueTable(
|
||||||
0u,
|
Source ="SEMIAUTOWEB",
|
||||||
LocalDateTime.now().format(datetimeformat1),
|
Type="SOUNDBANK",
|
||||||
"SEMIAUTOWEB",
|
Message=description,
|
||||||
"SOUNDBANK",
|
SB_TAGS =tags,
|
||||||
description,
|
BroadcastZones = broadcastzones,
|
||||||
tags,
|
Language=languages
|
||||||
broadcastzones,
|
|
||||||
1u,
|
|
||||||
languages
|
|
||||||
)
|
)
|
||||||
if (db.queuetableDB.Add(qt)) {
|
if (queuetableDB.Add(qt)) {
|
||||||
db.queuetableDB.Resort()
|
queuetableDB.Resort()
|
||||||
Logger.info { "SemiAutoWeb added to queue table: $qt" }
|
Logger.info { "SemiAutoWeb added to queue table: $qt" }
|
||||||
ctx.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
ctx.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
db.logSemiAuto.Add(
|
db.logSemiAuto.Add(
|
||||||
|
|||||||
Reference in New Issue
Block a user