Skip to content

Commit c10befc

Browse files
authored
Merge pull request #537 from msalemcode/msalem/scheduler_logging-notification
Adding scheduler notification
2 parents f3fcf7c + 6821220 commit c10befc

File tree

6 files changed

+394
-95
lines changed

6 files changed

+394
-95
lines changed

src/DataAccess/Migrations/Custom/BaselineV7_Seed.cs

+76-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,46 @@ public static void BaselineV7_SeedData(this MigrationBuilder migrationBuilder)
1414
{
1515
var seedDate = DateTime.Now;
1616
migrationBuilder.Sql(@$"
17-
IF NOT EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'WebNotificationUrl')
18-
BEGIN
19-
INSERT [dbo].[ApplicationConfiguration] ( [Name], [Value], [Description]) VALUES ( N'WebNotificationUrl', N'', N'Setting this URL will enable pushing LandingPage/Webhook events to this external URL')
20-
END
17+
IF NOT EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'WebNotificationUrl')
18+
BEGIN
19+
INSERT [dbo].[ApplicationConfiguration] ( [Name], [Value], [Description]) VALUES ( N'WebNotificationUrl', N'', N'Setting this URL will enable pushing LandingPage/Webhook events to this external URL')
20+
END
21+
22+
IF NOT EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesSuccessfulSchedulerEmail')
23+
BEGIN
24+
INSERT [dbo].[ApplicationConfiguration] ( [Name], [Value], [Description]) VALUES ( N'EnablesSuccessfulSchedulerEmail', N'False', N'This will enable sending email for successful metered usage.')
25+
END
26+
27+
IF NOT EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesFailureSchedulerEmail')
28+
BEGIN
29+
INSERT [dbo].[ApplicationConfiguration] ( [Name], [Value], [Description]) VALUES ( N'EnablesFailureSchedulerEmail', N'False', N'This will enable sending email for failure metered usage.')
30+
END
31+
32+
IF NOT EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesMissingSchedulerEmail')
33+
BEGIN
34+
INSERT [dbo].[ApplicationConfiguration] ( [Name], [Value], [Description]) VALUES ( N'EnablesMissingSchedulerEmail', N'False', N'This will enable sending email for missing metered usage.')
35+
END
36+
37+
IF NOT EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'SchedulerEmailTo')
38+
BEGIN
39+
INSERT [dbo].[ApplicationConfiguration] ( [Name], [Value], [Description]) VALUES ( N'SchedulerEmailTo', N'', N'Scheduler email receiver(s) ')
40+
END
41+
42+
IF NOT EXISTS (SELECT * FROM [dbo].[EmailTemplate] WHERE [Status] = 'Accepted')
43+
BEGIN
44+
INSERT [dbo].[EmailTemplate] ([Status],[Description],[InsertDate],[TemplateBody],[Subject],[isActive]) VALUES (N'Accepted',N'Accepted',GetDate(),N'<html> <head> <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8""/> </head> <body leftmargin=""0"" marginwidth=""0"" topmargin=""0"" marginheight=""0"" offset=""0""> <center> <table align=""center"" border=""0"" cellpadding=""0"" cellspacing=""0"" height=""100%"" width=""100%"" id=""bodyTable""> <tr><td align=""center"" valign=""top"" id=""bodyCell""><!-- BEGIN TEMPLATE // --><table border=""0"" cellpadding=""0"" cellspacing=""0"" id=""templateContainer""><tr><td align=""center"" valign=""top""><!-- BEGIN BODY // --><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" id=""templateBody""><tr><td valign=""top"" class=""bodyContent""><h2>Subscription ****SubscriptionName****</h2><br><p>The Scheduled Task ****SchedulerTaskName**** was fired <b>Successfully</b></p><p>The following section is the deatil results.</p><hr/><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" id=""templateBody"">****ResponseJson**** </table></td></tr></table></td></tr></table><!-- // END BODY --></td></tr> </table> <!-- // END TEMPLATE --> </center> </body> </html>',N'Scheduled SaaS Metered Usage Submitted Successfully!',N'True')
45+
END
46+
47+
IF NOT EXISTS (SELECT * FROM [dbo].[EmailTemplate] WHERE [Status] = 'Failure')
48+
BEGIN
49+
INSERT [dbo].[EmailTemplate] ([Status],[Description],[InsertDate],[TemplateBody],[Subject],[isActive]) VALUES (N'Failure',N'Failure',GetDate(),N'<html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8""/></head><body leftmargin=""0"" marginwidth=""0"" topmargin=""0"" marginheight=""0"" offset=""0""><center><table align=""center"" border=""0"" cellpadding=""0"" cellspacing=""0"" height=""100%"" width=""100%"" id=""bodyTable""><tr><td align=""center"" valign=""top"" id=""bodyCell""><!-- BEGIN TEMPLATE // --><table border=""0"" cellpadding=""0"" cellspacing=""0"" id=""templateContainer""> <tr><td align=""center"" valign=""top""><!-- BEGIN BODY // --> <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" id=""templateBody""><tr> <td valign=""top"" class=""bodyContent""><h2 >Subscription ****SubscriptionName****</h2><br><p>The Scheduled Task ****SchedulerTaskName**** was fired<b> but Failed to Submit Data</b></p><br>Please try again or contact technical support to troubleshoot the issue.<p>The following section is the deatil results.</p><hr/><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" id=""templateBody"">****ResponseJson****</table></td></tr></table></td> </tr></table><!-- // END BODY --></td></tr></table><!-- // END TEMPLATE --></center></body> </html>',N'Scheduled SaaS Metered Usage Failure!',N'True')
50+
END
51+
52+
IF NOT EXISTS (SELECT * FROM [dbo].[EmailTemplate] WHERE [Status] = 'Missing')
53+
BEGIN
54+
INSERT [dbo].[EmailTemplate] ([Status],[Description],[InsertDate],[TemplateBody],[Subject],[isActive]) VALUES (N'Missing',N'Missing',GetDate(),N'<html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8""/></head><body leftmargin=""0"" marginwidth=""0"" topmargin=""0"" marginheight=""0"" offset=""0""><center><table align=""center"" border=""0"" cellpadding=""0"" cellspacing=""0"" height=""100%"" width=""100%"" id=""bodyTable""><tr><td align=""center"" valign=""top"" id=""bodyCell""><!-- BEGIN TEMPLATE // --><table border=""0"" cellpadding=""0"" cellspacing=""0"" id=""templateContainer""> <tr><td align=""center"" valign=""top""><!-- BEGIN BODY // --> <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" id=""templateBody""><tr> <td valign=""top"" class=""bodyContent""><h2 >Subscription ****SubscriptionName****</h2><br><p>The Scheduled Task ****SchedulerTaskName**** was skipped by scheduler engine!</b></p><br>Please try again or contact technical support to troubleshoot the issue.<p>The following section is the deatil results.</p><hr/><table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%"" id=""templateBody"">****ResponseJson****</table></td></tr></table></td> </tr></table><!-- // END BODY --></td></tr></table><!-- // END TEMPLATE --></center></body> </html>',N'Scheduled SaaS Metered Task was Skipped!',N'True')
55+
END
56+
2157
GO");
2258
}
2359

