-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.ascx.cs
69 lines (65 loc) · 2.46 KB
/
Settings.ascx.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.IO;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;
namespace Albatros.DNN.Modules.Balises
{
public partial class Settings : ModuleSettingsBase
{
#region Properties
private Common.ModuleSettings _settings;
public Common.ModuleSettings ModSettings
{
get { return _settings ?? (_settings = Common.ModuleSettings.GetSettings(ModuleContext.Configuration)); }
}
#endregion
#region Base Method Implementations
public override void LoadSettings()
{
try
{
if (Page.IsPostBack == false)
{
ddView.Items.Clear();
ddView.Items.Add(new ListItem(LocalizeString("Default"), "Index"));
System.IO.DirectoryInfo viewDir = new DirectoryInfo(Server.MapPath("~/DesktopModules/MVC/Albatros/Balises/Views"));
foreach (var f in viewDir.GetFiles("*.cshtml"))
{
string vwName = Path.GetFileNameWithoutExtension(f.Name);
if (vwName.ToLower() != "index")
{
ddView.Items.Add(new ListItem(vwName, vwName));
}
}
try
{
ddView.Items.FindByValue(ModSettings.View).Selected = true;
}
catch { }
txtGoogleMapApiKey.Text = ModSettings.GoogleMapApiKey;
txtBeaconPassDistanceMeters.Text = ModSettings.BeaconPassDistanceMeters.ToString();
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
public override void UpdateSettings()
{
try
{
ModSettings.View = ddView.SelectedValue;
ModSettings.GoogleMapApiKey = txtGoogleMapApiKey.Text.Trim();
ModSettings.BeaconPassDistanceMeters = int.Parse(txtBeaconPassDistanceMeters.Text.Trim());
ModSettings.SaveSettings(ModuleContext.Configuration);
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
#endregion
}
}