1
using System;
2
using System.Data;
3
using System.Xml;
4
using System.Web.UI.WebControls;
5
using System.Web.UI;
6
7
using Discuz.Control;
8
using Discuz.Forum;
9
using Discuz.Config;
10
using Discuz.Data;
11
using Discuz.Aggregation;
12
using Discuz.Entity;
13
using Discuz.Common;
14
using Discuz.Common.Xml;
15
using Discuz.Web.Admin;
16
17
18
namespace Discuz.Album.Admin
19
...{
20
/**//// <summary>
21
/// 查找要审核的主题
22
/// </summary>
23
#if NET1
24
public class AutoAlbums : AdminPage
25
#else
26
public partial class AutoAlbums : AdminPage
27
#endif
28
...{
29
30
#if NET1
31
控件声明#region 控件声明
32
protected System.Web.UI.HtmlControls.HtmlForm Form1;
33
protected System.Web.UI.HtmlControls.HtmlInputHidden recommendphoto;
34
protected System.Web.UI.HtmlControls.HtmlInputHidden recommendalbum;
35
36
protected Discuz.Control.RadioButtonList focusphotoshowtype;
37
protected Discuz.Control.TextBox focusphotodays;
38
protected Discuz.Control.TextBox focusphotocount;
39
protected Discuz.Control.RadioButtonList recommendalbumtype;
40
protected Discuz.Control.TextBox focusalbumdays;
41
protected Discuz.Control.TextBox focusalbumcount;
42
protected Discuz.Control.TextBox weekhot;
43
protected Discuz.Control.Button savetopic;
44
#endregion
45
#endif
46
47
private string configPath;
48
49
protected void Page_Load(object sender, EventArgs e)
50
...{
51
if (!IsPostBack)
52
...{
53
LoadWebSiteConfig();
54
}
55
}
56
57
private void LoadWebSiteConfig()
58
...{
59
绑定自动推荐相册#region 绑定自动推荐相册
60
//装载配置文件
61
XmlDocumentExtender doc = new XmlDocumentExtender();
62
doc.Load(configPath);
63
XmlNode albumconfig = doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Albumindex/Albumconfig");
64
focusphotoshowtype.SelectedIndex = Convert.ToInt32(doc.GetSingleNodeValue(albumconfig, "Focusphotoshowtype"));
65
focusphotodays.Text = doc.GetSingleNodeValue(albumconfig, "Focusphotodays");
66
focusphotocount.Text = doc.GetSingleNodeValue(albumconfig, "Focusphotocount");
67
recommendalbumtype.SelectedIndex = Convert.ToInt32(doc.GetSingleNodeValue(albumconfig, "Focusalbumshowtype"));
68
focusalbumdays.Text = doc.GetSingleNodeValue(albumconfig, "Focusalbumdays");
69
focusalbumcount.Text = doc.GetSingleNodeValue(albumconfig, "Focusalbumcount");
70
weekhot.Text = doc.GetSingleNodeValue(albumconfig, "Weekhot");
71
#endregion
72
}
73
74
private void savetopic_Click(object sender, EventArgs e)
75
...{
76
绑定自动推荐相册修改#region 绑定自动推荐相册修改
77
//验证值是否正确
78
if (!ValidateValue(focusphotodays.Text)) return;
79
if (!ValidateValue(focusphotocount.Text)) return;
80
if (!ValidateValue(focusalbumdays.Text)) return;
81
if (!ValidateValue(focusalbumcount.Text)) return;
82
if (!ValidateValue(weekhot.Text)) return;
83
string strfocusphotoshowtype = focusphotoshowtype.SelectedIndex.ToString();
84
string strfocusphotodays = focusphotodays.Text;
85
string strfocusphotocount = focusphotocount.Text;
86
string strfocusalbumshowtype = recommendalbumtype.SelectedIndex.ToString();
87
string strfocusalbumdays = focusalbumdays.Text;
88
string strfocusalbumcount = focusalbumcount.Text;
89
string strweekhot = weekhot.Text;
90
//保存信息
91
XmlDocumentExtender doc = new XmlDocumentExtender();
92
doc.Load(configPath);
93
doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Albumindex/Albumconfig");
94
XmlNode albumconfig = doc.InitializeNode("/Aggregationinfo/Aggregationpage/Albumindex/Albumconfig");
95
XmlElement node = doc.CreateElement("Focusphotoshowtype");
96
node.InnerText = strfocusphotoshowtype;
97
albumconfig.AppendChild(node);
98
node = doc.CreateElement("Focusphotodays");
99
node.InnerText = strfocusphotodays;
100
albumconfig.AppendChild(node);
101
node = doc.CreateElement("Focusphotocount");
102
node.InnerText = strfocusphotocount;
103
albumconfig.AppendChild(node);
104
node = doc.CreateElement("Focusalbumshowtype");
105
node.InnerText = strfocusalbumshowtype;
106
albumconfig.AppendChild(node);
107
node = doc.CreateElement("Focusalbumdays");
108
node.InnerText = strfocusalbumdays;
109
albumconfig.AppendChild(node);
110
node = doc.CreateElement("Focusalbumcount");
111
node.InnerText = strfocusalbumcount;
112
albumconfig.AppendChild(node);
113
node = doc.CreateElement("Weekhot");
114
node.InnerText = strweekhot;
115
albumconfig.AppendChild(node);
116
doc.Save(configPath);
117
AggregationFacade.BaseAggregation.ClearAllDataBind();
118
Response.Redirect("aggregation_autoalbums.aspx");
119
#endregion
120
}
121
/**//// <summary>
122
/// 验证值是否正确
123
/// </summary>
124
/// <param name="val">要验证的值</param>
125
/// <returns>正确否</returns>
126
private bool ValidateValue(string val)
127
...{
128
验证值是否正确#region 验证值是否正确
129
if (Utils.IsNumeric(val))
130
...{
131
if (Convert.ToInt32(val) < 0)
132
...{
133
base.RegisterStartupScript("PAGE", "alert('页面中各项配置输入必须为正整数');window.location.href='aggregation_autoalbums.aspx';");
134
return false;
135
}
136
else
137
return true;
138
}
139
else
140
...{
141
base.RegisterStartupScript("PAGE", "alert('页面中各项配置输入必须为数字');window.location.href='aggregation_autoalbums.aspx';");
142
return false;
143
}
144
#endregion
145
}
146
147
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
148
149
protected override void OnInit(EventArgs e)
150
...{
151
InitializeComponent();
152
base.OnInit(e);
153
}
154
155
private void InitializeComponent()
156
...{
157
this.savetopic.Click += new EventHandler(this.savetopic_Click);
158
this.savetopic.ValidateForm = true;
159
160
configPath = Server.MapPath(BaseConfigs.GetForumPath + "config/aggregation.config");
161
}
162
163
#endregion
164
165
}
166
}