Commit 0c5f4d1a authored by Marcel's avatar Marcel

#2 kill Songbeamer and start with downloaded agenda

parent 7e75adbc
Pipeline #28387632 passed with stage
in 1 minute and 37 seconds
......@@ -4,5 +4,6 @@ churchtools:
user-token: ''
songbeamer:
install-path: 'C:\Program Files (x86)\SongBeamer'
agenda-base-folder: 'C:\SongBeamer\Agenda'
songs-base-folder: 'C:\SongBeamer\Songs'
......@@ -9,6 +9,7 @@ churchtools:
user-token: 'in ChurchDB generierte Token hier eintragen'
songbeamer:
install-path: 'C:\Program Files (x86)\SongBeamer'
agenda-base-folder: 'C:\Users\Benutzername\Documents\SongBeamer'
songs-base-folder: 'C:\Users\Benutzername\Documents\SongBeamer\Songs'
......@@ -31,6 +32,10 @@ Um einen Token zu erstellen, in ChurchDB den Benutzer wählen.
Dort auf `Berechtigungen` klicken.
Im Popup auf `Login-Token` klicken und den Login-Token kopieren.
### Install Path
Der Pfad unter dem der SongBeamer installiert ist.
### Agenda Base Folder
Hier werden die ausgewählten Abläufe abgespeichert.
......
......@@ -5,7 +5,7 @@
<groupId>de.apis-stuttgart</groupId>
<artifactId>churchtools-to-songbeamer</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
<packaging>jar</packaging>
<name>churchtools-to-songbeamer</name>
......
......@@ -40,11 +40,11 @@ public class ChurchtoolsToSongbeamerApplication {
// Check config
if (churchtoolsConfig.getUrlBase().isEmpty()) {
showMessage("Bitte Churchtools Instanz richtig konfigurieren");
showMessage("Bitte Churchtools Instanz richtig konfigurieren.");
} else if (churchtoolsConfig.getUserId().isEmpty()) {
showMessage("Bitte die User ID richtig konfigurieren");
showMessage("Bitte die User ID richtig konfigurieren.");
} else if (churchtoolsConfig.getUserToken().isEmpty()) {
showMessage("Bitte die User Token richtig konfigurieren");
showMessage("Bitte die User Token richtig konfigurieren.");
// Config seems correct
} else {
......@@ -63,12 +63,12 @@ public class ChurchtoolsToSongbeamerApplication {
JFrame jFrame = new JFrame("Churchtools to Songbeamer");
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPanel = jFrame.getContentPane();
JLabel jLabelLoading = new JLabel("Bitte warten, die Daten werden geladen.");
contentPanel.add(jLabelLoading);
contentPanel.setLayout(new BorderLayout());
jFrame.setSize(400, 400);
jFrame.setVisible(true);
showMessage("Bitte warten, die Daten werden geladen.");
}
......@@ -77,14 +77,14 @@ public class ChurchtoolsToSongbeamerApplication {
JLabel jLabel = new JLabel(message);
contentPanel.add(jLabel);
contentPanel.add(jLabel, BorderLayout.NORTH);
contentPanel.revalidate();
contentPanel.repaint();
}
protected static void showEventList(CtEvent[] ctEvents, AgendaConverterService agendaConverterService) {
contentPanel.removeAll();
showMessage("Agenda auswählen um diese im SongBeamer zu öffnen.");
JList list = new JList(ctEvents);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
......
......@@ -21,7 +21,7 @@ public class ChurchtoolsConfig {
public String getUrlBase() {
if (instance == null || instance.isEmpty()) {
log.error("Please set the churchtools instance");
return "http://localhost";
return "";
}
return "https://" + instance + ".church.tools/index.php";
......
......@@ -15,6 +15,9 @@ public class SongbeamerConfig {
protected String agendaExtension;
protected String songsExtension;
protected String installPath;
protected String executableName;
protected String agendaBaseFolder;
protected String songsBaseFolder;
protected String songsSubFolder;
......
......@@ -27,6 +27,9 @@ public class AgendaConverterService {
@Autowired
protected SongbeamerConfig songbeamerConfig;
@Autowired
protected SbControllerService sbControllerService;
protected static String LINE_SEPARATOR = System.getProperty("line.separator");
......@@ -68,6 +71,10 @@ public class AgendaConverterService {
Files.write(sbAgendaFile, sbAgenda.toString().getBytes(StandardCharsets.ISO_8859_1));
log.info("Songbeamer agenda was written to " + sbAgendaFile.toAbsolutePath().toString());
sbControllerService.stopSongBeamer();
sbControllerService.startSongBeamer(sbAgendaFile.toAbsolutePath().toString());
} catch (IOException e) {
log.error("Unable to write songbeamer agenda to " + sbAgendaFile.toAbsolutePath().toString(), e);
}
......
package de.apisstuttgart.churchtoolstosongbeamer.service;
import de.apisstuttgart.churchtoolstosongbeamer.config.SongbeamerConfig;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
@Service
@CommonsLog
public class SbControllerService {
protected static String FILE_SEPARATOR = System.getProperty("file.separator");
@Autowired
protected SongbeamerConfig songbeamerConfig;
public void startSongBeamer(String agendaPath) {
String executablePath = appendPathSeparator(songbeamerConfig.getInstallPath()) + songbeamerConfig.getExecutableName();
runCommand("\"" + executablePath + "\" \"" + agendaPath + "\"");
}
public void stopSongBeamer() {
runCommand("taskkill /t /IM SongBeamer.exe");
}
private void runCommand(String command) {
try {
Runtime.getRuntime().exec(command);
Thread.sleep(1000);
} catch (IOException | InterruptedException e) {
log.error("Could not run command: " + command);
}
}
private String appendPathSeparator(String string) {
return string + (string != null && !string.endsWith(FILE_SEPARATOR) ? FILE_SEPARATOR : "");
}
}
......@@ -6,6 +6,9 @@ churchtools:
songbeamer:
agenda-extension: '.col'
songs-extension: '.sng'
executable-name: 'SongBeamer.exe'
install-path: 'C:\Program Files (x86)\SongBeamer'
agenda-base-folder: 'C:\SongBeamer\Agenda'
songs-base-folder: 'C:\SongBeamer\Songs'
songs-sub-folder: 'churchtools-to-songbeamer'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment