-
Notifications
You must be signed in to change notification settings - Fork 4
/
SendReminders.ascx.vb
executable file
·231 lines (157 loc) · 10.2 KB
/
SendReminders.ascx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Services.Scheduling
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.UI.Utilities
Imports Ventrian.SubscriptionTools.Entities
Namespace Ventrian.SubscriptionTools
Partial Public Class SendReminders
Inherits ModuleBase
#Region " Private Methods "
Private Sub BindCrumbs()
Dim crumbs As New ArrayList
Dim objCrumbMain As New CrumbInfo
objCrumbMain.Caption = Localization.GetString("Main", LocalResourceFile)
objCrumbMain.Url = NavigateURL()
crumbs.Add(objCrumbMain)
Dim objEditReceipts As New CrumbInfo
objEditReceipts.Caption = Localization.GetString("SendReminders", LocalResourceFile)
objEditReceipts.Url = EditUrl("Reminders")
crumbs.Add(objEditReceipts)
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End Sub
Private Sub BindDefaults()
txtReminderPeriod.Text = Me.ReminderPeriod.ToString()
If Not (drpReminderPeriodMeasurement.Items.FindByValue(Me.ReminderPeriodMeasurement) Is Nothing) Then
drpReminderPeriodMeasurement.SelectedValue = Me.ReminderPeriodMeasurement
End If
txtReminderFrequency.Text = Me.ReminderFrequency.ToString()
If Not (drpReminderFrequencyMeasurement.Items.FindByValue(Me.ReminderFrequencyMeasurement) Is Nothing) Then
drpReminderFrequencyMeasurement.SelectedValue = Me.ReminderFrequencyMeasurement
End If
txtSubject.Text = Me.ReminderSubject
txtTemplate.Text = Me.ReminderTemplate
txtBCCEmail.Text = Me.ReminderBCC
chkEnabled.Checked = Me.ReminderSchedulerEnabled
txtTimeLapse.Text = Me.ReminderSchedulerTimeLapse.ToString()
If Not (drpTimeLapseMeasurement.Items.FindByValue(Me.ReminderSchedulerTimeLapseMeasurement) Is Nothing) Then
drpTimeLapseMeasurement.SelectedValue = Me.ReminderSchedulerTimeLapseMeasurement
End If
txtRetryTimeLapse.Text = Me.ReminderSchedulerRetryFrequency.ToString()
If Not (drpRetryTimeLapseMeasurement.Items.FindByValue(Me.ReminderSchedulerRetryFrequencyMeasurement) Is Nothing) Then
drpRetryTimeLapseMeasurement.SelectedValue = Me.ReminderSchedulerRetryFrequencyMeasurement
End If
End Sub
Private Sub BindHistory()
If (Me.ReminderScheduleID <> Null.NullInteger) Then
Dim arrSchedule As ArrayList = SchedulingProvider.Instance.GetScheduleHistory(Me.ReminderScheduleID)
If (arrSchedule.Count > 0) Then
arrSchedule.Sort(New ScheduleHistorySortStartDate)
'Localize Grid
Services.Localization.Localization.LocalizeDataGrid(dgScheduleHistory, Me.LocalResourceFile)
dgScheduleHistory.DataSource = arrSchedule
dgScheduleHistory.DataBind()
lblNoHistory.Visible = False
dgScheduleHistory.Visible = True
Else
lblNoHistory.Visible = True
dgScheduleHistory.Visible = False
End If
Else
lblNoHistory.Visible = True
dgScheduleHistory.Visible = False
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
BindCrumbs()
If (IsPostBack = False) Then
BindDefaults()
BindHistory()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
Try
If (Page.IsValid) Then
Dim objModuleController As New ModuleController
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_EMAIL, PortalSettings.Email)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_PORTAL_NAME, PortalSettings.PortalName)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_PERIOD, txtReminderPeriod.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_PERIOD_MEASUREMENT, drpReminderPeriodMeasurement.SelectedValue)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_FREQUENCY, txtReminderFrequency.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_FREQUENCY_MEASUREMENT, drpReminderFrequencyMeasurement.SelectedValue)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_SUBJECT, txtSubject.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_TEMPLATE, txtTemplate.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_BCC, txtBCCEmail.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_SCHEDULER_ENABLED, chkEnabled.Checked.ToString())
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_SCHEDULER_TIME_LAPSE, txtTimeLapse.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_SCHEDULER_TIME_LAPSE_MEASUREMENT, drpTimeLapseMeasurement.SelectedValue)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_SCHEDULER_RETRY_FREQUENCY, txtRetryTimeLapse.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_SCHEDULER_RETRY_FREQUENCY_MEASUREMENT, drpRetryTimeLapseMeasurement.SelectedValue)
Dim objScheduleItem As New ScheduleItem
objScheduleItem.TypeFullName = "Ventrian.SubscriptionTools.Entities.ReminderJob, Ventrian.SubscriptionTools"
If txtTimeLapse.Text = "" Or txtTimeLapse.Text = "0" Or txtTimeLapse.Text = "-1" Then
objScheduleItem.TimeLapse = Null.NullInteger
Else
objScheduleItem.TimeLapse = Convert.ToInt32(txtTimeLapse.Text)
End If
objScheduleItem.TimeLapseMeasurement = drpTimeLapseMeasurement.SelectedItem.Value
If txtRetryTimeLapse.Text = "" Or txtRetryTimeLapse.Text = "0" Or txtRetryTimeLapse.Text = "-1" Then
objScheduleItem.RetryTimeLapse = Null.NullInteger
Else
objScheduleItem.RetryTimeLapse = Convert.ToInt32(txtRetryTimeLapse.Text)
End If
objScheduleItem.RetryTimeLapseMeasurement = drpRetryTimeLapseMeasurement.SelectedItem.Value
objScheduleItem.RetainHistoryNum = 10
objScheduleItem.AttachToEvent = ""
objScheduleItem.CatchUpEnabled = False
objScheduleItem.Enabled = chkEnabled.Checked
objScheduleItem.ObjectDependencies = ""
objScheduleItem.Servers = ""
If (Me.ReminderScheduleID <> Null.NullInteger) Then
If (SchedulingProvider.Instance().GetSchedule(Me.ReminderScheduleID) Is Nothing) Then
objScheduleItem.ScheduleID = SchedulingProvider.Instance().AddSchedule(objScheduleItem)
Else
objScheduleItem.ScheduleID = Me.ReminderScheduleID
SchedulingProvider.Instance().UpdateSchedule(objScheduleItem)
End If
Else
objScheduleItem.ScheduleID = SchedulingProvider.Instance().AddSchedule(objScheduleItem)
End If
Data.DataProvider.Instance().AddScheduleItemSetting(objScheduleItem.ScheduleID, "PortalID", Me.PortalSettings.PortalId.ToString())
Data.DataProvider.Instance().AddScheduleItemSetting(objScheduleItem.ScheduleID, "ModuleID", Me.ModuleId.ToString())
Data.DataProvider.Instance().AddScheduleItemSetting(objScheduleItem.ScheduleID, "Period", txtReminderPeriod.Text)
Data.DataProvider.Instance().AddScheduleItemSetting(objScheduleItem.ScheduleID, "PeriodMeasurement", drpReminderPeriodMeasurement.SelectedValue)
Data.DataProvider.Instance().AddScheduleItemSetting(objScheduleItem.ScheduleID, "Frequency", txtReminderFrequency.Text)
Data.DataProvider.Instance().AddScheduleItemSetting(objScheduleItem.ScheduleID, "FrequencyMeasurement", drpReminderFrequencyMeasurement.SelectedValue)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.REMINDER_SCHEDULER_ID, objScheduleItem.ScheduleID.ToString())
Response.Redirect(NavigateURL(), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
Try
Response.Redirect(NavigateURL(), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace