Skip to content
Snippets Groups Projects
Commit a7dac81c authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Add SendTransferInterruptedMail.

Fixes #8
parent 59cc0407
No related branches found
No related tags found
No related merge requests found
......@@ -342,7 +342,7 @@ namespace AutoTx
writeLog("Not all files were transferred - will resume upon next start");
writeLogDebug("CurrentTransferSrc: " + _status.CurrentTransferSrc);
// should we delete an incompletely transferred file on the target?
// TODO: send a notification to the user of the interrupted transfer (#38)
SendTransferInterruptedMail();
}
// set the shutdown status to clean:
_status.CleanShutdown = true;
......
......@@ -153,5 +153,33 @@ namespace AutoTx
writeLog("Error loading email template: " + ex.Message, true);
}
}
/// <summary>
/// Send a notification email when a transfer has been interrupted before completion.
/// Recipient address is derived from the global variable CurrentTransferSrc.
/// </summary>
public void SendTransferInterruptedMail() {
if (_config.SendTransferNotification == false)
return;
var userDir = new DirectoryInfo(_status.CurrentTransferSrc).Name;
var substitutions = new List<Tuple<string, string>> {
Tuple.Create("FACILITY_USER", GetFullUserName(userDir)),
Tuple.Create("HOST_ALIAS", _config.HostAlias),
Tuple.Create("HOST_NAME", Environment.MachineName),
Tuple.Create("EMAIL_FROM", _config.EmailFrom)
};
try {
var body = LoadMailTemplate("Transfer-Interrupted.txt", substitutions);
SendEmail(GetEmailAddress(userDir),
ServiceName + " - Transfer Interrupted - " + _config.HostAlias,
body);
}
catch (Exception ex) {
writeLog("Error loading email template: " + ex.Message, true);
}
}
}
}
\ No newline at end of file
Dear FACILITY_USER,
unfortunately the transfer service on "HOST_ALIAS" (HOST_NAME)
has been stopped while one of your transfers was still running, probably
due the computer being shut down.
Your transfer will resume without any additional action required once the
service is started again, which happens automatically when the computer has
finished booting up again.
Don't hesitate to contact EMAIL_FROM if you have any additional question.
Have a nice day
The Facility Team
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment