forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModalGatherFileSet.cs
179 lines (157 loc) · 7.44 KB
/
ModalGatherFileSet.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
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
using System;
using System.Collections.Specialized;
using System.Web.UI.WebControls;
using BaiRong.Core;
using SiteServer.BackgroundPages.Cms;
using SiteServer.CMS.Core;
namespace SiteServer.BackgroundPages.Plugins
{
public class ModalGatherFileSet : BasePageCms
{
public TextBox GatherUrl;
public PlaceHolder PlaceHolder_File;
public TextBox FilePath;
public RadioButtonList IsSaveRelatedFiles;
public RadioButtonList IsRemoveScripts;
public PlaceHolder PlaceHolder_File_Directory;
public TextBox StyleDirectoryPath;
public TextBox ScriptDirectoryPath;
public TextBox ImageDirectoryPath;
public PlaceHolder PlaceHolder_Content;
protected DropDownList NodeIDDropDownList;
public RadioButtonList IsSaveImage;
private string _gatherRuleName;
public static string GetOpenWindowString(int publishmentSystemId, string gatherRuleName)
{
return PageUtils.GetOpenWindowString("信息采集", PageUtils.GetPluginsUrl(nameof(ModalGatherFileSet), new NameValueCollection
{
{"PublishmentSystemID", publishmentSystemId.ToString()},
{"GatherRuleName", gatherRuleName}
}));
}
public void Page_Load(object sender, EventArgs e)
{
if (IsForbidden) return;
PageUtils.CheckRequestParameter("PublishmentSystemID", "GatherRuleName");
_gatherRuleName = Body.GetQueryString("GatherRuleName");
if (!IsPostBack)
{
InfoMessage("采集名称:" + _gatherRuleName);
var gatherFileRuleInfo = DataProvider.GatherFileRuleDao.GetGatherFileRuleInfo(_gatherRuleName, PublishmentSystemId);
GatherUrl.Text = gatherFileRuleInfo.GatherUrl;
if (gatherFileRuleInfo.IsToFile)
{
PlaceHolder_File.Visible = true;
PlaceHolder_Content.Visible = false;
FilePath.Text = gatherFileRuleInfo.FilePath;
ControlUtils.SelectListItems(IsSaveRelatedFiles, gatherFileRuleInfo.IsSaveRelatedFiles.ToString());
ControlUtils.SelectListItems(IsRemoveScripts, gatherFileRuleInfo.IsRemoveScripts.ToString());
StyleDirectoryPath.Text = gatherFileRuleInfo.StyleDirectoryPath;
ScriptDirectoryPath.Text = gatherFileRuleInfo.ScriptDirectoryPath;
ImageDirectoryPath.Text = gatherFileRuleInfo.ImageDirectoryPath;
}
else
{
PlaceHolder_File.Visible = false;
PlaceHolder_Content.Visible = true;
NodeManager.AddListItemsForAddContent(NodeIDDropDownList.Items, PublishmentSystemInfo, true, Body.AdminName);
ControlUtils.SelectListItems(NodeIDDropDownList, gatherFileRuleInfo.NodeId.ToString());
ControlUtils.SelectListItems(IsSaveImage, gatherFileRuleInfo.IsSaveImage.ToString());
}
}
}
public void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
if (PlaceHolder_File.Visible)
{
PlaceHolder_File_Directory.Visible = TranslateUtils.ToBool(IsSaveRelatedFiles.SelectedValue);
}
}
public override void Submit_OnClick(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(GatherUrl.Text))
{
FailMessage("必须填写采集网页地址!");
return;
}
if (PlaceHolder_File.Visible)
{
if (string.IsNullOrEmpty(FilePath.Text))
{
FailMessage("必须填写采集到的文件地址!");
return;
}
else
{
var isOk = false;
if (StringUtils.StringStartsWith(FilePath.Text, '~') || StringUtils.StringStartsWith(FilePath.Text, '@'))
{
if (!PathUtils.IsDirectoryPath(FilePath.Text))
{
isOk = true;
}
}
if (isOk == false)
{
FailMessage("采集到的文件地址不正确,必须填写有效的文件地址!");
return;
}
}
if (TranslateUtils.ToBool(IsSaveRelatedFiles.SelectedValue))
{
var isOk = false;
if (StringUtils.StringStartsWith(StyleDirectoryPath.Text, '~') || StringUtils.StringStartsWith(StyleDirectoryPath.Text, '@'))
{
if (PathUtils.IsDirectoryPath(StyleDirectoryPath.Text))
{
isOk = true;
}
}
if (isOk == false)
{
FailMessage("CSS样式保存地址不正确,必须填写有效的文件夹地址!");
return;
}
isOk = false;
if (StringUtils.StringStartsWith(ScriptDirectoryPath.Text, '~') || StringUtils.StringStartsWith(ScriptDirectoryPath.Text, '@'))
{
if (PathUtils.IsDirectoryPath(ScriptDirectoryPath.Text))
{
isOk = true;
}
}
if (isOk == false)
{
FailMessage("Js脚本保存地址不正确,必须填写有效的文件夹地址!");
return;
}
isOk = false;
if (StringUtils.StringStartsWith(ImageDirectoryPath.Text, '~') || StringUtils.StringStartsWith(ImageDirectoryPath.Text, '@'))
{
if (PathUtils.IsDirectoryPath(ImageDirectoryPath.Text))
{
isOk = true;
}
}
if (isOk == false)
{
FailMessage("图片保存地址不正确,必须填写有效的文件夹地址!");
return;
}
}
}
var gatherFileRuleInfo = DataProvider.GatherFileRuleDao.GetGatherFileRuleInfo(_gatherRuleName, PublishmentSystemId);
gatherFileRuleInfo.GatherUrl = GatherUrl.Text;
gatherFileRuleInfo.FilePath = FilePath.Text;
gatherFileRuleInfo.IsSaveRelatedFiles = TranslateUtils.ToBool(IsSaveRelatedFiles.SelectedValue);
gatherFileRuleInfo.IsRemoveScripts = TranslateUtils.ToBool(IsRemoveScripts.SelectedValue);
gatherFileRuleInfo.StyleDirectoryPath = StyleDirectoryPath.Text;
gatherFileRuleInfo.ScriptDirectoryPath = ScriptDirectoryPath.Text;
gatherFileRuleInfo.ImageDirectoryPath = ImageDirectoryPath.Text;
gatherFileRuleInfo.NodeId = TranslateUtils.ToInt(NodeIDDropDownList.SelectedValue);
gatherFileRuleInfo.IsSaveImage = TranslateUtils.ToBool(IsSaveImage.SelectedValue);
DataProvider.GatherFileRuleDao.Update(gatherFileRuleInfo);
PageUtils.Redirect(ModalProgressBar.GetRedirectUrlStringWithGatherFile(PublishmentSystemId, _gatherRuleName));
}
}
}