Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

MethodeBeispiel
getSystemParameter
Codeblock
package org.nuclet.businessentity; 
 
import org.nuclos.api.common.NuclosFileannotation.Rule;
import org.nuclos.api.context.UpdateContext;
import org.nuclos.api.mailexception.NuclosMailBusinessException;
import org.nuclos.api.provider.PrintoutProviderParameterProvider;
import org.nuclos.api.provider.MailProvider;
.rule.UpdateRule;
import org.nuclos.parameter.NuclosSystemParameter;
 
/** @name       
  * @description
  * @usage      
  * @change     
*/
@Rule(name="SendConfirmationEmail", description="SendConfirmationEmail")
public class AbschlussAuftragRegelSendConfirmationEmail implements InsertFinalRuleUpdateRule {

    public void insertFinalupdate(InsertContextUpdateContext context) throws BusinessException {
     
        
		Auftrag a = context.getBusinessObject(Auftrag.class);
  
    	
		NuclosFile result = PrintoutProvider.run(FormularAbschlussAuftragPO.Deutsch_PDF, if(a.getIdisApproved());
 {
            
		NuclosMail newMailString useEmail = new NuclosMail(ParameterProvider.getSystemParameter(NuclosSystemParameter.ConfirmationEmailIsActive);
          
		newMail.setSubject("Abschluss eines Auftrags");
 // First check, if the value of if this parameter is not null
           if (useEmail != null) {
                if newMail(usrEmail.setFromequals("automatic@meineFirma.deY")); {
          newMail.addRecipient("Max.Mustermann@meinKunde.de");          // Following method creates a NuclosEmail and sends it to the user mentioned in "Auftrag" a.
        newMail.setMessage("Der Auftrag wurde erfolgreich abgeschlossen.");
            // For lack of space this method is not implemented in this example. Suppose it does exist.
                  newMail.addAttachment(result  sendConfirmationEmail(a);
                }
           }       
   MailProvider.send(newMail);    }
    }
}

Erläuterung:

Mit dem erfolgreichen Abschluss eines Auftrags soll automatisch eine Bestätigungsmail an den Kunden verschickt werden. Das vom PrintoutProvider erzeugte Formular wird dabei als NuclosFile an die Email gehängt.

Anzumerken ist, dass durchaus mehrere NuclosFiles hinzugefügt werden können. Auch die Angabe von BCC- und CC-Empfängern ist möglich.

Im Falle eines Laufzeit-Fehlers wird eine BusinessException geworfen.

 Für einen abgeschlossenen Auftrag soll eine Bestätigungsemail versandt werden. In den Systemparametern wurde nun ein Parameter namens "ConfirmationEmailIsActive" hinterlegt, der festlegt, ob das System (unabhängig von Aufträgen) im aktuellen Zustand überhaupt den Versandt ermöglicht oder nicht. Findet die Regel den Wert "Y" (steht für Yes), dann kann die Email verschickt werden.

Systemparameter zur Konfiguration des Emailservers siehe Systemparameter