Mandanten via Application Interface starten / stoppen
Folgendes Dokument enthält ein Beispiel-Programm, welches es mittels Java Application Interface ermöglicht, einen beliebigen Mandanten zu starten oder zu stoppen.
Sie können den Java Code übernehmen oder beliebig anpassen.
Das Beispielprogramm ist mit folgenden Kommandozeilenparametern aufzurufen:
java aeClientGoStop <go/stop> <cp> <port> <client> <user> <dep> <pwd>
- <go/stop>
Mögliche Werte: go oder stop.
go - Startet den Mandanten und stop - Stoppt den Mandanten - <cp> = IP-Adresse oder Name des CP-Rechners
- <port> = Portnummer des CPs
- <client> = Vierstellige Mandantennummer
- <user> = Name des AE-Benutzers
- <pwd> = Benutzer-Passwort
Um das Programm erfolgreich aufrufen zu können, ist das Java Application Interface (uc4.jar) erforderlich.
import java.io.IOException;
import com.uc4.communication.Connection;
import com.uc4.communication.requests.CreateSession;
import com.uc4.communication.requests.ResumeClient;
import com.uc4.communication.requests.SuspendClient;
import com.uc4.communication.requests.XMLRequest;
public class aeClientGoStop {
public static void main(String[] args) throws IOException {
new aeClientGoStop().gostop(args);
}
private void gostop(String[] args) throws IOException {
int count = args.length;
if(count < 6){
System.err.println("not enough arguments: min = 6 -> found only: " + count);
System.exit(1);
}
//System.err.println("arguments passed on: " + count);
String action = null;
String cp = null;
String port = null;
String client = null;
String user = null;
String dep = null;
String pwd = null;
if(count < 7){
action = args[0];
cp = args[1];
port = args[2];
client = args[3];
user = args[4];
dep = args[5];
pwd = "";
}else if(count == 7){
action = args[0];
cp = args[1];
port = args[2];
client = args[3];
user = args[4];
dep = args[5];
pwd = args[6];
}
//Erstellt eine Verbindung zur Automation Engine
Connection uc4 = Connection.open(cp, Integer.parseInt(port));
//Login
CreateSession login = uc4.login(Integer.parseInt(client),user,dep,pwd,'E');
//Test, ob das Login erfolgreich war
if (!login.isLoginSuccessful()) {
System.err.println(login.getMessageBox().getText());
uc4.close();
System.exit(1);
}
XMLRequest rqr = null ;
if (action.equals("go")){
rqr = new ResumeClient();
} else if (action.equals("stop")){
rqr = new SuspendClient();
}
uc4.sendRequestAndWait(rqr);
if (rqr.getMessageBox() != null) {
System.err.println(rqr.getMessageBox().getText());
uc4.close();
System.exit(3);
}
uc4.close();
System.out.println("Aktion erledigt: " + action + " Mandant: " + client);
}
};