forked from ventrian/News-Articles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucImportFeeds.ascx.vb
executable file
·264 lines (182 loc) · 9.8 KB
/
ucImportFeeds.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Services.Scheduling
Imports DotNetNuke.UI.UserControls
Imports Ventrian.NewsArticles.Import
Imports DotNetNuke.Entities.Modules
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class ucImportFeeds
Inherits NewsArticleModuleBase
#Region " Private Methods "
Private Sub BindFeeds()
Dim objFeedController As New FeedController
Localization.LocalizeDataGrid(grdFeeds, Me.LocalResourceFile)
grdFeeds.DataSource = objFeedController.GetFeedList(ModuleId, False)
grdFeeds.DataBind()
If (grdFeeds.Items.Count > 0) Then
grdFeeds.Visible = True
lblNoFeeds.Visible = False
Else
grdFeeds.Visible = False
lblNoFeeds.Visible = True
lblNoFeeds.Text = Localization.GetString("NoFeedsMessage.Text", LocalResourceFile)
End If
End Sub
Private Sub BindHistory()
Dim typeName As String = "Ventrian.NewsArticles.Import.RssImportJob, Ventrian.NewsArticles"
Dim objSchedule As ScheduleItem = SchedulingProvider.Instance().GetSchedule(typeName, Null.NullString)
If (objSchedule IsNot Nothing) Then
Dim arrSchedule As ArrayList = SchedulingProvider.Instance.GetScheduleHistory(objSchedule.ScheduleID)
If (arrSchedule.Count > 0) Then
arrSchedule.Sort(New ScheduleHistorySortStartDate)
'Localize Grid
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
Private Sub BindSchedulerSettings()
Dim typeName As String = "Ventrian.NewsArticles.Import.RssImportJob, Ventrian.NewsArticles"
Dim objSchedule As ScheduleItem = SchedulingProvider.Instance().GetSchedule(typeName, Null.NullString)
If (objSchedule IsNot Nothing) Then
chkEnabled.Checked = objSchedule.Enabled
txtTimeLapse.Text = objSchedule.TimeLapse.ToString()
If (drpTimeLapseMeasurement.Items.FindByValue(objSchedule.TimeLapseMeasurement) IsNot Nothing) Then
drpTimeLapseMeasurement.SelectedValue = objSchedule.TimeLapseMeasurement
Else
drpTimeLapseMeasurement.SelectedValue = "m"
End If
txtRetryTimeLapse.Text = objSchedule.RetryTimeLapse.ToString()
If (drpRetryTimeLapseMeasurement.Items.FindByValue(objSchedule.RetryTimeLapseMeasurement) IsNot Nothing) Then
drpRetryTimeLapseMeasurement.SelectedValue = objSchedule.RetryTimeLapseMeasurement
Else
drpRetryTimeLapseMeasurement.SelectedValue = "m"
End If
Else
txtTimeLapse.Text = "30"
drpTimeLapseMeasurement.SelectedValue = "m"
txtRetryTimeLapse.Text = "60"
drpRetryTimeLapseMeasurement.SelectedValue = "m"
End If
Dim objModuleController As New ModuleController
If (Settings.Contains("NewsArticles-Import-Clear-" & Me.ModuleId)) Then
chkDeleteArticles.Checked = Convert.ToBoolean(Settings("NewsArticles-Import-Clear-" & Me.ModuleId).ToString())
Else
chkDeleteArticles.Checked = 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
phScheduler.Visible = Me.UserInfo.IsSuperUser
If (IsPostBack = False) Then
BindFeeds()
If (phScheduler.Visible) Then
BindSchedulerSettings()
BindHistory()
Else
Dim typeName As String = "Ventrian.NewsArticles.Import.RssImportJob, Ventrian.NewsArticles"
Dim objSchedule As ScheduleItem = SchedulingProvider.Instance().GetSchedule(typeName, Null.NullString)
If (objSchedule IsNot Nothing) Then
If (objSchedule.Enabled) Then
lblScheduler.Visible = False
Else
lblScheduler.Text = Localization.GetString("SchedulerNotEnabled", Me.LocalResourceFile)
lblScheduler.Visible = True
End If
Else
lblScheduler.Text = Localization.GetString("SchedulerNotEnabled", Me.LocalResourceFile)
lblScheduler.Visible = True
End If
End If
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub cmdAddFeed_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdAddFeed.Click
Try
Response.Redirect(EditUrl("ImportFeed"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdate.Click
Try
Dim typeName As String = "Ventrian.NewsArticles.Import.RssImportJob, Ventrian.NewsArticles"
Dim objSchedule As ScheduleItem = SchedulingProvider.Instance().GetSchedule(typeName, Null.NullString)
If (objSchedule IsNot Nothing) Then
objSchedule.Enabled = chkEnabled.Checked
If (IsNumeric(txtTimeLapse.Text)) Then
objSchedule.TimeLapse = Convert.ToInt32(txtTimeLapse.Text)
Else
objSchedule.TimeLapse = 30
End If
objSchedule.TimeLapseMeasurement = drpTimeLapseMeasurement.SelectedValue
If (IsNumeric(txtTimeLapse.Text)) Then
objSchedule.RetryTimeLapse = Convert.ToInt32(txtRetryTimeLapse.Text)
Else
objSchedule.RetryTimeLapse = 60
End If
objSchedule.RetryTimeLapseMeasurement = drpRetryTimeLapseMeasurement.SelectedValue
SchedulingProvider.Instance().UpdateSchedule(objSchedule)
Else
objSchedule = New ScheduleItem()
objSchedule.TypeFullName = typeName
objSchedule.Enabled = chkEnabled.Checked
If (IsNumeric(txtTimeLapse.Text)) Then
objSchedule.TimeLapse = Convert.ToInt32(txtTimeLapse.Text)
Else
objSchedule.TimeLapse = 30
End If
objSchedule.TimeLapseMeasurement = drpTimeLapseMeasurement.SelectedValue
If (IsNumeric(txtTimeLapse.Text)) Then
objSchedule.RetryTimeLapse = Convert.ToInt32(txtRetryTimeLapse.Text)
Else
objSchedule.RetryTimeLapse = 60
End If
objSchedule.RetryTimeLapseMeasurement = drpRetryTimeLapseMeasurement.SelectedValue
objSchedule.RetainHistoryNum = 10
objSchedule.AttachToEvent = ""
objSchedule.CatchUpEnabled = False
objSchedule.Enabled = chkEnabled.Checked
objSchedule.ObjectDependencies = ""
objSchedule.Servers = ""
objSchedule.ScheduleID = SchedulingProvider.Instance().AddSchedule(objSchedule)
End If
Dim objModuleController As New ModuleController
objModuleController.UpdateModuleSetting(Me.ModuleId, "NewsArticles-Import-Clear-" & Me.ModuleId, chkDeleteArticles.Checked.ToString())
SchedulingProvider.Instance().AddScheduleItemSetting(objSchedule.ScheduleID, "NewsArticles-Import-Clear-" & Me.ModuleId, chkDeleteArticles.Checked.ToString())
Response.Redirect(EditUrl("AdminOptions"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click
Try
Response.Redirect(EditUrl("AdminOptions"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace