@ -14,6 +14,7 @@ import 'package:queuing_system/core/response_models/prayers_widget_model.dart';
import ' package:queuing_system/core/response_models/rss_feed_model.dart ' ;
import ' package:queuing_system/core/response_models/weathers_widget_model.dart ' ;
import ' package:queuing_system/core/response_models/widgets_config_model.dart ' ;
import ' package:queuing_system/main.dart ' ;
import ' package:queuing_system/utils/call_by_voice.dart ' ;
import ' package:queuing_system/utils/call_type.dart ' ;
import ' package:queuing_system/utils/signalR_utils.dart ' ;
@ -57,8 +58,8 @@ class AppProvider extends ChangeNotifier {
}
Future < void > onVoiceCompleted ( ) async {
log ( " My Value is in setCompletionHandler: $ isVoiceActualCompletedGlobally " ) ;
log ( " isQueuePatients.length in setCompletionHandler: ${ isQueuePatients . length } " ) ;
log ger. i ( " My Value is in setCompletionHandler: $ isVoiceActualCompletedGlobally " ) ;
log ger. i ( " isQueuePatients.length in setCompletionHandler: ${ isQueuePatients . length } " ) ;
if ( ! isVoiceActualCompletedGlobally ) {
return ;
}
@ -86,13 +87,13 @@ class AppProvider extends ChangeNotifier {
) ;
}
log ( " here log g: ${ isQueuePatients . length } " ) ;
log ger. i ( " here log ger.i g: ${ isQueuePatients . length } " ) ;
if ( isQueuePatients . isEmpty ) {
isCallingInProgress = false ;
}
if ( isApiCallNeeded & & isQueuePatients . isEmpty ) {
log ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
log ger. i ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
Timer ( Duration ( seconds: patientCallConfigurations . concurrentCallDelaySec ) , ( ) async {
await callPatientsAPI ( ) ;
isApiCallNeeded = false ;
@ -134,7 +135,7 @@ class AppProvider extends ChangeNotifier {
Future < void > getInfoWidgetsConfigurationsFromServer ( ) async {
WidgetsConfigModel ? widgetsConfigModel = await API . getWidgetConfigsFromServer ( currentDeviceIp , onFailure: ( error ) {
log ( " Api call failed with this error: ${ error . toString ( ) } " ) ;
log ger. i ( " Api call failed with this error: ${ error . toString ( ) } " ) ;
} ) ;
if ( widgetsConfigModel ! = null ) currentWidgetsConfigModel = widgetsConfigModel ;
@ -146,7 +147,7 @@ class AppProvider extends ChangeNotifier {
Future < void > getWeatherDetailsFromServer ( ) async {
WeathersWidgetModel ? weathersWidgetModel = await API . getWeatherDetailsFromServer (
( currentWidgetsConfigModel ! . cityKey ? ? " " ) . toString ( ) ,
onFailure: ( error ) = > log ( " Api call failed with this error: ${ error . toString ( ) } " ) ,
onFailure: ( error ) = > log ger. i ( " Api call failed with this error: ${ error . toString ( ) } " ) ,
) ;
if ( weathersWidgetModel ! = null ) {
@ -159,7 +160,7 @@ class AppProvider extends ChangeNotifier {
void getNextPrayerToShow ( ) {
final current = DateTime . now ( ) ;
log ( " Checking Namaz time Locally at ${ current . toString ( ) } and ${ current . timeZoneName } " ) ;
log ger. i ( " Checking Namaz time Locally at ${ current . toString ( ) } and ${ current . timeZoneName } " ) ;
if ( DateTime . fromMillisecondsSinceEpoch ( currentPrayersWidgetModel . fajr ! ) . isAfter ( current ) ) {
final namazTime = DateFormat ( ' hh:mm a ' ) . format ( DateTime . fromMillisecondsSinceEpoch ( currentPrayersWidgetModel . fajr ! ) ) ;
@ -197,13 +198,11 @@ class AppProvider extends ChangeNotifier {
Future < void > getPrayerDetailsFromServer ( ) async {
PrayersWidgetModel ? prayersWidgetModel = await API . getPrayerDetailsFromServer (
latitude: currentWidgetsConfigModel ! . projectLatitude ? ? 0 ,
longitude: currentWidgetsConfigModel ! . projectLongitude ? ? 0 ,
onFailure: ( error ) = > log ( " Api call failed with this error: ${ error . toString ( ) } " ) ) ;
latitude: currentWidgetsConfigModel ! . projectLatitude ? ? 0 , longitude: currentWidgetsConfigModel ! . projectLongitude ? ? 0 , onFailure: ( error ) = > logger . i ( " Api call failed with this error: ${ error . toString ( ) } " ) ) ;
if ( prayersWidgetModel ! = null ) {
currentPrayersWidgetModel = prayersWidgetModel ;
log ( " I got this data from Prayers: ${ prayersWidgetModel . toString ( ) } " ) ;
log ger. i ( " I got this data from Prayers: ${ prayersWidgetModel . toString ( ) } " ) ;
getNextPrayerToShow ( ) ;
notifyListeners ( ) ;
}
@ -212,11 +211,11 @@ class AppProvider extends ChangeNotifier {
RssFeedModel currentRssFeedModel = RssFeedModel ( ) ;
Future < void > getRssFeedDetailsFromServer ( ) async {
RssFeedModel ? rssFeedModel = await API . getRssFeedDetailsFromServer ( languageId: 0 , onFailure: ( error ) = > log ( " Api call failed with this error: ${ error . toString ( ) } " ) ) ;
RssFeedModel ? rssFeedModel = await API . getRssFeedDetailsFromServer ( languageId: 0 , onFailure: ( error ) = > log ger. i ( " Api call failed with this error: ${ error . toString ( ) } " ) ) ;
if ( rssFeedModel ! = null ) {
currentRssFeedModel = rssFeedModel ;
log ( " I got this data from RssFeed: ${ currentRssFeedModel . rssFeed } " ) ;
log ger. i ( " I got this data from RssFeed: ${ currentRssFeedModel . rssFeed } " ) ;
notifyListeners ( ) ;
}
}
@ -259,7 +258,7 @@ class AppProvider extends ChangeNotifier {
counter + + ;
log ( " counterValue: $ counter " ) ;
log ger. i ( " counterValue: $ counter " ) ;
if ( counter = = 60 & & currentWidgetsConfigModel ! . isRssFeedReq ! ) {
await getRssFeedDetailsFromServer ( ) ;
@ -299,7 +298,7 @@ class AppProvider extends ChangeNotifier {
}
Future < void > callPatientsAPI ( ) async {
log ( " calling callPatientsAPI " ) ;
log ger. i ( " calling callPatientsAPI " ) ;
patientTickets . clear ( ) ;
API . getCallRequestInfoByClinicInfo ( currentDeviceIp ,
onSuccess: ( waitingCalls , isQueuePatientsCalls , callConfigs ) async {
@ -321,13 +320,13 @@ class AppProvider extends ChangeNotifier {
updatePatientTicket ( patientTickets . first ) ;
}
} ,
onFailure: ( error ) = > log ( " Api call failed with this error: ${ error . toString ( ) } " ) ) ;
onFailure: ( error ) = > log ger. i ( " Api call failed with this error: ${ error . toString ( ) } " ) ) ;
}
onPingReceived ( data ) async {
log ( " A new Ping Received when isQueuePatients: ${ isQueuePatients . length } " ) ;
log ( " isCallingInProgress from onPingReceived: $ isCallingInProgress " ) ;
log ( " isApiCallNeeded: $ isApiCallNeeded " ) ;
log ger. i ( " A new Ping Received when isQueuePatients: ${ isQueuePatients . length } " ) ;
log ger. i ( " isCallingInProgress from onPingReceived: $ isCallingInProgress " ) ;
log ger. i ( " isApiCallNeeded: $ isApiCallNeeded " ) ;
if ( patientTickets . isNotEmpty ) {
if ( isCallingInProgress ) {
isApiCallNeeded = true ;
@ -372,16 +371,16 @@ class AppProvider extends ChangeNotifier {
/ / }
voiceCallPatientTicket ( PatientTicketModel patientTicket , String calledFrom ) async {
log ( " voiceCallPatientTicket calledFrom : $ calledFrom " ) ;
log ger. i ( " voiceCallPatientTicket calledFrom : $ calledFrom " ) ;
currentPatient = patientTicket ;
isCallingInProgress = true ;
log ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
log ger. i ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
log ( " isVoiceReq: ${ patientTicket . isVoiceReq } " ) ;
log ( " voiceCaller: ${ voiceCaller = = null } " ) ;
log ( " isQueue: ${ patientTicket . isQueue } " ) ;
log ( " isToneReq: ${ patientTicket . isToneReq } " ) ;
log ger. i ( " isVoiceReq: ${ patientTicket . isVoiceReq } " ) ;
log ger. i ( " voiceCaller: ${ voiceCaller = = null } " ) ;
log ger. i ( " isQueue: ${ patientTicket . isQueue } " ) ;
log ger. i ( " isToneReq: ${ patientTicket . isToneReq } " ) ;
if ( patientTicket . isToneReq & & ! patientTicket . isQueue ) {
audioPlayer . setAsset ( " assets/tones/call_tone.mp3 " ) ;
@ -390,7 +389,7 @@ class AppProvider extends ChangeNotifier {
}
if ( patientTicket . isVoiceReq & & voiceCaller = = null & & ! patientTicket . isQueue ) {
log ( " patientTicket.voiceLanguage: ${ patientTicket . voiceLanguage } " ) ;
log ger. i ( " patientTicket.voiceLanguage: ${ patientTicket . voiceLanguage } " ) ;
final postVoice = getCallTypeText ( patientTicket ) ;
voiceCaller = CallByVoice (
preVoice: patientTicket . ticketNoText ,
@ -402,11 +401,11 @@ class AppProvider extends ChangeNotifier {
await voiceCaller ! . startCalling ( patientTicket . queueNo . trim ( ) . toString ( ) ! = patientTicket . callNoStr . trim ( ) . toString ( ) ) . whenComplete ( ( ) {
voiceCaller = null ;
onVoiceCompleted ( ) ;
log ( " Completed Calling!! ${ isQueuePatients . length } " ) ;
log ger. i ( " Completed Calling!! ${ isQueuePatients . length } " ) ;
} ) ;
} else {
isCallingInProgress = false ;
log ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
log ger. i ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
if ( isApiCallNeeded ) {
Timer ( Duration ( seconds: patientCallConfigurations . concurrentCallDelaySec ) , ( ) async {
await callPatientsAPI ( ) ;
@ -419,7 +418,7 @@ class AppProvider extends ChangeNotifier {
Future < void > listenAudioPlayerEvents ( ) async {
audioPlayer . playerStateStream . listen ( ( playerState ) async {
if ( playerState . processingState = = ProcessingState . completed ) {
log ( " Tone Completed " ) ;
log ger. i ( " Tone Completed " ) ;
if ( currentPatient . isVoiceReq ) {
isCallingInProgress = true ;
@ -429,7 +428,7 @@ class AppProvider extends ChangeNotifier {
if ( isQueuePatients . isNotEmpty ) {
isCallingInProgress = true ;
log ( " isQueuePatients.length 1: ${ isQueuePatients . length } " ) ;
log ger. i ( " isQueuePatients.length 1: ${ isQueuePatients . length } " ) ;
/ / for ( int i = 0 ; i < length ; i + + ) {
await Future . delayed ( Duration ( seconds: patientCallConfigurations . concurrentCallDelaySec ) ) . whenComplete ( ( ) async {
PatientTicketModel temp = PatientTicketModel ( ) ;
@ -445,7 +444,7 @@ class AppProvider extends ChangeNotifier {
patientTickets . add ( temp ) ;
}
notifyListeners ( ) ;
log ( " isQueuePatients.length 2: ${ isQueuePatients . length } " ) ;
log ger. i ( " isQueuePatients.length 2: ${ isQueuePatients . length } " ) ;
if ( isQueuePatients . isNotEmpty ) {
await voiceCallPatientTicket ( patientTickets . first , " listenAudioPlayerEvents " ) ;
@ -458,7 +457,7 @@ class AppProvider extends ChangeNotifier {
isCallingInProgress = false ;
}
if ( isApiCallNeeded & & isQueuePatients . isEmpty ) {
log ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
log ger. i ( " Setting isCallingInProgress : $ isCallingInProgress " ) ;
Timer ( Duration ( seconds: patientCallConfigurations . concurrentCallDelaySec ) , ( ) async {
await callPatientsAPI ( ) ;
isApiCallNeeded = false ;
@ -472,9 +471,9 @@ class AppProvider extends ChangeNotifier {
/ / if ( patientTickets . isNotEmpty ) {
/ / List < Tickets > _ticketsToUpdate = patientTickets . where ( ( t ) = > t . callUpdated = = false ) . toList ( ) ;
/ / API . callUpdateNotIsQueueRecordByIDAsync ( currentDeviceIp , ticket: _ticketsToUpdate . first , onSuccess: ( ticketsUpdated ) {
/ / log ( " [ ${ ticketsUpdated . length } ] Tickets Updated: $ ticketsUpdated " ) ;
/ / log ger. i ( " [ ${ ticketsUpdated . length } ] Tickets Updated: $ ticketsUpdated " ) ;
/ / } , onFailure: ( e ) {
/ / log ( " Tickets Update Failed with : ${ e . toString ( ) } " ) ;
/ / log ger. i ( " Tickets Update Failed with : ${ e . toString ( ) } " ) ;
/ / } ) ;
/ / }
/ / }
@ -482,24 +481,24 @@ class AppProvider extends ChangeNotifier {
updatePatientTicket ( PatientTicketModel patientTicket ) {
if ( ! patientTicket . isQueue ) {
API . callUpdateNotIsQueueRecordByIDAsync ( currentDeviceIp , ticket: patientTicket , onSuccess: ( ticketsUpdated ) {
log ( " [ ${ patientTicket . callNoStr } ] Ticket Updated: $ ticketsUpdated " ) ;
log ger. i ( " [ ${ patientTicket . callNoStr } ] Ticket Updated: $ ticketsUpdated " ) ;
} , onFailure: ( e ) {
log ( " Tickets Update ${ patientTicket . callNoStr } Failed with Error : ${ e . toString ( ) } " ) ;
log ger. i ( " Tickets Update ${ patientTicket . callNoStr } Failed with Error : ${ e . toString ( ) } " ) ;
} ) ;
}
}
onConnect ( ) {
log ( " SignalR: onConnect " ) ;
log ger. i ( " SignalR: onConnect " ) ;
}
onDisconnect ( exception ) {
log ( " SignalR: onDisconnect " ) ;
signalRHelper . startSignalRConnection ( currentDeviceIp , onUpdateAvailable: onPingReceived , onConnect: onConnect , onConnecting: onConnecting , onDisconnect: onDisconnect );
log ger. i ( " SignalR: onDisconnect " ) ;
signalRHelper . startSignalRConnection ( currentDeviceIp , onUpdateAvailable: onPingReceived , onConnect: onConnect , onConnecting: onConnecting , onDisconnect: onDisconnect , );
}
onConnecting ( ) {
log ( " SignalR: onConnecting " ) ;
log ger. i ( " SignalR: onConnecting " ) ;
}
listenNetworkConnectivity ( ) async {