@@ -28,6 +64,42 @@ IF EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'WebNot
2864
BEGIN
2965
DELETE FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'WebNotificationUrl'
3066
END
67+
68+
IF EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesSuccessfulSchedulerEmail')
69+
BEGIN
70+
DELETE FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesSuccessfulSchedulerEmail'
71+
END
72+
73+
IF EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesFailureSchedulerEmail')
74+
BEGIN
75+
DELETE FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesFailureSchedulerEmail'
76+
END
77+
78+
IF EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesMissingSchedulerEmail')
79+
BEGIN
80+
DELETE FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'EnablesMissingSchedulerEmail'
81+
END
82+
83+
IF EXISTS (SELECT * FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'SchedulerEmailTo')
84+
BEGIN
85+
DELETE FROM [dbo].[ApplicationConfiguration] WHERE [Name] = 'SchedulerEmailTo'
86+
END
87+
88+
IF EXISTS (SELECT * FROM [dbo].[EmailTemplate] WHERE [Status] = 'Accepted')
89+
BEGIN
90+
DELETE FROM [dbo].[EmailTemplate] WHERE [Status] = 'Accepted'
91+
END
92+
93+
IF EXISTS (SELECT * FROM [dbo].[EmailTemplate] WHERE [Status] = 'Failure')
94+
BEGIN
95+
DELETE FROM [dbo].[EmailTemplate] WHERE [Status] = 'Failure'
96+
END
97+
98+
IF EXISTS (SELECT * FROM [dbo].[EmailTemplate] WHERE [Status] = 'Missing')
99+
BEGIN
100+
DELETE FROM [dbo].[EmailTemplate] WHERE [Status] = 'Missing'
101+
END
102+
31103
GO");
32104
}
33105
}

0 commit comments

Comments
 (0)