Skip to content

Commit

Permalink
Progress Info im ZipMailer (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannMaierhofer authored Jun 5, 2024
1 parent 9d436b0 commit c6f6d04
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/de/jost_net/JVerein/io/ZipMailer.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ public void run(ProgressMonitor monitor) throws ApplicationException
Logger.debug("preparing velocity context");
monitor.setStatus(ProgressMonitor.STATUS_RUNNING);
monitor.setPercentComplete(0);
// int sentCount = 0;
int sentCount = 0;

ZipFile zip = new ZipFile(zipfile);
int zae = 0;
int size = zip.size();
for (@SuppressWarnings("rawtypes")
Enumeration e = zip.entries(); e.hasMoreElements();)
{
Expand Down Expand Up @@ -132,15 +134,26 @@ public void run(ProgressMonitor monitor) throws ApplicationException
{
sender.sendMail(mail, wtext1.getBuffer().toString(),
wtext2.getBuffer().toString(), anhang);
sentCount++;
}
catch (SendFailedException e1)
{
monitor.log("Versand fehlgeschlagen: " + mail);
Logger.error("Fehler beim Mailversand: " + e1);
}
} // Ende von if
zae++;
double proz = (double) zae / (double) size * 100d;
monitor.setPercentComplete((int) proz);
} // Ende von for
zip.close();
monitor.setPercentComplete(100);
monitor.setStatus(ProgressMonitor.STATUS_DONE);
monitor.setStatusText(
String.format("Anzahl verschickter Mails: %d", sentCount));
GUI.getStatusBar().setSuccessText(
"Mail" + (sentCount > 1 ? "s" : "") + " verschickt");
GUI.getCurrentView().reload();
}
catch (ZipException e)
{
Expand Down

0 comments on commit c6f6d04

Please sign in to comment.