11package Jvakt ;
22/*
3+ * 2024-07-09 V.57 Michael Ekdal Added more info when reporting in status to Jvakt server.
34 * 2023-08-21 V.56 Michael Ekdal Increased sleep times when waiting for the operator response.
45 * 2023-01-03 V.55 Michael Ekdal Added send of the status to Jvakt server
56 * 2022-06-23 V.54 Michael Ekdal Added getVersion() to get at consistent version throughout all classes.
@@ -28,6 +29,7 @@ public class SendSMS {
2829 static boolean swDormant = false ;
2930 static boolean swShowVer = true ;
3031 static boolean swOK = false ;
32+ static boolean swSTS = false ;
3133
3234 static java .sql .Date zDate ;
3335 static java .sql .Timestamp zD ;
@@ -70,6 +72,8 @@ public class SendSMS {
7072 static String jvport = "1956" ;
7173 static int port = 1956 ;
7274 static InetAddress inet ;
75+
76+ static File configF ;
7377
7478 // static Authenticator auth;
7579
@@ -78,7 +82,7 @@ public class SendSMS {
7882 public static void main (String [] args ) throws IOException , UnknownHostException {
7983
8084 String version = "SendSMS " ;
81- version += getVersion ()+".56 " ;
85+ version += getVersion ()+".57 " ;
8286 String database = "jVakt" ;
8387 String dbuser = "jVakt" ;
8488 String dbpassword = "" ;
@@ -88,7 +92,6 @@ public static void main(String[] args ) throws IOException, UnknownHostException
8892// String jvport = "1956";
8993
9094 String config = null ;
91- File configF ;
9295
9396 Calendar cal = Calendar .getInstance ();
9497
@@ -189,12 +192,14 @@ public static void main(String[] args ) throws IOException, UnknownHostException
189192 " and prio < 30" +
190193 ";" );
191194
192- // System.out.println(s);
195+ // System.out.println(s);
193196 // stmt = conn.createStatement(ResultSet.CONCUR_UPDATABLE,ResultSet.TYPE_SCROLL_INSENSITIVE);
194197 stmt = conn .createStatement (ResultSet .CONCUR_UPDATABLE ,ResultSet .TYPE_FORWARD_ONLY ,ResultSet .CLOSE_CURSORS_AT_COMMIT );
195198 stmt .setFetchSize (1000 );
196199 ResultSet rs = stmt .executeQuery (s );
197200 // swHits = false; // is there already a record?
201+ swSTS = true ;
202+
198203 while (rs .next ()) {
199204 System .out .println ("\n " +LocalDateTime .now ()+" **** main RS - State:" +rs .getString ("state" )+" Id:" + rs .getString ("id" )+" Type:" +rs .getString ("type" )+" Prio:" +rs .getString ("prio" )+" Console:" +rs .getString ("console" )+" Status:" +rs .getString ("status" )+ " Sms:" +rs .getString ("sms" ));
200205 // swHits = true;
@@ -291,7 +296,8 @@ else if (rs.getString("sms").equalsIgnoreCase("R")) {
291296 // System.err.println(e.getMessage());
292297 }
293298 finally {
294- if (swOK ) try {sendSTS (true );} catch (IOException e ) { e .printStackTrace ();}
299+ if (swSTS ) try {sendSTS (true );} catch (IOException e ) { e .printStackTrace ();}
300+ if (!swSTS ) try {sendSTS (false );} catch (IOException e ) { e .printStackTrace ();}
295301 }
296302 }
297303
@@ -400,6 +406,7 @@ static boolean sendSMS() {
400406 return true ;
401407 }
402408 else {
409+ swSTS =false ;
403410 System .out .println (LocalDateTime .now ()+" Failure sending SMS message" );
404411 try {sendSTS (false );} catch (IOException e ) { e .printStackTrace ();}
405412 return false ;
@@ -472,11 +479,11 @@ static protected void sendSTS( boolean STS) throws IOException {
472479 jm .open ();
473480 jmsg .setId ("Jvakt-SendSMS" );
474481 if (STS ) {
475- jmsg .setBody ("The SendSMS program is active" );
482+ jmsg .setBody ("The SendSMS program is active. " + configF . getCanonicalPath () );
476483 jmsg .setRptsts ("OK" );
477484 }
478485 else {
479- jmsg .setBody ("The SendSMS program aborted the SMS sending!" );
486+ jmsg .setBody ("The SendSMS program aborted the SMS sending! " + configF . getCanonicalPath () );
480487 jmsg .setRptsts ("ERR" );
481488 }
482489 jmsg .setType ("T" );
0 commit comments