-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.ascx.vb
198 lines (161 loc) · 8.97 KB
/
Settings.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
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
' 4/15/2011 - Converted to WAP and Updated to DNN 5 Compliance by Robert J Collins
'
Imports System.IO
Imports System.Runtime.Serialization.Formatters
Imports System.Collections.Generic
Imports DotNetNuke
''' -----------------------------------------------------------------------------
''' <summary>
''' The Settings ModuleSettingsBase is used to manage the
''' settings for the Survey Module
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 10/22/2004 Updated to reflect design changes for Help, 508 support
''' and localisation
''' [cnurse] 10/22/2004 Converted to a ModuleSettingsBase class
''' [mwashington] 8/12/2006 Converted to ASP.NET 2.0
'''
''' </history>
''' -----------------------------------------------------------------------------
Namespace DotNetNuke.Modules.Survey
Public Class Settings
Inherits Entities.Modules.ModuleSettingsBase
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Framework.AJAX.IsInstalled Then
Framework.AJAX.RegisterScriptManager()
Framework.AJAX.RegisterPostBackControl(lnkExport)
End If
End Sub
#Region "Base Method Implementations"
''' -----------------------------------------------------------------------------
''' <summary>
''' LoadSettings loads the settings from the Database and displays them
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 10/22/2004 created
''' </history>
''' -----------------------------------------------------------------------------
Public Overrides Sub LoadSettings()
Try
'this needs to execute always to the client script code is registred in InvokePopupCal
cmdCalendar.NavigateUrl = Common.Utilities.Calendar.InvokePopupCal(txtClosingDate)
If (Page.IsPostBack = False) Then
If CType(ModuleSettings("surveyclosingdate"), String) <> "" Then
txtClosingDate.Text = CType(ModuleSettings("surveyclosingdate"), Date).ToShortDateString
End If
txtGraphWidth.Text = CType(TabModuleSettings("surveygraphwidth"), String)
rblstPersonal.SelectedIndex = CType(ModuleSettings("surveytracking"), Integer)
rblstSurveyResults.SelectedIndex = CType(ModuleSettings("surveyresultstype"), Integer)
'Get or create Template
If CType(Settings("surveyresulttemplate"), String) Is Nothing Then
txtSurveyResultsTremplate.Text = DefaultSurveyResultTemplate()
Else
txtSurveyResultsTremplate.Text = CType(Settings("surveyresulttemplate"), String)
End If
End If
Catch exc As Exception 'Module failed to load
Services.Exceptions.Exceptions.ProcessModuleLoadException(Me, exc)
End Try
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' UpdateSettings saves the modified settings to the Database
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 10/22/2004 created
''' </history>
''' -----------------------------------------------------------------------------
Public Overrides Sub UpdateSettings()
Try
Dim objModules As New Entities.Modules.ModuleController
Dim datClosingDate As Date '= Convert.ToDateTime(DBNull.Value)
If txtClosingDate.Text.Trim.Length > 0 Then
If IsDate(txtClosingDate.Text.Trim) Then
datClosingDate = Convert.ToDateTime(txtClosingDate.Text.Trim)
End If
End If
'Update Module Settings
objModules.UpdateModuleSetting(ModuleId, "surveyclosingdate", Common.Globals.DateToString(datClosingDate))
objModules.UpdateModuleSetting(ModuleId, "surveytracking", (rblstPersonal.SelectedIndex).ToString)
objModules.UpdateModuleSetting(ModuleId, "surveyresultstype", (rblstSurveyResults.SelectedIndex).ToString)
objModules.UpdateModuleSetting(ModuleId, "surveyresulttemplate", txtSurveyResultsTremplate.Text)
Dim strGraphWidth As String = ""
If txtGraphWidth.Text.Trim.Length > 0 Then
If IsNumeric(txtGraphWidth.Text.Trim) Then
strGraphWidth = txtGraphWidth.Text.Trim
End If
End If
'Update Tab Module Settings
objModules.UpdateTabModuleSetting(TabModuleId, "surveygraphwidth", strGraphWidth)
Catch exc As Exception 'Module failed to load
Services.Exceptions.Exceptions.ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
#Region "Export"
Public Sub ExportData()
Response.Clear()
Response.AddHeader("content-disposition", "attachment; filename=Survey_Results_" + ModuleId.ToString + "_" + DateTime.Now.ToShortDateString().Replace("/", "_") + ".csv")
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Dim stringWriter As System.IO.StringWriter = New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWriter)
stringWriter.Write("Question,Option,Option Type,Is Correct?,UserID" & vbCrLf)
Dim colSurveyResultInfo As List(Of SurveyResultInfo) = SurveyOptionController.GetSurveyResultData(ModuleId)
Dim objSurveyResultInfo As SurveyResultInfo
For Each objSurveyResultInfo In colSurveyResultInfo
stringWriter.Write(objSurveyResultInfo.Question & "," & objSurveyResultInfo.OptionName & "," & objSurveyResultInfo.OptionType & "," & objSurveyResultInfo.IsCorrect & "," & objSurveyResultInfo.UserId & vbCrLf)
Next
Response.Write(stringWriter.ToString())
Response.End()
End Sub
Protected Sub lnkExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkExport.Click
ExportData()
End Sub
#End Region
#Region "Clear Results"
Protected Sub lnkClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkClear.Click
SurveyOptionController.DeleteSurveyResultData(ModuleId)
lnkClear.Enabled = False
End Sub
#End Region
#Region "Default Template"
Public Function DefaultSurveyResultTemplate() As String
Dim objModules As New Entities.Modules.ModuleController
Dim strHTML As String = ""
strHTML += "<table border=""0"" cellpadding=""2"" cellspacing=""0"" summary=""Survey Results"">"
strHTML += "<tr>"
strHTML += "<td valign=""top"" class=""YourCompanyNameSurveyResults"">[SURVEY_OPTION_NAME] ([SURVEY_OPTION_VOTES])</td>"
strHTML += "<td align=""left"" valign=""top"" class=""Normal"" nowrap=""nowrap""><img src=""[SURVEY_OPTION_IMAGEPATH]/Images/red.gif"" width=""[SURVEY_OPTION_GRAPH_WIDTH]"" border=""0"" height=""15"" alt="""" /> [SURVEY_OPTION_PERCENTAGE]%"
strHTML += "</td>"
strHTML += "</tr>"
strHTML += "</table>"
objModules.UpdateModuleSetting(ModuleId, "surveyresulttemplate", strHTML)
Return strHTML
End Function
#End Region
End Class
End Namespace