-
Notifications
You must be signed in to change notification settings - Fork 8
/
UrlRule_Edit.ascx.cs
148 lines (116 loc) · 5.01 KB
/
UrlRule_Edit.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
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
/*
' Copyright (c) 2012 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 System;
using DotNetNuke.Services.Exceptions;
using Satrabel.Services.Log.UrlRule;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Tabs;
namespace DotNetNuke.Modules.OpenUrlRewriter
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The EditOpenUrlRewriter class is used to manage content
///
/// Typically your edit control would be used to create new content, or edit existing content within your module.
/// The ControlKey for this control is "Edit", and is defined in the manifest (.dnn) file.
///
/// Because the control inherits from OpenUrlRewriterModuleBase you have access to any custom properties
/// defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.
///
/// </summary>
/// -----------------------------------------------------------------------------
public partial class UrlRule_Edit : PortalModuleBase
{
#region Event Handlers
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
hlCancel.NavigateUrl = Globals.NavigateURL();
}
int ItemId = Null.NullInteger;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
try
{
if (Page.Request.QueryString["UrlRuleId"] != null)
{
ItemId = int.Parse(Page.Request.QueryString["UrlRuleId"]);
}
ddlTab.DataSource = TabController.GetPortalTabs(PortalId, -1, false, true);
ddlTab.DataBind();
lbDelete.Visible = ItemId != Null.NullInteger;
if (!Page.IsPostBack) {
if (ItemId != Null.NullInteger)
{
var rule = UrlRuleController.GetUrlRule(ItemId);
ddlRuleType.SelectedValue = rule.RuleType.ToString();
//CultureCode = ddlCultureCode.SelectedValue,
if (rule.TabId > 0)
ddlTab.SelectedValue = rule.TabId.ToString();
tbParameters.Text = rule.Parameters;
ddlAction.SelectedValue = rule.RuleAction.ToString();
cbRemoveTab.Checked = rule.RemoveTab;
tbUrl.Text = rule.Url;
tbRedirectDestination.Text = rule.RedirectDestination;
ddlRedirectStatus.SelectedValue = rule.RedirectStatus.ToString();
}
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
#endregion
protected void lbSave_Click(object sender, EventArgs e)
{
UrlRuleInfo rule = new UrlRuleInfo()
{
RuleType = int.Parse(ddlRuleType.SelectedValue),
PortalId = PortalId,
//CultureCode = ddlCultureCode.SelectedValue,
TabId = int.Parse(ddlTab.SelectedValue),
Parameters = tbParameters.Text,
RuleAction = int.Parse(ddlAction.SelectedValue),
RemoveTab = cbRemoveTab.Checked,
Url = tbUrl.Text,
RedirectDestination = tbRedirectDestination.Text,
RedirectStatus = int.Parse(ddlRedirectStatus.SelectedValue),
UserId = UserId,
DateTime = DateTime.Now
};
if (ItemId == Null.NullInteger)
{
var UrlRule = UrlRuleController.AddUrlRule(rule);
}
else
{
rule.UrlRuleId = ItemId;
UrlRuleController.UpdateUrlRule(rule);
}
DataCache.ClearCache();
this.Response.Redirect(Globals.NavigateURL(this.TabId), true);
}
protected void lbDelete_Click(object sender, EventArgs e)
{
if (ItemId != Null.NullInteger)
{
UrlRuleController.DeleteUrlRule(ItemId);
}
DataCache.ClearCache();
this.Response.Redirect(Globals.NavigateURL(this.TabId), true);
}
}
}