-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathViewContactLog.ascx.vb
executable file
·254 lines (192 loc) · 9.51 KB
/
ViewContactLog.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
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Namespace Ventrian.PropertyAgent
Partial Public Class ViewContactLog
Inherits PropertyAgentBase
Private _fieldID As Integer = Null.NullInteger
Private _showCustomField As Boolean = False
#Region " Private Methods "
Private Sub BindContactLog()
Dim objContactLogController As New ContactLogController()
Dim log As List(Of ContactLogInfo) = objContactLogController.List(ModuleId, Convert.ToDateTime(txtStartDate.Text), Convert.ToDateTime(txtEndDate.Text).AddDays(1).AddMinutes(-1))
Dim dt As New DataTable
dt.Columns.Add("DateSent")
dt.Columns.Add("Subject")
dt.Columns.Add("Body")
If (PropertySettings.ContactCustomField <> Null.NullInteger) Then
Dim objCustomFieldController As New CustomFieldController()
Dim objCustomField As CustomFieldInfo = objCustomFieldController.Get(PropertySettings.ContactCustomField)
If (objCustomField IsNot Nothing) Then
dt.Columns.Add(objCustomField.Name)
_showCustomField = True
End If
End If
Dim objContactFieldController As New ContactFieldController()
Dim fields As List(Of ContactFieldInfo) = objContactFieldController.List(Me.ModuleId)
Dim fieldShow As String = ""
For Each field As ContactFieldInfo In fields
If (field.ContactFieldID = PropertySettings.ContactLogField) Then
fieldShow = field.Caption
End If
dt.Columns.Add(field.Caption)
Next
For Each objLog As ContactLogInfo In log
Dim dr As DataRow = dt.NewRow()
dr(0) = objLog.DateSent
dr(1) = objLog.Subject
dr(2) = objLog.Body
Dim counter As Integer = 3
If (PropertySettings.ContactCustomField <> Null.NullInteger) Then
If (objLog.PropertyID <> Null.NullInteger) Then
Dim objPropertyController As New PropertyController
Dim objProperty As PropertyInfo = objPropertyController.Get(objLog.PropertyID)
If (objProperty IsNot Nothing) Then
If (objProperty.PropertyList.Contains(PropertySettings.ContactCustomField)) Then
dr(counter) = objProperty.PropertyList(PropertySettings.ContactCustomField).ToString()
Else
dr(counter) = ""
End If
counter = counter + 1
End If
Else
dr(counter) = ""
counter = counter + 1
End If
End If
For Each field As ContactFieldInfo In fields
If (objLog.FieldValues <> "") Then
For Each entry As String In objLog.FieldValues.Split("|||")
If (entry <> "") Then
Dim arr() As String = entry.Split(":::")
Dim caption As String = arr(0)
Dim value As String = arr(3)
If (caption.ToLower() = field.Caption.ToLower()) Then
dr(counter) = value
If (caption.ToLower() = fieldShow.ToLower()) Then
_fieldID = counter
End If
End If
End If
Next
End If
counter = counter + 1
Next
dt.Rows.Add(dr)
Next
grdContactLog.DataSource = dt
grdContactLog.DataBind()
If (grdContactLog.Items.Count = 0) Then
grdContactLog.Visible = False
lblNoContactLogs.Visible = True
cmdExport.visible = False
Else
grdContactLog.Visible = True
lblNoContactLogs.Visible = False
cmdExport.Visible = True
End If
End Sub
Private Sub BindCrumbs()
Dim crumbs As New ArrayList
Dim objCrumbMain As New CrumbInfo
objCrumbMain.Caption = PropertySettings.MainLabel
objCrumbMain.Url = NavigateURL()
crumbs.Add(objCrumbMain)
Dim objTemplateDefinitions As New CrumbInfo
objTemplateDefinitions.Caption = Localization.GetString("ContactLog", LocalResourceFile)
objTemplateDefinitions.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=ContactLog")
crumbs.Add(objTemplateDefinitions)
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Portal) Then
For i As Integer = 0 To crumbs.Count - 1
Dim objCrumb As CrumbInfo = crumbs(i)
If (i > 0) Then
Dim objTab As New DotNetNuke.Entities.Tabs.TabInfo
objTab.TabID = -8888 + i
objTab.TabName = objCrumb.Caption
objTab.Url = objCrumb.Url
PortalSettings.ActiveTab.BreadCrumbs.Add(objTab)
End If
Next
End If
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Module) Then
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
Try
BindCrumbs()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If (Page.IsPostBack = False) Then
txtStartDate.Text = DateTime.Now.AddMonths(-1).ToShortDateString()
txtEndDate.Text = DateTime.Now.ToShortDateString()
Localization.LocalizeDataGrid(grdContactLog, Me.LocalResourceFile)
End If
cmdStartDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtStartDate)
cmdEndDate.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(txtEndDate)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub DataGrid1_ItemDataBound(ByVal s As Object, ByVal e As DataGridItemEventArgs) Handles grdContactLog.ItemDataBound
If (_hideColumns) Then
Dim i As Integer = 0
For Each tc As TableCell In e.Item.Cells
If ((i > 3 And _showCustomField) Or (i > 2 And _showCustomField = False)) Then
If (_fieldID <> Null.NullInteger) Then
If (i = _fieldID) Then
e.Item.Cells(i).Visible = True
Else
e.Item.Cells(i).Visible = False
End If
Else
e.Item.Cells(i).Visible = False
End If
Else
e.Item.Cells(i).Visible = True
End If
i = i + 1
Next
Else
Dim i As Integer = 0
For Each tc As TableCell In e.Item.Cells
e.Item.Cells(i).Visible = True
i = i + 1
Next
End If
End Sub
Protected Sub cmdSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdSearch.Click
Try
If (Page.IsValid) Then
BindContactLog()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
Private _hideColumns As Boolean = True
Protected Sub cmdExport_Click(ByVal sender As Object, ByVal e As EventArgs)
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=ExportContactLog.xls")
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
_hideColumns = False
BindContactLog()
grdContactLog.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()
End Sub
End Class
End Namespace