Examples of JeMail


Examples of com.commander4j.email.JeMail

  {

    setHostID(host);
    setSessionID(session);
    ugm = new JDBUserGroupMembership(host, session);
    mail = new JeMail(getHostID(), getSessionID());
    lang = new JDBLanguage(Common.selectedHostID, Common.sessionID);

    if (Common.userList.getUser(Common.sessionID).isModuleAllowed("FRM_ADMIN_USER_REPORT_EDIT"))
    {
      adminUser = true;
View Full Code Here

Examples of com.commander4j.email.JeMail

          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();
                //   mail.postMail(emailList, subject, "Interface service has started.", "", "");
                }
                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))
            {
              com.commander4j.util.JWait.milliSec(1000);
              secondsRemaining--;
              // logger.debug("Housekeeping scheduled in "+String.valueOf(secondsRemaining)+" seconds.");

              if (secondsRemaining == 0)
              {
                houseKeeping = true;

              }
            }

            logger.debug("Stopping Threads....");
            shutdownThreads();

            user.logout();
            logger.debug("Interface Logged out successfully");

            if (enableEnterfaceStatusEmails == true)
            {
              try
              {
                String subject = "";
                if (houseKeeping == true)
                {
                //   subject = "Commander4j "+JVersion.getProgramVersion()+" Interface maintenance shutdown for [" + siteName + "] on "+JUtility.getClientName();
                //   mail.postMail(emailList, subject, "Interface service has stopped.", "", "");
                }
                else
                {
                  subject = "Commander4j "+JVersion.getProgramVersion()+" Interface shutdown for [" + siteName + "] on "+JUtility.getClientName();
                  mail.postMail(emailList, subject, "Interface service has stopped.", "", "");
               
              }
              catch (Exception ex)
              {
                logger.error("InterfaceThread Unable to send emails");
              }
            }

          }
          else
          {
            logger.debug("Interface routine failed to logon to application using account INTERFACE");

          }
         
          try
          {
            backupMessageRetention =Integer.valueOf(ctrl.getKeyValueWithDefault("INTERFACE BACKUP RETENTION","30","NUMBER OF DAYS TO KEEP BACKUP MESSAGES"));
          }
          catch (Exception ex)
          {
            backupMessageRetention = 30;
          }
         
          logger.debug("Initiating data archiving....");
          JDBArchive c = new JDBArchive(getHostID(), getSessionID());           
          c.runSQLJobList();
          String archiveReportString = c.reportData();
          c=null;
          logger.debug("Data archiving complete....");
         
          logger.debug("Disconnecting from database.");
          Common.hostList.getHost(getHostID()).disconnectAll();
          // .disconnect(Common.sessionID);

          if (houseKeeping == true)
          {
            logger.debug("HOUSEKEEPING START");
           
            // Archive old backup files goes here
            String archivedFiles ="Backup message files removed by auto archive = ";
            if (backupMessageRetention > 0)
            {
              archivedFiles = archivedFiles + String.valueOf(JArchive.archiveBackupFiles(System.getProperty("user.dir")+File.separator+Common.interface_backup_path, backupMessageRetention));
            }
            else
            {
              archivedFiles = "Auto archive of messages disabled";
            }
           
            String freeSpace = JUtility.diskFree();
           
            String memoryBefore = "Memory used before garbage collection = " + String.valueOf((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) + "k";
            System.gc();
            String memoryAfter = "Memory used after garbage collection  = " + String.valueOf((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) + "k";
            String stats = GenericMessageHeader.getStats();
            GenericMessageHeader.clearStats();
           
            if (enableEnterfaceStatusEmails == true)
            {
              try
              {
                mail.postMail(emailList, "Commander4j "+JVersion.getProgramVersion()+" Interface maintenance for [" + siteName+ "] on "+JUtility.getClientName(),
                    memoryBefore + "\n\n" + memoryAfter + "\n\n" + archivedFiles + "\n\n"+ freeSpace + "\n\n"+ "Maintenance is scheduled to occur every " + String.valueOf(secondsBeforeHousekeeping) + " seconds.\n\n\n\n"+stats+"\n\n\n"+archiveReportString,
                   "","");
              }
              catch (Exception ex)
              {
View Full Code Here

Examples of com.commander4j.email.JeMail

    }

    if (dbconnected)
    {
      JDBInterfaceLog il = new JDBInterfaceLog(getHostID(), getSessionID());
      JeMail mail = new JeMail(getHostID(), getSessionID());
      JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
      IncommingMaterialDefinition imd = new IncommingMaterialDefinition(getHostID(), getSessionID());
      IncommingProcessOrderStatusChange iposc = new IncommingProcessOrderStatusChange(getHostID(), getSessionID());
      IncommingProductionDeclarationConfirmation ipd = new IncommingProductionDeclarationConfirmation(getHostID(), getSessionID());
      IncommingProcessOrder ipo = new IncommingProcessOrder(getHostID(), getSessionID());
      IncommingPalletStatusChange ipsc = new IncommingPalletStatusChange(getHostID(), getSessionID());
      IncommingBatchStatusChange bsc = new IncommingBatchStatusChange(getHostID(), getSessionID());
      IncommingInspectionResult iirslt = new IncommingInspectionResult(getHostID(), getSessionID());
      IncommingDespatchConfirmation idc = new IncommingDespatchConfirmation(getHostID(), getSessionID());
      IncommingQMInspectionRequest iireq = new IncommingQMInspectionRequest(getHostID(), getSessionID());
      GenericMessageHeader gmh = new GenericMessageHeader();
      LinkedList<String> filenames = new LinkedList<String>();
      BasicFileAttributes attrs;
     
      while (true)
      {

        com.commander4j.util.JWait.milliSec(100);

        if (allDone)
        {
          if (dbconnected)
          {
            Common.hostList.getHost(hostID).disconnect(getSessionID());
          }
          return;
        }

        if (InboundMessageCollectionThread.recoveringFiles == false)
        {

          dir = new File(inputPath);

          chld = dir.listFiles((FileFilter) FileFileFilter.FILE);

          if (chld == null)
          {
            allDone = true;
          } else
          {
            Arrays.sort(chld, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);
            filenames.clear();

            for (int i = 0; (i < chld.length) & (i < maxfiles); i++)
            {
              fileName = chld[i].getName();
              try
              {
                attrs = Files.readAttributes(chld[i].getAbsoluteFile().toPath(), BasicFileAttributes.class);

                if (attrs.size() > 0)
                {
                  if (fileName.indexOf(".xml") > 0)
                  {
                    filenames.addFirst(fileName);
                    com.commander4j.util.JWait.milliSec(50);
                  }
                } else
                {
                  try
                  {
                    chld[i].delete();
                  }
                  catch (Exception ex)
                  {
                   
                  }
                }
              } catch (IOException e)
              {

              }

            }

            if (filenames.size() > 0)
            {
              logger.debug("Begin processing " + String.valueOf(filenames.size()) + " files.");
              for (int i = filenames.size() - 1; i >= 0; i--)
              {
                if (allDone)
                {
                  if (dbconnected)
                  {
                    Common.hostList.getHost(hostID).disconnect(getSessionID());
                  }
                  return;
                }

                fromFile = filenames.get(i);

                try
                {
                  logger.debug("<---  START OF PROCESSING " + fromFile + "  ---->");
                  logger.debug("Reading message header : " + inputPath + fromFile);

                  if (gmh.readAddressInfo(inputPath + fromFile, getSessionID()) == true)
                  {

                    messageProcessedOK = true;
                    errorMessage = "";

                    if (gmh.getInterfaceType().length() == 0)
                    {
                      messageProcessedOK = false;
                      errorMessage = "Unrecognised Commander4j XML message format in file " + fromFile;
                      logger.debug(errorMessage);
                      String datetime = "";
                      datetime = JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime());
                      gmh.setMessageDate(datetime);
                      gmh.setInterfaceDirection("Unknown");
                      gmh.setMessageInformation(fromFile);
                      gmh.setInterfaceType("Unknown");
                      gmh.setMessageRef("Unknown");
                    } else
                    {
                      if (gmh.getInterfaceDirection().equals("Input") == false)
                      {
                        messageProcessedOK = false;
                        errorMessage = "Inbound message ignored - Interface Direction = " + gmh.getInterfaceDirection();
                      } else
                      {
                        String interfaceType = gmh.getInterfaceType();
                        logger.debug("Processing " + interfaceType + " started.");
                        if (interfaceType.equals("Despatch Confirmation") == true)
                        {
                          messageProcessedOK = idc.processMessage(gmh);
                          errorMessage = idc.getErrorMessage();
                        }

                        if (interfaceType.equals("Material Definition") == true)
                        {
                          messageProcessedOK = imd.processMessage(gmh);
                          errorMessage = imd.getErrorMessage();
                        }

                        if (interfaceType.equals("Process Order") == true)
                        {
                          messageProcessedOK = ipo.processMessage(gmh);
                          errorMessage = ipo.getErrorMessage();
                        }

                        if (interfaceType.equals("Pallet Status Change") == true)
                        {
                          messageProcessedOK = ipsc.processMessage(gmh);
                          errorMessage = ipsc.getErrorMessage();
                        }

                        if (interfaceType.equals("Batch Status Change") == true)
                        {
                          messageProcessedOK = bsc.processMessage(gmh);
                          errorMessage = bsc.getErrorMessage();
                        }

                        if (interfaceType.equals("Process Order Status Change") == true)
                        {
                          messageProcessedOK = iposc.processMessage(gmh);
                          errorMessage = iposc.getErrorMessage();
                        }

                        if (interfaceType.equals("Production Declaration") == true)
                        {
                          messageProcessedOK = ipd.processMessage(gmh);
                          errorMessage = ipd.getErrorMessage();
                        }

                        if (interfaceType.equals("QM Inspection Request") == true)
                        {
                          messageProcessedOK = iireq.processMessage(gmh);
                          errorMessage = iireq.getErrorMessage();
                        }

                        if (interfaceType.equals("QM Inspection Result") == true)
                        {
                          messageProcessedOK = iirslt.processMessage(gmh);
                          errorMessage = iirslt.getErrorMessage();
                        }

                        GenericMessageHeader.updateStats("Input", interfaceType, messageProcessedOK.toString());
                        logger.debug("Processing " + interfaceType + " finished.");
                      }
                    }

                    logger.debug("    ===  RESULT " + messageProcessedOK.toString() + "  ===");

                    if (messageProcessedOK)
                    {

                      il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "DB Update", fromFile);
                      reader.deleteFile(backupPath + gmh.getInterfaceType() + File.separator + fromFile);
                      reader.move_FileToDirectory(inputPath + fromFile, backupPath + gmh.getInterfaceType(), true);
                    } else
                    {
                      il.write(gmh, GenericMessageHeader.msgStatusError, errorMessage, "DB Update", fromFile);
                      if (inter.getInterfaceProperties(gmh.getInterfaceType(), "Input") == true)
                      {
                        if (inter.getEmailError() == true)
                        {
                          String emailaddresses = inter.getEmailAddresses();

                          StringConverter stringConverter = new StringConverter();
                          ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter);
                          arrayConverter.setDelimiter(';');
                          arrayConverter.setAllowedChars(new char[]
                          { '@', '_' });

                          String[] emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses);

                          if (emailList.length > 0)
                          {
                            String siteName = Common.hostList.getHost(getHostID()).getSiteDescription();
                            String attachedFilename = Common.base_dir + java.io.File.separator + inputPath + fromFile;
                            logger.debug("Attaching file  " + Common.base_dir + java.io.File.separator + inputPath + fromFile);
                            mail.postMail(emailList, "Error Processing Incoming " + gmh.getInterfaceType() + " for [" + siteName + "] on " + JUtility.getClientName(), errorMessage, fromFile, attachedFilename);
                            com.commander4j.util.JWait.milliSec(2000);
                          }
                        }

                      }
View Full Code Here

Examples of com.commander4j.email.JeMail

    }

    if (dbconnected)
    {

      JeMail mail = new JeMail(getHostID(), getSessionID());
      JDBInterfaceRequest ir = new JDBInterfaceRequest(getHostID(), getSessionID());
      JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
      OutgoingProductionDeclarationConfirmation opdc = new OutgoingProductionDeclarationConfirmation(getHostID(), getSessionID());
      OutgoingDespatchConfirmation odc = new OutgoingDespatchConfirmation(getHostID(), getSessionID());
      OutgoingDespatchPreAdvice opa = new OutgoingDespatchPreAdvice(getHostID(), getSessionID());
      OutgoingEquipmentTracking oet = new OutgoingEquipmentTracking(getHostID(), getSessionID());
      OutgoingPalletStatusChange psc = new OutgoingPalletStatusChange(getHostID(), getSessionID());
      OutgoingPalletSplit ops = new OutgoingPalletSplit(getHostID(), getSessionID());
      OutgoingPalletDelete opd = new OutgoingPalletDelete(getHostID(), getSessionID());
      OutgoingLabelData old = new OutgoingLabelData(getHostID(), getSessionID());
      LinkedList<Long> irqList = new LinkedList<Long>();
      int noOfMessages = 0;

      while (true)
      {

        JWait.milliSec(500);

        if (allDone)
        {
          if (dbconnected)
          {
            Common.hostList.getHost(hostID).disconnect(getSessionID());
          }
          return;
        }

        irqList.clear();
        irqList = ir.getInterfaceRequestIDs();
        noOfMessages = irqList.size();

        if (noOfMessages > 0)
        {
          for (int x = 0; x < noOfMessages; x++)
          {
            JWait.milliSec(100);
            ir.setInterfaceRequestID(irqList.get(x));
            ir.getInterfaceRequestProperties();

            if (ir.getMode().equals("Inbound File Re-Submit"))
            {
              if (inter.getInterfaceProperties(ir.getInterfaceType(), "Input") == true)
              {
                String sourceFile = Common.base_dir + java.io.File.separator + "xml" + java.io.File.separator + "interface" + java.io.File.separator + "error" + java.io.File.separator + ir.getInterfaceType() + java.io.File.separator
                    + ir.getFilename();

                destinationFile = inter.getRealPath() + java.io.File.separator + ir.getFilename();
                renamedDestinationFile = inter.getRealPath() + java.io.File.separator + ir.getFilename().replaceAll(".xml", ".lmx");

                mover.move_File(sourceFile, renamedDestinationFile);
                mover.move_File(renamedDestinationFile, destinationFile);
                ir.delete();

              }
            }

            if (ir.getMode().equals("Normal"))
            {

              errorMessage = "Unknown Outbound Interface Type :" + ir.getInterfaceType();
              messageProcessedOK = false;

              if (ir.getInterfaceType().equals("Production Declaration"))
              {
                messageProcessedOK = opdc.processMessage(ir.getTransactionRef());
                errorMessage = opdc.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Production Declaration", messageProcessedOK.toString());
              }

              if (ir.getInterfaceType().equals("Pallet Status Change"))
              {
                messageProcessedOK = psc.processMessage(ir.getTransactionRef());
                errorMessage = psc.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Pallet Status Change", messageProcessedOK.toString());
              }             

              if (ir.getInterfaceType().equals("Pallet Split"))
              {
                messageProcessedOK = ops.processMessage(ir.getTransactionRef());
                errorMessage = ops.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Pallet Split", messageProcessedOK.toString());
             
             
              if (ir.getInterfaceType().equals("Pallet Delete"))
              {
                messageProcessedOK = opd.processMessage(ir.getTransactionRef());
                errorMessage = opd.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Pallet Delete", messageProcessedOK.toString());
             
             
              if (ir.getInterfaceType().equals("Despatch Confirmation"))
              {
                messageProcessedOK = odc.processMessage(ir.getTransactionRef());
                errorMessage = odc.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Despatch Confirmation", messageProcessedOK.toString());
              }

              if (ir.getInterfaceType().equals("Despatch Pre Advice"))
              {
                messageProcessedOK = opa.processMessage(ir.getTransactionRef());
                errorMessage = opa.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Despatch Pre Advice", messageProcessedOK.toString());
              }

              if (ir.getInterfaceType().equals("Equipment Tracking"))
              {
                messageProcessedOK = oet.processMessage(ir.getTransactionRef());
                errorMessage = oet.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Equipment Tracking", messageProcessedOK.toString());
              }
             
              if (ir.getInterfaceType().equals("Label Data"))
              {
                messageProcessedOK = old.processMessage(ir.getUniqueID());
                errorMessage = oet.getErrorMessage();
                GenericMessageHeader.updateStats("Output","Label Data", messageProcessedOK.toString());
              }

              if (messageProcessedOK == true)
              {
                ir.delete();
              }
              else
              {
                ir.update(irqList.get(x), "Error");
                if (inter.getInterfaceProperties(ir.getInterfaceType(), "Output") == true)
                {
                  if (inter.getEmailError() == true)
                  {
                    String emailaddresses = inter.getEmailAddresses();

                    StringConverter stringConverter = new StringConverter();
                    ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter);
                    arrayConverter.setDelimiter(';');
                    arrayConverter.setAllowedChars(new char[] { '@' });

                    String[] emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses);

                    if (emailList.length > 0)
                    {
                      try
                      {
                        String siteName = Common.hostList.getHost(getHostID()).getSiteDescription();
                        mail.postMail(emailList, "Error Processing Outgoing " + ir.getInterfaceType()+" for ["+siteName+"] on "+JUtility.getClientName(), errorMessage, "", "");
                      }
                      catch (MessagingException e)
                      {

                      }
View Full Code Here

Examples of com.commander4j.email.JeMail

    }

    if (dbconnected)
    {
      JDBInterfaceLog il = new JDBInterfaceLog(getHostID(), getSessionID());
      JeMail mail = new JeMail(getHostID(), getSessionID());
      JDBInterface inter = new JDBInterface(getHostID(), getSessionID());
      IncommingMaterialDefinition imd = new IncommingMaterialDefinition(getHostID(), getSessionID());
      IncommingProcessOrderStatusChange iposc = new IncommingProcessOrderStatusChange(getHostID(), getSessionID());
      IncommingProductionDeclarationConfirmation ipd = new IncommingProductionDeclarationConfirmation(getHostID(), getSessionID());
      IncommingProcessOrder ipo = new IncommingProcessOrder(getHostID(), getSessionID());
      IncommingPalletStatusChange ipsc = new IncommingPalletStatusChange(getHostID(), getSessionID());
      IncommingBatchStatusChange bsc = new IncommingBatchStatusChange(getHostID(), getSessionID());
      IncommingInspectionResult iirslt = new IncommingInspectionResult(getHostID(), getSessionID());
      IncommingDespatchConfirmation idc = new IncommingDespatchConfirmation(getHostID(), getSessionID());
      IncommingQMInspectionRequest iireq = new IncommingQMInspectionRequest(getHostID(), getSessionID());
      GenericMessageHeader gmh = new GenericMessageHeader();
      LinkedList<String> filenames = new LinkedList<String>();

      while (true)
      {

        com.commander4j.util.JWait.milliSec(100);

        if (allDone)
        {
          if (dbconnected)
          {
            Common.hostList.getHost(hostID).disconnect(getSessionID());
          }
          return;
        }

        if (InboundMessageCollectionThread.recoveringFiles == false)
        {

          dir = new File(inputPath);
          chld = dir.list();

          if (chld == null)
          {
            allDone = true;
          }
          else
          {
            filenames.clear();
            for (int i = 0; (i < chld.length) & (i < maxfiles); i++)
            {
              fileName = chld[i];
              if (fileName.indexOf(".xml") > 0)
              {
                filenames.addFirst(fileName);
                com.commander4j.util.JWait.milliSec(50);
              }
            }

            if (filenames.size() > 0)
            {
              logger.debug("Begin processing " + String.valueOf(filenames.size()) + " files.");
              for (int i = filenames.size() - 1; i >= 0; i--)
              {
                if (allDone)
                {
                  if (dbconnected)
                  {
                    Common.hostList.getHost(hostID).disconnect(getSessionID());
                  }
                  return;
                }

                fromFile = filenames.get(i);

                try
                {
                  logger.debug("<---  START OF PROCESSING " + fromFile + "  ---->");
                  logger.debug("Reading message header : " + inputPath + fromFile);

                  if (gmh.readAddressInfo(inputPath + fromFile, getSessionID()) == true)
                  {

                    messageProcessedOK = true;
                    errorMessage = "";

                    if (gmh.getInterfaceType().length() == 0)
                    {
                      messageProcessedOK = false;
                      errorMessage = "Unrecognised Commander4j XML message format in file " + fromFile;
                      logger.debug(errorMessage);
                      String datetime = "";
                      datetime = JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime());
                      gmh.setMessageDate(datetime);
                      gmh.setInterfaceDirection("Unknown");
                      gmh.setMessageInformation(fromFile);
                      gmh.setInterfaceType("Unknown");
                      gmh.setMessageRef("Unknown");
                    }
                    else
                    {
                      if (gmh.getInterfaceDirection().equals("Input") == false)
                      {
                        messageProcessedOK = false;
                        errorMessage = "Inbound message ignored - Interface Direction = " + gmh.getInterfaceDirection();
                      }
                      else
                      {
                        String interfaceType = gmh.getInterfaceType();
                        logger.debug("Processing " + interfaceType + " started.");
                        if (interfaceType.equals("Despatch Confirmation") == true)
                        {
                          messageProcessedOK = idc.processMessage(gmh);
                          errorMessage = idc.getErrorMessage();
                        }

                        if (interfaceType.equals("Material Definition") == true)
                        {
                          messageProcessedOK = imd.processMessage(gmh);
                          errorMessage = imd.getErrorMessage();
                        }

                        if (interfaceType.equals("Process Order") == true)
                        {
                          messageProcessedOK = ipo.processMessage(gmh);
                          errorMessage = ipo.getErrorMessage();
                        }

                        if (interfaceType.equals("Pallet Status Change") == true)
                        {
                          messageProcessedOK = ipsc.processMessage(gmh);
                          errorMessage = ipsc.getErrorMessage();
                        }

                        if (interfaceType.equals("Batch Status Change") == true)
                        {
                          messageProcessedOK = bsc.processMessage(gmh);
                          errorMessage = bsc.getErrorMessage();
                        }

                        if (interfaceType.equals("Process Order Status Change") == true)
                        {
                          messageProcessedOK = iposc.processMessage(gmh);
                          errorMessage = iposc.getErrorMessage();
                        }

                        if (interfaceType.equals("Production Declaration") == true)
                        {
                          messageProcessedOK = ipd.processMessage(gmh);
                          errorMessage = ipd.getErrorMessage();
                        }
                       
                        if (interfaceType.equals("QM Inspection Request") == true)
                        {
                          messageProcessedOK = iireq.processMessage(gmh);
                          errorMessage = iireq.getErrorMessage();
                        }
                       
                        if (interfaceType.equals("QM Inspection Result") == true)
                        {
                          messageProcessedOK = iirslt.processMessage(gmh);
                          errorMessage = iirslt.getErrorMessage();
                        }
                       
                        GenericMessageHeader.updateStats("Input", interfaceType, messageProcessedOK.toString());
                        logger.debug("Processing " + interfaceType + " finished.");
                      }
                    }

                    logger.debug("    ===  RESULT " + messageProcessedOK.toString() + "  ===");

                    if (messageProcessedOK)
                    {

                      il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "DB Update", fromFile);
                      reader.deleteFile(backupPath + gmh.getInterfaceType() + File.separator + fromFile);
                      reader.move_FileToDirectory(inputPath + fromFile, backupPath + gmh.getInterfaceType(), true);
                    }
                    else
                    {
                      il.write(gmh, GenericMessageHeader.msgStatusError, errorMessage, "DB Update", fromFile);
                      if (inter.getInterfaceProperties(gmh.getInterfaceType(), "Input") == true)
                      {
                        if (inter.getEmailError() == true)
                        {
                          String emailaddresses = inter.getEmailAddresses();

                          StringConverter stringConverter = new StringConverter();
                          ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter);
                          arrayConverter.setDelimiter(';');
                          arrayConverter.setAllowedChars(new char[]
                          { '@','_' });

                          String[] emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses);

                          if (emailList.length > 0)
                          {
                            String siteName = Common.hostList.getHost(getHostID()).getSiteDescription();
                            String attachedFilename = Common.base_dir + java.io.File.separator +inputPath+fromFile;
                            logger.debug("Attaching file  "+Common.base_dir + java.io.File.separator +inputPath+fromFile);
                            mail.postMail(emailList, "Error Processing Incoming " + gmh.getInterfaceType() + " for [" + siteName + "] on " + JUtility.getClientName(), errorMessage, fromFile, attachedFilename);
                            com.commander4j.util.JWait.milliSec(2000);
                          }
                        }

                      }
View Full Code Here

Examples of com.commander4j.email.JeMail

          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))
            {
              com.commander4j.util.JWait.milliSec(1000);
              secondsRemaining--;
              // logger.debug("Housekeeping scheduled in "+String.valueOf(secondsRemaining)+" seconds.");

              if (secondsRemaining == 0)
              {
                houseKeeping = true;

              }
            }

            logger.debug("Stopping Threads....");
            shutdownThreads();

            user.logout();
            logger.debug("Interface Logged out successfully");

            if (enableEnterfaceStatusEmails == true)
            {
              try
              {
                String subject = "";
                if (houseKeeping == true)
                {
                   subject = "Commander4j "+JVersion.getProgramVersion()+" Interface maintenance shutdown for [" + siteName + "] on "+JUtility.getClientName();
                }
                else
                {
                  subject = "Commander4j "+JVersion.getProgramVersion()+" Interface shutdown for [" + siteName + "] on "+JUtility.getClientName();
                }
                mail.postMail(emailList, subject, "Interface service has stopped.", "", "");
              }
              catch (Exception ex)
              {
                logger.error("InterfaceThread Unable to send emails");
              }
            }

          }
          else
          {
            logger.debug("Interface routine failed to logon to application using account INTERFACE");

          }
          logger.debug("Disconnecting from database.");
          Common.hostList.getHost(getHostID()).disconnectAll();
          // .disconnect(Common.sessionID);

          if (houseKeeping == true)
          {
            logger.debug("HOUSEKEEPING START");
            String memoryBefore = "Memory used before garbage collection = " + String.valueOf((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) + "k";
            System.gc();
            String memoryAfter = "Memory used after garbage collection  = " + String.valueOf((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) + "k";
            String stats = GenericMessageHeader.getStats();
            GenericMessageHeader.clearStats();
           
            if (enableEnterfaceStatusEmails == true)
            {
              try
              {
                mail.postMail(emailList, "Commander4j "+JVersion.getProgramVersion()+" Interface maintenance for [" + siteName+ "] on "+JUtility.getClientName(),
                    memoryBefore + "\n\n" + memoryAfter + "\n\n" + "Maintenance is scheduled to occur every " + String.valueOf(secondsBeforeHousekeeping) + " seconds.\n\n\n\n"+stats,
                   "","");
              }
              catch (Exception ex)
              {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.