JUtility.initEANBarcode();
JLaunchReport.init();
Common.init();
JDBUser user = new JDBUser(getHostID(), getSessionID());
JDBControl ctrl = new JDBControl(getHostID(), getSessionID());
JeMail mail = new JeMail(getHostID(), getSessionID());
user.setUserId("INTERFACE");
user.setPassword("INTERFACE");
Common.userList.addUser(getSessionID(), user);
enableEnterfaceStatusEmails = Boolean.parseBoolean(ctrl.getKeyValueWithDefault("INTERFACE EMAIL NOTIFY", "false", "Email startup and shutdown events :- true or false"));
interfaceEmailAddresses = ctrl.getKeyValueWithDefault("INTERFACE ADMIN EMAIL", "someone@somewhere.com", "Email address for startup and shutdown events.");
StringConverter stringConverter = new StringConverter();
ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter);
arrayConverter.setDelimiter(';');
arrayConverter.setAllowedChars(new char[] { '@','_' });
String[] emailList = (String[]) arrayConverter.convert(String[].class, interfaceEmailAddresses);
siteName = Common.hostList.getHost(getHostID()).getSiteDescription();
if (user.login())
{
if (enableEnterfaceStatusEmails == true)
{
try
{
String subject = "";
if (houseKeeping == true)
{
subject = "Commander4j "+JVersion.getProgramVersion()+" Interface maintenance restart for [" + siteName + "] on "+JUtility.getClientName();
}
else
{
subject = "Commander4j "+JVersion.getProgramVersion()+" Interface startup for [" + siteName + "] on "+JUtility.getClientName();
}
mail.postMail(emailList, subject, "Interface service has started.", "", "");
}
catch (Exception ex)
{
logger.error("InterfaceThread Unable to send emails");
}
}
houseKeeping = false;
logger.debug("Interface Logged on successfully");
logger.debug("Starting Threads....");
secondsBeforeHousekeeping = Integer.valueOf(ctrl.getKeyValueWithDefault("INTERFACE HOUSEKEEPING INTERVAL", "86400", "Frequency in seconds."));
secondsRemaining = secondsBeforeHousekeeping;
startupThreads();
while ((shutdown == false) & (houseKeeping == false))