当前文件路径:DNN/Library/Controls/URLTrackingControl.vb 
1
'
2
' DotNetNuke?- http://www.dotnetnuke.com
3
' Copyright (c) 2002-2008
4
' by DotNetNuke Corporation
5
'
6
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
8
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
9
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
'
11
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
12
' of the Software.
13
'
14
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
' DEALINGS IN THE SOFTWARE.
19
'
20
Imports DotNetNuke.Services.FileSystem
21
22
Namespace DotNetNukeNamespace DotNetNuke.UI.UserControls
23
24
Public MustInherit Class URLTrackingControlClass URLTrackingControl
25
Inherits Framework.UserControlBase
26
27
Controls#Region "Controls"
28
Protected WithEvents lblURL As System.Web.UI.WebControls.Label
29
Protected WithEvents lblCreatedDate As System.Web.UI.WebControls.Label
30
31
Protected WithEvents pnlTrack As System.Web.UI.WebControls.Panel
32
Protected WithEvents lblTrackingURL As System.Web.UI.WebControls.Label
33
Protected WithEvents lblClicks As System.Web.UI.WebControls.Label
34
Protected WithEvents lblLastClick As System.Web.UI.WebControls.Label
35
36
Protected WithEvents pnlLog As System.Web.UI.WebControls.Panel
37
Protected WithEvents txtStartDate As System.Web.UI.WebControls.TextBox
38
Protected WithEvents txtEndDate As System.Web.UI.WebControls.TextBox
39
Protected WithEvents cmdStartCalendar As System.Web.UI.WebControls.HyperLink
40
Protected WithEvents cmdEndCalendar As System.Web.UI.WebControls.HyperLink
41
Protected WithEvents valStartDate As System.Web.UI.WebControls.CompareValidator
42
Protected WithEvents valEndDate As System.Web.UI.WebControls.CompareValidator
43
Protected WithEvents cmdDisplay As System.Web.UI.WebControls.LinkButton
44
Protected WithEvents grdLog As System.Web.UI.WebControls.DataGrid
45
Protected WithEvents lblLogURL As System.Web.UI.WebControls.Label
46
47
Protected Label1 As System.Web.UI.WebControls.Label
48
Protected Label2 As System.Web.UI.WebControls.Label
49
Protected Label3 As System.Web.UI.WebControls.Label
50
Protected Label4 As System.Web.UI.WebControls.Label
51
Protected Label5 As System.Web.UI.WebControls.Label
52
Protected Label6 As System.Web.UI.WebControls.Label
53
Protected Label7 As System.Web.UI.WebControls.Label
54
#End Region
55
56
Private Members#Region "Private Members"
57
Private _URL As String = ""
58
Private _FormattedURL As String = ""
59
Private _TrackingURL As String = ""
60
Private _ModuleID As Integer = -2
61
Private _localResourceFile As String
62
#End Region
63
64
Public Properties#Region "Public Properties"
65
Public Property FormattedURL()Property FormattedURL() As String
66
Get
67
FormattedURL = _FormattedURL
68
End Get
69
Set(ByVal Value As String)
70
_FormattedURL = Value
71
End Set
72
End Property
73
74
Public Property TrackingURL()Property TrackingURL() As String
75
Get
76
TrackingURL = _TrackingURL
77
End Get
78
Set(ByVal Value As String)
79
_TrackingURL = Value
80
End Set
81
End Property
82
83
Public Property URL()Property URL() As String
84
Get
85
URL = _URL
86
End Get
87
Set(ByVal Value As String)
88
_URL = Value
89
End Set
90
End Property
91
92
Public Property ModuleID()Property ModuleID() As Integer
93
Get
94
ModuleID = _ModuleID
95
If ModuleID = -2 Then
96
If Not Request.QueryString("mid") Is Nothing Then
97
ModuleID = Int32.Parse(Request.QueryString("mid"))
98
End If
99
End If
100
End Get
101
Set(ByVal Value As Integer)
102
_ModuleID = Value
103
End Set
104
End Property
105
106
Public Property LocalResourceFile()Property LocalResourceFile() As String
107
Get
108
Dim fileRoot As String
109
110
If _localResourceFile = "" Then
111
fileRoot = Me.TemplateSourceDirectory & "/" & Services.Localization.Localization.LocalResourceDirectory & "/URLTrackingControl.ascx"
112
Else
113
fileRoot = _localResourceFile
114
End If
115
Return fileRoot
116
End Get
117
Set(ByVal Value As String)
118
_localResourceFile = Value
119
End Set
120
End Property
121
122
#End Region
123
124
Event Handlers#Region "Event Handlers"
125
'*******************************************************
126
'
127
' The Page_Load server event handler on this page is used
128
' to populate the role information for the page
129
'
130
'*******************************************************
131
132
Private Sub Page_Load()Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
133
Try
134
135
'this needs to execute always to the client script code is registred in InvokePopupCal
136
cmdStartCalendar.NavigateUrl = Common.Utilities.Calendar.InvokePopupCal(txtStartDate)
137
cmdEndCalendar.NavigateUrl = Common.Utilities.Calendar.InvokePopupCal(txtEndDate)
138
139
If Not Page.IsPostBack Then
140
141
If _URL <> "" Then
142
143
lblLogURL.Text = URL ' saved for loading Log grid
144
145
Dim URLType As TabType = GetURLType(_URL)
146
If URLType = TabType.File And _URL.ToLower.StartsWith("fileid=") = False Then
147
' to handle legacy scenarios before the introduction of the FileServerHandler
148
Dim objFiles As New FileController
149
lblLogURL.Text = "FileID=" & objFiles.ConvertFilePathToFileId(_URL, PortalSettings.PortalId).ToString
150
End If
151
152
153
Dim objUrls As New UrlController
154
Dim objUrlTracking As UrlTrackingInfo = objUrls.GetUrlTracking(PortalSettings.PortalId, lblLogURL.Text, ModuleID)
155
If Not objUrlTracking Is Nothing Then
156
If _FormattedURL = "" Then
157
If Not URL.StartsWith("http") And Not URL.StartsWith("mailto") Then
158
lblURL.Text = AddHTTP(Request.Url.Host)
159
End If
160
lblURL.Text += Common.Globals.LinkClick(URL, PortalSettings.ActiveTab.TabID, ModuleID, False)
161
Else
162
lblURL.Text = _FormattedURL
163
End If
164
lblCreatedDate.Text = objUrlTracking.CreatedDate.ToString
165
166
If objUrlTracking.TrackClicks Then
167
pnlTrack.Visible = True
168
If _TrackingURL = "" Then
169
If Not URL.StartsWith("http") Then
170
lblTrackingURL.Text = AddHTTP(Request.Url.Host)
171
End If
172
lblTrackingURL.Text += Common.Globals.LinkClick(URL, PortalSettings.ActiveTab.TabID, ModuleID, objUrlTracking.TrackClicks)
173
Else
174
lblTrackingURL.Text = _TrackingURL
175
End If
176
lblClicks.Text = objUrlTracking.Clicks.ToString
177
If Not Null.IsNull(objUrlTracking.LastClick) Then
178
lblLastClick.Text = objUrlTracking.LastClick.ToString
179
End If
180
End If
181
182
If objUrlTracking.LogActivity Then
183
pnlLog.Visible = True
184
185
txtStartDate.Text = DateAdd(DateInterval.Day, -6, Date.Today).ToShortDateString
186
txtEndDate.Text = DateAdd(DateInterval.Day, 1, Date.Today).ToShortDateString
187
End If
188
End If
189
Else
190
Me.Visible = False
191
End If
192
193
End If
194
195
Catch exc As Exception 'Module failed to load
196
ProcessModuleLoadException(Me, exc)
197
End Try
198
End Sub
199
200
Private Sub cmdDisplay_Click()Sub cmdDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdDisplay.Click
201
Try
202
203
Dim strStartDate As String = txtStartDate.Text
204
If strStartDate <> "" Then
205
strStartDate = strStartDate & " 00:00"
206
End If
207
208
Dim strEndDate As String = txtEndDate.Text
209
If strEndDate <> "" Then
210
strEndDate = strEndDate & " 23:59"
211
End If
212
213
Dim objUrls As New UrlController
214
'localize datagrid
215
Services.Localization.Localization.LocalizeDataGrid(grdLog, Me.LocalResourceFile)
216
grdLog.DataSource = objUrls.GetUrlLog(PortalSettings.PortalId, lblLogURL.Text, ModuleID, Convert.ToDateTime(strStartDate), Convert.ToDateTime(strEndDate))
217
grdLog.DataBind()
218
219
Catch exc As Exception 'Module failed to load
220
ProcessModuleLoadException(Me, exc)
221
End Try
222
End Sub
223
224
#End Region
225
226
End Class
227
228
End Namespace
229