/
AngularModuleBase.cs
49 lines (41 loc) · 2.3 KB
/
AngularModuleBase.cs
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
/*
' Copyright (c) 2013 DotNetNuke Corporation
' All rights reserved.
'
' 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.
'
*/
using DotNetNuke.Entities.Modules;
namespace DotNetNuke.Modules.Angular
{
public class AngularModuleBase : PortalModuleBase
{
public static void SessionTimerJavaScript(PortalModuleBase portalModuleBase)
{
if (portalModuleBase.Page != null)
{
string timerScript = "<script src=\"/DesktopModules/Angular/Scripts/SessionTimer.js\" type=\"text/javascript\"></script>";
int sessionWarningThresholdInMilliSeconds = int.Parse(portalModuleBase.Settings["SessionTimerThreshold"].ToString()) * 60000;
int sessionDurationInMilliSeconds = portalModuleBase.Page.Session.Timeout * 60000;
//guard against invalid warning threshold.
if (sessionWarningThresholdInMilliSeconds >= sessionDurationInMilliSeconds)
{
sessionWarningThresholdInMilliSeconds = sessionDurationInMilliSeconds - 1000;
}
string timerVars = string.Format("sessionApp.constant('settings',{{ threshold: {0}, sessionDuration: {1} }});\n", sessionWarningThresholdInMilliSeconds.ToString(), sessionDurationInMilliSeconds.ToString());
if (!portalModuleBase.Page.ClientScript.IsStartupScriptRegistered("_SessionTimerInclude_"))
{
portalModuleBase.Page.ClientScript.RegisterStartupScript(portalModuleBase.Page.GetType(), "_SessionTimerInclude_", timerScript, false);
}
if (!portalModuleBase.Page.ClientScript.IsStartupScriptRegistered("_SessionTimerVars_"))
{
portalModuleBase.Page.ClientScript.RegisterStartupScript(portalModuleBase.Page.GetType(), "_SessionTimer_", timerVars, true);
}
}
}
}
}