Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
aae35948
Commit
aae35948
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Always include host alias in mail subjects.
parent
431f4117
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxService/Email.cs
+8
-11
8 additions, 11 deletions
ATxService/Email.cs
with
8 additions
and
11 deletions
ATxService/Email.cs
+
8
−
11
View file @
aae35948
...
...
@@ -17,7 +17,7 @@ namespace ATxService
/// <param name="subject">The subject, might be prefixed with a configurable string.</param>
/// <param name="body">The email body.</param>
private
void
SendEmail
(
string
recipient
,
string
subject
,
string
body
)
{
subject
=
_config
.
EmailPrefix
+
subject
;
subject
=
$"
{
_config
.
EmailPrefix
}{
ServiceName
}
-
{
subject
}
-
{
_config
.
HostAlias
}
"
;
body
+=
$"\n\n--\n[
{
_versionSummary
}
]\n"
;
if
(
string
.
IsNullOrEmpty
(
_config
.
SmtpHost
))
{
Log
.
Debug
(
"SendEmail: {0}\n{1}"
,
subject
,
body
);
...
...
@@ -89,9 +89,9 @@ namespace ATxService
return
;
}
if
(
s
ubject
==
""
)
{
subject
=
$"
{
ServiceName
}
-
{
Environment
.
MachineName
}
-
Admin Notification"
;
}
if
(
s
tring
.
IsNullOrWhiteSpace
(
subject
))
subject
=
"
Admin Notification"
;
body
=
$"Notification from:
{
_config
.
HostAlias
}
(
{
Environment
.
MachineName
}
)\n\n
{
body
}
"
;
Log
.
Debug
(
"Sending an admin notification email."
);
SendEmail
(
_config
.
AdminEmailAdress
,
subject
,
body
);
...
...
@@ -127,8 +127,7 @@ namespace ATxService
};
try
{
var
body
=
LoadMailTemplate
(
"DiskSpace-Low.txt"
,
substitutions
);
var
subject
=
$"Low Disk Space On
{
_config
.
HostAlias
}
"
;
SendEmail
(
_config
.
AdminEmailAdress
,
subject
,
body
);
SendEmail
(
_config
.
AdminEmailAdress
,
"low disk space"
,
body
);
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"Error loading email template: {0}"
,
ex
.
Message
);
...
...
@@ -162,7 +161,7 @@ namespace ATxService
try
{
var
body
=
LoadMailTemplate
(
"Transfer-Success.txt"
,
substitutions
);
SendEmail
(
userDir
,
$"
{
ServiceName
}
-
Transfer Notification"
,
body
);
SendEmail
(
userDir
,
"
Transfer Notification"
,
body
);
Log
.
Debug
(
"Sent transfer completed notification to {0}"
,
userDir
);
}
catch
(
Exception
ex
)
{
...
...
@@ -189,9 +188,7 @@ namespace ATxService
try
{
var
body
=
LoadMailTemplate
(
"Transfer-Interrupted.txt"
,
substitutions
);
SendEmail
(
userDir
,
$"
{
ServiceName
}
- Transfer Interrupted -
{
_config
.
HostAlias
}
"
,
body
);
SendEmail
(
userDir
,
"INTERRUPTED Transfer"
,
body
);
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"Error loading email template: {0}"
,
ex
.
Message
);
...
...
@@ -218,7 +215,7 @@ namespace ATxService
return
report
;
_status
.
LastGraceNotification
=
DateTime
.
Now
;
SendAdminEmail
(
report
,
$"
{
_config
.
HostAlias
}
: grace location cleanup required.
"
);
SendAdminEmail
(
report
,
"grace location summary
"
);
return
report
+
"\nNotification sent to AdminEmailAdress.\n"
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment