diff --git a/.gitignore b/.gitignore
index 272d07eaa..334874485 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,16 @@
*.zip
+TestResults/
+backup/
+update/
build/
-.vscode/
+packages/
+*.exe
+*.exe.config
+package-lock.json
+Web.Backup.config
+Web.Restore.config
+Web.RestoreUpdate.config
+/SiteFiles/
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
@@ -216,7 +226,6 @@ Generated_Code/
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
-Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 000000000..4bfd587b3
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,40 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "Build Web",
+ "type": "shell",
+ "command": "MSBuild.exe siteserver-web.sln",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ }
+ },
+ {
+ "label": "Build Cli",
+ "type": "shell",
+ "command": "MSBuild.exe siteserver-cli.sln",
+ "group": "build",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ }
+ },
+ {
+ "label": "Build All",
+ "type": "shell",
+ "command": "MSBuild.exe siteserver-all.sln",
+ "group": "build",
+ "presentation": {
+ "reveal": "always",
+ "panel": "new"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/NuGet.config b/NuGet.config
deleted file mode 100644
index 9335e9610..000000000
--- a/NuGet.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index d01642dfe..5abbea2ed 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,66 @@
# SiteServer CMS
-SiteServer CMS 是.NET平台CMS系统的创始者,能够以最低的成本、最少的人力投入在最短的时间内架设一个功能齐全、性能优异、规模庞大并易于维护的网站平台。
+SiteServer CMS 基于.NET 平台,能够以最低的成本、最少的人力投入在最短的时间内架设一个功能齐全、性能优异、规模庞大并易于维护的网站平台。
-
+
-[官网](http://www.siteserver.cn/) | [文档中心](http://docs.siteserver.cn/) | [STL 语言](http://stl.siteserver.cn/) | [博客](http://blog.siteserver.cn/)
+## 版本
+
+项目发布的正式版本存放在 `master` 分支,当前的开发版本存放在 `dev` 分支
+
+| 版本 | 编译状态 | 版本号 | 发布日期 |
+| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
+| 正式版 | [](https://ci.appveyor.com/project/starlying/cms/branch/master) |  |  |
+| 开发版 | [](https://ci.appveyor.com/project/starlying/cms/branch/staging) |  |  |
+
+## 迭代计划
+
+[2019 年 1 月/2 月迭代计划](https://github.com/siteserver/cms/issues/1683)
+
+[2018 年 11 月/12 月迭代计划](https://github.com/siteserver/cms/issues/1521)
+
+[2018 年 9 月/10 月迭代计划](https://github.com/siteserver/cms/issues/1280)
+
+[2018 年 8 月迭代计划](https://github.com/siteserver/cms/issues/1138)
+
+[2018 年 7 月迭代计划](https://github.com/siteserver/cms/issues/956)
+
+[2018 年 6 月迭代计划](https://github.com/siteserver/cms/issues/719)
+
+[2018 年 5 月迭代计划](https://github.com/siteserver/cms/issues/518)
+
+[2018 年 4 月迭代计划](https://github.com/siteserver/cms/issues/412)
+
+[2018 年 3 月迭代计划](https://github.com/siteserver/cms/issues/300)
+
+[2018 年 2 月迭代计划](https://github.com/siteserver/cms/issues/239)
+
+[SiteServer CMS 路线图 2018](https://github.com/siteserver/cms/issues/718)
+
+## 开发文档
+
+[《STL 语言参考手册》](https://docs.siteserver.cn/stl/)
+
+[《插件开发参考手册》](https://docs.siteserver.cn/plugins/)
+
+[《CLI 命令行参考手册》](https://docs.siteserver.cn/cli/)
+
+[《REST API 参考手册》](https://docs.siteserver.cn/api/)
+
+[《数据结构参考手册》](https://docs.siteserver.cn/model/)
+
+系统使用文档请点击 [SiteServer CMS 文档中心](https://www.siteserver.cn/docs/)
## SiteServer CMS 源码结构
```code
│ siteserver.sln Visual Studio 项目文件
│
-├─SiteServer.Utils 基础类库
-├─SiteServer.CMS CMS 源文件
├─SiteServer.BackgroundPages ASP.NET 页面源文件
-└─SiteServer.Web API 源文件及aspx页面
+├─SiteServer.Cli 命令行工具
+├─SiteServer.CMS CMS 源文件
+├─SiteServer.Utils 基础类库
+└─SiteServer.API API 源文件及页面
```
## 生成安装包
@@ -24,15 +70,15 @@ SiteServer CMS 是.NET平台CMS系统的创始者,能够以最低的成本、
二、安装NodeJs
三、打开命令行,运行 npm install gulp -g
四、命令行,转到根目录,运行 npm install
-五、命令行,运行 gulp release
+五、命令行,运行 gulp build
六、命令行,运行 gulp zip
```
-结束后会在根目录看到siteserver_install.zip,这就是安装包了。
+结束后会在根目录看到 siteserver_install.zip,这就是安装包了。
以上步骤是第一次生成安装包所需要执行的操作,如果已经生成过安装包:
```code
-一、命令行,转到根目录,运行 gulp release
+一、命令行,转到根目录,运行 gulp build
二、命令行,运行 gulp zip
```
@@ -48,29 +94,20 @@ SiteServer CMS 是.NET平台CMS系统的创始者,能够以最低的成本、
- 4、将您的修改记录提交到远程 `git` 仓库 (`git push origin my-new-feature`)
- 5、然后到 github 网站的该 `git` 远程仓库的 `my-new-feature` 分支下发起 Pull Request(请提交到 `dev` 分支,不要直接提交到 `master` 分支)
-## 产品路线图
+## 系统更新
-SiteServer CMS 产品将在每个月底发布新的稳定版本,我们将在每次迭代中对核心功能、文档支持、功能插件以及网站模板四个方面进行持续改进,详情请参考 [路线图](https://github.com/siteserver/cms/wiki/%E8%B7%AF%E7%BA%BF%E5%9B%BE)。
+SiteServer CMS 产品将在每个月底发布新的正式版本,我们将在每次迭代中对核心功能、文档支持、功能插件以及网站模板四个方面进行持续改进。
## 问题与建议
-我们的目标是系统零BUG,如果发现任何BUG请提交至[Github Issues](https://github.com/siteserver/cms/issues)。
+如果发现任何 BUG 以及对产品使用的问题与建议,请提交至 [Github Issues](https://github.com/siteserver/cms/issues)。
## 关注最新动态
-[](http://www.siteserver.cn/)
+[](https://www.siteserver.cn/)
## License
[GNU GENERAL PUBLIC LICENSE 3.0](LICENSE)
-Copyright (C) 2003-2018 北京百容千域软件技术开发有限公司
-
-## 编译状态
-
-项目正式发布的稳定版本存放在 `master` 分支,当前的开发版本存放在 `dev` 分支
-
-分支 | AppVeyor
------- | ------
-master | [](https://ci.appveyor.com/project/starlying/cms/branch/master)
-dev | [](https://ci.appveyor.com/project/starlying/cms/branch/dev)
\ No newline at end of file
+Copyright (C) 2003-2019 SiteServer CMS
diff --git a/SS.CMS.nuspec b/SS.CMS.nuspec
index 92543298e..803c7eacd 100644
--- a/SS.CMS.nuspec
+++ b/SS.CMS.nuspec
@@ -12,7 +12,7 @@
Copyright © SiteServer CMS 2018
SiteServer CMS
- 6.1正式版,40余项BUG修复,10余项功能增强
+ SiteServer CMS V6.8正式版
\ No newline at end of file
diff --git a/SiteServer.BackgroundPages/Account/PagePassword.cs b/SiteServer.BackgroundPages/Account/PagePassword.cs
deleted file mode 100644
index f79bfcca0..000000000
--- a/SiteServer.BackgroundPages/Account/PagePassword.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Account
-{
- public class PagePassword : BasePage
- {
- public Literal LtlUserName;
- public TextBox TbCurrentPassword;
- public TextBox TbNewPassword;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (!Page.IsPostBack)
- {
- LtlUserName.Text = AuthRequest.AdminName;
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var adminInfo = DataProvider.AdministratorDao.GetByUserName(AuthRequest.AdminName);
-
- if (DataProvider.AdministratorDao.CheckPassword(TbCurrentPassword.Text, adminInfo.Password, adminInfo.PasswordFormat, adminInfo.PasswordSalt))
- {
- string errorMessage;
- if (DataProvider.AdministratorDao.ChangePassword(AuthRequest.AdminName, TbNewPassword.Text, out errorMessage))
- {
- SuccessMessage("密码更改成功");
- }
- else
- {
- FailMessage(errorMessage);
- }
- }
- else
- {
- FailMessage("当前帐号密码错误");
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Account/PageProfile.cs b/SiteServer.BackgroundPages/Account/PageProfile.cs
deleted file mode 100644
index f91a8ba97..000000000
--- a/SiteServer.BackgroundPages/Account/PageProfile.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Account
-{
- public class PageProfile : BasePage
- {
- public Literal LtlUserName;
- public TextBox TbDisplayName;
- public TextBox TbEmail;
- public TextBox TbMobile;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (Page.IsPostBack) return;
-
- LtlUserName.Text = AuthRequest.AdminInfo.UserName;
- TbDisplayName.Text = AuthRequest.AdminInfo.DisplayName;
- TbEmail.Text = AuthRequest.AdminInfo.Email;
- TbMobile.Text = AuthRequest.AdminInfo.Mobile;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- AuthRequest.AdminInfo.DisplayName = TbDisplayName.Text;
- AuthRequest.AdminInfo.Email = TbEmail.Text;
- AuthRequest.AdminInfo.Mobile = TbMobile.Text;
-
- DataProvider.AdministratorDao.Update(AuthRequest.AdminInfo);
-
- SuccessMessage("资料更改成功");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/BaseHandler.cs b/SiteServer.BackgroundPages/BaseHandler.cs
deleted file mode 100644
index a91ea495a..000000000
--- a/SiteServer.BackgroundPages/BaseHandler.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Web;
-using SiteServer.Utils;
-using SiteServer.CMS.Plugin;
-
-namespace SiteServer.BackgroundPages
-{
- public abstract class BaseHandler : IHttpHandler
- {
- protected AuthRequest AuthRequest { get; private set; }
-
- public void ProcessRequest(HttpContext context)
- {
- AuthRequest = new AuthRequest(context.Request);
-
- if (!AuthRequest.IsAdminLoggin) return;
-
- Finish(Process());
- }
-
- protected abstract object Process();
-
- protected void Finish(object retval)
- {
- var response = HttpContext.Current.Response;
-
- response.ContentType = "application/json";
- response.Write(TranslateUtils.JsonSerialize(retval));
- response.End();
- }
-
- public bool IsReusable => false;
- }
-}
diff --git a/SiteServer.BackgroundPages/BasePage.cs b/SiteServer.BackgroundPages/BasePage.cs
deleted file mode 100644
index 5ec0fbc63..000000000
--- a/SiteServer.BackgroundPages/BasePage.cs
+++ /dev/null
@@ -1,255 +0,0 @@
-using System;
-using System.Web.UI;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-using SiteServer.CMS.Plugin;
-
-namespace SiteServer.BackgroundPages
-{
- public class BasePage : Page
- {
- private MessageUtils.Message.EMessageType _messageType;
- private string _message = string.Empty;
- private string _scripts = string.Empty;
-
- protected virtual bool IsAccessable => false; // 页面默认情况下是不能直接访问
-
- protected virtual bool IsSinglePage => false; // 是否为单页(即是否需要放在框架页内运行,false表示需要)
-
- public string IsNightly => WebConfigUtils.IsNightlyUpdate.ToString().ToLower(); // 系统是否允许升级到最新的开发版本
-
- public string Version => SystemManager.PluginVersion; // 系统采用的插件API版本号
-
- protected bool IsForbidden { get; private set; }
-
- public AuthRequest AuthRequest { get; private set; }
-
- private void SetMessage(MessageUtils.Message.EMessageType messageType, Exception ex, string message)
- {
- _messageType = messageType;
- _message = ex != null ? $"{message}" : message;
- }
-
- protected override void OnInit(EventArgs e)
- {
- base.OnInit(e);
-
- AuthRequest = new AuthRequest(Request);
-
- if (!IsAccessable) // 如果页面不能直接访问且又没有登录则直接跳登录页
- {
- if (!AuthRequest.IsAdminLoggin || AuthRequest.AdminInfo == null) // 检测管理员是否登录
- {
- IsForbidden = true;
- PageUtils.RedirectToLoginPage();
- return;
- }
-
- if (AuthRequest.AdminInfo.IsLockedOut) // 检测管理员帐号是否被锁定
- {
- IsForbidden = true;
- PageUtils.RedirectToLoginPage("对不起,您的账号已被锁定,无法进入系统!");
- return;
- }
- }
-
- //防止csrf攻击
- Response.AddHeader("X-Frame-Options", "SAMEORIGIN");
- //tell Chrome to disable its XSS protection
- Response.AddHeader("X-XSS-Protection", "0");
- }
-
- protected override void Render(HtmlTextWriter writer)
- {
- if (!string.IsNullOrEmpty(_message))
- {
- MessageUtils.SaveMessage(_messageType, _message);
- }
-
- base.Render(writer);
-
- if (!IsAccessable && !IsSinglePage) // 页面不能直接访问且不是单页,需要加一段框架检测代码,检测页面是否运行在框架内
- {
- writer.Write($@"");
- }
-
- if (!string.IsNullOrEmpty(_scripts))
- {
- writer.Write($@"");
- }
- }
-
- public void AddScript(string script)
- {
- _scripts += script;
- }
-
- public void AddWaitAndRedirectScript(string redirectUrl)
- {
- _scripts += $@"
-setTimeout(function() {{
- location.href = '{redirectUrl}';
-}}, 1500);
-";
- }
-
- public void AddWaitAndReloadMainPage()
- {
- _scripts += @"
-setTimeout(function() {{
- window.top.location.reload(true);
-}}, 1500);
-";
- }
-
- public void AddWaitAndScript(string scripts)
- {
- _scripts += $@"
-setTimeout(function() {{
- {scripts}
-}}, 1500);
-";
- }
-
- public void FailMessage(Exception ex, string message)
- {
- SetMessage(MessageUtils.Message.EMessageType.Error, ex, message);
- }
-
- public void FailMessage(string message)
- {
- SetMessage(MessageUtils.Message.EMessageType.Error, null, message);
- }
-
- public void SuccessMessage(string message)
- {
- SetMessage(MessageUtils.Message.EMessageType.Success, null, message);
- }
-
- public void SuccessMessage()
- {
- SuccessMessage("操作成功!");
- }
-
- public void InfoMessage(string message)
- {
- SetMessage(MessageUtils.Message.EMessageType.Info, null, message);
- }
-
- public void SuccessDeleteMessage()
- {
- SuccessMessage(MessageUtils.DeleteSuccess);
- }
-
- public void SuccessUpdateMessage()
- {
- SuccessMessage(MessageUtils.UpdateSuccess);
- }
-
- public void SuccessCheckMessage()
- {
- SuccessMessage(MessageUtils.CheckSuccess);
- }
-
- public void SuccessInsertMessage()
- {
- SuccessMessage(MessageUtils.InsertSuccess);
- }
-
- public void FailInsertMessage(Exception ex)
- {
- FailMessage(ex, MessageUtils.InsertFail);
- }
-
- public void FailUpdateMessage(Exception ex)
- {
- FailMessage(ex, MessageUtils.UpdateFail);
- }
-
- public void FailDeleteMessage(Exception ex)
- {
- FailMessage(ex, MessageUtils.DeleteFail);
- }
-
- public void FailCheckMessage(Exception ex)
- {
- FailMessage(ex, MessageUtils.CheckFail);
- }
-
- public string MaxLengthText(string str, int length)
- {
- return StringUtils.MaxLengthText(str, length);
- }
-
- public Control FindControlBySelfAndChildren(string controlId)
- {
- return ControlUtils.FindControlBySelfAndChildren(controlId, this);
- }
-
- public void VerifyAdministratorPermissions(params string[] permissionArray)
- {
- if (AuthRequest.AdminPermissions.HasAdministratorPermissions(permissionArray))
- {
- return;
- }
- AuthRequest.AdminLogout();
- PageUtils.Redirect(PageUtils.GetAdminDirectoryUrl(string.Empty));
- }
-
- public virtual void Submit_OnClick(object sender, EventArgs e)
- {
- LayerUtils.Close(Page);
- }
-
- public static string GetShowHintScript()
- {
- return GetShowHintScript("操作进行中");
- }
-
- public static string GetShowHintScript(string message)
- {
- return GetShowHintScript(message, 120);
- }
-
- public static string GetShowHintScript(string message, int top)
- {
- return $@"hideBoxAndShowHint(this, '{message}, 请稍候...', {top});";
- }
-
- public void ClientScriptRegisterClientScriptBlock(string key, string script)
- {
- if (!ClientScript.IsStartupScriptRegistered(key))
- {
- ClientScript.RegisterClientScriptBlock(GetType(), key, script);
- }
- }
-
- public void ClientScriptRegisterStartupScript(string key, string script)
- {
- if (!ClientScript.IsStartupScriptRegistered(key))
- {
- ClientScript.RegisterStartupScript(GetType(), key, script);
- }
- }
-
- public bool ClientScriptIsStartupScriptRegistered(string key)
- {
- return ClientScript.IsStartupScriptRegistered(key);
- }
-
- public static string GetShowImageScript(string imageClientId, string siteUrl)
- {
- return GetShowImageScript("this", imageClientId, siteUrl);
- }
-
- public static string GetShowImageScript(string objString, string imageClientId, string siteUrl)
- {
- return
- $"showImage({objString}, '{imageClientId}', '{PageUtils.ApplicationPath}', '{siteUrl}')";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalChannelEdit.cs b/SiteServer.BackgroundPages/Cms/ModalChannelEdit.cs
deleted file mode 100644
index 5b725dc99..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalChannelEdit.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalChannelEdit : BasePageCms
- {
- public PlaceHolder PhFilePath;
- public PlaceHolder PhLinkUrl;
- public PlaceHolder PhLinkType;
- public PlaceHolder PhChannelTemplateId;
-
- public TextBox TbNodeName;
- public TextBox TbNodeIndexName;
- public TextBox TbLinkUrl;
- public CheckBoxList CblNodeGroupNameCollection;
- public DropDownList DdlLinkType;
- public DropDownList DdlTaxisType;
- public DropDownList DdlChannelTemplateId;
- public DropDownList DdlContentTemplateId;
- public TextBox TbImageUrl;
- public Literal LtlImageUrlButtonGroup;
- public TextBox TbFilePath;
- public TextBox TbKeywords;
- public TextBox TbDescription;
-
- public TextEditorControl TbContent;
-
- public ChannelAuxiliaryControl CacAttributes;
-
- public Button BtnSubmit;
-
- private int _channelId;
- private string _returnUrl;
-
- public static string GetOpenWindowString(int siteId, int channelId, string returnUrl)
- {
- return LayerUtils.GetOpenScript("快速修改栏目", PageUtils.GetCmsUrl(siteId, nameof(ModalChannelEdit), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }));
- }
-
- public static string GetRedirectUrl(int siteId, int channelId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(ModalChannelEdit), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl");
- _channelId = AuthRequest.GetQueryInt("channelId");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
-
- CacAttributes.SiteInfo = SiteInfo;
- CacAttributes.ChannelId = _channelId;
-
- if (!IsPostBack)
- {
- if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ChannelEdit))
- {
- PageUtils.RedirectToErrorPage("您没有修改栏目的权限!");
- return;
- }
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- if (nodeInfo == null) return;
-
- if (nodeInfo.ParentId == 0)
- {
- PhLinkUrl.Visible = false;
- PhLinkType.Visible = false;
- PhChannelTemplateId.Visible = false;
- PhFilePath.Visible = false;
- }
-
- BtnSubmit.Attributes.Add("onclick", "if (UE && UE.getEditor('Content', {{allowDivTransToP: false}})){ UE.getEditor('Content', {{allowDivTransToP: false}}).sync(); }");
-
- CacAttributes.Attributes = nodeInfo.Additional;
-
- if (PhLinkType.Visible)
- {
- ELinkTypeUtils.AddListItems(DdlLinkType);
- }
-
- ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType);
-
- CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId);
- if (PhChannelTemplateId.Visible)
- {
- DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);
- }
- DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);
-
- DataBind();
-
- if (PhChannelTemplateId.Visible)
- {
- DdlChannelTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
- ControlUtils.SelectSingleItem(DdlChannelTemplateId, nodeInfo.ChannelTemplateId.ToString());
- }
-
- DdlContentTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
- ControlUtils.SelectSingleItem(DdlContentTemplateId, nodeInfo.ContentTemplateId.ToString());
-
- TbNodeName.Text = nodeInfo.ChannelName;
- TbNodeIndexName.Text = nodeInfo.IndexName;
- if (PhLinkUrl.Visible)
- {
- TbLinkUrl.Text = nodeInfo.LinkUrl;
- }
-
- foreach (ListItem item in CblNodeGroupNameCollection.Items)
- {
- item.Selected = StringUtils.In(nodeInfo.GroupNameCollection, item.Value);
- }
- if (PhFilePath.Visible)
- {
- TbFilePath.Text = nodeInfo.FilePath;
- }
-
- if (PhLinkType.Visible)
- {
- ControlUtils.SelectSingleItem(DdlLinkType, nodeInfo.LinkType);
- }
- ControlUtils.SelectSingleItem(DdlTaxisType, nodeInfo.Additional.DefaultTaxisType);
-
- TbImageUrl.Text = nodeInfo.ImageUrl;
- LtlImageUrlButtonGroup.Text = WebUtils.GetImageUrlButtonGroupHtml(SiteInfo, TbImageUrl.ClientID);
- TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, nodeInfo.Content);
- if (TbKeywords.Visible)
- {
- TbKeywords.Text = nodeInfo.Keywords;
- }
- if (TbDescription.Visible)
- {
- TbDescription.Text = nodeInfo.Description;
- }
- }
- else
- {
- CacAttributes.Attributes = new ExtendedAttributes(Request.Form);
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var isChanged = false;
-
- try
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
-
- if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
- {
- var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
- if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
- {
- FailMessage("栏目修改失败,栏目索引已存在!");
- return;
- }
- }
-
- if (PhFilePath.Visible)
- {
- TbFilePath.Text = TbFilePath.Text.Trim();
- if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
- {
- if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
- {
- FailMessage("栏目页面路径不符合系统要求!");
- return;
- }
-
- if (PathUtils.IsDirectoryPath(TbFilePath.Text))
- {
- TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
- }
-
- var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
- if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
- {
- FailMessage("栏目修改失败,栏目页面路径已存在!");
- return;
- }
- }
- }
-
- var extendedAttributes = new ExtendedAttributes();
- var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
- var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName,
- relatedIdentities);
- BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
- if (extendedAttributes.ToNameValueCollection().Count > 0)
- {
- nodeInfo.Additional.Load(extendedAttributes.ToNameValueCollection());
- }
-
- nodeInfo.ChannelName = TbNodeName.Text;
- nodeInfo.IndexName = TbNodeIndexName.Text;
- if (PhFilePath.Visible)
- {
- nodeInfo.FilePath = TbFilePath.Text;
- }
-
- var list = new ArrayList();
- foreach (ListItem item in CblNodeGroupNameCollection.Items)
- {
- if (item.Selected)
- {
- list.Add(item.Value);
- }
- }
- nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
- nodeInfo.ImageUrl = TbImageUrl.Text;
- nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
- if (TbKeywords.Visible)
- {
- nodeInfo.Keywords = TbKeywords.Text;
- }
- if (TbDescription.Visible)
- {
- nodeInfo.Description = TbDescription.Text;
- }
-
- if (PhLinkUrl.Visible)
- {
- nodeInfo.LinkUrl = TbLinkUrl.Text;
- }
- if (PhLinkType.Visible)
- {
- nodeInfo.LinkType = DdlLinkType.SelectedValue;
- }
- nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
- if (PhChannelTemplateId.Visible)
- {
- nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
- }
- nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;
-
- DataProvider.ChannelDao.Update(nodeInfo);
-
- AuthRequest.AddSiteLog(SiteId, _channelId, 0, "修改栏目", $"栏目:{nodeInfo.ChannelName}");
-
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, $"栏目修改失败:{ex.Message}");
- LogUtils.AddErrorLog(ex);
- }
-
- if (isChanged)
- {
- CreateManager.CreateChannel(SiteId, _channelId);
-
- if (string.IsNullOrEmpty(_returnUrl))
- {
- LayerUtils.Close(Page);
- }
- else
- {
- LayerUtils.CloseAndRedirect(Page, _returnUrl);
- }
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalCheckState.cs b/SiteServer.BackgroundPages/Cms/ModalCheckState.cs
deleted file mode 100644
index 5c6e536f7..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalCheckState.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalCheckState : BasePageCms
- {
- public Literal LtlTitle;
- public Literal LtlState;
- public PlaceHolder PhCheckReasons;
- public Repeater RptContents;
- public Button BtnCheck;
-
- private int _channelId;
- private string _tableName;
- private int _contentId;
- private string _returnUrl;
-
- public static string GetOpenWindowString(int siteId, ContentInfo contentInfo, string returnUrl)
- {
- return LayerUtils.GetOpenScript("审核状态",
- PageUtils.GetCmsUrl(siteId, nameof(ModalCheckState), new NameValueCollection
- {
- {"channelId", contentInfo.ChannelId.ToString()},
- {"contentID", contentInfo.Id.ToString()},
- {"returnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), 560, 500);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "contentID", "returnUrl");
-
- _channelId = AuthRequest.GetQueryInt("channelId");
- _tableName = ChannelManager.GetTableName(SiteInfo, _channelId);
- _contentId = AuthRequest.GetQueryInt("contentID");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl"));
-
- var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, _contentId);
-
- int checkedLevel;
- var isChecked = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, SiteId, out checkedLevel);
- BtnCheck.Visible = CheckManager.IsCheckable(SiteInfo, _channelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isChecked, checkedLevel);
-
- LtlTitle.Text = contentInfo.Title;
- LtlState.Text = CheckManager.GetCheckState(SiteInfo, contentInfo.IsChecked, contentInfo.CheckedLevel);
-
- var checkInfoList = DataProvider.ContentCheckDao.GetCheckInfoList(_tableName, _contentId);
- if (checkInfoList.Count > 0)
- {
- PhCheckReasons.Visible = true;
- RptContents.DataSource = checkInfoList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
- }
- }
-
- private static void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- var checkInfo = (ContentCheckInfo)e.Item.DataItem;
-
- var ltlUserName = (Literal)e.Item.FindControl("ltlUserName");
- var ltlCheckDate = (Literal)e.Item.FindControl("ltlCheckDate");
- var ltlReasons = (Literal)e.Item.FindControl("ltlReasons");
-
- ltlUserName.Text = AdminManager.GetDisplayName(checkInfo.UserName, true);
- ltlCheckDate.Text = DateUtils.GetDateAndTimeString(checkInfo.CheckDate);
- ltlReasons.Text = checkInfo.Reasons;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var redirectUrl = ModalContentCheck.GetRedirectUrl(SiteId, _channelId, _contentId, _returnUrl);
- PageUtils.Redirect(redirectUrl);
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalConfigurationCreateChannel.cs b/SiteServer.BackgroundPages/Cms/ModalConfigurationCreateChannel.cs
deleted file mode 100644
index 17711a5d3..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalConfigurationCreateChannel.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalConfigurationCreateChannel : BasePageCms
- {
- public DropDownList DdlIsCreateChannelIfContentChanged;
-
- protected ListBox LbChannelId;
-
- private int _channelId;
-
- public static string GetOpenWindowString(int siteId, int channelId)
- {
- return LayerUtils.GetOpenScript("栏目生成设置",
- PageUtils.GetCmsUrl(siteId, nameof(ModalConfigurationCreateChannel), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- }), 550, 500);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId");
- _channelId = AuthRequest.GetQueryInt("channelId");
-
- if (!IsPostBack)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
-
- EBooleanUtils.AddListItems(DdlIsCreateChannelIfContentChanged, "生成", "不生成");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateChannelIfContentChanged, nodeInfo.Additional.IsCreateChannelIfContentChanged.ToString());
-
- //NodeManager.AddListItemsForAddContent(this.channelIdCollection.Items, base.SiteInfo, false);
- ChannelManager.AddListItemsForCreateChannel(LbChannelId.Items, SiteInfo, false, AuthRequest.AdminPermissions);
- ControlUtils.SelectMultiItems(LbChannelId, TranslateUtils.StringCollectionToStringList(nodeInfo.Additional.CreateChannelIDsIfContentChanged));
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isSuccess = false;
-
- try
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
-
- nodeInfo.Additional.IsCreateChannelIfContentChanged = TranslateUtils.ToBool(DdlIsCreateChannelIfContentChanged.SelectedValue);
- nodeInfo.Additional.CreateChannelIDsIfContentChanged = ControlUtils.GetSelectedListControlValueCollection(LbChannelId);
-
- DataProvider.ChannelDao.Update(nodeInfo);
-
- AuthRequest.AddSiteLog(SiteId, _channelId, 0, "设置栏目变动生成页面", $"栏目:{nodeInfo.ChannelName}");
- isSuccess = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, ex.Message);
- }
-
- if (isSuccess)
- {
- LayerUtils.CloseAndRedirect(Page, PageConfigurationCreateTrigger.GetRedirectUrl(SiteId, _channelId));
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentArchive.cs b/SiteServer.BackgroundPages/Cms/ModalContentArchive.cs
deleted file mode 100644
index e6ef0c513..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentArchive.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentArchive : BasePageCms
- {
- private int _channelId;
- private string _returnUrl;
- private List _contentIdList;
-
- public static string GetOpenWindowString(int siteId, int channelId, string returnUrl)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("内容归档", PageUtils.GetCmsUrl(siteId, nameof(ModalContentArchive), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), "contentIdCollection", "请选择需要归档的内容!", 400, 230);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl", "contentIdCollection");
-
- _channelId = AuthRequest.GetQueryInt("channelId");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
- _contentIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection"));
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, _channelId);
- ArchiveManager.CreateArchiveTableIfNotExists(SiteInfo, tableName);
- var tableNameOfArchive = TableMetadataManager.GetTableNameOfArchive(tableName);
-
- foreach (var contentId in _contentIdList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- contentInfo.LastEditDate = DateTime.Now;
- DataProvider.ContentDao.Insert(tableNameOfArchive, SiteInfo, contentInfo);
- }
-
- DataProvider.ContentDao.DeleteContents(SiteId, tableName, _contentIdList, _channelId);
-
- CreateManager.CreateContentTrigger(SiteId, _channelId);
-
- AuthRequest.AddSiteLog(SiteId, _channelId, 0, "归档内容", string.Empty);
-
- LayerUtils.CloseAndRedirect(Page, _returnUrl);
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentAttributes.cs b/SiteServer.BackgroundPages/Cms/ModalContentAttributes.cs
deleted file mode 100644
index dab97a4cd..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentAttributes.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentAttributes : BasePageCms
- {
- protected CheckBox CbIsRecommend;
- protected CheckBox CbIsHot;
- protected CheckBox CbIsColor;
- protected CheckBox CbIsTop;
- protected HtmlInputHidden HihType;
- protected TextBox TbHits;
-
- private int _channelId;
- private string _tableName;
- private List _idList;
-
- public static string GetOpenWindowString(int siteId, int channelId)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("设置内容属性", PageUtils.GetCmsUrl(siteId, nameof(ModalContentAttributes), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- }), "contentIdCollection", "请选择需要设置属性的内容!", 450, 350);
- }
-
- public static string GetOpenWindowStringWithCheckBoxValue(int siteId, int channelId)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("设置内容属性", PageUtils.GetCmsUrl(siteId, nameof(ModalContentAttributes), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- }), "contentIdCollection", "请选择需要设置属性的内容!", 450, 350);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId");
-
- _channelId = AuthRequest.GetQueryInt("channelId");
- _tableName = ChannelManager.GetTableName(SiteInfo, _channelId);
- _idList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection"));
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- try
- {
- if (HihType.Value == "1")
- {
- if (CbIsRecommend.Checked || CbIsHot.Checked || CbIsColor.Checked || CbIsTop.Checked)
- {
- foreach (var contentId in _idList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
- if (contentInfo != null)
- {
- if (CbIsRecommend.Checked)
- {
- contentInfo.IsRecommend = true;
- }
- if (CbIsHot.Checked)
- {
- contentInfo.IsHot = true;
- }
- if (CbIsColor.Checked)
- {
- contentInfo.IsColor = true;
- }
- if (CbIsTop.Checked)
- {
- contentInfo.IsTop = true;
- }
- DataProvider.ContentDao.Update(_tableName, SiteInfo, contentInfo);
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, "设置内容属性");
-
- isChanged = true;
- }
- }
- else if (HihType.Value == "2")
- {
- if (CbIsRecommend.Checked || CbIsHot.Checked || CbIsColor.Checked || CbIsTop.Checked)
- {
- foreach (var contentId in _idList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
- if (contentInfo != null)
- {
- if (CbIsRecommend.Checked)
- {
- contentInfo.IsRecommend = false;
- }
- if (CbIsHot.Checked)
- {
- contentInfo.IsHot = false;
- }
- if (CbIsColor.Checked)
- {
- contentInfo.IsColor = false;
- }
- if (CbIsTop.Checked)
- {
- contentInfo.IsTop = false;
- }
- DataProvider.ContentDao.Update(_tableName, SiteInfo, contentInfo);
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, "取消内容属性");
-
- isChanged = true;
- }
- }
- else if (HihType.Value == "3")
- {
- var hits = TranslateUtils.ToInt(TbHits.Text);
-
- foreach (var contentId in _idList)
- {
- DataProvider.ContentDao.SetValue(_tableName, contentId, ContentAttribute.Hits, hits.ToString());
- }
-
- AuthRequest.AddSiteLog(SiteId, "设置内容点击量");
-
- isChanged = true;
- }
- }
- catch(Exception ex)
- {
- FailMessage(ex, ex.Message);
- isChanged = false;
- }
-
- if (isChanged)
- {
- LayerUtils.Close(Page);
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentCheck.cs b/SiteServer.BackgroundPages/Cms/ModalContentCheck.cs
deleted file mode 100644
index cbd4b0ab4..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentCheck.cs
+++ /dev/null
@@ -1,192 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentCheck : BasePageCms
- {
- public Literal LtlTitles;
- public DropDownList DdlCheckType;
- public DropDownList DdlTranslateChannelId;
- public TextBox TbCheckReasons;
-
- private Dictionary> _idsDictionary = new Dictionary>();
- private string _returnUrl;
-
- public static string GetOpenWindowString(int siteId, int channelId, string returnUrl)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("审核内容", PageUtils.GetCmsUrl(siteId, nameof(ModalContentCheck), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), "contentIdCollection", "请选择需要审核的内容!", 560, 550);
- }
-
- public static string GetOpenWindowStringForMultiChannels(int siteId, string returnUrl)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("审核内容", PageUtils.GetCmsUrl(siteId, nameof(ModalContentCheck), new NameValueCollection
- {
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), "IDsCollection", "请选择需要审核的内容!", 560, 550);
- }
-
- public static string GetOpenWindowString(int siteId, int channelId, int contentId, string returnUrl)
- {
- return LayerUtils.GetOpenScript("审核内容", PageUtils.GetCmsUrl(siteId, nameof(ModalContentCheck), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"contentIdCollection", contentId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), 560, 550);
- }
-
- public static string GetRedirectUrl(int siteId, int channelId, int contentId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(ModalContentCheck), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)},
- {"contentIdCollection", contentId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "ReturnUrl");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
-
- _idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString);
-
- if (IsPostBack) return;
-
- var titles = new StringBuilder();
- foreach (var channelId in _idsDictionary.Keys)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- var contentIdList = _idsDictionary[channelId];
- foreach (var contentId in contentIdList)
- {
- var title = DataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Title);
- titles.Append(title + " ");
- }
- }
-
- if (!string.IsNullOrEmpty(LtlTitles.Text))
- {
- titles.Length -= 6;
- }
- LtlTitles.Text = titles.ToString();
-
- var checkedLevel = 5;
- var isChecked = true;
-
- foreach (var channelId in _idsDictionary.Keys)
- {
- int checkedLevelByChannelId;
- var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, channelId, out checkedLevelByChannelId);
- if (checkedLevel > checkedLevelByChannelId)
- {
- checkedLevel = checkedLevelByChannelId;
- }
- if (!isCheckedByChannelId)
- {
- isChecked = false;
- }
- }
-
- CheckManager.LoadContentLevelToCheck(DdlCheckType, SiteInfo, isChecked, checkedLevel);
-
- var listItem = new ListItem("<保持原栏目不变>", "0");
- DdlTranslateChannelId.Items.Add(listItem);
-
- ChannelManager.AddListItemsForAddContent(DdlTranslateChannelId.Items, SiteInfo, true, AuthRequest.AdminPermissions);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlCheckType.SelectedValue);
-
- var isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;
-
- var contentInfoListToCheck = new List();
- var idsDictionaryToCheck = new Dictionary>();
- foreach (var channelId in _idsDictionary.Keys)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- var contentIdList = _idsDictionary[channelId];
- var contentIdListToCheck = new List();
-
- int checkedLevelOfUser;
- var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, channelId, out checkedLevelOfUser);
-
- foreach (var contentId in contentIdList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- if (contentInfo != null)
- {
- if (CheckManager.IsCheckable(SiteInfo, contentInfo.ChannelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
- {
- contentInfoListToCheck.Add(contentInfo);
- contentIdListToCheck.Add(contentId);
- }
-
- DataProvider.ContentDao.Update(tableName, SiteInfo, contentInfo);
-
- CreateManager.CreateContentAndTrigger(SiteId, contentInfo.ChannelId, contentId);
- }
- }
- if (contentIdListToCheck.Count > 0)
- {
- idsDictionaryToCheck[channelId] = contentIdListToCheck;
- }
- }
-
- if (contentInfoListToCheck.Count == 0)
- {
- LayerUtils.CloseWithoutRefresh(Page, "alert('您的审核权限不足,无法审核所选内容!');");
- return;
- }
-
- var translateChannelId = TranslateUtils.ToInt(DdlTranslateChannelId.SelectedValue);
-
- foreach (var channelId in idsDictionaryToCheck.Keys)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- var contentIdList = idsDictionaryToCheck[channelId];
- DataProvider.ContentDao.UpdateIsChecked(tableName, SiteId, channelId, contentIdList, translateChannelId, true, AuthRequest.AdminName, isChecked, checkedLevel, TbCheckReasons.Text);
-
- DataProvider.ChannelDao.UpdateContentNum(SiteInfo, channelId, true);
- }
-
- if (translateChannelId > 0)
- {
- DataProvider.ChannelDao.UpdateContentNum(SiteInfo, translateChannelId, true);
- }
-
- AuthRequest.AddSiteLog(SiteId, SiteId, 0, "设置内容状态为" + DdlCheckType.SelectedItem.Text, TbCheckReasons.Text);
-
- foreach (var channelId in idsDictionaryToCheck.Keys)
- {
- var contentIdList = _idsDictionary[channelId];
- if (contentIdList != null)
- {
- foreach (var contentId in contentIdList)
- {
- CreateManager.CreateContentAndTrigger(SiteId, channelId, contentId);
- }
- }
- }
-
- LayerUtils.CloseAndRedirect(Page, _returnUrl);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentCrossSiteTrans.cs b/SiteServer.BackgroundPages/Cms/ModalContentCrossSiteTrans.cs
deleted file mode 100644
index eb0042c36..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentCrossSiteTrans.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentCrossSiteTrans : BasePageCms
- {
- protected DropDownList DdlSiteId;
- protected ListBox LbChannelId;
-
- private int _channelId;
- private List _contentIdList;
-
- public static string GetOpenWindowString(int siteId, int channelId)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("跨站转发", PageUtils.GetCmsUrl(siteId, nameof(ModalContentCrossSiteTrans), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- }), "contentIdCollection", "请选择需要转发的内容!", 400, 410);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "contentIdCollection");
-
- _channelId = AuthRequest.GetQueryInt("channelId");
- _contentIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection"));
-
- if (IsPostBack) return;
-
- CrossSiteTransUtility.LoadSiteIdDropDownList(DdlSiteId, SiteInfo, _channelId);
-
- if (DdlSiteId.Items.Count > 0)
- {
- DdlSiteId_SelectedIndexChanged(null, EventArgs.Empty);
- }
- }
-
- public void DdlSiteId_SelectedIndexChanged(object sender, EventArgs e)
- {
- var psId = int.Parse(DdlSiteId.SelectedValue);
- CrossSiteTransUtility.LoadChannelIdListBox(LbChannelId, SiteInfo, psId, ChannelManager.GetChannelInfo(SiteId, _channelId), AuthRequest.AdminPermissions);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var targetSiteId = int.Parse(DdlSiteId.SelectedValue);
- var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
- try
- {
- foreach (ListItem listItem in LbChannelId.Items)
- {
- if (listItem.Selected)
- {
- var targetChannelId = TranslateUtils.ToInt(listItem.Value);
- if (targetChannelId != 0)
- {
- var targetTableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelId);
- var tableName = ChannelManager.GetTableName(SiteInfo, _channelId);
- foreach (var contentId in _contentIdList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- FileUtility.MoveFileByContentInfo(SiteInfo, targetSiteInfo, contentInfo);
- contentInfo.SiteId = targetSiteId;
- contentInfo.SourceId = contentInfo.ChannelId;
- contentInfo.ChannelId = targetChannelId;
-
- contentInfo.IsChecked = targetSiteInfo.Additional.IsCrossSiteTransChecked;
- contentInfo.CheckedLevel = 0;
-
- DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo);
- }
- }
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, _channelId, 0, "跨站转发", string.Empty);
-
- SuccessMessage("内容转发成功,请选择后续操作。");
- }
- catch (Exception ex)
- {
- FailMessage(ex, "内容转发失败!");
- }
-
- LayerUtils.Close(Page);
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentExport.cs b/SiteServer.BackgroundPages/Cms/ModalContentExport.cs
deleted file mode 100644
index 7ff410d22..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentExport.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentExport : BasePageCms
- {
- public DropDownList DdlExportType;
- public DropDownList DdlPeriods;
- public DateTimeTextBox TbStartDate;
- public DateTimeTextBox TbEndDate;
- public PlaceHolder PhDisplayAttributes;
- public CheckBoxList CblDisplayAttributes;
- public DropDownList DdlIsChecked;
-
- private int _channelId;
-
- public static string GetOpenWindowString(int siteId, int channelId)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("导出内容",
- PageUtils.GetCmsUrl(siteId, nameof(ModalContentExport), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- }), "contentIdCollection", string.Empty);
- }
-
- private void LoadDisplayAttributeCheckBoxList()
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
- var tableName = ChannelManager.GetTableName(SiteInfo, nodeInfo);
- var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetTableStyleInfoList(tableName, relatedIdentities));
-
- foreach (var styleInfo in styleInfoList)
- {
- var listItem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName)
- {
- Selected = true
- };
- CblDisplayAttributes.Items.Add(listItem);
- }
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _channelId = AuthRequest.GetQueryInt("channelId", SiteId);
- if (IsPostBack) return;
-
- LoadDisplayAttributeCheckBoxList();
- ConfigSettings(true);
- }
-
- private void ConfigSettings(bool isLoad)
- {
- if (isLoad)
- {
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigExportType))
- {
- DdlExportType.SelectedValue = SiteInfo.Additional.ConfigExportType;
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigExportPeriods))
- {
- DdlPeriods.SelectedValue = SiteInfo.Additional.ConfigExportPeriods;
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigExportDisplayAttributes))
- {
- var displayAttributes = TranslateUtils.StringCollectionToStringList(SiteInfo.Additional.ConfigExportDisplayAttributes);
- ControlUtils.SelectMultiItems(CblDisplayAttributes, displayAttributes);
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigExportIsChecked))
- {
- DdlIsChecked.SelectedValue = SiteInfo.Additional.ConfigExportIsChecked;
- }
- }
- else
- {
- SiteInfo.Additional.ConfigExportType = DdlExportType.SelectedValue;
- SiteInfo.Additional.ConfigExportPeriods = DdlPeriods.SelectedValue;
- SiteInfo.Additional.ConfigExportDisplayAttributes = ControlUtils.GetSelectedListControlValueCollection(CblDisplayAttributes);
- SiteInfo.Additional.ConfigExportIsChecked = DdlIsChecked.SelectedValue;
- DataProvider.SiteDao.Update(SiteInfo);
- }
- }
-
- public void DdlExportType_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhDisplayAttributes.Visible = DdlExportType.SelectedValue != "ContentZip";
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var displayAttributes = ControlUtils.GetSelectedListControlValueCollection(CblDisplayAttributes);
- if (PhDisplayAttributes.Visible && string.IsNullOrEmpty(displayAttributes))
- {
- FailMessage("必须至少选择一项!");
- return;
- }
-
- ConfigSettings(false);
-
- var isPeriods = false;
- var startDate = string.Empty;
- var endDate = string.Empty;
- if (DdlPeriods.SelectedValue != "0")
- {
- isPeriods = true;
- if (DdlPeriods.SelectedValue == "-1")
- {
- startDate = TbStartDate.Text;
- endDate = TbEndDate.Text;
- }
- else
- {
- var days = int.Parse(DdlPeriods.SelectedValue);
- startDate = DateUtils.GetDateString(DateTime.Now.AddDays(-days));
- endDate = DateUtils.GetDateString(DateTime.Now);
- }
- }
- var checkedState = ETriStateUtils.GetEnumType(DdlPeriods.SelectedValue);
- var redirectUrl = ModalExportMessage.GetRedirectUrlStringToExportContent(SiteId, _channelId, DdlExportType.SelectedValue, AuthRequest.GetQueryString("contentIdCollection"), displayAttributes, isPeriods, startDate, endDate, checkedState);
- PageUtils.Redirect(redirectUrl);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentGroupAdd.cs b/SiteServer.BackgroundPages/Cms/ModalContentGroupAdd.cs
deleted file mode 100644
index 783ef209b..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentGroupAdd.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentGroupAdd : BasePageCms
- {
- protected TextBox TbContentGroupName;
- public Literal LtlContentGroupName;
- protected TextBox TbDescription;
-
- public static string GetOpenWindowString(int siteId, string groupName)
- {
- return LayerUtils.GetOpenScript("修改内容组", PageUtils.GetCmsUrl(siteId, nameof(ModalContentGroupAdd), new NameValueCollection
- {
- {"GroupName", groupName}
- }), 600, 300);
- }
-
- public static string GetOpenWindowString(int siteId)
- {
- return LayerUtils.GetOpenScript("添加内容组", PageUtils.GetCmsUrl(siteId, nameof(ModalContentGroupAdd), null), 600, 300);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (!IsPostBack)
- {
- if (AuthRequest.IsQueryExists("GroupName"))
- {
- var groupName = AuthRequest.GetQueryString("GroupName");
- var contentGroupInfo = DataProvider.ContentGroupDao.GetContentGroupInfo(groupName, SiteId);
- if (contentGroupInfo != null)
- {
- TbContentGroupName.Text = contentGroupInfo.GroupName;
- TbContentGroupName.Visible = false;
- LtlContentGroupName.Text = $"{contentGroupInfo.GroupName} ";
- TbDescription.Text = contentGroupInfo.Description;
- }
- }
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- var contentGroupInfo = new ContentGroupInfo
- {
- GroupName = PageUtils.FilterXss(TbContentGroupName.Text),
- SiteId = SiteId,
- Description = TbDescription.Text
- };
-
- if (AuthRequest.IsQueryExists("GroupName"))
- {
- try
- {
- DataProvider.ContentGroupDao.Update(contentGroupInfo);
- AuthRequest.AddSiteLog(SiteId, "修改内容组", $"内容组:{contentGroupInfo.GroupName}");
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "内容组修改失败!");
- }
- }
- else
- {
- var contentGroupNameList = DataProvider.ContentGroupDao.GetGroupNameList(SiteId);
- if (contentGroupNameList.IndexOf(TbContentGroupName.Text) != -1)
- {
- FailMessage("内容组添加失败,内容组名称已存在!");
- }
- else
- {
- try
- {
- DataProvider.ContentGroupDao.Insert(contentGroupInfo);
- AuthRequest.AddSiteLog(SiteId, "添加内容组",
- $"内容组:{contentGroupInfo.GroupName}");
- isChanged = true;
- }
- catch(Exception ex)
- {
- FailMessage(ex, "内容组添加失败!");
- }
- }
- }
-
- if (isChanged)
- {
- LayerUtils.Close(Page);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentMultipleSelect.cs b/SiteServer.BackgroundPages/Cms/ModalContentMultipleSelect.cs
deleted file mode 100644
index 07039e06d..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentMultipleSelect.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentMultipleSelect : BasePageCms
- {
- public DropDownList DdlChannelId;
- public CheckBox CbIsDuplicate;
- public DropDownList DdlSearchType;
- public TextBox TbKeyword;
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
-
- public Repeater RptContents;
- public SqlPager SpContents;
-
- private ChannelInfo _channelInfo;
- private string _tableName;
- private List _relatedIdentities;
- private List _tableStyleInfoList;
- private string _jsMethod;
- private readonly Hashtable _valueHashtable = new Hashtable();
-
- public static string GetOpenWindowString(int siteId, string jsMethod)
- {
- return LayerUtils.GetOpenScript("选择内容", PageUtils.GetCmsUrl(siteId, nameof(ModalContentMultipleSelect), new NameValueCollection
- {
- {"jsMethod", jsMethod}
- }));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _jsMethod = AuthRequest.GetQueryString("jsMethod");
-
- PageUtils.CheckRequestParameter("siteId");
- var channelId = AuthRequest.GetQueryInt("channelId");
- if (channelId == 0)
- {
- channelId = SiteId;
- }
- _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- _tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo);
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelInfo.Id);
- _tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.SelectCommand = string.IsNullOrEmpty(AuthRequest.GetQueryString("channelId"))
- ? DataProvider.ContentDao.GetSqlString(_tableName, SiteId,
- _channelInfo.Id, AuthRequest.AdminPermissions.IsSystemAdministrator,
- AuthRequest.AdminPermissions.OwningChannelIdList, DdlSearchType.SelectedValue, TbKeyword.Text,
- TbDateFrom.Text, TbDateTo.Text, true, ETriState.True, !CbIsDuplicate.Checked, false)
- : DataProvider.ContentDao.GetSqlString(_tableName, SiteId,
- _channelInfo.Id, AuthRequest.AdminPermissions.IsSystemAdministrator,
- AuthRequest.AdminPermissions.OwningChannelIdList, AuthRequest.GetQueryString("SearchType"),
- AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryString("DateFrom"), AuthRequest.GetQueryString("DateTo"), true,
- ETriState.True, !AuthRequest.GetQueryBool("IsDuplicate"), true);
- SpContents.ItemsPerPage = SiteInfo.Additional.PageSize;
- SpContents.SortField = ContentAttribute.Id;
- SpContents.SortMode = SortMode.DESC;
- SpContents.OrderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (IsPostBack) return;
-
- ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, false, true, AuthRequest.AdminPermissions);
-
- if (_tableStyleInfoList != null)
- {
- foreach (var styleInfo in _tableStyleInfoList)
- {
- var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
- DdlSearchType.Items.Add(listitem);
- }
- }
-
- //添加隐藏属性
- DdlSearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id));
- DdlSearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName));
- DdlSearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName));
-
- if (AuthRequest.IsQueryExists("channelId"))
- {
- if (SiteId != _channelInfo.Id)
- {
- ControlUtils.SelectSingleItem(DdlChannelId, _channelInfo.Id.ToString());
- }
- CbIsDuplicate.Checked = AuthRequest.GetQueryBool("IsDuplicate");
- ControlUtils.SelectSingleItem(DdlSearchType, AuthRequest.GetQueryString("SearchType"));
- TbKeyword.Text = AuthRequest.GetQueryString("Keyword");
- TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom");
- TbDateTo.Text = AuthRequest.GetQueryString("DateTo");
- }
-
- SpContents.DataBind();
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
- {
- var ltlChannel = (Literal)e.Item.FindControl("ltlChannel");
- var ltlTitle = (Literal)e.Item.FindControl("ltlTitle");
- var ltlSelect = (Literal)e.Item.FindControl("ltlSelect");
-
- var contentInfo = new ContentInfo(e.Item.DataItem);
-
- var nodeName = _valueHashtable[contentInfo.ChannelId] as string;
- if (nodeName == null)
- {
- nodeName = ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId);
- _valueHashtable[contentInfo.ChannelId] = nodeName;
- }
- ltlChannel.Text = nodeName;
-
- ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);
-
- ltlSelect.Text =
- $@" ";
- }
- }
-
- public void AddContent_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(WebUtils.GetContentAddAddUrl(SiteId, _channelInfo, PageUrl));
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- Response.Redirect(PageUrl, true);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!string.IsNullOrEmpty(Request.Form["IDsCollection"]))
- {
- var builder = new StringBuilder();
- foreach (var pair in TranslateUtils.StringCollectionToStringList(Request.Form["IDsCollection"]))
- {
- var channelId = TranslateUtils.ToInt(pair.Split('_')[0]);
- var contentId = TranslateUtils.ToInt(pair.Split('_')[1]);
-
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- var title = DataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Title);
- builder.Append($@"parent.{_jsMethod}('{title}', '{pair}');");
- }
- LayerUtils.CloseWithoutRefresh(Page, builder.ToString());
- }
- else
- {
- LayerUtils.CloseWithoutRefresh(Page);
- }
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl = PageUtils.GetCmsUrl(SiteId, nameof(ModalContentMultipleSelect), new NameValueCollection
- {
- {"channelId", DdlChannelId.SelectedValue},
- {"IsDuplicate", CbIsDuplicate.Checked.ToString()},
- {"SearchType", DdlSearchType.SelectedValue},
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text}
- });
- }
- return _pageUrl;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentTagAdd.cs b/SiteServer.BackgroundPages/Cms/ModalContentTagAdd.cs
deleted file mode 100644
index 3e2746440..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentTagAdd.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentTagAdd : BasePageCms
- {
- protected TextBox TbTags;
-
- private string _tagName;
-
- public static string GetOpenWindowStringToAdd(int siteId)
- {
- return LayerUtils.GetOpenScript("添加标签", PageUtils.GetCmsUrl(siteId, nameof(ModalContentTagAdd), null), 600, 360);
- }
-
- public static string GetOpenWindowStringToEdit(int siteId, string tagName)
- {
- return LayerUtils.GetOpenScript("修改标签", PageUtils.GetCmsUrl(siteId, nameof(ModalContentTagAdd), new NameValueCollection
- {
- {"TagName", tagName}
- }), 600, 360);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _tagName = AuthRequest.GetQueryString("TagName");
-
- if (IsPostBack) return;
-
- if (!string.IsNullOrEmpty(_tagName))
- {
- TbTags.Text = _tagName;
-
- var count = DataProvider.TagDao.GetTagCount(_tagName, SiteId);
-
- InfoMessage($@"标签“{_tagName} ”被使用 {count} 次,编辑此标签将更新所有使用此标签的内容。");
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- if (!string.IsNullOrEmpty(_tagName))
- {
- try
- {
- if (!string.Equals(_tagName, TbTags.Text))
- {
- var tagCollection = TagUtils.ParseTagsString(TbTags.Text);
- var contentIdList = DataProvider.TagDao.GetContentIdListByTag(_tagName, SiteId);
- if (contentIdList.Count > 0)
- {
- foreach (int contentId in contentIdList)
- {
- if (!tagCollection.Contains(_tagName))//删除
- {
- var tagInfo = DataProvider.TagDao.GetTagInfo(SiteId, _tagName);
- if (tagInfo != null)
- {
- var idArrayList = TranslateUtils.StringCollectionToIntList(tagInfo.ContentIdCollection);
- idArrayList.Remove(contentId);
- tagInfo.ContentIdCollection = TranslateUtils.ObjectCollectionToString(idArrayList);
- tagInfo.UseNum = idArrayList.Count;
- DataProvider.TagDao.Update(tagInfo);
- }
- }
-
- TagUtils.AddTags(tagCollection, SiteId, contentId);
-
- var contentTags = DataProvider.ContentDao.GetValue(SiteInfo.TableName, contentId, ContentAttribute.Tags);
- var contentTagArrayList = TranslateUtils.StringCollectionToStringList(contentTags);
- contentTagArrayList.Remove(_tagName);
- foreach (var theTag in tagCollection)
- {
- if (!contentTagArrayList.Contains(theTag))
- {
- contentTagArrayList.Add(theTag);
- }
- }
- DataProvider.ContentDao.SetValue(SiteInfo.TableName, contentId, ContentAttribute.Tags, TranslateUtils.ObjectCollectionToString(contentTagArrayList));
- }
- }
- else
- {
- DataProvider.TagDao.DeleteTag(_tagName, SiteId);
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, "修改内容标签", $"内容标签:{TbTags.Text}");
-
- isChanged = true;
- }
- catch(Exception ex)
- {
- FailMessage(ex, "标签修改失败!");
- }
- }
- else
- {
- try
- {
- var tagCollection = TagUtils.ParseTagsString(TbTags.Text);
- TagUtils.AddTags(tagCollection, SiteId, 0);
- AuthRequest.AddSiteLog(SiteId, "添加内容标签", $"内容标签:{TbTags.Text}");
- isChanged = true;
- }
- catch(Exception ex)
- {
- FailMessage(ex, "标签添加失败!");
- }
- }
-
- if (isChanged)
- {
- LayerUtils.Close(Page);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalContentTaxis.cs b/SiteServer.BackgroundPages/Cms/ModalContentTaxis.cs
deleted file mode 100644
index ce720faaf..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalContentTaxis.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalContentTaxis : BasePageCms
- {
- protected DropDownList DdlTaxisType;
- protected TextBox TbTaxisNum;
-
- private int _channelId;
- private string _returnUrl;
- private List _contentIdList;
- private string _tableName;
-
- public static string GetOpenWindowString(int siteId, int channelId, string returnUrl)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("内容排序", PageUtils.GetCmsUrl(siteId, nameof(ModalContentTaxis), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), "contentIdCollection", "请选择需要排序的内容!", 400, 280);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl", "contentIdCollection");
-
- _channelId = AuthRequest.GetQueryInt("channelId");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
- _contentIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection"));
- _tableName = ChannelManager.GetTableName(SiteInfo, _channelId);
-
- if (IsPostBack) return;
-
- DdlTaxisType.Items.Add(new ListItem("上升", "Up"));
- DdlTaxisType.Items.Add(new ListItem("下降", "Down"));
- ControlUtils.SelectSingleItem(DdlTaxisType, "Up");
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isUp = DdlTaxisType.SelectedValue == "Up";
- var taxisNum = TranslateUtils.ToInt(TbTaxisNum.Text);
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- if (ETaxisTypeUtils.Equals(nodeInfo.Additional.DefaultTaxisType, ETaxisType.OrderByTaxis))
- {
- isUp = !isUp;
- }
-
- if (isUp == false)
- {
- _contentIdList.Reverse();
- }
-
- foreach (var contentId in _contentIdList)
- {
- var isTop = TranslateUtils.ToBool(DataProvider.ContentDao.GetValue(_tableName, contentId, ContentAttribute.IsTop));
- for (var i = 1; i <= taxisNum; i++)
- {
- if (isUp)
- {
- if (DataProvider.ContentDao.UpdateTaxisToUp(_tableName, _channelId, contentId, isTop) == false)
- {
- break;
- }
- }
- else
- {
- if (DataProvider.ContentDao.UpdateTaxisToDown(_tableName, _channelId, contentId, isTop) == false)
- {
- break;
- }
- }
- }
- }
-
- CreateManager.CreateContentTrigger(SiteId, _channelId);
-
- AuthRequest.AddSiteLog(SiteId, _channelId, 0, "对内容排序", string.Empty);
-
- LayerUtils.CloseAndRedirect(Page, _returnUrl);
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalCrossSiteTransEdit.cs b/SiteServer.BackgroundPages/Cms/ModalCrossSiteTransEdit.cs
deleted file mode 100644
index f6c5522ec..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalCrossSiteTransEdit.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalCrossSiteTransEdit : BasePageCms
- {
- public DropDownList DdlTransType;
- public PlaceHolder PhSite;
- public DropDownList DdlSiteId;
- public ListBox LbChannelId;
- public PlaceHolder PhNodeNames;
- public TextBox TbNodeNames;
- public PlaceHolder PhIsAutomatic;
- public DropDownList DdlIsAutomatic;
- public DropDownList DdlTranslateDoneType;
-
- private ChannelInfo _channelInfo;
-
- public static string GetOpenWindowString(int siteId, int channelId)
- {
- return LayerUtils.GetOpenScript("跨站转发设置", PageUtils.GetCmsUrl(siteId, nameof(ModalCrossSiteTransEdit), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- }));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId");
- var channelId = int.Parse(AuthRequest.GetQueryString("channelId"));
- _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
-
- if (IsPostBack) return;
-
- ECrossSiteTransTypeUtils.AddAllListItems(DdlTransType, SiteInfo.ParentId > 0);
-
- ControlUtils.SelectSingleItem(DdlTransType, ECrossSiteTransTypeUtils.GetValue(_channelInfo.Additional.TransType));
-
- DdlTransType_OnSelectedIndexChanged(null, EventArgs.Empty);
- ControlUtils.SelectSingleItem(DdlSiteId, _channelInfo.Additional.TransSiteId.ToString());
-
-
- DdlSiteId_OnSelectedIndexChanged(null, EventArgs.Empty);
- ControlUtils.SelectMultiItems(LbChannelId, TranslateUtils.StringCollectionToStringList(_channelInfo.Additional.TransChannelIds));
- TbNodeNames.Text = _channelInfo.Additional.TransChannelNames;
-
- EBooleanUtils.AddListItems(DdlIsAutomatic, "系统自动转发", "需手动操作");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsAutomatic, _channelInfo.Additional.TransIsAutomatic.ToString());
-
- ETranslateContentTypeUtils.AddListItems(DdlTranslateDoneType, false);
- ControlUtils.SelectSingleItem(DdlTranslateDoneType, ETranslateContentTypeUtils.GetValue(_channelInfo.Additional.TransDoneType));
- }
-
- protected void DdlTransType_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- DdlSiteId.Items.Clear();
- DdlSiteId.Enabled = true;
-
- PhIsAutomatic.Visible = false;
-
- var contributeType = ECrossSiteTransTypeUtils.GetEnumType(DdlTransType.SelectedValue);
- if (contributeType == ECrossSiteTransType.None)
- {
- PhSite.Visible = PhNodeNames.Visible = false;
- }
- else if (contributeType == ECrossSiteTransType.SelfSite || contributeType == ECrossSiteTransType.SpecifiedSite)
- {
- PhSite.Visible = true;
- PhNodeNames.Visible = false;
-
- PhIsAutomatic.Visible = true;
- }
- else if (contributeType == ECrossSiteTransType.ParentSite)
- {
- PhSite.Visible = true;
- PhNodeNames.Visible = false;
- DdlSiteId.Enabled = false;
-
- PhIsAutomatic.Visible = true;
- }
- else if (contributeType == ECrossSiteTransType.AllParentSite || contributeType == ECrossSiteTransType.AllSite)
- {
- PhSite.Visible = false;
- PhNodeNames.Visible = true;
- }
-
- if (PhSite.Visible)
- {
- var siteIdList = SiteManager.GetSiteIdList();
-
- var allParentSiteIdList = new List();
- if (contributeType == ECrossSiteTransType.AllParentSite)
- {
- SiteManager.GetAllParentSiteIdList(allParentSiteIdList, siteIdList, SiteId);
- }
- else if (contributeType == ECrossSiteTransType.SelfSite)
- {
- siteIdList = new List
- {
- SiteId
- };
- }
-
- foreach (var psId in siteIdList)
- {
- var psInfo = SiteManager.GetSiteInfo(psId);
- var show = false;
- if (contributeType == ECrossSiteTransType.SpecifiedSite)
- {
- show = true;
- }
- else if (contributeType == ECrossSiteTransType.SelfSite)
- {
- if (psId == SiteId)
- {
- show = true;
- }
- }
- else if (contributeType == ECrossSiteTransType.ParentSite)
- {
- if (psInfo.Id == SiteInfo.ParentId || (SiteInfo.ParentId == 0 && psInfo.IsRoot))
- {
- show = true;
- }
- }
- if (!show) continue;
-
- var listitem = new ListItem(psInfo.SiteName, psId.ToString());
- if (psInfo.IsRoot) listitem.Selected = true;
- DdlSiteId.Items.Add(listitem);
- }
- }
- DdlSiteId_OnSelectedIndexChanged(sender, e);
- }
-
- protected void DdlSiteId_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- LbChannelId.Items.Clear();
- if (PhSite.Visible && DdlSiteId.Items.Count > 0)
- {
- ChannelManager.AddListItemsForAddContent(LbChannelId.Items, SiteManager.GetSiteInfo(int.Parse(DdlSiteId.SelectedValue)), false, AuthRequest.AdminPermissions);
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isSuccess = false;
-
- try
- {
- _channelInfo.Additional.TransType = ECrossSiteTransTypeUtils.GetEnumType(DdlTransType.SelectedValue);
- _channelInfo.Additional.TransSiteId = _channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite ? TranslateUtils.ToInt(DdlSiteId.SelectedValue) : 0;
- _channelInfo.Additional.TransChannelIds = ControlUtils.GetSelectedListControlValueCollection(LbChannelId);
- _channelInfo.Additional.TransChannelNames = TbNodeNames.Text;
-
- _channelInfo.Additional.TransIsAutomatic = TranslateUtils.ToBool(DdlIsAutomatic.SelectedValue);
-
- var translateDoneType = ETranslateContentTypeUtils.GetEnumType(DdlTranslateDoneType.SelectedValue);
- _channelInfo.Additional.TransDoneType = translateDoneType;
-
- DataProvider.ChannelDao.Update(_channelInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改跨站转发设置");
-
- isSuccess = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, ex.Message);
- }
-
- if (isSuccess)
- {
- LayerUtils.Close(Page);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalExportMessage.cs b/SiteServer.BackgroundPages/Cms/ModalExportMessage.cs
deleted file mode 100644
index c0658b6ba..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalExportMessage.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Api;
-using SiteServer.CMS.Api.Sys.Stl;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Office;
-using SiteServer.CMS.ImportExport;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalExportMessage : BasePageCms
- {
- public const int Width = 580;
- public const int Height = 250;
- public const string ExportTypeContentZip = "ContentZip";
- public const string ExportTypeContentAccess = "ContentAccess";
- public const string ExportTypeContentExcel = "ContentExcel";
- public const string ExportTypeContentTxtZip = "ContentTxtZip";
- public const string ExportTypeRelatedField = "RelatedField";
- public const string ExportTypeChannel = "Channel";
- public const string ExportTypeSingleTableStyle = "SingleTableStyle";
-
- private string _exportType;
-
- public static string GetRedirectUrlStringToExportContent(int siteId, int channelId,
- string exportType, string contentIdCollection, string displayAttributes, bool isPeriods,
- string startDate, string endDate, ETriState checkedState)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(ModalExportMessage), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ExportType", exportType},
- {"contentIdCollection", contentIdCollection},
- {"DisplayAttributes", displayAttributes},
- {"isPeriods", isPeriods.ToString()},
- {"startDate", startDate},
- {"endDate", endDate},
- {"checkedState", ETriStateUtils.GetValue(checkedState)}
- });
- }
-
- public static string GetOpenWindowStringToChannel(int siteId, string checkBoxId, string alertString)
- {
- return LayerUtils.GetOpenScriptWithCheckBoxValue("导出数据",
- PageUtils.GetCmsUrl(siteId, nameof(ModalExportMessage), new NameValueCollection
- {
- {"ExportType", ExportTypeChannel}
- }), checkBoxId, alertString, Width, Height);
- }
-
- public static string GetOpenWindowStringToSingleTableStyle(string tableName, int siteId, int relatedIdentity)
- {
- return LayerUtils.GetOpenScript("导出数据",
- PageUtils.GetCmsUrl(siteId, nameof(ModalExportMessage), new NameValueCollection
- {
- {"TableName", tableName},
- {"ExportType", ExportTypeSingleTableStyle},
- {"RelatedIdentity", relatedIdentity.ToString()}
- }), Width, Height);
- }
-
- public static string GetOpenWindowStringToRelatedField(int siteId, int relatedFieldId)
- {
- return LayerUtils.GetOpenScript("导出数据",
- PageUtils.GetCmsUrl(siteId, nameof(ModalExportMessage), new NameValueCollection
- {
- {"RelatedFieldID", relatedFieldId.ToString()},
- {"ExportType", ExportTypeRelatedField}
- }), Width, Height);
- }
-
- public static string GetOpenWindowStringToExport(int siteId, string exportType)
- {
- return LayerUtils.GetOpenScript("导出数据",
- PageUtils.GetCmsUrl(siteId, nameof(ModalExportMessage), new NameValueCollection
- {
- {"ExportType", exportType}
- }), Width, Height);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _exportType = AuthRequest.GetQueryString("ExportType");
-
- if (!IsPostBack)
- {
- var isExport = true;
- var fileName = string.Empty;
- try
- {
- if (_exportType == ExportTypeRelatedField)
- {
- var relatedFieldId = AuthRequest.GetQueryInt("RelatedFieldID");
- fileName = ExportRelatedField(relatedFieldId);
- }
- else if (_exportType == ExportTypeContentZip)
- {
- var channelId = AuthRequest.GetQueryInt("channelId");
- var contentIdCollection = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection"));
- var isPeriods = AuthRequest.GetQueryBool("isPeriods");
- var startDate = AuthRequest.GetQueryString("startDate");
- var endDate = AuthRequest.GetQueryString("endDate");
- var checkedState = ETriStateUtils.GetEnumType(AuthRequest.GetQueryString("checkedState"));
- isExport = ExportContentZip(channelId, contentIdCollection, isPeriods, startDate, endDate, checkedState, out fileName);
- }
- else if (_exportType == ExportTypeContentAccess)
- {
- var channelId = AuthRequest.GetQueryInt("channelId");
- var contentIdCollection = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection"));
- var displayAttributes = TranslateUtils.StringCollectionToStringList(AuthRequest.GetQueryString("DisplayAttributes"));
- var isPeriods = AuthRequest.GetQueryBool("isPeriods");
- var startDate = AuthRequest.GetQueryString("startDate");
- var endDate = AuthRequest.GetQueryString("endDate");
- var checkedState = ETriStateUtils.GetEnumType(AuthRequest.GetQueryString("checkedState"));
- isExport = ExportContentAccess(channelId, contentIdCollection, displayAttributes, isPeriods, startDate, endDate, checkedState, out fileName);
- }
- else if (_exportType == ExportTypeContentExcel)
- {
- var channelId = AuthRequest.GetQueryInt("channelId");
- var contentIdCollection = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("contentIdCollection"));
- var displayAttributes = TranslateUtils.StringCollectionToStringList(AuthRequest.GetQueryString("DisplayAttributes"));
- var isPeriods = AuthRequest.GetQueryBool("isPeriods");
- var startDate = AuthRequest.GetQueryString("startDate");
- var endDate = AuthRequest.GetQueryString("endDate");
- var checkedState = ETriStateUtils.GetEnumType(AuthRequest.GetQueryString("checkedState"));
- ExportContentExcel(channelId, contentIdCollection, displayAttributes, isPeriods, startDate, endDate, checkedState, out fileName);
- }
- else if (_exportType == ExportTypeChannel)
- {
- var channelIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("ChannelIDCollection"));
- fileName = ExportChannel(channelIdList);
- }
- else if (_exportType == ExportTypeSingleTableStyle)
- {
- var tableName = AuthRequest.GetQueryString("TableName");
- var relatedIdentity = AuthRequest.GetQueryInt("RelatedIdentity");
- fileName = ExportSingleTableStyle(tableName, relatedIdentity);
- }
-
- if (isExport)
- {
- var link = new HyperLink();
- var filePath = PathUtils.GetTemporaryFilesPath(fileName);
- link.NavigateUrl = ApiRouteActionsDownload.GetUrl(ApiManager.InnerApiUrl, filePath);
- link.Text = "下载";
- var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link);
- SuccessMessage(successMessage);
- }
- else
- {
- FailMessage("导出失败,所选条件没有匹配内容,请重新选择条件导出内容");
- }
- }
- catch (Exception ex)
- {
- var failedMessage = "文件导出失败! 原因为:" + ex.Message;
- FailMessage(ex, failedMessage);
- }
- }
- }
-
- private string ExportRelatedField(int relatedFieldId)
- {
- var exportObject = new ExportObject(SiteId, AuthRequest.AdminName);
- return exportObject.ExportRelatedField(relatedFieldId);
- }
-
- private bool ExportContentZip(int channelId, List contentIdArrayList, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState, out string fileName)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- fileName = $"{nodeInfo.ChannelName}.zip";
- var filePath = PathUtils.GetTemporaryFilesPath(fileName);
- var exportObject = new ExportObject(SiteId, AuthRequest.AdminName);
- return exportObject.ExportContents(filePath, channelId, contentIdArrayList, isPeriods, dateFrom, dateTo, checkedState);
- }
-
- private bool ExportContentAccess(int channelId, List contentIdArrayList, List displayAttributes, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState, out string fileName)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- fileName = $"{nodeInfo.ChannelName}.mdb";
- var filePath = PathUtils.GetTemporaryFilesPath(fileName);
- return AccessObject.CreateAccessFileForContents(filePath, SiteInfo, nodeInfo, contentIdArrayList, displayAttributes, isPeriods, dateFrom, dateTo, checkedState);
- }
-
- private void ExportContentExcel(int channelId, List contentIdList, List displayAttributes, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState, out string fileName)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
-
- fileName = $"{nodeInfo.ChannelName}.csv";
- var filePath = PathUtils.GetTemporaryFilesPath(fileName);
- ExcelObject.CreateExcelFileForContents(filePath, SiteInfo, nodeInfo, contentIdList, displayAttributes, isPeriods, dateFrom, dateTo, checkedState);
- }
-
- private string ExportChannel(List channelIdList)
- {
- var exportObject = new ExportObject(SiteId, AuthRequest.AdminName);
- return exportObject.ExportChannels(channelIdList);
- }
-
- private string ExportSingleTableStyle(string tableName, int relatedIdentity)
- {
- var exportObject = new ExportObject(SiteId, AuthRequest.AdminName);
- return exportObject.ExportSingleTableStyle(tableName, relatedIdentity);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalNodeGroupAdd.cs b/SiteServer.BackgroundPages/Cms/ModalNodeGroupAdd.cs
deleted file mode 100644
index e13482d6e..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalNodeGroupAdd.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalNodeGroupAdd : BasePageCms
- {
- public TextBox TbNodeGroupName;
- public Literal LtlNodeGroupName;
- public TextBox TbDescription;
-
- public static string GetOpenWindowString(int siteId, string groupName)
- {
- return LayerUtils.GetOpenScript("修改栏目组", PageUtils.GetCmsUrl(siteId, nameof(ModalNodeGroupAdd), new NameValueCollection
- {
- {"GroupName", groupName}
- }), 600, 300);
- }
-
- public static string GetOpenWindowString(int siteId)
- {
- return LayerUtils.GetOpenScript("添加栏目组", PageUtils.GetCmsUrl(siteId, nameof(ModalNodeGroupAdd), null), 600, 300);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (IsPostBack) return;
-
- if (AuthRequest.IsQueryExists("GroupName"))
- {
- var groupName = AuthRequest.GetQueryString("GroupName");
- var nodeGroupInfo = DataProvider.ChannelGroupDao.GetGroupInfo(SiteId, groupName);
- if (nodeGroupInfo != null)
- {
- TbNodeGroupName.Text = nodeGroupInfo.GroupName;
- TbNodeGroupName.Visible = false;
- LtlNodeGroupName.Text = $"{nodeGroupInfo.GroupName} ";
- TbDescription.Text = nodeGroupInfo.Description;
- }
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- var nodeGroupInfo = new ChannelGroupInfo
- {
- GroupName = TbNodeGroupName.Text,
- SiteId = SiteId,
- Description = TbDescription.Text
- };
-
- if (AuthRequest.IsQueryExists("GroupName"))
- {
- try
- {
- DataProvider.ChannelGroupDao.Update(nodeGroupInfo);
- AuthRequest.AddSiteLog(SiteId, "修改栏目组", $"栏目组:{nodeGroupInfo.GroupName}");
- isChanged = true;
- }
- catch(Exception ex)
- {
- FailMessage(ex, "栏目组修改失败!");
- }
- }
- else
- {
- var nodeGroupNameList = DataProvider.ChannelGroupDao.GetGroupNameList(SiteId);
- if (nodeGroupNameList.IndexOf(TbNodeGroupName.Text) != -1)
- {
- FailMessage("栏目组添加失败,栏目组名称已存在!");
- }
- else
- {
- try
- {
- DataProvider.ChannelGroupDao.Insert(nodeGroupInfo);
- AuthRequest.AddSiteLog(SiteId, "添加栏目组", $"栏目组:{nodeGroupInfo.GroupName}");
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "栏目组添加失败!");
- }
- }
- }
-
- if (isChanged)
- {
- LayerUtils.Close(Page);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalSelectColumns.cs b/SiteServer.BackgroundPages/Cms/ModalSelectColumns.cs
deleted file mode 100644
index af1cbb4ea..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalSelectColumns.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalSelectColumns : BasePageCms
- {
- public CheckBoxList CblDisplayAttributes;
-
- private int _relatedIdentity;
- private List _relatedIdentities;
- private bool _isList;
-
- public static string GetOpenWindowString(int siteId, int relatedIdentity, bool isList)
- {
- return LayerUtils.GetOpenScript("选择需要显示的项", PageUtils.GetCmsUrl(siteId, nameof(ModalSelectColumns), new NameValueCollection
- {
- {"RelatedIdentity", relatedIdentity.ToString()},
- {"IsList", isList.ToString()}
- }), 0, 550);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- _relatedIdentity = AuthRequest.GetQueryInt("RelatedIdentity");
- _isList = AuthRequest.GetQueryBool("IsList");
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _relatedIdentity);
- var tableName = ChannelManager.GetTableName(SiteInfo, nodeInfo);
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _relatedIdentity);
- var attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(nodeInfo.Additional.ContentAttributesOfDisplay);
-
- if (IsPostBack) return;
-
- var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetTableStyleInfoList(tableName, _relatedIdentities));
- foreach (var styleInfo in styleInfoList)
- {
- var listitem = new ListItem($"{styleInfo.DisplayName}({styleInfo.AttributeName})", styleInfo.AttributeName);
- if (styleInfo.AttributeName == ContentAttribute.Title)
- {
- listitem.Selected = true;
- }
- else
- {
- if (_isList)
- {
- if (attributesOfDisplay.Contains(styleInfo.AttributeName))
- {
- listitem.Selected = true;
- }
- }
- else
- {
- listitem.Selected = true;
- }
- }
-
- CblDisplayAttributes.Items.Add(listitem);
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _relatedIdentity);
- var attributesOfDisplay = ControlUtils.SelectedItemsValueToStringCollection(CblDisplayAttributes.Items);
- nodeInfo.Additional.ContentAttributesOfDisplay = attributesOfDisplay;
-
- DataProvider.ChannelDao.Update(nodeInfo);
-
- AuthRequest.AddSiteLog(SiteId, "设置内容显示项", $"显示项:{attributesOfDisplay}");
-
- if (!_isList)
- {
- LayerUtils.CloseWithoutRefresh(Page);
- }
- else
- {
- LayerUtils.Close(Page);
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalSiteSelect.cs b/SiteServer.BackgroundPages/Cms/ModalSiteSelect.cs
deleted file mode 100644
index 7a470eaf6..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalSiteSelect.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalSiteSelect : BasePageCms
- {
- public Literal LtlHtml;
-
- public static string GetOpenLayerString(int siteId)
- {
- return LayerUtils.GetOpenScript("选择站点", PageUtils.GetCmsUrl(siteId, nameof(ModalSiteSelect), null));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (IsPostBack) return;
-
- var builder = new StringBuilder();
-
- var siteIdList = AuthRequest.AdminPermissions.SiteIdList;
- foreach (var siteId in siteIdList)
- {
- var loadingUrl = PageUtils.GetLoadingUrl(PageMain.GetRedirectUrl(siteId));
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- builder.Append($@"
-");
- }
-
- LtlHtml.Text = builder.ToString();
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalTableStyleAdd.cs b/SiteServer.BackgroundPages/Cms/ModalTableStyleAdd.cs
deleted file mode 100644
index e26a76edb..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalTableStyleAdd.cs
+++ /dev/null
@@ -1,470 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalTableStyleAdd : BasePageCms
- {
- public TextBox TbAttributeName;
- public TextBox TbDisplayName;
- public TextBox TbHelpText;
- public TextBox TbTaxis;
- public PlaceHolder PhIsFormatString;
- public DropDownList DdlInputType;
- public DropDownList DdlIsFormatString;
- public PlaceHolder PhDefaultValue;
- public TextBox TbDefaultValue;
- public Control SpanDateTip;
- public DropDownList DdlIsHorizontal;
- public TextBox TbColumns;
- public PlaceHolder PhRelatedField;
- public DropDownList DdlRelatedFieldId;
- public DropDownList DdlRelatedFieldStyle;
- public PlaceHolder PhWidth;
- public TextBox TbWidth;
- public PlaceHolder PhHeight;
- public TextBox TbHeight;
-
- public PlaceHolder PhIsSelectField;
- public DropDownList DdlIsRapid;
- public PlaceHolder PhRapid;
- public TextBox TbRapidValues;
- public PlaceHolder PhNotRapid;
- public TextBox TbItemCount;
- public Repeater RptItems;
- public PlaceHolder PhRepeat;
-
- public PlaceHolder PhCustomize;
- public TextBox TbCustomizeLeft;
- public TextBox TbCustomizeRight;
-
- private int _tableStyleId;
- private List _relatedIdentities;
- private string _tableName;
- private string _attributeName;
- private string _redirectUrl;
- private TableStyleInfo _styleInfo;
-
- public static string GetOpenWindowString(int siteId, int tableStyleId, List relatedIdentities, string tableName, string attributeName, string redirectUrl)
- {
- return LayerUtils.GetOpenScript("修改显示样式", PageUtils.GetCmsUrl(siteId, nameof(ModalTableStyleAdd), new NameValueCollection
- {
- {"TableStyleID", tableStyleId.ToString()},
- {"RelatedIdentities", TranslateUtils.ObjectCollectionToString(relatedIdentities)},
- {"TableName", tableName},
- {"AttributeName", attributeName},
- {"RedirectUrl", StringUtils.ValueToUrl(redirectUrl)}
- }));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _tableStyleId = AuthRequest.GetQueryInt("TableStyleID");
- _relatedIdentities = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("RelatedIdentities"));
- if (_relatedIdentities.Count == 0)
- {
- _relatedIdentities.Add(0);
- }
- _tableName = AuthRequest.GetQueryString("TableName");
- _attributeName = AuthRequest.GetQueryString("AttributeName");
- _redirectUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("RedirectUrl"));
-
- _styleInfo = _tableStyleId != 0 ? DataProvider.TableStyleDao.GetTableStyleInfo(_tableStyleId) : TableStyleManager.GetTableStyleInfo(_tableName, _attributeName, _relatedIdentities);
-
- if (IsPostBack) return;
-
- InputTypeUtils.AddListItems(DdlInputType);
-
- var relatedFieldInfoList = DataProvider.RelatedFieldDao.GetRelatedFieldInfoList(SiteId);
- foreach (var rfInfo in relatedFieldInfoList)
- {
- var listItem = new ListItem(rfInfo.Title, rfInfo.Id.ToString());
- DdlRelatedFieldId.Items.Add(listItem);
- }
-
- ERelatedFieldStyleUtils.AddListItems(DdlRelatedFieldStyle);
-
- ControlUtils.SelectSingleItem(DdlIsRapid, _styleInfo.Id != 0 ? false.ToString() : true.ToString());
-
- TbAttributeName.Text = _styleInfo.AttributeName;
- TbDisplayName.Text = _styleInfo.DisplayName;
- TbHelpText.Text = _styleInfo.HelpText;
- ControlUtils.SelectSingleItem(DdlInputType, _styleInfo.InputType.Value);
- TbTaxis.Text = _styleInfo.Taxis.ToString();
- ControlUtils.SelectSingleItem(DdlIsFormatString, _styleInfo.Additional.IsFormatString.ToString());
- TbDefaultValue.Text = _styleInfo.DefaultValue;
- DdlIsHorizontal.SelectedValue = _styleInfo.IsHorizontal.ToString();
- TbColumns.Text = _styleInfo.Additional.Columns.ToString();
-
- ControlUtils.SelectSingleItem(DdlRelatedFieldId, _styleInfo.Additional.RelatedFieldId.ToString());
- ControlUtils.SelectSingleItem(DdlRelatedFieldStyle, _styleInfo.Additional.RelatedFieldStyle);
-
- TbHeight.Text = _styleInfo.Additional.Height == 0 ? string.Empty : _styleInfo.Additional.Height.ToString();
- TbWidth.Text = _styleInfo.Additional.Width;
-
- var styleItems = _styleInfo.StyleItems ?? DataProvider.TableStyleItemDao.GetStyleItemInfoList(_styleInfo.Id);
- TbItemCount.Text = styleItems.Count.ToString();
- RptItems.DataSource = GetDataSource(styleItems.Count, styleItems);
- RptItems.ItemDataBound += RptItems_ItemDataBound;
- RptItems.DataBind();
-
- var isSelected = false;
- var isNotEquals = false;
- var list = new List();
- foreach (var item in styleItems)
- {
- list.Add(item.ItemValue);
- if (item.IsSelected)
- {
- isSelected = true;
- }
- if (item.ItemValue != item.ItemTitle)
- {
- isNotEquals = true;
- }
- }
-
- DdlIsRapid.SelectedValue = (!isSelected && !isNotEquals).ToString();
- TbRapidValues.Text = string.Join(",", list);
-
- TbCustomizeLeft.Text = _styleInfo.Additional.CustomizeLeft;
- TbCustomizeRight.Text = _styleInfo.Additional.CustomizeRight;
-
- ReFresh(null, EventArgs.Empty);
- }
-
- private List GetDataSource(int count, List styleItems)
- {
- var items = new List();
- for (var i = 0; i < count; i++)
- {
- var itemInfo = styleItems != null && styleItems.Count > i ? styleItems[i] : new TableStyleItemInfo();
- items.Add(itemInfo);
- }
- return items;
- }
-
- private static void RptItems_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var itemInfo = (TableStyleItemInfo) e.Item.DataItem;
-
- var ltlSeq = (Literal) e.Item.FindControl("ltlSeq");
- var tbTitle = (TextBox) e.Item.FindControl("tbTitle");
- var tbValue = (TextBox) e.Item.FindControl("tbValue");
- var cbIsSelected = (CheckBox) e.Item.FindControl("cbIsSelected");
-
- ltlSeq.Text = (e.Item.ItemIndex + 1).ToString();
- tbTitle.Text = itemInfo.ItemTitle;
- tbValue.Text = itemInfo.ItemValue;
- cbIsSelected.Checked = itemInfo.IsSelected;
- }
-
- public void ReFresh(object sender, EventArgs e)
- {
- PhRelatedField.Visible = PhWidth.Visible = PhHeight.Visible = SpanDateTip.Visible = PhIsSelectField.Visible = PhRapid.Visible = PhNotRapid.Visible = PhRepeat.Visible = PhIsFormatString.Visible = PhDefaultValue.Visible = PhCustomize.Visible = false;
-
- if (!string.IsNullOrEmpty(_attributeName))
- {
- TbAttributeName.Enabled = false;
- }
-
- var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue);
- if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)
- {
- PhDefaultValue.Visible = PhIsSelectField.Visible = true;
- var isRapid = TranslateUtils.ToBool(DdlIsRapid.SelectedValue);
- if (isRapid)
- {
- PhRapid.Visible = true;
- PhNotRapid.Visible = false;
- }
- else
- {
- PhRapid.Visible = false;
- PhNotRapid.Visible = true;
- }
- if (inputType == InputType.CheckBox || inputType == InputType.Radio)
- {
- PhRepeat.Visible = true;
- }
- }
- else if (inputType == InputType.TextEditor)
- {
- PhDefaultValue.Visible = PhWidth.Visible = PhHeight.Visible = true;
- }
- else if (inputType == InputType.TextArea)
- {
- PhDefaultValue.Visible = PhWidth.Visible = PhHeight.Visible = true;
- }
- else if (inputType == InputType.Text)
- {
- PhDefaultValue.Visible = PhIsFormatString.Visible = PhWidth.Visible = true;
- }
- else if (inputType == InputType.Date || inputType == InputType.DateTime)
- {
- PhDefaultValue.Visible = SpanDateTip.Visible = true;
- }
- else if (inputType == InputType.SelectCascading)
- {
- PhDefaultValue.Visible = PhRelatedField.Visible = true;
- }
- else if (inputType == InputType.Image || inputType == InputType.Video || inputType == InputType.File)
- {
- PhDefaultValue.Visible = true;
- }
- else if (inputType == InputType.Customize)
- {
- PhCustomize.Visible = true;
- }
- }
-
- public void SetCount_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack) return;
-
- var count = TranslateUtils.ToInt(TbItemCount.Text);
- if (count != 0)
- {
- List styleItems = null;
- if (_styleInfo.Id != 0)
- {
- styleItems = DataProvider.TableStyleItemDao.GetStyleItemInfoList(_styleInfo.Id);
- }
- RptItems.DataSource = GetDataSource(count, styleItems);
- RptItems.DataBind();
- }
- else
- {
- FailMessage("选项数目必须为大于0的数字!");
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- bool isChanged;
-
- var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue);
-
- if (inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)
- {
- var isRapid = TranslateUtils.ToBool(DdlIsRapid.SelectedValue);
- if (!isRapid)
- {
- var itemCount = TranslateUtils.ToInt(TbItemCount.Text);
- if (itemCount == 0)
- {
- FailMessage("操作失败,选项数目不能为0!");
- return;
- }
- }
- }
-
- if (_styleInfo.Id == 0 && _styleInfo.RelatedIdentity == 0)//数据库中没有此项及父项的表样式
- {
- isChanged = InsertTableStyleInfo(inputType);
- }
- else if (_styleInfo.RelatedIdentity != _relatedIdentities[0])//数据库中没有此项的表样式,但是有父项的表样式
- {
- isChanged = InsertTableStyleInfo(inputType);
- }
- else//数据库中有此项的表样式
- {
- isChanged = UpdateTableStyleInfo(inputType);
- }
-
- if (isChanged)
- {
- LayerUtils.CloseAndRedirect(Page, _redirectUrl);
- }
- }
-
- private bool UpdateTableStyleInfo(InputType inputType)
- {
- var isChanged = false;
- _styleInfo.AttributeName =TbAttributeName.Text;
- _styleInfo.DisplayName = PageUtils.FilterXss(TbDisplayName.Text);
- _styleInfo.HelpText = TbHelpText.Text;
- _styleInfo.Taxis = TranslateUtils.ToInt(TbTaxis.Text);
- _styleInfo.InputType = inputType;
- _styleInfo.DefaultValue = TbDefaultValue.Text;
- _styleInfo.IsHorizontal = TranslateUtils.ToBool(DdlIsHorizontal.SelectedValue);
-
- _styleInfo.Additional.Columns = TranslateUtils.ToInt(TbColumns.Text);
- _styleInfo.Additional.Height = TranslateUtils.ToInt(TbHeight.Text);
- _styleInfo.Additional.Width = TbWidth.Text;
- _styleInfo.Additional.IsFormatString = TranslateUtils.ToBool(DdlIsFormatString.SelectedValue);
- _styleInfo.Additional.RelatedFieldId = TranslateUtils.ToInt(DdlRelatedFieldId.SelectedValue);
- _styleInfo.Additional.RelatedFieldStyle = DdlRelatedFieldStyle.SelectedValue;
- _styleInfo.Additional.CustomizeLeft = TbCustomizeLeft.Text;
- _styleInfo.Additional.CustomizeRight = TbCustomizeRight.Text;
-
- List styleItems = null;
-
- if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)
- {
- styleItems = new List();
-
- var isRapid = TranslateUtils.ToBool(DdlIsRapid.SelectedValue);
- if (isRapid)
- {
- var rapidValues = TranslateUtils.StringCollectionToStringList(TbRapidValues.Text);
- foreach (var rapidValue in rapidValues)
- {
- var itemInfo = new TableStyleItemInfo(0, _styleInfo.Id, rapidValue, rapidValue, false);
- styleItems.Add(itemInfo);
- }
- }
- else
- {
- var isHasSelected = false;
- foreach (RepeaterItem item in RptItems.Items)
- {
- var tbTitle = (TextBox)item.FindControl("tbTitle");
- var tbValue = (TextBox)item.FindControl("tbValue");
- var cbIsSelected = (CheckBox)item.FindControl("cbIsSelected");
-
- if (inputType != InputType.SelectMultiple && inputType != InputType.CheckBox && isHasSelected && cbIsSelected.Checked)
- {
- FailMessage("操作失败,只能有一个初始化时选定项!");
- return false;
- }
- if (cbIsSelected.Checked) isHasSelected = true;
-
- var itemInfo = new TableStyleItemInfo(0, _styleInfo.Id, tbTitle.Text, tbValue.Text, cbIsSelected.Checked);
- styleItems.Add(itemInfo);
- }
- }
- }
-
- try
- {
- TableStyleManager.Update(_styleInfo);
- TableStyleManager.DeleteAndInsertStyleItems(_styleInfo.Id, styleItems);
-
- if (SiteId > 0)
- {
- AuthRequest.AddSiteLog(SiteId, "修改表单显示样式", $"字段名:{_styleInfo.AttributeName}");
- }
- else
- {
- AuthRequest.AddAdminLog("修改表单显示样式", $"字段名:{_styleInfo.AttributeName}");
- }
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "显示样式修改失败:" + ex.Message);
- }
- return isChanged;
- }
-
- private bool InsertTableStyleInfo(InputType inputType)
- {
- var isChanged = false;
-
- var relatedIdentity = _relatedIdentities[0];
-
- if (string.IsNullOrEmpty(TbAttributeName.Text))
- {
- FailMessage("操作失败,字段名不能为空!");
- return false;
- }
-
- if (TableStyleManager.IsExists(relatedIdentity, _tableName, TbAttributeName.Text))
- {
- FailMessage($@"显示样式添加失败:字段名""{TbAttributeName.Text}""已存在");
- return false;
- }
-
- _styleInfo = DataProvider.TableMetadataDao.IsExists(_tableName, TbAttributeName.Text) ? TableStyleManager.GetTableStyleInfo(_tableName, TbAttributeName.Text, _relatedIdentities) : new TableStyleInfo();
-
- _styleInfo.RelatedIdentity = relatedIdentity;
- _styleInfo.TableName = _tableName;
- _styleInfo.AttributeName = TbAttributeName.Text;
- _styleInfo.DisplayName =PageUtils.FilterXss(TbDisplayName.Text);
- _styleInfo.HelpText = TbHelpText.Text;
- _styleInfo.Taxis = TranslateUtils.ToInt(TbTaxis.Text);
- _styleInfo.InputType = inputType;
- _styleInfo.DefaultValue = TbDefaultValue.Text;
- _styleInfo.IsHorizontal = TranslateUtils.ToBool(DdlIsHorizontal.SelectedValue);
-
- _styleInfo.Additional.Columns = TranslateUtils.ToInt(TbColumns.Text);
- _styleInfo.Additional.Height = TranslateUtils.ToInt(TbHeight.Text);
- _styleInfo.Additional.Width = TbWidth.Text;
- _styleInfo.Additional.IsFormatString = TranslateUtils.ToBool(DdlIsFormatString.SelectedValue);
- _styleInfo.Additional.RelatedFieldId = TranslateUtils.ToInt(DdlRelatedFieldId.SelectedValue);
- _styleInfo.Additional.RelatedFieldStyle = DdlRelatedFieldStyle.SelectedValue;
- _styleInfo.Additional.CustomizeLeft = TbCustomizeLeft.Text;
- _styleInfo.Additional.CustomizeRight = TbCustomizeRight.Text;
-
- if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)
- {
- _styleInfo.StyleItems = new List();
-
- var isRapid = TranslateUtils.ToBool(DdlIsRapid.SelectedValue);
- if (isRapid)
- {
- var rapidValues = TranslateUtils.StringCollectionToStringList(TbRapidValues.Text);
- foreach (var rapidValue in rapidValues)
- {
- var itemInfo = new TableStyleItemInfo(0, _styleInfo.Id, rapidValue, rapidValue, false);
- _styleInfo.StyleItems.Add(itemInfo);
- }
- }
- else
- {
- var isHasSelected = false;
- foreach (RepeaterItem item in RptItems.Items)
- {
- var tbTitle = (TextBox)item.FindControl("tbTitle");
- var tbValue = (TextBox)item.FindControl("tbValue");
- var cbIsSelected = (CheckBox)item.FindControl("cbIsSelected");
-
- if (inputType != InputType.SelectMultiple && inputType != InputType.CheckBox && isHasSelected && cbIsSelected.Checked)
- {
- FailMessage("操作失败,只能有一个初始化时选定项!");
- return false;
- }
- if (cbIsSelected.Checked) isHasSelected = true;
-
- var itemInfo = new TableStyleItemInfo(0, 0, tbTitle.Text, tbValue.Text, cbIsSelected.Checked);
- _styleInfo.StyleItems.Add(itemInfo);
- }
- }
- }
-
- try
- {
- TableStyleManager.Insert(_styleInfo);
-
- if (SiteId > 0)
- {
- AuthRequest.AddSiteLog(SiteId, "添加表单显示样式", $"字段名:{_styleInfo.AttributeName}");
- }
- else
- {
- AuthRequest.AddAdminLog("添加表单显示样式", $"字段名:{_styleInfo.AttributeName}");
- }
-
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "显示样式添加失败:" + ex.Message);
- }
- return isChanged;
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalTableStyleValidateAdd.cs b/SiteServer.BackgroundPages/Cms/ModalTableStyleValidateAdd.cs
deleted file mode 100644
index 5df4ada60..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalTableStyleValidateAdd.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalTableStyleValidateAdd : BasePageCms
- {
- public DropDownList DdlIsValidate;
- public PlaceHolder PhValidate;
- public DropDownList DdlIsRequired;
- public PlaceHolder PhNum;
- public TextBox TbMinNum;
- public TextBox TbMaxNum;
- public DropDownList DdlValidateType;
- public PlaceHolder PhRegExp;
- public TextBox TbRegExp;
- public TextBox TbErrorMessage;
-
- private int _tableStyleId;
- private List _relatedIdentities;
- private string _tableName;
- private string _attributeName;
- private string _redirectUrl;
- private TableStyleInfo _styleInfo;
-
- public static string GetOpenWindowString(int siteId, int tableStyleId, List relatedIdentities, string tableName, string attributeName, string redirectUrl)
- {
- return LayerUtils.GetOpenScript("设置表单验证", PageUtils.GetCmsUrl(siteId, nameof(ModalTableStyleValidateAdd), new NameValueCollection
- {
- {"TableStyleID", tableStyleId.ToString()},
- {"RelatedIdentities", TranslateUtils.ObjectCollectionToString(relatedIdentities)},
- {"TableName", tableName},
- {"AttributeName", attributeName},
- {"RedirectUrl", StringUtils.ValueToUrl(redirectUrl)}
- }));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _tableStyleId = AuthRequest.GetQueryInt("TableStyleID");
- _relatedIdentities = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("RelatedIdentities"));
- if (_relatedIdentities.Count == 0)
- {
- _relatedIdentities.Add(0);
- }
- _tableName = AuthRequest.GetQueryString("TableName");
- _attributeName = AuthRequest.GetQueryString("AttributeName");
- _redirectUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("RedirectUrl"));
-
- _styleInfo = _tableStyleId != 0
- ? DataProvider.TableStyleDao.GetTableStyleInfo(_tableStyleId)
- : TableStyleManager.GetTableStyleInfo(_tableName, _attributeName, _relatedIdentities);
-
- if (IsPostBack) return;
-
- DdlIsValidate.Items[0].Value = true.ToString();
- DdlIsValidate.Items[1].Value = false.ToString();
-
- ControlUtils.SelectSingleItem(DdlIsValidate, _styleInfo.Additional.IsValidate.ToString());
-
- DdlIsRequired.Items[0].Value = true.ToString();
- DdlIsRequired.Items[1].Value = false.ToString();
-
- ControlUtils.SelectSingleItem(DdlIsRequired, _styleInfo.Additional.IsRequired.ToString());
-
- PhNum.Visible = InputTypeUtils.EqualsAny(_styleInfo.InputType, InputType.Text, InputType.TextArea);
-
- TbMinNum.Text = _styleInfo.Additional.MinNum.ToString();
- TbMaxNum.Text = _styleInfo.Additional.MaxNum.ToString();
-
- ValidateTypeUtils.AddListItems(DdlValidateType);
- ControlUtils.SelectSingleItem(DdlValidateType, _styleInfo.Additional.ValidateType.Value);
-
- TbRegExp.Text = _styleInfo.Additional.RegExp;
- TbErrorMessage.Text = _styleInfo.Additional.ErrorMessage;
-
- DdlValidate_SelectedIndexChanged(null, EventArgs.Empty);
- }
-
- public void DdlValidate_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhValidate.Visible = !EBooleanUtils.Equals(EBoolean.False, DdlIsValidate.SelectedValue);
- var type = ValidateTypeUtils.GetEnumType(DdlValidateType.SelectedValue);
- PhRegExp.Visible = type == ValidateType.RegExp;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = InsertOrUpdateTableStyleInfo();
-
- if (isChanged)
- {
- LayerUtils.CloseAndRedirect(Page, _redirectUrl);
- }
- }
-
- private bool InsertOrUpdateTableStyleInfo()
- {
- var isChanged = false;
-
- _styleInfo.Additional.IsValidate = TranslateUtils.ToBool(DdlIsValidate.SelectedValue);
- _styleInfo.Additional.IsRequired = TranslateUtils.ToBool(DdlIsRequired.SelectedValue);
- _styleInfo.Additional.MinNum = TranslateUtils.ToInt(TbMinNum.Text);
- _styleInfo.Additional.MaxNum = TranslateUtils.ToInt(TbMaxNum.Text);
- _styleInfo.Additional.ValidateType = ValidateTypeUtils.GetEnumType(DdlValidateType.SelectedValue);
- _styleInfo.Additional.RegExp = TbRegExp.Text.Trim('/');
- _styleInfo.Additional.ErrorMessage = TbErrorMessage.Text;
-
- try
- {
- if (_tableStyleId == 0)//数据库中没有此项的表样式,但是有父项的表样式
- {
- var relatedIdentity = _relatedIdentities[0];
- _styleInfo.RelatedIdentity = relatedIdentity;
- _styleInfo.Id = TableStyleManager.Insert(_styleInfo);
- }
-
- if (_styleInfo.Id > 0)
- {
- TableStyleManager.Update(_styleInfo);
- AuthRequest.AddSiteLog(SiteId, "修改表单验证", $"字段:{_styleInfo.AttributeName}");
- }
- else
- {
- TableStyleManager.Insert(_styleInfo);
- AuthRequest.AddSiteLog(SiteId, "新增表单验证", $"字段:{_styleInfo.AttributeName}");
- }
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "设置表单验证失败:" + ex.Message);
- }
- return isChanged;
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalTemplateFilePathRule.cs b/SiteServer.BackgroundPages/Cms/ModalTemplateFilePathRule.cs
deleted file mode 100644
index 03be76d4b..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalTemplateFilePathRule.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalTemplateFilePathRule : BasePageCms
- {
- public PlaceHolder PhFilePath;
- public TextBox TbFilePath;
- public TextBox TbChannelFilePathRule;
- public TextBox TbContentFilePathRule;
- public Button BtnCreateChannelRule;
- public Button BtnCreateContentRule;
-
- private int _channelId;
-
- public static string GetOpenWindowString(int siteId, int channelId)
- {
- return LayerUtils.GetOpenScript("页面命名规则",
- PageUtils.GetCmsUrl(siteId, nameof(ModalTemplateFilePathRule), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- }));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId");
- _channelId = AuthRequest.GetQueryInt("channelId");
-
- if (IsPostBack) return;
-
- var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- var linkType = ELinkTypeUtils.GetEnumType(channelInfo.LinkType);
- if (channelInfo.ParentId == 0 || linkType == ELinkType.LinkToFirstChannel || linkType == ELinkType.LinkToFirstContent || linkType == ELinkType.LinkToLastAddChannel || linkType == ELinkType.NoLink)
- {
- PhFilePath.Visible = false;
- }
-
- var showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, true, TbChannelFilePathRule.ClientID);
- BtnCreateChannelRule.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, false, TbContentFilePathRule.ClientID);
- BtnCreateContentRule.Attributes.Add("onclick", showPopWinString);
-
- TbFilePath.Text = string.IsNullOrEmpty(channelInfo.FilePath) ? PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false) : channelInfo.FilePath;
-
- TbChannelFilePathRule.Text = string.IsNullOrEmpty(channelInfo.ChannelFilePathRule) ? PathUtility.GetChannelFilePathRule(SiteInfo, _channelId) : channelInfo.ChannelFilePathRule;
-
- TbContentFilePathRule.Text = string.IsNullOrEmpty(channelInfo.ContentFilePathRule) ? PathUtility.GetContentFilePathRule(SiteInfo, _channelId) : channelInfo.ContentFilePathRule;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isSuccess = false;
-
- try
- {
- var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
-
- var filePath = channelInfo.FilePath;
-
- if (PhFilePath.Visible)
- {
- TbFilePath.Text = TbFilePath.Text.Trim();
- if (!string.IsNullOrEmpty(TbFilePath.Text) && !StringUtils.EqualsIgnoreCase(filePath, TbFilePath.Text))
- {
- if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
- {
- FailMessage("栏目页面路径不符合系统要求!");
- return;
- }
-
- if (PathUtils.IsDirectoryPath(TbFilePath.Text))
- {
- TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
- }
-
- var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
- filePathArrayList.AddRange(DataProvider.TemplateMatchDao.GetAllFilePathBySiteId(SiteId));
- if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
- {
- FailMessage("栏目修改失败,栏目页面路径已存在!");
- return;
- }
- }
- }
-
- if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
- {
- var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty);
- if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
- {
- FailMessage("栏目页面命名规则不符合系统要求!");
- return;
- }
- if (PathUtils.IsDirectoryPath(filePathRule))
- {
- FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
- return;
- }
- }
-
- if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
- {
- var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty);
- if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
- {
- FailMessage("内容页面命名规则不符合系统要求!");
- return;
- }
- if (PathUtils.IsDirectoryPath(filePathRule))
- {
- FailMessage("内容页面命名规则必须包含生成文件的后缀!");
- return;
- }
- }
-
- if (TbFilePath.Text != PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false))
- {
- channelInfo.FilePath = TbFilePath.Text;
- }
- if (TbChannelFilePathRule.Text != PathUtility.GetChannelFilePathRule(SiteInfo, _channelId))
- {
- channelInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
- }
- if (TbContentFilePathRule.Text != PathUtility.GetContentFilePathRule(SiteInfo, _channelId))
- {
- channelInfo.ContentFilePathRule = TbContentFilePathRule.Text;
- }
-
- DataProvider.ChannelDao.Update(channelInfo);
-
- CreateManager.CreateChannel(SiteId, _channelId);
-
- AuthRequest.AddSiteLog(SiteId, _channelId, 0, "设置页面命名规则", $"栏目:{channelInfo.ChannelName}");
-
- isSuccess = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, ex.Message);
- }
-
- if (isSuccess)
- {
- LayerUtils.CloseAndRedirect(Page, PageConfigurationCreateRule.GetRedirectUrl(SiteId, _channelId));
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalTemplateView.cs b/SiteServer.BackgroundPages/Cms/ModalTemplateView.cs
deleted file mode 100644
index 1a94ba309..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalTemplateView.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalTemplateView : BasePageCms
- {
- public TextBox TbContent;
-
- public static string GetOpenWindowString(int siteId, int templateLogId)
- {
- return LayerUtils.GetOpenScript("查看修订内容", PageUtils.GetCmsUrl(siteId, nameof(ModalTemplateView), new NameValueCollection
- {
- {"templateLogID", templateLogId.ToString()}
- }));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (!IsPostBack)
- {
- var templateLogId = AuthRequest.GetQueryInt("templateLogID");
- TbContent.Text = DataProvider.TemplateLogDao.GetTemplateContent(templateLogId);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalTextEditorInsertImage.cs b/SiteServer.BackgroundPages/Cms/ModalTextEditorInsertImage.cs
deleted file mode 100644
index 58e1df1e6..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalTextEditorInsertImage.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Core.Office;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-using SiteServer.Utils.Images;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalTextEditorInsertImage : BasePageCms
- {
- public HtmlInputHidden HihFilePaths;
- public CheckBox CbIsLinkToOriginal;
- public CheckBox CbIsSmallImage;
- public TextBox TbSmallImageWidth;
- public TextBox TbSmallImageHeight;
-
- private string _attributeName;
-
- public static string GetOpenWindowString(int siteId, string attributeName)
- {
- return LayerUtils.GetOpenScript("插入图片",
- PageUtils.GetCmsUrl(siteId, nameof(ModalTextEditorInsertImage), new NameValueCollection
- {
- {"attributeName", attributeName}
- }), 700, 550);
- }
-
- public string UploadUrl => ModalTextEditorInsertImageHandler.GetRedirectUrl(SiteId);
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "attributeName");
- _attributeName = AuthRequest.GetQueryString("attributeName");
-
- if (IsPostBack) return;
-
- ConfigSettings(true);
-
- CbIsSmallImage.Attributes.Add("onclick", "checkBoxChange();");
- }
-
- private void ConfigSettings(bool isLoad)
- {
- if (isLoad)
- {
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageIsLinkToOriginal))
- {
- CbIsLinkToOriginal.Checked = TranslateUtils.ToBool(SiteInfo.Additional.ConfigUploadImageIsLinkToOriginal);
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageIsSmallImage))
- {
- CbIsSmallImage.Checked = TranslateUtils.ToBool(SiteInfo.Additional.ConfigUploadImageIsSmallImage);
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageSmallImageWidth))
- {
- TbSmallImageWidth.Text = SiteInfo.Additional.ConfigUploadImageSmallImageWidth;
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageSmallImageHeight))
- {
- TbSmallImageHeight.Text = SiteInfo.Additional.ConfigUploadImageSmallImageHeight;
- }
- }
- else
- {
- if (SiteInfo.Additional.ConfigUploadImageIsLinkToOriginal != CbIsLinkToOriginal.Checked.ToString()
- || SiteInfo.Additional.ConfigUploadImageIsSmallImage != CbIsSmallImage.Checked.ToString()
- || SiteInfo.Additional.ConfigUploadImageSmallImageWidth != TbSmallImageWidth.Text
- || SiteInfo.Additional.ConfigUploadImageSmallImageHeight != TbSmallImageHeight.Text)
- {
- SiteInfo.Additional.ConfigUploadImageIsLinkToOriginal = CbIsLinkToOriginal.Checked.ToString();
- SiteInfo.Additional.ConfigUploadImageIsSmallImage = CbIsSmallImage.Checked.ToString();
- SiteInfo.Additional.ConfigUploadImageSmallImageWidth = TbSmallImageWidth.Text;
- SiteInfo.Additional.ConfigUploadImageSmallImageHeight = TbSmallImageHeight.Text;
-
- DataProvider.SiteDao.Update(SiteInfo);
- }
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- if (CbIsSmallImage.Checked && string.IsNullOrEmpty(TbSmallImageWidth.Text) && string.IsNullOrEmpty(TbSmallImageHeight.Text))
- {
- FailMessage("缩略图尺寸不能为空!");
- return;
- }
-
- ConfigSettings(false);
-
- var scripts = string.Empty;
-
- var fileNames = TranslateUtils.StringCollectionToStringList(HihFilePaths.Value);
-
- foreach (var filePath in fileNames)
- {
- if (!string.IsNullOrEmpty(filePath))
- {
- var fileName = PathUtils.GetFileName(filePath);
-
- var fileExtName = PathUtils.GetExtension(filePath).ToLower();
- var localDirectoryPath = PathUtility.GetUploadDirectoryPath(SiteInfo, fileExtName);
-
- var imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, filePath, true);
-
- if (CbIsSmallImage.Checked)
- {
- var localSmallFileName = StringUtils.Constants.SmallImageAppendix + fileName;
- var localSmallFilePath = PathUtils.Combine(localDirectoryPath, localSmallFileName);
-
- var smallImageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localSmallFilePath, true);
-
- var width = TranslateUtils.ToInt(TbSmallImageWidth.Text);
- var height = TranslateUtils.ToInt(TbSmallImageHeight.Text);
- ImageUtils.MakeThumbnail(filePath, localSmallFilePath, width, height, true);
-
- var insertHtml = CbIsLinkToOriginal.Checked
- ? $@" "
- : $@" ";
-
- scripts += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." +
- ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml);
- }
- else
- {
- var insertHtml = $@" ";
-
- scripts += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." +
- ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml);
- }
- }
- }
-
- LayerUtils.CloseWithoutRefresh(Page, scripts);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalTextEditorInsertVideo.cs b/SiteServer.BackgroundPages/Cms/ModalTextEditorInsertVideo.cs
deleted file mode 100644
index 4ab5928c8..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalTextEditorInsertVideo.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-using SiteServer.Utils.LitJson;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalTextEditorInsertVideo : BasePageCms
- {
- public TextBox TbPlayUrl;
- public TextBox TbWidth;
- public TextBox TbHeight;
- public CheckBox CbIsAutoPlay;
-
- private string _attributeName;
-
- public static string GetOpenWindowString(int siteId, string attributeName)
- {
- return LayerUtils.GetOpenScript("插入视频", PageUtils.GetCmsUrl(siteId, nameof(ModalTextEditorInsertVideo), new NameValueCollection
- {
- {"AttributeName", attributeName}
- }), 600, 460);
- }
-
- public string UploadUrl => PageUtils.GetCmsUrl(SiteId, nameof(ModalTextEditorInsertVideo), new NameValueCollection
- {
- {"upload", true.ToString()}
- });
-
- public string TypeCollection => SiteInfo.Additional.VideoUploadTypeCollection;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("upload"))
- {
- var json = JsonMapper.ToJson(Upload());
- Response.Write(json);
- Response.End();
- return;
- }
-
- _attributeName = AuthRequest.GetQueryString("AttributeName");
-
- if (IsPostBack) return;
-
- TbWidth.Text = SiteInfo.Additional.ConfigVideoContentInsertWidth.ToString();
- TbHeight.Text = SiteInfo.Additional.ConfigVideoContentInsertHeight.ToString();
- }
-
- private Hashtable Upload()
- {
- var success = false;
- var playUrl = string.Empty;
- var message = "视频上传失败";
-
- if (Request.Files["filedata"] != null)
- {
- var postedFile = Request.Files["filedata"];
- try
- {
- if (!string.IsNullOrEmpty(postedFile?.FileName))
- {
- var filePath = postedFile.FileName;
- var fileExtName = PathUtils.GetExtension(filePath);
-
- var isAllow = true;
- if (!PathUtility.IsVideoExtenstionAllowed(SiteInfo, fileExtName))
- {
- message = "此格式不允许上传,请选择有效的音频文件";
- isAllow = false;
- }
- if (!PathUtility.IsVideoSizeAllowed(SiteInfo, postedFile.ContentLength))
- {
- message = "上传失败,上传文件超出规定文件大小";
- isAllow = false;
- }
-
- if (isAllow)
- {
- var localDirectoryPath = PathUtility.GetUploadDirectoryPath(SiteInfo, fileExtName);
- var localFileName = PathUtility.GetUploadFileName(SiteInfo, filePath);
- var localFilePath = PathUtils.Combine(localDirectoryPath, localFileName);
-
- postedFile.SaveAs(localFilePath);
-
- playUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true);
- playUrl = PageUtility.GetVirtualUrl(SiteInfo, playUrl);
-
- success = true;
- }
- }
- }
- catch (Exception ex)
- {
- message = ex.Message;
- }
- }
-
- var jsonAttributes = new Hashtable();
- if (success)
- {
- jsonAttributes.Add("success", "true");
- jsonAttributes.Add("playUrl", playUrl);
- }
- else
- {
- jsonAttributes.Add("success", "false");
- jsonAttributes.Add("message", message);
- }
-
- return jsonAttributes;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var width = TranslateUtils.ToInt(TbWidth.Text);
- var height = TranslateUtils.ToInt(TbHeight.Text);
- if (width > 0 && height > 0 && (width != SiteInfo.Additional.ConfigVideoContentInsertWidth || height != SiteInfo.Additional.ConfigVideoContentInsertHeight))
- {
- SiteInfo.Additional.ConfigVideoContentInsertWidth = width;
- SiteInfo.Additional.ConfigVideoContentInsertHeight = height;
- DataProvider.SiteDao.Update(SiteInfo);
- }
-
- var playUrl = TbPlayUrl.Text;
-
- var script = "parent." + ETextEditorTypeUtils.GetInsertVideoScript(_attributeName, playUrl, width, height, CbIsAutoPlay.Checked);
- LayerUtils.CloseWithoutRefresh(Page, script);
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalUploadImage.cs b/SiteServer.BackgroundPages/Cms/ModalUploadImage.cs
deleted file mode 100644
index d2e8cb092..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalUploadImage.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.Utils.Images;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalUploadImage : BasePageCms
- {
- public HtmlInputFile HifUpload;
-
- public CheckBox CbIsTitleImage;
- public TextBox TbTitleImageWidth;
- public TextBox TbTitleImageHeight;
-
- public CheckBox CbIsShowImageInTextEditor;
- public CheckBox CbIsLinkToOriginal;
- public CheckBox CbIsSmallImage;
- public TextBox TbSmallImageWidth;
- public TextBox TbSmallImageHeight;
-
- public Literal LtlScript;
-
- private string _textBoxClientId;
-
- public static string GetOpenWindowString(int siteId, string textBoxClientId)
- {
- return LayerUtils.GetOpenScript("上传图片", PageUtils.GetCmsUrl(siteId, nameof(ModalUploadImage), new NameValueCollection
- {
- {"textBoxClientID", textBoxClientId}
- }), 600, 560);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
- _textBoxClientId = AuthRequest.GetQueryString("TextBoxClientID");
-
- if (IsPostBack) return;
-
- ConfigSettings(true);
-
- CbIsTitleImage.Attributes.Add("onclick", "checkBoxChange();");
- CbIsShowImageInTextEditor.Attributes.Add("onclick", "checkBoxChange();");
- CbIsSmallImage.Attributes.Add("onclick", "checkBoxChange();");
- }
-
- private void ConfigSettings(bool isLoad)
- {
- if (isLoad)
- {
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageIsTitleImage))
- {
- CbIsTitleImage.Checked = TranslateUtils.ToBool(SiteInfo.Additional.ConfigUploadImageIsTitleImage);
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageTitleImageWidth))
- {
- TbTitleImageWidth.Text = SiteInfo.Additional.ConfigUploadImageTitleImageWidth;
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageTitleImageHeight))
- {
- TbTitleImageHeight.Text = SiteInfo.Additional.ConfigUploadImageTitleImageHeight;
- }
-
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageIsShowImageInTextEditor))
- {
- CbIsShowImageInTextEditor.Checked = TranslateUtils.ToBool(SiteInfo.Additional.ConfigUploadImageIsShowImageInTextEditor);
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageIsLinkToOriginal))
- {
- CbIsLinkToOriginal.Checked = TranslateUtils.ToBool(SiteInfo.Additional.ConfigUploadImageIsLinkToOriginal);
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageIsSmallImage))
- {
- CbIsSmallImage.Checked = TranslateUtils.ToBool(SiteInfo.Additional.ConfigUploadImageIsSmallImage);
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageSmallImageWidth))
- {
- TbSmallImageWidth.Text = SiteInfo.Additional.ConfigUploadImageSmallImageWidth;
- }
- if (!string.IsNullOrEmpty(SiteInfo.Additional.ConfigUploadImageSmallImageHeight))
- {
- TbSmallImageHeight.Text = SiteInfo.Additional.ConfigUploadImageSmallImageHeight;
- }
- }
- else
- {
- SiteInfo.Additional.ConfigUploadImageIsTitleImage = CbIsTitleImage.Checked.ToString();
- SiteInfo.Additional.ConfigUploadImageTitleImageWidth = TbTitleImageWidth.Text;
- SiteInfo.Additional.ConfigUploadImageTitleImageHeight = TbTitleImageHeight.Text;
-
- SiteInfo.Additional.ConfigUploadImageIsShowImageInTextEditor = CbIsShowImageInTextEditor.Checked.ToString();
- SiteInfo.Additional.ConfigUploadImageIsLinkToOriginal = CbIsLinkToOriginal.Checked.ToString();
- SiteInfo.Additional.ConfigUploadImageIsSmallImage = CbIsSmallImage.Checked.ToString();
- SiteInfo.Additional.ConfigUploadImageSmallImageWidth = TbSmallImageWidth.Text;
- SiteInfo.Additional.ConfigUploadImageSmallImageHeight = TbSmallImageHeight.Text;
-
- DataProvider.SiteDao.Update(SiteInfo);
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (CbIsTitleImage.Checked && string.IsNullOrEmpty(TbTitleImageWidth.Text) && string.IsNullOrEmpty(TbTitleImageHeight.Text))
- {
- FailMessage("缩略图尺寸不能为空!");
- return;
- }
- if (CbIsSmallImage.Checked && string.IsNullOrEmpty(TbSmallImageWidth.Text) && string.IsNullOrEmpty(TbSmallImageHeight.Text))
- {
- FailMessage("缩略图尺寸不能为空!");
- return;
- }
-
- ConfigSettings(false);
-
- if (HifUpload.PostedFile == null || "" == HifUpload.PostedFile.FileName) return;
-
- var filePath = HifUpload.PostedFile.FileName;
- try
- {
- var fileExtName = PathUtils.GetExtension(filePath).ToLower();
- var localDirectoryPath = PathUtility.GetUploadDirectoryPath(SiteInfo, fileExtName);
- var localFileName = PathUtility.GetUploadFileName(SiteInfo, filePath);
- var localTitleFileName = StringUtils.Constants.TitleImageAppendix + localFileName;
- var localSmallFileName = StringUtils.Constants.SmallImageAppendix + localFileName;
- var localFilePath = PathUtils.Combine(localDirectoryPath, localFileName);
- var localTitleFilePath = PathUtils.Combine(localDirectoryPath, localTitleFileName);
- var localSmallFilePath = PathUtils.Combine(localDirectoryPath, localSmallFileName);
-
- if (!PathUtility.IsImageExtenstionAllowed(SiteInfo, fileExtName))
- {
- FailMessage("上传失败,上传图片格式不正确!");
- return;
- }
- if (!PathUtility.IsImageSizeAllowed(SiteInfo, HifUpload.PostedFile.ContentLength))
- {
- FailMessage("上传失败,上传图片超出规定文件大小!");
- return;
- }
-
- HifUpload.PostedFile.SaveAs(localFilePath);
-
- var isImage = EFileSystemTypeUtils.IsImage(fileExtName);
-
- //处理上半部分
- if (isImage)
- {
- FileUtility.AddWaterMark(SiteInfo, localFilePath);
- if (CbIsTitleImage.Checked)
- {
- var width = TranslateUtils.ToInt(TbTitleImageWidth.Text);
- var height = TranslateUtils.ToInt(TbTitleImageHeight.Text);
- ImageUtils.MakeThumbnail(localFilePath, localTitleFilePath, width, height, true);
- }
- }
-
- var imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true);
- if (CbIsTitleImage.Checked)
- {
- imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localTitleFilePath, true);
- }
-
- var textBoxUrl = PageUtility.GetVirtualUrl(SiteInfo, imageUrl);
-
- var script = $@"
-if (parent.document.getElementById('{_textBoxClientId}'))
-{{
- parent.document.getElementById('{_textBoxClientId}').value = '{textBoxUrl}';
-}}
-";
-
- //处理下半部分
- if (CbIsShowImageInTextEditor.Checked && isImage)
- {
- imageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localFilePath, true);
- var smallImageUrl = imageUrl;
- if (CbIsSmallImage.Checked)
- {
- smallImageUrl = PageUtility.GetSiteUrlByPhysicalPath(SiteInfo, localSmallFilePath, true);
- }
-
- if (CbIsSmallImage.Checked)
- {
- var width = TranslateUtils.ToInt(TbSmallImageWidth.Text);
- var height = TranslateUtils.ToInt(TbSmallImageHeight.Text);
- ImageUtils.MakeThumbnail(localFilePath, localSmallFilePath, width, height, true);
- }
-
- var insertHtml = CbIsLinkToOriginal.Checked ? $@" " : $@" ";
-
- script += "if(parent." + ETextEditorTypeUtils.GetEditorInstanceScript() + ") parent." + ETextEditorTypeUtils.GetInsertHtmlScript("Content", insertHtml);
- }
-
- LtlScript.Text = $@"
-";
- }
- catch (Exception ex)
- {
- FailMessage(ex, ex.Message);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/ModalUploadWord.cs b/SiteServer.BackgroundPages/Cms/ModalUploadWord.cs
deleted file mode 100644
index 4d5149928..000000000
--- a/SiteServer.BackgroundPages/Cms/ModalUploadWord.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Core.Office;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class ModalUploadWord : BasePageCms
- {
- public HtmlInputHidden HihFileNames;
- public CheckBox CbIsFirstLineTitle;
- public CheckBox CbIsFirstLineRemove;
- public CheckBox CbIsClearFormat;
- public CheckBox CbIsFirstLineIndent;
- public CheckBox CbIsClearFontSize;
- public CheckBox CbIsClearFontFamily;
- public CheckBox CbIsClearImages;
- public DropDownList DdlContentLevel;
-
- private ChannelInfo _channelInfo;
- private string _returnUrl;
-
- public static string GetOpenWindowString(int siteId, int channelId, string returnUrl)
- {
- return LayerUtils.GetOpenScript("批量导入Word文件",
- PageUtils.GetCmsUrl(siteId, nameof(ModalUploadWord), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"returnUrl", returnUrl}
- }), 700, 550);
- }
-
- public string UploadUrl => ModalUploadWordHandler.GetRedirectUrl(SiteId);
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "ReturnUrl");
- var channelId = int.Parse(AuthRequest.GetQueryString("channelId"));
- _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- _returnUrl = AuthRequest.GetQueryString("ReturnUrl");
-
- if (IsPostBack) return;
-
- int checkedLevel;
- var isChecked = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, SiteId, out checkedLevel);
- CheckManager.LoadContentLevelToEdit(DdlContentLevel, SiteInfo, _channelInfo.Id, null, isChecked, checkedLevel);
- ControlUtils.SelectSingleItem(DdlContentLevel, CheckManager.LevelInt.CaoGao.ToString());
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var fileNames = TranslateUtils.StringCollectionToStringList(HihFileNames.Value);
- if (fileNames.Count == 1)
- {
- var fileName = fileNames[0];
- if (!string.IsNullOrEmpty(fileName))
- {
- var redirectUrl = WebUtils.GetContentAddUploadWordUrl(SiteId, _channelInfo, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue), fileName, _returnUrl);
- LayerUtils.CloseAndRedirect(Page, redirectUrl);
- }
-
- return;
- }
-
- if (fileNames.Count > 1)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo);
- var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelInfo.Id);
- var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, relatedIdentities);
-
- foreach (var fileName in fileNames)
- {
- if (!string.IsNullOrEmpty(fileName))
- {
- var formCollection = WordUtils.GetWordNameValueCollection(SiteId, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToInt(DdlContentLevel.SelectedValue), fileName);
-
- if (!string.IsNullOrEmpty(formCollection[ContentAttribute.Title]))
- {
- var contentInfo = new ContentInfo();
-
- BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributesLowercase);
-
- contentInfo.ChannelId = _channelInfo.Id;
- contentInfo.SiteId = SiteId;
- contentInfo.AddUserName = AuthRequest.AdminName;
- contentInfo.AddDate = DateTime.Now;
- contentInfo.LastEditUserName = contentInfo.AddUserName;
- contentInfo.LastEditDate = contentInfo.AddDate;
-
- contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
- contentInfo.IsChecked = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel;
-
- contentInfo.Title = formCollection[ContentAttribute.Title];
-
- contentInfo.Id = DataProvider.ContentDao.Insert(tableName, SiteInfo, contentInfo);
-
- CreateManager.CreateContentAndTrigger(SiteId, _channelInfo.Id, contentInfo.Id);
- }
- }
- }
- }
-
- LayerUtils.Close(Page);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageChannel.cs b/SiteServer.BackgroundPages/Cms/PageChannel.cs
deleted file mode 100644
index 21b80c752..000000000
--- a/SiteServer.BackgroundPages/Cms/PageChannel.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageChannel : BasePageCms
- {
- public Repeater RptContents;
-
- public PlaceHolder PhAddChannel;
- public Button BtnAddChannel1;
- public Button BtnAddChannel2;
- public PlaceHolder PhChannelEdit;
- public Button BtnAddToGroup;
- public PlaceHolder PhTranslate;
- public Button BtnTranslate;
- public PlaceHolder PhImport;
- public Button BtnImport;
- public Button BtnExport;
- public PlaceHolder PhDelete;
- public Button BtnDelete;
- public PlaceHolder PhCreate;
- public Button BtnCreate;
-
- private int _currentChannelId;
-
- public static string GetRedirectUrl(int siteId, int currentChannelId)
- {
- if (currentChannelId > 0 && currentChannelId != siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageChannel), new NameValueCollection
- {
- {"CurrentChannelId", currentChannelId.ToString()}
- });
- }
- return PageUtils.GetCmsUrl(siteId, nameof(PageChannel), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (AuthRequest.IsQueryExists("channelId") && (AuthRequest.IsQueryExists("Subtract") || AuthRequest.IsQueryExists("Add")))
- {
- var channelId = AuthRequest.GetQueryInt("channelId");
- if (SiteId != channelId)
- {
- var isSubtract = AuthRequest.IsQueryExists("Subtract");
- DataProvider.ChannelDao.UpdateTaxis(SiteId, channelId, isSubtract);
-
- AuthRequest.AddSiteLog(SiteId, channelId, 0, "栏目排序" + (isSubtract ? "上升" : "下降"),
- $"栏目:{ChannelManager.GetChannelName(SiteId, channelId)}");
-
- PageUtils.Redirect(GetRedirectUrl(SiteId, channelId));
- return;
- }
- }
-
- if (IsPostBack) return;
-
- ClientScriptRegisterClientScriptBlock("NodeTreeScript", ChannelLoading.GetScript(SiteInfo, string.Empty, ELoadingType.Channel, null));
-
- if (AuthRequest.IsQueryExists("CurrentChannelId"))
- {
- _currentChannelId = AuthRequest.GetQueryInt("CurrentChannelId");
- var onLoadScript = ChannelLoading.GetScriptOnLoad(SiteId, _currentChannelId);
- if (!string.IsNullOrEmpty(onLoadScript))
- {
- ClientScriptRegisterClientScriptBlock("NodeTreeScriptOnLoad", onLoadScript);
- }
- }
-
- PhAddChannel.Visible = HasChannelPermissionsIgnoreChannelId(ConfigManager.ChannelPermissions.ChannelAdd);
- if (PhAddChannel.Visible)
- {
- BtnAddChannel1.Attributes.Add("onclick", ModalChannelsAdd.GetOpenWindowString(SiteId, SiteId, GetRedirectUrl(SiteId, SiteId)));
- BtnAddChannel2.Attributes.Add("onclick",
- $"location.href='{PageChannelAdd.GetRedirectUrl(SiteId, SiteId, GetRedirectUrl(SiteId, 0))}';return false;");
- }
-
- PhChannelEdit.Visible = HasChannelPermissionsIgnoreChannelId(ConfigManager.ChannelPermissions.ChannelEdit);
- if (PhChannelEdit.Visible)
- {
- var showPopWinString = ModalAddToGroup.GetOpenWindowStringToChannel(SiteId);
- BtnAddToGroup.Attributes.Add("onclick", showPopWinString);
- }
-
- PhTranslate.Visible = HasChannelPermissionsIgnoreChannelId(ConfigManager.ChannelPermissions.ChannelTranslate);
- if (PhTranslate.Visible)
- {
- BtnTranslate.Attributes.Add("onclick",
- PageUtils.GetRedirectStringWithCheckBoxValue(
- PageChannelTranslate.GetRedirectUrl(SiteId,
- GetRedirectUrl(SiteId, _currentChannelId)), "ChannelIDCollection",
- "ChannelIDCollection", "请选择需要转移的栏目!"));
- }
-
- PhDelete.Visible = HasChannelPermissionsIgnoreChannelId(ConfigManager.ChannelPermissions.ChannelDelete);
- if (PhDelete.Visible)
- {
- BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValue(PageChannelDelete.GetRedirectUrl(SiteId, GetRedirectUrl(SiteId, SiteId)), "ChannelIDCollection", "ChannelIDCollection", "请选择需要删除的栏目!"));
- }
-
- PhCreate.Visible = HasSitePermissions(ConfigManager.WebSitePermissions.Create) || HasChannelPermissionsIgnoreChannelId(ConfigManager.ChannelPermissions.CreatePage);
- if (PhCreate.Visible)
- {
- BtnCreate.Attributes.Add("onclick", ModalCreateChannels.GetOpenWindowString(SiteId));
- }
-
- PhImport.Visible = PhAddChannel.Visible;
- if (PhImport.Visible)
- {
- BtnImport.Attributes.Add("onclick", ModalChannelImport.GetOpenWindowString(SiteId, SiteId));
- }
- BtnExport.Attributes.Add("onclick", ModalExportMessage.GetOpenWindowStringToChannel(SiteId, "ChannelIDCollection", "请选择需要导出的栏目!"));
-
- var channelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(SiteId, SiteId), EScopeType.SelfAndChildren, string.Empty, string.Empty, string.Empty);
-
- RptContents.DataSource = channelIdList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- var channelId = (int)e.Item.DataItem;
- var enabled = IsOwningChannelId(channelId);
- if (!enabled)
- {
- if (!IsDescendantOwningChannelId(channelId)) e.Item.Visible = false;
- }
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
-
- var ltlHtml = (Literal)e.Item.FindControl("ltlHtml");
-
- ltlHtml.Text = ChannelLoading.GetChannelRowHtml(SiteInfo, nodeInfo, enabled, ELoadingType.Channel, null, AuthRequest.AdminPermissions);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageChannelAdd.cs b/SiteServer.BackgroundPages/Cms/PageChannelAdd.cs
deleted file mode 100644
index 882fae1e0..000000000
--- a/SiteServer.BackgroundPages/Cms/PageChannelAdd.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.CMS.Plugin;
-using SiteServer.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageChannelAdd : BasePageCms
- {
- public DropDownList DdlParentChannelId;
- public TextBox TbNodeName;
- public TextBox TbNodeIndexName;
- public DropDownList DdlContentModelPluginId;
- public PlaceHolder PhContentRelatedPluginIds;
- public CheckBoxList CblContentRelatedPluginIds;
- public TextBox TbLinkUrl;
- public CheckBoxList CblNodeGroupNameCollection;
- public DropDownList DdlLinkType;
- public DropDownList DdlTaxisType;
- public DropDownList DdlChannelTemplateId;
- public DropDownList DdlContentTemplateId;
- public RadioButtonList RblIsChannelAddable;
- public RadioButtonList RblIsContentAddable;
- public TextBox TbImageUrl;
- public TextBox TbFilePath;
- public TextBox TbChannelFilePathRule;
- public TextBox TbContentFilePathRule;
-
- public TextEditorControl TbContent;
- public TextBox TbKeywords;
- public TextBox TbDescription;
-
- public ChannelAuxiliaryControl CacAttributes;
-
- public Button BtnCreateChannelRule;
- public Button BtnCreateContentRule;
- public Button BtnSelectImage;
- public Button BtnUploadImage;
-
- private int _channelId;
-
- public static string GetRedirectUrl(int siteId, int channelId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageChannelAdd), new NameValueCollection
- {
- {"channelId", channelId.ToString() },
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl) }
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl");
- _channelId = AuthRequest.GetQueryInt("channelId");
- ReturnUrl = StringUtils.ValueFromUrl(PageUtils.FilterSqlAndXss(AuthRequest.GetQueryString("ReturnUrl")));
- //if (!base.HasChannelPermissions(this.channelId, AppManager.CMS.Permission.Channel.ChannelAdd))
- //{
- // PageUtils.RedirectToErrorPage("您没有添加栏目的权限!");
- // return;
- //}
-
- var parentNodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- if (parentNodeInfo.Additional.IsChannelAddable == false)
- {
- PageUtils.RedirectToErrorPage("此栏目不能添加子栏目!");
- return;
- }
-
- CacAttributes.SiteInfo = SiteInfo;
- CacAttributes.ChannelId = _channelId;
-
- if (!IsPostBack)
- {
- ChannelManager.AddListItems(DdlParentChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions);
- ControlUtils.SelectSingleItem(DdlParentChannelId, _channelId.ToString());
-
- DdlContentModelPluginId.Items.Add(new ListItem("<默认>", string.Empty));
- var contentTables = PluginContentManager.GetContentModelPlugins();
- foreach (var contentTable in contentTables)
- {
- DdlContentModelPluginId.Items.Add(new ListItem(contentTable.Title, contentTable.Id));
- }
- ControlUtils.SelectSingleItem(DdlContentModelPluginId, parentNodeInfo.ContentModelPluginId);
-
- var plugins = PluginContentManager.GetAllContentRelatedPlugins(false);
- if (plugins.Count > 0)
- {
- foreach (var pluginMetadata in plugins)
- {
- CblContentRelatedPluginIds.Items.Add(new ListItem(pluginMetadata.Title, pluginMetadata.Id));
- }
- }
- else
- {
- PhContentRelatedPluginIds.Visible = false;
- }
-
- CacAttributes.Attributes = new ExtendedAttributes();
-
- TbImageUrl.Attributes.Add("onchange", GetShowImageScript("preview_NavigationPicPath", SiteInfo.Additional.WebUrl));
-
- var showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, true, TbChannelFilePathRule.ClientID);
- BtnCreateChannelRule.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, false, TbContentFilePathRule.ClientID);
- BtnCreateContentRule.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalSelectImage.GetOpenWindowString(SiteInfo, TbImageUrl.ClientID);
- BtnSelectImage.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalUploadImage.GetOpenWindowString(SiteId, TbImageUrl.ClientID);
- BtnUploadImage.Attributes.Add("onclick", showPopWinString);
-
- ELinkTypeUtils.AddListItems(DdlLinkType);
-
- ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType);
- ControlUtils.SelectSingleItem(DdlTaxisType, ETaxisTypeUtils.GetValue(ETaxisType.OrderByTaxisDesc));
-
- CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId);
- DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);
- DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);
-
- DataBind();
-
- DdlChannelTemplateId.Items.Insert(0, new ListItem("<默认>", "0"));
- DdlChannelTemplateId.Items[0].Selected = true;
-
- DdlContentTemplateId.Items.Insert(0, new ListItem("<默认>", "0"));
- DdlContentTemplateId.Items[0].Selected = true;
- TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, string.Empty);
- }
- else
- {
- CacAttributes.Attributes = new ExtendedAttributes(Request.Form);
- }
- }
-
- public void DdlParentChannelId_SelectedIndexChanged(object sender, EventArgs e)
- {
- var theChannelId = TranslateUtils.ToInt(DdlParentChannelId.SelectedValue);
- if (theChannelId == 0)
- {
- theChannelId = _channelId;
- }
- PageUtils.Redirect(GetRedirectUrl(SiteId, theChannelId, AuthRequest.GetQueryString("ReturnUrl")));
- }
-
- public string PreviewImageSrc
- {
- get
- {
- if (string.IsNullOrEmpty(TbImageUrl.Text)) return SiteServerAssets.GetIconUrl("empty.gif");
-
- var extension = PathUtils.GetExtension(TbImageUrl.Text);
- if (EFileSystemTypeUtils.IsImage(extension))
- {
- return PageUtility.ParseNavigationUrl(SiteInfo, TbImageUrl.Text, true);
- }
- if (EFileSystemTypeUtils.IsFlash(extension))
- {
- return SiteServerAssets.GetIconUrl("flash.jpg");
- }
- if (EFileSystemTypeUtils.IsPlayer(extension))
- {
- return SiteServerAssets.GetIconUrl("player.gif");
- }
- return SiteServerAssets.GetIconUrl("empty.gif");
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- int insertChannelId;
- try
- {
- var channelId = AuthRequest.GetQueryInt("ChannelId");
- var nodeInfo = new ChannelInfo
- {
- ParentId = channelId,
- ContentModelPluginId = DdlContentModelPluginId.SelectedValue,
- ContentRelatedPluginIds =
- ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds)
- };
-
- if (TbNodeIndexName.Text.Length != 0)
- {
- var nodeIndexNameArrayList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
- if (nodeIndexNameArrayList.IndexOf(TbNodeIndexName.Text) != -1)
- {
- FailMessage("栏目添加失败,栏目索引已存在!");
- return;
- }
- }
-
- if (TbFilePath.Text.Length != 0)
- {
- if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
- {
- FailMessage("栏目页面路径不符合系统要求!");
- return;
- }
-
- if (PathUtils.IsDirectoryPath(TbFilePath.Text))
- {
- TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
- }
-
- var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
- if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
- {
- FailMessage("栏目添加失败,栏目页面路径已存在!");
- return;
- }
- }
-
- if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
- {
- if (!DirectoryUtils.IsDirectoryNameCompliant(TbChannelFilePathRule.Text))
- {
- FailMessage("栏目页面命名规则不符合系统要求!");
- return;
- }
- if (PathUtils.IsDirectoryPath(TbChannelFilePathRule.Text))
- {
- FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
- return;
- }
- }
-
- if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
- {
- if (!DirectoryUtils.IsDirectoryNameCompliant(TbContentFilePathRule.Text))
- {
- FailMessage("内容页面命名规则不符合系统要求!");
- return;
- }
- if (PathUtils.IsDirectoryPath(TbContentFilePathRule.Text))
- {
- FailMessage("内容页面命名规则必须包含生成文件的后缀!");
- return;
- }
- }
-
- var extendedAttributes = new ExtendedAttributes();
- var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
- var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities);
- BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
- var attributes = extendedAttributes.ToNameValueCollection();
- nodeInfo.Additional.Load(attributes);
- //foreach (string key in attributes)
- //{
- // nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]);
- //}
-
- nodeInfo.ChannelName = TbNodeName.Text;
- nodeInfo.IndexName = TbNodeIndexName.Text;
- nodeInfo.FilePath = TbFilePath.Text;
- nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
- nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text;
-
- var list = new ArrayList();
- foreach (ListItem item in CblNodeGroupNameCollection.Items)
- {
- if (item.Selected)
- {
- list.Add(item.Value);
- }
- }
- nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
- nodeInfo.ImageUrl = TbImageUrl.Text;
- nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
- nodeInfo.Keywords = TbKeywords.Text;
- nodeInfo.Description = TbDescription.Text;
- nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
- nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);
-
- nodeInfo.LinkUrl = TbLinkUrl.Text;
- nodeInfo.LinkType = DdlLinkType.SelectedValue;
-
- nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
-
- nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
- nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;
-
- nodeInfo.AddDate = DateTime.Now;
- insertChannelId = DataProvider.ChannelDao.Insert(nodeInfo);
- //栏目选择投票样式后,内容
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(ex);
- FailMessage(ex, $"栏目添加失败:{ex.Message}");
- return;
- }
-
- CreateManager.CreateChannel(SiteId, insertChannelId);
-
- AuthRequest.AddSiteLog(SiteId, "添加栏目", $"栏目:{TbNodeName.Text}");
-
- SuccessMessage("栏目添加成功!");
- AddWaitAndRedirectScript(ReturnUrl);
- }
-
- public string ReturnUrl { get; private set; }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageChannelDelete.cs b/SiteServer.BackgroundPages/Cms/PageChannelDelete.cs
deleted file mode 100644
index 9a8938204..000000000
--- a/SiteServer.BackgroundPages/Cms/PageChannelDelete.cs
+++ /dev/null
@@ -1,158 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using System.Collections.Generic;
-using SiteServer.CMS.Core.Create;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageChannelDelete : BasePageCms
- {
- public Literal LtlPageTitle;
- public RadioButtonList RblRetainFiles;
- public Button BtnDelete;
-
- private bool _deleteContents;
- private readonly List _nodeNameList = new List();
-
- public string ReturnUrl { get; private set; }
-
- public static string GetRedirectUrl(int siteId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageChannelDelete), new NameValueCollection
- {
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "ReturnUrl");
- ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
- _deleteContents = AuthRequest.GetQueryBool("DeleteContents");
-
- if (IsPostBack) return;
-
- var channelIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("ChannelIDCollection"));
- channelIdList.Sort();
- channelIdList.Reverse();
- foreach (var channelId in channelIdList)
- {
- if (channelId == SiteId) continue;
- if (!HasChannelPermissions(channelId, ConfigManager.ChannelPermissions.ChannelDelete)) continue;
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- var displayName = nodeInfo.ChannelName;
- if (nodeInfo.ContentNum > 0)
- {
- displayName += $"({nodeInfo.ContentNum})";
- }
- _nodeNameList.Add(displayName);
- }
-
- if (_nodeNameList.Count == 0)
- {
- BtnDelete.Enabled = false;
- }
- else
- {
- if (_deleteContents)
- {
- LtlPageTitle.Text = "删除内容";
- InfoMessage(
- $"此操作将会删除栏目“{TranslateUtils.ObjectCollectionToString(_nodeNameList)}”下的所有内容,确认吗?");
- }
- else
- {
- LtlPageTitle.Text = "删除栏目";
- InfoMessage(
- $"此操作将会删除栏目“{TranslateUtils.ObjectCollectionToString(_nodeNameList)}”及包含的下级栏目,确认吗?");
- }
- }
- }
-
- public void Delete_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- try
- {
- var channelIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("ChannelIDCollection"));
- channelIdList.Sort();
- channelIdList.Reverse();
-
- var channelIdListToDelete = new List();
- foreach (var channelId in channelIdList)
- {
- if (channelId == SiteId) continue;
- if (HasChannelPermissions(channelId, ConfigManager.ChannelPermissions.ChannelDelete))
- {
- channelIdListToDelete.Add(channelId);
- }
- }
-
- var builder = new StringBuilder();
- foreach (var channelId in channelIdListToDelete)
- {
- builder.Append(ChannelManager.GetChannelName(SiteId, channelId)).Append(",");
- }
-
- if (builder.Length > 0)
- {
- builder.Length -= 1;
- }
-
- if (_deleteContents)
- {
- SuccessMessage(bool.Parse(RblRetainFiles.SelectedValue) == false
- ? "成功删除内容以及生成页面!"
- : "成功删除内容,生成页面未被删除!");
-
- foreach (var channelId in channelIdListToDelete)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- var contentIdList = DataProvider.ContentDao.GetContentIdList(tableName, channelId);
- DeleteManager.DeleteContents(SiteInfo, channelId, contentIdList);
- DataProvider.ContentDao.TrashContents(SiteId, tableName, contentIdList);
- }
-
- AuthRequest.AddSiteLog(SiteId, "清空栏目下的内容", $"栏目:{builder}");
- }
- else
- {
- if (bool.Parse(RblRetainFiles.SelectedValue) == false)
- {
- DeleteManager.DeleteChannels(SiteInfo, channelIdListToDelete);
- SuccessMessage("成功删除栏目以及相关生成页面!");
- }
- else
- {
- SuccessMessage("成功删除栏目,相关生成页面未被删除!");
- }
-
- foreach (var channelId in channelIdListToDelete)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- DataProvider.ContentDao.TrashContentsByChannelId(SiteId, tableName, channelId);
- DataProvider.ChannelDao.Delete(SiteId, channelId);
- }
-
- AuthRequest.AddSiteLog(SiteId, "删除栏目", $"栏目:{builder}");
- }
-
- AddWaitAndRedirectScript(ReturnUrl);
- }
- catch (Exception ex)
- {
- FailMessage(ex, _deleteContents ? "删除内容失败!" : "删除栏目失败!");
-
- LogUtils.AddErrorLog(ex);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageChannelEdit.cs b/SiteServer.BackgroundPages/Cms/PageChannelEdit.cs
deleted file mode 100644
index 54a8a0f0b..000000000
--- a/SiteServer.BackgroundPages/Cms/PageChannelEdit.cs
+++ /dev/null
@@ -1,317 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.CMS.Plugin;
-using SiteServer.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageChannelEdit : BasePageCms
- {
- public TextBox TbNodeName;
- public TextBox TbNodeIndexName;
- public DropDownList DdlContentModelPluginId;
- public PlaceHolder PhContentRelatedPluginIds;
- public CheckBoxList CblContentRelatedPluginIds;
- public CheckBoxList CblNodeGroupNameCollection;
- public RadioButtonList RblIsChannelAddable;
- public RadioButtonList RblIsContentAddable;
- public TextBox TbLinkUrl;
- public DropDownList DdlLinkType;
- public DropDownList DdlTaxisType;
- public DropDownList DdlChannelTemplateId;
- public DropDownList DdlContentTemplateId;
- public TextBox TbImageUrl;
- public TextBox TbFilePath;
- public TextBox TbChannelFilePathRule;
- public TextBox TbContentFilePathRule;
- public TextEditorControl TbContent;
- public TextBox TbKeywords;
- public TextBox TbDescription;
- public ChannelAuxiliaryControl CacAttributes;
- public Button BtnCreateChannelRule;
- public Button BtnCreateContentRule;
- public Button BtnSelectImage;
- public Button BtnUploadImage;
- public Button BtnSubmit;
-
- private int _channelId;
-
- public static string GetRedirectUrl(int siteId, int channelId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageChannelEdit), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "ReturnUrl");
-
- _channelId = AuthRequest.GetQueryInt("channelId");
- ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
-
- if (AuthRequest.GetQueryString("CanNotEdit") == null && AuthRequest.GetQueryString("UncheckedChannel") == null)
- {
- if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ChannelEdit))
- {
- PageUtils.RedirectToErrorPage("您没有修改栏目的权限!");
- return;
- }
- }
- if (AuthRequest.IsQueryExists("CanNotEdit"))
- {
- BtnSubmit.Visible = false;
- }
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- if (nodeInfo == null) return;
-
- CacAttributes.SiteInfo = SiteInfo;
- CacAttributes.ChannelId = _channelId;
-
- if (!IsPostBack)
- {
- DdlContentModelPluginId.Items.Add(new ListItem("<默认>", string.Empty));
- var contentTables = PluginContentManager.GetContentModelPlugins();
- foreach (var contentTable in contentTables)
- {
- DdlContentModelPluginId.Items.Add(new ListItem(contentTable.Title, contentTable.Id));
- }
- ControlUtils.SelectSingleItem(DdlContentModelPluginId, nodeInfo.ContentModelPluginId);
-
- var plugins = PluginContentManager.GetAllContentRelatedPlugins(false);
- if (plugins.Count > 0)
- {
- var relatedPluginIds =
- TranslateUtils.StringCollectionToStringList(nodeInfo.ContentRelatedPluginIds);
- foreach (var pluginMetadata in plugins)
- {
- CblContentRelatedPluginIds.Items.Add(new ListItem(pluginMetadata.Title, pluginMetadata.Id)
- {
- Selected = relatedPluginIds.Contains(pluginMetadata.Id)
- });
- }
- }
- else
- {
- PhContentRelatedPluginIds.Visible = false;
- }
-
- CacAttributes.Attributes = nodeInfo.Additional;
-
- TbImageUrl.Attributes.Add("onchange", GetShowImageScript("preview_NavigationPicPath", SiteInfo.Additional.WebUrl));
-
- var showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, true, TbChannelFilePathRule.ClientID);
- BtnCreateChannelRule.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalFilePathRule.GetOpenWindowString(SiteId, _channelId, false, TbContentFilePathRule.ClientID);
- BtnCreateContentRule.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalSelectImage.GetOpenWindowString(SiteInfo, TbImageUrl.ClientID);
- BtnSelectImage.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalUploadImage.GetOpenWindowString(SiteId, TbImageUrl.ClientID);
- BtnUploadImage.Attributes.Add("onclick", showPopWinString);
-
- ELinkTypeUtils.AddListItems(DdlLinkType);
- ETaxisTypeUtils.AddListItemsForChannelEdit(DdlTaxisType);
-
- CblNodeGroupNameCollection.DataSource = DataProvider.ChannelGroupDao.GetDataSource(SiteId);
-
- DdlChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);
-
- DdlContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);
-
- DataBind();
-
- DdlChannelTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
- ControlUtils.SelectSingleItem(DdlChannelTemplateId, nodeInfo.ChannelTemplateId.ToString());
-
- DdlContentTemplateId.Items.Insert(0, new ListItem("<未设置>", "0"));
- ControlUtils.SelectSingleItem(DdlContentTemplateId, nodeInfo.ContentTemplateId.ToString());
-
- TbNodeName.Text = nodeInfo.ChannelName;
- TbNodeIndexName.Text = nodeInfo.IndexName;
- TbLinkUrl.Text = nodeInfo.LinkUrl;
-
- foreach (ListItem item in CblNodeGroupNameCollection.Items)
- {
- item.Selected = StringUtils.In(nodeInfo.GroupNameCollection, item.Value);
- }
- TbFilePath.Text = nodeInfo.FilePath;
- TbChannelFilePathRule.Text = nodeInfo.ChannelFilePathRule;
- TbContentFilePathRule.Text = nodeInfo.ContentFilePathRule;
-
- ControlUtils.SelectSingleItem(DdlLinkType, nodeInfo.LinkType);
- ControlUtils.SelectSingleItem(DdlTaxisType, nodeInfo.Additional.DefaultTaxisType);
- ControlUtils.SelectSingleItem(RblIsChannelAddable, nodeInfo.Additional.IsChannelAddable.ToString());
- ControlUtils.SelectSingleItem(RblIsContentAddable, nodeInfo.Additional.IsContentAddable.ToString());
-
- TbImageUrl.Text = nodeInfo.ImageUrl;
-
- TbContent.SetParameters(SiteInfo, ChannelAttribute.Content, nodeInfo.Content);
-
- TbKeywords.Text = nodeInfo.Keywords;
- TbDescription.Text = nodeInfo.Description;
-
- //this.Content.SiteId = base.SiteId;
- //this.Content.Text = StringUtility.TextEditorContentDecode(nodeInfo.Content, ConfigUtils.Instance.ApplicationPath, base.SiteInfo.SiteUrl);
- }
- else
- {
- CacAttributes.Attributes = new ExtendedAttributes(Request.Form);
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- ChannelInfo nodeInfo;
- try
- {
- nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
- {
- var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
- if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
- {
- FailMessage("栏目属性修改失败,栏目索引已存在!");
- return;
- }
- }
-
- if (nodeInfo.ContentModelPluginId != DdlContentModelPluginId.SelectedValue)
- {
- nodeInfo.ContentModelPluginId = DdlContentModelPluginId.SelectedValue;
- nodeInfo.ContentNum = DataProvider.ContentDao.GetCount(ChannelManager.GetTableName(SiteInfo, nodeInfo.ContentModelPluginId), nodeInfo.Id);
- }
-
- nodeInfo.ContentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds);
-
- TbFilePath.Text = TbFilePath.Text.Trim();
- if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
- {
- if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
- {
- FailMessage("栏目页面路径不符合系统要求!");
- return;
- }
-
- if (PathUtils.IsDirectoryPath(TbFilePath.Text))
- {
- TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
- }
-
- var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
- if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
- {
- FailMessage("栏目修改失败,栏目页面路径已存在!");
- return;
- }
- }
-
- if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
- {
- var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty);
- if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
- {
- FailMessage("栏目页面命名规则不符合系统要求!");
- return;
- }
- if (PathUtils.IsDirectoryPath(filePathRule))
- {
- FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
- return;
- }
- }
-
- if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
- {
- var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty);
- if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
- {
- FailMessage("内容页面命名规则不符合系统要求!");
- return;
- }
- if (PathUtils.IsDirectoryPath(filePathRule))
- {
- FailMessage("内容页面命名规则必须包含生成文件的后缀!");
- return;
- }
- }
-
- var extendedAttributes = new ExtendedAttributes();
- var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
- var styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName, relatedIdentities);
- BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
- var attributes = extendedAttributes.ToNameValueCollection();
- foreach (string key in attributes)
- {
- nodeInfo.Additional.Set(key, attributes[key]);
- }
-
- nodeInfo.ChannelName = TbNodeName.Text;
- nodeInfo.IndexName = TbNodeIndexName.Text;
- nodeInfo.FilePath = TbFilePath.Text;
- nodeInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
- nodeInfo.ContentFilePathRule = TbContentFilePathRule.Text;
-
- var list = new ArrayList();
- foreach (ListItem item in CblNodeGroupNameCollection.Items)
- {
- if (item.Selected)
- {
- list.Add(item.Value);
- }
- }
- nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
- nodeInfo.ImageUrl = TbImageUrl.Text;
- nodeInfo.Content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
-
- nodeInfo.Keywords = TbKeywords.Text;
- nodeInfo.Description = TbDescription.Text;
-
- nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue);
- nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue);
-
- nodeInfo.LinkUrl = TbLinkUrl.Text;
- nodeInfo.LinkType = DdlLinkType.SelectedValue;
- nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
- nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
- nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;
-
- DataProvider.ChannelDao.Update(nodeInfo);
- }
- catch (Exception ex)
- {
- FailMessage(ex, $"栏目修改失败:{ex.Message}");
- LogUtils.AddErrorLog(ex);
- return;
- }
-
- CreateManager.CreateChannel(SiteId, nodeInfo.Id);
-
- AuthRequest.AddSiteLog(SiteId, "修改栏目", $"栏目:{TbNodeName.Text}");
-
- SuccessMessage("栏目修改成功!");
- PageUtils.Redirect(ReturnUrl);
- }
-
- public string ReturnUrl { get; private set; }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationContent.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationContent.cs
deleted file mode 100644
index eb840e063..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationContent.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationContent : BasePageCms
- {
- public DropDownList DdlIsSaveImageInTextEditor;
- public DropDownList DdlIsAutoPageInTextEditor;
- public PlaceHolder PhAutoPage;
- public TextBox TbAutoPageWordNum;
- public DropDownList DdlIsContentTitleBreakLine;
- public DropDownList DdlIsCheckContentUseLevel;
- public PlaceHolder PhCheckContentLevel;
- public DropDownList DdlCheckContentLevel;
- public DropDownList DdlIsAutoCheckKeywords;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageConfigurationContent), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- EBooleanUtils.AddListItems(DdlIsSaveImageInTextEditor, "保存", "不保存");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsSaveImageInTextEditor, SiteInfo.Additional.IsSaveImageInTextEditor.ToString());
-
- EBooleanUtils.AddListItems(DdlIsAutoPageInTextEditor, "自动分页", "手动分页");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsAutoPageInTextEditor, SiteInfo.Additional.IsAutoPageInTextEditor.ToString());
-
- PhAutoPage.Visible = SiteInfo.Additional.IsAutoPageInTextEditor;
- TbAutoPageWordNum.Text = SiteInfo.Additional.AutoPageWordNum.ToString();
-
- EBooleanUtils.AddListItems(DdlIsContentTitleBreakLine, "启用标题换行", "不启用");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsContentTitleBreakLine, SiteInfo.Additional.IsContentTitleBreakLine.ToString());
-
- //保存时,敏感词自动检测
- EBooleanUtils.AddListItems(DdlIsAutoCheckKeywords, "启用敏感词自动检测", "不启用");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsAutoCheckKeywords, SiteInfo.Additional.IsAutoCheckKeywords.ToString());
-
- DdlIsCheckContentUseLevel.Items.Add(new ListItem("默认审核机制", false.ToString()));
- DdlIsCheckContentUseLevel.Items.Add(new ListItem("多级审核机制", true.ToString()));
-
- ControlUtils.SelectSingleItem(DdlIsCheckContentUseLevel, SiteInfo.Additional.IsCheckContentLevel.ToString());
- if (SiteInfo.Additional.IsCheckContentLevel)
- {
- ControlUtils.SelectSingleItem(DdlCheckContentLevel, SiteInfo.Additional.CheckContentLevel.ToString());
- PhCheckContentLevel.Visible = true;
- }
- else
- {
- PhCheckContentLevel.Visible = false;
- }
- }
-
- public void DdlIsAutoPageInTextEditor_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- PhAutoPage.Visible = EBooleanUtils.Equals(DdlIsAutoPageInTextEditor.SelectedValue, EBoolean.True);
- }
-
- public void DdlIsCheckContentUseLevel_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- PhCheckContentLevel.Visible = EBooleanUtils.Equals(DdlIsCheckContentUseLevel.SelectedValue, EBoolean.True);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- SiteInfo.Additional.IsSaveImageInTextEditor = TranslateUtils.ToBool(DdlIsSaveImageInTextEditor.SelectedValue, true);
-
- var isReCaculate = false;
- if (TranslateUtils.ToBool(DdlIsAutoPageInTextEditor.SelectedValue, false))
- {
- if (SiteInfo.Additional.IsAutoPageInTextEditor == false)
- {
- isReCaculate = true;
- }
- else if (SiteInfo.Additional.AutoPageWordNum != TranslateUtils.ToInt(TbAutoPageWordNum.Text, SiteInfo.Additional.AutoPageWordNum))
- {
- isReCaculate = true;
- }
- }
-
- SiteInfo.Additional.IsAutoPageInTextEditor = TranslateUtils.ToBool(DdlIsAutoPageInTextEditor.SelectedValue, false);
-
- SiteInfo.Additional.AutoPageWordNum = TranslateUtils.ToInt(TbAutoPageWordNum.Text, SiteInfo.Additional.AutoPageWordNum);
-
- SiteInfo.Additional.IsContentTitleBreakLine = TranslateUtils.ToBool(DdlIsContentTitleBreakLine.SelectedValue, true);
-
- SiteInfo.Additional.IsAutoCheckKeywords = TranslateUtils.ToBool(DdlIsAutoCheckKeywords.SelectedValue, true);
-
- SiteInfo.Additional.IsCheckContentLevel = TranslateUtils.ToBool(DdlIsCheckContentUseLevel.SelectedValue);
- if (SiteInfo.Additional.IsCheckContentLevel)
- {
- SiteInfo.Additional.CheckContentLevel = TranslateUtils.ToInt(DdlCheckContentLevel.SelectedValue);
- }
-
- DataProvider.SiteDao.Update(SiteInfo);
- if (isReCaculate)
- {
- DataProvider.ContentDao.UpdateAutoPageContent(SiteInfo.TableName, SiteInfo);
- }
-
- AuthRequest.AddSiteLog(SiteId, "修改内容设置");
-
- SuccessMessage("内容设置修改成功!");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationCreate.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationCreate.cs
deleted file mode 100644
index 8e47a46ea..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationCreate.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationCreate : BasePageCms
- {
- public DropDownList DdlIsCreateContentIfContentChanged;
- public DropDownList DdlIsCreateChannelIfChannelChanged;
- public DropDownList DdlIsCreateShowPageInfo;
- public DropDownList DdlIsCreateIe8Compatible;
- public DropDownList DdlIsCreateBrowserNoCache;
- public DropDownList DdlIsCreateJsIgnoreError;
- public DropDownList DdlIsCreateSearchDuplicate;
- public DropDownList DdlIsCreateWithJQuery;
- public DropDownList DdlIsCreateDoubleClick;
- public TextBox TbCreateStaticMaxPage;
- public DropDownList DdlIsCreateStaticContentByAddDate;
- public PlaceHolder PhIsCreateStaticContentByAddDate;
- public DateTimeTextBox TbCreateStaticContentAddDate;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Create);
-
- EBooleanUtils.AddListItems(DdlIsCreateContentIfContentChanged, "生成", "不生成");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateContentIfContentChanged, SiteInfo.Additional.IsCreateContentIfContentChanged.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateChannelIfChannelChanged, "生成", "不生成");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateChannelIfChannelChanged, SiteInfo.Additional.IsCreateChannelIfChannelChanged.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateShowPageInfo, "显示", "不显示");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateShowPageInfo, SiteInfo.Additional.IsCreateShowPageInfo.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateIe8Compatible, "强制兼容", "不设置");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateIe8Compatible, SiteInfo.Additional.IsCreateIe8Compatible.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateBrowserNoCache, "强制清除缓存", "不设置");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateBrowserNoCache, SiteInfo.Additional.IsCreateBrowserNoCache.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateJsIgnoreError, "包含JS容错代码", "不设置");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateJsIgnoreError, SiteInfo.Additional.IsCreateJsIgnoreError.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateSearchDuplicate, "包含", "不包含");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateSearchDuplicate, SiteInfo.Additional.IsCreateSearchDuplicate.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateWithJQuery, "是", "否");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateWithJQuery, SiteInfo.Additional.IsCreateWithJQuery.ToString());
-
- EBooleanUtils.AddListItems(DdlIsCreateDoubleClick, "启用双击生成", "不启用");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateDoubleClick, SiteInfo.Additional.IsCreateDoubleClick.ToString());
-
- TbCreateStaticMaxPage.Text = SiteInfo.Additional.CreateStaticMaxPage.ToString();
-
- EBooleanUtils.AddListItems(DdlIsCreateStaticContentByAddDate, "启用", "不启用");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateStaticContentByAddDate, SiteInfo.Additional.IsCreateStaticContentByAddDate.ToString());
- PhIsCreateStaticContentByAddDate.Visible = SiteInfo.Additional.IsCreateStaticContentByAddDate;
- if (SiteInfo.Additional.CreateStaticContentAddDate != DateTime.MinValue)
- {
- TbCreateStaticContentAddDate.DateTime = SiteInfo.Additional.CreateStaticContentAddDate;
- }
- }
-
- public void DdlIsCreateStaticContentByAddDate_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhIsCreateStaticContentByAddDate.Visible = TranslateUtils.ToBool(DdlIsCreateStaticContentByAddDate.SelectedValue);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- SiteInfo.Additional.IsCreateContentIfContentChanged = TranslateUtils.ToBool(DdlIsCreateContentIfContentChanged.SelectedValue);
- SiteInfo.Additional.IsCreateChannelIfChannelChanged = TranslateUtils.ToBool(DdlIsCreateChannelIfChannelChanged.SelectedValue);
-
- SiteInfo.Additional.IsCreateShowPageInfo = TranslateUtils.ToBool(DdlIsCreateShowPageInfo.SelectedValue);
- SiteInfo.Additional.IsCreateIe8Compatible = TranslateUtils.ToBool(DdlIsCreateIe8Compatible.SelectedValue);
- SiteInfo.Additional.IsCreateBrowserNoCache = TranslateUtils.ToBool(DdlIsCreateBrowserNoCache.SelectedValue);
- SiteInfo.Additional.IsCreateJsIgnoreError = TranslateUtils.ToBool(DdlIsCreateJsIgnoreError.SelectedValue);
- SiteInfo.Additional.IsCreateSearchDuplicate = TranslateUtils.ToBool(DdlIsCreateSearchDuplicate.SelectedValue);
- SiteInfo.Additional.IsCreateWithJQuery = TranslateUtils.ToBool(DdlIsCreateWithJQuery.SelectedValue);
-
- SiteInfo.Additional.IsCreateDoubleClick = TranslateUtils.ToBool(DdlIsCreateDoubleClick.SelectedValue);
- SiteInfo.Additional.CreateStaticMaxPage = TranslateUtils.ToInt(TbCreateStaticMaxPage.Text);
-
- SiteInfo.Additional.IsCreateStaticContentByAddDate = TranslateUtils.ToBool(DdlIsCreateStaticContentByAddDate.SelectedValue);
- if (SiteInfo.Additional.IsCreateStaticContentByAddDate)
- {
- SiteInfo.Additional.CreateStaticContentAddDate = TbCreateStaticContentAddDate.DateTime;
- }
-
- DataProvider.SiteDao.Update(SiteInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改页面生成设置");
-
- SuccessMessage("页面生成设置修改成功!");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationCrossSiteTrans.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationCrossSiteTrans.cs
deleted file mode 100644
index b582b9dee..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationCrossSiteTrans.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationCrossSiteTrans : BasePageCms
- {
- public RadioButtonList RblIsCrossSiteTransChecked;
-
- private int _currentChannelId;
-
- public static string GetRedirectUrl(int siteId, int currentChannelId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageConfigurationCrossSiteTrans), new NameValueCollection
- {
- {"CurrentChannelId", currentChannelId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- ClientScriptRegisterClientScriptBlock("NodeTreeScript", ChannelLoading.GetScript(SiteInfo, string.Empty, ELoadingType.ConfigurationCrossSiteTrans, null));
-
- if (AuthRequest.IsQueryExists("CurrentChannelId"))
- {
- _currentChannelId = AuthRequest.GetQueryInt("CurrentChannelId");
- var onLoadScript = ChannelLoading.GetScriptOnLoad(SiteId, _currentChannelId);
- if (!string.IsNullOrEmpty(onLoadScript))
- {
- ClientScriptRegisterClientScriptBlock("NodeTreeScriptOnLoad", onLoadScript);
- }
- }
-
- EBooleanUtils.AddListItems(RblIsCrossSiteTransChecked, "无需审核", "需要审核");
- ControlUtils.SelectSingleItem(RblIsCrossSiteTransChecked, SiteInfo.Additional.IsCrossSiteTransChecked.ToString());
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- SiteInfo.Additional.IsCrossSiteTransChecked = TranslateUtils.ToBool(RblIsCrossSiteTransChecked.SelectedValue);
-
- try
- {
- DataProvider.SiteDao.Update(SiteInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改默认跨站转发设置");
-
- SuccessMessage("默认跨站转发设置修改成功!");
- }
- catch(Exception ex)
- {
- FailMessage(ex, "默认跨站转发设置修改失败!");
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationSite.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationSite.cs
deleted file mode 100644
index 5bacda812..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationSite.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationSite : BasePageCms
- {
- public DropDownList DdlCharset;
- public TextBox TbPageSize;
- public DropDownList DdlIsCreateDoubleClick;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageConfigurationSite), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- ECharsetUtils.AddListItems(DdlCharset);
- ControlUtils.SelectSingleItem(DdlCharset, SiteInfo.Additional.Charset);
-
- TbPageSize.Text = SiteInfo.Additional.PageSize.ToString();
-
- EBooleanUtils.AddListItems(DdlIsCreateDoubleClick, "启用双击生成", "不启用");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsCreateDoubleClick, SiteInfo.Additional.IsCreateDoubleClick.ToString());
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- if (SiteInfo.Additional.Charset != DdlCharset.SelectedValue)
- {
- SiteInfo.Additional.Charset = DdlCharset.SelectedValue;
- }
-
- SiteInfo.Additional.PageSize = TranslateUtils.ToInt(TbPageSize.Text, SiteInfo.Additional.PageSize);
- SiteInfo.Additional.IsCreateDoubleClick = TranslateUtils.ToBool(DdlIsCreateDoubleClick.SelectedValue);
-
- //修改所有模板编码
- var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListBySiteId(SiteId);
- var charset = ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset);
- foreach (var templateInfo in templateInfoList)
- {
- if (templateInfo.Charset == charset) continue;
-
- var templateContent = TemplateManager.GetTemplateContent(SiteInfo, templateInfo);
- templateInfo.Charset = charset;
- DataProvider.TemplateDao.Update(SiteInfo, templateInfo, templateContent, AuthRequest.AdminName);
- }
-
- DataProvider.SiteDao.Update(SiteInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改站点设置");
-
- SuccessMessage("站点设置修改成功!");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationSiteAttributes.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationSiteAttributes.cs
deleted file mode 100644
index 0b989681e..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationSiteAttributes.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationSiteAttributes : BasePageCms
- {
- public TextBox TbSiteName;
- public Literal LtlAttributes;
- public Button BtnSubmit;
-
- private List _styleInfoList;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageConfigurationSiteAttributes), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- var relatedIdentities = RelatedIdentities.GetRelatedIdentities(SiteId, SiteId);
- _styleInfoList = TableStyleManager.GetTableStyleInfoList(DataProvider.SiteDao.TableName, relatedIdentities);
-
- if (!IsPostBack)
- {
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- TbSiteName.Text = SiteInfo.SiteName;
-
- LtlAttributes.Text = GetAttributesHtml(SiteInfo.Additional.ToNameValueCollection());
-
- BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm"));
- }
- else
- {
- LtlAttributes.Text = GetAttributesHtml(Request.Form);
- }
- }
-
- private string GetAttributesHtml(NameValueCollection formCollection)
- {
- if (formCollection == null)
- {
- formCollection = Request.Form.Count > 0 ? Request.Form : new NameValueCollection();
- }
-
- var pageScripts = new NameValueCollection();
-
- if (_styleInfoList == null) return string.Empty;
-
- var attributes = new ExtendedAttributes(formCollection);
-
- var builder = new StringBuilder();
- foreach (var styleInfo in _styleInfoList)
- {
- string extra;
- var value = BackgroundInputTypeParser.Parse(SiteInfo, 0, styleInfo, attributes, pageScripts, out extra);
- if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra)) continue;
-
- if (InputTypeUtils.Equals(styleInfo.InputType, InputType.TextEditor))
- {
- var commands = WebUtils.GetTextEditorCommands(SiteInfo, styleInfo.AttributeName);
- builder.Append($@"
-
- {styleInfo.DisplayName}
- {commands}
-
- {value}
- {extra}
-
");
- }
- else
- {
- builder.Append($@"
-
- {styleInfo.DisplayName}
- {value}
- {extra}
-
");
- }
- }
-
- foreach (string key in pageScripts.Keys)
- {
- builder.Append(pageScripts[key]);
- }
-
- return builder.ToString();
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- SiteInfo.SiteName = TbSiteName.Text;
-
- BackgroundInputTypeParser.SaveAttributes(SiteInfo.Additional, SiteInfo, _styleInfoList, Page.Request.Form, null);
-
- DataProvider.SiteDao.Update(SiteInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改站点设置");
-
- SuccessMessage("站点设置修改成功!");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationUploadFile.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationUploadFile.cs
deleted file mode 100644
index f353121fe..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationUploadFile.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationUploadFile : BasePageCms
- {
- public TextBox TbFileUploadDirectoryName;
- public DropDownList DdlFileUploadDateFormatString;
- public DropDownList DdlIsFileUploadChangeFileName;
- public TextBox TbFileUploadTypeCollection;
- public DropDownList DdlFileUploadTypeUnit;
- public TextBox TbFileUploadTypeMaxSize;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (!IsPostBack)
- {
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- TbFileUploadDirectoryName.Text = SiteInfo.Additional.FileUploadDirectoryName;
-
- DdlFileUploadDateFormatString.Items.Add(new ListItem("按年存入不同目录(不推荐)", EDateFormatTypeUtils.GetValue(EDateFormatType.Year)));
- DdlFileUploadDateFormatString.Items.Add(new ListItem("按年/月存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Month)));
- DdlFileUploadDateFormatString.Items.Add(new ListItem("按年/月/日存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Day)));
- ControlUtils.SelectSingleItemIgnoreCase(DdlFileUploadDateFormatString, SiteInfo.Additional.FileUploadDateFormatString);
-
- EBooleanUtils.AddListItems(DdlIsFileUploadChangeFileName, "自动修改文件名", "保持文件名不变");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsFileUploadChangeFileName, SiteInfo.Additional.IsFileUploadChangeFileName.ToString());
-
- TbFileUploadTypeCollection.Text = SiteInfo.Additional.FileUploadTypeCollection.Replace("|", ",");
- var mbSize = GetMbSize(SiteInfo.Additional.FileUploadTypeMaxSize);
- if (mbSize == 0)
- {
- DdlFileUploadTypeUnit.SelectedIndex = 0;
- TbFileUploadTypeMaxSize.Text = SiteInfo.Additional.FileUploadTypeMaxSize.ToString();
- }
- else
- {
- DdlFileUploadTypeUnit.SelectedIndex = 1;
- TbFileUploadTypeMaxSize.Text = mbSize.ToString();
- }
- }
- }
-
- private static int GetMbSize(int kbSize)
- {
- var retval = 0;
- if (kbSize >= 1024 && ((kbSize % 1024) == 0))
- {
- retval = kbSize / 1024;
- }
- return retval;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (Page.IsPostBack && Page.IsValid)
- {
- SiteInfo.Additional.FileUploadDirectoryName = TbFileUploadDirectoryName.Text;
-
- SiteInfo.Additional.FileUploadDateFormatString = EDateFormatTypeUtils.GetValue(EDateFormatTypeUtils.GetEnumType(DdlFileUploadDateFormatString.SelectedValue));
- SiteInfo.Additional.IsFileUploadChangeFileName = TranslateUtils.ToBool(DdlIsFileUploadChangeFileName.SelectedValue);
-
- SiteInfo.Additional.FileUploadTypeCollection = TbFileUploadTypeCollection.Text.Replace(",", "|");
- var kbSize = int.Parse(TbFileUploadTypeMaxSize.Text);
- SiteInfo.Additional.FileUploadTypeMaxSize = (DdlFileUploadTypeUnit.SelectedIndex == 0) ? kbSize : 1024 * kbSize;
-
- try
- {
- DataProvider.SiteDao.Update(SiteInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改附件上传设置");
-
- SuccessMessage("上传附件设置修改成功!");
- }
- catch(Exception ex)
- {
- FailMessage(ex, "上传附件设置修改失败!");
- }
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationUploadImage.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationUploadImage.cs
deleted file mode 100644
index a7121eb28..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationUploadImage.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationUploadImage : BasePageCms
- {
- public TextBox TbImageUploadDirectoryName;
- public DropDownList DdlImageUploadDateFormatString;
- public DropDownList DdlIsImageUploadChangeFileName;
- public TextBox TbImageUploadTypeCollection;
- public DropDownList DdlImageUploadTypeUnit;
- public TextBox TbImageUploadTypeMaxSize;
-
- public TextBox TbPhotoSmallWidth;
- public TextBox TbPhotoMiddleWidth;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- TbImageUploadDirectoryName.Text = SiteInfo.Additional.ImageUploadDirectoryName;
-
- DdlImageUploadDateFormatString.Items.Add(new ListItem("按年存入不同目录(不推荐)", EDateFormatTypeUtils.GetValue(EDateFormatType.Year)));
- DdlImageUploadDateFormatString.Items.Add(new ListItem("按年/月存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Month)));
- DdlImageUploadDateFormatString.Items.Add(new ListItem("按年/月/日存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Day)));
- ControlUtils.SelectSingleItemIgnoreCase(DdlImageUploadDateFormatString, SiteInfo.Additional.ImageUploadDateFormatString);
-
- EBooleanUtils.AddListItems(DdlIsImageUploadChangeFileName, "自动修改文件名", "保持文件名不变");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsImageUploadChangeFileName, SiteInfo.Additional.IsImageUploadChangeFileName.ToString());
-
- TbImageUploadTypeCollection.Text = SiteInfo.Additional.ImageUploadTypeCollection.Replace("|", ",");
- var mbSize = GetMbSize(SiteInfo.Additional.ImageUploadTypeMaxSize);
- if (mbSize == 0)
- {
- DdlImageUploadTypeUnit.SelectedIndex = 0;
- TbImageUploadTypeMaxSize.Text = SiteInfo.Additional.ImageUploadTypeMaxSize.ToString();
- }
- else
- {
- DdlImageUploadTypeUnit.SelectedIndex = 1;
- TbImageUploadTypeMaxSize.Text = mbSize.ToString();
- }
-
- TbPhotoSmallWidth.Text = SiteInfo.Additional.PhotoSmallWidth.ToString();
- TbPhotoMiddleWidth.Text = SiteInfo.Additional.PhotoMiddleWidth.ToString();
- }
-
- private static int GetMbSize(int kbSize)
- {
- var retval = 0;
- if (kbSize >= 1024 && kbSize % 1024 == 0)
- {
- retval = kbSize / 1024;
- }
- return retval;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- SiteInfo.Additional.ImageUploadDirectoryName = TbImageUploadDirectoryName.Text;
-
- SiteInfo.Additional.ImageUploadDateFormatString = EDateFormatTypeUtils.GetValue(EDateFormatTypeUtils.GetEnumType(DdlImageUploadDateFormatString.SelectedValue));
- SiteInfo.Additional.IsImageUploadChangeFileName = TranslateUtils.ToBool(DdlIsImageUploadChangeFileName.SelectedValue);
-
- SiteInfo.Additional.ImageUploadTypeCollection = TbImageUploadTypeCollection.Text.Replace(",", "|");
- var kbSize = int.Parse(TbImageUploadTypeMaxSize.Text);
- SiteInfo.Additional.ImageUploadTypeMaxSize = DdlImageUploadTypeUnit.SelectedIndex == 0 ? kbSize : 1024 * kbSize;
-
- SiteInfo.Additional.PhotoSmallWidth = TranslateUtils.ToInt(TbPhotoSmallWidth.Text, SiteInfo.Additional.PhotoSmallWidth);
- SiteInfo.Additional.PhotoMiddleWidth = TranslateUtils.ToInt(TbPhotoMiddleWidth.Text, SiteInfo.Additional.PhotoMiddleWidth);
-
- try
- {
- DataProvider.SiteDao.Update(SiteInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改图片上传设置");
-
- SuccessMessage("上传图片设置修改成功!");
- }
- catch(Exception ex)
- {
- FailMessage(ex, "上传图片设置修改失败!");
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationUploadVideo.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationUploadVideo.cs
deleted file mode 100644
index fb5be26f6..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationUploadVideo.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationUploadVideo : BasePageCms
- {
- public TextBox TbVideoUploadDirectoryName;
- public DropDownList DdlVideoUploadDateFormatString;
- public DropDownList DdlIsVideoUploadChangeFileName;
- public TextBox TbVideoUploadTypeCollection;
- public DropDownList DdlVideoUploadTypeUnit;
- public TextBox TbVideoUploadTypeMaxSize;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- TbVideoUploadDirectoryName.Text = SiteInfo.Additional.VideoUploadDirectoryName;
-
- DdlVideoUploadDateFormatString.Items.Add(new ListItem("按年存入不同目录(不推荐)", EDateFormatTypeUtils.GetValue(EDateFormatType.Year)));
- DdlVideoUploadDateFormatString.Items.Add(new ListItem("按年/月存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Month)));
- DdlVideoUploadDateFormatString.Items.Add(new ListItem("按年/月/日存入不同目录", EDateFormatTypeUtils.GetValue(EDateFormatType.Day)));
- ControlUtils.SelectSingleItemIgnoreCase(DdlVideoUploadDateFormatString, SiteInfo.Additional.VideoUploadDateFormatString);
-
- EBooleanUtils.AddListItems(DdlIsVideoUploadChangeFileName, "自动修改文件名", "保持文件名不变");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsVideoUploadChangeFileName, SiteInfo.Additional.IsVideoUploadChangeFileName.ToString());
-
- TbVideoUploadTypeCollection.Text = SiteInfo.Additional.VideoUploadTypeCollection.Replace("|", ",");
- var mbSize = GetMbSize(SiteInfo.Additional.VideoUploadTypeMaxSize);
- if (mbSize == 0)
- {
- DdlVideoUploadTypeUnit.SelectedIndex = 0;
- TbVideoUploadTypeMaxSize.Text = SiteInfo.Additional.VideoUploadTypeMaxSize.ToString();
- }
- else
- {
- DdlVideoUploadTypeUnit.SelectedIndex = 1;
- TbVideoUploadTypeMaxSize.Text = mbSize.ToString();
- }
- }
-
- private static int GetMbSize(int kbSize)
- {
- var retval = 0;
- if (kbSize >= 1024 && ((kbSize % 1024) == 0))
- {
- retval = kbSize / 1024;
- }
- return retval;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (Page.IsPostBack && Page.IsValid)
- {
- SiteInfo.Additional.VideoUploadDirectoryName = TbVideoUploadDirectoryName.Text;
-
- SiteInfo.Additional.VideoUploadDateFormatString = EDateFormatTypeUtils.GetValue(EDateFormatTypeUtils.GetEnumType(DdlVideoUploadDateFormatString.SelectedValue));
- SiteInfo.Additional.IsVideoUploadChangeFileName = TranslateUtils.ToBool(DdlIsVideoUploadChangeFileName.SelectedValue);
-
- SiteInfo.Additional.VideoUploadTypeCollection = TbVideoUploadTypeCollection.Text.Replace(",", "|");
- var kbSize = int.Parse(TbVideoUploadTypeMaxSize.Text);
- SiteInfo.Additional.VideoUploadTypeMaxSize = (DdlVideoUploadTypeUnit.SelectedIndex == 0) ? kbSize : 1024 * kbSize;
-
- try
- {
- DataProvider.SiteDao.Update(SiteInfo);
-
- AuthRequest.AddSiteLog(SiteId, "修改视频上传设置");
-
- SuccessMessage("上传视频设置修改成功!");
- }
- catch(Exception ex)
- {
- FailMessage(ex, "上传视频设置修改失败!");
- }
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageConfigurationWaterMark.cs b/SiteServer.BackgroundPages/Cms/PageConfigurationWaterMark.cs
deleted file mode 100644
index c20280a31..000000000
--- a/SiteServer.BackgroundPages/Cms/PageConfigurationWaterMark.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-using System;
-using System.Drawing.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageConfigurationWaterMark : BasePageCms
- {
- public DropDownList DdlIsWaterMark;
- public Literal LtlWaterMarkPosition;
- public PlaceHolder PhWaterMarkPosition;
- public DropDownList DdlWaterMarkTransparency;
- public PlaceHolder PhWaterMarkTransparency;
- public TextBox TbWaterMarkMinWidth;
- public TextBox TbWaterMarkMinHeight;
- public PlaceHolder PhWaterMarkMin;
- public DropDownList DdlIsImageWaterMark;
- public PlaceHolder PhIsImageWaterMark;
- public TextBox TbWaterMarkFormatString;
- public PlaceHolder PhWaterMarkFormatString;
- public DropDownList DdlWaterMarkFontName;
- public PlaceHolder PhWaterMarkFontName;
- public TextBox TbWaterMarkFontSize;
- public PlaceHolder PhWaterMarkFontSize;
- public TextBox TbWaterMarkImagePath;
- public PlaceHolder PhWaterMarkImagePath;
- public Button BtnImageUrlSelect;
- public Button BtnImageUrlUpload;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- EBooleanUtils.AddListItems(DdlIsWaterMark);
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsWaterMark, SiteInfo.Additional.IsWaterMark.ToString());
-
- LoadWaterMarkPosition(SiteInfo.Additional.WaterMarkPosition);
-
- for (var i = 1; i <= 10; i++)
- {
- DdlWaterMarkTransparency.Items.Add(new ListItem(i + "0%", i.ToString()));
- }
- ControlUtils.SelectSingleItemIgnoreCase(DdlWaterMarkTransparency, SiteInfo.Additional.WaterMarkTransparency.ToString());
-
- TbWaterMarkMinWidth.Text = SiteInfo.Additional.WaterMarkMinWidth.ToString();
- TbWaterMarkMinHeight.Text = SiteInfo.Additional.WaterMarkMinHeight.ToString();
-
- EBooleanUtils.AddListItems(DdlIsImageWaterMark, "图片型", "文字型");
- ControlUtils.SelectSingleItemIgnoreCase(DdlIsImageWaterMark, SiteInfo.Additional.IsImageWaterMark.ToString());
-
- TbWaterMarkFormatString.Text = SiteInfo.Additional.WaterMarkFormatString;
-
- LoadSystemFont();
- ControlUtils.SelectSingleItemIgnoreCase(DdlWaterMarkFontName, SiteInfo.Additional.WaterMarkFontName);
-
- TbWaterMarkFontSize.Text = SiteInfo.Additional.WaterMarkFontSize.ToString();
-
- TbWaterMarkImagePath.Text = SiteInfo.Additional.WaterMarkImagePath;
-
- DdlIsWaterMark_SelectedIndexChanged(null, null);
- TbWaterMarkImagePath.Attributes.Add("onchange", GetShowImageScript("preview_WaterMarkImagePath", SiteInfo.Additional.WebUrl));
-
- var showPopWinString = ModalSelectImage.GetOpenWindowString(SiteInfo, TbWaterMarkImagePath.ClientID);
- BtnImageUrlSelect.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalUploadImageSingle.GetOpenWindowStringToTextBox(SiteId, TbWaterMarkImagePath.ClientID);
- BtnImageUrlUpload.Attributes.Add("onclick", showPopWinString);
- }
-
- private void LoadWaterMarkPosition (int selectPosition)
- {
- LtlWaterMarkPosition.Text = "";
- }
-
- private void LoadSystemFont()
- {
- var familyArray = new InstalledFontCollection().Families;
- foreach (var family in familyArray)
- {
- DdlWaterMarkFontName.Items.Add(new ListItem(family.Name, family.Name));
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- SiteInfo.Additional.IsWaterMark = TranslateUtils.ToBool(DdlIsWaterMark.SelectedValue);
- SiteInfo.Additional.WaterMarkPosition = TranslateUtils.ToInt(Request.Form["WaterMarkPosition"]);
- SiteInfo.Additional.WaterMarkTransparency = TranslateUtils.ToInt(DdlWaterMarkTransparency.SelectedValue);
- SiteInfo.Additional.WaterMarkMinWidth = TranslateUtils.ToInt(TbWaterMarkMinWidth.Text);
- SiteInfo.Additional.WaterMarkMinHeight = TranslateUtils.ToInt(TbWaterMarkMinHeight.Text);
- SiteInfo.Additional.IsImageWaterMark = TranslateUtils.ToBool(DdlIsImageWaterMark.SelectedValue);
- SiteInfo.Additional.WaterMarkFormatString = TbWaterMarkFormatString.Text;
- SiteInfo.Additional.WaterMarkFontName = DdlWaterMarkFontName.SelectedValue;
- SiteInfo.Additional.WaterMarkFontSize = TranslateUtils.ToInt(TbWaterMarkFontSize.Text);
- SiteInfo.Additional.WaterMarkImagePath = TbWaterMarkImagePath.Text;
-
- try
- {
- DataProvider.SiteDao.Update(SiteInfo);
- AuthRequest.AddSiteLog(SiteId, "修改图片水印设置");
- SuccessMessage("图片水印设置修改成功!");
- }
- catch(Exception ex)
- {
- FailMessage(ex, "图片水印设置修改失败!");
- }
- }
-
- public void DdlIsWaterMark_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (EBooleanUtils.Equals(DdlIsWaterMark.SelectedValue, EBoolean.True))
- {
- PhWaterMarkPosition.Visible = PhWaterMarkTransparency.Visible = PhWaterMarkMin.Visible = PhIsImageWaterMark.Visible = true;
- if (EBooleanUtils.Equals(DdlIsImageWaterMark.SelectedValue, EBoolean.True))
- {
- PhWaterMarkFormatString.Visible = PhWaterMarkFontName.Visible = PhWaterMarkFontSize.Visible = false;
- PhWaterMarkImagePath.Visible = true;
- }
- else
- {
- PhWaterMarkFormatString.Visible = PhWaterMarkFontName.Visible = PhWaterMarkFontSize.Visible = true;
- PhWaterMarkImagePath.Visible = false;
- }
- }
- else
- {
- PhWaterMarkPosition.Visible = PhWaterMarkTransparency.Visible = PhWaterMarkMin.Visible = PhIsImageWaterMark.Visible = PhWaterMarkFormatString.Visible = PhWaterMarkFontName.Visible = PhWaterMarkFontSize.Visible = PhWaterMarkImagePath.Visible = false;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContent.cs b/SiteServer.BackgroundPages/Cms/PageContent.cs
deleted file mode 100644
index db1fe279c..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContent.cs
+++ /dev/null
@@ -1,199 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContent : BasePageCms
- {
- public Repeater RptContents;
- public SqlPager SpContents;
- public Literal LtlColumnsHead;
- public Literal LtlButtons;
- public Literal LtlMoreButtons;
- public DateTimeTextBox TbDateFrom;
- public DropDownList DdlSearchType;
- public TextBox TbKeyword;
-
- private ChannelInfo _channelInfo;
- private string _tableName;
- private List _relatedIdentities;
- private List _styleInfoList;
- private StringCollection _attributesOfDisplay;
- private List _attributesOfDisplayStyleInfoList;
- private Dictionary> _pluginLinks;
- private bool _isEdit;
- private readonly Dictionary _nameValueCacheDict = new Dictionary();
-
- public static string GetRedirectUrl(int siteId, int channelId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageContent), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId");
- var channelId = AuthRequest.GetQueryInt("channelId");
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, channelId);
- _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- _tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo);
- _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
- _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, channelId));
- _attributesOfDisplayStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList);
-
- _pluginLinks = PluginContentManager.GetContentLinks(_channelInfo);
- _isEdit = TextUtility.IsEdit(SiteInfo, channelId, AuthRequest.AdminPermissions);
-
- if (_channelInfo.Additional.IsPreviewContents)
- {
- new Action(() =>
- {
- DataProvider.ContentDao.DeletePreviewContents(SiteId, _tableName, _channelInfo);
- }).BeginInvoke(null, null);
- }
-
- if (!HasChannelPermissions(channelId, ConfigManager.ChannelPermissions.ContentView, ConfigManager.ChannelPermissions.ContentAdd, ConfigManager.ChannelPermissions.ContentEdit, ConfigManager.ChannelPermissions.ContentDelete, ConfigManager.ChannelPermissions.ContentTranslate))
- {
- if (!AuthRequest.IsAdminLoggin)
- {
- PageUtils.RedirectToLoginPage();
- return;
- }
- PageUtils.RedirectToErrorPage("您无此栏目的操作权限!");
- return;
- }
-
- SpContents.ControlToPaginate = RptContents;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- SpContents.ItemsPerPage = SiteInfo.Additional.PageSize;
-
- var administratorName = AuthRequest.AdminPermissions.IsViewContentOnlySelf(SiteId, channelId)
- ? AuthRequest.AdminName
- : string.Empty;
-
- if (AuthRequest.IsQueryExists("searchType"))
- {
- var owningChannelIdList = new List
- {
- channelId
- };
- SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(_tableName, SiteId, channelId, AuthRequest.AdminPermissions.IsSystemAdministrator, owningChannelIdList, AuthRequest.GetQueryString("searchType"), AuthRequest.GetQueryString("keyword"), AuthRequest.GetQueryString("dateFrom"), string.Empty, false, ETriState.All, false, false, false, administratorName);
- }
- else
- {
- SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(_tableName, channelId, ETriState.All, administratorName);
- }
-
- //spContents.SortField = DataProvider.ContentDao.GetSortFieldName();
- //spContents.SortMode = SortMode.DESC;
- //spContents.OrderByString = ETaxisTypeUtils.GetOrderByString(tableStyle, ETaxisType.OrderByTaxisDesc);
- SpContents.OrderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(_channelInfo.Additional.DefaultTaxisType));
- SpContents.TotalCount = _channelInfo.ContentNum;
-
- if (IsPostBack) return;
-
- LtlButtons.Text = WebUtils.GetContentCommands(AuthRequest.AdminPermissions, SiteInfo, _channelInfo, PageUrl);
- LtlMoreButtons.Text = WebUtils.GetContentMoreCommands(AuthRequest.AdminPermissions, SiteInfo, _channelInfo, PageUrl);
-
- SpContents.DataBind();
-
- if (_styleInfoList != null)
- {
- foreach (var styleInfo in _styleInfoList)
- {
- var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
- DdlSearchType.Items.Add(listitem);
- }
- }
-
- //添加隐藏属性
- DdlSearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id));
- DdlSearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName));
- DdlSearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName));
- DdlSearchType.Items.Add(new ListItem("内容组", ContentAttribute.GroupNameCollection));
-
- if (AuthRequest.IsQueryExists("searchType"))
- {
- TbDateFrom.Text = AuthRequest.GetQueryString("dateFrom");
- ControlUtils.SelectSingleItem(DdlSearchType, AuthRequest.GetQueryString("searchType"));
- TbKeyword.Text = AuthRequest.GetQueryString("keyword");
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("searchType")) || !string.IsNullOrEmpty(TbDateFrom.Text) ||
- !string.IsNullOrEmpty(TbKeyword.Text))
- {
- LtlButtons.Text += @"
-
-";
- }
-
- }
-
- LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo);
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var contentInfo = new ContentInfo(e.Item.DataItem);
-
- var ltlTitle = (Literal)e.Item.FindControl("ltlTitle");
- var ltlColumns = (Literal)e.Item.FindControl("ltlColumns");
- var ltlStatus = (Literal)e.Item.FindControl("ltlStatus");
- var ltlCommands = (Literal)e.Item.FindControl("ltlCommands");
- var ltlSelect = (Literal)e.Item.FindControl("ltlSelect");
-
- ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);
-
- ltlColumns.Text = TextUtility.GetColumnsHtml(_nameValueCacheDict, SiteInfo, contentInfo, _attributesOfDisplay, _attributesOfDisplayStyleInfoList);
-
- ltlStatus.Text =
- $@"{CheckManager.GetCheckState(SiteInfo, contentInfo.IsChecked, contentInfo.CheckedLevel)} ";
-
- ltlCommands.Text = TextUtility.GetCommandsHtml(SiteInfo, _pluginLinks, contentInfo, PageUrl, AuthRequest.AdminName, _isEdit);
-
- ltlSelect.Text = $@" ";
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUrl);
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageContent), new NameValueCollection
- {
- {"channelId", _channelInfo.Id.ToString()},
- {"dateFrom", TbDateFrom.Text},
- {"searchType", DdlSearchType.SelectedValue},
- {"keyword", TbKeyword.Text},
- {"page", AuthRequest.GetQueryInt("page", 1).ToString()}
- });
- }
- return _pageUrl;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContentAdd.cs b/SiteServer.BackgroundPages/Cms/PageContentAdd.cs
deleted file mode 100644
index d33f73578..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContentAdd.cs
+++ /dev/null
@@ -1,497 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Ajax;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Core.Office;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.CMS.Plugin;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContentAdd : BasePageCms
- {
- public Literal LtlPageTitle;
-
- public TextBox TbTitle;
- public Literal LtlTitleHtml;
- public AuxiliaryControl AcAttributes;
- public CheckBoxList CblContentAttributes;
- public CheckBoxList CblContentGroups;
- public Button BtnContentGroupAdd;
- public DropDownList DdlContentLevel;
- public TextBox TbTags;
- public Literal LtlTags;
- public PlaceHolder PhTranslate;
- public Button BtnTranslate;
- public DropDownList DdlTranslateType;
- public PlaceHolder PhStatus;
- public TextBox TbLinkUrl;
- public DateTimeTextBox TbAddDate;
- public Button BtnSubmit;
-
- private ChannelInfo _nodeInfo;
- private List _styleInfoList;
- private string _tableName;
-
- protected override bool IsSinglePage => true;
-
- public string PageContentAddHandlerUrl => PageContentAddHandler.GetRedirectUrl(SiteId, AuthRequest.GetQueryInt("channelId"), AuthRequest.GetQueryInt("id"));
-
- public static string GetRedirectUrlOfAdd(int siteId, int channelId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageContentAdd), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"returnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public static string GetRedirectUrlOfEdit(int siteId, int channelId, int id, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageContentAdd), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"id", id.ToString()},
- {"returnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId");
-
- var channelId = AuthRequest.GetQueryInt("channelId");
- var contentId = AuthRequest.GetQueryInt("id");
- ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl"));
- if (string.IsNullOrEmpty(ReturnUrl))
- {
- ReturnUrl = PageContent.GetRedirectUrl(SiteId, channelId);
- }
-
- _nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, channelId);
- _tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo);
- ContentInfo contentInfo = null;
- _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, relatedIdentities);
-
- if (!IsPermissions(contentId)) return;
-
- if (contentId > 0)
- {
- contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
- }
-
- var titleFormat = IsPostBack ? Request.Form[ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)] : contentInfo?.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title));
- LtlTitleHtml.Text = ContentUtility.GetTitleHtml(titleFormat, AjaxCmsService.GetTitlesUrl(SiteId, _nodeInfo.Id));
-
- AcAttributes.SiteInfo = SiteInfo;
- AcAttributes.ChannelId = _nodeInfo.Id;
- AcAttributes.StyleInfoList = _styleInfoList;
-
- if (!IsPostBack)
- {
- var pageTitle = contentId == 0 ? "添加内容" : "编辑内容";
-
- LtlPageTitle.Text = pageTitle;
-
- if (HasChannelPermissions(_nodeInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate))
- {
- PhTranslate.Visible = true;
- BtnTranslate.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(SiteId, true));
-
- ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true);
- ControlUtils.SelectSingleItem(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy));
- }
- else
- {
- PhTranslate.Visible = false;
- }
-
- CblContentAttributes.Items.Add(new ListItem("置顶", ContentAttribute.IsTop));
- CblContentAttributes.Items.Add(new ListItem("推荐", ContentAttribute.IsRecommend));
- CblContentAttributes.Items.Add(new ListItem("热点", ContentAttribute.IsHot));
- CblContentAttributes.Items.Add(new ListItem("醒目", ContentAttribute.IsColor));
- TbAddDate.DateTime = DateTime.Now;
- TbAddDate.Now = true;
-
- var contentGroupNameList = DataProvider.ContentGroupDao.GetGroupNameList(SiteId);
- foreach (var groupName in contentGroupNameList)
- {
- var item = new ListItem(groupName, groupName);
- CblContentGroups.Items.Add(item);
- }
-
- BtnContentGroupAdd.Attributes.Add("onclick", ModalContentGroupAdd.GetOpenWindowString(SiteId));
-
- LtlTags.Text = ContentUtility.GetTagsHtml(AjaxCmsService.GetTagsUrl(SiteId));
-
- if (HasChannelPermissions(_nodeInfo.Id, ConfigManager.ChannelPermissions.ContentCheck))
- {
- PhStatus.Visible = true;
- int checkedLevel;
- var isChecked = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, _nodeInfo.Id, out checkedLevel);
- if (AuthRequest.IsQueryExists("contentLevel"))
- {
- checkedLevel = TranslateUtils.ToIntWithNagetive(AuthRequest.GetQueryString("contentLevel"));
- if (checkedLevel != CheckManager.LevelInt.NotChange)
- {
- isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;
- }
- }
-
- CheckManager.LoadContentLevelToEdit(DdlContentLevel, SiteInfo, _nodeInfo.Id, contentInfo, isChecked, checkedLevel);
- }
- else
- {
- PhStatus.Visible = false;
- }
-
- BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()"));
- //自动检测敏感词
- ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(SiteInfo));
-
- if (contentId == 0)
- {
- var attributes = TableStyleManager.GetDefaultAttributes(_styleInfoList);
-
- if (AuthRequest.IsQueryExists("isUploadWord"))
- {
- var isFirstLineTitle = AuthRequest.GetQueryBool("isFirstLineTitle");
- var isFirstLineRemove = AuthRequest.GetQueryBool("isFirstLineRemove");
- var isClearFormat = AuthRequest.GetQueryBool("isClearFormat");
- var isFirstLineIndent = AuthRequest.GetQueryBool("isFirstLineIndent");
- var isClearFontSize = AuthRequest.GetQueryBool("isClearFontSize");
- var isClearFontFamily = AuthRequest.GetQueryBool("isClearFontFamily");
- var isClearImages = AuthRequest.GetQueryBool("isClearImages");
- var contentLevel = AuthRequest.GetQueryInt("contentLevel");
- var fileName = AuthRequest.GetQueryString("fileName");
-
- var formCollection = WordUtils.GetWordNameValueCollection(SiteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, contentLevel, fileName);
- attributes.Load(formCollection);
-
- TbTitle.Text = formCollection[ContentAttribute.Title];
- }
-
- AcAttributes.Attributes = attributes;
- }
- else if (contentInfo != null)
- {
- TbTitle.Text = contentInfo.Title;
-
- TbTags.Text = contentInfo.Tags;
-
- var list = new List();
- if (contentInfo.IsTop)
- {
- list.Add(ContentAttribute.IsTop);
- }
- if (contentInfo.IsRecommend)
- {
- list.Add(ContentAttribute.IsRecommend);
- }
- if (contentInfo.IsHot)
- {
- list.Add(ContentAttribute.IsHot);
- }
- if (contentInfo.IsColor)
- {
- list.Add(ContentAttribute.IsColor);
- }
- ControlUtils.SelectMultiItems(CblContentAttributes, list);
- TbLinkUrl.Text = contentInfo.LinkUrl;
- TbAddDate.DateTime = contentInfo.AddDate;
- ControlUtils.SelectMultiItems(CblContentGroups, TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection));
-
- AcAttributes.Attributes = contentInfo;
- }
- }
- else
- {
- AcAttributes.Attributes = new ExtendedAttributes(Request.Form);
- }
- //DataBind();
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var contentId = AuthRequest.GetQueryInt("id");
- string redirectUrl;
-
- if (contentId == 0)
- {
- var contentInfo = new ContentInfo();
- try
- {
- contentInfo.ChannelId = _nodeInfo.Id;
- contentInfo.SiteId = SiteId;
- contentInfo.AddUserName = AuthRequest.AdminName;
- contentInfo.LastEditUserName = contentInfo.AddUserName;
- contentInfo.LastEditDate = DateTime.Now;
-
- BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributesLowercase);
-
- contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items);
- var tagCollection = TagUtils.ParseTagsString(TbTags.Text);
-
- contentInfo.Title = TbTitle.Text;
- var formatString = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]);
- var formatEm = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]);
- var formatU = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]);
- var formatColor = Request.Form[ContentAttribute.Title + "_formatColor"];
- var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);
- contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString);
- foreach (ListItem listItem in CblContentAttributes.Items)
- {
- var value = listItem.Selected.ToString();
- var attributeName = listItem.Value;
- contentInfo.Set(attributeName, value);
- }
- contentInfo.LinkUrl = TbLinkUrl.Text;
- contentInfo.AddDate = TbAddDate.DateTime;
- if (contentInfo.AddDate.Year <= DateUtils.SqlMinValue.Year)
- {
- contentInfo.AddDate = DateTime.Now;
- }
-
- contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
- contentInfo.IsChecked = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel;
- contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");
-
- foreach (var service in PluginManager.Services)
- {
- try
- {
- service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _nodeInfo.Id,
- contentInfo, new ExtendedAttributes(Request.Form)));
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
- }
- }
-
- contentInfo.Id = DataProvider.ContentDao.Insert(_tableName, SiteInfo, contentInfo);
- //判断是不是有审核权限
- int checkedLevelOfUser;
- var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, contentInfo.ChannelId, out checkedLevelOfUser);
- if (CheckManager.IsCheckable(SiteInfo, contentInfo.ChannelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
- {
- //添加审核记录
- DataProvider.ContentDao.UpdateIsChecked(_tableName, SiteId, contentInfo.ChannelId, new List { contentInfo.Id }, 0, true, AuthRequest.AdminName, contentInfo.IsChecked, contentInfo.CheckedLevel, "");
- }
-
- TagUtils.AddTags(tagCollection, SiteId, contentInfo.Id);
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(ex);
- FailMessage($"内容添加失败:{ex.Message}");
- }
-
- CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentInfo.Id);
-
- AuthRequest.AddSiteLog(SiteId, _nodeInfo.Id, contentInfo.Id, "添加内容",
- $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}");
-
- ContentUtility.Translate(SiteInfo, _nodeInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName);
-
- redirectUrl = PageContentAddAfter.GetRedirectUrl(SiteId, _nodeInfo.Id, contentInfo.Id,
- ReturnUrl);
- }
- else
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
- try
- {
- var tagsLast = contentInfo.Tags;
-
- contentInfo.LastEditUserName = AuthRequest.AdminName;
- contentInfo.LastEditDate = DateTime.Now;
-
- BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributesLowercase);
-
- contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items);
- var tagCollection = TagUtils.ParseTagsString(TbTags.Text);
-
- contentInfo.Title = TbTitle.Text;
- var formatString = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]);
- var formatEm = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]);
- var formatU = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]);
- var formatColor = Request.Form[ContentAttribute.Title + "_formatColor"];
- var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);
- contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString);
- foreach (ListItem listItem in CblContentAttributes.Items)
- {
- var value = listItem.Selected.ToString();
- var attributeName = listItem.Value;
- contentInfo.Set(attributeName, value);
- }
- contentInfo.LinkUrl = TbLinkUrl.Text;
- contentInfo.AddDate = TbAddDate.DateTime;
-
- var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
- if (checkedLevel != CheckManager.LevelInt.NotChange)
- {
- contentInfo.IsChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;
- contentInfo.CheckedLevel = checkedLevel;
- }
- contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");
-
- foreach (var service in PluginManager.Services)
- {
- try
- {
- service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _nodeInfo.Id,
- contentInfo, new ExtendedAttributes(Request.Form)));
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
- }
- }
-
- DataProvider.ContentDao.Update(_tableName, SiteInfo, contentInfo);
-
- TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, SiteId, contentId);
-
- ContentUtility.Translate(SiteInfo, _nodeInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName);
-
- //更新引用该内容的信息
- //如果不是异步自动保存,那么需要将引用此内容的content修改
- //var sourceContentIdList = new List
- //{
- // contentInfo.Id
- //};
- //var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb();
- //foreach (var table in tableList)
- //{
- // var targetContentIdList = DataProvider.ContentDao.GetReferenceIdList(table.TableName, sourceContentIdList);
- // foreach (var targetContentId in targetContentIdList)
- // {
- // var targetContentInfo = DataProvider.ContentDao.GetContentInfo(table.TableName, targetContentId);
- // if (targetContentInfo == null || targetContentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) continue;
-
- // contentInfo.Id = targetContentId;
- // contentInfo.SiteId = targetContentInfo.SiteId;
- // contentInfo.ChannelId = targetContentInfo.ChannelId;
- // contentInfo.SourceId = targetContentInfo.SourceId;
- // contentInfo.ReferenceId = targetContentInfo.ReferenceId;
- // contentInfo.Taxis = targetContentInfo.Taxis;
- // contentInfo.Set(ContentAttribute.TranslateContentType, targetContentInfo.GetString(ContentAttribute.TranslateContentType));
- // DataProvider.ContentDao.Update(table.TableName, contentInfo);
-
- // //资源:图片,文件,视频
- // var targetSiteInfo = SiteManager.GetSiteInfo(targetContentInfo.SiteId);
- // var bgContentInfo = contentInfo as BackgroundContentInfo;
- // var bgTargetContentInfo = targetContentInfo as BackgroundContentInfo;
- // if (bgTargetContentInfo != null && bgContentInfo != null)
- // {
- // if (bgContentInfo.ImageUrl != bgTargetContentInfo.ImageUrl)
- // {
- // //修改图片
- // var sourceImageUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.ImageUrl);
- // CopyReferenceFiles(targetSiteInfo, sourceImageUrl);
- // }
- // else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)))
- // {
- // var sourceImageUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)));
-
- // foreach (string imageUrl in sourceImageUrls)
- // {
- // var sourceImageUrl = PathUtility.MapPath(SiteInfo, imageUrl);
- // CopyReferenceFiles(targetSiteInfo, sourceImageUrl);
- // }
- // }
- // if (bgContentInfo.FileUrl != bgTargetContentInfo.FileUrl)
- // {
- // //修改附件
- // var sourceFileUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.FileUrl);
- // CopyReferenceFiles(targetSiteInfo, sourceFileUrl);
-
- // }
- // else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)))
- // {
- // var sourceFileUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)));
-
- // foreach (var fileUrl in sourceFileUrls)
- // {
- // var sourceFileUrl = PathUtility.MapPath(SiteInfo, fileUrl);
- // CopyReferenceFiles(targetSiteInfo, sourceFileUrl);
- // }
- // }
- // }
- // }
- //}
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(ex);
- FailMessage($"内容修改失败:{ex.Message}");
- return;
- }
-
- CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentId);
-
- AuthRequest.AddSiteLog(SiteId, _nodeInfo.Id, contentId, "修改内容",
- $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}");
-
- redirectUrl = ReturnUrl;
- }
-
- PageUtils.Redirect(redirectUrl);
- }
-
- private bool IsPermissions(int contentId)
- {
- if (contentId == 0)
- {
- if (_nodeInfo == null || _nodeInfo.Additional.IsContentAddable == false)
- {
- PageUtils.RedirectToErrorPage("此栏目不能添加内容!");
- return false;
- }
-
- if (!HasChannelPermissions(_nodeInfo.Id, ConfigManager.ChannelPermissions.ContentAdd))
- {
- if (!AuthRequest.IsAdminLoggin)
- {
- PageUtils.RedirectToLoginPage();
- return false;
- }
-
- PageUtils.RedirectToErrorPage("您无此栏目的添加内容权限!");
- return false;
- }
- }
- else
- {
- if (!HasChannelPermissions(_nodeInfo.Id, ConfigManager.ChannelPermissions.ContentEdit))
- {
- if (!AuthRequest.IsAdminLoggin)
- {
- PageUtils.RedirectToLoginPage();
- return false;
- }
-
- PageUtils.RedirectToErrorPage("您无此栏目的修改内容权限!");
- return false;
- }
- }
- return true;
- }
-
- public string ReturnUrl { get; private set; }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContentCheck.cs b/SiteServer.BackgroundPages/Cms/PageContentCheck.cs
deleted file mode 100644
index 76ab0fd8d..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContentCheck.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContentCheck : BasePageCms
- {
- public DropDownList DdlChannelId;
- public DropDownList DdlState;
-
- public Repeater RptContents;
- public SqlPager SpContents;
- public Literal LtlColumnsHead;
-
- public Button BtnCheck;
- public Button BtnDelete;
-
- private int _channelId;
- private List _styleInfoList;
- private StringCollection _attributesOfDisplay;
- private List _attributesOfDisplayStyleInfoList;
- private List _relatedIdentities;
- private ChannelInfo _nodeInfo;
- private string _tableName;
- private Dictionary> _pluginLinks;
- private bool _isEdit;
- private readonly Dictionary _nameValueCacheDict = new Dictionary();
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageContentCheck), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
- _channelId = AuthRequest.IsQueryExists("ChannelId") ? AuthRequest.GetQueryInt("ChannelId") : SiteId;
-
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
- _nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- _tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo);
- _styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
- _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId));
- _attributesOfDisplayStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList);
- _pluginLinks = PluginContentManager.GetContentLinks(_nodeInfo);
- _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissions);
-
- if (IsPostBack) return;
-
- var checkedLevel = 5;
- var isChecked = true;
- foreach (var owningChannelId in AuthRequest.AdminPermissions.OwningChannelIdList)
- {
- int checkedLevelByChannelId;
- var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, owningChannelId, out checkedLevelByChannelId);
- if (checkedLevel > checkedLevelByChannelId)
- {
- checkedLevel = checkedLevelByChannelId;
- }
- if (!isCheckedByChannelId)
- {
- isChecked = false;
- }
- }
-
- ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions);
- CheckManager.LoadContentLevelToList(DdlState, SiteInfo, SiteId, isChecked, checkedLevel);
- var checkLevelList = new List();
-
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("channelId")))
- {
- ControlUtils.SelectSingleItem(DdlChannelId, AuthRequest.GetQueryString("channelId"));
- }
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("state")))
- {
- ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("state"));
- checkLevelList.Add(AuthRequest.GetQueryInt("state"));
- }
- else
- {
- checkLevelList = CheckManager.LevelInt.GetCheckLevelList(SiteInfo, isChecked, checkedLevel);
- }
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = SiteInfo.Additional.PageSize;
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- var tableName = ChannelManager.GetTableName(SiteInfo, nodeInfo);
- var channelIdList = ChannelManager.GetChannelIdList(nodeInfo, EScopeType.All, string.Empty, string.Empty, nodeInfo.ContentModelPluginId);
- var list = new List();
- if (AuthRequest.AdminPermissions.IsSystemAdministrator)
- {
- list = channelIdList;
- }
- else
- {
- var owningChannelIdList = new List();
- foreach (var owningChannelId in AuthRequest.AdminPermissions.OwningChannelIdList)
- {
- if (HasChannelPermissions(owningChannelId, ConfigManager.ChannelPermissions.ContentCheck))
- {
- owningChannelIdList.Add(owningChannelId);
- }
- }
- foreach (var theChannelId in channelIdList)
- {
- if (owningChannelIdList.Contains(theChannelId))
- {
- list.Add(theChannelId);
- }
- }
- }
-
- SpContents.SelectCommand = DataProvider.ContentDao.GetSelectedCommendByCheck(tableName, SiteId, list, checkLevelList);
-
- SpContents.SortField = ContentAttribute.LastEditDate;
- SpContents.SortMode = SortMode.DESC;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- SpContents.DataBind();
-
- var showPopWinString = ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl);
- BtnCheck.Attributes.Add("onclick", showPopWinString);
-
- LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo);
-
- if (!HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentDelete))
- {
- BtnDelete.Visible = false;
- }
- else
- {
- BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl));
- }
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var contentInfo = new ContentInfo(e.Item.DataItem);
-
- var ltlTitle = (Literal)e.Item.FindControl("ltlTitle");
- var ltlChannel = (Literal)e.Item.FindControl("ltlChannel");
- var ltlColumns = (Literal)e.Item.FindControl("ltlColumns");
- var ltlStatus = (Literal)e.Item.FindControl("ltlStatus");
- var ltlCommands = (Literal)e.Item.FindControl("ltlCommands");
- var ltlSelect = (Literal) e.Item.FindControl("ltlSelect");
-
- ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);
-
- ltlColumns.Text = TextUtility.GetColumnsHtml(_nameValueCacheDict, SiteInfo, contentInfo, _attributesOfDisplay, _attributesOfDisplayStyleInfoList);
-
- string nodeName;
- if (!_nameValueCacheDict.TryGetValue(contentInfo.ChannelId.ToString(), out nodeName))
- {
- nodeName = ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId);
- _nameValueCacheDict[contentInfo.ChannelId.ToString()] = nodeName;
- }
- ltlChannel.Text = nodeName;
-
- ltlStatus.Text =
- $@"{CheckManager.GetCheckState(SiteInfo, contentInfo.IsChecked, contentInfo.CheckedLevel)} ";
-
- ltlCommands.Text = TextUtility.GetCommandsHtml(SiteInfo, _pluginLinks, contentInfo, PageUrl, AuthRequest.AdminName, _isEdit);
-
- ltlSelect.Text = $@" ";
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- Response.Redirect(PageUrl, true);
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageContentCheck), new NameValueCollection
- {
- {"channelId", DdlChannelId.SelectedValue},
- {"state", DdlState.SelectedValue}
- });
- }
- return _pageUrl;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContentDelete.cs b/SiteServer.BackgroundPages/Cms/PageContentDelete.cs
deleted file mode 100644
index 92c803560..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContentDelete.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContentDelete : BasePageCms
- {
- public Literal LtlContents;
- public PlaceHolder PhRetain;
- public RadioButtonList RblRetainFiles;
-
- private Dictionary> _idsDictionary = new Dictionary>();
- private bool _isDeleteFromTrash;
- private string _returnUrl;
-
- public static string GetRedirectClickStringForMultiChannels(int siteId, bool isDeleteFromTrash,
- string returnUrl)
- {
- return PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.GetCmsUrl(siteId, nameof(PageContentDelete),
- new NameValueCollection
- {
- {"IsDeleteFromTrash", isDeleteFromTrash.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), "IDsCollection", "IDsCollection", "请选择需要删除的内容!");
- }
-
- public static string GetRedirectClickStringForSingleChannel(int siteId, int channelId,
- bool isDeleteFromTrash, string returnUrl)
- {
- return PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.GetCmsUrl(siteId, nameof(PageContentDelete),
- new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"IsDeleteFromTrash", isDeleteFromTrash.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- }), "contentIdCollection", "contentIdCollection", "请选择需要删除的内容!");
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "ReturnUrl");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
- _isDeleteFromTrash = AuthRequest.GetQueryBool("IsDeleteFromTrash");
- _idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString);
-
- //if (this.channelId > 0)
- //{
- // this.nodeInfo = NodeManager.GetChannelInfo(base.SiteId, this.channelId);
- //}
- //else
- //{
- // this.nodeInfo = NodeManager.GetChannelInfo(base.SiteId, -this.channelId);
- //}
- //if (this.nodeInfo != null)
- //{
- // this.tableStyle = NodeManager.GetTableStyle(base.SiteInfo, nodeInfo);
- // this.tableName = NodeManager.GetTableName(base.SiteInfo, nodeInfo);
- //}
-
- //if (this.contentID == 0)
- //{
- // if (!base.HasChannelPermissions(Math.Abs(this.channelId), AppManager.CMS.Permission.Channel.ContentDelete))
- // {
- // PageUtils.RedirectToErrorPage("您没有删除此栏目内容的权限!");
- // return;
- // }
- //}
- //else
- //{
- // ContentInfo contentInfo = DataProvider.ContentDAO.GetContentInfo(this.tableStyle, this.tableName, this.contentID);
-
- // if (contentInfo == null || !string.Equals(AuthRequest.AdminName, contentInfo.AddUserName))
- // {
- // if (!base.HasChannelPermissions(Math.Abs(this.channelId), AppManager.CMS.Permission.Channel.ContentDelete))
- // {
- // PageUtils.RedirectToErrorPage("您没有删除此栏目内容的权限!");
- // return;
- // }
- // }
- //}
-
- if (IsPostBack) return;
-
- var builder = new StringBuilder();
- foreach (var channelId in _idsDictionary.Keys)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- var contentIdList = _idsDictionary[channelId];
- foreach (var contentId in contentIdList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- if (contentInfo != null)
- {
- builder.Append(
- $@"{WebUtils.GetContentTitle(SiteInfo, contentInfo, _returnUrl)} ");
- }
- }
- }
- LtlContents.Text = builder.ToString();
-
- if (!_isDeleteFromTrash)
- {
- PhRetain.Visible = true;
- InfoMessage("此操作将把所选内容放入回收站,确定吗?");
- }
- else
- {
- PhRetain.Visible = false;
- InfoMessage("此操作将从回收站中彻底删除所选内容,确定吗?");
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- try
- {
- foreach (var channelId in _idsDictionary.Keys)
- {
- var tableName = ChannelManager.GetTableName(SiteInfo, channelId);
- var contentIdList = _idsDictionary[channelId];
-
- if (!_isDeleteFromTrash)
- {
- if (bool.Parse(RblRetainFiles.SelectedValue) == false)
- {
- DeleteManager.DeleteContents(SiteInfo, channelId, contentIdList);
- SuccessMessage("成功删除内容以及生成页面!");
- }
- else
- {
- SuccessMessage("成功删除内容,生成页面未被删除!");
- }
-
- if (contentIdList.Count == 1)
- {
- var contentId = contentIdList[0];
- var contentTitle = DataProvider.ContentDao.GetValue(tableName, contentId, ContentAttribute.Title);
- AuthRequest.AddSiteLog(SiteId, channelId, contentId, "删除内容",
- $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, channelId)},内容标题:{contentTitle}");
- }
- else
- {
- AuthRequest.AddSiteLog(SiteId, "批量删除内容",
- $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, channelId)},内容条数:{contentIdList.Count}");
- }
-
- DataProvider.ContentDao.TrashContents(SiteId, tableName, contentIdList);
-
- //引用内容,需要删除
- var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb();
- foreach (var table in tableList)
- {
- var targetContentIdList = DataProvider.ContentDao.GetReferenceIdList(table.TableName, contentIdList);
- if (targetContentIdList.Count > 0)
- {
- var targetContentInfo = DataProvider.ContentDao.GetContentInfo(table.TableName, TranslateUtils.ToInt(targetContentIdList[0].ToString()));
- DataProvider.ContentDao.DeleteContents(targetContentInfo.SiteId, table.TableName, targetContentIdList, targetContentInfo.ChannelId);
- }
- }
-
- CreateManager.CreateContentTrigger(SiteId, channelId);
- }
- else
- {
- SuccessMessage("成功从回收站清空内容!");
- DataProvider.ContentDao.DeleteContents(SiteId, tableName, contentIdList, channelId);
-
- AuthRequest.AddSiteLog(SiteId, "从回收站清空内容", $"内容条数:{contentIdList.Count}");
- }
- }
-
-
- AddWaitAndRedirectScript(_returnUrl);
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(ex);
- FailMessage(ex, "删除内容失败!");
- }
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(_returnUrl);
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContentSearch.cs b/SiteServer.BackgroundPages/Cms/PageContentSearch.cs
deleted file mode 100644
index a89ab29c5..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContentSearch.cs
+++ /dev/null
@@ -1,236 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContentSearch : BasePageCms
- {
- public DropDownList DdlChannelId;
- public DropDownList DdlState;
- public CheckBox CbIsDuplicate;
- public DropDownList DdlSearchType;
- public TextBox TbKeyword;
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
-
- public Repeater RptContents;
- public SqlPager SpContents;
- public Literal LtlColumnsHead;
-
- public Button BtnAddContent;
- public Button BtnAddToGroup;
- public Button BtnDelete;
- public Button BtnTranslate;
- public Button BtnSelect;
- public PlaceHolder PhCheck;
- public Button BtnCheck;
-
- private bool _isWritingOnly;
- private bool _isSelfOnly;
- private int _channelId;
- private ChannelInfo _nodeInfo;
- private List _relatedIdentities;
- private List _styleInfoList;
- private StringCollection _attributesOfDisplay;
- private List _attributesOfDisplayStyleInfoList;
- private Dictionary> _pluginLinks;
- private bool _isEdit;
- private readonly Dictionary _nameValueCacheDict = new Dictionary();
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageContentSearch), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("SiteId");
- _channelId = AuthRequest.IsQueryExists("ChannelId") ? AuthRequest.GetQueryInt("ChannelId") : SiteId;
-
- _isWritingOnly = AuthRequest.GetQueryBool("isWritingOnly");
-
- var administratorName = string.Empty;
- _isSelfOnly = AuthRequest.GetQueryBool("isSelfOnly");
- if (!_isSelfOnly)
- {
- administratorName = AuthRequest.AdminPermissions.IsViewContentOnlySelf(SiteId, _channelId) ? AuthRequest.AdminName : string.Empty;
- }
-
- _nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- var tableName = ChannelManager.GetTableName(SiteInfo, _nodeInfo);
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
- _styleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, _relatedIdentities);
- _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId));
- _attributesOfDisplayStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList);
- _pluginLinks = PluginContentManager.GetContentLinks(_nodeInfo);
- _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissions);
-
- var stateType = AuthRequest.IsQueryExists("state") ? ETriStateUtils.GetEnumType(AuthRequest.GetQueryString("state")) : ETriState.All;
- var searchType = AuthRequest.IsQueryExists("searchType") ? AuthRequest.GetQueryString("searchType") : ContentAttribute.Title;
- var dateFrom = AuthRequest.IsQueryExists("dateFrom") ? AuthRequest.GetQueryString("dateFrom") : string.Empty;
- var dateTo = AuthRequest.IsQueryExists("dateTo") ? AuthRequest.GetQueryString("dateTo") : string.Empty;
- var isDuplicate = AuthRequest.IsQueryExists("isDuplicate") && AuthRequest.GetQueryBool("isDuplicate");
- var keyword = AuthRequest.IsQueryExists("keyword") ? AuthRequest.GetQueryString("keyword") : string.Empty;
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(tableName, SiteId, _channelId, AuthRequest.AdminPermissions.IsSystemAdministrator, AuthRequest.AdminPermissions.OwningChannelIdList, searchType, keyword, dateFrom, dateTo, true, stateType, !isDuplicate, false, _isWritingOnly, administratorName);
- SpContents.ItemsPerPage = SiteInfo.Additional.PageSize;
- SpContents.SortField = ContentAttribute.Id;
- SpContents.SortMode = SortMode.DESC;
- SpContents.OrderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (!IsPostBack)
- {
- ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissions);
-
- DdlSearchType.Items.Add(new ListItem("标题", ContentAttribute.Title));
- if (_styleInfoList != null)
- {
- foreach (var styleInfo in _styleInfoList)
- {
- if (styleInfo.AttributeName != ContentAttribute.AddDate)
- {
- var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
- DdlSearchType.Items.Add(listitem);
- }
- }
- }
- DdlSearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id));
- DdlSearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName));
- DdlSearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName));
-
- ETriStateUtils.AddListItems(DdlState, "全部", "已审核", "待审核");
-
- if (SiteId != _channelId)
- {
- ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString());
- }
- ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("State"));
- CbIsDuplicate.Checked = isDuplicate;
- ControlUtils.SelectSingleItem(DdlSearchType, searchType);
- TbKeyword.Text = keyword;
- TbDateFrom.Text = dateFrom;
- TbDateTo.Text = dateTo;
-
- SpContents.DataBind();
-
- var showPopWinString = ModalAddToGroup.GetOpenWindowStringToContentForMultiChannels(SiteId);
- BtnAddToGroup.Attributes.Add("onclick", showPopWinString);
-
- showPopWinString = ModalSelectColumns.GetOpenWindowString(SiteId, _channelId, true);
- BtnSelect.Attributes.Add("onclick", showPopWinString);
-
- if (HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentCheck))
- {
- showPopWinString = ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl);
- BtnCheck.Attributes.Add("onclick", showPopWinString);
- }
- else
- {
- PhCheck.Visible = false;
- }
-
- LtlColumnsHead.Text = TextUtility.GetColumnsHeadHtml(_styleInfoList, _attributesOfDisplay, SiteInfo);
- }
-
- if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentAdd)) BtnAddContent.Visible = false;
- if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentTranslate))
- {
- BtnTranslate.Visible = false;
- }
- else
- {
- BtnTranslate.Attributes.Add("onclick", PageContentTranslate.GetRedirectClickStringForMultiChannels(SiteId, PageUrl));
- }
-
- if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete))
- {
- BtnDelete.Visible = false;
- }
- else
- {
- BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl));
- }
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var contentInfo = new ContentInfo(e.Item.DataItem);
-
- var ltlTitle = (Literal)e.Item.FindControl("ltlTitle");
- var ltlChannel = (Literal)e.Item.FindControl("ltlChannel");
- var ltlColumns = (Literal)e.Item.FindControl("ltlColumns");
- var ltlStatus = (Literal)e.Item.FindControl("ltlStatus");
- var ltlCommands = (Literal)e.Item.FindControl("ltlCommands");
- var ltlSelect = (Literal)e.Item.FindControl("ltlSelect");
-
- ltlTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);
-
- ltlColumns.Text = TextUtility.GetColumnsHtml(_nameValueCacheDict, SiteInfo, contentInfo, _attributesOfDisplay, _attributesOfDisplayStyleInfoList);
-
- string nodeName;
- if (!_nameValueCacheDict.TryGetValue(contentInfo.ChannelId.ToString(), out nodeName))
- {
- nodeName = ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId);
- _nameValueCacheDict[contentInfo.ChannelId.ToString()] = nodeName;
- }
-
- ltlChannel.Text = nodeName;
-
- ltlStatus.Text =
- $@"{CheckManager.GetCheckState(SiteInfo, contentInfo.IsChecked, contentInfo.CheckedLevel)} ";
-
- ltlCommands.Text = TextUtility.GetCommandsHtml(SiteInfo, _pluginLinks, contentInfo, PageUrl, AuthRequest.AdminName, _isEdit);
-
- ltlSelect.Text = $@" ";
- }
-
- public void AddContent_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(WebUtils.GetContentAddAddUrl(SiteId, _nodeInfo, PageUrl));
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUrl);
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageContentSearch), new NameValueCollection
- {
- {"ChannelId", DdlChannelId.SelectedValue},
- {"State", DdlState.SelectedValue},
- {"IsDuplicate", CbIsDuplicate.Checked.ToString()},
- {"SearchType", DdlSearchType.SelectedValue},
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text},
- {"isWritingOnly", _isWritingOnly.ToString()},
- {"isSelfOnly", _isSelfOnly.ToString()}
- });
- }
- return _pageUrl;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContentTags.cs b/SiteServer.BackgroundPages/Cms/PageContentTags.cs
deleted file mode 100644
index d36842f61..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContentTags.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContentTags : BasePageCms
- {
- public Repeater RptContents;
- public SqlPager SpContents;
-
- public Button BtnAddTag;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var tagName = AuthRequest.GetQueryString("TagName");
-
- try
- {
- var contentIdList = DataProvider.TagDao.GetContentIdListByTag(tagName, SiteId);
- if (contentIdList.Count > 0)
- {
- foreach (var contentId in contentIdList)
- {
- var contentTags = DataProvider.ContentDao.GetValue(SiteInfo.TableName, contentId, ContentAttribute.Tags);
- var contentTagArrayList = TranslateUtils.StringCollectionToStringList(contentTags);
- contentTagArrayList.Remove(tagName);
- DataProvider.ContentDao.SetValue(SiteInfo.TableName, contentId, ContentAttribute.Tags, TranslateUtils.ObjectCollectionToString(contentTagArrayList));
- }
- }
- DataProvider.TagDao.DeleteTag(tagName, SiteId);
- AuthRequest.AddSiteLog(SiteId, "删除内容标签", $"内容标签:{tagName}");
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = SiteInfo.Additional.PageSize;
-
- SpContents.SelectCommand = DataProvider.TagDao.GetSqlString(SiteId, 0, true, 0);
- SpContents.SortField = nameof(TagInfo.UseNum);
- SpContents.SortMode = SortMode.DESC;
-
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- SpContents.DataBind();
-
- var showPopWinString = ModalContentTagAdd.GetOpenWindowStringToAdd(SiteId);
- BtnAddTag.Attributes.Add("onclick", showPopWinString);
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var tag = SqlUtils.EvalString(e.Item.DataItem, nameof(TagInfo.Tag));
- var level = SqlUtils.EvalInt(e.Item.DataItem, nameof(TagInfo.Level));
- var useNum = SqlUtils.EvalInt(e.Item.DataItem, nameof(TagInfo.UseNum));
-
- var ltlTagName = (Literal)e.Item.FindControl("ltlTagName");
- var ltlCount = (Literal)e.Item.FindControl("ltlCount");
- var ltlEditUrl = (Literal)e.Item.FindControl("ltlEditUrl");
- var ltlDeleteUrl = (Literal)e.Item.FindControl("ltlDeleteUrl");
-
- var cssClass = "tag_popularity_1";
- if (level == 2)
- {
- cssClass = "tag_popularity_2";
- }
- else if (level == 3)
- {
- cssClass = "tag_popularity_3";
- }
-
- ltlTagName.Text = $@"{tag} ";
- ltlCount.Text = useNum.ToString();
-
- var showPopWinString = ModalContentTagAdd.GetOpenWindowStringToEdit(SiteId, tag);
- ltlEditUrl.Text = $"编辑 ";
-
- var urlDelete = PageUtils.GetCmsUrl(SiteId, nameof(PageContentTags), new NameValueCollection
- {
- {"TagName", tag},
- {"Delete", true.ToString()}
- });
- ltlDeleteUrl.Text =
- $"删除 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContentTrash.cs b/SiteServer.BackgroundPages/Cms/PageContentTrash.cs
deleted file mode 100644
index 0f964083c..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContentTrash.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContentTrash : BasePageCms
- {
- public DropDownList DdlChannelId;
- public DropDownList DdlPageNum;
- public DropDownList DdlSearchType;
- public TextBox TbKeyword;
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
-
- public Repeater RptContents;
- public SqlPager SpContents;
-
- public Button BtnRestore;
- public Button BtnRestoreAll;
- public Button BtnDelete;
- public Button BtnDeleteAll;
-
- private int _channelId;
- private List _relatedIdentities;
- private List _tableStyleInfoList;
- private readonly Hashtable _nodeNameNavigations = new Hashtable();
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
- _channelId = AuthRequest.GetQueryInt("channelId");
- if (_channelId == 0)
- {
- _channelId = SiteId;
- }
- var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- var tableName = ChannelManager.GetTableName(SiteInfo, channelInfo);
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
- _tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, _relatedIdentities);
-
- SpContents.ControlToPaginate = RptContents;
- if (string.IsNullOrEmpty(AuthRequest.GetQueryString("channelId")))
- {
- SpContents.ItemsPerPage = TranslateUtils.ToInt(DdlPageNum.SelectedValue) == 0 ? SiteInfo.Additional.PageSize : TranslateUtils.ToInt(DdlPageNum.SelectedValue);
- SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(tableName, SiteId, _channelId, AuthRequest.AdminPermissions.IsSystemAdministrator, AuthRequest.AdminPermissions.OwningChannelIdList, DdlSearchType.SelectedValue, TbKeyword.Text, TbDateFrom.Text, TbDateTo.Text, true, ETriState.All, false, true);
- }
- else
- {
- SpContents.ItemsPerPage = AuthRequest.GetQueryInt("PageNum") == 0 ? SiteInfo.Additional.PageSize : AuthRequest.GetQueryInt("PageNum");
- SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(tableName, SiteId, _channelId, AuthRequest.AdminPermissions.IsSystemAdministrator, AuthRequest.AdminPermissions.OwningChannelIdList, AuthRequest.GetQueryString("SearchType"), AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryString("DateFrom"), AuthRequest.GetQueryString("DateTo"), true, ETriState.All, false, true);
- }
- SpContents.OrderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if(!IsPostBack)
- {
- VerifySitePermissions(ConfigManager.WebSitePermissions.Content);
-
- if (AuthRequest.IsQueryExists("IsDeleteAll"))
- {
- DataProvider.ContentDao.DeleteContentsByTrash(SiteId, tableName);
- AuthRequest.AddSiteLog(SiteId, "清空回收站");
- SuccessMessage("成功清空回收站!");
- AddWaitAndRedirectScript(PageUrl);
- return;
- }
- if (AuthRequest.IsQueryExists("IsRestore"))
- {
- var idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString);
- foreach (var channelId in idsDictionary.Keys)
- {
- var contentIdArrayList = idsDictionary[channelId];
- DataProvider.ContentDao.TrashContents(SiteId, ChannelManager.GetTableName(SiteInfo, channelId), contentIdArrayList);
- }
- AuthRequest.AddSiteLog(SiteId, "从回收站还原内容");
- SuccessMessage("成功还原内容!");
- AddWaitAndRedirectScript(PageUrl);
- return;
- }
- if (AuthRequest.IsQueryExists("IsRestoreAll"))
- {
- DataProvider.ContentDao.RestoreContentsByTrash(SiteId, tableName);
- AuthRequest.AddSiteLog(SiteId, "从回收站还原所有内容");
- SuccessMessage("成功还原所有内容!");
- AddWaitAndRedirectScript(PageUrl);
- return;
- }
- ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, false, AuthRequest.AdminPermissions);
-
- if (_tableStyleInfoList != null)
- {
- foreach (var styleInfo in _tableStyleInfoList)
- {
- var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
- DdlSearchType.Items.Add(listitem);
- }
- }
- //添加隐藏属性
- DdlSearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id));
- DdlSearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName));
- DdlSearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName));
-
- if (AuthRequest.IsQueryExists("channelId"))
- {
- if (SiteId != _channelId)
- {
- ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString());
- }
- ControlUtils.SelectSingleItem(DdlPageNum, AuthRequest.GetQueryString("PageNum"));
- ControlUtils.SelectSingleItem(DdlSearchType, AuthRequest.GetQueryString("SearchType"));
- TbKeyword.Text = AuthRequest.GetQueryString("Keyword");
- TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom");
- TbDateTo.Text = AuthRequest.GetQueryString("DateTo");
- }
-
- SpContents.DataBind();
- }
-
- if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete))
- {
- BtnDelete.Visible = false;
- BtnDeleteAll.Visible = false;
- }
- else
- {
- BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, true, PageUrl));
- BtnDeleteAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsDeleteAll", "True"), "确实要清空回收站吗?"));
- }
- BtnRestore.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.AddQueryString(PageUrl, "IsRestore", "True"), "IDsCollection", "IDsCollection", "请选择需要还原的内容!"));
- BtnRestoreAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsRestoreAll", "True"), "确实要还原所有内容吗?"));
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var ltlItemTitle = (Literal)e.Item.FindControl("ltlItemTitle");
- var ltlChannel = (Literal)e.Item.FindControl("ltlChannel");
- var ltlDeleteDate = (Literal)e.Item.FindControl("ltlDeleteDate");
- var ltlItemEditUrl = (Literal)e.Item.FindControl("ltlItemEditUrl");
- var ltlSelect = (Literal)e.Item.FindControl("ltlSelect");
-
- var contentInfo = new ContentInfo(e.Item.DataItem);
- contentInfo.ChannelId = -contentInfo.ChannelId;
-
- ltlItemTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);
- string nodeNameNavigation;
- if (!_nodeNameNavigations.ContainsKey(contentInfo.ChannelId))
- {
- nodeNameNavigation = ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId);
- _nodeNameNavigations.Add(contentInfo.ChannelId, nodeNameNavigation);
- }
- else
- {
- nodeNameNavigation = _nodeNameNavigations[contentInfo.ChannelId] as string;
- }
- ltlChannel.Text = nodeNameNavigation;
- ltlDeleteDate.Text = DateUtils.GetDateAndTimeString(contentInfo.LastEditDate);
-
- if (HasChannelPermissions(contentInfo.ChannelId, ConfigManager.ChannelPermissions.ContentEdit) || AuthRequest.AdminName == contentInfo.AddUserName)
- {
- var channelInfo = ChannelManager.GetChannelInfo(SiteId, contentInfo.ChannelId);
- ltlItemEditUrl.Text =
- $"修改 ";
- }
-
- ltlSelect.Text =
- $@" ";
- }
-
- public void AddContent_OnClick(object sender, EventArgs e)
- {
- var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- PageUtils.Redirect(WebUtils.GetContentAddAddUrl(SiteId, channelInfo, PageUrl));
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- Response.Redirect(PageUrl, true);
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageContentTrash), new NameValueCollection
- {
- {"channelId", DdlChannelId.SelectedValue},
- {"PageNum", DdlPageNum.SelectedValue},
- {"SearchType", DdlSearchType.SelectedValue},
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text}
- });
- }
- return _pageUrl;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageContentView.cs b/SiteServer.BackgroundPages/Cms/PageContentView.cs
deleted file mode 100644
index 381074426..000000000
--- a/SiteServer.BackgroundPages/Cms/PageContentView.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Api.Preview;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageContentView : BasePageCms
- {
- public Literal LtlScripts;
- public Literal LtlNodeName;
- public Literal LtlContentGroup;
- public Literal LtlTags;
- public Literal LtlLastEditDate;
- public Literal LtlAddUserName;
- public Literal LtlLastEditUserName;
- public Literal LtlContentLevel;
- public Repeater RptContents;
- public PlaceHolder PhTags;
- public PlaceHolder PhContentGroup;
- public Button BtnSubmit;
- public HyperLink HlPreview;
-
- private int _channelId;
- private string _tableName;
- private List _relatedIdentities;
- private int _contentId;
- private string _returnUrl;
- private ContentInfo _contentInfo;
-
- public static string GetContentViewUrl(int siteId, int channelId, int contentId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageContentView), new NameValueCollection
- {
- {"channelId", channelId.ToString()},
- {"ID", contentId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId", "channelId", "ID", "ReturnUrl");
-
- _channelId = AuthRequest.GetQueryInt("channelId");
- var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
- _tableName = ChannelManager.GetTableName(SiteInfo, channelInfo);
- _contentId = AuthRequest.GetQueryInt("ID");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
-
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
-
- _contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, _contentId);
-
- if (IsPostBack) return;
-
- var styleInfoList = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
- var myStyleInfoArrayList = new ArrayList();
- if (styleInfoList != null)
- {
- foreach (var styleInfo in styleInfoList)
- {
- myStyleInfoArrayList.Add(styleInfo);
- }
- }
-
- RptContents.DataSource = myStyleInfoArrayList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- LtlNodeName.Text = ChannelManager.GetChannelName(SiteId, _channelId);
-
- LtlTags.Text = _contentInfo.Tags;
- if (string.IsNullOrEmpty(LtlTags.Text))
- {
- PhTags.Visible = false;
- }
-
- LtlContentGroup.Text = _contentInfo.GroupNameCollection;
- if (string.IsNullOrEmpty(LtlContentGroup.Text))
- {
- PhContentGroup.Visible = false;
- }
-
- LtlLastEditDate.Text = DateUtils.GetDateAndTimeString(_contentInfo.LastEditDate);
- LtlAddUserName.Text = AdminManager.GetDisplayName(_contentInfo.AddUserName, true);
- LtlLastEditUserName.Text = AdminManager.GetDisplayName(_contentInfo.LastEditUserName, true);
-
- LtlContentLevel.Text = CheckManager.GetCheckState(SiteInfo, _contentInfo.IsChecked, _contentInfo.CheckedLevel);
-
- if (_contentInfo.ReferenceId > 0 && _contentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
- {
- var referenceSiteId = DataProvider.ChannelDao.GetSiteId(_contentInfo.SourceId);
- var referenceSiteInfo = SiteManager.GetSiteInfo(referenceSiteId);
- var referenceTableName = ChannelManager.GetTableName(referenceSiteInfo, _contentInfo.SourceId);
- var referenceContentInfo = DataProvider.ContentDao.GetContentInfo(referenceTableName, _contentInfo.ReferenceId);
-
- if (referenceContentInfo != null)
- {
- var pageUrl = PageUtility.GetContentUrl(referenceSiteInfo, referenceContentInfo, true);
- var referenceNodeInfo = ChannelManager.GetChannelInfo(referenceContentInfo.SiteId, referenceContentInfo.ChannelId);
- var addEditUrl =
- WebUtils.GetContentAddEditUrl(referenceSiteInfo.Id,
- referenceNodeInfo, _contentInfo.ReferenceId, AuthRequest.GetQueryString("ReturnUrl"));
-
- LtlScripts.Text += $@"
-此内容为对内容 (站点:{referenceSiteInfo.SiteName},栏目:{referenceNodeInfo.ChannelName})“
{_contentInfo.Title} ”(
编辑 ) 的引用,内容链接将和原始内容链接一致
";
- }
- }
-
- BtnSubmit.Attributes.Add("onclick", ModalContentCheck.GetOpenWindowString(SiteInfo.Id, _channelId, _contentId, _returnUrl));
- HlPreview.NavigateUrl = ApiRoutePreview.GetContentUrl(SiteId, _contentInfo.ChannelId, _contentInfo.Id);
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var styleInfo = (TableStyleInfo)e.Item.DataItem;
-
- var inputHtml = InputParserUtility.GetContentByTableStyle(_contentInfo.GetString(styleInfo.AttributeName), SiteInfo, styleInfo);
-
- var ltlHtml = (Literal)e.Item.FindControl("ltlHtml");
-
- ltlHtml.Text = $@"
-
-
{styleInfo.DisplayName}
-
- {inputHtml}
-
-
-
-";
- }
-
- public string ReturnUrl => _returnUrl;
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageCreateAll.cs b/SiteServer.BackgroundPages/Cms/PageCreateAll.cs
deleted file mode 100644
index 3a25db7aa..000000000
--- a/SiteServer.BackgroundPages/Cms/PageCreateAll.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Settings;
-using SiteServer.CMS.Core.Create;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageCreateAll : BasePageCms
- {
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- CreateManager.CreateAll(SiteId);
- PageCreateStatus.Redirect(SiteId);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageCreateChannel.cs b/SiteServer.BackgroundPages/Cms/PageCreateChannel.cs
deleted file mode 100644
index c632a0031..000000000
--- a/SiteServer.BackgroundPages/Cms/PageCreateChannel.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Settings;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageCreateChannel : BasePageCms
- {
- public ListBox LbChannelIdList;
- public DropDownList DdlScope;
- public Button BtnDeleteAll;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Create);
-
- var listitem = new ListItem("所有选中的栏目", "All");
- DdlScope.Items.Add(listitem);
- listitem = new ListItem("一个月内更新的栏目", "Month");
- DdlScope.Items.Add(listitem);
- listitem = new ListItem("一天内更新的栏目", "Day");
- DdlScope.Items.Add(listitem);
- listitem = new ListItem("2小时内更新的栏目", "2Hour");
- DdlScope.Items.Add(listitem);
-
- ChannelManager.AddListItems(LbChannelIdList.Items, SiteInfo, false, true, AuthRequest.AdminPermissions);
- BtnDeleteAll.Attributes.Add("onclick", "return confirm(\"此操作将删除所有已生成的栏目页面,确定吗?\");");
- }
-
- public void Create_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var channelIdList = new List();
- var selectedChannelIdArrayList = ControlUtils.GetSelectedListControlValueArrayList(LbChannelIdList);
-
- var tableName = SiteInfo.TableName;
-
- if (DdlScope.SelectedValue == "Month")
- {
- var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 720);
- foreach (var channelId in lastEditList)
- {
- if (selectedChannelIdArrayList.Contains(channelId.ToString()))
- {
- channelIdList.Add(channelId);
- }
- }
- }
- else if (DdlScope.SelectedValue == "Day")
- {
- var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 24);
- foreach (var channelId in lastEditList)
- {
- if (selectedChannelIdArrayList.Contains(channelId.ToString()))
- {
- channelIdList.Add(channelId);
- }
- }
- }
- else if (DdlScope.SelectedValue == "2Hour")
- {
- var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 2);
- foreach (var channelId in lastEditList)
- {
- if (selectedChannelIdArrayList.Contains(channelId.ToString()))
- {
- channelIdList.Add(channelId);
- }
- }
- }
- else
- {
- channelIdList = TranslateUtils.StringCollectionToIntList(TranslateUtils.ObjectCollectionToString(selectedChannelIdArrayList));
- }
-
- if (channelIdList.Count == 0)
- {
- FailMessage("请首先选中希望生成页面的栏目!");
- return;
- }
-
- foreach (var channelId in channelIdList)
- {
- CreateManager.CreateChannel(SiteId, channelId);
- }
-
- PageCreateStatus.Redirect(SiteId);
- }
-
- public void BtnDeleteAll_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var url = PageProgressBar.GetDeleteAllPageUrl(SiteId, TemplateType.ChannelTemplate);
- PageUtils.RedirectToLoadingPage(url);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageCreateContent.cs b/SiteServer.BackgroundPages/Cms/PageCreateContent.cs
deleted file mode 100644
index 7ef1a89af..000000000
--- a/SiteServer.BackgroundPages/Cms/PageCreateContent.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Settings;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageCreateContent : BasePageCms
- {
- public ListBox LbChannelIdList;
- public DropDownList DdlScope;
- public Button BtnDeleteAll;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Create);
-
- var listitem = new ListItem("所有选中的栏目", "All");
- DdlScope.Items.Add(listitem);
- listitem = new ListItem("一个月内更新的内容", "Month");
- DdlScope.Items.Add(listitem);
- listitem = new ListItem("一天内更新的内容", "Day");
- DdlScope.Items.Add(listitem);
- listitem = new ListItem("2小时内更新的内容", "2Hour");
- DdlScope.Items.Add(listitem);
-
- ChannelManager.AddListItems(LbChannelIdList.Items, SiteInfo, false, true, AuthRequest.AdminPermissions);
- BtnDeleteAll.Attributes.Add("onclick", "return confirm(\"此操作将删除所有已生成的内容页面,确定吗?\");");
- }
-
-
- public void Create_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var channelIdList = new List();
- var selectedChannelIdArrayList = ControlUtils.GetSelectedListControlValueArrayList(LbChannelIdList);
-
- var tableName = SiteInfo.TableName;
-
- if (DdlScope.SelectedValue == "Month")
- {
- var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 720);
- foreach (var channelId in lastEditList)
- {
- if (selectedChannelIdArrayList.Contains(channelId.ToString()))
- {
- channelIdList.Add(channelId);
- }
- }
- }
- else if (DdlScope.SelectedValue == "Day")
- {
- var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 24);
- foreach (var channelId in lastEditList)
- {
- if (selectedChannelIdArrayList.Contains(channelId.ToString()))
- {
- channelIdList.Add(channelId);
- }
- }
- }
- else if (DdlScope.SelectedValue == "2Hour")
- {
- var lastEditList = DataProvider.ContentDao.GetChannelIdListCheckedByLastEditDateHour(tableName, SiteId, 2);
- foreach (var channelId in lastEditList)
- {
- if (selectedChannelIdArrayList.Contains(channelId.ToString()))
- {
- channelIdList.Add(channelId);
- }
- }
- }
- else
- {
- channelIdList = TranslateUtils.StringCollectionToIntList(TranslateUtils.ObjectCollectionToString(selectedChannelIdArrayList));
- }
-
-
- if (channelIdList.Count == 0)
- {
- FailMessage("请首先选中希望生成内容页面的栏目!");
- return;
- }
-
- foreach (var channelId in channelIdList)
- {
- CreateManager.CreateAllContent(SiteId, channelId);
- }
-
- PageCreateStatus.Redirect(SiteId);
- }
-
- public void BtnDeleteAll_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var url = PageProgressBar.GetDeleteAllPageUrl(SiteId, TemplateType.ContentTemplate);
- PageUtils.RedirectToLoadingPage(url);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageCreateFile.cs b/SiteServer.BackgroundPages/Cms/PageCreateFile.cs
deleted file mode 100644
index b479365ff..000000000
--- a/SiteServer.BackgroundPages/Cms/PageCreateFile.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Settings;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Create;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageCreateFile : BasePageCms
- {
- public ListBox LbTemplateIdList;
- public Button BtnDeleteAll;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Create);
-
- var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListOfFile(SiteId);
-
- foreach (var templateInfo in templateInfoList)
- {
- var listitem = new ListItem(templateInfo.CreatedFileFullName, templateInfo.Id.ToString());
- LbTemplateIdList.Items.Add(listitem);
- }
-
- BtnDeleteAll.Attributes.Add("onclick", "return confirm(\"此操作将删除所有已生成的文件页面,确定吗?\");");
- }
-
- public void Create_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var templateIdList = new List();
- foreach (ListItem item in LbTemplateIdList.Items)
- {
- if (!item.Selected) continue;
-
- var templateId = int.Parse(item.Value);
- templateIdList.Add(templateId);
- }
-
- if (templateIdList.Count == 0)
- {
- FailMessage("请选择需要生成的文件页!");
- return;
- }
-
- foreach (var templateId in templateIdList)
- {
- CreateManager.CreateFile(SiteId, templateId);
- }
-
- PageCreateStatus.Redirect(SiteId);
- }
-
- public void BtnDeleteAll_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var url = PageProgressBar.GetDeleteAllPageUrl(SiteId, TemplateType.FileTemplate);
- PageUtils.RedirectToLoadingPage(url);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageCreateIndex.cs b/SiteServer.BackgroundPages/Cms/PageCreateIndex.cs
deleted file mode 100644
index fcf410f49..000000000
--- a/SiteServer.BackgroundPages/Cms/PageCreateIndex.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Settings;
-using SiteServer.CMS.Core.Create;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageCreateIndex : BasePageCms
- {
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (!IsPostBack)
- {
- CreateManager.CreateChannel(SiteId, SiteId); // 创建任务
- PageCreateStatus.Redirect(SiteId); // 转到查询任务进度页面
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageProgressBar.cs b/SiteServer.BackgroundPages/Cms/PageProgressBar.cs
deleted file mode 100644
index 67775dc22..000000000
Binary files a/SiteServer.BackgroundPages/Cms/PageProgressBar.cs and /dev/null differ
diff --git a/SiteServer.BackgroundPages/Cms/PageTableStyleContent.cs b/SiteServer.BackgroundPages/Cms/PageTableStyleContent.cs
deleted file mode 100644
index d02d4ce35..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTableStyleContent.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTableStyleContent : BasePageCms
- {
- public DropDownList DdlChannelId;
- public Repeater RptContents;
-
- public Button BtnAddStyle;
- public Button BtnAddStyles;
- public Button BtnImport;
- public Button BtnExport;
-
- private ChannelInfo _channelInfo;
- private string _tableName;
- private List _relatedIdentities;
- private string _redirectUrl;
-
- public static string GetRedirectUrl(int siteId, int channelId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTableStyleContent), new NameValueCollection
- {
- {"channelId", channelId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- var channelId = AuthRequest.GetQueryInt("channelId", SiteId);
- _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- _tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo);
- _redirectUrl = GetRedirectUrl(SiteId, channelId);
- _relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, channelId);
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- //删除样式
- if (AuthRequest.IsQueryExists("DeleteStyle"))
- {
- var attributeName = AuthRequest.GetQueryString("AttributeName");
- if (TableStyleManager.IsExists(_channelInfo.Id, _tableName, attributeName))
- {
- try
- {
- TableStyleManager.Delete(_channelInfo.Id, _tableName, attributeName);
- AuthRequest.AddSiteLog(SiteId, "删除数据表单样式", $"表单:{_tableName},字段:{attributeName}");
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- }
-
- InfoMessage(
- $"在此编辑内容模型字段,子栏目默认继承父栏目字段设置; 辅助表:{DataProvider.TableDao.GetDisplayName(_tableName)}({_tableName})");
- ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, false, true, AuthRequest.AdminPermissions);
- ControlUtils.SelectSingleItem(DdlChannelId, channelId.ToString());
-
- RptContents.DataSource = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- BtnAddStyle.Attributes.Add("onclick", ModalTableStyleAdd.GetOpenWindowString(SiteId, 0, _relatedIdentities, _tableName, string.Empty, _redirectUrl));
- BtnAddStyles.Attributes.Add("onclick", ModalTableStylesAdd.GetOpenWindowString(SiteId, _relatedIdentities, _tableName, _redirectUrl));
- BtnImport.Attributes.Add("onclick", ModalTableStyleImport.GetOpenWindowString(_tableName, SiteId, channelId));
- BtnExport.Attributes.Add("onclick", ModalExportMessage.GetOpenWindowStringToSingleTableStyle(_tableName, SiteId, channelId));
- }
-
- public void Redirect(object sender, EventArgs e)
- {
- PageUtils.Redirect(GetRedirectUrl(SiteId, TranslateUtils.ToInt(DdlChannelId.SelectedValue)));
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var styleInfo = (TableStyleInfo)e.Item.DataItem;
-
- var ltlAttributeName = (Literal)e.Item.FindControl("ltlAttributeName");
- var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName");
- var ltlInputType = (Literal)e.Item.FindControl("ltlInputType");
- var ltlFieldType = (Literal)e.Item.FindControl("ltlFieldType");
- var ltlValidate = (Literal)e.Item.FindControl("ltlValidate");
- var ltlTaxis = (Literal)e.Item.FindControl("ltlTaxis");
- var ltlEditStyle = (Literal)e.Item.FindControl("ltlEditStyle");
- var ltlEditValidate = (Literal)e.Item.FindControl("ltlEditValidate");
-
- ltlAttributeName.Text = styleInfo.AttributeName;
-
- ltlDisplayName.Text = styleInfo.DisplayName;
- ltlInputType.Text = InputTypeUtils.GetText(styleInfo.InputType);
- ltlFieldType.Text = TableMetadataManager.IsAttributeNameExists(_tableName, styleInfo.AttributeName) ? $"真实 {TableMetadataManager.GetTableMetadataDataType(_tableName, styleInfo.AttributeName)}" : "虚拟字段";
-
- ltlValidate.Text = TableStyleManager.GetValidateInfo(styleInfo);
-
- var showPopWinString = ModalTableStyleAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, _redirectUrl);
- var editText = styleInfo.RelatedIdentity == _channelInfo.Id ? "修改" : "添加";
- ltlEditStyle.Text = $@"{editText} ";
-
- showPopWinString = ModalTableStyleValidateAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, _redirectUrl);
- ltlEditValidate.Text = $@"设置 ";
-
- ltlTaxis.Text = styleInfo.Taxis.ToString();
-
- if (styleInfo.RelatedIdentity != _channelInfo.Id) return;
-
- var urlStyle = PageUtils.GetCmsUrl(SiteId, nameof(PageTableStyleContent), new NameValueCollection
- {
- {"channelId", _channelInfo.Id.ToString()},
- {"DeleteStyle", true.ToString()},
- {"TableName", _tableName},
- {"AttributeName", styleInfo.AttributeName}
- });
- ltlEditStyle.Text +=
- $@" 删除 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTableStyleSite.cs b/SiteServer.BackgroundPages/Cms/PageTableStyleSite.cs
deleted file mode 100644
index f010579ec..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTableStyleSite.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTableStyleSite : BasePageCms
- {
- public Repeater RptContents;
-
- public Button BtnAddStyle;
- public Button BtnAddStyles;
- public Button BtnImport;
- public Button BtnExport;
- public Button BtnReturn;
-
- private int _relatedIdentity;
- private List _relatedIdentities;
- private string _tableName;
- private int _itemId;
- private List _attributeNames;
- private string _returnUrl;
-
- public static string GetRedirectUrl(int siteId, int relatedIdentity, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTableStyleSite), new NameValueCollection
- {
- {"RelatedIdentity", relatedIdentity.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public static string GetRedirectUrl(int siteId, int relatedIdentity, int itemId, string returnUrl)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTableStyleSite), new NameValueCollection
- {
- {"RelatedIdentity", relatedIdentity.ToString()},
- {"ItemID", itemId.ToString()},
- {"ReturnUrl", StringUtils.ValueToUrl(returnUrl)}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _relatedIdentity = string.IsNullOrEmpty(AuthRequest.GetQueryString("RelatedIdentity")) ? SiteId : AuthRequest.GetQueryInt("RelatedIdentity");
- _tableName = DataProvider.SiteDao.TableName;
- _itemId = AuthRequest.GetQueryInt("itemID");
- _relatedIdentities = RelatedIdentities.GetRelatedIdentities(SiteId, _relatedIdentity);
- _attributeNames = TableMetadataManager.GetAttributeNameList(_tableName);
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("ReturnUrl"));
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Configration);
-
- //删除样式
- if (AuthRequest.IsQueryExists("DeleteStyle"))
- {
- var attributeName = AuthRequest.GetQueryString("AttributeName");
- if (TableStyleManager.IsExists(_relatedIdentity, _tableName, attributeName))
- {
- try
- {
- TableStyleManager.Delete(_relatedIdentity, _tableName, attributeName);
- AuthRequest.AddSiteLog(SiteId, "删除数据表单样式", $"表单:{_tableName},字段:{attributeName}");
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- }
-
- if (!string.IsNullOrEmpty(_returnUrl))
- {
- BtnReturn.Attributes.Add("onclick", $"location.href='{_returnUrl}';return false;");
- }
- else
- {
- BtnReturn.Visible = false;
- }
-
- RptContents.DataSource = TableStyleManager.GetTableStyleInfoList(_tableName, _relatedIdentities);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- var redirectUrl = GetRedirectUrl(SiteId, _relatedIdentity, _itemId, _returnUrl);
-
- BtnAddStyle.Attributes.Add("onclick", ModalTableStyleAdd.GetOpenWindowString(SiteId, 0, _relatedIdentities, _tableName, string.Empty, redirectUrl));
- BtnAddStyles.Attributes.Add("onclick", ModalTableStylesAdd.GetOpenWindowString(SiteId, _relatedIdentities, _tableName, redirectUrl));
-
- BtnImport.Attributes.Add("onclick", ModalTableStyleImport.GetOpenWindowString(_tableName, SiteId, _relatedIdentity));
- BtnExport.Attributes.Add("onclick", ModalExportMessage.GetOpenWindowStringToSingleTableStyle(_tableName, SiteId, _relatedIdentity));
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var styleInfo = (TableStyleInfo)e.Item.DataItem;
-
- if (_attributeNames.Contains(styleInfo.AttributeName))
- {
- e.Item.Visible = false;
- return;
- }
-
- var ltlAttributeName = (Literal)e.Item.FindControl("ltlAttributeName");
- var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName");
- var ltlInputType = (Literal)e.Item.FindControl("ltlInputType");
- var ltlValidate = (Literal)e.Item.FindControl("ltlValidate");
- var ltlTaxis = (Literal)e.Item.FindControl("ltlTaxis");
- var ltlEditStyle = (Literal)e.Item.FindControl("ltlEditStyle");
- var ltlEditValidate = (Literal)e.Item.FindControl("ltlEditValidate");
-
- ltlAttributeName.Text = styleInfo.AttributeName;
-
- ltlDisplayName.Text = styleInfo.DisplayName;
- ltlInputType.Text = InputTypeUtils.GetText(styleInfo.InputType);
-
- ltlValidate.Text = TableStyleManager.GetValidateInfo(styleInfo);
-
- var redirectUrl = GetRedirectUrl(SiteId, _relatedIdentity, _itemId, _returnUrl);
- var showPopWinString = ModalTableStyleAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, redirectUrl);
- var editText = styleInfo.RelatedIdentity == _relatedIdentity ? "修改" : "设置";
- ltlEditStyle.Text = $@"{editText} ";
-
- showPopWinString = ModalTableStyleValidateAdd.GetOpenWindowString(SiteId, styleInfo.Id, _relatedIdentities, _tableName, styleInfo.AttributeName, redirectUrl);
- ltlEditValidate.Text = $@"设置 ";
-
- ltlTaxis.Text = styleInfo.Taxis.ToString();
-
- if (styleInfo.RelatedIdentity != _relatedIdentity) return;
-
- var urlStyle = PageUtils.GetCmsUrl(SiteId, nameof(PageTableStyleSite), new NameValueCollection
- {
- {"TableName", _tableName},
- {"RelatedIdentity", _relatedIdentity.ToString()},
- {"DeleteStyle", true.ToString()},
- {"AttributeName", styleInfo.AttributeName}
- });
- ltlEditStyle.Text +=
- $@" 删除 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateCss.cs b/SiteServer.BackgroundPages/Cms/PageTemplateCss.cs
deleted file mode 100644
index 80054e222..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateCss.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateCss : BasePageCms
- {
- public Repeater RptContents;
- public Button BtnAdd;
-
- private string _directoryPath;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateCss), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- _directoryPath = PathUtility.MapPath(SiteInfo, "@/css");
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var fileName = AuthRequest.GetQueryString("FileName");
-
- try
- {
- FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, fileName));
- AuthRequest.AddSiteLog(SiteId, "删除样式文件", $"样式文件:{fileName}");
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- DirectoryUtils.CreateDirectoryIfNotExists(_directoryPath);
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- var fileNameList = new List();
- foreach (var fileName in fileNames)
- {
- if (EFileSystemTypeUtils.IsTextEditable(EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(fileName))))
- {
- if (!fileName.Contains("_parsed"))
- {
- fileNameList.Add(fileName);
- }
- }
- }
-
- RptContents.DataSource = fileNameList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- BtnAdd.Attributes.Add("onclick", $"location.href='{PageTemplateCssAdd.GetRedirectUrl(SiteId)}';return false");
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var fileName = (string) e.Item.DataItem;
-
- var ltlFileName = (Literal)e.Item.FindControl("ltlFileName");
- var ltlCharset = (Literal)e.Item.FindControl("ltlCharset");
- var ltlView = (Literal)e.Item.FindControl("ltlView");
- var ltlEdit = (Literal)e.Item.FindControl("ltlEdit");
- var ltlDelete = (Literal)e.Item.FindControl("ltlDelete");
-
- ltlFileName.Text = fileName;
-
- var charset = FileUtils.GetFileCharset(PathUtils.Combine(_directoryPath, fileName));
- ltlCharset.Text = ECharsetUtils.GetText(charset);
-
- ltlView.Text = $@"查看 ";
- ltlEdit.Text =
- $@"编辑 ";
- ltlDelete.Text =
- $@"删除 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateCssAdd.cs b/SiteServer.BackgroundPages/Cms/PageTemplateCssAdd.cs
deleted file mode 100644
index 66dec1718..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateCssAdd.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateCssAdd : BasePageCms
- {
- public Literal LtlPageTitle;
- public TextBox TbRelatedFileName;
- public DropDownList DdlCharset;
- public TextBox TbContent;
- public PlaceHolder PhCodeMirror;
- public Button BtnEditorType;
-
- private string _fileName;
- private string _directoryPath;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateCssAdd), null);
- }
-
- public static string GetRedirectUrl(int siteId, string fileName)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateCssAdd), new NameValueCollection
- {
- {"FileName", fileName}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (AuthRequest.IsQueryExists("FileName"))
- {
- _fileName = AuthRequest.GetQueryString("FileName");
- _fileName = PathUtils.RemoveParentPath(_fileName);
- }
- _directoryPath = PathUtility.MapPath(SiteInfo, "@/css");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- LtlPageTitle.Text = string.IsNullOrEmpty(_fileName) ? "添加样式文件" : "编辑样式文件";
-
- var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;
- BtnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
- PhCodeMirror.Visible = isCodeMirror;
-
- ECharsetUtils.AddListItems(DdlCharset);
-
- if (_fileName != null)
- {
- if (!EFileSystemTypeUtils.IsCss(PathUtils.GetExtension(_fileName)))
- {
- PageUtils.RedirectToErrorPage("对不起,此文件无法编辑!");
- }
- else
- {
- TbRelatedFileName.Text = PathUtils.RemoveExtension(_fileName);
- var fileCharset = FileUtils.GetFileCharset(PathUtils.Combine(_directoryPath, _fileName));
- ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, ECharsetUtils.GetValue(fileCharset));
- TbContent.Text = FileUtils.ReadText(PathUtils.Combine(_directoryPath, _fileName), fileCharset);
- }
- }
- else
- {
- ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, SiteInfo.Additional.Charset);
- }
- }
-
- public void EditorType_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;
- isCodeMirror = !isCodeMirror;
- SiteInfo.Additional.ConfigTemplateIsCodeMirror = isCodeMirror;
- DataProvider.SiteDao.Update(SiteInfo);
-
- BtnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
- PhCodeMirror.Visible = isCodeMirror;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- if (_fileName != null)
- {
- var isChanged = false;
- if (PathUtils.RemoveExtension(_fileName) != PathUtils.RemoveExtension(TbRelatedFileName.Text))//文件名改变
- {
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- foreach (var theFileName in fileNames)
- {
- var fileNameWithoutExtension = PathUtils.RemoveExtension(theFileName);
- if (fileNameWithoutExtension == TbRelatedFileName.Text.ToLower())
- {
- FailMessage("样式文件修改失败,样式文件已存在!");
- return;
- }
- }
-
- isChanged = true;
- }
-
- var previousFileName = string.Empty;
- if (isChanged)
- {
- previousFileName = _fileName;
- }
-
- var currentFileName = TbRelatedFileName.Text + ".css";
- var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue);
- FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text);
- if (!string.IsNullOrEmpty(previousFileName))
- {
- FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, previousFileName));
- }
- AuthRequest.AddSiteLog(SiteId, "修改样式文件", $"样式文件:{currentFileName}");
- SuccessMessage("样式文件修改成功!");
- AddWaitAndRedirectScript(PageTemplateCss.GetRedirectUrl(SiteId));
- }
- else
- {
- var currentFileName = TbRelatedFileName.Text + ".css";
-
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- foreach (var theFileName in fileNames)
- {
- if (StringUtils.EqualsIgnoreCase(theFileName, currentFileName))
- {
- FailMessage("样式文件添加失败,样式文件文件已存在!");
- return;
- }
- }
-
- var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue);
- FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text);
- AuthRequest.AddSiteLog(SiteId, "添加样式文件", $"样式文件:{currentFileName}");
- SuccessMessage("样式文件添加成功!");
- AddWaitAndRedirectScript(PageTemplateCss.GetRedirectUrl(SiteId));
- }
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageTemplateCss.GetRedirectUrl(SiteId));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateInclude.cs b/SiteServer.BackgroundPages/Cms/PageTemplateInclude.cs
deleted file mode 100644
index 7fb8e1623..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateInclude.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateInclude : BasePageCms
- {
- public Repeater RptContents;
- public Button BtnAdd;
-
- private string _directoryPath;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateInclude), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- _directoryPath = PathUtility.MapPath(SiteInfo, "@/include");
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var fileName = AuthRequest.GetQueryString("FileName");
-
- try
- {
- FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, fileName));
- AuthRequest.AddSiteLog(SiteId, "删除包含文件", $"包含文件:{fileName}");
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- DirectoryUtils.CreateDirectoryIfNotExists(_directoryPath);
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- var fileNameList = new List();
- foreach (var fileName in fileNames)
- {
- if (EFileSystemTypeUtils.IsTextEditable(EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(fileName))))
- {
- if (!fileName.Contains("_parsed"))
- {
- fileNameList.Add(fileName);
- }
- }
- }
-
- RptContents.DataSource = fileNameList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- BtnAdd.Attributes.Add("onclick", $"location.href='{PageTemplateIncludeAdd.GetRedirectUrl(SiteId)}';return false");
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var fileName = (string)e.Item.DataItem;
-
- var ltlFileName = (Literal)e.Item.FindControl("ltlFileName");
- var ltlCharset = (Literal)e.Item.FindControl("ltlCharset");
- var ltlEdit = (Literal)e.Item.FindControl("ltlEdit");
- var ltlDelete = (Literal)e.Item.FindControl("ltlDelete");
-
- ltlFileName.Text = fileName;
-
- var charset = FileUtils.GetFileCharset(PathUtils.Combine(_directoryPath, fileName));
- ltlCharset.Text = ECharsetUtils.GetText(charset);
-
- ltlEdit.Text =
- $@"编辑 ";
- ltlDelete.Text =
- $@"删除 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateIncludeAdd.cs b/SiteServer.BackgroundPages/Cms/PageTemplateIncludeAdd.cs
deleted file mode 100644
index 8400089ff..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateIncludeAdd.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateIncludeAdd : BasePageCms
- {
- public Literal LtlPageTitle;
- public TextBox TbRelatedFileName;
- public Literal LtlCreatedFileExtName;
- public DropDownList DdlCharset;
- public TextBox TbContent;
- public PlaceHolder PhCodeMirror;
- public Button BtnEditorType;
-
- private string _fileName;
- private string _directoryPath;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateIncludeAdd), null);
- }
-
- public static string GetRedirectUrl(int siteId, string fileName)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateIncludeAdd), new NameValueCollection
- {
- {"FileName", fileName}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (AuthRequest.IsQueryExists("FileName"))
- {
- _fileName = AuthRequest.GetQueryString("FileName");
- _fileName = PathUtils.RemoveParentPath(_fileName);
- }
- _directoryPath = PathUtility.MapPath(SiteInfo, "@/include");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- LtlPageTitle.Text = string.IsNullOrEmpty(_fileName) ? "添加包含文件" : "编辑包含文件";
-
- var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;
- BtnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
- PhCodeMirror.Visible = isCodeMirror;
-
- ECharsetUtils.AddListItems(DdlCharset);
-
- if (_fileName != null)
- {
- if (!EFileSystemTypeUtils.IsHtml(PathUtils.GetExtension(_fileName)))
- {
- PageUtils.RedirectToErrorPage("对不起,此文件无法编辑!");
- }
- else
- {
- TbRelatedFileName.Text = PathUtils.RemoveExtension(_fileName);
- LtlCreatedFileExtName.Text = PathUtils.GetExtension(_fileName);
- var fileCharset = FileUtils.GetFileCharset(PathUtils.Combine(_directoryPath, _fileName));
- ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, ECharsetUtils.GetValue(fileCharset));
- TbContent.Text = FileUtils.ReadText(PathUtils.Combine(_directoryPath, _fileName), fileCharset);
- }
- }
- else
- {
- LtlCreatedFileExtName.Text = ".html";
- ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, SiteInfo.Additional.Charset);
- }
- }
-
- public void EditorType_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;
- isCodeMirror = !isCodeMirror;
- SiteInfo.Additional.ConfigTemplateIsCodeMirror = isCodeMirror;
- DataProvider.SiteDao.Update(SiteInfo);
-
- BtnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
- PhCodeMirror.Visible = isCodeMirror;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- if (_fileName != null)
- {
- var isChanged = false;
- if (PathUtils.RemoveExtension(_fileName) != PathUtils.RemoveExtension(TbRelatedFileName.Text))//文件名改变
- {
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- foreach (var theFileName in fileNames)
- {
- var fileNameWithoutExtension = PathUtils.RemoveExtension(theFileName);
- if (fileNameWithoutExtension == TbRelatedFileName.Text.ToLower())
- {
- FailMessage("包含文件修改失败,包含文件已存在!");
- return;
- }
- }
-
- isChanged = true;
- }
-
- if (PathUtils.GetExtension(_fileName) != LtlCreatedFileExtName.Text)//文件后缀改变
- {
- isChanged = true;
- }
-
- var previousFileName = string.Empty;
- if (isChanged)
- {
- previousFileName = _fileName;
- }
-
- var currentFileName = TbRelatedFileName.Text + LtlCreatedFileExtName.Text;
- var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue);
- FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text);
- if (!string.IsNullOrEmpty(previousFileName))
- {
- FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, previousFileName));
- }
- AuthRequest.AddSiteLog(SiteId, "修改包含文件", $"包含文件:{currentFileName}");
- SuccessMessage("包含文件修改成功!");
- AddWaitAndRedirectScript(PageTemplateInclude.GetRedirectUrl(SiteId));
- }
- else
- {
- var currentFileName = TbRelatedFileName.Text + LtlCreatedFileExtName.Text;
-
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- foreach (var theFileName in fileNames)
- {
- if (StringUtils.EqualsIgnoreCase(theFileName, currentFileName))
- {
- FailMessage("包含文件添加失败,包含文件文件已存在!");
- return;
- }
- }
-
- var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue);
- FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text);
- AuthRequest.AddSiteLog(SiteId, "添加包含文件", $"包含文件:{currentFileName}");
- SuccessMessage("包含文件添加成功!");
- AddWaitAndRedirectScript(PageTemplateInclude.GetRedirectUrl(SiteId));
- }
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageTemplateInclude.GetRedirectUrl(SiteId));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateJs.cs b/SiteServer.BackgroundPages/Cms/PageTemplateJs.cs
deleted file mode 100644
index 10b418233..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateJs.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateJs : BasePageCms
- {
- public Repeater RptContents;
- public Button BtnAdd;
-
- private string _directoryPath;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateJs), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- _directoryPath = PathUtility.MapPath(SiteInfo, "@/js");
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var fileName = AuthRequest.GetQueryString("FileName");
-
- try
- {
- FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, fileName));
- AuthRequest.AddSiteLog(SiteId, "删除脚本文件", $"脚本文件:{fileName}");
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- DirectoryUtils.CreateDirectoryIfNotExists(_directoryPath);
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- var fileNameList = new List();
- foreach (var fileName in fileNames)
- {
- if (EFileSystemTypeUtils.IsTextEditable(EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(fileName))))
- {
- if (!fileName.Contains("_parsed"))
- {
- fileNameList.Add(fileName);
- }
- }
- }
-
- RptContents.DataSource = fileNameList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- BtnAdd.Attributes.Add("onclick", $"location.href='{PageTemplateJsAdd.GetRedirectUrl(SiteId)}';return false");
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var fileName = (string)e.Item.DataItem;
-
- var ltlFileName = (Literal)e.Item.FindControl("ltlFileName");
- var ltlCharset = (Literal)e.Item.FindControl("ltlCharset");
- var ltlView = (Literal)e.Item.FindControl("ltlView");
- var ltlEdit = (Literal)e.Item.FindControl("ltlEdit");
- var ltlDelete = (Literal)e.Item.FindControl("ltlDelete");
-
- ltlFileName.Text = fileName;
-
- var charset = FileUtils.GetFileCharset(PathUtils.Combine(_directoryPath, fileName));
- ltlCharset.Text = ECharsetUtils.GetText(charset);
-
- ltlView.Text = $@"查看 ";
- ltlEdit.Text =
- $@"编辑 ";
- ltlDelete.Text =
- $@"删除 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateJsAdd.cs b/SiteServer.BackgroundPages/Cms/PageTemplateJsAdd.cs
deleted file mode 100644
index 1e9a7b046..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateJsAdd.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateJsAdd : BasePageCms
- {
- public Literal LtlPageTitle;
- public TextBox TbRelatedFileName;
- public DropDownList DdlCharset;
- public TextBox TbContent;
- public PlaceHolder PhCodeMirror;
- public Button BtnEditorType;
-
- private string _fileName;
- private string _directoryPath;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateJsAdd), null);
- }
-
- public static string GetRedirectUrl(int siteId, string fileName)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateJsAdd), new NameValueCollection
- {
- {"FileName", fileName}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (AuthRequest.IsQueryExists("FileName"))
- {
- _fileName = AuthRequest.GetQueryString("FileName");
- _fileName = PathUtils.RemoveParentPath(_fileName);
- }
- _directoryPath = PathUtility.MapPath(SiteInfo, "@/js");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- LtlPageTitle.Text = string.IsNullOrEmpty(_fileName) ? "添加脚本文件" : "编辑脚本文件";
-
- var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;
- BtnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
- PhCodeMirror.Visible = isCodeMirror;
-
- ECharsetUtils.AddListItems(DdlCharset);
-
- if (_fileName != null)
- {
- if (!EFileSystemTypeUtils.IsJs(PathUtils.GetExtension(_fileName)))
- {
- PageUtils.RedirectToErrorPage("对不起,此文件无法编辑!");
- }
- else
- {
- TbRelatedFileName.Text = PathUtils.RemoveExtension(_fileName);
- var fileCharset = FileUtils.GetFileCharset(PathUtils.Combine(_directoryPath, _fileName));
- ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, ECharsetUtils.GetValue(fileCharset));
- TbContent.Text = FileUtils.ReadText(PathUtils.Combine(_directoryPath, _fileName), fileCharset);
- }
- }
- else
- {
- ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, SiteInfo.Additional.Charset);
- }
- }
-
- public void EditorType_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;
- isCodeMirror = !isCodeMirror;
- SiteInfo.Additional.ConfigTemplateIsCodeMirror = isCodeMirror;
- DataProvider.SiteDao.Update(SiteInfo);
-
- BtnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
- PhCodeMirror.Visible = isCodeMirror;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- if (_fileName != null)
- {
- var isChanged = false;
- if (PathUtils.RemoveExtension(_fileName) != PathUtils.RemoveExtension(TbRelatedFileName.Text))//文件名改变
- {
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- foreach (var theFileName in fileNames)
- {
- var fileNameWithoutExtension = PathUtils.RemoveExtension(theFileName);
- if (fileNameWithoutExtension == TbRelatedFileName.Text.ToLower())
- {
- FailMessage("脚本文件修改失败,脚本文件已存在!");
- return;
- }
- }
-
- isChanged = true;
- }
-
- var previousFileName = string.Empty;
- if (isChanged)
- {
- previousFileName = _fileName;
- }
-
- var currentFileName = TbRelatedFileName.Text + ".js";
- var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue);
- FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text);
- if (!string.IsNullOrEmpty(previousFileName))
- {
- FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, previousFileName));
- }
- AuthRequest.AddSiteLog(SiteId, "修改脚本文件", $"脚本文件:{currentFileName}");
- SuccessMessage("脚本文件修改成功!");
- AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(SiteId));
- }
- else
- {
- var currentFileName = TbRelatedFileName.Text + ".js";
-
- var fileNames = DirectoryUtils.GetFileNames(_directoryPath);
- foreach (var theFileName in fileNames)
- {
- if (StringUtils.EqualsIgnoreCase(theFileName, currentFileName))
- {
- FailMessage("脚本文件添加失败,脚本文件文件已存在!");
- return;
- }
- }
-
- var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue);
- FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text);
- AuthRequest.AddSiteLog(SiteId, "添加脚本文件", $"脚本文件:{currentFileName}");
- SuccessMessage("脚本文件添加成功!");
- AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(SiteId));
- }
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageTemplateJs.GetRedirectUrl(SiteId));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateMatch.cs b/SiteServer.BackgroundPages/Cms/PageTemplateMatch.cs
deleted file mode 100644
index 8f6ea0afe..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateMatch.cs
+++ /dev/null
@@ -1,483 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateMatch : BasePageCms
- {
- public ListBox LbChannelId;
- public ListBox LbChannelTemplateId;
- public ListBox LbContentTemplateId;
- public Button BtnCreateChannelTemplate;
- public Button BtnCreateSubChannelTemplate;
- public Button BtnCreateContentTemplate;
- public Button BtnCreateSubContentTemplate;
-
- private bool[] _isLastNodeArray;
- private string _defaultChannelTemplateName;
- private string _defaultContentTemplateName;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetCmsUrl(siteId, nameof(PageTemplateMatch), null);
- }
-
- public string GetTitle(ChannelInfo nodeInfo)
- {
- var str = string.Empty;
- if (nodeInfo.Id == SiteId)
- {
- nodeInfo.IsLastNode = true;
- }
- if (nodeInfo.IsLastNode == false)
- {
- _isLastNodeArray[nodeInfo.ParentsCount] = false;
- }
- else
- {
- _isLastNodeArray[nodeInfo.ParentsCount] = true;
- }
- for (var i = 0; i < nodeInfo.ParentsCount; i++)
- {
- str = string.Concat(str, _isLastNodeArray[i] ? " " : "│");
- }
- str = string.Concat(str, nodeInfo.IsLastNode ? "└" : "├");
- str = string.Concat(str, StringUtils.MaxLengthText(nodeInfo.ChannelName, 8));
-
- if (nodeInfo.ParentId == 0)
- {
- var indexTemplateId = TemplateManager.GetDefaultTemplateId(SiteId, TemplateType.IndexPageTemplate);
- var indexTemplateName = TemplateManager.GetTemplateName(SiteId, indexTemplateId);
- str = string.Concat(str, $" ({indexTemplateName})");
- }
- else
- {
- var channelTemplateId = nodeInfo.ChannelTemplateId;
- var contentTemplateId = nodeInfo.ContentTemplateId;
-
- var channelTemplateName = string.Empty;
- if (channelTemplateId != 0)
- {
- channelTemplateName = TemplateManager.GetTemplateName(SiteId, channelTemplateId);
- }
- if (string.IsNullOrEmpty(channelTemplateName))
- {
- channelTemplateName = _defaultChannelTemplateName;
- }
- str = string.Concat(str, $" ({channelTemplateName})");
-
- var contentTemplateName = string.Empty;
- if (contentTemplateId != 0)
- {
- contentTemplateName = TemplateManager.GetTemplateName(SiteId, contentTemplateId);
- }
- if (string.IsNullOrEmpty(contentTemplateName))
- {
- contentTemplateName = _defaultContentTemplateName;
- }
- str = string.Concat(str, $" ({contentTemplateName})");
- }
-
- return str;
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- var defaultChannelTemplateId = TemplateManager.GetDefaultTemplateId(SiteId, TemplateType.ChannelTemplate);
- _defaultChannelTemplateName = TemplateManager.GetTemplateName(SiteId, defaultChannelTemplateId);
-
- var defaultContentTemplateId = TemplateManager.GetDefaultTemplateId(SiteId, TemplateType.ContentTemplate);
- _defaultContentTemplateName = TemplateManager.GetTemplateName(SiteId, defaultContentTemplateId);
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- LbChannelTemplateId.Attributes.Add("onfocus", "$('#LbContentTemplateId option:selected').removeAttr('selected')");
- LbContentTemplateId.Attributes.Add("onfocus", "$('#LbChannelTemplateId option:selected').removeAttr('selected')");
-
- BindListBox();
-
- BtnCreateChannelTemplate.OnClientClick = $"{AlertUtils.Confirm("创建栏目模板", "此操作将创建空的栏目模板并匹配选中栏目,确认吗?", "创 建", "$('#BtnCreateChannelTemplateReal').click()")}";
- BtnCreateSubChannelTemplate.OnClientClick = $"{AlertUtils.Confirm("创建下级栏目模版", "此操作将创建空的栏目模板并匹配选中栏目的下级栏目,确认吗?", "创 建", "$('#BtnCreateSubChannelTemplateReal').click()")}";
- BtnCreateContentTemplate.OnClientClick = $"{AlertUtils.Confirm("创建内容模版", "此操作将创建空的内容模板并匹配选中栏目,确认吗?", "创 建", "$('#BtnCreateContentTemplateReal').click()")}";
- BtnCreateSubContentTemplate.OnClientClick = $"{AlertUtils.Confirm("创建下级内容模版", "此操作将创建空的内容模板并匹配选中栏目的下级栏目,确认吗?", "创 建", "$('#BtnCreateSubContentTemplateReal').click()")}";
- }
-
-
- public void BindListBox()
- {
- var selectedChannelIdList = new List();
- foreach (ListItem listitem in LbChannelId.Items)
- {
- if (listitem.Selected) selectedChannelIdList.Add(listitem.Value);
- }
- var selectedChannelTemplateId = LbChannelTemplateId.SelectedValue;
- var selectedContentTemplateId = LbContentTemplateId.SelectedValue;
-
- LbChannelId.Items.Clear();
- LbChannelTemplateId.Items.Clear();
- LbContentTemplateId.Items.Clear();
- var channelIdList = ChannelManager.GetChannelIdList(SiteId);
- var nodeCount = channelIdList.Count;
- _isLastNodeArray = new bool[nodeCount];
- foreach (var theChannelId in channelIdList)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, theChannelId);
- var listitem = new ListItem(GetTitle(nodeInfo), nodeInfo.Id.ToString());
- LbChannelId.Items.Add(listitem);
- }
-
- LbChannelTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ChannelTemplate);
- LbContentTemplateId.DataSource = DataProvider.TemplateDao.GetDataSourceByType(SiteId, TemplateType.ContentTemplate);
- DataBind();
-
- ControlUtils.SelectMultiItems(LbChannelId, selectedChannelIdList);
- ControlUtils.SelectSingleItem(LbChannelTemplateId, selectedChannelTemplateId);
- ControlUtils.SelectSingleItem(LbContentTemplateId, selectedContentTemplateId);
- }
-
- public void MatchChannelTemplateButton_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(true, true)) return;
-
- var channelIdList = new List();
- foreach (ListItem item in LbChannelId.Items)
- {
- if (item.Selected)
- {
- var channelId = int.Parse(item.Value);
- channelIdList.Add(channelId);
- }
- }
- var channelTemplateId = int.Parse(LbChannelTemplateId.SelectedValue);
- Process(channelIdList, channelTemplateId, true);
- }
-
- public void RemoveChannelTemplateButton_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(false, true)) return;
-
- var channelIdList = new List();
- foreach (ListItem item in LbChannelId.Items)
- {
- if (item.Selected)
- {
- var channelId = int.Parse(item.Value);
- channelIdList.Add(channelId);
- }
- }
- Process(channelIdList, 0, true);
- }
-
- public void MatchContentTemplateButton_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(true, false)) return;
-
- var channelIdList = new List();
- foreach (ListItem item in LbChannelId.Items)
- {
- if (item.Selected)
- {
- var channelId = int.Parse(item.Value);
- channelIdList.Add(channelId);
- }
- }
- var contentTemplateId = int.Parse(LbContentTemplateId.SelectedValue);
- Process(channelIdList, contentTemplateId, false);
- }
-
- public void RemoveContentTemplateButton_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(false, false)) return;
-
- var channelIdList = new List();
- foreach (ListItem item in LbChannelId.Items)
- {
- if (item.Selected)
- {
- var channelId = int.Parse(item.Value);
- channelIdList.Add(channelId);
- }
- }
- Process(channelIdList, 0, false);
- }
-
- private bool Validate(bool isMatch, bool isChannelTemplate)
- {
- if (LbChannelId.SelectedIndex < 0)
- {
- FailMessage("请选择栏目!");
- return false;
- }
- if (isMatch)
- {
- if (isChannelTemplate)
- {
- if (LbChannelTemplateId.SelectedIndex < 0)
- {
- FailMessage("请选择栏目模板!");
- return false;
- }
- }
- else
- {
- if (LbContentTemplateId.SelectedIndex < 0)
- {
- FailMessage("请选择内容模板!");
- return false;
- }
- }
- }
- return true;
- }
-
- private void Process(List channelIdList, int templateId, bool isChannelTemplate)
- {
- if (channelIdList != null && channelIdList.Count > 0)
- {
- if (isChannelTemplate)
- {
- foreach (var channelId in channelIdList)
- {
- TemplateManager.UpdateChannelTemplateId(SiteId, channelId, templateId);
- }
- }
- else
- {
- foreach (var channelId in channelIdList)
- {
- TemplateManager.UpdateContentTemplateId(SiteId, channelId, templateId);
- }
- }
- }
-
- if (templateId == 0)
- {
- AuthRequest.AddSiteLog(SiteId, "取消模板匹配", $"栏目:{GetNodeNames()}");
- SuccessMessage("取消匹配成功!");
- }
- else
- {
- AuthRequest.AddSiteLog(SiteId, "模板匹配", $"栏目:{GetNodeNames()}");
- SuccessMessage("模板匹配成功!");
- }
-
- BindListBox();
- }
-
- private string GetNodeNames()
- {
- var builder = new StringBuilder();
- foreach (ListItem listItem in LbChannelId.Items)
- {
- if (listItem.Selected)
- {
- builder.Append(listItem.Text).Append(",");
- }
- }
-
- if (builder.Length > 0)
- {
- builder.Length = builder.Length - 1;
- }
-
- return RegexUtils.Replace("\\(.*?\\)|│|├| |└", builder.ToString(), string.Empty);
- }
-
- public void CreateChannelTemplate_Click(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(false, false)) return;
-
- var defaultChannelTemplateId = TemplateManager.GetDefaultTemplateId(SiteId, TemplateType.ChannelTemplate);
- var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, TemplateType.ChannelTemplate);
- var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, TemplateType.ChannelTemplate);
- foreach (ListItem item in LbChannelId.Items)
- {
- if (!item.Selected) continue;
-
- var channelId = int.Parse(item.Value);
- var channelTemplateId = -1;
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
- if (nodeInfo.ParentId > 0)
- {
- channelTemplateId = nodeInfo.ChannelTemplateId;
- }
-
- if (channelTemplateId != -1 && channelTemplateId != 0 && channelTemplateId != defaultChannelTemplateId)
- {
- if (TemplateManager.GetTemplateInfo(SiteId, channelTemplateId) == null)
- {
- channelTemplateId = -1;
- }
- }
-
- if (channelTemplateId != -1)
- {
- var templateInfo = new TemplateInfo(0, SiteId, nodeInfo.ChannelName, TemplateType.ChannelTemplate, "T_" + nodeInfo.ChannelName + ".html", "index.html", ".html", ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset), false);
-
- if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower()))
- {
- continue;
- }
- if (templateNameList.Contains(templateInfo.TemplateName))
- {
- continue;
- }
- var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, AuthRequest.AdminName);
- if (nodeInfo.ParentId > 0)
- {
- TemplateManager.UpdateChannelTemplateId(SiteId, channelId, insertedTemplateId);
- //DataProvider.BackgroundNodeDAO.UpdateChannelTemplateID(channelId, insertedTemplateID);
- }
-
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, "生成并匹配栏目模版", $"栏目:{GetNodeNames()}");
-
- SuccessMessage("生成栏目模版并匹配成功!");
-
- BindListBox();
- }
-
- public void CreateSubChannelTemplate_Click(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(false, false)) return;
-
- var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, TemplateType.ChannelTemplate);
- var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, TemplateType.ChannelTemplate);
- foreach (ListItem item in LbChannelId.Items)
- {
- if (!item.Selected) continue;
-
- var channelId = int.Parse(item.Value);
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
-
- var templateInfo = new TemplateInfo(0, SiteId, nodeInfo.ChannelName + "_下级", TemplateType.ChannelTemplate, "T_" + nodeInfo.ChannelName + "_下级.html", "index.html", ".html", ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset), false);
-
- if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower()))
- {
- continue;
- }
- if (templateNameList.Contains(templateInfo.TemplateName))
- {
- continue;
- }
- var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, AuthRequest.AdminName);
- var childChannelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(SiteId, channelId), EScopeType.Descendant, string.Empty, string.Empty, string.Empty);
- foreach (var childChannelId in childChannelIdList)
- {
- TemplateManager.UpdateChannelTemplateId(SiteId, childChannelId, insertedTemplateId);
- //DataProvider.BackgroundNodeDAO.UpdateChannelTemplateID(childChannelId, insertedTemplateID);
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, "生成并匹配下级栏目模版", $"栏目:{GetNodeNames()}");
-
- SuccessMessage("生成下级栏目模版并匹配成功!");
-
- BindListBox();
- }
-
- public void CreateContentTemplate_Click(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(false, false)) return;
-
- var defaultContentTemplateId = TemplateManager.GetDefaultTemplateId(SiteId, TemplateType.ContentTemplate);
- var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, TemplateType.ContentTemplate);
- var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, TemplateType.ContentTemplate);
- foreach (ListItem item in LbChannelId.Items)
- {
- if (!item.Selected) continue;
-
- var channelId = TranslateUtils.ToInt(item.Value);
-
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
-
- var contentTemplateId = nodeInfo.ContentTemplateId;
-
- if (contentTemplateId != 0 && contentTemplateId != defaultContentTemplateId)
- {
- if (TemplateManager.GetTemplateInfo(SiteId, contentTemplateId) == null)
- {
- contentTemplateId = -1;
- }
- }
-
- if (contentTemplateId != -1)
- {
- var templateInfo = new TemplateInfo(0, SiteId, nodeInfo.ChannelName, TemplateType.ContentTemplate, "T_" + nodeInfo.ChannelName + ".html", "index.html", ".html", ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset), false);
- if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower()))
- {
- continue;
- }
- if (templateNameList.Contains(templateInfo.TemplateName))
- {
- continue;
- }
- var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, AuthRequest.AdminName);
- TemplateManager.UpdateContentTemplateId(SiteId, channelId, insertedTemplateId);
- //DataProvider.BackgroundNodeDAO.UpdateContentTemplateID(channelId, insertedTemplateID);
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, "生成并匹配内容模版", $"栏目:{GetNodeNames()}");
-
- SuccessMessage("生成内容模版并匹配成功!");
-
- BindListBox();
- }
-
- public void CreateSubContentTemplate_Click(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid || !Validate(false, false)) return;
-
- var relatedFileNameList = DataProvider.TemplateDao.GetLowerRelatedFileNameList(SiteId, TemplateType.ContentTemplate);
- var templateNameList = DataProvider.TemplateDao.GetTemplateNameList(SiteId, TemplateType.ContentTemplate);
- foreach (ListItem item in LbChannelId.Items)
- {
- if (!item.Selected) continue;
-
- var channelId = int.Parse(item.Value);
- var nodeInfo = ChannelManager.GetChannelInfo(SiteId, channelId);
-
- var templateInfo = new TemplateInfo(0, SiteId, nodeInfo.ChannelName + "_下级", TemplateType.ContentTemplate, "T_" + nodeInfo.ChannelName + "_下级.html", "index.html", ".html", ECharsetUtils.GetEnumType(SiteInfo.Additional.Charset), false);
-
- if (relatedFileNameList.Contains(templateInfo.RelatedFileName.ToLower()))
- {
- continue;
- }
- if (templateNameList.Contains(templateInfo.TemplateName))
- {
- continue;
- }
- var insertedTemplateId = DataProvider.TemplateDao.Insert(templateInfo, string.Empty, AuthRequest.AdminName);
- var childChannelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(SiteId, channelId), EScopeType.Descendant, string.Empty, string.Empty, string.Empty);
- foreach (var childChannelId in childChannelIdList)
- {
- TemplateManager.UpdateContentTemplateId(SiteId, childChannelId, insertedTemplateId);
- //DataProvider.BackgroundNodeDAO.UpdateContentTemplateID(childChannelId, insertedTemplateID);
- }
- }
-
- AuthRequest.AddSiteLog(SiteId, "生成并匹配下级内容模版", $"栏目:{GetNodeNames()}");
-
- SuccessMessage("生成下级内容模版并匹配成功!");
-
- BindListBox();
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Cms/PageTemplateReference.cs b/SiteServer.BackgroundPages/Cms/PageTemplateReference.cs
deleted file mode 100644
index b71a2e2d5..000000000
--- a/SiteServer.BackgroundPages/Cms/PageTemplateReference.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System;
-using System.Reflection;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-using SiteServer.CMS.StlParser.Model;
-
-namespace SiteServer.BackgroundPages.Cms
-{
- public class PageTemplateReference : BasePageCms
- {
- public Literal LtlElements;
- public Literal LtlAttributes;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifySitePermissions(ConfigManager.WebSitePermissions.Template);
-
- // var elementsDictionary = StlAll.StlElements.GetElementsNameDictionary();
- var elements = StlAll.Elements;
-
- var liBuilder = new StringBuilder();
- var contentBuilder = new StringBuilder();
- foreach (var elementName in elements.Keys)
- {
- var elementType = elements[elementName];
-
- var htmlId = elementName.Replace(":", "-");
- liBuilder.Append($@"
-
- {elementName}
-
- ");
-
- var attrBuilder = new StringBuilder();
-
- var fields = elementType.GetFields(BindingFlags.Static | BindingFlags.NonPublic);
- foreach (var field in fields)
- {
- var attr = field.GetValue(null) as Attr;
- if (attr != null)
- {
- attrBuilder.Append($@"
- {attr.Name}
- {AttrUtils.GetAttrTypeText(attr.Type, attr.GetEnums(elementType, SiteId))}
- {attr.Description}
- ");
- }
- }
-
- var helpUrl = StringUtils.Constants.GetStlUrl(false, elementName);
-
- var stlAttribute = (StlClassAttribute) Attribute.GetCustomAttribute(elementType, typeof(StlClassAttribute));
-
- contentBuilder.Append($@"
-
- <{elementName}> {stlAttribute.Usage}
-
-
- {stlAttribute.Description}
- 详细使用说明
-
-
-
-
-
-
-
- 属性
- 取值
- 简介
-
-
-
- {attrBuilder}
-
-
-
-
-
-
-");
- }
- LtlElements.Text = liBuilder.ToString();
- LtlAttributes.Text = contentBuilder.ToString();
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Controls/Alerts.cs b/SiteServer.BackgroundPages/Controls/Alerts.cs
deleted file mode 100644
index 39a1269c4..000000000
--- a/SiteServer.BackgroundPages/Controls/Alerts.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Web.UI;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Controls
-{
- public class Alerts : Control
- {
- public bool IsShowImmidiatary { get; set; }
-
- public MessageUtils.Message.EMessageType MessageType { get; set; } = MessageUtils.Message.EMessageType.None;
-
- public string Content { get; set; } = string.Empty;
-
- public string Text
- {
- get
- {
- var state = ViewState["Text"];
- if (state != null)
- {
- return (string)state;
- }
- return string.Empty;
- }
- set
- {
- ViewState["Text"] = value;
- }
- }
-
- protected override void Render(HtmlTextWriter writer)
- {
- writer.Write(IsShowImmidiatary
- ? MessageUtils.GetAlertHtml(MessageType, Content, this)
- : MessageUtils.GetAlertHtml(this, Text));
-
- writer.Write(@"× 提示!
");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Controls/AuxiliaryControl.cs b/SiteServer.BackgroundPages/Controls/AuxiliaryControl.cs
deleted file mode 100644
index d860827af..000000000
--- a/SiteServer.BackgroundPages/Controls/AuxiliaryControl.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Plugin;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Controls
-{
- public class AuxiliaryControl : Control
- {
- public IAttributes Attributes { get; set; }
-
- public SiteInfo SiteInfo { get; set; }
-
- public int ChannelId { get; set; }
-
- public List StyleInfoList { get; set; }
-
- protected override void Render(HtmlTextWriter output)
- {
- if (StyleInfoList == null || StyleInfoList.Count == 0 || Attributes == null) return;
-
- var pageScripts = new NameValueCollection();
-
- var builder = new StringBuilder();
- foreach (var styleInfo in StyleInfoList)
- {
- string extra;
- var value = BackgroundInputTypeParser.Parse(SiteInfo, ChannelId, styleInfo, Attributes, pageScripts, out extra);
-
- if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra)) continue;
-
- if (styleInfo.InputType == InputType.TextEditor)
- {
- var commands = WebUtils.GetTextEditorCommands(SiteInfo, styleInfo.AttributeName);
- builder.Append($@"
-
-
{styleInfo.DisplayName}
-
- {commands}
-
- {value}
-
-
-
- {extra}
-
-
");
- }
- else
- {
- var html = $@"
-
-
{styleInfo.DisplayName}
-
- {value}
-
-
- {extra}
-
-
";
-
- if (styleInfo.InputType == InputType.Customize)
- {
- var eventArgs = new ContentFormLoadEventArgs(SiteInfo.Id, ChannelId, styleInfo.AttributeName, Attributes);
- foreach (var service in PluginManager.Services)
- {
- try
- {
- var serviceReturnedHtml = service.OnContentFormLoad(eventArgs);
- if (!string.IsNullOrEmpty(serviceReturnedHtml))
- {
- html = serviceReturnedHtml;
- }
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormLoad));
- }
- }
- }
-
- builder.Append(html);
- }
- }
-
- output.Write(builder.ToString());
-
- foreach (string key in pageScripts.Keys)
- {
- output.Write(pageScripts[key]);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Controls/Message.cs b/SiteServer.BackgroundPages/Controls/Message.cs
deleted file mode 100644
index ed3f569c5..000000000
--- a/SiteServer.BackgroundPages/Controls/Message.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System.Web.UI;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Controls
-{
- public class Message : Control
- {
- private bool isShowImmidiatary = false;
- public bool IsShowImmidiatary
- {
- get { return isShowImmidiatary; }
- set { isShowImmidiatary = value; }
- }
-
- private MessageUtils.Message.EMessageType messageType = MessageUtils.Message.EMessageType.None;
- public MessageUtils.Message.EMessageType MessageType
- {
- get { return messageType; }
- set { messageType = value; }
- }
-
- private string content = string.Empty;
- public string Content
- {
- get { return content; }
- set { content = value; }
- }
-
- protected override void Render(HtmlTextWriter writer)
- {
- if (isShowImmidiatary) // 有直接显示的消息
- {
- writer.Write(MessageUtils.GetMessageHtml(messageType, content, this));
- }
- else // 没有直接显示的消息则去cookies中检查是否有消息需要显示
- {
- writer.Write(MessageUtils.GetMessageHtml(this));
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Controls/NavigationTree.cs b/SiteServer.BackgroundPages/Controls/NavigationTree.cs
deleted file mode 100644
index 159973049..000000000
--- a/SiteServer.BackgroundPages/Controls/NavigationTree.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI;
-using SiteServer.BackgroundPages.Plugins;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Controls
-{
- public class NavigationTree : Control
- {
- public int SiteId { get; set; }
-
- public string TopId { get; set; }
-
- public string Title { get; set; }
-
- public List PermissionList { get; set; }
-
- protected override void Render(HtmlTextWriter writer)
- {
- var builder = new StringBuilder();
- var tabList = TabManager.GetTabList(TopId, SiteId);
- if (tabList != null && tabList.Count > 0)
- {
- var linkHtml = string.Empty;
- if (string.IsNullOrEmpty(TopId) && PermissionList.Contains(ConfigManager.PluginsPermissions.Management))
- {
- linkHtml = $@" ";
- }
- builder.Append($@"{Title}{linkHtml} ");
- BuildNavigationTree(builder, tabList, 0, true);
- }
- writer.Write(builder);
- }
-
- protected void BuildNavigationTree(StringBuilder builder, List tabs, int parentsCount, bool isDisplay)
- {
- if (tabs == null) return;
-
- foreach (var parent in tabs)
- {
- if (!TabManager.IsValid(parent, PermissionList)) continue;
-
- var childBuilder = new StringBuilder();
- if (parent.Children != null && parent.Children.Length > 0)
- {
- var tabCollection = new TabCollection(parent.Children);
- if (tabCollection.Tabs != null && tabCollection.Tabs.Length > 0)
- {
- foreach (var childTab in tabCollection.Tabs)
- {
- if (!TabManager.IsValid(childTab, PermissionList)) continue;
-
- var href = childTab.Href;
- if (!PageUtils.IsAbsoluteUrl(href))
- {
- href = PageUtils.AddQueryString(href,
- new NameValueCollection { { "siteId", SiteId.ToString() } });
- }
- href = childTab.HasHref ? PageUtils.GetLoadingUrl(href) : "javascript:;";
-
- childBuilder.Append($@"
-
-
-
- {childTab.Text}
-
- ");
- }
- }
- }
-
- if (childBuilder.Length > 0)
- {
- builder.Append($@"
-
-
-
- {parent.Text}
-
-
-
-
-");
- }
- else
- {
- var href = parent.Href;
- if (!PageUtils.IsAbsoluteUrl(href))
- {
- href = PageUtils.AddQueryString(href,
- new NameValueCollection {{"siteId", SiteId.ToString()}});
- }
- href = parent.HasHref ? PageUtils.GetLoadingUrl(href) : "javascript:;";
- builder.Append($@"
-
-
-
- {parent.Text}
-
- ");
- }
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Controls/SqlCountPager.cs b/SiteServer.BackgroundPages/Controls/SqlCountPager.cs
deleted file mode 100644
index e4b1b003e..000000000
--- a/SiteServer.BackgroundPages/Controls/SqlCountPager.cs
+++ /dev/null
@@ -1,864 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using System.Data;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Controls
-{
- [DefaultProperty("SelectCommand")]
- [DefaultEvent("PageIndexChanged")]
- [ToolboxData("<{0}:SqlCountPager runat=\"server\" />")]
- public class SqlCountPager : Table, INamingContainer
- {
- private PagedDataSource _dataSource;
- private Control _controlToPaginate;
- private string CacheKeyName => Page.Request.FilePath + "_" + UniqueID + "_Data";
- public const string ParmPage = "page";
-
-// private string GetQueryPageCommandText(int recsToRetrieve)
-// {
-// if (!string.IsNullOrEmpty(OrderByString))
-// {
-// var orderByString2 = OrderByString.Replace(" DESC", " DESC2");
-// orderByString2 = orderByString2.Replace(" ASC", " DESC");
-// orderByString2 = orderByString2.Replace(" DESC2", " ASC");
-
-// if (WebConfigUtils.DatabaseType == EDatabaseType.MySql)
-// {
-// return $@"
-//SELECT * FROM (
-// SELECT * FROM (
-// SELECT * FROM ({SelectCommand}) AS t0 {OrderByString} LIMIT {ItemsPerPage * (CurrentPageIndex + 1)}
-// ) AS t1 {orderByString2} LIMIT {recsToRetrieve}
-//) AS t2 {OrderByString}";
-// }
-// else
-// {
-// return $@"
-//SELECT * FROM (
-// SELECT TOP {recsToRetrieve} * FROM (
-// SELECT TOP {ItemsPerPage * (CurrentPageIndex + 1)} * FROM ({SelectCommand}) AS t0 {OrderByString}
-// ) AS t1 {orderByString2}
-//) AS t2 {OrderByString}";
-// }
-// }
-// else
-// {
-// if (WebConfigUtils.DatabaseType == EDatabaseType.MySql)
-// {
-// return $@"
-//SELECT * FROM (
-// SELECT * FROM (
-// SELECT * FROM ({SelectCommand}) AS t0 ORDER BY {SortField} {SortMode} LIMIT {ItemsPerPage * (CurrentPageIndex + 1)}
-// ) AS t1 ORDER BY {SortField} {AlterSortMode(SortMode)} LIMIT {recsToRetrieve}
-//) AS t2 ORDER BY {SortField} {SortMode}";
-// }
-// else
-// {
-// return $@"
-//SELECT * FROM (
-// SELECT TOP {recsToRetrieve} * FROM (
-// SELECT TOP {ItemsPerPage * (CurrentPageIndex + 1)} * FROM ({SelectCommand}) AS t0 ORDER BY {SortField} {SortMode}
-// ) AS t1 ORDER BY {SortField} {AlterSortMode(SortMode)}
-//) AS t2 ORDER BY {SortField} {SortMode}";
-// }
-// }
-// }
-
- public SqlCountPager()
- {
- _dataSource = null;
- _controlToPaginate = null;
-
- PagingMode = PagingMode.NonCached;
- PagerStyle = PagerStyle.NextPrev;
- CurrentPageIndex = 0;
- SelectCommand = "";
- ItemsPerPage = 10;
- TotalPages = -1;
- CacheDuration = 60;
- SortMode = SortMode.DESC;
- }
-
- ///
- /// Removes any data cached for paging
- ///
- public void ClearCache()
- {
- if (PagingMode == PagingMode.Cached)
- Page.Cache.Remove(CacheKeyName);
- }
-
- [Description("Gets and sets for how many seconds the data should stay in the cache")]
- public int CacheDuration
- {
- get { return Convert.ToInt32(ViewState["CacheDuration"]); }
- set { ViewState["CacheDuration"] = value; }
- }
-
- [Description("Indicates whether the data are retrieved page by page or can be cached")]
- public PagingMode PagingMode
- {
- get { return (PagingMode)ViewState["PagingMode"]; }
- set { ViewState["PagingMode"] = value; }
- }
-
- [Description("Indicates the style of the pager's navigation bar")]
- public PagerStyle PagerStyle
- {
- get { return (PagerStyle)ViewState["PagerStyle"]; }
- set { ViewState["PagerStyle"] = value; }
- }
-
- [Description("Gets and sets the name of the control to paginate")]
- public Control ControlToPaginate
- {
- get { return _controlToPaginate; }
- set { _controlToPaginate = value; }
- }
-
- [Description("Gets and sets the number of items to display per page")]
- public int ItemsPerPage
- {
- get { return Convert.ToInt32(ViewState["ItemsPerPage"]); }
- set { ViewState["ItemsPerPage"] = value; }
- }
-
- [Description("Gets and sets the index of the currently displayed page")]
- public int CurrentPageIndex
- {
- get { return Convert.ToInt32(ViewState["CurrentPageIndex"]); }
- set { ViewState["CurrentPageIndex"] = value; }
- }
-
- [Description("Gets and sets the SQL query to get data")]
- public string SelectCommand
- {
- get { return Convert.ToString(ViewState["SelectCommand"]); }
- set { ViewState["SelectCommand"] = value; }
- }
-
- public string OrderByString
- {
- get { return Convert.ToString(ViewState["OrderByString"]); }
- set { ViewState["OrderByString"] = value; }
- }
-
- [Description("Gets and sets the sort-by field. It is mandatory in NonCached mode.)")]
- public string SortField
- {
- get { return Convert.ToString(ViewState["SortKeyField"]); }
- set { ViewState["SortKeyField"] = value; }
- }
-
- [Description("Gets and sets the Unit.)")]
- public string Unit
- {
- get { return Convert.ToString(ViewState["Unit"]); }
- set { ViewState["Unit"] = value; }
- }
-
- [Description("取得设置排序模式")]
- public SortMode SortMode
- {
- get { return (SortMode)ViewState["SortMode"]; }
- set { ViewState["SortMode"] = value; }
- }
-
- public string FirstText
- {
- get
- {
- var text = ViewState["FirstText"] as string;
- if (string.IsNullOrEmpty(text))
- {
- text = "首页";
- }
- return text;
- }
- set { ViewState["FirstText"] = value; }
- }
-
- public string LastText
- {
- get
- {
- var text = ViewState["LastText"] as string;
- if (string.IsNullOrEmpty(text))
- {
- text = "末页";
- }
- return text;
- }
- set { ViewState["LastText"] = value; }
- }
-
- public string PrevText
- {
- get
- {
- var text = ViewState["PrevText"] as string;
- if (string.IsNullOrEmpty(text))
- {
- text = "上一页";
- }
- return text;
- }
- set { ViewState["PrevText"] = value; }
- }
-
- public string NextText
- {
- get
- {
- var text = ViewState["NextText"] as string;
- if (string.IsNullOrEmpty(text))
- {
- text = "下一页";
- }
- return text;
- }
- set { ViewState["NextText"] = value; }
- }
-
- public string CurrentPageText
- {
- get { return ViewState["CurrentPageText"] as string; }
- set { ViewState["CurrentPageText"] = value; }
- }
-
- public string EnabledCssClass
- {
- get { return ViewState["EnabledCssClass"] as string; }
- set { ViewState["EnabledCssClass"] = value; }
- }
-
- public new string DisabledCssClass
- {
- get { return ViewState["DisabledCssClass"] as string; }
- set { ViewState["DisabledCssClass"] = value; }
- }
-
- public string TextCssClass
- {
- get { return ViewState["TextCssClass"] as string; }
- set { ViewState["TextCssClass"] = value; }
- }
-
- ///
- /// Gets the number of displayable pages
- ///
- [Browsable(false)]
- public int PageCount => TotalPages;
-
- ///
- /// Gets and sets the number of pages to display
- ///
- protected int TotalPages
- {
- get { return Convert.ToInt32(ViewState["TotalPages"]); }
- set { ViewState["TotalPages"] = value; }
- }
-
- ///
- /// Gets and sets the number of pages to display
- ///
- public int TotalCount
- {
- get { return Convert.ToInt32(ViewState["TotalCount"]); }
- set { ViewState["TotalCount"] = value; }
- }
-
- ///
- /// Fetches and stores the data
- ///
- public override void DataBind()
- {
- CurrentPageIndex = TranslateUtils.ToInt(Page.Request.QueryString[ParmPage], 1) - 1;
-
- base.DataBind();
-
- // Controls must be recreated after data binding
- ChildControlsCreated = false;
-
- // Ensures the control exists and is a list control
- if (_controlToPaginate == null)
- return;
- if (!(_controlToPaginate is BaseDataList || _controlToPaginate is Repeater || _controlToPaginate is ListControl))
- return;
-
- // Ensures enough info to connect and query is specified
- if (SelectCommand == "")
- return;
-
- // Fetch data
- if (PagingMode == PagingMode.Cached)
- {
- FetchAllData();
- }
- else
- {
- FetchPageData();
- }
-
- // Bind data to the buddy control
- if (_controlToPaginate is BaseDataList)
- {
- var baseDataListControl = (BaseDataList)_controlToPaginate;
- baseDataListControl.DataSource = _dataSource;
- baseDataListControl.DataBind();
- }
- else if (_controlToPaginate is Repeater)
- {
- var baseRepeaterControl = (Repeater)_controlToPaginate;
- baseRepeaterControl.DataSource = _dataSource;
- baseRepeaterControl.DataBind();
- }
- else if (_controlToPaginate is ListControl)
- {
- var listControl = (ListControl)_controlToPaginate;
- listControl.Items.Clear();
- listControl.DataSource = _dataSource;
- listControl.DataBind();
- }
- }
-
- ///
- /// Writes the content to be rendered on the client
- ///
- protected override void Render(HtmlTextWriter output)
- {
- // If in design-mode ensure that child controls have been created.
- // Child controls are not created at this time in design-mode because
- // there's no pre-render stage. Do so for composite controls like this
- if (Site != null && Site.DesignMode)
- CreateChildControls();
-
- base.Render(output);
- }
-
- ///
- /// Outputs the HTML markup for the control
- ///
- protected override void CreateChildControls()
- {
- Controls.Clear();
- ClearChildViewState();
-
- BuildControlHierarchy();
- }
-
- ///
- /// Control the building of the control's hierarchy
- ///
- private void BuildControlHierarchy()
- {
- if (TotalPages > 1)
- {
- // Build the surrounding table (one row, two cells)
-
- // Build the table row
- var row = new TableRow {Height = 25};
- Rows.Add(row);
- //t.Rows.Add(row);
-
- // Build the cell with navigation bar
- var cellNavBar = new TableCell {VerticalAlign = VerticalAlign.Middle};
- if (PagerStyle == PagerStyle.NextPrev)
- {
- BuildNextPrevUi(cellNavBar);
- row.Cells.Add(cellNavBar);
- // Build the cell with the page index
- var cellPageDesc = new TableCell();
- if (!string.IsNullOrEmpty(TextCssClass))
- {
- cellPageDesc.CssClass = TextCssClass;
- }
- cellPageDesc.HorizontalAlign = HorizontalAlign.Right;
- cellPageDesc.VerticalAlign = VerticalAlign.Top;
- BuildCurrentPage(cellPageDesc);
- row.Cells.Add(cellPageDesc);
- }
- else
- {
- row.Cells.Add(cellNavBar);
- }
- }
- }
-
- private string GetNavigationUrl(int page)
- {
- var queryString = new NameValueCollection(Page.Request.QueryString);
- if (page > 1)
- {
- queryString[ParmPage] = page.ToString();
- }
- else
- {
- queryString.Remove(ParmPage);
- }
- return PageUtils.AddQueryString(PageUtils.GetUrlWithoutQueryString(Page.Request.RawUrl), queryString);
- }
-
- ///
- /// Generates the HTML markup for the Next/Prev navigation bar
- ///
- ///
- private void BuildNextPrevUi(TableCell cell)
- {
- var isValidPage = (CurrentPageIndex >= 0 && CurrentPageIndex <= TotalPages - 1);
- var canMoveBack = (CurrentPageIndex > 0);
- var canMoveForward = (CurrentPageIndex < TotalPages - 1);
-
- // 首页
- var enabled = isValidPage && canMoveBack;
- var firstImage = new Image {ToolTip = FirstText};
- var firstText = new Label {Text = FirstText};
-
- if (enabled)
- {
- firstImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.First);
-
- var link = new HyperLink();
- link.Style.Add("text-decoration", "none");
- link.NavigateUrl = GetNavigationUrl(1);
- if (!string.IsNullOrEmpty(EnabledCssClass))
- {
- link.CssClass = EnabledCssClass;
- }
- link.Controls.Add(firstImage);
- link.Controls.Add(new LiteralControl(" "));
- link.Controls.Add(firstText);
- cell.Controls.Add(link);
- }
- else
- {
- firstImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.FirstDisabled);
- cell.Controls.Add(firstImage);
- cell.Controls.Add(new LiteralControl(" "));
- if (!string.IsNullOrEmpty(DisabledCssClass))
- {
- firstText.CssClass = DisabledCssClass;
- }
- else
- {
- firstText.Style.Add("color", "gray");
- }
- cell.Controls.Add(firstText);
- }
-
- cell.Controls.Add(new LiteralControl(" "));
-
- // 上一页
- var prevImage = new Image {ToolTip = PrevText};
- var prevText = new Label {Text = PrevText};
-
- if (enabled)
- {
- prevImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.Previous);
-
- var link = new HyperLink();
- link.Style.Add("text-decoration", "none");
- link.NavigateUrl = GetNavigationUrl(CurrentPageIndex);
- if (!string.IsNullOrEmpty(EnabledCssClass))
- {
- link.CssClass = EnabledCssClass;
- }
- link.Controls.Add(prevImage);
- link.Controls.Add(new LiteralControl(" "));
- link.Controls.Add(prevText);
- cell.Controls.Add(link);
- }
- else
- {
- prevImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.PreviousDisabled);
- cell.Controls.Add(prevImage);
- cell.Controls.Add(new LiteralControl(" "));
- if (!string.IsNullOrEmpty(DisabledCssClass))
- {
- prevText.CssClass = DisabledCssClass;
- }
- else
- {
- prevText.Style.Add("color", "gray");
- }
- cell.Controls.Add(prevText);
- }
-
- cell.Controls.Add(new LiteralControl(" "));
-
- // 下一页
- enabled = isValidPage && canMoveForward;
- var nextImage = new Image {ToolTip = NextText};
- var nextText = new Label {Text = NextText};
-
- if (enabled)
- {
- nextImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.Next);
-
- var link = new HyperLink();
- link.Style.Add("text-decoration", "none");
- link.NavigateUrl = GetNavigationUrl(CurrentPageIndex + 2);
- if (!string.IsNullOrEmpty(EnabledCssClass))
- {
- link.CssClass = EnabledCssClass;
- }
- link.Controls.Add(nextImage);
- link.Controls.Add(new LiteralControl(" "));
- link.Controls.Add(nextText);
- cell.Controls.Add(link);
- }
- else
- {
- nextImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.NextDisabled);
-
- cell.Controls.Add(nextImage);
- cell.Controls.Add(new LiteralControl(" "));
- if (!string.IsNullOrEmpty(DisabledCssClass))
- {
- nextText.CssClass = DisabledCssClass;
- }
- else
- {
- nextText.Style.Add("color", "gray");
- }
- cell.Controls.Add(nextText);
- }
-
- cell.Controls.Add(new LiteralControl(" "));
-
- // 末页
- var lastImage = new Image {ToolTip = LastText};
- var lastText = new Label {Text = LastText};
-
- if (enabled)
- {
- lastImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.Last);
-
- var link = new HyperLink();
- link.Style.Add("text-decoration", "none");
- link.NavigateUrl = GetNavigationUrl(TotalPages);
- if (!string.IsNullOrEmpty(EnabledCssClass))
- {
- link.CssClass = EnabledCssClass;
- }
- link.Controls.Add(lastImage);
- link.Controls.Add(new LiteralControl(" "));
- link.Controls.Add(lastText);
- cell.Controls.Add(link);
- }
- else
- {
- lastImage.ImageUrl = SiteServerAssets.GetUrl(SiteServerAssets.Arrow.LastDisabled);
-
- cell.Controls.Add(lastImage);
- cell.Controls.Add(new LiteralControl(" "));
- if (!string.IsNullOrEmpty(DisabledCssClass))
- {
- lastText.CssClass = DisabledCssClass;
- }
- else
- {
- lastText.Style.Add("color", "gray");
- }
- cell.Controls.Add(lastText);
- }
-
- //显示总记录数
- if (TotalPages > 0)
- {
-
- cell.Controls.Add(new LiteralControl(" "));
- var totalPagesText = new Label();
- lastText.Text = $@" ( 共{TotalCount}条 )";
- cell.Controls.Add(totalPagesText);
- }
- }
-
- // ***********************************************************************
-
- ///
- /// Generates the HTML markup to describe the current page (0-based)
- ///
- private void BuildCurrentPage(TableCell cell)
- {
- var text = new NoTagText
- {
- ID = "Text",
- Text = CurrentPageText
- };
- cell.Controls.Add(text);
- // Render a drop-down list
- var pageList = new DropDownList
- {
- ID = "PageList",
- AutoPostBack = true
- };
- pageList.SelectedIndexChanged += PageList_Click;
- pageList.Font.Name = Font.Name;
- pageList.Font.Size = Font.Size;
- pageList.ForeColor = ForeColor;
- pageList.CssClass = "input-medium";
-
- // Embellish the list when there are no pages to list
- if (TotalPages <= 0 || CurrentPageIndex == -1)
- {
- pageList.Items.Add("1 / 1");
- pageList.Enabled = false;
- pageList.SelectedIndex = 0;
- }
- else // Populate the list
- {
- for (var i = 1; i <= TotalPages; i++)
- {
- var item = new ListItem($"{i} / {TotalPages}", (i - 1).ToString());
- pageList.Items.Add(item);
- }
- pageList.SelectedIndex = CurrentPageIndex;
- }
- cell.CssClass = "align-right";
- cell.Controls.Add(pageList);
- }
-
- ///
- /// Ensures the CurrentPageIndex is either valid [0,TotalPages)
- ///
- private void ValidatePageIndex()
- {
- if (CurrentPageIndex < 0)
- {
- CurrentPageIndex = 0;
- }
- else if (CurrentPageIndex > TotalPages - 1)
- {
- CurrentPageIndex = TotalPages - 1;
- }
- }
-
- ///
- /// Runs the query for all data to be paged and caches the resulting data
- ///
- private void FetchAllData()
- {
- // Looks for data in the ASP.NET Cache
- var data = (DataTable)Page.Cache[CacheKeyName];
- if (data == null)
- {
- // Fix SelectCommand with order-by info
- AdjustSelectCommand(true);
-
- // If data expired or has never been fetched, go to the database
- //SqlDataAdapter adapter = new SqlDataAdapter(SelectCommand, ConnectionString);
- var adapter = SqlUtils.GetIDbDataAdapter(SelectCommand, WebConfigUtils.ConnectionString);
- data = new DataTable();
- //adapter.Fill(data);
- SqlUtils.FillDataAdapterWithDataTable(adapter, data);
- Page.Cache.Insert(CacheKeyName, data, null,
- DateTime.Now.AddSeconds(CacheDuration),
- System.Web.Caching.Cache.NoSlidingExpiration);
- }
-
- // Configures the paged data source component
- if (_dataSource == null)
- _dataSource = new PagedDataSource();
- _dataSource.DataSource = data.DefaultView; // must be IEnumerable!
- _dataSource.AllowPaging = true;
- _dataSource.PageSize = ItemsPerPage;
- TotalPages = _dataSource.PageCount;
-
- // Ensures the page index is valid
- ValidatePageIndex();
- if (CurrentPageIndex == -1)
- {
- _dataSource = null;
- return;
- }
-
- // Selects the page to view
- _dataSource.CurrentPageIndex = CurrentPageIndex;
- }
-
- ///
- /// Runs the query to get only the data that fit into the current page
- ///
- private void FetchPageData()
- {
- // Need a validated page index to fetch data.
- // Also need the virtual page count to validate the page index
- AdjustSelectCommand(false);
- var countInfo = CalculateVirtualRecordCount();
- TotalPages = countInfo.PageCount;
- TotalCount = countInfo.RecordCount;
-
- // Validate the page number (ensures CurrentPageIndex is valid or -1)
- ValidatePageIndex();
- if (CurrentPageIndex == -1)
- return;
-
- // Prepare and run the command
- var cmd = PrepareCommand(countInfo);
- if (cmd == null)
- return;
- //SqlDataAdapter adapter = new SqlDataAdapter(cmd);
- var adapter = SqlUtils.GetIDbDataAdapter();
- adapter.SelectCommand = cmd;
- var data = new DataTable();
- //adapter.Fill(data);
- SqlUtils.FillDataAdapterWithDataTable(adapter, data);
-
- // Configures the paged data source component
- if (_dataSource == null)
- _dataSource = new PagedDataSource();
- _dataSource.AllowCustomPaging = true;
- _dataSource.AllowPaging = true;
- _dataSource.CurrentPageIndex = 0;
- _dataSource.PageSize = ItemsPerPage;
- _dataSource.VirtualCount = countInfo.RecordCount;
- _dataSource.DataSource = data.DefaultView;
- }
-
- ///
- /// Strips ORDER-BY clauses from SelectCommand and adds a new one based
- /// on SortKeyField
- ///
- private void AdjustSelectCommand(bool addCustomSortInfo)
- {
- // Truncate where ORDER BY is found
- var temp = SelectCommand.ToLower();
- var pos = temp.IndexOf("order by", StringComparison.Ordinal);
- if (pos > -1)
- SelectCommand = SelectCommand.Substring(0, pos);
-
- // Add new ORDER BY info if SortKeyField is specified
- if (SortField != "" && addCustomSortInfo)
- SelectCommand += " ORDER BY " + SortField;
- }
-
- ///
- /// Calculates record and page count for the specified query
- ///
- private VirtualRecordCount CalculateVirtualRecordCount()
- {
- var count = new VirtualRecordCount
- {
- RecordCount = GetQueryVirtualCount(),
- RecordsInLastPage = ItemsPerPage
- };
-
- // Calculate the virtual number of records from the query
-
- // Calculate the correspondent number of pages
- var lastPage = count.RecordCount / ItemsPerPage;
- var remainder = count.RecordCount % ItemsPerPage;
- if (remainder > 0)
- lastPage++;
- count.PageCount = lastPage;
-
- // Calculate the number of items in the last page
- if (remainder > 0)
- count.RecordsInLastPage = remainder;
- return count;
- }
-
- ///
- /// Prepares and returns the command object for the reader-based query
- ///
- private IDbCommand PrepareCommand(VirtualRecordCount countInfo)
- {
- // Determines how many records are to be retrieved.
- // The last page could require less than other pages
- //var recsToRetrieve = ItemsPerPage;
- //if (CurrentPageIndex == countInfo.PageCount - 1)
- // recsToRetrieve = countInfo.RecordsInLastPage;
-
- //var cmdText = GetQueryPageCommandText(recsToRetrieve);
- var orderString = OrderByString;
- if (string.IsNullOrEmpty(orderString))
- {
- orderString = $"ORDER BY {SortField} {SortMode}";
- }
- var cmdText = SqlUtils.GetPageSqlString(SelectCommand, orderString, ItemsPerPage, CurrentPageIndex, PageCount, countInfo.RecordsInLastPage);
-
- var conn = SqlUtils.GetIDbConnection(WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString);
- var cmd = SqlUtils.GetIDbCommand();
- cmd.Connection = conn;
- cmd.CommandText = cmdText;
- return cmd;
- }
-
- /////
- ///// 方法 反转排序模式
- /////
- ///// 排序模式
- ///// 相反的排序模式
- //private static SortMode AlterSortMode(SortMode mode)
- //{
- // return mode == SortMode.DESC ? SortMode.ASC : SortMode.DESC;
- //}
-
- ///
- /// Run a query to get the record count
- ///
- private int GetQueryVirtualCount()
- {
- var recCount = DataProvider.DatabaseDao.GetPageTotalCount(SelectCommand);
- // SqlConnection conn = new SqlConnection(ConnectionString);
- // SqlCommand cmd = new SqlCommand(cmdText, conn);
- //IDbConnection conn = SqlUtils.GetIDbConnection(DataProvider.ADOType, ConnectionString);
- //IDbCommand cmd = SqlUtils.GetIDbCommand(DataProvider.ADOType);
- //cmd.Connection = conn;
- //cmd.CommandText = cmdText;
-
- //cmd.Connection.Open();
- //int recCount = (int)cmd.ExecuteScalar();
- //cmd.Connection.Close();
-
- return recCount;
- }
-
- ///
- /// Sets the current page index
- ///
- //private void GoToPage(int pageIndex)
- //{
- // // Prepares event data
- // PageChangedEventArgs e = new PageChangedEventArgs();
- // e.OldPageIndex = CurrentPageIndex;
- // e.NewPageIndex = pageIndex;
-
- // // Updates the current index
- // CurrentPageIndex = pageIndex;
-
- // // Fires the page changed event
- // OnPageIndexChanged(e);
-
- // // Binds new data
- // DataBind();
- //}
-
- ///
- /// Event handler for any page selected from the drop-down page list
- ///
- private void PageList_Click(object sender, EventArgs e)
- {
- var pageList = (DropDownList)sender;
- var pageIndex = Convert.ToInt32(pageList.SelectedValue);
- PageUtils.Redirect(GetNavigationUrl(pageIndex + 1));
- }
-
- /////
- ///// Event handler for any page selected from the drop-down page list
- /////
- //private void Numeric_Click(object sender, EventArgs e)
- //{
- // LinkButton linkButton = (LinkButton)sender;
- // int pageIndex = Convert.ToInt32(linkButton.CommandArgument);
- // GoToPage(pageIndex);
- //}
- }
-}
diff --git a/SiteServer.BackgroundPages/Core/ChannelLoading.cs b/SiteServer.BackgroundPages/Core/ChannelLoading.cs
deleted file mode 100644
index 0729c7dde..000000000
--- a/SiteServer.BackgroundPages/Core/ChannelLoading.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-using System;
-using System.Text;
-using SiteServer.Utils;
-using System.Collections.Specialized;
-using SiteServer.BackgroundPages.Cms;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Core
-{
- public class ChannelLoading
- {
- public static string GetChannelRowHtml(SiteInfo siteInfo, ChannelInfo nodeInfo, bool enabled, ELoadingType loadingType, NameValueCollection additional, PermissionManager permissionManager)
- {
- var nodeTreeItem = ChannelTreeItem.CreateInstance(siteInfo, nodeInfo, enabled, permissionManager);
- var title = nodeTreeItem.GetItemHtml(loadingType, PageChannel.GetRedirectUrl(siteInfo.Id, nodeInfo.Id), additional);
-
- var rowHtml = string.Empty;
-
- if (loadingType == ELoadingType.ContentTree)
- {
- rowHtml = $@"
-
- {title}
-
-";
- }
- else if (loadingType == ELoadingType.Channel)
- {
- var upLink = string.Empty;
- var downLink = string.Empty;
- var editUrl = string.Empty;
- var checkBoxHtml = string.Empty;
-
- if (enabled)
- {
- if (permissionManager.HasChannelPermissions(nodeInfo.SiteId, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelEdit))
- {
- var urlEdit = PageChannelEdit.GetRedirectUrl(nodeInfo.SiteId, nodeInfo.Id, PageChannel.GetRedirectUrl(nodeInfo.SiteId, nodeInfo.Id));
- editUrl = $"编辑 ";
- var urlSubtract = PageUtils.GetCmsUrl(nodeInfo.SiteId, nameof(PageChannel), new NameValueCollection
- {
- {"Subtract", true.ToString()},
- {"channelId", nodeInfo.Id.ToString()}
- });
- upLink =
- $@" ";
- var urlAdd = PageUtils.GetCmsUrl(nodeInfo.SiteId, nameof(PageChannel), new NameValueCollection
- {
- {"Add", true.ToString()},
- {"channelId", nodeInfo.Id.ToString()}
- });
- downLink =
- $@" ";
- }
- checkBoxHtml = $" ";
- }
-
- rowHtml = $@"
-
- {title}
- {nodeInfo.GroupNameCollection}
- {nodeInfo.IndexName}
- {upLink}
- {downLink}
- {editUrl}
- {checkBoxHtml}
-
-";
- }
- else if (loadingType == ELoadingType.SiteAnalysis)
- {
- var startDate = TranslateUtils.ToDateTime(additional["StartDate"]);
- var endDate = TranslateUtils.ToDateTime(additional["EndDate"]);
-
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- var num = DataProvider.ContentDao.GetCountOfContentAdd(tableName, siteInfo.Id, nodeInfo.Id, EScopeType.All, startDate, endDate, string.Empty, ETriState.All);
- var contentAddNum = num == 0 ? "0" : $"{num} ";
-
- num = DataProvider.ContentDao.GetCountOfContentUpdate(tableName, siteInfo.Id, nodeInfo.Id, EScopeType.All, startDate, endDate, string.Empty);
- var contentUpdateNum = num == 0 ? "0" : $"{num} ";
-
- rowHtml = $@"
-
- {title}
- {contentAddNum}
- {contentUpdateNum}
-
-";
- }
- else if (loadingType == ELoadingType.TemplateFilePathRule)
- {
- var editLink = string.Empty;
-
- if (enabled)
- {
- var showPopWinString = ModalTemplateFilePathRule.GetOpenWindowString(nodeInfo.SiteId, nodeInfo.Id);
- editLink = $"更改 ";
- }
- var filePath = PageUtility.GetInputChannelUrl(siteInfo, nodeInfo, false);
-
- rowHtml = $@"
-
- {title}
- {filePath}
- {editLink}
-
-";
- }
- else if (loadingType == ELoadingType.ConfigurationCreateDetails)
- {
- var editChannelLink = string.Empty;
-
- var nodeNames = string.Empty;
-
- if (enabled)
- {
- var showPopWinString = ModalConfigurationCreateChannel.GetOpenWindowString(nodeInfo.SiteId, nodeInfo.Id);
- editChannelLink = $"触发栏目 ";
- }
-
- if (nodeInfo.Additional.ToNameValueCollection().Count > 0)
- {
- var nodeNameBuilder = new StringBuilder();
- var channelIdList = TranslateUtils.StringCollectionToIntList(nodeInfo.Additional.CreateChannelIDsIfContentChanged);
- foreach (var theChannelId in channelIdList)
- {
- var theNodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, theChannelId);
- if (theNodeInfo != null)
- {
- nodeNameBuilder.Append(theNodeInfo.ChannelName).Append(",");
- }
- }
- if (nodeNameBuilder.Length > 0)
- {
- nodeNameBuilder.Length--;
- nodeNames = nodeNameBuilder.ToString();
- }
- }
-
- rowHtml = $@"
-
- {title}
- {nodeNames}
- {editChannelLink}
-
-";
- }
- else if (loadingType == ELoadingType.ConfigurationCrossSiteTrans)
- {
- var editLink = string.Empty;
-
- if (enabled)
- {
- var showPopWinString = ModalCrossSiteTransEdit.GetOpenWindowString(nodeInfo.SiteId, nodeInfo.Id);
- editLink = $"更改 ";
- }
-
- var contribute = CrossSiteTransUtility.GetDescription(nodeInfo.SiteId, nodeInfo);
-
- rowHtml = $@"
-
- {title}
- {contribute}
- {editLink}
-
-";
- }
- else if (loadingType == ELoadingType.ChannelSelect)
- {
- rowHtml = $@"
-
- {title}
-
-";
- }
-
- return rowHtml;
- }
-
- public static string GetScript(SiteInfo siteInfo, string contentModelPluginId, ELoadingType loadingType, NameValueCollection additional)
- {
- return ChannelTreeItem.GetScript(siteInfo, loadingType, contentModelPluginId, additional);
- }
-
- public static string GetScriptOnLoad(int siteId, int currentChannelId)
- {
- if (currentChannelId == 0 || currentChannelId == siteId) return string.Empty;
-
- var nodeInfo = ChannelManager.GetChannelInfo(siteId, currentChannelId);
- if (nodeInfo == null) return string.Empty;
-
- string path;
- if (nodeInfo.ParentId == siteId)
- {
- path = currentChannelId.ToString();
- }
- else
- {
- path = nodeInfo.ParentsPath.Substring(nodeInfo.ParentsPath.IndexOf(",", StringComparison.Ordinal) + 1) + "," + currentChannelId;
- }
- return ChannelTreeItem.GetScriptOnLoad(path);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Core/PagingMode.cs b/SiteServer.BackgroundPages/Core/PagingMode.cs
deleted file mode 100644
index 91b9f73fc..000000000
--- a/SiteServer.BackgroundPages/Core/PagingMode.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace SiteServer.BackgroundPages.Core
-{
- public enum PagingMode
- {
- Cached,
- NonCached
- }
-}
diff --git a/SiteServer.BackgroundPages/Core/TextUtility.cs b/SiteServer.BackgroundPages/Core/TextUtility.cs
deleted file mode 100644
index 2544663ca..000000000
--- a/SiteServer.BackgroundPages/Core/TextUtility.cs
+++ /dev/null
@@ -1,255 +0,0 @@
-using SiteServer.CMS.Model;
-using System.Text;
-using SiteServer.Utils;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using SiteServer.BackgroundPages.Cms;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Plugin;
-using System.Web.UI.WebControls;
-
-namespace SiteServer.BackgroundPages.Core
-{
- public class TextUtility
- {
- private TextUtility()
- {
- }
-
- private static string GetColumnValue(Dictionary nameValueCacheDict, SiteInfo siteInfo, ContentInfo contentInfo, TableStyleInfo styleInfo)
- {
- var value = string.Empty;
- if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.AddUserName))
- {
- if (!string.IsNullOrEmpty(contentInfo.AddUserName))
- {
- var key = ContentAttribute.AddUserName + ":" + contentInfo.AddUserName;
- if (!nameValueCacheDict.TryGetValue(key, out value))
- {
- value = AdminManager.GetDisplayName(contentInfo.AddUserName, false);
- nameValueCacheDict[key] = value;
- }
- }
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.LastEditUserName))
- {
- if (!string.IsNullOrEmpty(contentInfo.LastEditUserName))
- {
- var key = ContentAttribute.LastEditUserName + ":" + contentInfo.LastEditUserName;
- if (!nameValueCacheDict.TryGetValue(key, out value))
- {
- value = AdminManager.GetDisplayName(contentInfo.LastEditUserName, false);
- nameValueCacheDict[key] = value;
- }
- }
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.CheckUserName))
- {
- var checkUserName = contentInfo.GetString(ContentAttribute.CheckUserName);
- if (!string.IsNullOrEmpty(checkUserName))
- {
- var key = ContentAttribute.CheckUserName + ":" + checkUserName;
- if (!nameValueCacheDict.TryGetValue(key, out value))
- {
- value = AdminManager.GetDisplayName(checkUserName, false);
- nameValueCacheDict[key] = value;
- }
- }
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.CheckCheckDate))
- {
- var checkDate = contentInfo.GetString(ContentAttribute.CheckCheckDate);
- if (!string.IsNullOrEmpty(checkDate))
- {
- value = DateUtils.GetDateAndTimeString(TranslateUtils.ToDateTime(checkDate));
- }
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.CheckReasons))
- {
- value = contentInfo.GetString(ContentAttribute.CheckReasons);
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.AddDate))
- {
- value = DateUtils.GetDateAndTimeString(contentInfo.AddDate);
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.LastEditDate))
- {
- value = DateUtils.GetDateAndTimeString(contentInfo.LastEditDate);
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.SourceId))
- {
- value = SourceManager.GetSourceName(contentInfo.SourceId);
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.Tags))
- {
- value = contentInfo.Tags;
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.GroupNameCollection))
- {
- value = contentInfo.GroupNameCollection;
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.Hits))
- {
- value = contentInfo.Hits.ToString();
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.HitsByDay))
- {
- value = contentInfo.HitsByDay.ToString();
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.HitsByWeek))
- {
- value = contentInfo.HitsByWeek.ToString();
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.HitsByMonth))
- {
- value = contentInfo.HitsByMonth.ToString();
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.LastHitsDate))
- {
- value = DateUtils.GetDateAndTimeString(contentInfo.LastHitsDate);
- }
- else if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsTop) || StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsColor) || StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsHot) || StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.IsRecommend))
- {
- value = StringUtils.GetTrueImageHtml(contentInfo.GetString(styleInfo.AttributeName));
- }
- else
- {
- value = InputParserUtility.GetContentByTableStyle(contentInfo.GetString(styleInfo.AttributeName), siteInfo, styleInfo);
- }
- return value;
- }
-
- public static bool IsEdit(SiteInfo siteInfo, int channelId, PermissionManager permissionManager)
- {
- return permissionManager.HasChannelPermissions(siteInfo.Id, channelId, ConfigManager.ChannelPermissions.ContentEdit);
- }
-
- //public static bool IsComment(SiteInfo siteInfo, int channelId, string administratorName)
- //{
- // return siteInfo.Additional.IsCommentable && AdminUtility.HasChannelPermissions(administratorName, siteInfo.Id, channelId, ConfigManager.Permissions.Channel.CommentCheck, ConfigManager.Permissions.Channel.CommentDelete);
- //}
-
- public static string GetColumnsHeadHtml(List tableStyleInfoList, StringCollection attributesOfDisplay, SiteInfo siteInfo)
- {
- var builder = new StringBuilder();
-
- var styleInfoList = ContentUtility.GetAllTableStyleInfoList(tableStyleInfoList);
-
- foreach (var styleInfo in styleInfoList)
- {
- if (!attributesOfDisplay.Contains(styleInfo.AttributeName) || styleInfo.AttributeName == ContentAttribute.Title) continue;
- builder.Append($@"{styleInfo.DisplayName} ");
- }
-
- return builder.ToString();
- }
-
- public static string GetColumnsHtml(Dictionary nameValueCacheDict, SiteInfo siteInfo, ContentInfo contentInfo, StringCollection attributesOfDisplay, List displayStyleInfoList)
- {
- var builder = new StringBuilder();
-
- foreach (var styleInfo in displayStyleInfoList)
- {
- if (!attributesOfDisplay.Contains(styleInfo.AttributeName) || styleInfo.AttributeName == ContentAttribute.Title) continue;
-
- var value = GetColumnValue(nameValueCacheDict, siteInfo, contentInfo, styleInfo);
- builder.Append($@"{value} ");
- }
-
- return builder.ToString();
- }
-
- public static string GetCommandsHtml(SiteInfo siteInfo, Dictionary> pluginLinks, ContentInfo contentInfo, string pageUrl, string administratorName, bool isEdit)
- {
- var builder = new StringBuilder();
-
- if (isEdit || administratorName == contentInfo.AddUserName)
- {
- builder.Append($@"编辑 ");
- }
-
- //if (isComment)
- //{
- // //var urlComment = PageComment.GetRedirectUrl(siteInfo.SiteId, contentInfo.ChannelId, contentInfo.Id, pageUrl);
- // var urlComment = PageComments.GetRedirectUrl(siteInfo.Id, contentInfo.ChannelId, contentInfo.Id, pageUrl);
- // builder.Append(
- // $@"评论({contentInfo
- // .Comments}) ");
- //}
-
- if (pluginLinks != null)
- {
- foreach (var pluginId in pluginLinks.Keys)
- {
- var contentLinks = pluginLinks[pluginId];
- if (contentLinks != null && contentLinks.Count > 0)
- {
- foreach (var link in contentLinks)
- {
- var originalUrl = link.NavigateUrl;
- link.NavigateUrl = PluginMenuManager.GetMenuContentHref(pluginId, originalUrl, siteInfo.Id, contentInfo.ChannelId, contentInfo.Id, pageUrl);
-
- builder.Append(" ").Append(ControlUtils.GetControlRenderHtml(link));
-
- link.NavigateUrl = originalUrl;
-
- //builder.Append(
- // $@"{link.Text} ");
- }
- }
- }
- }
-
- return builder.ToString();
- }
-
- //public static string GetCommandItemRowsHtml(SiteInfo siteInfo, Dictionary pluginChannels, ContentInfo contentInfo, string pageUrl, string administratorName)
- //{
- // var builder = new StringBuilder();
-
- // foreach (var pluginId in pluginChannels.Keys)
- // {
- // var pluginChannel = pluginChannels[pluginId];
- // if (pluginChannel?.ContentLinks != null && pluginChannel.ContentLinks.Count > 0)
- // {
- // foreach (var link in pluginChannel.ContentLinks)
- // {
- // var href = PluginUtils.GetMenuContentHref(pluginId, link.Href,
- // siteInfo.Id, contentInfo.ChannelId, contentInfo.Id, pageUrl);
- // builder.Append(
- // $@"{link.Text} ");
- // }
- // }
- // }
-
- // //if (modelType == EContentModelType.Photo)
- // //{
- // // var contentPhotoUploadUrl = PageContentPhotoUpload.GetRedirectUrl(siteInfo.Id, contentInfo.ChannelId, contentInfo.Id, pageUrl);
- // // builder.Append(
- // // $@"图片 ({contentInfo
- // // .Photos}) ");
- // //}
- // //else if (modelType == EContentModelType.Job)
- // //{
- // // var resumeNum = DataProvider.ResumeContentDao.GetCount(siteInfo.Id, contentInfo.Id);
- // // var urlResume = PageResumeContent.GetRedirectUrl(siteInfo.Id, contentInfo.Id, StringUtils.ValueToUrl(pageUrl));;
- // // builder.Append(
- // // $@"简历 ({resumeNum}) ");
- // //}
-
- // if (siteInfo.Additional.IsCommentable)
- // {
- // if (AdminUtility.HasChannelPermissions(administratorName, siteInfo.Id, contentInfo.ChannelId, ConfigManager.Permissions.Channel.CommentCheck, ConfigManager.Permissions.Channel.CommentDelete))
- // {
- // //var urlComment = PageComment.GetRedirectUrl(siteInfo.SiteId, contentInfo.ChannelId, contentInfo.Id, pageUrl);
- // var urlComment = PageComments.GetRedirectUrl(siteInfo.Id, contentInfo.ChannelId, contentInfo.Id, pageUrl);
- // builder.Append(
- // $@"评论 ({contentInfo
- // .Comments}) ");
- // }
- // }
-
- // return builder.ToString();
- //}
- }
-}
diff --git a/SiteServer.BackgroundPages/Core/WebUtils.cs b/SiteServer.BackgroundPages/Core/WebUtils.cs
deleted file mode 100644
index c677ce4b4..000000000
--- a/SiteServer.BackgroundPages/Core/WebUtils.cs
+++ /dev/null
@@ -1,503 +0,0 @@
-using System.Text;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Ajax;
-using SiteServer.BackgroundPages.Cms;
-using SiteServer.BackgroundPages.Settings;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Core
-{
- public class WebUtils
- {
- public static string GetContentTitle(SiteInfo siteInfo, ContentInfo contentInfo, string pageUrl)
- {
- string url;
- var title = ContentUtility.FormatTitle(contentInfo.GetString(BackgroundContentAttribute.TitleFormatString), contentInfo.Title);
-
- var displayString = contentInfo.IsColor ? $"{title} " : title;
-
- if (contentInfo.ChannelId < 0)
- {
- url = displayString;
- }
- else if (contentInfo.IsChecked)
- {
- url =
- $"{displayString} ";
- }
- else
- {
- url =
- $"{displayString} ";
- }
-
- var image = string.Empty;
- if (contentInfo.IsRecommend)
- {
- image += " ";
- }
- if (contentInfo.IsHot)
- {
- image += " ";
- }
- if (contentInfo.IsTop)
- {
- image += " ";
- }
- if (contentInfo.ReferenceId > 0)
- {
- if (contentInfo.GetString(ContentAttribute.TranslateContentType) == ETranslateContentType.ReferenceContent.ToString())
- {
- image += " (引用内容)";
- }
- else if (contentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
- {
- image += " (引用地址)";
- }
- }
- if (!string.IsNullOrEmpty(contentInfo.GetString(ContentAttribute.LinkUrl)))
- {
- image += " ";
- }
- if (!string.IsNullOrEmpty(contentInfo.GetString(BackgroundContentAttribute.ImageUrl)))
- {
- var imageUrl = PageUtility.ParseNavigationUrl(siteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), true);
- var openWindowString = ModalMessage.GetOpenWindowString(siteInfo.Id, "预览图片", $" ", 500, 500);
- image +=
- $@" ";
- }
- if (!string.IsNullOrEmpty(contentInfo.GetString(BackgroundContentAttribute.VideoUrl)))
- {
- var openWindowString = ModalMessage.GetOpenWindowStringToPreviewVideoByUrl(siteInfo.Id, contentInfo.GetString(BackgroundContentAttribute.VideoUrl));
- image +=
- $@" ";
- }
- if (!string.IsNullOrEmpty(contentInfo.GetString(BackgroundContentAttribute.FileUrl)))
- {
- image += " ";
- if (siteInfo.Additional.IsCountDownload)
- {
- var count = CountManager.GetCount(siteInfo.TableName, contentInfo.Id.ToString(), ECountType.Download);
- image += $"下载次数:{count} ";
- }
- }
- if (!string.IsNullOrEmpty(contentInfo.WritingUserName))
- {
- var openWindowString = ModalUserView.GetOpenWindowString(contentInfo.WritingUserName);
- image +=
- $@" (投稿用户:{contentInfo.WritingUserName} )";
- }
- return url + image;
- }
-
- public static string GetChannelListBoxTitle(int siteId, int channelId, string nodeName, int parentsCount, bool isLastNode, bool[] isLastNodeArray)
- {
- var str = string.Empty;
- if (channelId == siteId)
- {
- isLastNode = true;
- }
- if (isLastNode == false)
- {
- isLastNodeArray[parentsCount] = false;
- }
- else
- {
- isLastNodeArray[parentsCount] = true;
- }
- for (var i = 0; i < parentsCount; i++)
- {
- str = string.Concat(str, isLastNodeArray[i] ? " " : "│");
- }
- str = string.Concat(str, isLastNode ? "└" : "├");
- str = string.Concat(str, StringUtils.MaxLengthText(nodeName, 8));
-
- return str;
- }
-
- public static string GetContentAddUploadWordUrl(int siteId, ChannelInfo nodeInfo, bool isFirstLineTitle, bool isFirstLineRemove, bool isClearFormat, bool isFirstLineIndent, bool isClearFontSize, bool isClearFontFamily, bool isClearImages, int contentLevel, string fileName, string returnUrl)
- {
- return
- $"{PageContentAdd.GetRedirectUrlOfAdd(siteId, nodeInfo.Id, returnUrl)}&isUploadWord=True&isFirstLineTitle={isFirstLineTitle}&isFirstLineRemove={isFirstLineRemove}&isClearFormat={isClearFormat}&isFirstLineIndent={isFirstLineIndent}&isClearFontSize={isClearFontSize}&isClearFontFamily={isClearFontFamily}&isClearImages={isClearImages}&contentLevel={contentLevel}&fileName={fileName}";
- }
-
- public static string GetContentAddAddUrl(int siteId, ChannelInfo nodeInfo, string returnUrl)
- {
- return PageContentAdd.GetRedirectUrlOfAdd(siteId, nodeInfo.Id, returnUrl);
- }
-
- public static string GetContentAddEditUrl(int siteId, ChannelInfo nodeInfo, int id, string returnUrl)
- {
- return PageContentAdd.GetRedirectUrlOfEdit(siteId, nodeInfo.Id, id, returnUrl);
- }
-
- public static string GetContentCommands(PermissionManager permissionManager, SiteInfo siteInfo, ChannelInfo nodeInfo, string pageUrl)
- {
- var builder = new StringBuilder();
-
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentAdd) && nodeInfo.Additional.IsContentAddable)
- {
- builder.Append($@"
-
-
- 添加
- ");
-
- builder.Append($@"
-
- 导入Word
- ");
- }
-
- if (nodeInfo.ContentNum > 0 && permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentDelete))
- {
- builder.Append($@"
-
-
- 删 除
- ");
- }
-
- if (nodeInfo.ContentNum > 0)
- {
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentEdit))
- {
- builder.Append($@"
-
-
- 属性
- ");
- builder.Append($@"
-
- 内容组
- ");
- }
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate))
- {
- var redirectUrl = PageContentTranslate.GetRedirectUrl(siteInfo.Id, nodeInfo.Id, pageUrl);
- var clickString = PageUtils.GetRedirectStringWithCheckBoxValue(redirectUrl, "contentIdCollection", "contentIdCollection", "请选择需要转移的内容!");
- builder.Append($@"
-
- 转 移
- ");
- }
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentEdit))
- {
- builder.Append($@"
-
- 排 序
- ");
- }
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentCheck))
- {
- builder.Append($@"
-
- 审 核
- ");
- }
- if (permissionManager.HasSitePermissions(siteInfo.Id, ConfigManager.WebSitePermissions.Create) || permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.CreatePage))
- {
- builder.Append($@"
-
-
- 生 成
- ");
- }
- }
-
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelEdit))
- {
- builder.Append($@"
-
-
- 显示项
- ");
- }
-
- if (nodeInfo.ContentNum > 0)
- {
- builder.Append(@"
-
-
- 查找
- ");
- }
-
- return builder.ToString();
- }
-
- public static string GetContentMoreCommands(PermissionManager permissionManager, SiteInfo siteInfo, ChannelInfo nodeInfo, string pageUrl)
- {
- var builder = new StringBuilder();
-
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentAdd) && nodeInfo.Additional.IsContentAddable)
- {
- builder.Append($@"
-
- 导 入
- ");
- }
-
- if (nodeInfo.ContentNum > 0)
- {
- builder.Append($@"
-
- 导 出
- ");
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentOrder))
- {
- builder.Append($@"
-
- 整 理
- ");
- }
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentArchive))
- {
- builder.Append($@"
-
- 归 档
- ");
- }
- if (CrossSiteTransUtility.IsCrossSiteTrans(siteInfo, nodeInfo) && !CrossSiteTransUtility.IsAutomatic(nodeInfo))
- {
- builder.Append($@"
-
- 跨站转发
- ");
- }
- }
-
- return builder.ToString();
- }
-
- public static string GetChannelCommands(PermissionManager permissionManager, SiteInfo siteInfo, ChannelInfo nodeInfo, string pageUrl, string currentFileName)
- {
- var iconUrl = SiteServerAssets.GetIconUrl(string.Empty);
- var builder = new StringBuilder();
- //添加栏目
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelAdd) && nodeInfo.Additional.IsChannelAddable)
- {
- builder.Append(
- $@" 添加栏目 | ");
- builder.Append(
- $@"快速添加 | ");
- }
- if (nodeInfo.ChildrenCount > 0)
- {
- //删除栏目
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelDelete))
- {
- builder.Append(
- $@"删除栏目 | ");
- }
- //清空内容
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ContentDelete))
- {
- builder.Append(
- $@"清空内容 | ");
- }
-
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelAdd))
- {
- //导 入
- if (nodeInfo.Additional.IsChannelAddable)
- {
- builder.Append(
- $@"导 入 | ");
- }
- //导 出
- builder.Append(
- $@"导 出 | ");
- }
-
- //设置栏目组
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelEdit))
- {
- builder.Append(
- $@"设置栏目组 | ");
- }
- //转 移
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelTranslate))
- {
- builder.Append(
- $@"转 移 | ");
- }
-
- //生 成
- if (permissionManager.HasSitePermissions(siteInfo.Id, ConfigManager.WebSitePermissions.Create) || permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.CreatePage))
- {
- builder.Append(
- $@"生 成 | ");
- }
- }
- else
- {
- //导 入
- if (permissionManager.HasChannelPermissions(siteInfo.Id, nodeInfo.Id, ConfigManager.ChannelPermissions.ChannelAdd) && nodeInfo.Additional.IsChannelAddable)
- {
- builder.Append(
- $@"导 入 | ");
- }
- }
- if (siteInfo.Id != nodeInfo.Id)
- {
- builder.Append(
- $@" 向 上 | ");
- }
- if (builder.Length > 0)
- {
- builder.Length = builder.Length - 15;
- }
- return builder.ToString();
- }
-
- public static string GetTextEditorCommands(SiteInfo siteInfo, string attributeName)
- {
- return $@"
-
-
- 导入Word
- 插入图片
- 插入视频
- 插入音频
- 提取关键字
- 敏感词检测
-
-";
- }
-
- public static string GetAutoCheckKeywordsScript(SiteInfo siteInfo)
- {
- var isAutoCheckKeywords = siteInfo.Additional.IsAutoCheckKeywords.ToString().ToLower();
- var url = AjaxCmsService.GetDetectionReplaceUrl(siteInfo.Id);
- var getPureText = ETextEditorTypeUtils.GetPureTextScript(BackgroundContentAttribute.Content);
- var getContent = ETextEditorTypeUtils.GetContentScript(BackgroundContentAttribute.Content);
- var setContent = ETextEditorTypeUtils.GetSetContentScript(BackgroundContentAttribute.Content, "htmlContent");
- var tipsWarn = AlertUtils.Warning("敏感词检测", "内容中共检测到' + i + '个敏感词,已用黄色背景标明", "取 消", "自动替换并保存",
- "autoReplaceKeywords");
-
- var command = $@"
-
-";
-
-
-
- return command;
- }
-
- public static string GetImageUrlButtonGroupHtml(SiteInfo siteInfo, string attributeName)
- {
- return $@"
-
-
- 上传
-
-
- 选择
-
-
- 裁切
-
-
- 预览
-
-
-";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/PageFindPwd.cs b/SiteServer.BackgroundPages/PageFindPwd.cs
deleted file mode 100644
index 1d632a7e8..000000000
--- a/SiteServer.BackgroundPages/PageFindPwd.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages
-{
- public class PageFindPwd : BasePage
- {
- protected Literal LtlPageTitle;
- protected Literal LtlMessage;
-
- protected PlaceHolder PhStepAccount;
- protected TextBox TbAccount;
- protected TextBox TbValidateCode;
- protected Literal LtlValidateCodeImage;
-
- protected PlaceHolder PhStepSmsCode;
- protected TextBox TbSmsCode;
-
- protected PlaceHolder PhStepChangePassword;
- protected TextBox TbPassword;
- protected TextBox TbConfirmPassword;
-
- private VcManager _vcManager;
-
- protected override bool IsAccessable => true;
-
- private string GetMessageHtml(string message, bool isError) => $@"{message}
";
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _vcManager = VcManager.GetInstance();
- if (Page.IsPostBack) return;
-
- if (!ConfigManager.SystemConfigInfo.IsAdminFindPassword)
- {
- PageUtils.RedirectToErrorPage("基于安全考虑,找回密码功能已关闭,如需使用请与管理员联系!");
- }
- else if (!SmsManager.IsReady() || string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.AdminFindPasswordSmsTplId))
- {
- PageUtils.RedirectToErrorPage("短信验证码发送功能未开启或配置不正确,找回密码功能无法使用,如需使用请与管理员联系!");
- }
-
- LtlValidateCodeImage.Text =
- $@" ";
-
- LtlPageTitle.Text = "找回密码";
- }
-
- public void Account_OnClick(object sender, EventArgs e)
- {
- var account = TbAccount.Text;
-
- if (!_vcManager.IsCodeValid(TbValidateCode.Text))
- {
- LtlMessage.Text = GetMessageHtml("验证码不正确,请重新输入!", true);
- return;
- }
-
- string userName = null;
- if (StringUtils.IsMobile(account))
- {
- userName = DataProvider.AdministratorDao.GetUserNameByMobile(account);
- }
- else if (StringUtils.IsEmail(account))
- {
- userName = DataProvider.AdministratorDao.GetUserNameByEmail(account);
- }
- else
- {
- if (DataProvider.AdministratorDao.IsAdminNameExists(account))
- {
- userName = account;
- }
- }
-
- if (string.IsNullOrEmpty(userName))
- {
- LtlMessage.Text = GetMessageHtml("找回密码错误,输入的账号不存在", true);
- return;
- }
-
- var mobile = DataProvider.AdministratorDao.GetMobileByUserName(account);
- if (string.IsNullOrEmpty(mobile) || !StringUtils.IsMobile(mobile))
- {
- LtlMessage.Text = GetMessageHtml("找回密码错误,账号对应的管理员未设置手机号码", true);
- return;
- }
-
- string errorMessage;
- var code = StringUtils.GetRandomInt(1111, 9999);
- CacheDbUtils.RemoveAndInsert($"BaiRong.BackgroundPages.FrameworkFindPwd.{userName}.Code", code.ToString());
- var isSend = SmsManager.SendCode(mobile, code, ConfigManager.SystemConfigInfo.AdminFindPasswordSmsTplId, out errorMessage);
- if (!isSend)
- {
- LtlMessage.Text = GetMessageHtml($"找回密码错误:{errorMessage}", true);
- return;
- }
-
- ViewState["UserName"] = userName;
- LtlPageTitle.Text = "验证手机";
- LtlMessage.Text = GetMessageHtml($"短信验证码已发送至:{mobile.Substring(0, 3) + "*****" + mobile.Substring(8)}", true);
- PhStepAccount.Visible = false;
- PhStepSmsCode.Visible = true;
- PhStepChangePassword.Visible = false;
- }
-
- public void SmsCode_OnClick(object sender, EventArgs e)
- {
- var smsCode = TbSmsCode.Text;
- var userName = ViewState["UserName"];
- var code = CacheDbUtils.GetValueAndRemove($"BaiRong.BackgroundPages.FrameworkFindPwd.{userName}.Code");
-
- if (smsCode != code)
- {
- LtlMessage.Text = GetMessageHtml("找回密码错误:短信验证码不正确", true);
- return;
- }
-
- LtlPageTitle.Text = "重设密码";
- LtlMessage.Text = string.Empty;
- PhStepAccount.Visible = false;
- PhStepSmsCode.Visible = false;
- PhStepChangePassword.Visible = true;
- }
-
- public void ChangePassword_OnClick(object sender, EventArgs e)
- {
- var userName = ViewState["UserName"] as string;
-
- var password = TbPassword.Text;
- var confirmPassword = TbConfirmPassword.Text;
-
- if (password != confirmPassword)
- {
- LtlMessage.Text = GetMessageHtml("重设密码错误:新密码与确认密码不一致", true);
- return;
- }
-
- string errorMessage;
- if (!DataProvider.AdministratorDao.ChangePassword(userName, password, out errorMessage))
- {
- LtlMessage.Text = GetMessageHtml($"重设密码错误:{errorMessage}", true);
- return;
- }
-
- LtlPageTitle.Text = "密码设置成功";
- LtlMessage.Text = GetMessageHtml("密码设置成功,系统将跳转至登录页面", false);
- AddWaitAndRedirectScript("login.aspx");
- PhStepAccount.Visible = false;
- PhStepSmsCode.Visible = false;
- PhStepChangePassword.Visible = false;
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/PageLogin.cs b/SiteServer.BackgroundPages/PageLogin.cs
deleted file mode 100644
index 8a482b2d3..000000000
--- a/SiteServer.BackgroundPages/PageLogin.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages
-{
- public class PageLogin : BasePage
- {
- public Literal LtlMessage;
- public TextBox TbAccount;
- public TextBox TbPassword;
- public TextBox TbValidateCode;
- public Literal LtlValidateCodeImage;
- public CheckBox CbRememberMe;
- public PlaceHolder PhFindPassword;
-
- private VcManager _vcManager; // 验证码类
-
- protected override bool IsAccessable => true; // 设置本页面是否能直接访问 如果为false,则必须管理员登录后才能访问
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return; // 如果无权访问页面,则返回空白页
-
- try
- {
- _vcManager = VcManager.GetInstance(); // 构建验证码实例
- if (Page.IsPostBack) return;
-
- PhFindPassword.Visible = ConfigManager.SystemConfigInfo.IsAdminFindPassword;
-
- if (AuthRequest.IsQueryExists("error")) // 如果url参数error不为空,则把错误信息显示到页面上
- {
- LtlMessage.Text = GetMessageHtml(AuthRequest.GetQueryString("error"));
- }
-
- SystemManager.DetermineRedirectToInstaller(); // 判断是否需要安装,如果需要则转到安装页面。
-
- LtlValidateCodeImage.Text =
- $@" ";
- }
- catch
- {
- // 再次探测是否需要安装或升级
- if (SystemManager.IsNeedInstall())
- {
- PageUtils.Redirect(PageInstaller.GetRedirectUrl());
- }
- else if (SystemManager.IsNeedUpdate())
- {
- PageUtils.Redirect(PageSyncDatabase.GetRedirectUrl());
- }
- else
- {
- throw;
- }
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var account = TbAccount.Text;
- var password = TbPassword.Text;
-
- if (!_vcManager.IsCodeValid(TbValidateCode.Text)) // 检测验证码是否正确
- {
- LtlMessage.Text = GetMessageHtml("验证码不正确,请重新输入!");
- return;
- }
-
- string userName;
- string errorMessage;
- if (!DataProvider.AdministratorDao.ValidateAccount(account, password, out userName, out errorMessage)) // 检测密码是否正确
- {
- LogUtils.AddAdminLog(userName, "后台管理员登录失败");
- DataProvider.AdministratorDao.UpdateLastActivityDateAndCountOfFailedLogin(userName); // 记录最后登录时间、失败次数+1
- LtlMessage.Text = GetMessageHtml(errorMessage); // 把错误信息显示在页面上
- return;
- }
-
- DataProvider.AdministratorDao.UpdateLastActivityDateAndCountOfLogin(userName); // 记录最后登录时间、失败次数清零
- AuthRequest.AdminLogin(userName); // 写Cookie并记录管理员操作日志
- PageUtils.Redirect(PageUtils.GetAdminDirectoryUrl(string.Empty)); // 跳转到登录成功的后台页
- }
-
- private string GetMessageHtml(string message) => $@"{message}
";
- }
-}
diff --git a/SiteServer.BackgroundPages/PageLogout.cs b/SiteServer.BackgroundPages/PageLogout.cs
deleted file mode 100644
index e313108e0..000000000
--- a/SiteServer.BackgroundPages/PageLogout.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages
-{
- public class PageLogout : BasePage
- {
- protected override bool IsAccessable => true;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- var redirectUrl = PageUtils.GetAdminDirectoryUrl("login.aspx");
-
- AuthRequest.AdminLogout();
- PageUtils.Redirect(PageUtils.ParseNavigationUrl(redirectUrl));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/PageMain.cs b/SiteServer.BackgroundPages/PageMain.cs
deleted file mode 100644
index 428f8c4be..000000000
--- a/SiteServer.BackgroundPages/PageMain.cs
+++ /dev/null
@@ -1,454 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Cms;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.BackgroundPages.Settings;
-using SiteServer.CMS.Api;
-using SiteServer.CMS.Api.Preview;
-using SiteServer.CMS.Api.Sys.Packaging;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Packaging;
-using SiteServer.CMS.Plugin;
-
-namespace SiteServer.BackgroundPages
-{
- public class PageMain : BasePageCms
- {
- public Literal LtlTopMenus;
- public PlaceHolder PhSite;
- public Literal LtlCreateStatus;
- public NavigationTree NtLeftManagement;
- public NavigationTree NtLeftFunctions;
-
- private SiteInfo _siteInfo = new SiteInfo();
- private SiteInfo _hqSiteInfo;
- private readonly List _addedSiteIdList = new List();
-
- protected override bool IsSinglePage => true;
-
- public string SignalrHubsUrl = ApiManager.SignalrHubsUrl;
-
- public string PackageIdSsCms = PackageUtils.PackageIdSsCms;
-
- public string PackageList
- {
- get
- {
- var list = new List();
- var dict = PluginManager.GetPluginIdAndVersionDict();
- foreach (var id in dict.Keys)
- {
- var version = dict[id];
- list.Add(new
- {
- id,
- version
- });
- }
- return TranslateUtils.JsonSerialize(list);
- }
- }
-
- public string DownloadApiUrl => ApiRouteDownload.GetUrl(ApiManager.InnerApiUrl);
-
- public string CurrentVersion => SystemManager.Version;
-
- public string UpdateSystemUrl => PageUpdateSystem.GetRedirectUrl();
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSiteServerUrl(nameof(PageMain), null);
- }
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetSiteServerUrl(nameof(PageMain), new NameValueCollection
- {
- {"siteId", siteId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- var siteId = SiteId;
-
- if (siteId == 0)
- {
- siteId = AuthRequest.AdminInfo.SiteId;
- }
-
- var siteIdList = AuthRequest.AdminPermissions.SiteIdList;
-
- //站点要判断是否存在,是否有权限
- if (siteId == 0 || !SiteManager.IsExists(siteId) || !siteIdList.Contains(siteId))
- {
- if (siteIdList != null && siteIdList.Count > 0)
- {
- siteId = siteIdList[0];
- }
- }
-
- _siteInfo = SiteManager.GetSiteInfo(siteId);
-
- if (_siteInfo != null && _siteInfo.Id > 0)
- {
- if (SiteId == 0)
- {
- PageUtils.Redirect(GetRedirectUrl(_siteInfo.Id));
- return;
- }
-
- var showSite = false;
-
- var permissionList = new List(AuthRequest.AdminPermissions.PermissionList);
-
- if (AuthRequest.AdminPermissions.HasSitePermissions(_siteInfo.Id))
- {
- var websitePermissionList = AuthRequest.AdminPermissions.GetSitePermissions(_siteInfo.Id);
- if (websitePermissionList != null)
- {
- showSite = true;
- permissionList.AddRange(websitePermissionList);
- }
- }
-
- var channelPermissions = AuthRequest.AdminPermissions.GetChannelPermissions(_siteInfo.Id);
- if (channelPermissions.Count > 0)
- {
- showSite = true;
- permissionList.AddRange(channelPermissions);
- }
-
- var siteIdHashtable = new Hashtable();
- if (siteIdList != null)
- {
- foreach (var theSiteId in siteIdList)
- {
- siteIdHashtable.Add(theSiteId, theSiteId);
- }
- }
-
- if (!siteIdHashtable.Contains(SiteId))
- {
- showSite = false;
- }
-
- if (!showSite)
- {
- PageUtils.RedirectToErrorPage("您没有此发布系统的操作权限!");
- return;
- }
-
- LtlTopMenus.Text = GetTopMenuSitesHtml() + GetTopMenuLinksHtml() + GetTopMenusHtml();
-
- PhSite.Visible = true;
-
- LtlCreateStatus.Text = $@"
-
-
-
- 0
-
-";
-
- NtLeftManagement.TopId = ConfigManager.TopMenu.IdSite;
- NtLeftManagement.SiteId = _siteInfo.Id;
- NtLeftManagement.PermissionList = permissionList;
-
- NtLeftFunctions.TopId = string.Empty;
- NtLeftFunctions.SiteId = _siteInfo.Id;
- NtLeftFunctions.PermissionList = permissionList;
-
- ClientScriptRegisterClientScriptBlock("NodeTreeScript", NodeNaviTreeItem.GetNavigationBarScript());
- }
- else
- {
- if (AuthRequest.AdminPermissions.IsSystemAdministrator)
- {
- PageUtils.Redirect(PageSiteAdd.GetRedirectUrl());
- return;
- }
- }
-
- if (_siteInfo != null && _siteInfo.Id > 0 && AuthRequest.AdminInfo.SiteId != _siteInfo.Id)
- {
- DataProvider.AdministratorDao.UpdateSiteId(AuthRequest.AdminName, _siteInfo.Id);
- }
- }
-
- private void AddSite(StringBuilder builder, SiteInfo siteInfo, Dictionary> parentWithChildren, int level)
- {
- if (_addedSiteIdList.Contains(siteInfo.Id)) return;
-
- var loadingUrl = PageUtils.GetLoadingUrl(GetRedirectUrl(siteInfo.Id));
-
- if (parentWithChildren.ContainsKey(siteInfo.Id))
- {
- var children = parentWithChildren[siteInfo.Id];
-
- builder.Append($@"
-
- {siteInfo.SiteName}
-
-");
-
- level++;
- foreach (var subSiteInfo in children)
- {
- AddSite(builder, subSiteInfo, parentWithChildren, level);
- }
-
- builder.Append(@"
-
- ");
- }
- else
- {
- builder.Append(
- $@"{siteInfo.SiteName} ");
- }
-
- _addedSiteIdList.Add(siteInfo.Id);
- }
-
- private string GetTopMenuSitesHtml()
- {
- var siteIdList = AuthRequest.AdminPermissions.SiteIdList;
-
- if (!AuthRequest.AdminPermissions.IsSystemAdministrator && siteIdList.Count == 0)
- {
- return string.Empty;
- }
-
- //操作者拥有的站点列表
- var mySystemInfoList = new List();
-
- var parentWithChildren = new Dictionary>();
-
- if (AuthRequest.AdminPermissions.IsSystemAdministrator)
- {
- foreach (var siteId in siteIdList)
- {
- AddToMySystemInfoList(mySystemInfoList, parentWithChildren, siteId);
- }
- }
- else
- {
- var permissionSiteIdList = AuthRequest.AdminPermissions.SiteIdList;
- var permissionChannelIdList = AuthRequest.AdminPermissions.ChannelPermissionChannelIdList;
- foreach (var siteId in siteIdList)
- {
- var showSite = IsShowSite(siteId, permissionSiteIdList, permissionChannelIdList);
- if (showSite)
- {
- AddToMySystemInfoList(mySystemInfoList, parentWithChildren, siteId);
- }
- }
- }
-
- var builder = new StringBuilder();
-
- if (_hqSiteInfo != null || mySystemInfoList.Count > 0)
- {
- if (_hqSiteInfo != null)
- {
- AddSite(builder, _hqSiteInfo, parentWithChildren, 0);
- }
-
- if (mySystemInfoList.Count > 0)
- {
- var count = 0;
- foreach (var siteInfo in mySystemInfoList)
- {
- if (siteInfo.IsRoot == false)
- {
- count++;
- AddSite(builder, siteInfo, parentWithChildren, 0);
- }
- if (count == 13)
- {
- builder.Append(
- $@"列出全部站点... ");
- break;
- }
- }
- }
- }
-
- var clazz = "has-submenu";
- var menuText = "站点管理";
- if (_siteInfo != null && _siteInfo.Id > 0)
- {
- clazz = "has-submenu active";
- menuText = _siteInfo.SiteName;
- if (_siteInfo.ParentId > 0)
- {
- menuText += $" ({SiteManager.GetSiteLevel(_siteInfo.Id) + 1}级)";
- }
- }
-
- return $@"
- {menuText}
-
- ";
- }
-
- private string GetTopMenuLinksHtml()
- {
- if (_siteInfo == null || _siteInfo.Id <= 0)
- {
- return string.Empty;
- }
-
- var builder = new StringBuilder();
-
- builder.Append(
- $@"访问站点 ");
- builder.Append(
- $@"预览站点 ");
-
- return $@"
- 站点链接
-
- ";
- }
-
- private string GetTopMenusHtml()
- {
- var topMenuTabs = TabManager.GetTopMenuTabs();
-
- if (topMenuTabs == null || topMenuTabs.Count == 0)
- {
- return string.Empty;
- }
-
- var permissionList = new List();
- if (AuthRequest.AdminPermissions.HasSitePermissions(SiteId))
- {
- var websitePermissionList = AuthRequest.AdminPermissions.GetSitePermissions(SiteId);
- if (websitePermissionList != null)
- {
- permissionList.AddRange(websitePermissionList);
- }
- }
-
- permissionList.AddRange(AuthRequest.AdminPermissions.PermissionList);
-
- var builder = new StringBuilder();
- foreach (var tab in topMenuTabs)
- {
- if (!AuthRequest.AdminPermissions.IsConsoleAdministrator && !TabManager.IsValid(tab, permissionList)) continue;
-
- var tabs = TabManager.GetTabList(tab.Id, 0);
- var tabsBuilder = new StringBuilder();
- foreach (var parent in tabs)
- {
- if (!AuthRequest.AdminPermissions.IsConsoleAdministrator && !TabManager.IsValid(parent, permissionList)) continue;
-
- var hasChildren = parent.Children != null && parent.Children.Length > 0;
-
- var parentUrl = !string.IsNullOrEmpty(parent.Href) ? PageUtils.GetLoadingUrl(parent.Href) : "javascript:;";
- var parentTarget = !string.IsNullOrEmpty(parent.Target) ? parent.Target : "right";
-
- if (hasChildren)
- {
- tabsBuilder.Append($@"
-
- {parent.Text}
-
-");
-
- if (parent.Children != null && parent.Children.Length > 0)
- {
- foreach (var childTab in parent.Children)
- {
- var childTarget = !string.IsNullOrEmpty(childTab.Target) ? childTab.Target : "right";
- tabsBuilder.Append($@"{childTab.Text} ");
- }
- }
-
- tabsBuilder.Append(@"
-
- ");
- }
- else
- {
- tabsBuilder.Append(
- $@"{parent.Text} ");
- }
- }
-
- var url = !string.IsNullOrEmpty(tab.Href) ? PageUtils.ParseNavigationUrl(tab.Href) : "javascript:;";
- var target = !string.IsNullOrEmpty(tab.Target) ? tab.Target : "right";
-
- builder.Append(
- $@"
- {tab.Text}
-
- ");
- }
-
- return builder.ToString();
- }
-
- private static bool IsShowSite(int siteId, List permissionSiteIdList, List permissionChannelIdList)
- {
- foreach (var permissionSiteId in permissionSiteIdList)
- {
- if (permissionSiteId == siteId)
- {
- return true;
- }
- }
- foreach (var permissionChannelId in permissionChannelIdList)
- {
- if (ChannelManager.IsAncestorOrSelf(siteId, siteId, permissionChannelId))
- {
- return true;
- }
- }
- return false;
- }
-
- private void AddToMySystemInfoList(List mySystemInfoList, Dictionary> parentWithChildren, int siteId)
- {
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- if (siteInfo == null) return;
-
- if (siteInfo.IsRoot)
- {
- _hqSiteInfo = siteInfo;
- }
- else if (siteInfo.ParentId > 0)
- {
- var children = new List();
- if (parentWithChildren.ContainsKey(siteInfo.ParentId))
- {
- children = parentWithChildren[siteInfo.ParentId];
- }
- children.Add(siteInfo);
- parentWithChildren[siteInfo.ParentId] = children;
- }
- mySystemInfoList.Add(siteInfo);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/PageRight.cs b/SiteServer.BackgroundPages/PageRight.cs
deleted file mode 100644
index 4554c8bbc..000000000
--- a/SiteServer.BackgroundPages/PageRight.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Api;
-using SiteServer.CMS.Api.Sys.Administrators;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Packaging;
-
-namespace SiteServer.BackgroundPages
-{
- public class PageRight : BasePage
- {
- public Literal LtlVersionInfo;
- public Literal LtlUpdateDate;
- public Literal LtlLastLoginDate;
-
- public string SiteCheckListApiUrl => ApiRouteSiteCheckList.GetUrl(ApiManager.InnerApiUrl, AuthRequest.AdminName);
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- LtlVersionInfo.Text = SystemManager.Version == PackageUtils.VersionDev ? "dev" : SystemManager.Version;
-
- if (AuthRequest.AdminInfo.LastActivityDate != DateTime.MinValue)
- {
- LtlLastLoginDate.Text = DateUtils.GetDateAndTimeString(AuthRequest.AdminInfo.LastActivityDate);
- }
-
- LtlUpdateDate.Text = DateUtils.GetDateAndTimeString(ConfigManager.Instance.UpdateDate);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/PageTest.cs b/SiteServer.BackgroundPages/PageTest.cs
deleted file mode 100644
index 7a2fa5a0a..000000000
--- a/SiteServer.BackgroundPages/PageTest.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Plugin.Apis;
-using SiteServer.CMS.StlParser.Model;
-using SiteServer.CMS.StlParser.StlElement;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages
-{
- public class PageTest : Page
- {
- public Literal LtlContent;
-
- public void Page_Load(object sender, EventArgs e)
- {
- FieldInfo[] fields = typeof(ChannelAttribute).GetFields(BindingFlags.Static | BindingFlags.Public);
-
-
- LtlContent.Text = DisplayPropertyInfo(fields);
- }
-
- public static string DisplayPropertyInfo(FieldInfo[] propInfos)
- {
- var builder = new StringBuilder();
- // Display information for all properties.
- foreach (var propInfo in propInfos)
- {
-
- builder.AppendFormat(" Property name: {0}", propInfo.Name);
- builder.AppendFormat(" Property value: {0}", propInfo.GetValue(null));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Plugins/ModalManualInstall.cs b/SiteServer.BackgroundPages/Plugins/ModalManualInstall.cs
deleted file mode 100644
index 5ce32f3f1..000000000
--- a/SiteServer.BackgroundPages/Plugins/ModalManualInstall.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-using System.IO;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Packaging;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Plugins
-{
- public class ModalManualInstall : BasePage
- {
- public RadioButtonList RblInstallType;
-
- public PlaceHolder PhFile;
- public HtmlInputFile HifFile;
-
- public PlaceHolder PhIdAndVersion;
- public TextBox TbPluginId;
- public TextBox TbVersion;
-
- public static string GetOpenWindowString()
- {
- return LayerUtils.GetOpenScript("手动安装插件", PageUtils.GetPluginsUrl(nameof(ModalManualInstall), null), 560, 430);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (IsPostBack) return;
-
- EBooleanUtils.AddListItems(RblInstallType, "上传插件包", "指定插件Id与版本号");
- ControlUtils.SelectSingleItem(RblInstallType, true.ToString());
- }
-
- public void RblInstallType_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhFile.Visible = TranslateUtils.ToBool(RblInstallType.SelectedValue);
- PhIdAndVersion.Visible = !PhFile.Visible;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (TranslateUtils.ToBool(RblInstallType.SelectedValue))
- {
- if (HifFile.PostedFile == null || HifFile.PostedFile.FileName == "") return;
-
- var filePath = HifFile.PostedFile.FileName;
- if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".nupkg"))
- {
- FailMessage("必须上传后缀为.nupkg的文件");
- return;
- }
-
- var idAndVersion = Path.GetFileNameWithoutExtension(filePath);
- var directoryPath = PathUtils.GetPackagesPath(idAndVersion);
- var localFilePath = PathUtils.Combine(directoryPath, idAndVersion + ".nupkg");
-
- if (!Directory.Exists(directoryPath))
- {
- Directory.CreateDirectory(directoryPath);
- }
-
- HifFile.PostedFile.SaveAs(localFilePath);
-
- ZipUtils.UnpackFiles(localFilePath, directoryPath);
-
- string errorMessage;
- if (!PackageUtils.UpdatePackage(idAndVersion, PackageType.Plugin, out errorMessage))
- {
- FailMessage($"手动安装插件失败:{errorMessage}");
- return;
- }
-
- AuthRequest.AddAdminLog("手动安装插件:" + idAndVersion);
-
- LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl());
- }
- else
- {
- string errorMessage;
- try
- {
- PackageUtils.DownloadPackage(TbPluginId.Text, TbVersion.Text);
- }
- catch (Exception ex)
- {
- FailMessage($"手动安装插件失败:{ex.Message}");
- return;
- }
-
- var idWithVersion = $"{TbPluginId.Text}.{TbVersion.Text}";
- if (!PackageUtils.UpdatePackage(idWithVersion, PackageType.Plugin, out errorMessage))
- {
- FailMessage($"手动安装插件失败:{errorMessage}");
- return;
- }
-
- AuthRequest.AddAdminLog($"手动安装插件:{TbPluginId.Text} {TbVersion.Text}");
-
- LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl());
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Plugins/PageAdd.cs b/SiteServer.BackgroundPages/Plugins/PageAdd.cs
deleted file mode 100644
index abd6f7bc3..000000000
--- a/SiteServer.BackgroundPages/Plugins/PageAdd.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Plugins
-{
- public class PageAdd : BasePage
- {
- public Button BtnUpload;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetPluginsUrl(nameof(PageAdd), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (Page.IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.PluginsPermissions.Add);
-
- BtnUpload.OnClientClick = ModalManualInstall.GetOpenWindowString();
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Plugins/PageInstall.cs b/SiteServer.BackgroundPages/Plugins/PageInstall.cs
deleted file mode 100644
index 1a17f1d72..000000000
--- a/SiteServer.BackgroundPages/Plugins/PageInstall.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using SiteServer.CMS.Api;
-using SiteServer.CMS.Api.Sys.Packaging;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Plugin;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Plugins
-{
- public class PageInstall : BasePage
- {
- public static string GetRedirectUrl(bool isUpdate, string packageId)
- {
- return PageUtils.GetPluginsUrl(nameof(PageInstall), new NameValueCollection
- {
- { "type", isUpdate ? "update" : "install" },
- { "packageId", packageId }
- });
- }
-
- public string Type => AuthRequest.GetQueryString("type") == "update" ? "升级" : "安装";
-
- public string AdminUrl => PageUtils.GetAdminDirectoryUrl(string.Empty);
-
- public string PackagesIdAndVersionList => TranslateUtils.JsonSerialize(PluginManager.PackagesIdAndVersionList);
-
- public string PackageId { get; set; }
-
- public string DownloadApiUrl => ApiRouteDownload.GetUrl(ApiManager.InnerApiUrl);
-
- public string UpdateApiUrl => ApiRouteUpdate.GetUrl(ApiManager.InnerApiUrl);
-
- public string ClearCacheApiUrl => ApiRouteClearCache.GetUrl(ApiManager.InnerApiUrl);
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PackageId = AuthRequest.GetQueryString("packageId");
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.PluginsPermissions.Add, ConfigManager.PluginsPermissions.Management);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Properties/AssemblyInfo.cs b/SiteServer.BackgroundPages/Properties/AssemblyInfo.cs
deleted file mode 100644
index def7b6441..000000000
--- a/SiteServer.BackgroundPages/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("SiteServer.BackgroundPages")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("SiteServer.BackgroundPages")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("aab355c2-8dd2-43d3-880c-eb9b51a59971")]
-
-// 程序集的版本信息由下列四个值组成:
-//
-// 主版本
-// 次版本
-// 生成号
-// 修订号
-//
-// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
-//通过使用 "*",如下所示:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.0.0")]
-[assembly: AssemblyFileVersion("0.0.0")]
-[assembly: AssemblyInformationalVersion("0.0.0")]
diff --git a/SiteServer.BackgroundPages/Settings/ModalAdminPassword.cs b/SiteServer.BackgroundPages/Settings/ModalAdminPassword.cs
deleted file mode 100644
index c7d34a5d1..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalAdminPassword.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalAdminPassword : BasePage
- {
- public Label LbUserName;
- public TextBox TbPassword;
-
- private string _userName;
-
- public static string GetOpenWindowString(string userName)
- {
- return LayerUtils.GetOpenScript("重设密码", PageUtils.GetSettingsUrl(nameof(ModalAdminPassword), new NameValueCollection
- {
- {"userName", userName}
- }), 520, 300);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _userName = AuthRequest.GetQueryString("userName");
-
- if (IsPostBack) return;
-
- if (!string.IsNullOrEmpty(_userName) && DataProvider.AdministratorDao.IsAdminNameExists(_userName))
- {
- LbUserName.Text = _userName;
- }
- else
- {
- FailMessage("此帐户不存在!");
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!IsPostBack || !IsValid) return;
-
- try
- {
- string errorMessage;
- if (!DataProvider.AdministratorDao.ChangePassword(_userName, TbPassword.Text, out errorMessage))
- {
- FailMessage(errorMessage);
- return;
- }
-
- AuthRequest.AddAdminLog("重设管理员密码", $"管理员:{_userName}");
-
- SuccessMessage("重设密码成功!");
-
- LayerUtils.Close(Page);
- }
- catch(Exception ex)
- {
- FailMessage(ex, "重设密码失败!");
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/ModalAdminView.cs b/SiteServer.BackgroundPages/Settings/ModalAdminView.cs
deleted file mode 100644
index e3ba97e49..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalAdminView.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalAdminView : BasePage
- {
- protected Literal LtlUserName;
- protected Literal LtlDisplayName;
- protected Literal LtlCreationDate;
- protected Literal LtlLastActivityDate;
- protected Literal LtlEmail;
- protected Literal LtlMobile;
- protected Literal LtlRoles;
-
- public static string GetOpenWindowString(string userName)
- {
- return LayerUtils.GetOpenScript("查看管理员资料", PageUtils.GetSettingsUrl(nameof(ModalAdminView), new NameValueCollection
- {
- {"UserName", userName}
- }), 500, 500);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- var userName = AuthRequest.GetQueryString("UserName");
- var adminInfo = DataProvider.AdministratorDao.GetByUserName(userName);
- LtlUserName.Text = adminInfo.UserName;
- LtlDisplayName.Text = adminInfo.DisplayName;
- LtlCreationDate.Text = DateUtils.GetDateAndTimeString(adminInfo.CreationDate);
- LtlLastActivityDate.Text = DateUtils.GetDateAndTimeString(adminInfo.LastActivityDate);
- LtlEmail.Text = adminInfo.Email;
- LtlMobile.Text = adminInfo.Mobile;
- LtlRoles.Text = AdminManager.GetRolesHtml(userName);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/ModalAuxiliaryTableAdd.cs b/SiteServer.BackgroundPages/Settings/ModalAuxiliaryTableAdd.cs
deleted file mode 100644
index 9a2ba859b..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalAuxiliaryTableAdd.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalAuxiliaryTableAdd : BasePageCms
- {
- public TextBox TbTableName;
- public TextBox TbDisplayName;
- public TextBox TbDescription;
-
- private string _tableName;
-
- public static string GetOpenWindowString()
- {
- return LayerUtils.GetOpenScript("添加辅助表", PageUtils.GetSettingsUrl(nameof(ModalAuxiliaryTableAdd), null), 580, 450);
- }
-
- public static string GetOpenWindowString(string tableName)
- {
- return LayerUtils.GetOpenScript("编辑辅助表", PageUtils.GetSettingsUrl(nameof(ModalAuxiliaryTableAdd), new NameValueCollection
- {
- {"tableName", tableName}
- }), 580, 450);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _tableName = AuthRequest.GetQueryString("tableName");
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- if (!string.IsNullOrEmpty(_tableName))
- {
- var info = DataProvider.TableDao.GetTableCollectionInfo(_tableName);
- if (info != null)
- {
- TbTableName.Text = info.TableName;
- TbTableName.Enabled = false;
- TbDisplayName.Text = info.DisplayName;
- TbDescription.Text = info.Description;
- }
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- if (!string.IsNullOrEmpty(_tableName))
- {
- var info = DataProvider.TableDao.GetTableCollectionInfo(_tableName);
- info.DisplayName = TbDisplayName.Text;
- info.Description = TbDescription.Text;
-
- DataProvider.TableDao.Update(info);
-
- AuthRequest.AddAdminLog("修改辅助表", $"辅助表:{_tableName}");
-
- SuccessMessage("辅助表修改成功!");
- LayerUtils.Close(Page);
- }
- else
- {
- var tableNameList = DataProvider.TableDao.GetTableNameList();
- if (tableNameList.IndexOf(TbTableName.Text) != -1)
- {
- FailMessage("辅助表添加失败,辅助表标识已存在!");
- }
- else if (DataProvider.DatabaseDao.IsTableExists(TbTableName.Text))
- {
- FailMessage("辅助表添加失败,数据库中已存在此表!");
- }
- else
- {
- var info = new TableInfo
- {
- TableName = TbTableName.Text,
- DisplayName = TbDisplayName.Text,
- Description = TbDescription.Text
- };
-
- DataProvider.TableDao.Insert(info, DataProvider.TableMetadataDao.GetDefaultTableMetadataInfoList(info.TableName));
-
- AuthRequest.AddAdminLog("添加辅助表", $"辅助表:{TbTableName.Text}");
-
- SuccessMessage("辅助表添加成功!");
- LayerUtils.Close(Page);
- }
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/ModalExportMessage.cs b/SiteServer.BackgroundPages/Settings/ModalExportMessage.cs
deleted file mode 100644
index 7abeaacc2..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalExportMessage.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Api;
-using SiteServer.CMS.Api.Sys.Stl;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.ImportExport;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalExportMessage : BasePage
- {
- private string _exportType;
- public const string ExportTypeSingleTableStyle = "SingleTableStyle";
-
- public static string GetOpenWindowStringToSingleTableStyle(string tableName)
- {
- return LayerUtils.GetOpenScript("导出数据",
- PageUtils.GetSettingsUrl(nameof(ModalExportMessage), new NameValueCollection
- {
- {"TableName", tableName},
- {"ExportType", ExportTypeSingleTableStyle}
- }), 380, 250);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _exportType = AuthRequest.GetQueryString("ExportType");
-
- if (!IsPostBack)
- {
- var fileName = string.Empty;
- try
- {
- if (_exportType == ExportTypeSingleTableStyle)
- {
- var tableName = AuthRequest.GetQueryString("TableName");
- fileName = ExportSingleTableStyle(tableName);
- }
-
- var link = new HyperLink();
- var filePath = PathUtils.GetTemporaryFilesPath(fileName);
- link.NavigateUrl = ApiRouteActionsDownload.GetUrl(ApiManager.InnerApiUrl, filePath);
- link.Text = "下载";
- var successMessage = "成功导出文件! " + ControlUtils.GetControlRenderHtml(link);
- SuccessMessage(successMessage);
- }
- catch (Exception ex)
- {
- var failedMessage = "文件导出失败! 原因为:" + ex.Message;
- FailMessage(ex, failedMessage);
- }
- }
- }
-
- private static string ExportSingleTableStyle(string tableName)
- {
- return ExportObject.ExportRootSingleTableStyle(tableName);
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/ModalKeywordAdd.cs b/SiteServer.BackgroundPages/Settings/ModalKeywordAdd.cs
deleted file mode 100644
index 4e588e7b8..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalKeywordAdd.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalKeywordAdd : BasePageCms
- {
- protected TextBox TbKeyword;
- protected TextBox TbAlternative;
- protected DropDownList DdlGrade;
-
- private int _keywordId;
-
- public static string GetOpenWindowStringToAdd()
- {
- return LayerUtils.GetOpenScript("添加敏感词", PageUtils.GetSettingsUrl(nameof(ModalKeywordAdd), null), 460, 300);
- }
-
- public static string GetOpenWindowStringToEdit(int keywordId)
- {
- return LayerUtils.GetOpenScript("修改敏感词",
- PageUtils.GetSettingsUrl(nameof(ModalKeywordAdd), new NameValueCollection
- {
- {"KeywordID", keywordId.ToString()}
- }), 460, 300);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _keywordId = AuthRequest.GetQueryInt("KeywordID");
-
- if (IsPostBack) return;
-
- EKeywordGradeUtils.AddListItems(DdlGrade);
- if (_keywordId <= 0) return;
-
- var keywordInfo = DataProvider.KeywordDao.GetKeywordInfo(_keywordId);
- TbKeyword.Text = keywordInfo.Keyword;
- TbAlternative.Text = keywordInfo.Alternative;
- ControlUtils.SelectSingleItem(DdlGrade, EKeywordGradeUtils.GetValue(keywordInfo.Grade));
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- if (_keywordId > 0)
- {
- try
- {
- var keywordInfo = DataProvider.KeywordDao.GetKeywordInfo(_keywordId);
- keywordInfo.Keyword = TbKeyword.Text.Trim();
- keywordInfo.Alternative = TbAlternative.Text.Trim();
- keywordInfo.Grade = EKeywordGradeUtils.GetEnumType(DdlGrade.SelectedValue);
- DataProvider.KeywordDao.Update(keywordInfo);
-
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "修改敏感词失败!");
- }
- }
- else
- {
- if (DataProvider.KeywordDao.IsExists(TbKeyword.Text))
- {
- FailMessage("敏感词添加失败,敏感词名称已存在!");
- }
- else
- {
- try
- {
- var keywordInfo = new KeywordInfo
- {
- Keyword = TbKeyword.Text.Trim(),
- Alternative = TbAlternative.Text.Trim(),
- Grade = EKeywordGradeUtils.GetEnumType(DdlGrade.SelectedValue)
- };
- DataProvider.KeywordDao.Insert(keywordInfo);
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "添加敏感词失败!");
- }
- }
- }
-
- if (isChanged)
- {
- LayerUtils.Close(Page);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/ModalKeywordImport.cs b/SiteServer.BackgroundPages/Settings/ModalKeywordImport.cs
deleted file mode 100644
index 56207840b..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalKeywordImport.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalKeywordImport : BasePageCms
- {
- public DropDownList DdlGrade;
- public TextBox TbKeywords;
-
- public static string GetOpenWindowString()
- {
- return LayerUtils.GetOpenScript("导入敏感词",
- PageUtils.GetSettingsUrl(nameof(ModalKeywordImport), null), 500, 530);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (!IsPostBack)
- {
- EKeywordGradeUtils.AddListItems(DdlGrade);
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- try
- {
- var grade = EKeywordGradeUtils.GetEnumType(DdlGrade.SelectedValue);
-
- var keywordArray = TbKeywords.Text.Split(',');
- foreach (var item in keywordArray)
- {
- if (!string.IsNullOrEmpty(item))
- {
- var value = item.Trim();
- string keyword;
- var alternative = string.Empty;
-
- if (value.IndexOf('|') != -1)
- {
- keyword = value.Split('|')[0];
- alternative = value.Split('|')[1];
- }
- else
- {
- keyword = value;
- }
-
- if (!string.IsNullOrEmpty(keyword) && !DataProvider.KeywordDao.IsExists(keyword))
- {
- var keywordInfo = new KeywordInfo(0, keyword, alternative, grade);
- DataProvider.KeywordDao.Insert(keywordInfo);
- }
- }
- }
-
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "导入敏感词失败");
- }
-
- if (isChanged)
- {
- LayerUtils.Close(Page);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/ModalPermissionsSet.cs b/SiteServer.BackgroundPages/Settings/ModalPermissionsSet.cs
deleted file mode 100644
index 3b26cb0d3..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalPermissionsSet.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalPermissionsSet : BasePageCms
- {
- public DropDownList DdlPredefinedRole;
- public PlaceHolder PhSiteId;
- public CheckBoxList CblSiteId;
- public PlaceHolder PhRoles;
- public ListBox LbAvailableRoles;
- public ListBox LbAssignedRoles;
-
- private string _userName = string.Empty;
-
- public static string GetOpenWindowString(string userName)
- {
- return LayerUtils.GetOpenScript("权限设置",
- PageUtils.GetSettingsUrl(nameof(ModalPermissionsSet), new NameValueCollection
- {
- {"UserName", userName}
- }));
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _userName = AuthRequest.GetQueryString("UserName");
-
- if (IsPostBack) return;
-
- var roles = DataProvider.AdministratorsInRolesDao.GetRolesForUser(_userName);
- if (AuthRequest.AdminPermissions.IsConsoleAdministrator)
- {
- DdlPredefinedRole.Items.Add(EPredefinedRoleUtils.GetListItem(EPredefinedRole.ConsoleAdministrator, false));
- DdlPredefinedRole.Items.Add(EPredefinedRoleUtils.GetListItem(EPredefinedRole.SystemAdministrator, false));
- }
- DdlPredefinedRole.Items.Add(EPredefinedRoleUtils.GetListItem(EPredefinedRole.Administrator, false));
-
- var type = EPredefinedRoleUtils.GetEnumTypeByRoles(roles);
- ControlUtils.SelectSingleItem(DdlPredefinedRole, EPredefinedRoleUtils.GetValue(type));
-
- SiteManager.AddListItems(CblSiteId);
- ControlUtils.SelectMultiItems(CblSiteId, DataProvider.AdministratorDao.GetSiteIdList(_userName));
-
- ListBoxDataBind();
-
- DdlPredefinedRole_SelectedIndexChanged(null, EventArgs.Empty);
- }
-
- public void DdlPredefinedRole_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (EPredefinedRoleUtils.Equals(EPredefinedRole.ConsoleAdministrator, DdlPredefinedRole.SelectedValue))
- {
- PhRoles.Visible = PhSiteId.Visible = false;
- }
- else if (EPredefinedRoleUtils.Equals(EPredefinedRole.SystemAdministrator, DdlPredefinedRole.SelectedValue))
- {
- PhRoles.Visible = false;
- PhSiteId.Visible = true;
- }
- else
- {
- PhRoles.Visible = true;
- PhSiteId.Visible = false;
- }
- }
-
- private void ListBoxDataBind()
- {
- LbAvailableRoles.Items.Clear();
- LbAssignedRoles.Items.Clear();
- var allRoles = AuthRequest.AdminPermissions.IsConsoleAdministrator ? DataProvider.RoleDao.GetAllRoles() : DataProvider.RoleDao.GetAllRolesByCreatorUserName(AuthRequest.AdminName);
- var userRoles = DataProvider.AdministratorsInRolesDao.GetRolesForUser(_userName);
- var userRoleNameArrayList = new ArrayList(userRoles);
- foreach (var roleName in allRoles)
- {
- if (!EPredefinedRoleUtils.IsPredefinedRole(roleName) && !userRoleNameArrayList.Contains(roleName))
- {
- LbAvailableRoles.Items.Add(new ListItem(roleName, roleName));
- }
- }
- foreach (var roleName in userRoles)
- {
- if (!EPredefinedRoleUtils.IsPredefinedRole(roleName))
- {
- LbAssignedRoles.Items.Add(new ListItem(roleName, roleName));
- }
- }
- }
-
- public void AddRole_OnClick(object sender, EventArgs e)
- {
- if (!IsPostBack || !IsValid) return;
-
- try
- {
- if (LbAvailableRoles.SelectedIndex != -1)
- {
- var selectedRoles = ControlUtils.GetSelectedListControlValueArray(LbAvailableRoles);
- if (selectedRoles.Length > 0)
- {
- DataProvider.AdministratorsInRolesDao.AddUserToRoles(_userName, selectedRoles);
- }
- }
- ListBoxDataBind();
- }
- catch (Exception ex)
- {
- FailMessage(ex, "用户角色分配失败");
- }
- }
-
- public void AddRoles_OnClick(object sender, EventArgs e)
- {
- if (!IsPostBack || !IsValid) return;
-
- try
- {
- var roles = ControlUtils.GetListControlValues(LbAvailableRoles);
- if (roles.Length > 0)
- {
- DataProvider.AdministratorsInRolesDao.AddUserToRoles(_userName, roles);
- }
- ListBoxDataBind();
- }
- catch (Exception ex)
- {
- FailMessage(ex, "用户角色分配失败");
- }
- }
-
- public void DeleteRole_OnClick(object sender, EventArgs e)
- {
- if (!IsPostBack || !IsValid) return;
-
- try
- {
- if (LbAssignedRoles.SelectedIndex != -1)
- {
- var selectedRoles = ControlUtils.GetSelectedListControlValueArray(LbAssignedRoles);
- DataProvider.AdministratorsInRolesDao.RemoveUserFromRoles(_userName, selectedRoles);
- }
- ListBoxDataBind();
- }
- catch (Exception ex)
- {
- FailMessage(ex, "用户角色分配失败");
- }
- }
-
- public void DeleteRoles_OnClick(object sender, EventArgs e)
- {
- if (!IsPostBack || !IsValid) return;
-
- try
- {
- var roles = ControlUtils.GetListControlValues(LbAssignedRoles);
- if (roles.Length > 0)
- {
- DataProvider.AdministratorsInRolesDao.RemoveUserFromRoles(_userName, roles);
- }
- ListBoxDataBind();
- }
- catch (Exception ex)
- {
- FailMessage(ex, "用户角色分配失败");
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- try
- {
- var allRoles = EPredefinedRoleUtils.GetAllPredefinedRoleName();
- foreach (var roleName in allRoles)
- {
- DataProvider.AdministratorsInRolesDao.RemoveUserFromRole(_userName, roleName);
- }
- DataProvider.AdministratorsInRolesDao.AddUserToRole(_userName, DdlPredefinedRole.SelectedValue);
-
- DataProvider.AdministratorDao.UpdateSiteIdCollection(_userName,
- EPredefinedRoleUtils.Equals(EPredefinedRole.SystemAdministrator, DdlPredefinedRole.SelectedValue)
- ? ControlUtils.SelectedItemsValueToStringCollection(CblSiteId.Items)
- : string.Empty);
-
- AuthRequest.AddAdminLog("设置管理员权限", $"管理员:{_userName}");
-
- SuccessMessage("权限设置成功!");
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, "权限设置失败!");
- }
-
- if (isChanged)
- {
- var redirectUrl = PageAdministrator.GetRedirectUrl();
- LayerUtils.CloseAndRedirect(Page, redirectUrl);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.BackgroundPages/Settings/ModalTableMetadataAdd.cs b/SiteServer.BackgroundPages/Settings/ModalTableMetadataAdd.cs
deleted file mode 100644
index 0c015c542..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalTableMetadataAdd.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Plugin;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalTableMetadataAdd : BasePageCms
- {
- public TextBox TbAttributeName;
- public DropDownList DdlDataType;
- public PlaceHolder PhDataLength;
- public TextBox TbDataLength;
-
- private string _tableName;
-
- public static string GetOpenWindowStringToAdd(string tableName)
- {
- return LayerUtils.GetOpenScript("添加辅助表字段", PageUtils.GetSettingsUrl(nameof(ModalTableMetadataAdd), new NameValueCollection
- {
- {"TableName", tableName}
- }), 600, 320);
- }
-
- public static string GetOpenWindowStringToEdit(string tableName, int tableMetadataId)
- {
- return LayerUtils.GetOpenScript("修改辅助表字段", PageUtils.GetSettingsUrl(nameof(ModalTableMetadataAdd), new NameValueCollection
- {
- {"TableName", tableName},
- {"TableMetadataID", tableMetadataId.ToString()}
- }), 600, 320);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("TableName");
-
- _tableName = AuthRequest.GetQueryString("TableName");
-
- if (IsPostBack) return;
-
- DataTypeUtils.AddListItems(DdlDataType);
-
- if (AuthRequest.IsQueryExists("TableMetadataID"))
- {
- var tableMetadataId = AuthRequest.GetQueryInt("TableMetadataID");
- var info = DataProvider.TableMetadataDao.GetTableMetadataInfo(tableMetadataId);
- if (info != null)
- {
- TbAttributeName.Text = info.AttributeName;
- TbAttributeName.Enabled = false;
- ControlUtils.SelectSingleItemIgnoreCase(DdlDataType, info.DataType.ToString());
- TbDataLength.Text = info.DataLength.ToString();
- }
- }
- }
-
- public void DdlDataType_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhDataLength.Visible = DataTypeUtils.GetEnumType(DdlDataType.SelectedValue) == DataType.VarChar;
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- var isChanged = false;
-
- if (AuthRequest.IsQueryExists("TableMetadataID"))
- {
- var tableMetadataId = AuthRequest.GetQueryInt("TableMetadataID");
-
- var info = DataProvider.TableMetadataDao.GetTableMetadataInfo(tableMetadataId);
- info.TableName = _tableName;
- info.AttributeName = TbAttributeName.Text;
- info.DataType = DataTypeUtils.GetEnumType(DdlDataType.SelectedValue);
-
- if (info.DataType == DataType.VarChar)
- {
- info.DataLength = TranslateUtils.ToInt(TbDataLength.Text);
- var maxLength = SqlUtils.GetMaxLengthForNVarChar();
- if (info.DataLength <= 0 || info.DataLength > maxLength)
- {
- FailMessage($"字段修改失败,数据长度的值必须位于 1 和 {maxLength} 之间");
- return;
- }
- }
-
- try
- {
- DataProvider.TableMetadataDao.Update(info);
-
- AuthRequest.AddAdminLog("修改辅助表字段",
- $"辅助表:{_tableName},字段名:{info.AttributeName}");
-
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, ex.Message);
- }
- }
- else
- {
- var attributeNameList = TableMetadataManager.GetAttributeNameList(_tableName, true);
-
- var attributeNameLowercase = TbAttributeName.Text.Trim().ToLower();
- if (attributeNameList.Contains(attributeNameLowercase) || ContentAttribute.AllAttributesLowercase.Contains(attributeNameLowercase))
- {
- FailMessage("字段添加失败,字段名已存在!");
- }
- else if (!SqlUtils.IsAttributeNameCompliant(TbAttributeName.Text))
- {
- FailMessage("字段名不符合系统要求!");
- }
- else
- {
- var info = new TableMetadataInfo
- {
- TableName = _tableName,
- AttributeName = TbAttributeName.Text,
- DataType = DataTypeUtils.GetEnumType(DdlDataType.SelectedValue)
- };
-
- if (info.DataType == DataType.VarChar)
- {
- info.DataLength = TranslateUtils.ToInt(TbDataLength.Text);
- var maxLength = SqlUtils.GetMaxLengthForNVarChar();
- if (info.DataLength <= 0 || info.DataLength > maxLength)
- {
- FailMessage($"字段修改失败,数据长度的值必须位于 1 和 {maxLength} 之间");
- return;
- }
- }
- info.IsSystem = false;
-
- try
- {
- DataProvider.TableMetadataDao.Insert(info);
-
- AuthRequest.AddAdminLog("添加辅助表字段",
- $"辅助表:{_tableName},字段名:{info.AttributeName}");
-
- isChanged = true;
- }
- catch (Exception ex)
- {
- FailMessage(ex, ex.Message);
- }
- }
- }
-
- if (isChanged)
- {
- LayerUtils.Close(Page);
- }
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/ModalUserView.cs b/SiteServer.BackgroundPages/Settings/ModalUserView.cs
deleted file mode 100644
index 225f3584e..000000000
--- a/SiteServer.BackgroundPages/Settings/ModalUserView.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class ModalUserView : BasePage
- {
- protected Literal LtlUserName;
- protected Literal LtlDisplayName;
- protected Literal LtlCreateDate;
- protected Literal LtlLastResetPasswordDate;
- protected Literal LtlLastActivityDate;
- protected Literal LtlEmail;
- protected Literal LtlMobile;
- protected Literal LtlLoginCount;
- protected Literal LtlWritingCount;
- protected Literal LtlOrganization;
- protected Literal LtlDepartment;
- protected Literal LtlPosition;
- protected Literal LtlGender;
- protected Literal LtlBirthday;
- protected Literal LtlEducation;
- protected Literal LtlGraduation;
- protected Literal LtlAddress;
- protected Literal LtlWeiXin;
- protected Literal LtlQq;
- protected Literal LtlWeiBo;
- protected Literal LtlInterests;
- protected Literal LtlSignature;
-
- private UserInfo _userInfo;
-
- public static string GetOpenWindowString(string userName)
- {
- return LayerUtils.GetOpenScript("查看用户信息", PageUtils.GetSettingsUrl(nameof(ModalUserView), new NameValueCollection
- {
- {"UserName", userName}
- }), 700, 560);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- var userName = Request.QueryString["UserName"];
- _userInfo = DataProvider.UserDao.GetUserInfoByAccount(userName);
-
- LtlUserName.Text = _userInfo.UserName;
- LtlDisplayName.Text = _userInfo.DisplayName;
- LtlCreateDate.Text = DateUtils.GetDateAndTimeString(_userInfo.CreateDate);
- LtlLastActivityDate.Text = DateUtils.GetDateAndTimeString(_userInfo.LastActivityDate);
- LtlLastResetPasswordDate.Text = DateUtils.GetDateAndTimeString(_userInfo.LastResetPasswordDate);
- LtlEmail.Text = _userInfo.Email;
- LtlMobile.Text = _userInfo.Mobile;
- LtlLoginCount.Text = _userInfo.CountOfLogin.ToString();
- LtlWritingCount.Text = _userInfo.CountOfWriting.ToString();
- LtlOrganization.Text = _userInfo.Organization;
- LtlDepartment.Text = _userInfo.Department;
- LtlPosition.Text = _userInfo.Position;
- LtlGender.Text = _userInfo.Gender;
- LtlBirthday.Text = _userInfo.Birthday;
- LtlEducation.Text = _userInfo.Education;
- LtlGraduation.Text = _userInfo.Graduation;
- LtlAddress.Text = _userInfo.Address;
- LtlWeiXin.Text = _userInfo.WeiXin;
- LtlQq.Text = _userInfo.Qq;
- LtlWeiBo.Text = _userInfo.WeiBo;
- LtlInterests.Text = _userInfo.Interests;
- LtlSignature.Text = _userInfo.Signature;
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageAdminConfiguration.cs b/SiteServer.BackgroundPages/Settings/PageAdminConfiguration.cs
deleted file mode 100644
index 89a05168f..000000000
--- a/SiteServer.BackgroundPages/Settings/PageAdminConfiguration.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageAdminConfiguration : BasePage
- {
- public TextBox TbLoginUserNameMinLength;
- public TextBox TbLoginPasswordMinLength;
- public DropDownList DdlLoginPasswordRestriction;
-
- public RadioButtonList RblIsLoginFailToLock;
- public PlaceHolder PhFailToLock;
- public TextBox TbLoginFailToLockCount;
- public DropDownList DdlLoginLockingType;
- public PlaceHolder PhLoginLockingHours;
- public TextBox TbLoginLockingHours;
-
- public RadioButtonList RblIsFindPassword;
- public PlaceHolder PhFindPassword;
- public TextBox TbFindPasswordSmsTplId;
-
- public RadioButtonList RblIsViewContentOnlySelf;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Admin);
-
- TbLoginUserNameMinLength.Text = ConfigManager.SystemConfigInfo.AdminUserNameMinLength.ToString();
- TbLoginPasswordMinLength.Text = ConfigManager.SystemConfigInfo.AdminPasswordMinLength.ToString();
- EUserPasswordRestrictionUtils.AddListItems(DdlLoginPasswordRestriction);
- ControlUtils.SelectSingleItemIgnoreCase(DdlLoginPasswordRestriction, ConfigManager.SystemConfigInfo.AdminPasswordRestriction);
-
- EBooleanUtils.AddListItems(RblIsLoginFailToLock, "是", "否");
- ControlUtils.SelectSingleItemIgnoreCase(RblIsLoginFailToLock, ConfigManager.SystemConfigInfo.IsAdminLockLogin.ToString());
-
- PhFailToLock.Visible = ConfigManager.SystemConfigInfo.IsAdminLockLogin;
-
- TbLoginFailToLockCount.Text = ConfigManager.SystemConfigInfo.AdminLockLoginCount.ToString();
-
- DdlLoginLockingType.Items.Add(new ListItem("按小时锁定", EUserLockTypeUtils.GetValue(EUserLockType.Hours)));
- DdlLoginLockingType.Items.Add(new ListItem("永久锁定", EUserLockTypeUtils.GetValue(EUserLockType.Forever)));
- ControlUtils.SelectSingleItemIgnoreCase(DdlLoginLockingType, ConfigManager.SystemConfigInfo.AdminLockLoginType);
-
- PhLoginLockingHours.Visible = false;
- if (!EUserLockTypeUtils.Equals(ConfigManager.SystemConfigInfo.AdminLockLoginType, EUserLockType.Forever))
- {
- PhLoginLockingHours.Visible = true;
- TbLoginLockingHours.Text = ConfigManager.SystemConfigInfo.AdminLockLoginHours.ToString();
- }
-
- EBooleanUtils.AddListItems(RblIsFindPassword, "启用", "禁用");
- ControlUtils.SelectSingleItemIgnoreCase(RblIsFindPassword, ConfigManager.SystemConfigInfo.IsAdminFindPassword.ToString());
- PhFindPassword.Visible = ConfigManager.SystemConfigInfo.IsAdminFindPassword;
- TbFindPasswordSmsTplId.Text = ConfigManager.SystemConfigInfo.AdminFindPasswordSmsTplId;
-
- EBooleanUtils.AddListItems(RblIsViewContentOnlySelf, "不可以", "可以");
- ControlUtils.SelectSingleItemIgnoreCase(RblIsViewContentOnlySelf, ConfigManager.SystemConfigInfo.IsViewContentOnlySelf.ToString());
- }
-
- public void RblIsLoginFailToLock_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhFailToLock.Visible = TranslateUtils.ToBool(RblIsLoginFailToLock.SelectedValue);
- }
-
- public void DdlLoginLockingType_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhLoginLockingHours.Visible = !EUserLockTypeUtils.Equals(EUserLockType.Forever, DdlLoginLockingType.SelectedValue);
- }
-
- public void RblIsFindPassword_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhFindPassword.Visible = TranslateUtils.ToBool(RblIsFindPassword.SelectedValue);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- try
- {
- ConfigManager.SystemConfigInfo.AdminUserNameMinLength = TranslateUtils.ToInt(TbLoginUserNameMinLength.Text);
- ConfigManager.SystemConfigInfo.AdminPasswordMinLength = TranslateUtils.ToInt(TbLoginPasswordMinLength.Text);
- ConfigManager.SystemConfigInfo.AdminPasswordRestriction = DdlLoginPasswordRestriction.SelectedValue;
-
- ConfigManager.SystemConfigInfo.IsAdminLockLogin = TranslateUtils.ToBool(RblIsLoginFailToLock.SelectedValue);
- ConfigManager.SystemConfigInfo.AdminLockLoginCount = TranslateUtils.ToInt(TbLoginFailToLockCount.Text, 3);
- ConfigManager.SystemConfigInfo.AdminLockLoginType = DdlLoginLockingType.SelectedValue;
- ConfigManager.SystemConfigInfo.AdminLockLoginHours = TranslateUtils.ToInt(TbLoginLockingHours.Text);
-
- ConfigManager.SystemConfigInfo.IsAdminFindPassword = TranslateUtils.ToBool(RblIsFindPassword.SelectedValue);
- ConfigManager.SystemConfigInfo.AdminFindPasswordSmsTplId = TbFindPasswordSmsTplId.Text;
-
- ConfigManager.SystemConfigInfo.IsViewContentOnlySelf = TranslateUtils.ToBool(RblIsViewContentOnlySelf.SelectedValue);
-
- DataProvider.ConfigDao.Update(ConfigManager.Instance);
-
- AuthRequest.AddAdminLog("管理员设置");
- SuccessMessage("管理员设置成功");
- }
- catch (Exception ex)
- {
- FailMessage(ex, ex.Message);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageAdminPermissionAdd.cs b/SiteServer.BackgroundPages/Settings/PageAdminPermissionAdd.cs
deleted file mode 100644
index 76ee71f11..000000000
Binary files a/SiteServer.BackgroundPages/Settings/PageAdminPermissionAdd.cs and /dev/null differ
diff --git a/SiteServer.BackgroundPages/Settings/PageAdminRole.cs b/SiteServer.BackgroundPages/Settings/PageAdminRole.cs
deleted file mode 100644
index 08634c913..000000000
--- a/SiteServer.BackgroundPages/Settings/PageAdminRole.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageAdminRole : BasePage
- {
- public Repeater RptContents;
- public Button BtnAdd;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageAdminRole), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var roleName = AuthRequest.GetQueryString("RoleName");
- try
- {
- DataProvider.PermissionsInRolesDao.Delete(roleName);
- DataProvider.RoleDao.DeleteRole(roleName);
-
- AuthRequest.AddAdminLog("删除管理员角色", $"角色名称:{roleName}");
-
- SuccessDeleteMessage();
- }
- catch(Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Admin);
-
- RptContents.DataSource = AuthRequest.AdminPermissions.IsConsoleAdministrator
- ? DataProvider.RoleDao.GetAllRoles()
- : DataProvider.RoleDao.GetAllRolesByCreatorUserName(AuthRequest.AdminName);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- BtnAdd.Attributes.Add("onclick", $"location.href = '{PageAdminRoleAdd.GetRedirectUrl()}';return false;");
- }
-
- private static void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var roleName = (string)e.Item.DataItem;
- e.Item.Visible = !EPredefinedRoleUtils.IsPredefinedRole(roleName);
-
- var ltlRoleName = (Literal) e.Item.FindControl("ltlRoleName");
- var ltlDescription = (Literal)e.Item.FindControl("ltlDescription");
- var ltlEdit = (Literal)e.Item.FindControl("ltlEdit");
- var ltlDelete = (Literal)e.Item.FindControl("ltlDelete");
-
- ltlRoleName.Text = roleName;
- ltlDescription.Text = DataProvider.RoleDao.GetRoleDescription(roleName);
- ltlEdit.Text = $@"修改 ";
- ltlDelete.Text = $@"删除 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageAdministrator.cs b/SiteServer.BackgroundPages/Settings/PageAdministrator.cs
deleted file mode 100644
index 08eed7618..000000000
--- a/SiteServer.BackgroundPages/Settings/PageAdministrator.cs
+++ /dev/null
@@ -1,329 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageAdministrator : BasePage
- {
- public DropDownList DdlRoleName;
- public DropDownList DdlPageNum;
- public DropDownList DdlOrder;
- public DropDownList DdlLastActivityDate;
- public DropDownList DdlDepartmentId;
- public DropDownList DdlAreaId;
- public TextBox TbKeyword;
-
- public Repeater RptContents;
- public SqlPager SpContents;
-
- public Button BtnAdd;
- public Button BtnLock;
- public Button BtnUnLock;
- public Button BtnDelete;
-
- private bool[] _isLastNodeArrayOfDepartment;
- private bool[] _isLastNodeArrayOfArea;
- private EUserLockType _lockType = EUserLockType.Forever;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageAdministrator), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- var departmentId = AuthRequest.GetQueryInt("departmentId");
- var areaId = AuthRequest.GetQueryInt("areaId");
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var userNameCollection = AuthRequest.GetQueryString("UserNameCollection");
- try
- {
- var userNameArrayList = TranslateUtils.StringCollectionToStringList(userNameCollection);
- foreach (var userName in userNameArrayList)
- {
- DataProvider.AdministratorDao.Delete(userName);
- }
-
- AuthRequest.AddAdminLog("删除管理员", $"管理员:{userNameCollection}");
-
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- else if (AuthRequest.IsQueryExists("Lock"))
- {
- var userNameCollection = AuthRequest.GetQueryString("UserNameCollection");
- try
- {
- var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
- DataProvider.AdministratorDao.Lock(userNameList);
-
- AuthRequest.AddAdminLog("锁定管理员", $"管理员:{userNameCollection}");
-
- SuccessMessage("成功锁定所选管理员!");
- }
- catch (Exception ex)
- {
- FailMessage(ex, "锁定所选管理员失败!");
- }
- }
- else if (AuthRequest.IsQueryExists("UnLock"))
- {
- var userNameCollection = AuthRequest.GetQueryString("UserNameCollection");
- try
- {
- var userNameList = TranslateUtils.StringCollectionToStringList(userNameCollection);
- DataProvider.AdministratorDao.UnLock(userNameList);
-
- AuthRequest.AddAdminLog("解除锁定管理员", $"管理员:{userNameCollection}");
-
- SuccessMessage("成功解除锁定所选管理员!");
- }
- catch (Exception ex)
- {
- FailMessage(ex, "解除锁定所选管理员失败!");
- }
- }
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = StringUtils.Constants.PageSize;
-
- if (string.IsNullOrEmpty(AuthRequest.GetQueryString("pageNum")))
- {
- SpContents.ItemsPerPage = TranslateUtils.ToInt(DdlPageNum.SelectedValue) == 0 ? StringUtils.Constants.PageSize : TranslateUtils.ToInt(DdlPageNum.SelectedValue);
-
- SpContents.SelectCommand = DataProvider.AdministratorDao.GetSelectCommand(AuthRequest.AdminPermissions.IsConsoleAdministrator, AuthRequest.AdminName);
- SpContents.SortField = DataProvider.AdministratorDao.GetSortFieldName();
- SpContents.SortMode = SortMode.ASC;
- }
- else
- {
- SpContents.ItemsPerPage = AuthRequest.GetQueryInt("pageNum") == 0 ? StringUtils.Constants.PageSize : AuthRequest.GetQueryInt("pageNum");
- SpContents.SelectCommand = DataProvider.AdministratorDao.GetSelectCommand(AuthRequest.GetQueryString("keyword"), AuthRequest.GetQueryString("roleName"), AuthRequest.GetQueryInt("lastActivityDate"), AuthRequest.AdminPermissions.IsConsoleAdministrator, AuthRequest.AdminName, AuthRequest.GetQueryInt("departmentId"), AuthRequest.GetQueryInt("areaId"));
- SpContents.SortField = AuthRequest.GetQueryString("order");
- SpContents.SortMode = StringUtils.EqualsIgnoreCase(SpContents.SortField, nameof(AdministratorInfo.UserName)) ? SortMode.ASC : SortMode.DESC;
- }
-
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- _lockType = EUserLockTypeUtils.GetEnumType(ConfigManager.SystemConfigInfo.AdminLockLoginType);
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Admin);
-
- var theListItem = new ListItem("全部", string.Empty)
- {
- Selected = true
- };
- DdlRoleName.Items.Add(theListItem);
-
- var allRoles = AuthRequest.AdminPermissions.IsConsoleAdministrator ? DataProvider.RoleDao.GetAllRoles() : DataProvider.RoleDao.GetAllRolesByCreatorUserName(AuthRequest.AdminName);
-
- var allPredefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRoleName();
- foreach (var roleName in allRoles)
- {
- if (allPredefinedRoles.Contains(roleName))
- {
- var listitem = new ListItem(EPredefinedRoleUtils.GetText(EPredefinedRoleUtils.GetEnumType(roleName)), roleName);
- DdlRoleName.Items.Add(listitem);
- }
- }
- foreach (var roleName in allRoles)
- {
- if (!allPredefinedRoles.Contains(roleName))
- {
- var listitem = new ListItem(roleName, roleName);
- DdlRoleName.Items.Add(listitem);
- }
- }
-
- DdlDepartmentId.Items.Add(new ListItem("<所有部门>", "0"));
- var departmentIdList = DepartmentManager.GetDepartmentIdList();
- var count = departmentIdList.Count;
- _isLastNodeArrayOfDepartment = new bool[count];
- foreach (var theDepartmentId in departmentIdList)
- {
- var departmentInfo = DepartmentManager.GetDepartmentInfo(theDepartmentId);
- DdlDepartmentId.Items.Add(new ListItem(GetTreeItem(departmentInfo.Id, departmentInfo.DepartmentName, departmentInfo.ParentsCount, departmentInfo.IsLastNode, _isLastNodeArrayOfDepartment), theDepartmentId.ToString()));
- }
- ControlUtils.SelectSingleItem(DdlDepartmentId, departmentId.ToString());
-
- DdlAreaId.Items.Add(new ListItem("<全部区域>", "0"));
- var areaIdList = AreaManager.GetAreaIdList();
- count = areaIdList.Count;
- _isLastNodeArrayOfArea = new bool[count];
- foreach (var theAreaId in areaIdList)
- {
- var areaInfo = AreaManager.GetAreaInfo(theAreaId);
- DdlAreaId.Items.Add(new ListItem(GetTreeItem(areaInfo.Id, areaInfo.AreaName, areaInfo.ParentsCount, areaInfo.IsLastNode, _isLastNodeArrayOfArea), theAreaId.ToString()));
- }
- ControlUtils.SelectSingleItem(DdlAreaId, areaId.ToString());
-
- if (AuthRequest.IsQueryExists("pageNum"))
- {
- ControlUtils.SelectSingleItem(DdlRoleName, AuthRequest.GetQueryString("roleName"));
- ControlUtils.SelectSingleItem(DdlPageNum, AuthRequest.GetQueryString("pageNum"));
- TbKeyword.Text = AuthRequest.GetQueryString("keyword");
- ControlUtils.SelectSingleItem(DdlDepartmentId, AuthRequest.GetQueryString("departmentId"));
- ControlUtils.SelectSingleItem(DdlAreaId, AuthRequest.GetQueryString("areaId"));
- ControlUtils.SelectSingleItem(DdlLastActivityDate, AuthRequest.GetQueryString("lastActivityDate"));
- ControlUtils.SelectSingleItem(DdlOrder, AuthRequest.GetQueryString("order"));
- }
-
- BtnAdd.Attributes.Add("onclick", $@"location.href='{PageAdministratorAdd.GetRedirectUrlToAdd(departmentId)}';return false;");
-
- var urlAdministrator = GetRedirectUrl();
-
- BtnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?Lock=True", "UserNameCollection", "UserNameCollection", "请选择需要锁定的管理员!", "此操作将锁定所选管理员,确认吗?"));
-
- BtnUnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?UnLock=True", "UserNameCollection", "UserNameCollection", "请选择需要解除锁定的管理员!", "此操作将解除锁定所选管理员,确认吗?"));
-
- BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlAdministrator + "?Delete=True", "UserNameCollection", "UserNameCollection", "请选择需要删除的管理员!", "此操作将删除所选管理员,确认吗?"));
-
- SpContents.DataBind();
- }
-
- public string GetTreeItem(int areaId, string areaName, int parentsCount, bool isLastNode, bool[] array)
- {
- var str = "";
- if (isLastNode == false)
- {
- array[parentsCount] = false;
- }
- else
- {
- array[parentsCount] = true;
- }
- for (var i = 0; i < parentsCount; i++)
- {
- str = string.Concat(str, array[i] ? " " : "│");
- }
- str = string.Concat(str, isLastNode ? "└" : "├");
- str = string.Concat(str, areaName);
- return str;
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var userName = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.UserName));
- var displayName = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.DisplayName));
- var mobile = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.Mobile));
- var departmentId = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.DepartmentId));
- var areaId = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.AreaId));
- if (string.IsNullOrEmpty(displayName))
- {
- displayName = userName;
- }
- var countOfFailedLogin = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.CountOfFailedLogin));
- var countOfLogin = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.CountOfLogin));
- var isLockedOut = SqlUtils.EvalBool(e.Item.DataItem, nameof(AdministratorInfo.IsLockedOut));
- var lastActivityDate = SqlUtils.EvalDateTime(e.Item.DataItem, nameof(AdministratorInfo.LastActivityDate));
-
- var ltlUserName = (Literal)e.Item.FindControl("ltlUserName");
- var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName");
- var ltlMobile = (Literal)e.Item.FindControl("ltlMobile");
- var ltlDepartment = (Literal)e.Item.FindControl("ltlDepartment");
- var ltlArea = (Literal)e.Item.FindControl("ltlArea");
- var ltlLastActivityDate = (Literal)e.Item.FindControl("ltlLastActivityDate");
- var ltlCountOfLogin = (Literal)e.Item.FindControl("ltlCountOfLogin");
- var ltlRoles = (Literal)e.Item.FindControl("ltlRoles");
- var ltlEdit = (Literal)e.Item.FindControl("ltlEdit");
- var hlChangePassword = (HyperLink)e.Item.FindControl("hlChangePassword");
- var ltlRole = (Literal)e.Item.FindControl("ltlRole");
- var ltlSelect = (Literal)e.Item.FindControl("ltlSelect");
-
- ltlUserName.Text = GetUserNameHtml(userName, countOfFailedLogin, isLockedOut, lastActivityDate);
- ltlDisplayName.Text = displayName;
- ltlMobile.Text = mobile;
- ltlDepartment.Text = DepartmentManager.GetDepartmentName(departmentId);
- ltlArea.Text = AreaManager.GetAreaName(areaId);
-
- ltlLastActivityDate.Text = GetDateTime(lastActivityDate);
- ltlCountOfLogin.Text = countOfLogin.ToString();
- ltlRoles.Text = AdminManager.GetRolesHtml(userName);
-
- var urlEdit = PageAdministratorAdd.GetRedirectUrlToEdit(departmentId, userName);
- ltlEdit.Text = $@"修改属性 ";
- hlChangePassword.Attributes.Add("onclick", ModalAdminPassword.GetOpenWindowString(userName));
-
- if (AuthRequest.AdminName != userName)
- {
- var openWindowString = ModalPermissionsSet.GetOpenWindowString(userName);
- ltlRole.Text = $@"权限设置 ";
- ltlSelect.Text = $@" ";
- }
- }
-
- private static string GetDateTime(DateTime datetime)
- {
- var retval = string.Empty;
- if (datetime > DateUtils.SqlMinValue)
- {
- retval = DateUtils.GetDateString(datetime);
- }
- return retval;
- }
-
- private string GetUserNameHtml(string userName, int countOfFailedLogin, bool isLockedOut, DateTime lastActivityDate)
- {
- var showPopWinString = ModalAdminView.GetOpenWindowString(userName);
- var state = string.Empty;
- if (isLockedOut)
- {
- state = @"[已被锁定] ";
- }
- else if (ConfigManager.SystemConfigInfo.IsAdminLockLogin &&
- ConfigManager.SystemConfigInfo.AdminLockLoginCount <= countOfFailedLogin)
- {
- if (_lockType == EUserLockType.Forever)
- {
- state = @"[已被锁定] ";
- }
- else
- {
- var ts = new TimeSpan(DateTime.Now.Ticks - lastActivityDate.Ticks);
- var hours = Convert.ToInt32(ConfigManager.SystemConfigInfo.AdminLockLoginHours - ts.TotalHours);
- if (hours > 0)
- {
- state = $@"[错误登录次数过多,已被锁定{hours}小时] ";
- }
- }
- }
- return $@"{userName} {state}";
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUrl);
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl = $"{GetRedirectUrl()}?roleName={DdlRoleName.SelectedValue}&pageNum={DdlPageNum.SelectedValue}&keyword={TbKeyword.Text}&departmentId={DdlDepartmentId.SelectedValue}&areaId={DdlAreaId.SelectedValue}&lastActivityDate={DdlLastActivityDate.SelectedValue}&order={DdlOrder.SelectedValue}";
- }
- return _pageUrl;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageAnalysisSiteDownloads.cs b/SiteServer.BackgroundPages/Settings/PageAnalysisSiteDownloads.cs
deleted file mode 100644
index 80677d587..000000000
--- a/SiteServer.BackgroundPages/Settings/PageAnalysisSiteDownloads.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageAnalysisSiteDownloads : BasePageCms
- {
- public DropDownList DdlSiteId;
- public Repeater RptContents;
- public Literal LtlTotalNum;
-
- public string StrArray { get; set; }
-
- private readonly Hashtable _horizentalHashtable = new Hashtable();
- private readonly Hashtable _verticalHashtable = new Hashtable();
- private readonly List _siteIdList = new List();
- private readonly Hashtable _xHashtable = new Hashtable();
- private readonly Hashtable _yHashtableDownload = new Hashtable();
- private const string YTypeDownload = "YType_Download";
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageAnalysisSiteDownloads), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Chart);
-
- DdlSiteId.Items.Add(new ListItem("<<全部站点>>", "0"));
- var siteIdList = SiteManager.GetSiteIdListOrderByLevel();
- foreach (var siteId in siteIdList)
- {
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- DdlSiteId.Items.Add(new ListItem(siteInfo.SiteName, siteId.ToString()));
-
- var key = siteInfo.Id;
- //x轴信息
- SetXHashtable(key, siteInfo.SiteName);
- //y轴信息
- SetYHashtable(key, CountManager.GetCount(siteInfo.TableName, siteInfo.Id, ECountType.Download));
- }
-
- RptContents.DataSource = siteIdList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- foreach (var key in _siteIdList)
- {
- var yValueDownload = GetYHashtable(key);
- if (yValueDownload != "0")
- {
- StrArray += $@"
-xArrayDownload.push('{GetXHashtable(key)}');
- yArrayDownload.push('{yValueDownload}');";
- }
- }
- LtlTotalNum.Text = GetVerticalTotalNum();
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var siteId = (int) e.Item.DataItem;
-
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- var ltlSiteName = (Literal)e.Item.FindControl("ltlSiteName");
- var ltlDownloadNum = (Literal)e.Item.FindControl("ltlDownloadNum");
-
- ltlSiteName.Text = $@"{siteInfo.SiteName} ";
- ltlDownloadNum.Text = GetYHashtable(siteId);
- }
-
- public void Analysis_OnClick(object sender, EventArgs e)
- {
- var siteId = TranslateUtils.ToInt(DdlSiteId.SelectedValue);
- PageUtils.Redirect(siteId > 0
- ? PageAnalysisSiteDownloadsChannels.GetRedirectUrl(siteId)
- : GetRedirectUrl());
- }
-
- private void SetXHashtable(int siteId, string siteName)
- {
- if (!_xHashtable.ContainsKey(siteId))
- {
- _xHashtable.Add(siteId, siteName);
- }
- if (!_siteIdList.Contains(siteId))
- {
- _siteIdList.Add(siteId);
- }
- _siteIdList.Sort();
- _siteIdList.Reverse();
- }
-
- private string GetXHashtable(int siteId)
- {
- return _xHashtable.ContainsKey(siteId) ? _xHashtable[siteId].ToString() : string.Empty;
- }
-
- private void SetYHashtable(int publishemtSystemId, int value)
- {
-
- if (!_yHashtableDownload.ContainsKey(publishemtSystemId))
- {
- _yHashtableDownload.Add(publishemtSystemId, value);
- }
- else
- {
- var num = TranslateUtils.ToInt(_yHashtableDownload[publishemtSystemId].ToString());
- _yHashtableDownload[publishemtSystemId] = num + value;
- }
- SetVertical(YTypeDownload, value);
-
- SetHorizental(publishemtSystemId, value);
- }
-
- private string GetYHashtable(int publishemtSystemId)
- {
- if (!_yHashtableDownload.ContainsKey(publishemtSystemId)) return "0";
- var num = TranslateUtils.ToInt(_yHashtableDownload[publishemtSystemId].ToString());
- return num.ToString();
- }
-
- private void SetHorizental(int siteId, int num)
- {
- if (_horizentalHashtable[siteId] == null)
- {
- _horizentalHashtable[siteId] = num;
- }
- else
- {
- var totalNum = (int)_horizentalHashtable[siteId];
- _horizentalHashtable[siteId] = totalNum + num;
- }
- }
-
- private void SetVertical(string type, int num)
- {
- if (_verticalHashtable[type] == null)
- {
- _verticalHashtable[type] = num;
- }
- else
- {
- var totalNum = (int)_verticalHashtable[type];
- _verticalHashtable[type] = totalNum + num;
- }
- }
-
- private string GetVerticalTotalNum()
- {
- var totalNum = 0;
- foreach (int num in _verticalHashtable.Values)
- {
- totalNum += num;
- }
- return totalNum == 0 ? "0" : $"{totalNum} ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageAnalysisSiteDownloadsChannels.cs b/SiteServer.BackgroundPages/Settings/PageAnalysisSiteDownloadsChannels.cs
deleted file mode 100644
index 0a84cc3db..000000000
--- a/SiteServer.BackgroundPages/Settings/PageAnalysisSiteDownloadsChannels.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Provider;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageAnalysisSiteDownloadsChannels : BasePageCms
- {
- public DropDownList DdlSiteId;
- public Repeater RptContents;
- public SqlPager SpContents;
-
- public string StrArray { get; set; }
-
- private readonly Hashtable _nodeNameNavigations = new Hashtable();
- private readonly Hashtable _horizentalHashtable = new Hashtable();
- private readonly Hashtable _verticalHashtable = new Hashtable();
- private readonly List _contentIdList = new List();
- private readonly Hashtable _xHashtable = new Hashtable();
- private readonly Hashtable _yHashtableDownload = new Hashtable();
- private const string YTypeDownload = "YType_Download";
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetSettingsUrl(nameof(PageAnalysisSiteDownloadsChannels), new NameValueCollection
- {
- {"siteID", siteId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- SpContents.ControlToPaginate = RptContents;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- SpContents.ItemsPerPage = SiteInfo.Additional.PageSize;
-
- SpContents.SelectCommand = DataProvider.ContentDao.GetSqlStringByDownloads(SiteInfo.TableName, SiteId);
-
- SpContents.SortField = ContentDao.SortFieldName;
- SpContents.SortMode = SortMode.DESC;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Chart);
-
- DdlSiteId.Items.Add(new ListItem("<<全部站点>>", "0"));
- var siteIdList = SiteManager.GetSiteIdListOrderByLevel();
- foreach (var siteId in siteIdList)
- {
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- DdlSiteId.Items.Add(new ListItem(siteInfo.SiteName, siteId.ToString()));
- }
- ControlUtils.SelectSingleItem(DdlSiteId, SiteId.ToString());
-
- SpContents.DataBind();
-
- foreach (var contentId in _contentIdList)
- {
- var yValueDownload = GetYHashtable(contentId);
- var xValue = GetXHashtable(contentId);
- if (xValue.Length > 10) xValue = xValue.Substring(0, 10);
-
- StrArray += $@"
-xArrayDownload.push('{xValue}');
- yArrayDownload.push('{yValueDownload}');";
- }
- }
-
- public void Analysis_OnClick(object sender, EventArgs e)
- {
- var siteId = TranslateUtils.ToInt(DdlSiteId.SelectedValue);
- PageUtils.Redirect(siteId > 0
- ? GetRedirectUrl(siteId)
- : PageAnalysisSiteDownloads.GetRedirectUrl());
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var ltlItemTitle = (Literal)e.Item.FindControl("ltlItemTitle");
- var ltlChannel = (Literal)e.Item.FindControl("ltlChannel");
- var ltlFileUrl = (Literal)e.Item.FindControl("ltlFileUrl");
-
- var contentInfo = new ContentInfo(e.Item.DataItem);
-
- ltlItemTitle.Text = WebUtils.GetContentTitle(SiteInfo, contentInfo, PageUrl);
-
- string nodeNameNavigation;
- if (!_nodeNameNavigations.ContainsKey(contentInfo.ChannelId))
- {
- nodeNameNavigation = ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId);
- _nodeNameNavigations.Add(contentInfo.ChannelId, nodeNameNavigation);
- }
- else
- {
- nodeNameNavigation = _nodeNameNavigations[contentInfo.ChannelId] as string;
- }
- ltlChannel.Text = nodeNameNavigation;
-
- var fileUrl = contentInfo.GetString(BackgroundContentAttribute.FileUrl);
- if (!string.IsNullOrEmpty(fileUrl))
- {
- ltlFileUrl.Text =
- $@"{fileUrl} ";
- }
-
- //x轴信息
- SetXHashtable(contentInfo.Id, contentInfo.Title);
- //y轴信息
- SetYHashtable(contentInfo.Id, CountManager.GetCount(SiteInfo.TableName, contentInfo.Id.ToString(), ECountType.Download));
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl = PageUtils.GetSettingsUrl(nameof(PageAnalysisSiteDownloadsChannels), new NameValueCollection
- {
- {"SiteId", SiteId.ToString()}
- });
- }
- return _pageUrl;
- }
- }
-
- private void SetXHashtable(int contentId, string title)
- {
- if (!_xHashtable.ContainsKey(contentId))
- {
- _xHashtable.Add(contentId, title);
- }
- if (!_contentIdList.Contains(contentId))
- {
- _contentIdList.Add(contentId);
- }
- }
-
- private string GetXHashtable(int contentId)
- {
- return _xHashtable.ContainsKey(contentId) ? _xHashtable[contentId].ToString() : string.Empty;
- }
-
- private void SetYHashtable(int contentId, int value)
- {
-
- if (!_yHashtableDownload.ContainsKey(contentId))
- {
- _yHashtableDownload.Add(contentId, value);
- }
- else
- {
- var num = TranslateUtils.ToInt(_yHashtableDownload[contentId].ToString());
- _yHashtableDownload[contentId] = num + value;
- }
- SetVertical(YTypeDownload, value);
-
- SetHorizental(contentId, value);
- }
-
- private string GetYHashtable(int contentId)
- {
- if (!_yHashtableDownload.ContainsKey(contentId)) return "0";
- var num = TranslateUtils.ToInt(_yHashtableDownload[contentId].ToString());
- return num.ToString();
- }
-
- private void SetHorizental(int contentId, int num)
- {
- if (_horizentalHashtable[contentId] == null)
- {
- _horizentalHashtable[contentId] = num;
- }
- else
- {
- var totalNum = (int)_horizentalHashtable[contentId];
- _horizentalHashtable[contentId] = totalNum + num;
- }
- }
-
- private void SetVertical(string type, int num)
- {
- if (_verticalHashtable[type] == null)
- {
- _verticalHashtable[type] = num;
- }
- else
- {
- var totalNum = (int)_verticalHashtable[type];
- _verticalHashtable[type] = totalNum + num;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageCreateStatus.cs b/SiteServer.BackgroundPages/Settings/PageCreateStatus.cs
deleted file mode 100644
index a21cf528a..000000000
--- a/SiteServer.BackgroundPages/Settings/PageCreateStatus.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System.Collections.Specialized;
-using SiteServer.CMS.Api;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageCreateStatus : BasePageCms
- {
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetSettingsUrl(nameof(PageCreateStatus), new NameValueCollection
- {
- {"siteID", siteId.ToString()}
- });
- }
-
- public static string GetOpenLayerString(int siteId)
- {
- return LayerUtils.GetOpenScript("页面生成进度",
- PageUtils.GetSettingsUrl(nameof(PageCreateStatus), new NameValueCollection
- {
- {"siteID", siteId.ToString()}
- }));
- }
-
- public static void Redirect(int siteId)
- {
- var pageUrl = PageUtils.GetSettingsUrl(nameof(PageCreateStatus), new NameValueCollection
- {
- {"siteID", siteId.ToString()}
- });
- PageUtils.Redirect(pageUrl);
- }
-
- public string SiteUrl => PageRedirect.GetRedirectUrl(SiteId);
-
- public string SignalrHubsUrl = ApiManager.SignalrHubsUrl;
-
- //public void Page_Load(object sender, EventArgs e)
- //{
- // if (IsForbidden) return;
-
- // if (!IsPostBack)
- // {
- // base.BreadCrumb(AppManager.LeftMenu.ID_Utility, "生成队列", AppManager.Permission.Platform_Utility);
- // }
-
- // if (!string.IsNullOrEmpty(base.AuthRequest.GetQueryString("Cancel")))
- // {
- // DataProvider.CreateTaskDAO.DeleteAll(base.SiteId);
- // }
- //}
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageLogAdmin.cs b/SiteServer.BackgroundPages/Settings/PageLogAdmin.cs
deleted file mode 100644
index 8851a1b1b..000000000
--- a/SiteServer.BackgroundPages/Settings/PageLogAdmin.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageLogAdmin : BasePage
- {
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
- public TextBox TbUserName;
- public TextBox TbKeyword;
- public Repeater RptContents;
- public SqlPager SpContents;
- public Literal LtlState;
- public Button BtnDelete;
- public Button BtnDeleteAll;
- public Button BtnSetting;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = StringUtils.Constants.PageSize;
-
- SpContents.SelectCommand = !AuthRequest.IsQueryExists("Keyword") ? DataProvider.LogDao.GetSelectCommend() : DataProvider.LogDao.GetSelectCommend(AuthRequest.GetQueryString("UserName"), AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryString("DateFrom"), AuthRequest.GetQueryString("DateTo"));
-
- SpContents.SortField = nameof(LogInfo.Id);
- SpContents.SortMode = SortMode.DESC;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Log);
-
- if (AuthRequest.IsQueryExists("Keyword"))
- {
- TbUserName.Text = AuthRequest.GetQueryString("UserName");
- TbKeyword.Text = AuthRequest.GetQueryString("Keyword");
- TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom");
- TbDateTo.Text = AuthRequest.GetQueryString("DateTo");
- }
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var arraylist = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("IDCollection"));
- try
- {
- DataProvider.LogDao.Delete(arraylist);
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- else if (AuthRequest.IsQueryExists("DeleteAll"))
- {
- DataProvider.LogDao.DeleteAll();
- SuccessDeleteMessage();
- }
- else if (AuthRequest.IsQueryExists("Setting"))
- {
- ConfigManager.SystemConfigInfo.IsLogAdmin = !ConfigManager.SystemConfigInfo.IsLogAdmin;
- DataProvider.ConfigDao.Update(ConfigManager.Instance);
- SuccessMessage($"成功{(ConfigManager.SystemConfigInfo.IsLogAdmin ? "启用" : "禁用")}日志记录");
- }
-
- BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
- {
- {"Delete", "True" }
- }), "IDCollection", "IDCollection", "请选择需要删除的日志!", "此操作将删除所选日志,确认吗?"));
-
- BtnDeleteAll.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("删除所有日志", "此操作将删除所有日志信息,确定吗?", "删除全部",
- PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
- {
- {"DeleteAll", "True"}
- })));
-
- if (ConfigManager.SystemConfigInfo.IsLogAdmin)
- {
- BtnSetting.Text = "禁用记录日志";
- BtnSetting.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("禁用记录日志", "此操作将禁用管理员日志记录功能,确定吗?", "禁 用",
- PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
- {
- {"Setting", "True"}
- })));
- }
- else
- {
- LtlState.Text = @"管理员日志当前处于禁用状态,系统将不会记录管理员操作日志!
";
- BtnSetting.Text = "启用记录日志";
- BtnSetting.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("启用记录日志", "此操作将启用管理员日志记录功能,确定吗?", "启 用",
- PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
- {
- {"Setting", "True"}
- })));
- }
-
- SpContents.DataBind();
- }
-
- private static void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var ltlUserName = (Literal)e.Item.FindControl("ltlUserName");
- var ltlAddDate = (Literal)e.Item.FindControl("ltlAddDate");
- var ltlIpAddress = (Literal)e.Item.FindControl("ltlIpAddress");
- var ltlAction = (Literal)e.Item.FindControl("ltlAction");
- var ltlSummary = (Literal)e.Item.FindControl("ltlSummary");
-
- ltlUserName.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(LogInfo.UserName));
- ltlAddDate.Text = DateUtils.GetDateAndTimeString(SqlUtils.EvalDateTime(e.Item.DataItem, nameof(LogInfo.AddDate)));
- ltlIpAddress.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(LogInfo.IpAddress));
- ltlAction.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(LogInfo.Action));
- ltlSummary.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(LogInfo.Summary));
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
- {
- {"UserName", TbUserName.Text},
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text}
- }));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageLogConfiguration.cs b/SiteServer.BackgroundPages/Settings/PageLogConfiguration.cs
deleted file mode 100644
index 75013e08a..000000000
--- a/SiteServer.BackgroundPages/Settings/PageLogConfiguration.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageLogConfiguration : BasePage
- {
- protected RadioButtonList RblIsTimeThreshold;
- public PlaceHolder PhTimeThreshold;
- protected TextBox TbTime;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Log);
-
- EBooleanUtils.AddListItems(RblIsTimeThreshold, "启用", "不启用");
- ControlUtils.SelectSingleItem(RblIsTimeThreshold, ConfigManager.SystemConfigInfo.IsTimeThreshold.ToString());
- TbTime.Text = ConfigManager.SystemConfigInfo.TimeThreshold.ToString();
-
- PhTimeThreshold.Visible = TranslateUtils.ToBool(RblIsTimeThreshold.SelectedValue);
- }
-
- public void RblIsTimeThreshold_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhTimeThreshold.Visible = TranslateUtils.ToBool(RblIsTimeThreshold.SelectedValue);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- ConfigManager.SystemConfigInfo.IsTimeThreshold = TranslateUtils.ToBool(RblIsTimeThreshold.SelectedValue);
- if (ConfigManager.SystemConfigInfo.IsTimeThreshold)
- {
- ConfigManager.SystemConfigInfo.TimeThreshold = TranslateUtils.ToInt(TbTime.Text);
- }
-
- DataProvider.ConfigDao.Update(ConfigManager.Instance);
-
- AuthRequest.AddAdminLog("设置日志阈值参数");
- SuccessMessage("日志设置成功");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageLogError.cs b/SiteServer.BackgroundPages/Settings/PageLogError.cs
deleted file mode 100644
index 65775525e..000000000
--- a/SiteServer.BackgroundPages/Settings/PageLogError.cs
+++ /dev/null
@@ -1,162 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Plugin;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageLogError : BasePage
- {
- public DropDownList DdlPluginId;
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
- public TextBox TbKeyword;
- public Repeater RptContents;
- public SqlPager SpContents;
- public Button BtnDelete;
- public Button BtnDeleteAll;
- public Literal LtlState;
- public Button BtnSetting;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var list = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("IDCollection"));
- try
- {
- DataProvider.ErrorLogDao.Delete(list);
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- else if (AuthRequest.IsQueryExists("DeleteAll"))
- {
- try
- {
- DataProvider.ErrorLogDao.DeleteAll();
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- else if (AuthRequest.IsQueryExists("Setting"))
- {
- ConfigManager.SystemConfigInfo.IsLogError = !ConfigManager.SystemConfigInfo.IsLogError;
- DataProvider.ConfigDao.Update(ConfigManager.Instance);
- SuccessMessage($"成功{(ConfigManager.SystemConfigInfo.IsLogError ? "启用" : "禁用")}日志记录");
- }
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = StringUtils.Constants.PageSize;
-
- SpContents.SelectCommand = DataProvider.ErrorLogDao.GetSelectCommend(AuthRequest.GetQueryString("PluginId"), AuthRequest.GetQueryString("Keyword"),
- AuthRequest.GetQueryString("DateFrom"), AuthRequest.GetQueryString("DateTo"));
-
- SpContents.SortField = nameof(ErrorLogInfo.Id);
- SpContents.SortMode = SortMode.DESC;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (IsPostBack) return;
-
- DdlPluginId.Items.Add(new ListItem("全部错误", string.Empty));
- foreach (var pluginInfo in PluginManager.AllPluginInfoList)
- {
- DdlPluginId.Items.Add(new ListItem(pluginInfo.Id, pluginInfo.Id));
- }
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Log);
-
- if (AuthRequest.IsQueryExists("Keyword"))
- {
- ControlUtils.SelectSingleItem(DdlPluginId, AuthRequest.GetQueryString("PluginId"));
- TbKeyword.Text = AuthRequest.GetQueryString("Keyword");
- TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom");
- TbDateTo.Text = AuthRequest.GetQueryString("DateTo");
- }
-
- BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(PageUtils.GetSettingsUrl(nameof(PageLogError), new NameValueCollection
- {
- {"Delete", "True" }
- }), "IDCollection", "IDCollection", "请选择需要删除的日志!", "此操作将删除所选日志,确认吗?"));
-
- BtnDeleteAll.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("删除所有日志", "此操作将删除所有日志信息,确定吗?", "删除全部",
- PageUtils.GetSettingsUrl(nameof(PageLogError), new NameValueCollection
- {
- {"DeleteAll", "True"}
- })));
-
- if (ConfigManager.SystemConfigInfo.IsLogError)
- {
- BtnSetting.Text = "禁用系统错误日志";
- BtnSetting.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("禁用系统错误日志", "此操作将禁用系统错误日志记录功能,确定吗?", "禁 用",
- PageUtils.GetSettingsUrl(nameof(PageLogError), new NameValueCollection
- {
- {"Setting", "True"}
- })));
- }
- else
- {
- LtlState.Text = @"系统错误日志当前处于禁用状态,系统将不会记录系统错误日志!
";
- BtnSetting.Text = "启用记录日志";
- BtnSetting.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("启用系统错误日志", "此操作将启用系统错误日志记录功能,确定吗?", "启 用",
- PageUtils.GetSettingsUrl(nameof(PageLogError), new NameValueCollection
- {
- {"Setting", "True"}
- })));
- }
-
- SpContents.DataBind();
- }
-
- private static void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var id = SqlUtils.EvalInt(e.Item.DataItem, nameof(ErrorLogInfo.Id));
- var addDate = SqlUtils.EvalDateTime(e.Item.DataItem, nameof(ErrorLogInfo.AddDate));
- var message = SqlUtils.EvalString(e.Item.DataItem, nameof(ErrorLogInfo.Message));
- var summary = SqlUtils.EvalString(e.Item.DataItem, nameof(ErrorLogInfo.Summary));
-
- var ltlId = (Literal)e.Item.FindControl("ltlId");
- var ltlAddDate = (Literal)e.Item.FindControl("ltlAddDate");
- var ltlMessage = (Literal)e.Item.FindControl("ltlMessage");
- var ltlSummary = (Literal)e.Item.FindControl("ltlSummary");
-
- ltlId.Text = $@"{id} ";
- ltlAddDate.Text = DateUtils.GetDateAndTimeString(addDate);
- ltlMessage.Text = message;
- ltlSummary.Text = summary;
- if (!string.IsNullOrEmpty(ltlSummary.Text))
- {
- ltlSummary.Text += " ";
- }
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUtils.GetSettingsUrl(nameof(PageLogError), new NameValueCollection
- {
- {"PluginId", DdlPluginId.SelectedValue},
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text}
- }));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageLogSite.cs b/SiteServer.BackgroundPages/Settings/PageLogSite.cs
deleted file mode 100644
index bc3239e79..000000000
--- a/SiteServer.BackgroundPages/Settings/PageLogSite.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageLogSite : BasePageCms
- {
- public DropDownList DdlSiteId;
- public DropDownList DdlLogType;
- public TextBox TbUserName;
- public TextBox TbKeyword;
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
-
- public Repeater RptContents;
- public SqlPager SpContents;
- public Literal LtlSite;
-
- public Button BtnDelete;
- public Button BtnDeleteAll;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = StringUtils.Constants.PageSize;
-
- SpContents.SelectCommand = !AuthRequest.IsQueryExists("LogType")
- ? DataProvider.SiteLogDao.GetSelectCommend()
- : DataProvider.SiteLogDao.GetSelectCommend(SiteId, AuthRequest.GetQueryString("LogType"),
- AuthRequest.GetQueryString("UserName"), AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryString("DateFrom"),
- AuthRequest.GetQueryString("DateTo"));
-
- SpContents.SortField = nameof(SiteLogInfo.Id);
- SpContents.SortMode = SortMode.DESC;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var arraylist = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("IDCollection"));
- try
- {
- DataProvider.SiteLogDao.Delete(arraylist);
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- else if (AuthRequest.IsQueryExists("DeleteAll"))
- {
- try
- {
- DataProvider.SiteLogDao.DeleteAll();
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Log);
-
- if (SiteId == 0)
- {
- LtlSite.Text = @"站点名称 ";
- }
-
- DdlSiteId.Items.Add(new ListItem("<<全部站点>>", "0"));
-
- var siteIdList = SiteManager.GetSiteIdListOrderByLevel();
- foreach (var psId in siteIdList)
- {
- DdlSiteId.Items.Add(new ListItem(SiteManager.GetSiteInfo(psId).SiteName, psId.ToString()));
- }
-
- DdlLogType.Items.Add(new ListItem("全部记录", "All"));
- DdlLogType.Items.Add(new ListItem("栏目相关记录", "Channel"));
- DdlLogType.Items.Add(new ListItem("内容相关记录", "Content"));
-
- if (AuthRequest.IsQueryExists("LogType"))
- {
- ControlUtils.SelectSingleItem(DdlSiteId, SiteId.ToString());
- ControlUtils.SelectSingleItem(DdlLogType, AuthRequest.GetQueryString("LogType"));
- TbUserName.Text = AuthRequest.GetQueryString("UserName");
- TbKeyword.Text = AuthRequest.GetQueryString("Keyword");
- TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom");
- TbDateTo.Text = AuthRequest.GetQueryString("DateTo");
- }
-
- BtnDelete.Attributes.Add("onclick",
- PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
- PageUtils.GetSettingsUrl(nameof(PageLogSite), new NameValueCollection
- {
- {"Delete", "True"}
- }), "IDCollection", "IDCollection", "请选择需要删除的日志!", "此操作将删除所选日志,确认吗?"));
-
- BtnDeleteAll.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("删除所有日志", "此操作将删除所有日志信息,确定吗?", "删除全部",
- PageUtils.GetSettingsUrl(nameof(PageLogSite), new NameValueCollection
- {
- {"DeleteAll", "True"}
- })));
-
- SpContents.DataBind();
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var ltlSite = (Literal)e.Item.FindControl("ltlSite");
- var ltlUserName = (Literal)e.Item.FindControl("ltlUserName");
- var ltlAddDate = (Literal)e.Item.FindControl("ltlAddDate");
- var ltlIpAddress = (Literal)e.Item.FindControl("ltlIpAddress");
- var ltlAction = (Literal)e.Item.FindControl("ltlAction");
- var ltlSummary = (Literal)e.Item.FindControl("ltlSummary");
-
- if (SiteId == 0)
- {
- var siteInfo = SiteManager.GetSiteInfo(SqlUtils.EvalInt(e.Item.DataItem, nameof(SiteLogInfo.SiteId)));
- var siteName = string.Empty;
- if (siteInfo != null)
- {
- siteName =
- $"{siteInfo.SiteName} ";
- }
- ltlSite.Text = $@"{siteName} ";
- }
- ltlUserName.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(SiteLogInfo.UserName));
- ltlAddDate.Text = DateUtils.GetDateAndTimeString(SqlUtils.EvalDateTime(e.Item.DataItem, nameof(SiteLogInfo.AddDate)));
- ltlIpAddress.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(SiteLogInfo.IpAddress));
- ltlAction.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(SiteLogInfo.Action));
- ltlSummary.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(SiteLogInfo.Summary));
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUtils.GetSettingsUrl(nameof(PageLogSite), new NameValueCollection
- {
- {"UserName", TbUserName.Text},
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text},
- {"SiteId", DdlSiteId.SelectedValue},
- {"LogType", DdlLogType.SelectedValue}
- }));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageLogUser.cs b/SiteServer.BackgroundPages/Settings/PageLogUser.cs
deleted file mode 100644
index ef5e8e8d6..000000000
--- a/SiteServer.BackgroundPages/Settings/PageLogUser.cs
+++ /dev/null
@@ -1,133 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageLogUser : BasePage
- {
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
- public TextBox TbUserName;
- public TextBox TbKeyword;
- public Repeater RptContents;
- public SqlPager SpContents;
- public Literal LtlState;
- public Button BtnDelete;
- public Button BtnDeleteAll;
- public Button BtnSetting;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = StringUtils.Constants.PageSize;
-
- SpContents.SelectCommand = !AuthRequest.IsQueryExists("Keyword") ? DataProvider.UserLogDao.GetSelectCommend() : DataProvider.UserLogDao.GetSelectCommend(AuthRequest.GetQueryString("UserName"), AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryString("DateFrom"), AuthRequest.GetQueryString("DateTo"));
-
- SpContents.SortField = nameof(UserLogInfo.Id);
- SpContents.SortMode = SortMode.DESC;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Log);
-
- if (AuthRequest.IsQueryExists("Keyword"))
- {
- TbUserName.Text = AuthRequest.GetQueryString("UserName");
- TbKeyword.Text = AuthRequest.GetQueryString("Keyword");
- TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom");
- TbDateTo.Text = AuthRequest.GetQueryString("DateTo");
- }
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var list = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("IDCollection"));
- DataProvider.UserLogDao.Delete(list);
- SuccessDeleteMessage();
- }
- else if (AuthRequest.IsQueryExists("DeleteAll"))
- {
- DataProvider.UserLogDao.DeleteAll();
- SuccessDeleteMessage();
- }
- else if (AuthRequest.IsQueryExists("Setting"))
- {
- ConfigManager.SystemConfigInfo.IsLogUser = !ConfigManager.SystemConfigInfo.IsLogUser;
- DataProvider.ConfigDao.Update(ConfigManager.Instance);
- SuccessMessage($"成功{(ConfigManager.SystemConfigInfo.IsLogUser ? "启用" : "禁用")}日志记录");
- }
-
- BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(PageUtils.GetSettingsUrl(nameof(PageLogUser), new NameValueCollection
- {
- {"Delete", "True" }
- }), "IDCollection", "IDCollection", "请选择需要删除的日志!", "此操作将删除所选日志,确认吗?"));
-
- BtnDeleteAll.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("删除所有日志", "此操作将删除所有日志信息,确定吗?", "删除全部",
- PageUtils.GetSettingsUrl(nameof(PageLogUser), new NameValueCollection
- {
- {"DeleteAll", "True"}
- })));
-
- if (ConfigManager.SystemConfigInfo.IsLogUser)
- {
- BtnSetting.Text = "禁用记录日志";
- BtnSetting.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("禁用记录日志", "此操作将禁用用户日志记录功能,确定吗?", "禁 用",
- PageUtils.GetSettingsUrl(nameof(PageLogUser), new NameValueCollection
- {
- {"Setting", "True"}
- })));
- }
- else
- {
- LtlState.Text = @"用户日志当前处于禁用状态,系统将不会记录用户操作日志!
";
- BtnSetting.Text = "启用记录日志";
- BtnSetting.Attributes.Add("onclick",
- AlertUtils.ConfirmRedirect("启用记录日志", "此操作将启用用户日志记录功能,确定吗?", "启 用",
- PageUtils.GetSettingsUrl(nameof(PageLogUser), new NameValueCollection
- {
- {"Setting", "True"}
- })));
- }
-
- SpContents.DataBind();
- }
-
- private static void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var ltlUserName = (Literal)e.Item.FindControl("ltlUserName");
- var ltlAddDate = (Literal)e.Item.FindControl("ltlAddDate");
- var ltlIpAddress = (Literal)e.Item.FindControl("ltlIpAddress");
- var ltlAction = (Literal)e.Item.FindControl("ltlAction");
- var ltlSummary = (Literal)e.Item.FindControl("ltlSummary");
-
- ltlUserName.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(UserLogInfo.UserName));
- ltlAddDate.Text = DateUtils.GetDateAndTimeString(SqlUtils.EvalDateTime(e.Item.DataItem, nameof(UserLogInfo.AddDate)));
- ltlIpAddress.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(UserLogInfo.IpAddress));
- ltlAction.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(UserLogInfo.Action));
- ltlSummary.Text = SqlUtils.EvalString(e.Item.DataItem, nameof(UserLogInfo.Summary));
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUtils.GetSettingsUrl(nameof(PageLogUser), new NameValueCollection
- {
- {"UserName", TbUserName.Text},
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text}
- }));
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageRecord.cs b/SiteServer.BackgroundPages/Settings/PageRecord.cs
deleted file mode 100644
index 1ae08013e..000000000
--- a/SiteServer.BackgroundPages/Settings/PageRecord.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageRecord : Page
- {
- public TextBox TbKeyword;
- public DateTimeTextBox TbDateFrom;
- public DateTimeTextBox TbDateTo;
- public Repeater RptContents;
- public SqlPager SpContents;
- public Button BtnDelete;
- public Button BtnDeleteAll;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (!DataProvider.RecordDao.IsRecord()) return;
-
- if (!string.IsNullOrEmpty(Request.QueryString["Delete"]))
- {
- var list = TranslateUtils.StringCollectionToIntList(Request.QueryString["IdCollection"]);
- DataProvider.RecordDao.Delete(list);
- }
- else if (!string.IsNullOrEmpty(Request.QueryString["DeleteAll"]))
- {
- DataProvider.RecordDao.DeleteAll();
- }
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = 100;
-
- SpContents.SelectCommand = string.IsNullOrEmpty(Request.QueryString["Keyword"]) ? DataProvider.RecordDao.GetSqlString() : DataProvider.RecordDao.GetSqlString(Request.QueryString["Keyword"], Request.QueryString["DateFrom"], Request.QueryString["DateTo"]);
-
- SpContents.SortField = "Id";
- SpContents.SortMode = SortMode.DESC;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
-
- if (IsPostBack) return;
-
- if (!string.IsNullOrEmpty(Request.QueryString["Keyword"]))
- {
- TbKeyword.Text = Request.QueryString["Keyword"];
- TbDateFrom.Text = Request.QueryString["DateFrom"];
- TbDateTo.Text = Request.QueryString["DateTo"];
- }
-
- BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(PageUtils.GetSettingsUrl(nameof(PageRecord), new NameValueCollection
- {
- {"Delete", "True" }
- }), "IDCollection", "IDCollection", "请选择需要删除的记录!", "此操作将删除所选记录,确认吗?"));
-
- BtnDeleteAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.GetSettingsUrl(nameof(PageRecord), new NameValueCollection
- {
- {"DeleteAll", "True" }
- }), "此操作将删除所有记录信息,确定吗?"));
-
- SpContents.DataBind();
- }
-
- private static void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var ltlText = (Literal)e.Item.FindControl("ltlText");
- var ltlSummary = (Literal)e.Item.FindControl("ltlSummary");
- var ltlSource = (Literal)e.Item.FindControl("ltlSource");
- var ltlAddDate = (Literal)e.Item.FindControl("ltlAddDate");
-
- ltlText.Text = SqlUtils.EvalString(e.Item.DataItem, "Text");
- ltlSummary.Text = SqlUtils.EvalString(e.Item.DataItem, "Summary");
- ltlSource.Text = SqlUtils.EvalString(e.Item.DataItem, "Source");
- ltlAddDate.Text = DateUtils.GetDateAndTimeString(SqlUtils.EvalDateTime(e.Item.DataItem, "AddDate"), EDateFormatType.Day, ETimeFormatType.LongTime);
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- Response.Redirect(PageUrl, true);
- }
-
- private string PageUrl => PageUtils.GetSettingsUrl(nameof(PageRecord), new NameValueCollection
- {
- {"Keyword", TbKeyword.Text},
- {"DateFrom", TbDateFrom.Text},
- {"DateTo", TbDateTo.Text}
- });
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSite.cs b/SiteServer.BackgroundPages/Settings/PageSite.cs
deleted file mode 100644
index e1fc28280..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSite.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSite : BasePageCms
- {
- public Repeater RptContents;
-
- private int _hqSiteId;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageSite), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("SiteId") && (AuthRequest.IsQueryExists("Up") || AuthRequest.IsQueryExists("Down")))
- {
- var siteId = AuthRequest.GetQueryInt("SiteId");
-
- if (AuthRequest.IsQueryExists("Up") && AuthRequest.GetQueryBool("Up"))
- {
- DataProvider.SiteDao.UpdateTaxisToUp(siteId);
- }
- else
- {
- DataProvider.SiteDao.UpdateTaxisToDown(siteId);
- }
-
- }
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- _hqSiteId = DataProvider.SiteDao.GetIdByIsRoot();
-
- RptContents.DataSource = SiteManager.GetSiteIdList();
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var siteId = (int)e.Item.DataItem;
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- if (siteInfo == null) return;
-
- var ltlSiteName = (Literal)e.Item.FindControl("ltlSiteName");
- var ltlSiteDir = (Literal)e.Item.FindControl("ltlSiteDir");
- var ltlAddDate = (Literal)e.Item.FindControl("ltlAddDate");
- var ltlSave = (Literal)e.Item.FindControl("ltlSave");
- var ltlEdit = (Literal)e.Item.FindControl("ltlEdit");
- var ltlChangeType = (Literal)e.Item.FindControl("ltlChangeType");
- var ltlReplace = (Literal)e.Item.FindControl("ltlReplace");
- var ltlDelete = (Literal)e.Item.FindControl("ltlDelete");
- var ltlUpLink = (Literal)e.Item.FindControl("ltlUpLink");
- var ltlDownLink = (Literal)e.Item.FindControl("ltlDownLink");
-
- ltlSiteName.Text = GetSiteNameHtml(siteInfo);
- ltlSiteDir.Text = siteInfo.SiteDir;
- ltlAddDate.Text = DateUtils.GetDateString(ChannelManager.GetAddDate(siteId, siteId));
-
- ltlSave.Text = $@"保存 ";
-
- ltlEdit.Text = $@"修改 ";
-
- ltlReplace.Text = $@"替换 ";
-
- var upUrl = PageUtils.GetSettingsUrl(nameof(PageSite), new NameValueCollection
- {
- {"Up", "True" },
- {"SiteId", siteId.ToString() }
- });
- ltlUpLink.Text = $@" ";
-
- var downUrl = PageUtils.GetSettingsUrl(nameof(PageSite), new NameValueCollection
- {
- {"Down", "True" },
- {"SiteId", siteId.ToString() }
- });
- ltlDownLink.Text = $@" ";
-
- if (siteInfo.ParentId == 0 && (_hqSiteId == 0 || siteId == _hqSiteId))
- {
- ltlChangeType.Text = GetChangeHtml(siteId, siteInfo.IsRoot);
- }
-
- if (siteInfo.IsRoot == false)
- {
- ltlDelete.Text = $@"删除 ";
- }
- }
-
- private static string GetSiteNameHtml(SiteInfo siteInfo)
- {
- var level = SiteManager.GetSiteLevel(siteInfo.Id);
- string psLogo;
- if (siteInfo.IsRoot)
- {
- psLogo = "siteHQ.gif";
- }
- else
- {
- psLogo = "site.gif";
- if (level > 0 && level < 10)
- {
- psLogo = $"subsite{level + 1}.gif";
- }
- }
- psLogo = SiteServerAssets.GetIconUrl("tree/" + psLogo);
-
- var padding = string.Empty;
- for (var i = 0; i < level; i++)
- {
- padding += " ";
- }
- if (level > 0)
- {
- padding += "└ ";
- }
-
- return
- $"{padding} {siteInfo.SiteName} ";
- }
-
- private static string GetChangeHtml(int siteId, bool isHeadquarters)
- {
- var showPopWinString = ModalChangeSiteType.GetOpenWindowString(siteId);
-
- return isHeadquarters == false
- ? $"转移到根目录 "
- : $"转移到子目录 ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteAdd.cs b/SiteServer.BackgroundPages/Settings/PageSiteAdd.cs
deleted file mode 100644
index 213ecb605..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteAdd.cs
+++ /dev/null
@@ -1,541 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.IO;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Cms;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteAdd : BasePageCms
- {
- protected override bool IsSinglePage => true;
-
- public PlaceHolder PhSource;
- public RadioButtonList RblSource;
- public HtmlInputHidden HihSiteTemplateDir;
- public HtmlInputHidden HihOnlineTemplateName;
-
- public PlaceHolder PhSiteTemplates;
- public Repeater RptSiteTemplates;
-
- public PlaceHolder PhOnlineTemplates;
- public Repeater RptOnlineTemplates;
-
- public PlaceHolder PhSubmit;
- public Literal LtlSource;
- public TextBox TbSiteName;
- public RadioButtonList RblIsRoot;
- public PlaceHolder PhIsNotRoot;
- public DropDownList DdlParentId;
- public TextBox TbSiteDir;
- public DropDownList DdlCharset;
- public PlaceHolder PhIsImportContents;
- public CheckBox CbIsImportContents;
- public PlaceHolder PhIsImportTableStyles;
- public CheckBox CbIsImportTableStyles;
- public PlaceHolder PhIsSiteTemplateTable;
- public RadioButtonList RblIsSiteTemplateTable;
- public PlaceHolder PhTableName;
- public DropDownList DdlTableName;
- public RadioButtonList RblIsCheckContentUseLevel;
- public PlaceHolder PhCheckContentLevel;
- public DropDownList DdlCheckContentLevel;
-
- public Button BtnPrevious;
- public Button BtnNext;
- public Button BtnSubmit;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteAdd), null);
- }
-
- public static string GetRedirectUrl(string siteTemplateDir, string onlineTemplateName)
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteAdd), new NameValueCollection
- {
- {"siteTemplateDir", siteTemplateDir},
- {"onlineTemplateName", onlineTemplateName}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.SiteAdd);
-
- DataProvider.TableDao.CreateAllTableCollectionInfoIfNotExists();
-
- var hqSiteId = DataProvider.SiteDao.GetIdByIsRoot();
- if (hqSiteId == 0)
- {
- ControlUtils.SelectSingleItem(RblIsRoot, true.ToString());
- PhIsNotRoot.Visible = false;
- }
- else
- {
- RblIsRoot.Enabled = false;
- }
-
- DdlParentId.Items.Add(new ListItem("<无上级站点>", "0"));
- var siteIdArrayList = SiteManager.GetSiteIdList();
- var mySystemInfoArrayList = new ArrayList();
- var parentWithChildren = new Hashtable();
- foreach (var siteId in siteIdArrayList)
- {
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- if (siteInfo.IsRoot == false)
- {
- if (siteInfo.ParentId == 0)
- {
- mySystemInfoArrayList.Add(siteInfo);
- }
- else
- {
- var children = new ArrayList();
- if (parentWithChildren.Contains(siteInfo.ParentId))
- {
- children = (ArrayList)parentWithChildren[siteInfo.ParentId];
- }
- children.Add(siteInfo);
- parentWithChildren[siteInfo.ParentId] = children;
- }
- }
- }
- foreach (SiteInfo siteInfo in mySystemInfoArrayList)
- {
- AddSite(DdlParentId, siteInfo, parentWithChildren, 0);
- }
- ControlUtils.SelectSingleItem(DdlParentId, "0");
-
- ECharsetUtils.AddListItems(DdlCharset);
- ControlUtils.SelectSingleItem(DdlCharset, ECharsetUtils.GetValue(ECharset.utf_8));
-
- var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb();
- foreach (var tableInfo in tableList)
- {
- if (tableInfo.DisplayName.StartsWith("插件内容表:")) continue;
-
- var li = new ListItem($"{tableInfo.DisplayName}({tableInfo.TableName})", tableInfo.TableName);
- DdlTableName.Items.Add(li);
- }
-
- RblIsCheckContentUseLevel.Items.Add(new ListItem("默认审核机制", false.ToString()));
- RblIsCheckContentUseLevel.Items.Add(new ListItem("多级审核机制", true.ToString()));
- ControlUtils.SelectSingleItem(RblIsCheckContentUseLevel, false.ToString());
-
- if (SiteTemplateManager.Instance.IsSiteTemplateExists)
- {
- RblSource.Items.Add(new ListItem("创建空站点(不使用站点模板)", ETriStateUtils.GetValue(ETriState.True)));
- RblSource.Items.Add(new ListItem("使用本地站点模板创建站点", ETriStateUtils.GetValue(ETriState.False)));
- RblSource.Items.Add(new ListItem("使用在线站点模板创建站点", ETriStateUtils.GetValue(ETriState.All)));
- }
- else
- {
- RblSource.Items.Add(new ListItem("创建空站点(不使用站点模板)", ETriStateUtils.GetValue(ETriState.True)));
- RblSource.Items.Add(new ListItem("使用在线站点模板创建站点", ETriStateUtils.GetValue(ETriState.All)));
- }
- ControlUtils.SelectSingleItem(RblSource, ETriStateUtils.GetValue(ETriState.True));
-
- var siteTemplateDir = AuthRequest.GetQueryString("siteTemplateDir");
- var onlineTemplateName = AuthRequest.GetQueryString("onlineTemplateName");
-
- if (!string.IsNullOrEmpty(siteTemplateDir))
- {
- HihSiteTemplateDir.Value = siteTemplateDir;
- ControlUtils.SelectSingleItem(RblSource, ETriStateUtils.GetValue(ETriState.False));
- BtnNext_Click(null, EventArgs.Empty);
- }
- else if (!string.IsNullOrEmpty(onlineTemplateName))
- {
- HihOnlineTemplateName.Value = onlineTemplateName;
- ControlUtils.SelectSingleItem(RblSource, ETriStateUtils.GetValue(ETriState.All));
- BtnNext_Click(null, EventArgs.Empty);
- }
- }
-
- private bool IsSiteTemplate => ETriStateUtils.GetEnumType(RblSource.SelectedValue) == ETriState.False;
-
- private bool IsOnlineTemplate => ETriStateUtils.GetEnumType(RblSource.SelectedValue) == ETriState.All;
-
- public void RblIsRoot_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhIsNotRoot.Visible = !TranslateUtils.ToBool(RblIsRoot.SelectedValue);
- }
-
- public void RblIsSiteTemplateTable_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhTableName.Visible = !TranslateUtils.ToBool(RblIsSiteTemplateTable.SelectedValue);
- }
-
- public void RblIsCheckContentUseLevel_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- PhCheckContentLevel.Visible = EBooleanUtils.Equals(RblIsCheckContentUseLevel.SelectedValue, EBoolean.True);
- }
-
- public void BtnNext_Click(object sender, EventArgs e)
- {
- if (PhSource.Visible)
- {
- HideAll();
-
- if (IsSiteTemplate)
- {
- var siteTemplates = SiteTemplateManager.Instance.GetSiteTemplateSortedList();
-
- RptSiteTemplates.DataSource = siteTemplates.Values;
- RptSiteTemplates.ItemDataBound += RptSiteTemplates_ItemDataBound;
- RptSiteTemplates.DataBind();
-
- ShowSiteTemplates();
- }
- else if (IsOnlineTemplate)
- {
- List> list;
- if (OnlineTemplateManager.TryGetOnlineTemplates(out list))
- {
- RptOnlineTemplates.DataSource = list;
- RptOnlineTemplates.ItemDataBound += RptOnlineTemplates_ItemDataBound;
- RptOnlineTemplates.DataBind();
-
- ShowOnlineTemplates();
- }
- else
- {
- FailMessage($"在线模板获取失败:页面地址{OnlineTemplateManager.UrlHome}无法访问!");
-
- ShowSource();
- }
- }
- else
- {
- LtlSource.Text = "创建空站点(不使用站点模板)";
-
- ShowSubmit();
- }
- }
- else if (PhSiteTemplates.Visible)
- {
- HideAll();
-
- var siteTemplateDir = HihSiteTemplateDir.Value;
-
- if (string.IsNullOrEmpty(siteTemplateDir))
- {
- FailMessage("请选择需要使用的站点模板");
- ShowSiteTemplates();
- return;
- }
-
- LtlSource.Text = $"使用本地站点模板创建站点({siteTemplateDir})";
-
- ShowSubmit();
- }
- else if (PhOnlineTemplates.Visible)
- {
- HideAll();
-
- var onlineTemplateName = HihOnlineTemplateName.Value;
-
- if (string.IsNullOrEmpty(onlineTemplateName))
- {
- FailMessage("请选择需要使用的在线站点模板");
- ShowOnlineTemplates();
- return;
- }
-
- LtlSource.Text = $@"使用在线站点模板创建站点({onlineTemplateName} )";
-
- ShowSubmit();
- }
- }
-
- public void BtnSubmit_Click(object sender, EventArgs e)
- {
- HideAll();
-
- string errorMessage;
- var theSiteId = Validate_SiteInfo(out errorMessage);
- if (theSiteId > 0)
- {
- var siteTemplateDir = IsSiteTemplate ? HihSiteTemplateDir.Value : string.Empty;
- var onlineTemplateName = IsOnlineTemplate ? HihOnlineTemplateName.Value : string.Empty;
- PageUtils.Redirect(PageProgressBar.GetCreateSiteUrl(theSiteId,
- CbIsImportContents.Checked, CbIsImportTableStyles.Checked, siteTemplateDir, onlineTemplateName,
- TranslateUtils.ToBool(RblIsSiteTemplateTable.SelectedValue), StringUtils.Guid()));
- }
- else
- {
- FailMessage(errorMessage);
-
- ShowSubmit();
- }
- }
-
- public void BtnPrevious_Click(object sender, EventArgs e)
- {
- if (PhSiteTemplates.Visible || PhOnlineTemplates.Visible)
- {
- HideAll();
- ShowSource();
- }
- else if (PhSubmit.Visible)
- {
- HideAll();
-
- if (IsSiteTemplate)
- {
- ShowSiteTemplates();
- }
- else if (IsOnlineTemplate)
- {
- ShowOnlineTemplates();
- }
- else
- {
- ShowSource();
- }
- }
- }
-
- private void RptSiteTemplates_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.AlternatingItem && e.Item.ItemType != ListItemType.Item) return;
-
- var templateInfo = (SiteTemplateInfo)e.Item.DataItem;
- if (templateInfo == null) return;
-
- var directoryPath = PathUtility.GetSiteTemplatesPath(templateInfo.DirectoryName);
- var directoryInfo = new DirectoryInfo(directoryPath);
-
- var ltlChoose = (Literal)e.Item.FindControl("ltlChoose");
- var ltlTemplateName = (Literal)e.Item.FindControl("ltlTemplateName");
- var ltlName = (Literal)e.Item.FindControl("ltlName");
- var ltlDescription = (Literal)e.Item.FindControl("ltlDescription");
- var ltlSamplePic = (Literal)e.Item.FindControl("ltlSamplePic");
-
- ltlChoose.Text = $@"选中 ";
-
- if (!string.IsNullOrEmpty(templateInfo.SiteTemplateName))
- {
- ltlTemplateName.Text = !string.IsNullOrEmpty(templateInfo.WebSiteUrl) ? $@"{templateInfo.SiteTemplateName} " : templateInfo.SiteTemplateName;
- }
-
- ltlName.Text = directoryInfo.Name;
-
- if (!string.IsNullOrEmpty(templateInfo.Description))
- {
- ltlDescription.Text = templateInfo.Description;
- }
-
- if (!string.IsNullOrEmpty(templateInfo.PicFileName))
- {
- var siteTemplateUrl = PageUtils.GetSiteTemplatesUrl(directoryInfo.Name);
- var picFileName = PageUtils.GetSiteTemplateMetadataUrl(siteTemplateUrl, templateInfo.PicFileName);
- ltlSamplePic.Text = $@"样图 ";
- }
- }
-
- private void RptOnlineTemplates_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.AlternatingItem && e.Item.ItemType != ListItemType.Item) return;
-
- var dict = (Dictionary)e.Item.DataItem;
- var title = dict["title"];
- var description = dict["description"];
- var author = dict["author"];
- var source = dict["source"];
- var lastEditDate = dict["lastEditDate"];
-
- var ltlChoose = (Literal)e.Item.FindControl("ltlChoose");
- var ltlTitle = (Literal)e.Item.FindControl("ltlTitle");
- var ltlDescription = (Literal)e.Item.FindControl("ltlDescription");
- var ltlAuthor = (Literal)e.Item.FindControl("ltlAuthor");
- var ltlLastEditDate = (Literal)e.Item.FindControl("ltlLastEditDate");
- var ltlPreviewUrl = (Literal)e.Item.FindControl("ltlPreviewUrl");
-
- ltlChoose.Text = $@"选中 ";
-
- var templateUrl = OnlineTemplateManager.GetTemplateUrl(title);
-
- ltlTitle.Text = $@"{title} ";
-
- ltlDescription.Text = description;
- ltlAuthor.Text = author;
- if (!string.IsNullOrEmpty(source) && PageUtils.IsProtocolUrl(source))
- {
- ltlAuthor.Text = $@"{ltlAuthor.Text} ";
- }
- ltlLastEditDate.Text = lastEditDate;
-
- ltlPreviewUrl.Text = $@"模板详情 ";
- }
-
- private int Validate_SiteInfo(out string errorMessage)
- {
- try
- {
- var isHq = TranslateUtils.ToBool(RblIsRoot.SelectedValue); // 是否主站
- var parentSiteId = 0;
- var siteDir = string.Empty;
-
- if (isHq == false)
- {
- if (DirectoryUtils.IsSystemDirectory(TbSiteDir.Text))
- {
- errorMessage = "文件夹名称不能为系统文件夹名称!";
- return 0;
- }
-
- parentSiteId = TranslateUtils.ToInt(DdlParentId.SelectedValue);
- siteDir = TbSiteDir.Text;
-
- var list = DataProvider.SiteDao.GetLowerSiteDirList(parentSiteId);
- if (list.IndexOf(siteDir.ToLower()) != -1)
- {
- errorMessage = "已存在相同的发布路径!";
- return 0;
- }
-
- if (!DirectoryUtils.IsDirectoryNameCompliant(siteDir))
- {
- errorMessage = "文件夹名称不符合系统要求!";
- return 0;
- }
- }
-
- var nodeInfo = new ChannelInfo();
-
- nodeInfo.ChannelName = nodeInfo.IndexName = "首页";
- nodeInfo.ParentId = 0;
- nodeInfo.ContentModelPluginId = string.Empty;
-
- var psInfo = new SiteInfo
- {
- SiteName = PageUtils.FilterXss(TbSiteName.Text),
- SiteDir = siteDir,
- TableName = DdlTableName.SelectedValue,
- ParentId = parentSiteId,
- IsRoot = isHq
- };
-
- psInfo.Additional.IsCheckContentLevel = TranslateUtils.ToBool(RblIsCheckContentUseLevel.SelectedValue);
-
- if (psInfo.Additional.IsCheckContentLevel)
- {
- psInfo.Additional.CheckContentLevel = TranslateUtils.ToInt(DdlCheckContentLevel.SelectedValue);
- }
- psInfo.Additional.Charset = DdlCharset.SelectedValue;
-
- var theSiteId = DataProvider.ChannelDao.InsertSiteInfo(nodeInfo, psInfo, AuthRequest.AdminName);
-
- if (AuthRequest.AdminPermissions.IsSystemAdministrator && !AuthRequest.AdminPermissions.IsConsoleAdministrator)
- {
- var siteIdList = AuthRequest.AdminPermissions.SiteIdList ?? new List();
- siteIdList.Add(theSiteId);
- DataProvider.AdministratorDao.UpdateSiteIdCollection(AuthRequest.AdminName, TranslateUtils.ObjectCollectionToString(siteIdList));
- }
-
- AuthRequest.AddAdminLog("创建新站点", $"站点名称:{PageUtils.FilterXss(TbSiteName.Text)}");
-
- errorMessage = string.Empty;
- return theSiteId;
- }
- catch (Exception e)
- {
- errorMessage = e.Message;
- return 0;
- }
- }
-
- private static void AddSite(ListControl listControl, SiteInfo siteInfo, Hashtable parentWithChildren, int level)
- {
- if (level > 1) return;
- var padding = string.Empty;
- for (var i = 0; i < level; i++)
- {
- padding += " ";
- }
- if (level > 0)
- {
- padding += "└ ";
- }
-
- if (parentWithChildren[siteInfo.Id] != null)
- {
- var children = (ArrayList)parentWithChildren[siteInfo.Id];
- listControl.Items.Add(new ListItem(padding + siteInfo.SiteName + $"({children.Count})", siteInfo.Id.ToString()));
- level++;
- foreach (SiteInfo subSiteInfo in children)
- {
- AddSite(listControl, subSiteInfo, parentWithChildren, level);
- }
- }
- else
- {
- listControl.Items.Add(new ListItem(padding + siteInfo.SiteName, siteInfo.Id.ToString()));
- }
- }
-
- private void HideAll()
- {
- PhSource.Visible =
- PhSiteTemplates.Visible =
- PhOnlineTemplates.Visible =
- PhSubmit.Visible = PhIsImportContents.Visible =
- PhIsImportTableStyles.Visible =
- PhIsSiteTemplateTable.Visible =
- PhTableName.Visible =
- BtnPrevious.Enabled = BtnNext.Visible = BtnSubmit.Visible = false;
- }
-
- private void ShowSource()
- {
- PhSource.Visible = BtnNext.Visible = true;
- }
-
- private void ShowSiteTemplates()
- {
- PhSiteTemplates.Visible = BtnPrevious.Enabled = BtnNext.Visible = true;
- }
-
- private void ShowOnlineTemplates()
- {
- PhOnlineTemplates.Visible = BtnPrevious.Enabled = BtnNext.Visible = true;
- }
-
- private void ShowSubmit()
- {
- if (IsSiteTemplate)
- {
- PhSubmit.Visible =
- PhIsImportContents.Visible =
- PhIsImportTableStyles.Visible =
- PhIsSiteTemplateTable.Visible =
- PhTableName.Visible = BtnPrevious.Enabled = BtnSubmit.Visible = true;
- }
- else if (IsOnlineTemplate)
- {
- PhSubmit.Visible =
- PhIsImportContents.Visible =
- PhIsImportTableStyles.Visible =
- PhIsSiteTemplateTable.Visible =
- PhTableName.Visible = BtnPrevious.Enabled = BtnSubmit.Visible = true;
- }
- else
- {
- PhSubmit.Visible = PhTableName.Visible = BtnPrevious.Enabled = BtnSubmit.Visible = true;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteAuxiliaryTable.cs b/SiteServer.BackgroundPages/Settings/PageSiteAuxiliaryTable.cs
deleted file mode 100644
index fdc7a8300..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteAuxiliaryTable.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteAuxiliaryTable : BasePageCms
- {
- public Repeater RptContents;
- public Button BtnAdd;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteAuxiliaryTable), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var enName = AuthRequest.GetQueryString("ENName");//辅助表
- var enNameArchive = enName + "_Archive";//辅助表归档
-
- try
- {
- DataProvider.TableDao.DeleteCollectionTableInfoAndDbTable(enName);//删除辅助表
- DataProvider.TableDao.DeleteCollectionTableInfoAndDbTable(enNameArchive);//删除辅助表归档
-
- AuthRequest.AddAdminLog("删除辅助表", $"辅助表:{enName}");
-
- SuccessDeleteMessage();
- }
- catch(Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- RptContents.DataSource = DataProvider.TableDao.GetTableCollectionInfoList();
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- BtnAdd.OnClientClick = ModalAuxiliaryTableAdd.GetOpenWindowString();
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var collectionInfo = (TableInfo)e.Item.DataItem;
- var tableName = collectionInfo.TableName;
- //var isHighlight = !collectionInfo.IsCreatedInDb || collectionInfo.IsChangedAfterCreatedInDb;
- var isTableUsed = DataProvider.SiteDao.IsTableUsed(tableName);
-
- //if (isHighlight) e.Item.Attributes.Add("style", "color: red");
-
- var ltlTableName = (Literal)e.Item.FindControl("ltlTableName");
- var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName");
- var ltlIsUsed = (Literal)e.Item.FindControl("ltlIsUsed");
- var ltlIsCreatedInDb = (Literal)e.Item.FindControl("ltlIsCreatedInDB");
- var ltlIsChangedAfterCreatedInDb = (Literal)e.Item.FindControl("ltlIsChangedAfterCreatedInDb");
- var ltlMetadataEdit = (Literal)e.Item.FindControl("ltlMetadataEdit");
- var ltlStyleEdit = (Literal)e.Item.FindControl("ltlStyleEdit");
- var ltlEdit = (Literal)e.Item.FindControl("ltlEdit");
- var ltlDelete = (Literal)e.Item.FindControl("ltlDelete");
-
- ltlTableName.Text = tableName;
- ltlDisplayName.Text = collectionInfo.DisplayName;
- ltlIsUsed.Text = StringUtils.GetBoolText(isTableUsed);
- ltlIsCreatedInDb.Text = StringUtils.GetBoolText(collectionInfo.IsCreatedInDb);
- ltlIsChangedAfterCreatedInDb.Text = collectionInfo.IsCreatedInDb == false
- ? "----"
- : StringUtils.GetBoolText(collectionInfo.IsChangedAfterCreatedInDb);
-
- ltlMetadataEdit.Text =
- $@"管理真实字段 ";
-
- ltlStyleEdit.Text = $@"管理虚拟字段 ";
-
- ltlEdit.Text = $@"编辑 ";
-
- if (!isTableUsed)
- {
- var script = AlertUtils.Warning("删除辅助表", $"此操作将删除辅助表“{tableName}”,如果辅助表已在数据库中建立,将同时删除建立的辅助表,确认吗?", "取 消",
- "确认删除", $"location.href = '{GetRedirectUrl()}?Delete=True&ENName={tableName}';");
- ltlDelete.Text =
- $@"删除 ";
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteEdit.cs b/SiteServer.BackgroundPages/Settings/PageSiteEdit.cs
deleted file mode 100644
index aa1416bed..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteEdit.cs
+++ /dev/null
@@ -1,239 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteEdit : BasePageCms
- {
- public TextBox TbSiteName;
- public PlaceHolder PhSiteDir;
- public TextBox TbSiteDir;
- public PlaceHolder PhParentId;
- public DropDownList DdlParentId;
- public DropDownList DdlTableName;
- public TextBox TbTaxis;
- public RadioButtonList RblIsCheckContentUseLevel;
- public PlaceHolder PhCheckContentLevel;
- public DropDownList DdlCheckContentLevel;
- public Button BtnSubmit;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteEdit), new NameValueCollection
- {
- {"siteId", siteId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("siteId");
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- if (SiteInfo.IsRoot)
- {
- PhParentId.Visible = false;
- }
- else
- {
- PhParentId.Visible = true;
-
- DdlParentId.Items.Add(new ListItem("<无上级站点>", "0"));
- var siteIdList = SiteManager.GetSiteIdList();
- var mySystemInfoArrayList = new ArrayList();
- var parentWithChildren = new Hashtable();
- foreach (var siteId in siteIdList)
- {
- if (siteId == SiteId) continue;
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- if (siteInfo.IsRoot == false)
- {
- if (siteInfo.ParentId == 0)
- {
- mySystemInfoArrayList.Add(siteInfo);
- }
- else
- {
- var children = new ArrayList();
- if (parentWithChildren.Contains(siteInfo.ParentId))
- {
- children = (ArrayList)parentWithChildren[siteInfo.ParentId];
- }
- children.Add(siteInfo);
- parentWithChildren[siteInfo.ParentId] = children;
- }
- }
- }
- foreach (SiteInfo siteInfo in mySystemInfoArrayList)
- {
- AddSite(DdlParentId, siteInfo, parentWithChildren, 0);
- }
- ControlUtils.SelectSingleItem(DdlParentId, SiteInfo.ParentId.ToString());
- }
-
- var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb();
- foreach (var tableInfo in tableList)
- {
- if (tableInfo.DisplayName.StartsWith("插件内容表:")) continue;
-
- var li = new ListItem($"{tableInfo.DisplayName}({tableInfo.TableName})", tableInfo.TableName);
- DdlTableName.Items.Add(li);
- }
-
- TbTaxis.Text = SiteInfo.Taxis.ToString();
-
- RblIsCheckContentUseLevel.Items.Add(new ListItem("默认审核机制",false.ToString()));
- RblIsCheckContentUseLevel.Items.Add(new ListItem("多级审核机制", true.ToString()));
-
- if (SiteInfo == null)
- {
- PageUtils.RedirectToErrorPage("站点不存在,请确认后再试!");
- return;
- }
- TbSiteName.Text = SiteInfo.SiteName;
- ControlUtils.SelectSingleItem(RblIsCheckContentUseLevel, SiteInfo.Additional.IsCheckContentLevel.ToString());
- if (SiteInfo.Additional.IsCheckContentLevel)
- {
- ControlUtils.SelectSingleItem(DdlCheckContentLevel, SiteInfo.Additional.CheckContentLevel.ToString());
- PhCheckContentLevel.Visible = true;
- }
- else
- {
- PhCheckContentLevel.Visible = false;
- }
- if (!string.IsNullOrEmpty(SiteInfo.SiteDir))
- {
- TbSiteDir.Text = PathUtils.GetDirectoryName(SiteInfo.SiteDir, false);
- }
- if (SiteInfo.IsRoot)
- {
- PhSiteDir.Visible = false;
- }
- foreach (ListItem item in DdlTableName.Items)
- {
- item.Selected = item.Value.Equals(SiteInfo.TableName);
- }
-
- BtnSubmit.Attributes.Add("onclick", GetShowHintScript());
- }
-
- private static void AddSite(ListControl listControl, SiteInfo siteInfo, Hashtable parentWithChildren, int level)
- {
- var padding = string.Empty;
- for (var i = 0; i < level; i++)
- {
- padding += " ";
- }
- if (level > 0)
- {
- padding += "└ ";
- }
-
- if (parentWithChildren[siteInfo.Id] != null)
- {
- var children = (ArrayList)parentWithChildren[siteInfo.Id];
- listControl.Items.Add(new ListItem(padding + siteInfo.SiteName +
- $"({children.Count})", siteInfo.Id.ToString()));
- level++;
- foreach (SiteInfo subSiteInfo in children)
- {
- AddSite(listControl, subSiteInfo, parentWithChildren, level);
- }
- }
- else
- {
- listControl.Items.Add(new ListItem(padding + siteInfo.SiteName, siteInfo.Id.ToString()));
- }
- }
-
- public void RblIsCheckContentUseLevel_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- PhCheckContentLevel.Visible = EBooleanUtils.Equals(RblIsCheckContentUseLevel.SelectedValue, EBoolean.True);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- SiteInfo.SiteName = TbSiteName.Text;
- SiteInfo.Taxis = TranslateUtils.ToInt(TbTaxis.Text);
- SiteInfo.Additional.IsCheckContentLevel = TranslateUtils.ToBool(RblIsCheckContentUseLevel.SelectedValue);
- if (SiteInfo.Additional.IsCheckContentLevel)
- {
- SiteInfo.Additional.CheckContentLevel = TranslateUtils.ToInt(DdlCheckContentLevel.SelectedValue);
- }
-
- var isTableChanged = false;
-
- if (SiteInfo.TableName != DdlTableName.SelectedValue)
- {
- isTableChanged = true;
- SiteInfo.TableName = DdlTableName.SelectedValue;
- }
-
- if (SiteInfo.IsRoot == false)
- {
- if (!StringUtils.EqualsIgnoreCase(PathUtils.GetDirectoryName(SiteInfo.SiteDir, false), TbSiteDir.Text))
- {
- var list = DataProvider.SiteDao.GetLowerSiteDirList(SiteInfo.ParentId);
- if (list.IndexOf(TbSiteDir.Text.ToLower()) != -1)
- {
- FailMessage("站点修改失败,已存在相同的发布路径!");
- return;
- }
-
- var parentPsPath = WebConfigUtils.PhysicalApplicationPath;
- if (SiteInfo.ParentId > 0)
- {
- var parentSiteInfo = SiteManager.GetSiteInfo(SiteInfo.ParentId);
- parentPsPath = PathUtility.GetSitePath(parentSiteInfo);
- }
- DirectoryUtility.ChangeSiteDir(parentPsPath, SiteInfo.SiteDir, TbSiteDir.Text);
- }
-
- if (PhParentId.Visible && SiteInfo.ParentId != TranslateUtils.ToInt(DdlParentId.SelectedValue))
- {
- var newParentId = TranslateUtils.ToInt(DdlParentId.SelectedValue);
- var list = DataProvider.SiteDao.GetLowerSiteDirList(newParentId);
- if (list.IndexOf(TbSiteDir.Text.ToLower()) != -1)
- {
- FailMessage("站点修改失败,已存在相同的发布路径!");
- return;
- }
-
- DirectoryUtility.ChangeParentSite(SiteInfo.ParentId, TranslateUtils.ToInt(DdlParentId.SelectedValue), SiteId, TbSiteDir.Text);
- SiteInfo.ParentId = newParentId;
- }
-
- SiteInfo.SiteDir = TbSiteDir.Text;
- }
-
- DataProvider.SiteDao.Update(SiteInfo);
- if (isTableChanged)
- {
- DataProvider.ChannelDao.UpdateContentNum(SiteInfo);
- }
-
- AuthRequest.AddAdminLog("修改站点属性", $"站点:{SiteInfo.SiteName}");
-
- SuccessMessage("站点修改成功!");
- AddWaitAndRedirectScript(PageSite.GetRedirectUrl());
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageSite.GetRedirectUrl());
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteReplace.cs b/SiteServer.BackgroundPages/Settings/PageSiteReplace.cs
deleted file mode 100644
index a6914fd88..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteReplace.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.IO;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Cms;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteReplace : BasePageCms
- {
- public Literal LtlSiteName;
- public PlaceHolder PhChooseSiteTemplate;
- public Repeater RptContents;
- public HtmlInputHidden HihSiteTemplateDir;
-
- public PlaceHolder PhCreateSiteParameters;
- public Literal LtlSiteTemplateName;
- public RadioButtonList RblIsDeleteChannels;
- public RadioButtonList RblIsDeleteTemplates;
- public RadioButtonList RblIsDeleteFiles;
- public RadioButtonList RblIsOverride;
-
- public Button BtnNext;
- public Button BtnSubmit;
-
- private SortedList _sortedlist = new SortedList();
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteReplace), new NameValueCollection
- {
- {"siteId", siteId.ToString()}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _sortedlist = SiteTemplateManager.Instance.GetSiteTemplateSortedList();
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- LtlSiteName.Text = SiteInfo.SiteName;
-
- var directoryList = new List();
- foreach (string directoryName in _sortedlist.Keys)
- {
- var directoryPath = PathUtility.GetSiteTemplatesPath(directoryName);
- var dirInfo = new DirectoryInfo(directoryPath);
- directoryList.Add(dirInfo);
- }
-
- RptContents.DataSource = directoryList;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- if (SiteTemplateManager.Instance.GetSiteTemplateCount() == 0)
- {
- PageUtils.RedirectToErrorPage("无站点模板!");
- }
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.AlternatingItem && e.Item.ItemType != ListItemType.Item) return;
-
- var directoryInfo = (DirectoryInfo)e.Item.DataItem;
- var siteTemplateInfo = _sortedlist[directoryInfo.Name] as SiteTemplateInfo;
-
- if (siteTemplateInfo == null) return;
-
- var ltlChoose = (Literal)e.Item.FindControl("ltlChoose");
- var ltlTemplateName = (Literal)e.Item.FindControl("ltlTemplateName");
- var ltlName = (Literal)e.Item.FindControl("ltlName");
- var ltlDescription = (Literal)e.Item.FindControl("ltlDescription");
- var ltlSamplePic = (Literal)e.Item.FindControl("ltlSamplePic");
-
- ltlChoose.Text = $@"选中 ";
-
- if (!string.IsNullOrEmpty(siteTemplateInfo.SiteTemplateName))
- {
- ltlTemplateName.Text = !string.IsNullOrEmpty(siteTemplateInfo.WebSiteUrl) ? $"{siteTemplateInfo.SiteTemplateName} " : siteTemplateInfo.SiteTemplateName;
- }
-
- ltlName.Text = directoryInfo.Name;
-
- if (!string.IsNullOrEmpty(siteTemplateInfo.Description))
- {
- ltlDescription.Text = siteTemplateInfo.Description;
- }
-
- if (!string.IsNullOrEmpty(siteTemplateInfo.PicFileName))
- {
- var siteTemplateUrl = PageUtils.GetSiteTemplatesUrl(directoryInfo.Name);
- var picFileName = PageUtils.GetSiteTemplateMetadataUrl(siteTemplateUrl, siteTemplateInfo.PicFileName);
- ltlSamplePic.Text = $@"样图 ";
- }
- }
-
- public void BtnNext_Click(object sender, EventArgs e)
- {
- var siteTemplateDir = HihSiteTemplateDir.Value;
- var siteTemplateInfo = _sortedlist[siteTemplateDir] as SiteTemplateInfo;
-
- if (siteTemplateInfo == null)
- {
- FailMessage("请选择需要替换的站点模板");
- return;
- }
-
- LtlSiteTemplateName.Text = !string.IsNullOrEmpty(siteTemplateInfo.WebSiteUrl) ? $"{siteTemplateInfo.SiteTemplateName} " : siteTemplateInfo.SiteTemplateName;
-
- PhChooseSiteTemplate.Visible = false;
- PhCreateSiteParameters.Visible = true;
- BtnNext.Visible = false;
- BtnSubmit.Visible = true;
- }
-
- public void BtnSubmit_Click(object sender, EventArgs e)
- {
- var siteTemplateDir = HihSiteTemplateDir.Value;
-
- var userKeyPrefix = StringUtils.Guid();
- var siteTemplatePath = PathUtility.GetSiteTemplatesPath(siteTemplateDir);
-
- AuthRequest.AddAdminLog("整站替换", $"站点:{SiteInfo.SiteName}");
-
- PageUtils.Redirect(PageProgressBar.GetRecoveryUrl(SiteId, RblIsDeleteChannels.SelectedValue, RblIsDeleteTemplates.SelectedValue, RblIsDeleteFiles.SelectedValue, false, siteTemplatePath, RblIsOverride.SelectedValue, RblIsOverride.SelectedValue, userKeyPrefix));
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageSite.GetRedirectUrl());
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteTableMetadata.cs b/SiteServer.BackgroundPages/Settings/PageSiteTableMetadata.cs
deleted file mode 100644
index 74449ac01..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteTableMetadata.cs
+++ /dev/null
@@ -1,315 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteTableMetadata : BasePageCms
- {
- public Repeater RptContents;
- public PlaceHolder PhSyncTable;
- public PlaceHolder PhSqlString;
- public Literal LtlSqlString;
- public Button BtnAdd;
- public Button BtnCreateDb;
- public Button BtnDelete;
- public Button BtnReCreateDb;
- public Button BtnSqlString;
-
- private bool _showSqlTable = true;
- private string _tableName;
- private bool _tableIsRealCreated;
- private bool _isTableUsed;
- private string _redirectUrl;
-
- public static string GetRedirectUrl(string tableName)
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteTableMetadata), new NameValueCollection
- {
- {"ENName", tableName}
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- PageUtils.CheckRequestParameter("ENName");
- _showSqlTable = AuthRequest.IsQueryExists("ShowCrateDBCommand");
-
- _tableName = AuthRequest.GetQueryString("ENName").Trim();
- _redirectUrl = GetRedirectUrl(_tableName);
-
- var tableInfo = DataProvider.TableDao.GetTableCollectionInfo(_tableName);
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var tableMetadataId = AuthRequest.GetQueryInt("TableMetadataID");
-
- try
- {
- var tableMetadataInfo = DataProvider.TableMetadataDao.GetTableMetadataInfo(tableMetadataId);
- DataProvider.TableMetadataDao.Delete(tableMetadataId);
-
- AuthRequest.AddAdminLog("删除辅助表字段", $"辅助表:{_tableName},字段名:{tableMetadataInfo.AttributeName}");
-
- SuccessDeleteMessage();
- PageUtils.Redirect(_redirectUrl);
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- else if (AuthRequest.IsQueryExists("DeleteStyle"))//删除样式
- {
- var attributeName = AuthRequest.GetQueryString("AttributeName");
- if (TableStyleManager.IsExists(0, _tableName, attributeName))
- {
- try
- {
- TableStyleManager.Delete(0, _tableName, attributeName);
-
- AuthRequest.AddAdminLog("删除辅助表字段样式", $"辅助表:{_tableName},字段名:{attributeName}");
-
- SuccessDeleteMessage();
- PageUtils.Redirect(_redirectUrl);
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- }
- else if (AuthRequest.IsQueryExists("CreateDB"))
- {
- try
- {
- DataProvider.TableDao.CreateDbTable(_tableName);
- tableInfo.IsChangedAfterCreatedInDb = false;
-
- AuthRequest.AddAdminLog("创建辅助表", $"辅助表:{_tableName}");
-
- SuccessMessage("辅助表创建成功!");
- PageUtils.Redirect(_redirectUrl);
- }
- catch (Exception ex)
- {
- FailMessage(ex, " 辅助表创建失败,失败原因为:" + ex.Message + " 请检查创建表SQL命令");
- var sqlString = DataProvider.ContentDao.GetCreateTableCollectionInfoSqlString(_tableName);
- LtlSqlString.Text = sqlString.Replace("\r\n", " ").Replace("\t", " ");
- _showSqlTable = true;
- }
- }
- else if (AuthRequest.IsQueryExists("DeleteDB"))
- {
- try
- {
- DataProvider.TableDao.DeleteDbTable(_tableName);
- tableInfo.IsChangedAfterCreatedInDb = false;
-
- AuthRequest.AddAdminLog("删除辅助表", $"辅助表:{_tableName}");
-
- SuccessMessage("辅助表删除成功!");
- PageUtils.Redirect(_redirectUrl);
- }
- catch (Exception ex)
- {
-
- FailMessage(ex, " 辅助表删除失败,失败原因为:" + ex.Message + " ");
- }
- }
- else if (AuthRequest.IsQueryExists("ReCreateDB"))
- {
- try
- {
- DataProvider.TableDao.ReCreateDbTable(_tableName);
- DataProvider.ChannelDao.UpdateContentNumToZero(_tableName);
- tableInfo.IsChangedAfterCreatedInDb = false;
-
- AuthRequest.AddAdminLog("重建辅助表", $"辅助表:{_tableName}");
-
- SuccessMessage("辅助表重建成功!");
- PageUtils.Redirect(_redirectUrl);
- }
- catch (Exception ex)
- {
-
- FailMessage(ex, " 辅助表重建失败,失败原因为:" + ex.Message + " 请检查创建表SQL命令");
- var sqlString = DataProvider.ContentDao.GetCreateTableCollectionInfoSqlString(_tableName);
- LtlSqlString.Text = sqlString.Replace("\r\n", " ").Replace("\t", " ");
- _showSqlTable = true;
- }
- }
- else if (AuthRequest.IsQueryExists("ShowCrateDBCommand"))
- {
- var sqlString = DataProvider.ContentDao.GetCreateTableCollectionInfoSqlString(_tableName);
- LtlSqlString.Text = sqlString.Replace("\r\n", " ").Replace("\t", " ");
- }
- else if (AuthRequest.IsQueryExists("SetTaxis"))
- {
- var direction = AuthRequest.GetQueryString("Direction");
- var tableMetadataId = AuthRequest.GetQueryInt("TableMetadataId");
- switch (direction.ToUpper())
- {
- case "UP":
- DataProvider.TableMetadataDao.TaxisDown(tableMetadataId, _tableName);
- break;
- case "DOWN":
- DataProvider.TableMetadataDao.TaxisUp(tableMetadataId, _tableName);
- break;
- }
- SuccessMessage("排序成功!");
- }
-
- _tableIsRealCreated = DataProvider.DatabaseDao.IsTableExists(_tableName);
-
- _isTableUsed = DataProvider.SiteDao.IsTableUsed(_tableName);
-
- PhSyncTable.Visible = _tableIsRealCreated && tableInfo.IsChangedAfterCreatedInDb;
- PhSqlString.Visible = _showSqlTable;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- RptContents.DataSource = DataProvider.TableMetadataDao.GetDataSource(_tableName);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
-
- BtnAdd.Attributes.Add("onclick", ModalTableMetadataAdd.GetOpenWindowStringToAdd(_tableName));
-
- var redirectUrl = GetRedirectUrl(_tableName);
-
- bool isBtnCreateDb;
- if (string.IsNullOrEmpty(_tableName))
- {
- isBtnCreateDb = false;
- }
- else
- {
- isBtnCreateDb = !_tableIsRealCreated;
- }
- if (isBtnCreateDb)
- {
- BtnCreateDb.Attributes.Add("onclick", $"location.href='{redirectUrl}&CreateDB={true}';return false;");
- }
- else
- {
- BtnCreateDb.Visible = false;
- }
-
- bool isBtnDelete;
- if (_tableName == null)
- {
- isBtnDelete = false;
- }
- else
- {
- isBtnDelete = !_isTableUsed;
- }
- if (isBtnDelete)
- {
- BtnDelete.Attributes.Add("onclick", $"if (confirm('此操作将删除辅助表“{_tableName}”,确认吗?'))location.href='{redirectUrl}&DeleteDB={true}';return false;");
- }
- else
- {
- BtnDelete.Visible = false;
- }
-
- if (isBtnCreateDb)
- {
- BtnReCreateDb.Attributes.Add("onclick", $"if (confirm('此操作将覆盖已建立的辅助表,表中已存数据将丢失,确认吗?'))location.href='{redirectUrl}&ReCreateDB={true}';return false;");
- }
- else
- {
- BtnReCreateDb.Visible = false;
- }
-
- var isSqlString = !string.IsNullOrEmpty(_tableName);
- if (isSqlString)
- {
- BtnSqlString.Attributes.Add("onclick", $"location.href='{redirectUrl}&ShowCrateDBCommand={true}';return false;");
- }
- else
- {
- BtnSqlString.Visible = false;
- }
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var tableMetadataId = SqlUtils.EvalInt(e.Item.DataItem, nameof(TableMetadataInfo.Id));
- var attributeName = SqlUtils.EvalString(e.Item.DataItem, nameof(TableMetadataInfo.AttributeName));
- var dataType = SqlUtils.EvalString(e.Item.DataItem, nameof(TableMetadataInfo.DataType));
- var isSystem = SqlUtils.EvalString(e.Item.DataItem, nameof(TableMetadataInfo.IsSystem));
-
- var ltlAttributeName = (Literal)e.Item.FindControl("ltlAttributeName");
- var ltlDataType = (Literal)e.Item.FindControl("ltlDataType");
- var hlUp = (HyperLink)e.Item.FindControl("hlUp");
- var hlDown = (HyperLink)e.Item.FindControl("hlDown");
- var ltlEditUrl = (Literal)e.Item.FindControl("ltlEditUrl");
- var ltlDeleteUrl = (Literal)e.Item.FindControl("ltlDeleteUrl");
-
- ltlAttributeName.Text = attributeName;
-
- ltlDataType.Text = DataTypeUtils.GetText(DataTypeUtils.GetEnumType(dataType));
-
- if (TranslateUtils.ToBool(isSystem))
- {
- hlUp.Visible = hlDown.Visible = false;
- return;
- }
-
- hlUp.NavigateUrl = PageUtils.GetSettingsUrl(nameof(PageSiteTableMetadata),
- new NameValueCollection
- {
- {"SiteId", SiteId.ToString()},
- {"SetTaxis", "True"},
- {"Direction", "UP"},
- {"TableMetadataId", tableMetadataId.ToString()},
- {"ENName", _tableName}
- });
-
- hlDown.NavigateUrl = PageUtils.GetSettingsUrl(nameof(PageSiteTableMetadata),
- new NameValueCollection
- {
- {"SiteId", SiteId.ToString()},
- {"SetTaxis", "True"},
- {"Direction", "DOWN"},
- {"TableMetadataId", tableMetadataId.ToString()},
- {"ENName", _tableName}
- });
-
- ltlEditUrl.Text =
- $@"修改字段 ";
-
- ltlDeleteUrl.Text =
- $@"删除字段 ";
- }
-
- public void SyncTableButton_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- DataProvider.TableDao.SyncDbTable(_tableName);
- PhSyncTable.Visible = false;
- SuccessMessage("同步辅助表成功!");
- PageUtils.Redirect(_redirectUrl);
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageSiteAuxiliaryTable.GetRedirectUrl());
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteUrlApi.cs b/SiteServer.BackgroundPages/Settings/PageSiteUrlApi.cs
deleted file mode 100644
index 7ae24cc6b..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteUrlApi.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteUrlApi : BasePage
- {
- public RadioButtonList RblIsSeparatedApi;
- public PlaceHolder PhSeparatedApi;
- public TextBox TbSeparatedApiUrl;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- EBooleanUtils.AddListItems(RblIsSeparatedApi, "API独立部署", "API与CMS部署在一起");
- ControlUtils.SelectSingleItem(RblIsSeparatedApi, ConfigManager.SystemConfigInfo.IsSeparatedApi.ToString());
- PhSeparatedApi.Visible = ConfigManager.SystemConfigInfo.IsSeparatedApi;
- TbSeparatedApiUrl.Text = ConfigManager.SystemConfigInfo.SeparatedApiUrl;
- }
-
- public void RblIsSeparatedApi_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhSeparatedApi.Visible = TranslateUtils.ToBool(RblIsSeparatedApi.SelectedValue);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- ConfigManager.SystemConfigInfo.IsSeparatedApi = TranslateUtils.ToBool(RblIsSeparatedApi.SelectedValue);
- ConfigManager.SystemConfigInfo.SeparatedApiUrl = TbSeparatedApiUrl.Text;
-
- DataProvider.ConfigDao.Update(ConfigManager.Instance);
-
- AuthRequest.AddAdminLog("修改API访问地址");
- SuccessUpdateMessage();
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteUrlAssetsConfig.cs b/SiteServer.BackgroundPages/Settings/PageSiteUrlAssetsConfig.cs
deleted file mode 100644
index f12f89901..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteUrlAssetsConfig.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteUrlAssetsConfig : BasePageCms
- {
- public Literal LtlSiteName;
-
- public RadioButtonList RblIsSeparatedAssets;
- public PlaceHolder PhSeparatedAssets;
- public TextBox TbSeparatedAssetsUrl;
- public TextBox TbAssetsDir;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteUrlAssetsConfig), new NameValueCollection
- {
- {
- "SiteId", siteId.ToString()
- }
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- LtlSiteName.Text = SiteInfo.SiteName;
-
- EBooleanUtils.AddListItems(RblIsSeparatedAssets, "资源文件独立部署", "资源文件与Web部署在一起");
- ControlUtils.SelectSingleItem(RblIsSeparatedAssets, SiteInfo.Additional.IsSeparatedAssets.ToString());
- PhSeparatedAssets.Visible = SiteInfo.Additional.IsSeparatedAssets;
- TbSeparatedAssetsUrl.Text = SiteInfo.Additional.SeparatedAssetsUrl;
- TbAssetsDir.Text = SiteInfo.Additional.AssetsDir;
- }
-
- public void RblIsSeparatedAssets_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhSeparatedAssets.Visible = TranslateUtils.ToBool(RblIsSeparatedAssets.SelectedValue);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- SiteInfo.Additional.IsSeparatedAssets = TranslateUtils.ToBool(RblIsSeparatedAssets.SelectedValue);
- SiteInfo.Additional.SeparatedAssetsUrl = TbSeparatedAssetsUrl.Text;
- SiteInfo.Additional.AssetsDir = TbAssetsDir.Text;
-
- DataProvider.SiteDao.Update(SiteInfo);
- AuthRequest.AddSiteLog(SiteId, "修改资源文件访问地址");
-
- SuccessMessage("资源文件访问地址修改成功!");
- AddWaitAndRedirectScript(PageSiteUrlAssets.GetRedirectUrl());
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageSiteUrlAssets.GetRedirectUrl());
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageSiteUrlWebConfig.cs b/SiteServer.BackgroundPages/Settings/PageSiteUrlWebConfig.cs
deleted file mode 100644
index 0e40cf254..000000000
--- a/SiteServer.BackgroundPages/Settings/PageSiteUrlWebConfig.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageSiteUrlWebConfig : BasePageCms
- {
- public Literal LtlSiteName;
-
- public RadioButtonList RblIsSeparatedWeb;
- public PlaceHolder PhSeparatedWeb;
- public TextBox TbSeparatedWebUrl;
-
- public static string GetRedirectUrl(int siteId)
- {
- return PageUtils.GetSettingsUrl(nameof(PageSiteUrlWebConfig), new NameValueCollection
- {
- {
- "SiteId", siteId.ToString()
- }
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Site);
-
- LtlSiteName.Text = SiteInfo.SiteName;
-
- EBooleanUtils.AddListItems(RblIsSeparatedWeb, "Web独立部署", "Web与CMS部署在一起");
- ControlUtils.SelectSingleItem(RblIsSeparatedWeb, SiteInfo.Additional.IsSeparatedWeb.ToString());
- PhSeparatedWeb.Visible = SiteInfo.Additional.IsSeparatedWeb;
- TbSeparatedWebUrl.Text = SiteInfo.Additional.SeparatedWebUrl;
- }
-
- public void RblIsSeparatedWeb_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhSeparatedWeb.Visible = TranslateUtils.ToBool(RblIsSeparatedWeb.SelectedValue);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- SiteInfo.Additional.IsSeparatedWeb = TranslateUtils.ToBool(RblIsSeparatedWeb.SelectedValue);
- SiteInfo.Additional.SeparatedWebUrl = TbSeparatedWebUrl.Text;
-
- DataProvider.SiteDao.Update(SiteInfo);
- AuthRequest.AddSiteLog(SiteId, "修改Web访问地址");
-
- SuccessMessage("Web访问地址修改成功!");
- AddWaitAndRedirectScript(PageSiteUrlWeb.GetRedirectUrl());
- }
-
- public void Return_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageSiteUrlWeb.GetRedirectUrl());
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageUser.cs b/SiteServer.BackgroundPages/Settings/PageUser.cs
deleted file mode 100644
index fe78d720c..000000000
--- a/SiteServer.BackgroundPages/Settings/PageUser.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageUser : BasePage
- {
- public DropDownList DdlPageNum;
- public DropDownList DdlLoginCount;
-
- public DropDownList DdlSearchType;
- public TextBox TbKeyword;
- public DropDownList DdlCreationDate;
- public DropDownList DdlLastActivityDate;
-
- public Repeater RptContents;
- public SqlPager SpContents;
-
- public Button BtnAdd;
- public Button BtnLock;
- public Button BtnUnLock;
- public Button BtnDelete;
- public Button BtnExport;
-
- private EUserLockType _lockType = EUserLockType.Forever;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageUser), null);
- }
-
- public string GetDateTime(DateTime datetime)
- {
- var retval = string.Empty;
- if (datetime > DateUtils.SqlMinValue)
- {
- retval = DateUtils.GetDateString(datetime);
- }
- return retval;
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
- try
- {
- foreach (var userId in userIdList)
- {
- DataProvider.UserDao.Delete(userId);
- }
-
- AuthRequest.AddAdminLog("删除用户", string.Empty);
-
- SuccessDeleteMessage();
- }
- catch (Exception ex)
- {
- FailDeleteMessage(ex);
- }
- }
- else if (AuthRequest.IsQueryExists("Lock"))
- {
- var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
- try
- {
- DataProvider.UserDao.Lock(userIdList);
-
- AuthRequest.AddAdminLog("锁定用户", string.Empty);
-
- SuccessMessage("成功锁定所选会员!");
- }
- catch (Exception ex)
- {
- FailMessage(ex, "锁定所选会员失败!");
- }
- }
- else if (AuthRequest.IsQueryExists("UnLock"))
- {
- var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
- try
- {
- DataProvider.UserDao.UnLock(userIdList);
-
- AuthRequest.AddAdminLog("解除锁定用户", string.Empty);
-
- SuccessMessage("成功解除锁定所选会员!");
- }
- catch (Exception ex)
- {
- FailMessage(ex, "解除锁定所选会员失败!");
- }
- }
-
- SpContents.ControlToPaginate = RptContents;
-
- if (string.IsNullOrEmpty(AuthRequest.GetQueryString("PageNum")))
- {
- SpContents.ItemsPerPage = TranslateUtils.ToInt(DdlPageNum.SelectedValue) == 0 ? 25 : TranslateUtils.ToInt(DdlPageNum.SelectedValue);
-
- SpContents.SelectCommand = DataProvider.UserDao.GetSelectCommand(true);
- }
- else
- {
- SpContents.ItemsPerPage = AuthRequest.GetQueryInt("PageNum") == 0 ? StringUtils.Constants.PageSize : AuthRequest.GetQueryInt("PageNum");
- SpContents.SelectCommand = DataProvider.UserDao.GetSelectCommand(AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryInt("CreationDate"), AuthRequest.GetQueryInt("LastActivityDate"), true, AuthRequest.GetQueryInt("LoginCount"), AuthRequest.GetQueryString("SearchType"));
- }
-
- RptContents.ItemDataBound += rptContents_ItemDataBound;
- SpContents.SortField = DataProvider.UserDao.GetSortFieldName();
- SpContents.SortMode = SortMode.DESC;
-
- _lockType = EUserLockTypeUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserLockLoginType);
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.User);
-
- //添加隐藏属性
- DdlSearchType.Items.Add(new ListItem("用户ID", "userID"));
- DdlSearchType.Items.Add(new ListItem("用户名", "userName"));
- DdlSearchType.Items.Add(new ListItem("邮箱", "email"));
- DdlSearchType.Items.Add(new ListItem("手机", "mobile"));
-
- //默认选择用户名
- DdlSearchType.SelectedValue = "userName";
-
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("SearchType")))
- {
- ControlUtils.SelectSingleItem(DdlSearchType, AuthRequest.GetQueryString("SearchType"));
- }
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("PageNum")))
- {
- ControlUtils.SelectSingleItem(DdlPageNum, AuthRequest.GetQueryString("PageNum"));
- }
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("LoginCount")))
- {
- ControlUtils.SelectSingleItem(DdlLoginCount, AuthRequest.GetQueryString("LoginCount"));
- }
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("Keyword")))
- {
- TbKeyword.Text = AuthRequest.GetQueryString("Keyword");
- }
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("CreationDate")))
- {
- ControlUtils.SelectSingleItem(DdlCreationDate, AuthRequest.GetQueryString("CreationDate"));
- }
- if (!string.IsNullOrEmpty(AuthRequest.GetQueryString("LastActivityDate")))
- {
- ControlUtils.SelectSingleItem(DdlLastActivityDate, AuthRequest.GetQueryString("LastActivityDate"));
- }
-
- var backgroundUrl = GetRedirectUrl();
-
- BtnAdd.Attributes.Add("onclick",
- $"location.href='{PageUserAdd.GetRedirectUrlToAdd(PageUrl)}';return false;");
-
- BtnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
- $"{backgroundUrl}?Lock=True", "UserIDCollection", "UserIDCollection", "请选择需要锁定的会员!", "此操作将锁定所选会员,确认吗?"));
-
- BtnUnLock.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
- $"{backgroundUrl}?UnLock=True", "UserIDCollection", "UserIDCollection", "请选择需要解除锁定的会员!", "此操作将解除锁定所选会员,确认吗?"));
-
- BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
- $"{backgroundUrl}?Delete=True", "UserIDCollection", "UserIDCollection", "请选择需要删除的会员!", "此操作将删除所选会员,确认吗?"));
-
- BtnExport.Attributes.Add("onclick", ModalUserExport.GetOpenWindowString());
-
- SpContents.DataBind();
- }
-
- public void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var userInfo = new UserInfo(e.Item.DataItem);
-
- var ltlUserName = (Literal)e.Item.FindControl("ltlUserName");
- var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName");
- var ltlEmail = (Literal)e.Item.FindControl("ltlEmail");
- var ltlMobile = (Literal)e.Item.FindControl("ltlMobile");
- var ltlLastActivityDate = (Literal)e.Item.FindControl("ltlLastActivityDate");
- var ltlLoginCount = (Literal)e.Item.FindControl("ltlLoginCount");
- var ltlCreationDate = (Literal)e.Item.FindControl("ltlCreationDate");
- var ltlWritingCount = (Literal)e.Item.FindControl("ltlWritingCount");
- var ltlSelect = (Literal)e.Item.FindControl("ltlSelect");
- var hlChangePassword = (HyperLink)e.Item.FindControl("hlChangePassword");
- var hlEditLink = (HyperLink)e.Item.FindControl("hlEditLink");
-
- ltlUserName.Text = GetUserNameHtml(userInfo);
- ltlDisplayName.Text = userInfo.DisplayName;
- ltlEmail.Text = userInfo.Email;
- ltlMobile.Text = userInfo.Mobile;
- ltlLastActivityDate.Text = DateUtils.GetDateAndTimeString(userInfo.LastActivityDate);
- ltlLoginCount.Text = userInfo.CountOfLogin.ToString();
- ltlCreationDate.Text = DateUtils.GetDateAndTimeString(userInfo.CreateDate);
-
- hlEditLink.NavigateUrl = PageUserAdd.GetRedirectUrlToEdit(userInfo.Id, GetRedirectUrl());
- hlChangePassword.Attributes.Add("onclick", ModalUserPassword.GetOpenWindowString(userInfo.UserName));
- ltlSelect.Text = $@" ";
-
- ltlWritingCount.Text = userInfo.CountOfWriting.ToString();
- }
-
- private string GetUserNameHtml(UserInfo userInfo)
- {
- var showPopWinString = ModalUserView.GetOpenWindowString(userInfo.UserName);
- var state = string.Empty;
- if (userInfo.IsLockedOut)
- {
- state = @"[已被锁定] ";
- }
- else if (ConfigManager.SystemConfigInfo.IsUserLockLogin &&
- ConfigManager.SystemConfigInfo.UserLockLoginCount <= userInfo.CountOfFailedLogin)
- {
- if (_lockType == EUserLockType.Forever)
- {
- state = @"[已被锁定] ";
- }
- else
- {
- var ts = new TimeSpan(DateTime.Now.Ticks - userInfo.LastActivityDate.Ticks);
- var hours = Convert.ToInt32(ConfigManager.SystemConfigInfo.UserLockLoginHours - ts.TotalHours);
- if (hours > 0)
- {
- state = $@"[错误登录次数过多,已被锁定{hours}小时] ";
- }
- }
- }
- return $@"{userInfo.UserName} {state}";
- }
-
- public void Search_OnClick(object sender, EventArgs e)
- {
- PageUtils.Redirect(PageUrl);
- }
-
- private string _pageUrl;
- private string PageUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_pageUrl))
- {
- _pageUrl =
- $"{GetRedirectUrl()}?PageNum={DdlPageNum.SelectedValue}&Keyword={TbKeyword.Text}&CreationDate={DdlCreationDate.SelectedValue}&LastActivityDate={DdlLastActivityDate.SelectedValue}&loginCount={DdlLoginCount.SelectedValue}&SearchType={DdlSearchType.SelectedValue}";
- }
- return _pageUrl;
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageUserAdd.cs b/SiteServer.BackgroundPages/Settings/PageUserAdd.cs
deleted file mode 100644
index 081e35ff9..000000000
--- a/SiteServer.BackgroundPages/Settings/PageUserAdd.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageUserAdd : BasePage
- {
- public Literal LtlPageTitle;
- public TextBox TbUserName;
- public TextBox TbDisplayName;
- public PlaceHolder PhPassword;
- public TextBox TbPassword;
- public Literal LtlPasswordTips;
- public TextBox TbEmail;
- public TextBox TbMobile;
- public Button BtnReturn;
-
- private int _userId;
- private string _returnUrl;
-
- public static string GetRedirectUrlToAdd(string returnUrl)
- {
- return PageUtils.GetSettingsUrl(nameof(PageUserAdd), new NameValueCollection
- {
- {"returnUrl", StringUtils.ValueToUrl(returnUrl) }
- });
- }
-
- public static string GetRedirectUrlToEdit(int userId, string returnUrl)
- {
- return PageUtils.GetSettingsUrl(nameof(PageUserAdd), new NameValueCollection
- {
- {"userID", userId.ToString() },
- {"returnUrl", StringUtils.ValueToUrl(returnUrl) }
- });
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- _userId = AuthRequest.GetQueryInt("userID");
- _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl"));
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.User);
-
- LtlPageTitle.Text = _userId == 0 ? "添加用户" : "编辑用户";
-
- if (_userId > 0)
- {
- var userInfo = DataProvider.UserDao.GetUserInfo(_userId);
- if (userInfo != null)
- {
- TbUserName.Text = userInfo.UserName;
- TbUserName.Enabled = false;
- TbDisplayName.Text = userInfo.DisplayName;
- PhPassword.Visible = false;
- TbEmail.Text = userInfo.Email;
- TbMobile.Text = userInfo.Mobile;
- }
- }
-
- if (!EUserPasswordRestrictionUtils.Equals(ConfigManager.SystemConfigInfo.UserPasswordRestriction, EUserPasswordRestriction.None))
- {
- LtlPasswordTips.Text = $"请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserPasswordRestriction))}";
- }
-
- if (!string.IsNullOrEmpty(_returnUrl))
- {
- BtnReturn.Attributes.Add("onclick", $"window.location.href='{_returnUrl}';return false;");
- }
- else
- {
- BtnReturn.Visible = false;
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- if (_userId == 0)
- {
- var userInfo = new UserInfo
- {
- UserName = TbUserName.Text,
- Password = TbPassword.Text,
- CreateDate = DateTime.Now,
- LastActivityDate = DateUtils.SqlMinValue,
- IsChecked = true,
- IsLockedOut = false,
- DisplayName = TbDisplayName.Text,
- Email = TbEmail.Text,
- Mobile = TbMobile.Text
- };
-
- string errorMessage;
- var isCreated = DataProvider.UserDao.Insert(userInfo, userInfo.Password, string.Empty, out errorMessage);
-
- if (isCreated)
- {
- AuthRequest.AddAdminLog("添加用户",
- $"用户:{TbUserName.Text}");
-
- SuccessMessage("用户添加成功,可以继续添加!");
- AddWaitAndRedirectScript(GetRedirectUrlToAdd(_returnUrl));
- }
- else
- {
- FailMessage($"用户添加失败: {errorMessage}");
- }
- }
- else
- {
- var userInfo = DataProvider.UserDao.GetUserInfo(_userId);
-
- userInfo.DisplayName = TbDisplayName.Text;
- userInfo.Email = TbEmail.Text;
- userInfo.Mobile = TbMobile.Text;
-
- DataProvider.UserDao.Update(userInfo);
-
- AuthRequest.AddAdminLog("修改用户",
- $"用户:{TbUserName.Text}");
-
- SuccessMessage("用户修改成功!");
- AddWaitAndRedirectScript(_returnUrl);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.BackgroundPages/Settings/PageUserCheck.cs b/SiteServer.BackgroundPages/Settings/PageUserCheck.cs
deleted file mode 100644
index f87584215..000000000
--- a/SiteServer.BackgroundPages/Settings/PageUserCheck.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.BackgroundPages.Controls;
-using SiteServer.BackgroundPages.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageUserCheck : BasePage
- {
- public Repeater RptContents;
- public SqlPager SpContents;
-
- public Button BtnCheck;
- public Button BtnDelete;
-
- public static string GetRedirectUrl()
- {
- return PageUtils.GetSettingsUrl(nameof(PageUserCheck), null);
- }
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (AuthRequest.IsQueryExists("Delete"))
- {
- var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
- foreach (var userId in userIdList)
- {
- DataProvider.UserDao.Delete(userId);
- }
-
- AuthRequest.AddAdminLog("删除用户", string.Empty);
-
- SuccessDeleteMessage();
- }
- else if (AuthRequest.IsQueryExists("Check"))
- {
- var userIdList = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("UserIDCollection"));
- DataProvider.UserDao.Check(userIdList);
-
- SuccessCheckMessage();
- }
-
- SpContents.ControlToPaginate = RptContents;
- SpContents.ItemsPerPage = 25;
- SpContents.SelectCommand = DataProvider.UserDao.GetSelectCommand(false);
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- SpContents.SortField = DataProvider.UserDao.GetSortFieldName();
- SpContents.SortMode = SortMode.DESC;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.User);
-
- SpContents.DataBind();
-
- BtnCheck.Attributes.Add("onclick",
- PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
- PageUtils.GetSettingsUrl(nameof(PageUserCheck), new NameValueCollection
- {
- {"Check", "True"}
- }), "UserIDCollection", "UserIDCollection", "请选择需要审核的会员!", "此操作将审核通过所选会员,确认吗?"));
-
- BtnDelete.Attributes.Add("onclick",
- PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(
- PageUtils.GetSettingsUrl(nameof(PageUserCheck), new NameValueCollection
- {
- {"Delete", "True"}
- }), "UserIDCollection", "UserIDCollection", "请选择需要删除的会员!", "此操作将删除所选会员,确认吗?"));
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var userInfo = new UserInfo(e.Item.DataItem);
-
- var ltlUserName = (Literal)e.Item.FindControl("ltlUserName");
- var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName");
- var ltlCreateDate = (Literal)e.Item.FindControl("ltlCreateDate");
- var ltlSelect = (Literal)e.Item.FindControl("ltlSelect");
- var hlEditLink = (HyperLink)e.Item.FindControl("hlEditLink");
-
- var state = string.Empty;
- if (userInfo.IsLockedOut)
- {
- state = @"[已被锁定] ";
- }
- ltlUserName.Text = $@"{userInfo.UserName} {state}";
-
- ltlDisplayName.Text = userInfo.DisplayName;
-
- ltlCreateDate.Text = DateUtils.GetDateAndTimeString(userInfo.CreateDate);
-
- var userAddUrl = PageUserAdd.GetRedirectUrlToEdit(userInfo.Id, GetRedirectUrl());
- hlEditLink.NavigateUrl = userAddUrl;
-
- ltlSelect.Text = $@" ";
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageUserConfiguration.cs b/SiteServer.BackgroundPages/Settings/PageUserConfiguration.cs
deleted file mode 100644
index 64ff1d68b..000000000
--- a/SiteServer.BackgroundPages/Settings/PageUserConfiguration.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageUserConfiguration : BasePage
- {
- public RadioButtonList RblIsRegisterAllowed;
- public TextBox TbRegisterPasswordMinLength;
- public DropDownList DdlRegisterPasswordRestriction;
- public TextBox TbRegisterMinMinutesOfIpAddress;
-
- public RadioButtonList RblIsFailToLock;
- public PlaceHolder PhFailToLock;
- public DropDownList DdlLockType;
- public TextBox TbLoginFailCount;
- public PlaceHolder PhLockingTime;
- public TextBox TbLockingTime;
- public RadioButtonList RblIsFindPassword;
- public PlaceHolder PhFindPassword;
- public TextBox TbFindPasswordSmsTplId;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.User);
-
- EBooleanUtils.AddListItems(RblIsRegisterAllowed);
-
- TbRegisterPasswordMinLength.Text = ConfigManager.SystemConfigInfo.UserPasswordMinLength.ToString();
-
- EUserPasswordRestrictionUtils.AddListItems(DdlRegisterPasswordRestriction);
- ControlUtils.SelectSingleItemIgnoreCase(DdlRegisterPasswordRestriction, ConfigManager.SystemConfigInfo.UserPasswordRestriction);
-
- ControlUtils.SelectSingleItemIgnoreCase(RblIsRegisterAllowed, ConfigManager.SystemConfigInfo.IsUserRegistrationAllowed.ToString());
-
- TbRegisterMinMinutesOfIpAddress.Text = ConfigManager.SystemConfigInfo.UserRegistrationMinMinutes.ToString();
-
- EBooleanUtils.AddListItems(RblIsFailToLock, "是", "否");
- ControlUtils.SelectSingleItemIgnoreCase(RblIsFailToLock, ConfigManager.SystemConfigInfo.IsUserLockLogin.ToString());
-
- PhFailToLock.Visible = ConfigManager.SystemConfigInfo.IsUserLockLogin;
-
- TbLoginFailCount.Text = ConfigManager.SystemConfigInfo.UserLockLoginCount.ToString();
-
- DdlLockType.Items.Add(new ListItem("按小时锁定", EUserLockTypeUtils.GetValue(EUserLockType.Hours)));
- DdlLockType.Items.Add(new ListItem("永久锁定", EUserLockTypeUtils.GetValue(EUserLockType.Forever)));
- ControlUtils.SelectSingleItemIgnoreCase(DdlLockType, ConfigManager.SystemConfigInfo.UserLockLoginType);
- TbLockingTime.Text = ConfigManager.SystemConfigInfo.UserLockLoginHours.ToString();
-
- PhLockingTime.Visible = false;
- PhLockingTime.Visible = EUserLockTypeUtils.Equals(ConfigManager.SystemConfigInfo.UserLockLoginType, EUserLockType.Hours);
-
- EBooleanUtils.AddListItems(RblIsFindPassword, "启用", "禁用");
- ControlUtils.SelectSingleItemIgnoreCase(RblIsFindPassword, ConfigManager.SystemConfigInfo.IsUserFindPassword.ToString());
- PhFindPassword.Visible = ConfigManager.SystemConfigInfo.IsUserFindPassword;
- TbFindPasswordSmsTplId.Text = ConfigManager.SystemConfigInfo.UserFindPasswordSmsTplId;
- }
-
- public void RblIsFailToLock_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhFailToLock.Visible = TranslateUtils.ToBool(RblIsFailToLock.SelectedValue);
- }
-
- public void DdlLockType_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhLockingTime.Visible = !EUserLockTypeUtils.Equals(EUserLockType.Forever, DdlLockType.SelectedValue);
- }
-
- public void RblIsFindPassword_SelectedIndexChanged(object sender, EventArgs e)
- {
- PhFindPassword.Visible = TranslateUtils.ToBool(RblIsFindPassword.SelectedValue);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- ConfigManager.SystemConfigInfo.IsUserRegistrationAllowed = TranslateUtils.ToBool(RblIsRegisterAllowed.SelectedValue);
- ConfigManager.SystemConfigInfo.UserPasswordMinLength = TranslateUtils.ToInt(TbRegisterPasswordMinLength.Text);
- ConfigManager.SystemConfigInfo.UserPasswordRestriction = DdlRegisterPasswordRestriction.SelectedValue;
- ConfigManager.SystemConfigInfo.UserRegistrationMinMinutes = TranslateUtils.ToInt(TbRegisterMinMinutesOfIpAddress.Text);
-
- ConfigManager.SystemConfigInfo.IsUserLockLogin = TranslateUtils.ToBool(RblIsFailToLock.SelectedValue);
- ConfigManager.SystemConfigInfo.UserLockLoginCount = TranslateUtils.ToInt(TbLoginFailCount.Text, 3);
- ConfigManager.SystemConfigInfo.UserLockLoginType = DdlLockType.SelectedValue;
- ConfigManager.SystemConfigInfo.UserLockLoginHours = TranslateUtils.ToInt(TbLockingTime.Text);
- ConfigManager.SystemConfigInfo.IsUserFindPassword = TranslateUtils.ToBool(RblIsFindPassword.SelectedValue);
- ConfigManager.SystemConfigInfo.UserFindPasswordSmsTplId = TbFindPasswordSmsTplId.Text;
-
- DataProvider.ConfigDao.Update(ConfigManager.Instance);
-
- AuthRequest.AddAdminLog("修改用户设置");
-
- SuccessMessage("设置修改成功!");
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageUtilityCache.cs b/SiteServer.BackgroundPages/Settings/PageUtilityCache.cs
deleted file mode 100644
index d9be447d6..000000000
--- a/SiteServer.BackgroundPages/Settings/PageUtilityCache.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageUtilityCache : BasePage
- {
- public Literal LtlCount;
- public Literal LtlPercentage;
- public Repeater RptContents;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Utility);
-
- LtlCount.Text = CacheUtils.Count.ToString();
-
- RptContents.DataSource = CacheUtils.AllKeys;
- RptContents.ItemDataBound += RptContents_ItemDataBound;
- RptContents.DataBind();
- }
-
- private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
-
- var key = (string) e.Item.DataItem;
- var value = CacheUtils.Get(key);
-
- if (value == null) return;
- var valueType = value.GetType().FullName;
-
- var ltlKey = (Literal)e.Item.FindControl("ltlKey");
- var ltlValue = (Literal)e.Item.FindControl("ltlValue");
-
- ltlKey.Text = key;
-
- if (valueType == "System.String")
- {
- ltlValue.Text = $"string, length:{value.ToString().Length}";
- } else if (valueType == "System.Int32")
- {
- ltlValue.Text = value.ToString();
- }
- else
- {
- ltlValue.Text = valueType;
- }
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- CacheUtils.ClearAll();
- CacheDbUtils.Clear();
- PageUtils.Redirect(PageUtils.GetSettingsUrl(nameof(PageUtilityCache), null));
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageUtilityDbLogDelete.cs b/SiteServer.BackgroundPages/Settings/PageUtilityDbLogDelete.cs
deleted file mode 100644
index ef30d7fc6..000000000
--- a/SiteServer.BackgroundPages/Settings/PageUtilityDbLogDelete.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageUtilityDbLogDelete : BasePage
- {
- public Literal LtlLastExecuteDate;
-
- protected override bool IsAccessable => true;
-
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (IsPostBack) return;
-
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Utility);
- var dt = DataProvider.LogDao.GetLastRemoveLogDate(AuthRequest.AdminName);
- LtlLastExecuteDate.Text = dt == DateTime.MinValue ? "无记录" : DateUtils.GetDateAndTimeString(dt);
- }
-
- public override void Submit_OnClick(object sender, EventArgs e)
- {
- if (!Page.IsPostBack || !Page.IsValid) return;
-
- DataProvider.DatabaseDao.DeleteDbLog();
-
- AuthRequest.AddAdminLog("清空数据库日志");
-
- SuccessMessage("清空日志成功!");
- }
-
- }
-}
diff --git a/SiteServer.BackgroundPages/Settings/PageUtilityJsMin.cs b/SiteServer.BackgroundPages/Settings/PageUtilityJsMin.cs
deleted file mode 100644
index 9c52d6305..000000000
--- a/SiteServer.BackgroundPages/Settings/PageUtilityJsMin.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using SiteServer.CMS.Core;
-
-namespace SiteServer.BackgroundPages.Settings
-{
- public class PageUtilityJsMin : BasePage
- {
- public void Page_Load(object sender, EventArgs e)
- {
- if (IsForbidden) return;
-
- if (!IsPostBack)
- {
- VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Utility);
- }
- }
- }
-}
diff --git a/SiteServer.BackgroundPages/app.config b/SiteServer.BackgroundPages/app.config
deleted file mode 100644
index 455df6f80..000000000
--- a/SiteServer.BackgroundPages/app.config
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SiteServer.BackgroundPages/packages.config b/SiteServer.BackgroundPages/packages.config
deleted file mode 100644
index a36a5149f..000000000
--- a/SiteServer.BackgroundPages/packages.config
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/SiteServer.CMS.sln b/SiteServer.CMS.sln
new file mode 100644
index 000000000..1c45d2c31
--- /dev/null
+++ b/SiteServer.CMS.sln
@@ -0,0 +1,85 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.572
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiteServer.Utils", "src\SiteServer.Utils\SiteServer.Utils.csproj", "{059E3927-37E1-4F6F-B525-FEF40C54906B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiteServer.Utils.Tests", "tests\SiteServer.Utils.Tests\SiteServer.Utils.Tests.csproj", "{05A848DE-A9E4-42A0-9A56-8C049A43F56A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteServer.CMS", "net452\SiteServer.CMS\SiteServer.CMS.csproj", "{944127C3-915D-4F02-A534-64EC668C46EC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteServer.CMS.Tests", "net452\SiteServer.CMS.Tests\SiteServer.CMS.Tests.csproj", "{9CD127C6-08E2-406D-9630-463DA1431EA4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteServer.BackgroundPages", "net452\SiteServer.BackgroundPages\SiteServer.BackgroundPages.csproj", "{6AA1713A-3B77-4B20-B8C7-FCB6DE556F64}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteServer.API", "net452\SiteServer.Web\SiteServer.API.csproj", "{69C00F60-F28A-4CBC-B1A4-2DB73BB97471}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteServer.API.Tests", "net452\SiteServer.API.Tests\SiteServer.API.Tests.csproj", "{5597BC9B-1E09-4EE4-9EA4-AC71CEA645F3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteServer.Cli", "net452\SiteServer.Cli\SiteServer.Cli.csproj", "{A7E4D925-AACF-4782-8B9A-C10B9F527A0C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiteServer.API.Core", "src\SiteServer.API.Core\SiteServer.API.Core.csproj", "{B7040189-5546-441E-85AC-019215CE2C5C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiteServer.Cli.Core", "src\SiteServer.Cli.Core\SiteServer.Cli.Core.csproj", "{8BA77BE2-8BE0-4588-A101-A10049578790}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiteServer.API.Core.Tests", "tests\SiteServer.API.Core.Tests\SiteServer.API.Core.Tests.csproj", "{1C123D87-E7FC-4CB8-887A-964CD5577DC6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {059E3927-37E1-4F6F-B525-FEF40C54906B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {059E3927-37E1-4F6F-B525-FEF40C54906B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {059E3927-37E1-4F6F-B525-FEF40C54906B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {059E3927-37E1-4F6F-B525-FEF40C54906B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {05A848DE-A9E4-42A0-9A56-8C049A43F56A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {05A848DE-A9E4-42A0-9A56-8C049A43F56A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {05A848DE-A9E4-42A0-9A56-8C049A43F56A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {05A848DE-A9E4-42A0-9A56-8C049A43F56A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {944127C3-915D-4F02-A534-64EC668C46EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {944127C3-915D-4F02-A534-64EC668C46EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {944127C3-915D-4F02-A534-64EC668C46EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {944127C3-915D-4F02-A534-64EC668C46EC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9CD127C6-08E2-406D-9630-463DA1431EA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9CD127C6-08E2-406D-9630-463DA1431EA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9CD127C6-08E2-406D-9630-463DA1431EA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9CD127C6-08E2-406D-9630-463DA1431EA4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6AA1713A-3B77-4B20-B8C7-FCB6DE556F64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6AA1713A-3B77-4B20-B8C7-FCB6DE556F64}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6AA1713A-3B77-4B20-B8C7-FCB6DE556F64}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6AA1713A-3B77-4B20-B8C7-FCB6DE556F64}.Release|Any CPU.Build.0 = Release|Any CPU
+ {69C00F60-F28A-4CBC-B1A4-2DB73BB97471}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {69C00F60-F28A-4CBC-B1A4-2DB73BB97471}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {69C00F60-F28A-4CBC-B1A4-2DB73BB97471}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {69C00F60-F28A-4CBC-B1A4-2DB73BB97471}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5597BC9B-1E09-4EE4-9EA4-AC71CEA645F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5597BC9B-1E09-4EE4-9EA4-AC71CEA645F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5597BC9B-1E09-4EE4-9EA4-AC71CEA645F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5597BC9B-1E09-4EE4-9EA4-AC71CEA645F3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A7E4D925-AACF-4782-8B9A-C10B9F527A0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A7E4D925-AACF-4782-8B9A-C10B9F527A0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A7E4D925-AACF-4782-8B9A-C10B9F527A0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A7E4D925-AACF-4782-8B9A-C10B9F527A0C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B7040189-5546-441E-85AC-019215CE2C5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B7040189-5546-441E-85AC-019215CE2C5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B7040189-5546-441E-85AC-019215CE2C5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B7040189-5546-441E-85AC-019215CE2C5C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8BA77BE2-8BE0-4588-A101-A10049578790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8BA77BE2-8BE0-4588-A101-A10049578790}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8BA77BE2-8BE0-4588-A101-A10049578790}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8BA77BE2-8BE0-4588-A101-A10049578790}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1C123D87-E7FC-4CB8-887A-964CD5577DC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1C123D87-E7FC-4CB8-887A-964CD5577DC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1C123D87-E7FC-4CB8-887A-964CD5577DC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1C123D87-E7FC-4CB8-887A-964CD5577DC6}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {5E5FD939-BED0-452A-B29F-1F8B0E14AFCC}
+ EndGlobalSection
+EndGlobal
diff --git a/SiteServer.CMS/Api/ApiManager.cs b/SiteServer.CMS/Api/ApiManager.cs
deleted file mode 100644
index 4e0dffcb6..000000000
--- a/SiteServer.CMS/Api/ApiManager.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using SiteServer.CMS.Core;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Api
-{
- public static class ApiManager
- {
- private static string _innerApiUrl;
-
- public static string InnerApiUrl
- {
- get
- {
- if (string.IsNullOrEmpty(_innerApiUrl))
- {
- _innerApiUrl = PageUtils.ParseNavigationUrl("~/api");
- }
- return _innerApiUrl;
- }
- }
-
- public static string GetInnerApiUrl(string route)
- {
- return PageUtils.Combine(InnerApiUrl, route);
- }
-
- public static string OuterApiUrl => ConfigManager.SystemConfigInfo.ApiUrl;
-
- public static string GetOuterApiUrl(string route)
- {
- return PageUtils.Combine(OuterApiUrl, route);
- }
-
- public static string SignalrHubsUrl => PageUtils.ParseNavigationUrl("~/signalr/hubs");
- }
-}
diff --git a/SiteServer.CMS/Api/ApiRoutePlugin.cs b/SiteServer.CMS/Api/ApiRoutePlugin.cs
deleted file mode 100644
index 0a1bf9981..000000000
--- a/SiteServer.CMS/Api/ApiRoutePlugin.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Api
-{
- public class ApiRoutePlugin
- {
- public const string Route = "plugins/{pluginId}";
- public const string RouteAction = "plugins/{pluginId}/{name}";
- public const string RouteActionAndId = "plugins/{pluginId}/{name}/{id}";
-
- public static string GetUrl(string pluginId, string name = "", string id = "")
- {
- var apiUrl = ApiManager.GetOuterApiUrl(Route);
- apiUrl = apiUrl.Replace("{pluginId}", pluginId);
- if (!string.IsNullOrEmpty(name))
- {
- apiUrl = PageUtils.Combine(apiUrl, name);
- if (!string.IsNullOrEmpty(id))
- {
- apiUrl = PageUtils.Combine(apiUrl, id);
- }
- }
- return apiUrl;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Http/ApiRoutePluginHttp.cs b/SiteServer.CMS/Api/Http/ApiRoutePluginHttp.cs
deleted file mode 100644
index 0d91b9b3d..000000000
--- a/SiteServer.CMS/Api/Http/ApiRoutePluginHttp.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Controllers.Http
-{
- public class ApiRoutePluginHttp
- {
- public const string Route = "http/{pluginId}";
- public const string RouteName = "http/{pluginId}/{name}";
- public const string RouteNameAndId = "http/{pluginId}/{name}/{id}";
-
- public static string GetUrl(string apiUrl, string pluginId, string name = "", string id = "")
- {
- apiUrl = PageUtils.Combine(apiUrl, Route);
- apiUrl = apiUrl.Replace("{pluginId}", pluginId);
- if (!string.IsNullOrEmpty(name))
- {
- apiUrl = PageUtils.Combine(apiUrl, name);
- if (!string.IsNullOrEmpty(id))
- {
- apiUrl = PageUtils.Combine(apiUrl, id);
- }
- }
- return apiUrl;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Json/ApiRoutePluginJson.cs b/SiteServer.CMS/Api/Json/ApiRoutePluginJson.cs
deleted file mode 100644
index 5eb77f98e..000000000
--- a/SiteServer.CMS/Api/Json/ApiRoutePluginJson.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Controllers.Json
-{
- public class ApiRoutePluginJson
- {
- public const string Route = "json/{pluginId}";
- public const string RouteName = "json/{pluginId}/{name}";
- public const string RouteNameAndId = "json/{pluginId}/{name}/{id}";
-
- public static string GetUrl(string apiUrl, string pluginId, string name = "", string id = "")
- {
- apiUrl = PageUtils.Combine(apiUrl, Route);
- apiUrl = apiUrl.Replace("{pluginId}", pluginId);
- if (!string.IsNullOrEmpty(name))
- {
- apiUrl = PageUtils.Combine(apiUrl, name);
- if (!string.IsNullOrEmpty(id))
- {
- apiUrl = PageUtils.Combine(apiUrl, id);
- }
- }
- return apiUrl;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Preview/ApiRoutePreview.cs b/SiteServer.CMS/Api/Preview/ApiRoutePreview.cs
deleted file mode 100644
index e4e877b99..000000000
--- a/SiteServer.CMS/Api/Preview/ApiRoutePreview.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Api.Preview
-{
- public class ApiRoutePreview
- {
- public const string Route = "preview/{siteId}";
- public const string RouteChannel = "preview/{siteId}/{channelId}";
- public const string RouteContent = "preview/{siteId}/{channelId}/{contentId}";
- public const string RouteFile = "preview/{siteId}/file/{fileTemplateId}";
-
- public static string GetSiteUrl(int siteId)
- {
- return GetUrl(siteId, 0, 0, 0);
- }
-
- public static string GetChannelUrl(int siteId, int channelId)
- {
- return GetUrl(siteId, channelId, 0, 0);
- }
-
- public static string GetContentUrl(int siteId, int channelId, int contentId)
- {
- return GetUrl(siteId, channelId, contentId, 0);
- }
-
- public static string GetContentPreviewUrl(int siteId, int channelId, int contentId, int previewId)
- {
- if (contentId == 0)
- {
- contentId = previewId;
- }
- return $"{GetUrl(siteId, channelId, contentId, 0)}?isPreview=true&previewId={previewId}";
- }
-
- public static string GetFileUrl(int siteId, int fileTemplateId)
- {
- return GetUrl(siteId, 0, 0, fileTemplateId);
- }
-
- private static string GetUrl(int siteId, int channelId, int contentId, int fileTemplateId)
- {
- var apiUrl = ApiManager.GetInnerApiUrl(Route);
- apiUrl = apiUrl.Replace("{siteId}", siteId.ToString());
- if (channelId > 0)
- {
- apiUrl = PageUtils.Combine(apiUrl, channelId.ToString());
- if (contentId > 0)
- {
- apiUrl = PageUtils.Combine(apiUrl, contentId.ToString());
- }
- }
- else if (fileTemplateId > 0)
- {
- apiUrl = PageUtils.Combine(apiUrl, fileTemplateId.ToString());
- }
- return apiUrl;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Sys/Administrators/ApiRouteActionsLogin.cs b/SiteServer.CMS/Api/Sys/Administrators/ApiRouteActionsLogin.cs
deleted file mode 100644
index ba2618096..000000000
--- a/SiteServer.CMS/Api/Sys/Administrators/ApiRouteActionsLogin.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace SiteServer.CMS.Api.Sys.Administrators
-{
- public class ApiRouteActionsLogin
- {
- public const string Route = "sys/administrators/actions/login";
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Sys/Administrators/ApiRouteSiteCheckList.cs b/SiteServer.CMS/Api/Sys/Administrators/ApiRouteSiteCheckList.cs
deleted file mode 100644
index 271b6d278..000000000
--- a/SiteServer.CMS/Api/Sys/Administrators/ApiRouteSiteCheckList.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Api.Sys.Administrators
-{
- public class ApiRouteSiteCheckList
- {
- public const string Route = "sys/administrators/{userName}/site_check_list";
-
- public static string GetUrl(string apiUrl, string userName)
- {
- apiUrl = PageUtils.Combine(apiUrl, Route);
- apiUrl = apiUrl.Replace("{userName}", userName);
- return apiUrl;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Sys/Errors/ApiRouteError.cs b/SiteServer.CMS/Api/Sys/Errors/ApiRouteError.cs
deleted file mode 100644
index f70bf9d6b..000000000
--- a/SiteServer.CMS/Api/Sys/Errors/ApiRouteError.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Api.Sys.Errors
-{
- public class ApiRouteError
- {
- public const string Route = "sys/errors/{id}";
-
- public static string GetUrl(string apiUrl, int id)
- {
- apiUrl = PageUtils.Combine(apiUrl, Route);
- apiUrl = apiUrl.Replace("{id}", id.ToString());
- return apiUrl;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Sys/Stl/ApiRouteActionsAddContentHits.cs b/SiteServer.CMS/Api/Sys/Stl/ApiRouteActionsAddContentHits.cs
deleted file mode 100644
index fd8115ac2..000000000
--- a/SiteServer.CMS/Api/Sys/Stl/ApiRouteActionsAddContentHits.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Api.Sys.Stl
-{
- public class ApiRouteActionsAddContentHits
- {
- public const string Route = "sys/stl/actions/add_content_hits/{siteId}/{channelId}/{contentId}";
-
- public static string GetUrl(string apiUrl, int siteId, int channelId, int contentId)
- {
- apiUrl = PageUtils.Combine(apiUrl, Route);
- apiUrl = apiUrl.Replace("{siteId}", siteId.ToString());
- apiUrl = apiUrl.Replace("{channelId}", channelId.ToString());
- apiUrl = apiUrl.Replace("{contentId}", contentId.ToString());
- return apiUrl;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Api/Sys/Stl/ApiRouteActionsSearch.cs b/SiteServer.CMS/Api/Sys/Stl/ApiRouteActionsSearch.cs
deleted file mode 100644
index b234d110b..000000000
--- a/SiteServer.CMS/Api/Sys/Stl/ApiRouteActionsSearch.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System.Collections.Generic;
-using SiteServer.CMS.StlParser.StlElement;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Api.Sys.Stl
-{
- public static class ApiRouteActionsSearch
- {
- public const string Route = "sys/stl/actions/search";
-
- public static string GetUrl(string apiUrl)
- {
- return PageUtils.Combine(apiUrl, Route);
- }
-
- public static string GetParameters(bool isAllSites, string siteName, string siteDir, string siteIds, string channelIndex, string channelName, string channelIds, string type, string word, string dateAttribute, string dateFrom, string dateTo, string since, int pageNum, bool isHighlight, bool isDefaultDisplay, int siteId, string ajaxDivId, string template)
- {
- return $@"
-{{
- {StlSearch.IsAllSites.Name.ToLower()}: {isAllSites.ToString().ToLower()},
- {StlSearch.SiteName.Name.ToLower()}: '{siteName}',
- {StlSearch.SiteDir.Name.ToLower()}: '{siteDir}',
- {StlSearch.SiteIds.Name.ToLower()}: '{siteIds}',
- {StlSearch.ChannelIndex.Name.ToLower()}: '{channelIndex}',
- {StlSearch.ChannelName.Name.ToLower()}: '{channelName}',
- {StlSearch.ChannelIds.Name.ToLower()}: '{channelIds}',
- {StlSearch.Type.Name.ToLower()}: '{type}',
- {StlSearch.Word.Name.ToLower()}: '{word}',
- {StlSearch.DateAttribute.Name.ToLower()}: '{dateAttribute}',
- {StlSearch.DateFrom.Name.ToLower()}: '{dateFrom}',
- {StlSearch.DateTo.Name.ToLower()}: '{dateTo}',
- {StlSearch.Since.Name.ToLower()}: '{since}',
- {StlSearch.PageNum.Name.ToLower()}: {pageNum},
- {StlSearch.IsHighlight.Name.ToLower()}: {isHighlight.ToString().ToLower()},
- {StlSearch.IsDefaultDisplay.Name.ToLower()}: {isDefaultDisplay.ToString().ToLower()},
- siteid: '{siteId}',
- ajaxdivid: '{ajaxDivId}',
- template: '{TranslateUtils.EncryptStringBySecretKey(template)}',
-}}";
- }
-
- public static List ExlcudeAttributeNames => new List
- {
- StlSearch.IsAllSites.Name.ToLower(),
- StlSearch.SiteName.Name.ToLower(),
- StlSearch.SiteDir.Name.ToLower(),
- StlSearch.SiteIds.Name.ToLower(),
- StlSearch.ChannelIndex.Name.ToLower(),
- StlSearch.ChannelName.Name.ToLower(),
- StlSearch.ChannelIds.Name.ToLower(),
- StlSearch.Type.Name.ToLower(),
- StlSearch.Word.Name.ToLower(),
- StlSearch.DateAttribute.Name.ToLower(),
- StlSearch.DateFrom.Name.ToLower(),
- StlSearch.DateTo.Name.ToLower(),
- StlSearch.Since.Name.ToLower(),
- StlSearch.PageNum.Name.ToLower(),
- StlSearch.IsHighlight.Name.ToLower(),
- StlSearch.IsDefaultDisplay.Name.ToLower(),
- "siteid",
- "ajaxdivid",
- "template",
- };
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Core/AdminManager.cs b/SiteServer.CMS/Core/AdminManager.cs
deleted file mode 100644
index a613aab20..000000000
--- a/SiteServer.CMS/Core/AdminManager.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-using System;
-using System.Collections;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class AdminManager
- {
- private static readonly object LockObject = new object();
-
- private AdminManager()
- {
- }
-
- public static AdministratorInfo GetAdminInfo(string userName)
- {
- var ht = GetActiveAdminInfo();
-
- var adminInfo = ht[userName] as AdministratorInfo;
- if (adminInfo != null) return adminInfo;
-
- lock (LockObject)
- {
- adminInfo = ht[userName] as AdministratorInfo;
-
- if (adminInfo == null)
- {
- adminInfo = DataProvider.AdministratorDao.GetByUserName(userName);
- ht[userName] = adminInfo;
- }
- }
-
- return adminInfo;
- }
-
- public static string GetDisplayName(string userName, bool isDepartment)
- {
- var adminInfo = GetAdminInfo(userName);
- if (adminInfo == null) return userName;
-
- if (!isDepartment) return adminInfo.DisplayName;
- var departmentName = DepartmentManager.GetDepartmentName(adminInfo.DepartmentId);
- return !string.IsNullOrEmpty(departmentName) ? $"{adminInfo.DisplayName}({departmentName})" : adminInfo.DisplayName;
- }
-
- public static string GetFullName(string userName)
- {
- if (!string.IsNullOrEmpty(userName))
- {
- var adminInfo = GetAdminInfo(userName);
- if (adminInfo != null)
- {
- string retval = $"账号:{userName} 姓名:{adminInfo.DisplayName}";
- var departmentName = DepartmentManager.GetDepartmentName(adminInfo.DepartmentId);
- if (!string.IsNullOrEmpty(departmentName))
- {
- retval += $" 部门:{departmentName}";
- }
- return retval;
- }
- return userName;
- }
- return string.Empty;
- }
-
- public static void RemoveCache(string userName)
- {
- var ht = GetActiveAdminInfo();
-
- lock (ht.SyncRoot)
- {
- ht.Remove(userName);
- }
- }
-
- public const string CacheKey = "BaiRong.Core.AdminManager";
-
- public static void Clear()
- {
- CacheUtils.Remove(CacheKey);
- }
-
- public static Hashtable GetActiveAdminInfo()
- {
- var retval = CacheUtils.Get(CacheKey);
- if (retval != null) return retval;
-
- lock (LockObject)
- {
- retval = CacheUtils.Get(CacheKey);
- if (retval == null)
- {
- retval = new Hashtable();
- CacheUtils.Insert(CacheKey, retval);
- }
- }
-
- return retval;
- }
-
- public static bool CreateAdministrator(AdministratorInfo administratorInfo, out string errorMessage)
- {
- try
- {
- administratorInfo.LastActivityDate = DateUtils.SqlMinValue;
- administratorInfo.CreationDate = DateTime.Now;
- administratorInfo.PasswordFormat = EPasswordFormat.Encrypted;
- var isCreated = DataProvider.AdministratorDao.Insert(administratorInfo, out errorMessage);
- if (isCreated == false) return false;
-
- var roles = new[] { EPredefinedRoleUtils.GetValue(EPredefinedRole.Administrator) };
- DataProvider.AdministratorsInRolesDao.AddUserToRoles(administratorInfo.UserName, roles);
-
- return true;
- }
- catch (Exception ex)
- {
- errorMessage = ex.Message;
- return false;
- }
- }
-
- public const string AnonymousUserName = "Anonymous";
-
- public static string GetRolesHtml(string userName)
- {
- var isConsoleAdministrator = false;
- var isSystemAdministrator = false;
- var arraylist = new ArrayList();
- var roles = DataProvider.AdministratorsInRolesDao.GetRolesForUser(userName);
- foreach (var role in roles)
- {
- if (!EPredefinedRoleUtils.IsPredefinedRole(role))
- {
- arraylist.Add(role);
- }
- else
- {
- if (EPredefinedRoleUtils.Equals(EPredefinedRole.ConsoleAdministrator, role))
- {
- isConsoleAdministrator = true;
- break;
- }
- if (EPredefinedRoleUtils.Equals(EPredefinedRole.SystemAdministrator, role))
- {
- isSystemAdministrator = true;
- break;
- }
- }
- }
-
- var retval = string.Empty;
-
- if (isConsoleAdministrator)
- {
- retval += EPredefinedRoleUtils.GetText(EPredefinedRole.ConsoleAdministrator);
- }
- else if (isSystemAdministrator)
- {
- retval += EPredefinedRoleUtils.GetText(EPredefinedRole.SystemAdministrator);
- }
- else
- {
- retval += TranslateUtils.ObjectCollectionToString(arraylist);
- }
- return retval;
- }
-
- //public static bool HasChannelPermissionIsConsoleAdministrator(string userName)
- //{
- // var roles = DataProvider.AdministratorsInRolesDao.GetRolesForUser(userName);
-
- // return EPredefinedRoleUtils.IsConsoleAdministrator(roles);
- //}
-
- //public static bool HasChannelPermissionIsSystemAdministrator(string userName)
- //{
- // var roles = DataProvider.AdministratorsInRolesDao.GetRolesForUser(userName);
-
- // return EPredefinedRoleUtils.IsSystemAdministrator(roles);
- //}
- }
-}
diff --git a/SiteServer.CMS/Core/ArchiveManager.cs b/SiteServer.CMS/Core/ArchiveManager.cs
deleted file mode 100644
index 60e3a1e6d..000000000
--- a/SiteServer.CMS/Core/ArchiveManager.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using SiteServer.CMS.Model;
-
-namespace SiteServer.CMS.Core
-{
- public class ArchiveManager
- {
- public static void CreateArchiveTableIfNotExists(SiteInfo siteInfo, string tableName)
- {
- if (!DataProvider.DatabaseDao.IsTableExists(TableMetadataManager.GetTableNameOfArchive(tableName)))
- {
- try
- {
- DataProvider.TableDao.CreateDbTableOfArchive(tableName);
- }
- catch
- {
- // ignored
- }
- }
- }
- }
-}
diff --git a/SiteServer.CMS/Core/AreaManager.cs b/SiteServer.CMS/Core/AreaManager.cs
deleted file mode 100644
index cd95300c3..000000000
--- a/SiteServer.CMS/Core/AreaManager.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using System.Collections.Generic;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Core
-{
- public class AreaManager
- {
- public static AreaInfo GetAreaInfo(int areaId)
- {
- var pairList = GetAreaInfoPairList();
-
- foreach (var pair in pairList)
- {
- var theAreaId = pair.Key;
- if (theAreaId == areaId)
- {
- var areaInfo = pair.Value;
- return areaInfo;
- }
- }
- return null;
- }
-
- public static string GetThisAreaName(int areaId)
- {
- var areaInfo = GetAreaInfo(areaId);
- if (areaInfo != null)
- {
- return areaInfo.AreaName;
- }
- return string.Empty;
- }
-
- public static string GetAreaName(int areaId)
- {
- if (areaId > 0)
- {
- var areaNameList = new List();
-
- var parentsPath = GetParentsPath(areaId);
- var areaIdList = new List();
- if (!string.IsNullOrEmpty(parentsPath))
- {
- areaIdList = TranslateUtils.StringCollectionToIntList(parentsPath);
- }
- areaIdList.Add(areaId);
-
- foreach (var theAreaId in areaIdList)
- {
- var areaInfo = GetAreaInfo(theAreaId);
- if (areaInfo != null)
- {
- areaNameList.Add(areaInfo.AreaName);
- }
- }
-
- return TranslateUtils.ObjectCollectionToString(areaNameList, " > ");
- }
- return string.Empty;
- }
-
- public static string GetParentsPath(int areaId)
- {
- var retval = string.Empty;
- var areaInfo = GetAreaInfo(areaId);
- if (areaInfo != null)
- {
- retval = areaInfo.ParentsPath;
- }
- return retval;
- }
-
- public static List GetAreaIdList()
- {
- var pairList = GetAreaInfoPairList();
- var list = new List();
- foreach (var pair in pairList)
- {
- list.Add(pair.Key);
- }
- return list;
- }
-
- public static void ClearCache()
- {
- CacheUtils.Remove(CacheKey);
- }
-
- public static List> GetAreaInfoPairList()
- {
- lock (LockObject)
- {
- if (CacheUtils.Get(CacheKey) == null)
- {
- var pairListFormDb = DataProvider.AreaDao.GetAreaInfoPairList();
- var sl = new List>();
- foreach (var pair in pairListFormDb)
- {
- var areaInfo = pair.Value;
- if (areaInfo != null)
- {
- sl.Add(pair);
- }
- }
- CacheUtils.Insert(CacheKey, sl);
- return sl;
- }
- return CacheUtils.Get(CacheKey) as List>;
- }
- }
-
- /****************** Cache *********************/
-
- private static readonly object LockObject = new object();
- private const string CacheKey = "BaiRong.Core.AreaManager";
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Core/CacheDbUtils.cs b/SiteServer.CMS/Core/CacheDbUtils.cs
deleted file mode 100644
index e9744d342..000000000
--- a/SiteServer.CMS/Core/CacheDbUtils.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-namespace SiteServer.CMS.Core
-{
- public class CacheDbUtils
- {
- private CacheDbUtils()
- {
- }
-
- public static void RemoveAndInsert(string cacheKey, string cacheValue)
- {
- if (!string.IsNullOrEmpty(cacheKey))
- {
- DataProvider.DbCacheDao.RemoveAndInsert(cacheKey, cacheValue);
- }
- }
-
- public static void Clear()
- {
- DataProvider.DbCacheDao.Clear();
- }
-
- public static bool IsExists(string cacheKey)
- {
- return DataProvider.DbCacheDao.IsExists(cacheKey);
- }
-
- public static string GetValue(string cacheKey)
- {
- return DataProvider.DbCacheDao.GetValue(cacheKey);
- }
-
- public static string GetValueAndRemove(string cacheKey)
- {
- return DataProvider.DbCacheDao.GetValueAndRemove(cacheKey);
- }
-
- public static int GetCount()
- {
- return DataProvider.DbCacheDao.GetCount();
- }
-
- }
-}
diff --git a/SiteServer.CMS/Core/ChannelManager.cs b/SiteServer.CMS/Core/ChannelManager.cs
deleted file mode 100644
index 46a4e0612..000000000
--- a/SiteServer.CMS/Core/ChannelManager.cs
+++ /dev/null
@@ -1,575 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.Utils.IO;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Plugin;
-using SiteServer.CMS.StlParser.Cache;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public static class ChannelManager
- {
- private static class ChannelManagerCache
- {
- private static readonly object LockObject = new object();
- private const string CacheKey = "SiteServer.CMS.Core.ChannelManager";
- private static readonly FileWatcherClass FileWatcher;
-
- static ChannelManagerCache()
- {
- FileWatcher = new FileWatcherClass(FileWatcherClass.Node);
- FileWatcher.OnFileChange += FileWatcher_OnFileChange;
- }
-
- private static void FileWatcher_OnFileChange(object sender, EventArgs e)
- {
- CacheUtils.Remove(CacheKey);
- }
-
- private static void Update(Dictionary> allDict, Dictionary dic, int siteId)
- {
- lock (LockObject)
- {
- allDict[siteId] = dic;
- }
- }
-
- private static Dictionary> GetAllDictionary()
- {
- var allDict = CacheUtils.Get(CacheKey) as Dictionary>;
- if (allDict != null) return allDict;
-
- allDict = new Dictionary>();
- CacheUtils.InsertHours(CacheKey, allDict, 24);
- return allDict;
- }
-
- public static void Remove(int siteId)
- {
- var allDict = GetAllDictionary();
-
- lock (LockObject)
- {
- allDict.Remove(siteId);
- }
-
- FileWatcher.UpdateCacheFile();
- }
-
- public static Dictionary GetChannelInfoDictionaryBySiteId(int siteId)
- {
- var allDict = GetAllDictionary();
-
- Dictionary dict;
- allDict.TryGetValue(siteId, out dict);
-
- if (dict != null) return dict;
-
- dict = DataProvider.ChannelDao.GetChannelInfoDictionaryBySiteId(siteId);
- Update(allDict, dict, siteId);
- return dict;
- }
- }
-
- public static void RemoveCache(int siteId)
- {
- ChannelManagerCache.Remove(siteId);
- Node.ClearCache();
- }
-
- public static ChannelInfo GetChannelInfo(int siteId, int channelId)
- {
- ChannelInfo nodeInfo = null;
- var dict = ChannelManagerCache.GetChannelInfoDictionaryBySiteId(siteId);
- dict?.TryGetValue(channelId, out nodeInfo);
- return nodeInfo;
- }
-
- public static List GetChannelInfoList(int siteId)
- {
- var dic = ChannelManagerCache.GetChannelInfoDictionaryBySiteId(siteId);
- return dic.Values.Where(nodeInfo => nodeInfo != null).ToList();
- }
-
- public static List GetChannelIdList(int siteId)
- {
- var dic = ChannelManagerCache.GetChannelInfoDictionaryBySiteId(siteId);
- return dic.Values.OrderBy(c => c.Taxis).Select(channelInfo => channelInfo.Id).ToList();
- }
-
- public static List GetChannelIdList(ChannelInfo channelInfo, EScopeType scopeType, string group, string groupNot, string contentModelPluginId)
- {
- if (channelInfo == null) return new List();
-
- var dic = ChannelManagerCache.GetChannelInfoDictionaryBySiteId(channelInfo.SiteId);
- var channelInfoList = new List();
-
- if (channelInfo.ChildrenCount == 0)
- {
- if (scopeType != EScopeType.Children && scopeType != EScopeType.Descendant)
- {
- channelInfoList.Add(channelInfo);
- }
- }
- else if (scopeType == EScopeType.Self)
- {
- channelInfoList.Add(channelInfo);
- }
- else if (scopeType == EScopeType.All)
- {
- foreach (var nodeInfo in dic.Values)
- {
- if (nodeInfo.Id == channelInfo.Id || nodeInfo.ParentId == channelInfo.Id || StringUtils.In(nodeInfo.ParentsPath, channelInfo.Id))
- {
- channelInfoList.Add(nodeInfo);
- }
- }
- }
- else if (scopeType == EScopeType.Children)
- {
- foreach (var nodeInfo in dic.Values)
- {
- if (nodeInfo.ParentId == channelInfo.Id)
- {
- channelInfoList.Add(nodeInfo);
- }
- }
- }
- else if (scopeType == EScopeType.Descendant)
- {
- foreach (var nodeInfo in dic.Values)
- {
- if (nodeInfo.ParentId == channelInfo.Id || StringUtils.In(nodeInfo.ParentsPath, channelInfo.Id))
- {
- channelInfoList.Add(nodeInfo);
- }
- }
- }
- else if (scopeType == EScopeType.SelfAndChildren)
- {
- foreach (var nodeInfo in dic.Values)
- {
- if (nodeInfo.Id == channelInfo.Id || nodeInfo.ParentId == channelInfo.Id)
- {
- channelInfoList.Add(nodeInfo);
- }
- }
- }
-
- var filteredChannelInfoList = new List();
- foreach (var nodeInfo in channelInfoList)
- {
- if (!string.IsNullOrEmpty(group))
- {
- if (!StringUtils.In(nodeInfo.GroupNameCollection, group))
- {
- continue;
- }
- }
- if (!string.IsNullOrEmpty(groupNot))
- {
- if (StringUtils.In(nodeInfo.GroupNameCollection, groupNot))
- {
- continue;
- }
- }
- if (!string.IsNullOrEmpty(contentModelPluginId))
- {
- if (!StringUtils.EqualsIgnoreCase(nodeInfo.ContentModelPluginId, contentModelPluginId))
- {
- continue;
- }
- }
- filteredChannelInfoList.Add(nodeInfo);
- }
-
- return filteredChannelInfoList.OrderBy(c => c.Taxis).Select(channelInfoInList => channelInfoInList.Id).ToList();
- }
-
- public static bool IsExists(int siteId, int channelId)
- {
- var nodeInfo = GetChannelInfo(siteId, channelId);
- return nodeInfo != null;
- }
-
- public static bool IsExists(int channelId)
- {
- var list = SiteManager.GetSiteIdList();
- foreach (var siteId in list)
- {
- var nodeInfo = GetChannelInfo(siteId, channelId);
- if (nodeInfo != null) return true;
- }
-
- return false;
- }
-
- public static int GetChannelIdByParentsCount(int siteId, int channelId, int parentsCount)
- {
- if (parentsCount == 0) return siteId;
- if (channelId == 0 || channelId == siteId) return siteId;
-
- var nodeInfo = GetChannelInfo(siteId, channelId);
- if (nodeInfo != null)
- {
- return nodeInfo.ParentsCount == parentsCount ? nodeInfo.Id : GetChannelIdByParentsCount(siteId, nodeInfo.ParentId, parentsCount);
- }
- return siteId;
- }
-
- public static string GetTableName(SiteInfo siteInfo, int channelId)
- {
- return GetTableName(siteInfo, GetChannelInfo(siteInfo.Id, channelId));
- }
-
- public static string GetTableName(SiteInfo siteInfo, ChannelInfo nodeInfo)
- {
- return nodeInfo != null ? GetTableName(siteInfo, nodeInfo.ContentModelPluginId) : string.Empty;
- }
-
- public static string GetTableName(SiteInfo siteInfo, string pluginId)
- {
- var tableName = siteInfo.TableName;
-
- if (string.IsNullOrEmpty(pluginId)) return tableName;
-
- var contentTable = PluginContentTableManager.GetTableName(pluginId);
- if (!string.IsNullOrEmpty(contentTable))
- {
- tableName = contentTable;
- }
-
- return tableName;
- }
-
- //public static ETableStyle GetTableStyle(SiteInfo siteInfo, int channelId)
- //{
- // return GetTableStyle(siteInfo, GetChannelInfo(siteInfo.Id, channelId));
- //}
-
- //public static ETableStyle GetTableStyle(SiteInfo siteInfo, NodeInfo nodeInfo)
- //{
- // var tableStyle = ETableStyle.BackgroundContent;
-
- // if (string.IsNullOrEmpty(nodeInfo.ContentModelPluginId)) return tableStyle;
-
- // var contentTable = PluginCache.GetEnabledPluginMetadata(nodeInfo.ContentModelPluginId);
- // if (contentTable != null)
- // {
- // tableStyle = ETableStyle.Custom;
- // }
-
- // return tableStyle;
- //}
-
- public static bool IsContentModelPlugin(SiteInfo siteInfo, ChannelInfo nodeInfo)
- {
- if (string.IsNullOrEmpty(nodeInfo.ContentModelPluginId)) return false;
-
- var contentTable = PluginContentTableManager.GetTableName(nodeInfo.ContentModelPluginId);
- return !string.IsNullOrEmpty(contentTable);
- }
-
- public static string GetNodeTreeLastImageHtml(SiteInfo siteInfo, ChannelInfo nodeInfo)
- {
- var imageHtml = string.Empty;
- if (nodeInfo.ParentId == 0)
- {
- var treeDirectoryUrl = SiteServerAssets.GetIconUrl("tree");
- if (siteInfo.IsRoot == false)
- {
- imageHtml =
- $@" ";
- }
- else
- {
- imageHtml =
- $@" ";
- }
- }
- if (!string.IsNullOrEmpty(nodeInfo.ContentRelatedPluginIds))
- {
- foreach (var service in PluginContentManager.GetContentPlugins(nodeInfo, false))
- {
- var iconClass = PluginMenuManager.GetPluginIconClass(service.PluginId);
- if (!string.IsNullOrEmpty(iconClass))
- {
- imageHtml +=
- $@" ";
- }
- else
- {
- imageHtml +=
- $@" ";
- }
- }
- }
- return imageHtml;
- }
-
- public static DateTime GetAddDate(int siteId, int channelId)
- {
- var retval = DateTime.MinValue;
- var nodeInfo = GetChannelInfo(siteId, channelId);
- if (nodeInfo != null)
- {
- retval = nodeInfo.AddDate;
- }
- return retval;
- }
-
- public static int GetParentId(int siteId, int channelId)
- {
- var retval = 0;
- var nodeInfo = GetChannelInfo(siteId, channelId);
- if (nodeInfo != null)
- {
- retval = nodeInfo.ParentId;
- }
- return retval;
- }
-
- public static string GetParentsPath(int siteId, int channelId)
- {
- var retval = string.Empty;
- var nodeInfo = GetChannelInfo(siteId, channelId);
- if (nodeInfo != null)
- {
- retval = nodeInfo.ParentsPath;
- }
- return retval;
- }
-
- public static int GetTopLevel(int siteId, int channelId)
- {
- var parentsPath = GetParentsPath(siteId, channelId);
- return string.IsNullOrEmpty(parentsPath) ? 0 : parentsPath.Split(',').Length;
- }
-
- public static string GetChannelName(int siteId, int channelId)
- {
- var retval = string.Empty;
- var nodeInfo = GetChannelInfo(siteId, channelId);
- if (nodeInfo != null)
- {
- retval = nodeInfo.ChannelName;
- }
- return retval;
- }
-
- public static string GetChannelNameNavigation(int siteId, int channelId)
- {
- var nodeNameList = new List();
-
- if (channelId == 0) channelId = siteId;
-
- if (channelId == siteId)
- {
- var nodeInfo = GetChannelInfo(siteId, siteId);
- return nodeInfo.ChannelName;
- }
- var parentsPath = GetParentsPath(siteId, channelId);
- var channelIdList = new List();
- if (!string.IsNullOrEmpty(parentsPath))
- {
- channelIdList = TranslateUtils.StringCollectionToIntList(parentsPath);
- }
- channelIdList.Add(channelId);
- channelIdList.Remove(siteId);
-
- foreach (var theChannelId in channelIdList)
- {
- var nodeInfo = GetChannelInfo(siteId, theChannelId);
- if (nodeInfo != null)
- {
- nodeNameList.Add(nodeInfo.ChannelName);
- }
- }
-
- return TranslateUtils.ObjectCollectionToString(nodeNameList, " > ");
- }
-
- public static void AddListItems(ListItemCollection listItemCollection, SiteInfo siteInfo, bool isSeeOwning, bool isShowContentNum, PermissionManager permissionManager)
- {
- var list = GetChannelIdList(siteInfo.Id);
- var nodeCount = list.Count;
- var isLastNodeArray = new bool[nodeCount];
- foreach (var channelId in list)
- {
- var enabled = true;
- if (isSeeOwning)
- {
- enabled = permissionManager.IsOwningChannelId(channelId);
- if (!enabled)
- {
- if (!permissionManager.IsDescendantOwningChannelId(siteInfo.Id, channelId)) continue;
- }
- }
- var nodeInfo = GetChannelInfo(siteInfo.Id, channelId);
-
- var listitem = new ListItem(GetSelectText(siteInfo, nodeInfo, isLastNodeArray, isShowContentNum), nodeInfo.Id.ToString());
- if (!enabled)
- {
- listitem.Attributes.Add("style", "color:gray;");
- }
- listItemCollection.Add(listitem);
- }
- }
-
- public static void AddListItems(ListItemCollection listItemCollection, SiteInfo siteInfo, bool isSeeOwning, bool isShowContentNum, string contentModelId, PermissionManager permissionManager)
- {
- var list = GetChannelIdList(siteInfo.Id);
- var nodeCount = list.Count;
- var isLastNodeArray = new bool[nodeCount];
- foreach (var channelId in list)
- {
- var enabled = true;
- if (isSeeOwning)
- {
- enabled = permissionManager.IsOwningChannelId(channelId);
- if (!enabled)
- {
- if (!permissionManager.IsDescendantOwningChannelId(siteInfo.Id, channelId)) continue;
- }
- }
- var nodeInfo = GetChannelInfo(siteInfo.Id, channelId);
-
- var listitem = new ListItem(GetSelectText(siteInfo, nodeInfo, isLastNodeArray, isShowContentNum), nodeInfo.Id.ToString());
- if (!enabled)
- {
- listitem.Attributes.Add("style", "color:gray;");
- }
- if (!StringUtils.EqualsIgnoreCase(nodeInfo.ContentModelPluginId, contentModelId))
- {
- listitem.Attributes.Add("disabled", "disabled");
- }
- listItemCollection.Add(listitem);
- }
- }
-
- public static void AddListItemsForAddContent(ListItemCollection listItemCollection, SiteInfo siteInfo, bool isSeeOwning, PermissionManager permissionManager)
- {
- var list = GetChannelIdList(siteInfo.Id);
- var nodeCount = list.Count;
- var isLastNodeArray = new bool[nodeCount];
- foreach (var channelId in list)
- {
- var enabled = true;
- if (isSeeOwning)
- {
- enabled = permissionManager.IsOwningChannelId(channelId);
- }
-
- var nodeInfo = GetChannelInfo(siteInfo.Id, channelId);
- if (enabled)
- {
- if (nodeInfo.Additional.IsContentAddable == false) enabled = false;
- }
-
- if (!enabled)
- {
- continue;
- }
-
- var listitem = new ListItem(GetSelectText(siteInfo, nodeInfo, isLastNodeArray, true), nodeInfo.Id.ToString());
- listItemCollection.Add(listitem);
- }
- }
-
- ///
- /// 得到栏目,并且不对(栏目是否可添加内容)进行判断
- /// 提供给触发器页面使用
- /// 使用场景:其他栏目的内容变动之后,设置某个栏目(此栏目不能添加内容)触发生成
- ///
- public static void AddListItemsForCreateChannel(ListItemCollection listItemCollection, SiteInfo siteInfo, bool isSeeOwning, PermissionManager permissionManager)
- {
- var list = GetChannelIdList(siteInfo.Id);
- var nodeCount = list.Count;
- var isLastNodeArray = new bool[nodeCount];
- foreach (var channelId in list)
- {
- var enabled = true;
- if (isSeeOwning)
- {
- enabled = permissionManager.IsOwningChannelId(channelId);
- }
-
- var nodeInfo = GetChannelInfo(siteInfo.Id, channelId);
-
- if (!enabled)
- {
- continue;
- }
-
- var listitem = new ListItem(GetSelectText(siteInfo, nodeInfo, isLastNodeArray, true), nodeInfo.Id.ToString());
- listItemCollection.Add(listitem);
- }
- }
-
- public static string GetSelectText(SiteInfo siteInfo, ChannelInfo nodeInfo, bool[] isLastNodeArray, bool isShowContentNum)
- {
- var retval = string.Empty;
- if (nodeInfo.Id == nodeInfo.SiteId)
- {
- nodeInfo.IsLastNode = true;
- }
- if (nodeInfo.IsLastNode == false)
- {
- isLastNodeArray[nodeInfo.ParentsCount] = false;
- }
- else
- {
- isLastNodeArray[nodeInfo.ParentsCount] = true;
- }
- for (var i = 0; i < nodeInfo.ParentsCount; i++)
- {
- retval = string.Concat(retval, isLastNodeArray[i] ? " " : "│");
- }
- retval = string.Concat(retval, nodeInfo.IsLastNode ? "└" : "├");
- retval = string.Concat(retval, nodeInfo.ChannelName);
-
- if (isShowContentNum)
- {
- retval = string.Concat(retval, " (", nodeInfo.ContentNum, ")");
- }
-
- return retval;
- }
-
- public static string GetContentAttributesOfDisplay(int siteId, int channelId)
- {
- var nodeInfo = GetChannelInfo(siteId, channelId);
- if (nodeInfo == null) return string.Empty;
- if (siteId != channelId && string.IsNullOrEmpty(nodeInfo.Additional.ContentAttributesOfDisplay))
- {
- return GetContentAttributesOfDisplay(siteId, nodeInfo.ParentId);
- }
- return nodeInfo.Additional.ContentAttributesOfDisplay;
- }
-
- public static bool IsAncestorOrSelf(int siteId, int parentId, int childId)
- {
- if (parentId == childId)
- {
- return true;
- }
- var nodeInfo = GetChannelInfo(siteId, childId);
- if (nodeInfo == null)
- {
- return false;
- }
- if (StringUtils.In(nodeInfo.ParentsPath, parentId.ToString()))
- {
- return true;
- }
- return false;
- }
- }
-
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Core/CheckManager.cs b/SiteServer.CMS/Core/CheckManager.cs
deleted file mode 100644
index 550419bb3..000000000
--- a/SiteServer.CMS/Core/CheckManager.cs
+++ /dev/null
@@ -1,1158 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.CMS.Core
-{
- public class CheckManager
- {
- public class LevelInt
- {
- public const int CaoGao = -99;//草稿
- public const int DaiShen = 0;//待审
-
- public const int Pass1 = 1;//初审通过
- public const int Pass2 = 2;//二审通过
- public const int Pass3 = 3;//三审通过
- public const int Pass4 = 4;//四审通过
- public const int Pass5 = 5;//终审通过
-
- public const int Fail1 = -1;//初审退稿
- public const int Fail2 = -2;//二审退稿
- public const int Fail3 = -3;//三审退稿
- public const int Fail4 = -4;//四审退稿
- public const int Fail5 = -5;//终审退稿
-
- public const int NotChange = -100;//保持不变
-
- public static List GetFailLevelList()
- {
- return new List
- {
- Fail1,
- Fail2,
- Fail3,
- Fail4,
- Fail5
- };
- }
-
- public static List GetUnCheckedLevelList()
- {
- return new List
- {
- DaiShen,
- Pass1,
- Pass2,
- Pass3,
- Pass4
- };
- }
-
- public static List GetCheckLevelList(SiteInfo siteInfo, bool isChecked, int checkedLevel)
- {
- if (isChecked)
- {
- checkedLevel = 5;
- }
-
- var list = new List
- {
- DaiShen
- };
-
- if (checkedLevel >= 1)
- {
- list.Add(Fail1);
- }
-
- if (checkedLevel >= 2)
- {
- list.Add(Pass1);
- list.Add(Fail2);
- }
-
- if (checkedLevel >= 3)
- {
- list.Add(Pass2);
- list.Add(Fail3);
- }
-
- if (checkedLevel >= 4)
- {
- list.Add(Pass3);
- list.Add(Fail4);
- }
-
- if (checkedLevel >= 5)
- {
- list.Add(Pass4);
- list.Add(Fail5);
- }
-
- return list;
- }
-
- public static List GetCheckLevelListOfNeedCheck(SiteInfo siteInfo, bool isChecked, int checkedLevel)
- {
- if (isChecked)
- {
- checkedLevel = 5;
- }
-
- var list = new List
- {
- DaiShen
- };
-
- if (checkedLevel >= 2)
- {
- list.Add(Pass1);
- }
-
- if (checkedLevel >= 3)
- {
- list.Add(Pass2);
- }
-
- if (checkedLevel >= 4)
- {
- list.Add(Pass3);
- }
-
- if (checkedLevel >= 5)
- {
- list.Add(Pass4);
- }
-
- return list;
- }
-
- public static string GetLevelName(int level, SiteInfo siteInfo)
- {
- var retval = string.Empty;
- if (level == CaoGao)
- {
- retval = "草稿";
- }
- else if (level == DaiShen)
- {
- retval = "待审核";
- }
- else if (level == Pass1)
- {
- retval = "初审通过";
- }
- else if (level == Pass2)
- {
- retval = "二审通过";
- }
- else if (level == Pass3)
- {
- retval = "三审通过";
- }
- else if (level == Pass4)
- {
- retval = "四审通过";
- }
- else if (level == Pass5)
- {
- retval = "终审通过";
- }
- else if (level == Fail1)
- {
- retval = "初审退稿";
- }
- else if (level == Fail2)
- {
- retval = "二审退稿";
- }
- else if (level == Fail3)
- {
- retval = "三审退稿";
- }
- else if (level == Fail4)
- {
- retval = "四审退稿";
- }
- else if (level == Fail5)
- {
- retval = "终审退稿";
- }
- else if (level == NotChange)
- {
- retval = "保持不变";
- }
-
- if (siteInfo.Additional.IsCheckContentLevel)
- {
- if (siteInfo.Additional.CheckContentLevel <= level)
- {
- retval = "终审通过";
- }
- }
- else
- {
- if (level > 1)
- {
- retval = "终审通过";
- }
- }
-
- return retval;
- }
- }
-
- public class Level
- {
- public const string CaoGao = "草稿";//草稿
- public const string DaiShen = "待审核";//待审
- public const string YiShenHe = "已审核";//已审核
-
- public const string NotChange = "保持不变";//保持不变
- }
-
- public class Level5
- {
- public const string Pass1 = "初审通过,等待二审";
- public const string Pass2 = "二审通过,等待三审";
- public const string Pass3 = "三审通过,等待四审";
- public const string Pass4 = "四审通过,等待终审";
- public const string Pass5 = "终审通过";
-
- public const string Fail1 = "初审退稿";
- public const string Fail2 = "二审退稿";
- public const string Fail3 = "三审退稿";
- public const string Fail4 = "四审退稿";
- public const string Fail5 = "终审退稿";
- }
-
- public class Level4
- {
- public const string Pass1 = "初审通过,等待二审";
- public const string Pass2 = "二审通过,等待三审";
- public const string Pass3 = "三审通过,等待终审";
- public const string Pass4 = "终审通过";
-
- public const string Fail1 = "初审退稿";
- public const string Fail2 = "二审退稿";
- public const string Fail3 = "三审退稿";
- public const string Fail4 = "终审退稿";
- }
-
- public class Level3
- {
- public const string Pass1 = "初审通过,等待二审";
- public const string Pass2 = "二审通过,等待终审";
- public const string Pass3 = "终审通过";
-
- public const string Fail1 = "初审退稿";
- public const string Fail2 = "二审退稿";
- public const string Fail3 = "终审退稿";
- }
-
- public class Level2
- {
- public const string Pass1 = "初审通过,等待终审";
- public const string Pass2 = "终审通过";
-
- public const string Fail1 = "初审退稿";
- public const string Fail2 = "终审退稿";
- }
-
- public class Level1
- {
- public const string Pass1 = "终审通过";
-
- public const string Fail1 = "终审退稿";
- }
-
- public static void LoadContentLevelToEdit(ListControl listControl, SiteInfo siteInfo, int channelId, ContentInfo contentInfo, bool isChecked, int checkedLevel)
- {
- var checkContentLevel = siteInfo.Additional.CheckContentLevel;
- if (isChecked)
- {
- checkedLevel = checkContentLevel;
- }
-
- ListItem listItem;
-
- var isCheckable = false;
- if (contentInfo != null)
- {
- isCheckable = IsCheckable(siteInfo, channelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isChecked, checkedLevel);
- if (isCheckable)
- {
- listItem = new ListItem(Level.NotChange, LevelInt.NotChange.ToString());
- listControl.Items.Add(listItem);
- }
- }
-
- listItem = new ListItem(Level.CaoGao, LevelInt.CaoGao.ToString());
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level.DaiShen, LevelInt.DaiShen.ToString());
- listControl.Items.Add(listItem);
-
- if (checkContentLevel == 0 || checkContentLevel == 1)
- {
- listItem = new ListItem(Level1.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 2)
- {
- listItem = new ListItem(Level2.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level2.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 3)
- {
- listItem = new ListItem(Level3.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level3.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level3.Pass3, LevelInt.Pass3.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 4)
- {
- listItem = new ListItem(Level4.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level4.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level4.Pass3, LevelInt.Pass3.ToString())
- {
- Enabled = checkedLevel >= 3
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level4.Pass4, LevelInt.Pass4.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 5)
- {
- listItem = new ListItem(Level5.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass3, LevelInt.Pass3.ToString())
- {
- Enabled = checkedLevel >= 3
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass4, LevelInt.Pass4.ToString())
- {
- Enabled = checkedLevel >= 4
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass5, LevelInt.Pass5.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
-
- if (contentInfo == null)
- {
- ControlUtils.SelectSingleItem(listControl, checkedLevel.ToString());
- }
- else
- {
- ControlUtils.SelectSingleItem(listControl,
- isCheckable ? LevelInt.NotChange.ToString() : checkedLevel.ToString());
- }
- }
-
- public static void LoadContentLevelToList(ListControl listControl, SiteInfo siteInfo, int siteId, bool isChecked, int checkedLevel)
- {
- var checkContentLevel = siteInfo.Additional.CheckContentLevel;
-
- if (isChecked)
- {
- checkedLevel = checkContentLevel;
- }
-
- var listItem = new ListItem("全部", String.Empty);
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level.DaiShen, LevelInt.DaiShen.ToString());
- listControl.Items.Add(listItem);
-
- if (checkContentLevel == 1)
- {
- if (isChecked)
- {
- listItem = new ListItem(Level1.Fail1, LevelInt.Fail1.ToString());
- listControl.Items.Add(listItem);
- }
- }
- else if (checkContentLevel == 2)
- {
- if (checkedLevel >= 1)
- {
- listItem = new ListItem(Level2.Fail1, LevelInt.Fail1.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (isChecked)
- {
- listItem = new ListItem(Level2.Fail2, LevelInt.Fail2.ToString());
- listControl.Items.Add(listItem);
- }
- }
- else if (checkContentLevel == 3)
- {
- if (checkedLevel >= 1)
- {
- listItem = new ListItem(Level3.Fail1, LevelInt.Fail1.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 2)
- {
- listItem = new ListItem(Level3.Fail2, LevelInt.Fail2.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (isChecked)
- {
- listItem = new ListItem(Level3.Fail3, LevelInt.Fail3.ToString());
- listControl.Items.Add(listItem);
- }
- }
- else if (checkContentLevel == 4)
- {
- if (checkedLevel >= 1)
- {
- listItem = new ListItem(Level4.Fail1, LevelInt.Fail1.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 2)
- {
- listItem = new ListItem(Level4.Fail2, LevelInt.Fail2.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 3)
- {
- listItem = new ListItem(Level4.Fail3, LevelInt.Fail3.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (isChecked)
- {
- listItem = new ListItem(Level4.Fail4, LevelInt.Fail4.ToString());
- listControl.Items.Add(listItem);
- }
- }
- else if (checkContentLevel == 5)
- {
- if (checkedLevel >= 1)
- {
- listItem = new ListItem(Level5.Fail1, LevelInt.Fail1.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 2)
- {
- listItem = new ListItem(Level5.Fail2, LevelInt.Fail2.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 3)
- {
- listItem = new ListItem(Level5.Fail3, LevelInt.Fail3.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 4)
- {
- listItem = new ListItem(Level5.Fail4, LevelInt.Fail4.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (isChecked)
- {
- listItem = new ListItem(Level5.Fail5, LevelInt.Fail5.ToString());
- listControl.Items.Add(listItem);
- }
- }
-
- if (checkContentLevel == 2)
- {
- if (checkedLevel >= 1)
- {
- listItem = new ListItem(Level2.Pass1, LevelInt.Pass1.ToString());
- listControl.Items.Add(listItem);
- }
- }
- else if (checkContentLevel == 3)
- {
- if (checkedLevel >= 1)
- {
- listItem = new ListItem(Level3.Pass1, LevelInt.Pass1.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 2)
- {
- listItem = new ListItem(Level3.Pass2, LevelInt.Pass2.ToString());
- listControl.Items.Add(listItem);
- }
- }
- else if (checkContentLevel == 4)
- {
- if (checkedLevel >= 1)
- {
- listItem = new ListItem(Level4.Pass1, LevelInt.Pass1.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 2)
- {
- listItem = new ListItem(Level4.Pass2, LevelInt.Pass2.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 3)
- {
- listItem = new ListItem(Level4.Pass3, LevelInt.Pass3.ToString());
- listControl.Items.Add(listItem);
- }
- }
- else if (checkContentLevel == 5)
- {
- if (checkedLevel >= 2)
- {
- listItem = new ListItem(Level5.Pass1, LevelInt.Pass1.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 3)
- {
- listItem = new ListItem(Level5.Pass2, LevelInt.Pass2.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 4)
- {
- listItem = new ListItem(Level5.Pass3, LevelInt.Pass3.ToString());
- listControl.Items.Add(listItem);
- }
-
- if (checkedLevel >= 5)
- {
- listItem = new ListItem(Level5.Pass4, LevelInt.Pass4.ToString());
- listControl.Items.Add(listItem);
- }
- }
-
- ControlUtils.SelectSingleItem(listControl, string.Empty);
- }
-
- public static void LoadContentLevelToCheck(ListControl listControl, SiteInfo siteInfo, bool isChecked, int checkedLevel)
- {
- var checkContentLevel = siteInfo.Additional.CheckContentLevel;
- if (isChecked)
- {
- checkedLevel = checkContentLevel;
- }
-
- var listItem = new ListItem(Level.CaoGao, LevelInt.CaoGao.ToString());
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level.DaiShen, LevelInt.DaiShen.ToString());
- listControl.Items.Add(listItem);
-
- if (checkContentLevel == 1)
- {
- listItem = new ListItem(Level1.Fail1, LevelInt.Fail1.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 2)
- {
- listItem = new ListItem(Level2.Fail1, LevelInt.Fail1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level2.Fail2, LevelInt.Fail2.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 3)
- {
- listItem = new ListItem(Level3.Fail1, LevelInt.Fail1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level3.Fail2, LevelInt.Fail2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level3.Fail3, LevelInt.Fail3.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 4)
- {
- listItem = new ListItem(Level4.Fail1, LevelInt.Fail1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level4.Fail2, LevelInt.Fail2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level4.Fail3, LevelInt.Fail3.ToString())
- {
- Enabled = checkedLevel >= 3
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level4.Fail4, LevelInt.Fail4.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 5)
- {
- listItem = new ListItem(Level5.Fail1, LevelInt.Fail1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level5.Fail2, LevelInt.Fail2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level5.Fail3, LevelInt.Fail3.ToString())
- {
- Enabled = checkedLevel >= 3
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level5.Fail4, LevelInt.Fail4.ToString())
- {
- Enabled = checkedLevel >= 4
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level5.Fail5, LevelInt.Fail5.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
-
- if (checkContentLevel == 0 || checkContentLevel == 1)
- {
- listItem = new ListItem(Level1.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 2)
- {
- listItem = new ListItem(Level2.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
-
- listItem = new ListItem(Level2.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 3)
- {
- listItem = new ListItem(Level3.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level3.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level3.Pass3, LevelInt.Pass3.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 4)
- {
- listItem = new ListItem(Level4.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level4.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level4.Pass3, LevelInt.Pass3.ToString())
- {
- Enabled = checkedLevel >= 3
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level4.Pass4, LevelInt.Pass4.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
- else if (checkContentLevel == 5)
- {
- listItem = new ListItem(Level5.Pass1, LevelInt.Pass1.ToString())
- {
- Enabled = checkedLevel >= 1
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass2, LevelInt.Pass2.ToString())
- {
- Enabled = checkedLevel >= 2
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass3, LevelInt.Pass3.ToString())
- {
- Enabled = checkedLevel >= 3
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass4, LevelInt.Pass4.ToString())
- {
- Enabled = checkedLevel >= 4
- };
- listControl.Items.Add(listItem);
- listItem = new ListItem(Level5.Pass5, LevelInt.Pass5.ToString())
- {
- Enabled = isChecked
- };
- listControl.Items.Add(listItem);
- }
-
- ControlUtils.SelectSingleItem(listControl, checkedLevel.ToString());
- }
-
- public static List GetCheckLevelToPassList(SiteInfo siteInfo)
- {
- var list = new List();
- var checkContentLevel = siteInfo.Additional.CheckContentLevel;
-
- list.Add(LevelInt.DaiShen);
-
- if (checkContentLevel == 0 || checkContentLevel == 1)
- {
- list.Add(LevelInt.Pass1);
- }
- else if (checkContentLevel == 2)
- {
- list.Add(LevelInt.Pass1);
- list.Add(LevelInt.Pass2);
- }
- else if (checkContentLevel == 3)
- {
- list.Add(LevelInt.Pass1);
- list.Add(LevelInt.Pass2);
- list.Add(LevelInt.Pass3);
- }
- else if (checkContentLevel == 4)
- {
- list.Add(LevelInt.Pass1);
- list.Add(LevelInt.Pass2);
- list.Add(LevelInt.Pass3);
- list.Add(LevelInt.Pass4);
- }
- else if (checkContentLevel == 5)
- {
- list.Add(LevelInt.Pass1);
- list.Add(LevelInt.Pass2);
- list.Add(LevelInt.Pass3);
- list.Add(LevelInt.Pass4);
- list.Add(LevelInt.Pass5);
- }
-
- return list;
- }
-
- public static string GetCheckState(SiteInfo siteInfo, bool isChecked, int level)
- {
- if (isChecked)
- {
- return Level.YiShenHe;
- }
-
- var retval = String.Empty;
-
- if (level == LevelInt.CaoGao)
- {
- retval = Level.CaoGao;
- }
- else if (level == LevelInt.DaiShen)
- {
- retval = Level.DaiShen;
- }
- else
- {
- var checkContentLevel = siteInfo.Additional.CheckContentLevel;
-
- if (checkContentLevel == 1)
- {
- if (level == LevelInt.Fail1)
- {
- retval = Level1.Fail1;
- }
- }
- else if (checkContentLevel == 2)
- {
- if (level == LevelInt.Pass1)
- {
- retval = Level2.Pass1;
- }
- else if (level == LevelInt.Fail1)
- {
- retval = Level2.Fail1;
- }
- else if (level == LevelInt.Fail2)
- {
- retval = Level2.Fail2;
- }
- }
- else if (checkContentLevel == 3)
- {
- if (level == LevelInt.Pass1)
- {
- retval = Level3.Pass1;
- }
- else if (level == LevelInt.Pass2)
- {
- retval = Level3.Pass2;
- }
- else if (level == LevelInt.Fail1)
- {
- retval = Level3.Fail1;
- }
- else if (level == LevelInt.Fail2)
- {
- retval = Level3.Fail2;
- }
- else if (level == LevelInt.Fail3)
- {
- retval = Level3.Fail3;
- }
- }
- else if (checkContentLevel == 4)
- {
- if (level == LevelInt.Pass1)
- {
- retval = Level4.Pass1;
- }
- else if (level == LevelInt.Pass2)
- {
- retval = Level4.Pass2;
- }
- else if (level == LevelInt.Pass3)
- {
- retval = Level4.Pass3;
- }
- else if (level == LevelInt.Fail1)
- {
- retval = Level4.Fail1;
- }
- else if (level == LevelInt.Fail2)
- {
- retval = Level4.Fail2;
- }
- else if (level == LevelInt.Fail3)
- {
- retval = Level4.Fail3;
- }
- else if (level == LevelInt.Fail4)
- {
- retval = Level4.Fail4;
- }
- }
- else if (checkContentLevel == 5)
- {
- if (level == LevelInt.Pass1)
- {
- retval = Level5.Pass1;
- }
- else if (level == LevelInt.Pass2)
- {
- retval = Level5.Pass2;
- }
- else if (level == LevelInt.Pass3)
- {
- retval = Level5.Pass3;
- }
- else if (level == LevelInt.Pass4)
- {
- retval = Level5.Pass4;
- }
- else if (level == LevelInt.Fail1)
- {
- retval = Level5.Fail1;
- }
- else if (level == LevelInt.Fail2)
- {
- retval = Level5.Fail2;
- }
- else if (level == LevelInt.Fail3)
- {
- retval = Level5.Fail3;
- }
- else if (level == LevelInt.Fail4)
- {
- retval = Level5.Fail4;
- }
- else if (level == LevelInt.Fail5)
- {
- retval = Level5.Fail5;
- }
- }
-
- if (String.IsNullOrEmpty(retval))
- {
- if (checkContentLevel == 1)
- {
- retval = Level.DaiShen;
- }
- else if (checkContentLevel == 2)
- {
- retval = Level2.Pass1;
- }
- else if (checkContentLevel == 3)
- {
- retval = Level3.Pass2;
- }
- else if (checkContentLevel == 4)
- {
- retval = Level4.Pass3;
- }
- }
- }
-
- return $"{retval} ";
- }
-
- public static bool IsCheckable(SiteInfo siteInfo, int channelId, bool contentIsChecked, int contentCheckLevel, bool isChecked, int checkedLevel)
- {
- if (isChecked || checkedLevel >= 5)
- {
- return true;
- }
- if (contentIsChecked)
- {
- return false;
- }
- if (checkedLevel == 0)
- {
- return false;
- }
- if (checkedLevel == 1)
- {
- if (contentCheckLevel == LevelInt.CaoGao || contentCheckLevel == LevelInt.DaiShen || contentCheckLevel == LevelInt.Pass1 || contentCheckLevel == LevelInt.Fail1)
- {
- return true;
- }
- return false;
- }
- if (checkedLevel == 2)
- {
- if (contentCheckLevel == LevelInt.CaoGao || contentCheckLevel == LevelInt.DaiShen || contentCheckLevel == LevelInt.Pass1 || contentCheckLevel == LevelInt.Pass2 || contentCheckLevel == LevelInt.Fail1 || contentCheckLevel == LevelInt.Fail2)
- {
- return true;
- }
- return false;
- }
- if (checkedLevel == 3)
- {
- if (contentCheckLevel == LevelInt.CaoGao || contentCheckLevel == LevelInt.DaiShen || contentCheckLevel == LevelInt.Pass1 || contentCheckLevel == LevelInt.Pass2 || contentCheckLevel == LevelInt.Pass3 || contentCheckLevel == LevelInt.Fail1 || contentCheckLevel == LevelInt.Fail2 || contentCheckLevel == LevelInt.Fail3)
- {
- return true;
- }
- return false;
- }
- if (checkedLevel == 4)
- {
- if (contentCheckLevel == LevelInt.CaoGao || contentCheckLevel == LevelInt.DaiShen || contentCheckLevel == LevelInt.Pass1 || contentCheckLevel == LevelInt.Pass2 || contentCheckLevel == LevelInt.Pass3 || contentCheckLevel == LevelInt.Pass4 || contentCheckLevel == LevelInt.Fail1 || contentCheckLevel == LevelInt.Fail2 || contentCheckLevel == LevelInt.Fail3 || contentCheckLevel == LevelInt.Fail4)
- {
- return true;
- }
- return false;
- }
-
- return false;
- }
-
- public static KeyValuePair GetUserCheckLevel(PermissionManager permissionManager, SiteInfo siteInfo, int channelId)
- {
- if (permissionManager.IsSystemAdministrator)
- {
- return new KeyValuePair(true, siteInfo.Additional.CheckContentLevel);
- }
-
- var isChecked = false;
- var checkedLevel = 0;
- if (siteInfo.Additional.IsCheckContentLevel == false)
- {
- if (permissionManager.HasChannelPermissions(siteInfo.Id, channelId, ConfigManager.ChannelPermissions.ContentCheck))
- {
- isChecked = true;
- }
- }
- else
- {
- if (permissionManager.HasChannelPermissions(siteInfo.Id, channelId, ConfigManager.ChannelPermissions.ContentCheckLevel5))
- {
- isChecked = true;
- }
- else if (permissionManager.HasChannelPermissions(siteInfo.Id, channelId, ConfigManager.ChannelPermissions.ContentCheckLevel4))
- {
- if (siteInfo.Additional.CheckContentLevel <= 4)
- {
- isChecked = true;
- }
- else
- {
- checkedLevel = 4;
- }
- }
- else if (permissionManager.HasChannelPermissions(siteInfo.Id, channelId, ConfigManager.ChannelPermissions.ContentCheckLevel3))
- {
- if (siteInfo.Additional.CheckContentLevel <= 3)
- {
- isChecked = true;
- }
- else
- {
- checkedLevel = 3;
- }
- }
- else if (permissionManager.HasChannelPermissions(siteInfo.Id, channelId, ConfigManager.ChannelPermissions.ContentCheckLevel2))
- {
- if (siteInfo.Additional.CheckContentLevel <= 2)
- {
- isChecked = true;
- }
- else
- {
- checkedLevel = 2;
- }
- }
- else if (permissionManager.HasChannelPermissions(siteInfo.Id, channelId, ConfigManager.ChannelPermissions.ContentCheckLevel1))
- {
- if (siteInfo.Additional.CheckContentLevel <= 1)
- {
- isChecked = true;
- }
- else
- {
- checkedLevel = 1;
- }
- }
- else
- {
- checkedLevel = 0;
- }
- }
- return new KeyValuePair(isChecked, checkedLevel);
- }
-
- public static bool GetUserCheckLevel(PermissionManager permissionManager, SiteInfo siteInfo, int channelId, out int userCheckedLevel)
- {
- var checkContentLevel = siteInfo.Additional.CheckContentLevel;
-
- var pair = GetUserCheckLevel(permissionManager, siteInfo, channelId);
- var isChecked = pair.Key;
- var checkedLevel = pair.Value;
- if (isChecked)
- {
- checkedLevel = checkContentLevel;
- }
- userCheckedLevel = checkedLevel;
- return isChecked;
- }
-
- public static List> GetUserCountListUnChecked(PermissionManager permissionManager)
- {
- var list = new List>();
-
- var tableNameList = DataProvider.TableDao.GetTableNameListCreatedInDb();
-
- foreach (var tableName in tableNameList)
- {
- list.AddRange(GetUserCountListUnChecked(permissionManager, tableName));
- }
-
- return list;
- }
-
- private static List> GetUserCountListUnChecked(PermissionManager permissionManager, string tableName)
- {
- return DataProvider.ContentDao.GetCountListUnChecked(permissionManager, tableName);
- }
- }
-}
diff --git a/SiteServer.CMS/Core/ContentUtility.cs b/SiteServer.CMS/Core/ContentUtility.cs
deleted file mode 100644
index 84899c33b..000000000
--- a/SiteServer.CMS/Core/ContentUtility.cs
+++ /dev/null
@@ -1,804 +0,0 @@
-using System;
-using SiteServer.CMS.Model;
-using System.Text;
-using SiteServer.Utils;
-using System.Web.UI.WebControls;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using SiteServer.CMS.Core.Create;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.CMS.Plugin;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Core
-{
- public class ContentUtility
- {
- private ContentUtility()
- {
- }
-
- public static string PagePlaceHolder = "[SITESERVER_PAGE]";//内容翻页展位符
-
- public static string TextEditorContentEncode(SiteInfo siteInfo, string content)
- {
- if (siteInfo == null) return content;
-
- var url = siteInfo.Additional.WebUrl;
- if (siteInfo.Additional.IsSaveImageInTextEditor && !string.IsNullOrEmpty(content))
- {
- content = PathUtility.SaveImage(siteInfo, content);
- }
-
- if (string.IsNullOrEmpty(url) || url == "/")
- {
- return content;
- }
-
- var builder = new StringBuilder(content);
-
- StringUtils.ReplaceHrefOrSrc(builder, url, "@");
-
- builder.Replace("@'@", "'@");
- builder.Replace("@\"@", "\"@");
-
- return builder.ToString();
- }
-
- public static string TextEditorContentDecode(SiteInfo siteInfo, string content, bool isLocal)
- {
- if (siteInfo == null) return content;
-
- var builder = new StringBuilder(content);
-
- var virtualAssetsUrl = $"@/{siteInfo.Additional.AssetsDir}";
- string assetsUrl;
- if (isLocal)
- {
- assetsUrl = PageUtility.GetLocalSiteUrl(siteInfo,
- siteInfo.Additional.AssetsDir);
- }
- else
- {
- assetsUrl = siteInfo.Additional.AssetsUrl;
- }
- StringUtils.ReplaceHrefOrSrc(builder, virtualAssetsUrl, assetsUrl);
- StringUtils.ReplaceHrefOrSrc(builder, "@", siteInfo.Additional.WebUrl);
-
- builder.Replace(" ", " ");
-
- return builder.ToString();
- }
-
- public static string GetTitleFormatString(bool isStrong, bool isEm, bool isU, string color)
- {
- return $"{isStrong}_{isEm}_{isU}_{color}";
- }
-
- public static bool SetTitleFormatControls(string titleFormatString, CheckBox formatStrong, CheckBox formatEm, CheckBox formatU, TextBox formatColor)
- {
- var isTitleFormatted = false;
- if (!string.IsNullOrEmpty(titleFormatString))
- {
- var formats = titleFormatString.Split('_');
- if (formats.Length == 4)
- {
- formatStrong.Checked = TranslateUtils.ToBool(formats[0]);
- formatEm.Checked = TranslateUtils.ToBool(formats[1]);
- formatU.Checked = TranslateUtils.ToBool(formats[2]);
- formatColor.Text = formats[3];
- if (formatStrong.Checked || formatEm.Checked || formatU.Checked || !string.IsNullOrEmpty(formatColor.Text))
- {
- isTitleFormatted = true;
- }
- }
- }
- return isTitleFormatted;
- }
-
- public static void SetTitleFormatControls(string titleFormatString, out bool formatStrong, out bool formatEm, out bool formatU, out string formatColor)
- {
- formatStrong = formatEm = formatU = false;
- formatColor = string.Empty;
-
- if (!string.IsNullOrEmpty(titleFormatString))
- {
- var formats = titleFormatString.Split('_');
- if (formats.Length == 4)
- {
- formatStrong = TranslateUtils.ToBool(formats[0]);
- formatEm = TranslateUtils.ToBool(formats[1]);
- formatU = TranslateUtils.ToBool(formats[2]);
- formatColor = formats[3];
- }
- }
- }
-
- public static string FormatTitle(string titleFormatString, string title)
- {
- var formattedTitle = title;
- if (!string.IsNullOrEmpty(titleFormatString))
- {
- var formats = titleFormatString.Split('_');
- if (formats.Length == 4)
- {
- var isStrong = TranslateUtils.ToBool(formats[0]);
- var isEm = TranslateUtils.ToBool(formats[1]);
- var isU = TranslateUtils.ToBool(formats[2]);
- var color = formats[3];
-
- if (!string.IsNullOrEmpty(color))
- {
- if (!color.StartsWith("#"))
- {
- color = "#" + color;
- }
- formattedTitle = $@"{formattedTitle} ";
- }
- if (isStrong)
- {
- formattedTitle = $"{formattedTitle} ";
- }
- if (isEm)
- {
- formattedTitle = $"{formattedTitle} ";
- }
- if (isU)
- {
- formattedTitle = $"{formattedTitle} ";
- }
- }
- }
- return formattedTitle;
- }
-
- public static void PutImagePaths(SiteInfo siteInfo, ContentInfo contentInfo, NameValueCollection collection)
- {
- if (contentInfo == null) return;
-
- var imageUrl = contentInfo.GetString(BackgroundContentAttribute.ImageUrl);
- var videoUrl = contentInfo.GetString(BackgroundContentAttribute.VideoUrl);
- var fileUrl = contentInfo.GetString(BackgroundContentAttribute.FileUrl);
- var content = contentInfo.GetString(BackgroundContentAttribute.Content);
-
- if (!string.IsNullOrEmpty(imageUrl) && PageUtility.IsVirtualUrl(imageUrl))
- {
- collection[imageUrl] = PathUtility.MapPath(siteInfo, imageUrl);
- }
- if (!string.IsNullOrEmpty(videoUrl) && PageUtility.IsVirtualUrl(videoUrl))
- {
- collection[videoUrl] = PathUtility.MapPath(siteInfo, videoUrl);
- }
- if (!string.IsNullOrEmpty(fileUrl) && PageUtility.IsVirtualUrl(fileUrl))
- {
- collection[fileUrl] = PathUtility.MapPath(siteInfo, fileUrl);
- }
-
- var srcList = RegexUtils.GetOriginalImageSrcs(content);
- foreach (var src in srcList)
- {
- if (PageUtility.IsVirtualUrl(src))
- {
- collection[src] = PathUtility.MapPath(siteInfo, src);
- }
- }
- }
-
- public static string GetAutoPageContent(string content, int pageWordNum)
- {
- var builder = new StringBuilder();
- if (!string.IsNullOrEmpty(content))
- {
- content = content.Replace(PagePlaceHolder, string.Empty);
- AutoPage(builder, content, pageWordNum);
- }
- return builder.ToString();
- }
-
- private static void AutoPage(StringBuilder builder, string content, int pageWordNum)
- {
- if (content.Length > pageWordNum)
- {
- var i = content.IndexOf(" ", pageWordNum, StringComparison.Ordinal);
- if (i == -1)
- {
- i = content.IndexOf("", pageWordNum, StringComparison.Ordinal);
- }
-
- if (i != -1)
- {
- var start = i + 4;
- builder.Append(content.Substring(0, start));
- content = content.Substring(start);
- if (!string.IsNullOrEmpty(content))
- {
- builder.Append(PagePlaceHolder);
- AutoPage(builder, content, pageWordNum);
- }
- }
- else
- {
- builder.Append(content);
- }
- }
- else
- {
- builder.Append(content);
- }
- }
-
- public static int GetRealContentId(string tableName, int contentId)
- {
- string linkUrl;
- var referenceId = DataProvider.ContentDao.GetReferenceId(tableName, contentId, out linkUrl);
- return referenceId > 0 ? referenceId : contentId;
- }
-
- public static List GetAllTableStyleInfoList(List tableStyleInfoList)
- {
- var list = new List
- {
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.Id,
- DisplayName = "编号"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.Title,
- DisplayName = "标题"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.LinkUrl,
- DisplayName = "外部链接"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.AddDate,
- DisplayName = "添加时间"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.LastEditDate,
- DisplayName = "修改时间"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.GroupNameCollection,
- DisplayName = "内容组"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.Tags,
- DisplayName = "标签"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.AddUserName,
- DisplayName = "添加人"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.LastEditUserName,
- DisplayName = "修改人"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.CheckUserName,
- DisplayName = "审核人"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.CheckCheckDate,
- DisplayName = "审核时间"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.CheckReasons,
- DisplayName = "审核原因"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.SourceId,
- DisplayName = "来源标识"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.Hits,
- DisplayName = "点击量"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.HitsByDay,
- DisplayName = "日点击"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.HitsByWeek,
- DisplayName = "周点击"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.HitsByMonth,
- DisplayName = "月点击"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.LastHitsDate,
- DisplayName = "最后点击时间"
- }
- };
-
- if (tableStyleInfoList != null)
- {
- list.InsertRange(2, tableStyleInfoList);
- }
-
- return list;
- }
-
- public static List GetEditableTableStyleInfoList(List tableStyleInfoList)
- {
- var list = new List
- {
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.Title,
- InputType = InputType.Text,
- DisplayName = "标题"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.LinkUrl,
- InputType = InputType.Text,
- DisplayName = "外部链接"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.AddDate,
- InputType = InputType.DateTime,
- DisplayName = "添加时间"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.GroupNameCollection,
- InputType = InputType.CheckBox,
- DisplayName = "内容组"
- },
- new TableStyleInfo
- {
- AttributeName = ContentAttribute.Tags,
- InputType = InputType.CheckBox,
- DisplayName = "标签"
- }
- };
-
- if (tableStyleInfoList != null)
- {
- list.InsertRange(2, tableStyleInfoList);
- }
-
- return list;
- }
-
- public static bool AfterContentAdded(SiteInfo siteInfo, ChannelInfo channelInfo, int contentId, bool isCrossSiteTrans, bool isAutomatic)
- {
- var isTranslated = false;
- if (isCrossSiteTrans && isAutomatic)
- {
- var targetSiteId = 0;
-
- if (channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite)
- {
- targetSiteId = channelInfo.Additional.TransSiteId;
- }
- else if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite)
- {
- targetSiteId = siteInfo.Id;
- }
- else if (channelInfo.Additional.TransType == ECrossSiteTransType.ParentSite)
- {
- targetSiteId = SiteManager.GetParentSiteId(siteInfo.Id);
- }
-
- if (targetSiteId > 0)
- {
- var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
- if (targetSiteInfo != null)
- {
- var targetChannelIdArrayList = TranslateUtils.StringCollectionToIntList(channelInfo.Additional.TransChannelIds);
- if (targetChannelIdArrayList.Count > 0)
- {
- foreach (var targetChannelId in targetChannelIdArrayList)
- {
- CrossSiteTransUtility.TransContentInfo(siteInfo, channelInfo, contentId, targetSiteInfo, targetChannelId);
- isTranslated = true;
- }
- }
- }
- }
- }
-
- foreach (var service in PluginManager.Services)
- {
- try
- {
- service.OnContentAddCompleted(new ContentEventArgs(siteInfo.Id, channelInfo.Id, contentId));
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentAddCompleted));
- }
- }
-
- return isTranslated;
- }
-
- public static void Translate(SiteInfo siteInfo, int channelId, int contentId, string translateCollection, ETranslateContentType translateType, string administratorName)
- {
- var translateList = TranslateUtils.StringCollectionToStringList(translateCollection);
- foreach (var translate in translateList)
- {
- if (string.IsNullOrEmpty(translate)) continue;
-
- var translates = translate.Split('_');
- if (translates.Length != 2) continue;
-
- var targetSiteId = TranslateUtils.ToInt(translates[0]);
- var targetChannelId = TranslateUtils.ToInt(translates[1]);
-
- Translate(siteInfo, channelId, contentId, targetSiteId, targetChannelId, translateType, administratorName);
- }
- }
-
- public static void Translate(SiteInfo siteInfo, int channelId, int contentId, int targetSiteId, int targetChannelId, ETranslateContentType translateType, string administratorName)
- {
- if (siteInfo == null || channelId <= 0 || contentId <= 0 || targetSiteId <= 0 || targetChannelId <= 0) return;
-
- var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
-
- var targetTableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelId);
-
- var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
- var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
-
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
-
- if (contentInfo == null) return;
-
- if (translateType == ETranslateContentType.Copy)
- {
- FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo);
-
- contentInfo.SiteId = targetSiteId;
- contentInfo.SourceId = contentInfo.ChannelId;
- contentInfo.ChannelId = targetChannelId;
- contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString());
- //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString());
- var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo);
-
- foreach (var service in PluginManager.Services)
- {
- try
- {
- service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId));
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted));
- }
- }
-
- CreateManager.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, theContentId);
- }
- else if (translateType == ETranslateContentType.Cut)
- {
- FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo);
-
- contentInfo.SiteId = targetSiteId;
- contentInfo.SourceId = contentInfo.ChannelId;
- contentInfo.ChannelId = targetChannelId;
- contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString());
- //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString());
-
- var newContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo);
- DataProvider.ContentDao.DeleteContents(siteInfo.Id, tableName, TranslateUtils.ToIntList(contentId), channelId);
-
- DataProvider.ChannelDao.UpdateContentNum(siteInfo, channelId, true);
- DataProvider.ChannelDao.UpdateContentNum(targetSiteInfo, targetChannelId, true);
-
- foreach (var service in PluginManager.Services)
- {
- try
- {
- service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, newContentId));
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted));
- }
-
- try
- {
- service.OnContentDeleteCompleted(new ContentEventArgs(siteInfo.Id, channelInfo.Id, contentId));
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentDeleteCompleted));
- }
- }
-
- CreateManager.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, newContentId);
- }
- else if (translateType == ETranslateContentType.Reference)
- {
- if (contentInfo.ReferenceId != 0) return;
-
- contentInfo.SiteId = targetSiteId;
- contentInfo.SourceId = contentInfo.ChannelId;
- contentInfo.ChannelId = targetChannelId;
- contentInfo.ReferenceId = contentId;
- contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString());
- //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString());
- DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo);
- }
- else if (translateType == ETranslateContentType.ReferenceContent)
- {
- if (contentInfo.ReferenceId != 0) return;
-
- FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo);
-
- contentInfo.SiteId = targetSiteId;
- contentInfo.SourceId = contentInfo.ChannelId;
- contentInfo.ChannelId = targetChannelId;
- contentInfo.ReferenceId = contentId;
- contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.ReferenceContent.ToString());
- var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo);
-
- foreach (var service in PluginManager.Services)
- {
- try
- {
- service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId));
- }
- catch (Exception ex)
- {
- LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted));
- }
- }
-
- CreateManager.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, theContentId);
- }
- }
-
- public static Dictionary> GetIDsDictionary(NameValueCollection queryString)
- {
- var dic = new Dictionary>();
-
- if (!string.IsNullOrEmpty(queryString["IDsCollection"]))
- {
- foreach (var ids in TranslateUtils.StringCollectionToStringList(queryString["IDsCollection"]))
- {
- var channelId = TranslateUtils.ToInt(ids.Split('_')[0]);
- var contentId = TranslateUtils.ToInt(ids.Split('_')[1]);
- var contentIdList = new List();
- if (dic.ContainsKey(channelId))
- {
- contentIdList = dic[channelId];
- }
- if (!contentIdList.Contains(contentId))
- {
- contentIdList.Add(contentId);
- }
-
- dic[channelId] = contentIdList;
- }
- }
- else
- {
- var channelId = TranslateUtils.ToInt(queryString["channelId"]);
- dic[channelId] = TranslateUtils.StringCollectionToIntList(queryString["contentIdCollection"]);
- }
-
- return dic;
- }
-
- public static Dictionary ContentToDictionary(ContentInfo contentInfo, string tableName, List relatedIdentities)
- {
- var dict = TranslateUtils.ObjectToDictionary(contentInfo);
- dict.Remove("Attributes");
-
- var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, relatedIdentities);
- foreach (var styleInfo in styleInfoList)
- {
- if (!dict.ContainsKey(styleInfo.AttributeName))
- {
- dict[styleInfo.AttributeName] = contentInfo.GetString(styleInfo.AttributeName);
- }
- if (styleInfo.InputType == InputType.Image)
- {
- var extendName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
- var extendValue = contentInfo.GetString(extendName);
- if (!string.IsNullOrEmpty(extendValue))
- {
- dict[extendName] = extendValue;
- }
- }
- }
-
- return dict;
- }
-
- public static string GetTitleHtml(string titleFormat, string titleAjaxUrl)
- {
- var builder = new StringBuilder();
- var formatStrong = false;
- var formatEm = false;
- var formatU = false;
- var formatColor = string.Empty;
- if (titleFormat != null)
- {
- SetTitleFormatControls(titleFormat, out formatStrong, out formatEm, out formatU, out formatColor);
- }
-
- builder.Append(
- $@"
-
-");
-
- builder.Append($@"
-
- 粗体
- 斜体
- 下划线
- 颜色
-
-
-
- 确定
-
-
-
-
-");
-
- builder.Append(@"
-
-
");
- builder.Replace("[url]", titleAjaxUrl);
-
- return builder.ToString();
- }
-
- public static string GetTagsHtml(string tagsAjaxUrl)
- {
- const string tagScript = @"
-
-
-";
- return tagScript.Replace("[url]", tagsAjaxUrl);
- }
- }
-}
diff --git a/SiteServer.CMS/Core/Converter.cs b/SiteServer.CMS/Core/Converter.cs
deleted file mode 100644
index 1787472bf..000000000
--- a/SiteServer.CMS/Core/Converter.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using System.Web.UI.WebControls;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Core
-{
- ///
- /// Convert ժҪ˵
- ///
- public static class Converter
- {
- ///
- /// 2004-1-202005-9-3 12:12:32ΪʽַתΪ
- ///
- public static DateTime ToDateTime(string dateTimeString)
- {
- if (string.IsNullOrEmpty(dateTimeString))
- {
- return DateTime.Now;
- }
- var dateTimeStr = dateTimeString.Trim();
-
- var year = DateTime.Now.Year;
- var month = DateTime.Now.Month;
- var day = DateTime.Now.Day;
- var hour = DateTime.Now.Hour;
- var minute = DateTime.Now.Minute;
- var second = DateTime.Now.Second;
-
- if (dateTimeStr.IndexOf(" ", StringComparison.Ordinal) != -1)
- {
- var dateAndTimeArray = dateTimeStr.Split(' ');
- if (dateAndTimeArray.Length == 2)
- {
- try
- {
- var arrayDate = dateAndTimeArray[0].Split('-');
- year = int.Parse(arrayDate[0]);
- month = int.Parse(arrayDate[1]);
- day = int.Parse(arrayDate[2]);
-
- var arrayTime = dateAndTimeArray[1].Split(':');
- hour = int.Parse(arrayTime[0]);
- minute = int.Parse(arrayTime[1]);
- second = int.Parse(arrayTime[2]);
- }
- catch
- {
- // ignored
- }
- }
- }
- else
- {
- var array = dateTimeStr.Split('-');
- if (array.Length == 3)
- {
- try
- {
- year = int.Parse(array[0]);
- month = int.Parse(array[1]);
- day = int.Parse(array[2]);
- }
- catch
- {
- // ignored
- }
- }
- }
-
- var dateTime = new DateTime(year, month, day, hour, minute, second);
- return dateTime;
- }
-
- public static HorizontalAlign ToHorizontalAlign(string typeStr)
- {
- return (HorizontalAlign)TranslateUtils.ToEnum(typeof(HorizontalAlign), typeStr, HorizontalAlign.Left);
- }
-
- public static VerticalAlign ToVerticalAlign(string typeStr)
- {
- return (VerticalAlign)TranslateUtils.ToEnum(typeof(VerticalAlign), typeStr, VerticalAlign.Middle);
- }
-
- public static GridLines ToGridLines(string typeStr)
- {
- return (GridLines)TranslateUtils.ToEnum(typeof(GridLines), typeStr, GridLines.None);
- }
-
- public static RepeatDirection ToRepeatDirection(string typeStr)
- {
- return (RepeatDirection)TranslateUtils.ToEnum(typeof(RepeatDirection), typeStr, RepeatDirection.Vertical);
- }
-
- public static RepeatLayout ToRepeatLayout(string typeStr)
- {
- return (RepeatLayout)TranslateUtils.ToEnum(typeof(RepeatLayout), typeStr, RepeatLayout.Table);
- }
-
- public static ContentInfo ToContentInfo(NameValueCollection collection, NameValueCollection columnsMap)
- {
- if (collection == null || columnsMap == null) return null;
-
- var contentInfo = new ContentInfo();
- foreach (string attributeName in collection.Keys)
- {
- if (columnsMap[attributeName] != null)
- {
- var columnsToMatch = columnsMap[attributeName];
- contentInfo.Set(columnsToMatch, collection[attributeName]);
- }
- }
- return contentInfo;
- }
-
- }
-}
diff --git a/SiteServer.CMS/Core/CountManager.cs b/SiteServer.CMS/Core/CountManager.cs
deleted file mode 100644
index 1f91e1a21..000000000
--- a/SiteServer.CMS/Core/CountManager.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class CountManager
- {
- private CountManager()
- {
- }
-
- public static void AddCount(string relatedTableName, string relatedIdentity, ECountType countType)
- {
- if (DataProvider.CountDao.IsExists(relatedTableName, relatedIdentity, countType))
- {
- DataProvider.CountDao.AddCountNum(relatedTableName, relatedIdentity, countType);
- }
- else
- {
- DataProvider.CountDao.Insert(relatedTableName, relatedIdentity, countType, 1);
- }
- }
-
- public static void DeleteByRelatedTableName(string relatedTableName)
- {
- DataProvider.CountDao.DeleteByRelatedTableName(relatedTableName);
- }
-
- public static void DeleteByIdentity(string relatedTableName, string relatedIdentity)
- {
- DataProvider.CountDao.DeleteByIdentity(relatedTableName, relatedIdentity);
- }
-
- public static int GetCount(string relatedTableName, string relatedIdentity, ECountType countType)
- {
- return DataProvider.CountDao.GetCountNum(relatedTableName, relatedIdentity, countType);
- }
-
- public static int GetCount(string relatedTableName, int siteId, ECountType countType)
- {
- return DataProvider.CountDao.GetCountNum(relatedTableName, siteId, countType);
- }
- }
-}
diff --git a/SiteServer.CMS/Core/Create/CreateManager.cs b/SiteServer.CMS/Core/Create/CreateManager.cs
deleted file mode 100644
index c0cca4550..000000000
--- a/SiteServer.CMS/Core/Create/CreateManager.cs
+++ /dev/null
@@ -1,152 +0,0 @@
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.CMS.Core.Create
-{
- public class CreateManager
- {
- public static string GetTaskName(ECreateType createType, int siteId, int channelId, int contentId,
- int templateId, out int pageCount)
- {
- pageCount = 0;
- var name = string.Empty;
- if (createType == ECreateType.Channel)
- {
- name = channelId == siteId ? "首页" : ChannelManager.GetChannelName(siteId, channelId);
- if (!string.IsNullOrEmpty(name))
- {
- pageCount = 1;
- }
- }
- else if (createType == ECreateType.AllContent)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(siteId, channelId);
- if (nodeInfo != null && nodeInfo.ContentNum > 0)
- {
- pageCount = nodeInfo.ContentNum;
- name = $"{nodeInfo.ChannelName}下所有内容页,共{pageCount}项";
- }
- }
- else if (createType == ECreateType.Content)
- {
- name =
- DataProvider.ContentDao.GetValue(
- ChannelManager.GetTableName(
- SiteManager.GetSiteInfo(siteId), channelId),
- contentId, ContentAttribute.Title);
- if (!string.IsNullOrEmpty(name))
- {
- pageCount = 1;
- }
- }
- else if (createType == ECreateType.File)
- {
- name = TemplateManager.GetTemplateName(siteId, templateId);
- if (!string.IsNullOrEmpty(name))
- {
- pageCount = 1;
- }
- }
- return name;
- }
-
- public static void CreateChannel(int siteId, int channelId)
- {
- if (siteId <= 0 || channelId <= 0) return;
-
- int pageCount;
- var taskName = GetTaskName(ECreateType.Channel, siteId, channelId, 0, 0, out pageCount);
- if (pageCount == 0) return;
-
- var taskInfo = new CreateTaskInfo(0, taskName, ECreateType.Channel, siteId, channelId, 0, 0, pageCount);
- CreateTaskManager.Instance.AddPendingTask(taskInfo);
- }
-
- public static void CreateContent(int siteId, int channelId, int contentId)
- {
- if (siteId <= 0 || channelId <= 0 || contentId <= 0) return;
-
- int pageCount;
- var taskName = GetTaskName(ECreateType.Content, siteId, channelId, contentId, 0, out pageCount);
- if (pageCount == 0) return;
-
- var taskInfo = new CreateTaskInfo(0, taskName, ECreateType.Content, siteId, channelId, contentId, 0, pageCount);
- CreateTaskManager.Instance.AddPendingTask(taskInfo);
- }
-
- public static void CreateAllContent(int siteId, int channelId)
- {
- if (siteId <= 0 || channelId <= 0) return;
-
- int pageCount;
- var taskName = GetTaskName(ECreateType.AllContent, siteId, channelId, 0, 0, out pageCount);
- if (pageCount == 0) return;
-
- var taskInfo = new CreateTaskInfo(0, taskName, ECreateType.AllContent, siteId, channelId, 0, 0, pageCount);
- CreateTaskManager.Instance.AddPendingTask(taskInfo);
- }
-
- public static void CreateFile(int siteId, int templateId)
- {
- if (siteId <= 0 || templateId <= 0) return;
-
- int pageCount;
- var taskName = GetTaskName(ECreateType.File, siteId, 0, 0, templateId, out pageCount);
- if (pageCount == 0) return;
-
- var taskInfo = new CreateTaskInfo(0, taskName, ECreateType.File, siteId, 0, 0, templateId, pageCount);
- CreateTaskManager.Instance.AddPendingTask(taskInfo);
- }
-
- public static void CreateAll(int siteId)
- {
- CreateTaskManager.Instance.ClearAllTask(siteId);
-
- var nodeInfoList = ChannelManager.GetChannelInfoList(siteId);
- foreach (var nodeInfo in nodeInfoList)
- {
- CreateChannel(siteId, nodeInfo.Id);
- CreateAllContent(siteId, nodeInfo.Id);
- }
-
- foreach (var templateId in TemplateManager.GetAllFileTemplateIdList(siteId))
- {
- CreateFile(siteId, templateId);
- }
- }
-
- public static void CreateContentTrigger(int siteId, int channelId)
- {
- if (channelId > 0)
- {
- ContentTrigger(siteId, channelId);
- }
- }
-
- public static void CreateContentAndTrigger(int siteId, int channelId, int contentId)
- {
- if (siteId <= 0 || channelId <= 0 || contentId <= 0) return;
-
- CreateContent(siteId, channelId, contentId);
-
- ContentTrigger(siteId, channelId);
- }
-
- private static void ContentTrigger(int siteId, int channelId)
- {
- if (siteId <= 0 || channelId <= 0) return;
-
- var nodeInfo = ChannelManager.GetChannelInfo(siteId, channelId);
- var channelIdList = TranslateUtils.StringCollectionToIntList(nodeInfo.Additional.CreateChannelIDsIfContentChanged);
- if (nodeInfo.Additional.IsCreateChannelIfContentChanged && !channelIdList.Contains(channelId))
- {
- channelIdList.Add(channelId);
- }
- foreach (var theChannelId in channelIdList)
- {
- CreateChannel(siteId, theChannelId);
- }
- }
- }
-}
diff --git a/SiteServer.CMS/Core/Create/CreateTaskManager.cs b/SiteServer.CMS/Core/Create/CreateTaskManager.cs
deleted file mode 100644
index 28e847dc6..000000000
--- a/SiteServer.CMS/Core/Create/CreateTaskManager.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.CMS.Core.Create
-{
- public class CreateTaskManager : ICreateTaskManager
- {
- private static readonly ConcurrentDictionary> PendingTaskDict = new ConcurrentDictionary>();
- private static readonly ConcurrentDictionary> ExecutingTaskDict = new ConcurrentDictionary>();
- private static readonly ConcurrentDictionary> TaskLogDict = new ConcurrentDictionary>();
- private static readonly object LockObject = new object();
-
- public static CreateTaskManager Instance { get; } = new CreateTaskManager();
-
- ///
- /// 获取某个站点的所有任务
- ///
- ///
- ///
- private static ConcurrentQueue GetPendingTasks(int siteId)
- {
- lock (LockObject)
- {
- if (!PendingTaskDict.ContainsKey(siteId))
- {
- PendingTaskDict.TryAdd(siteId, new ConcurrentQueue());
- }
- return PendingTaskDict[siteId];
- }
- }
-
- private static List GetExecutingTasks(int siteId)
- {
- lock (LockObject)
- {
- if (!ExecutingTaskDict.ContainsKey(siteId))
- {
- ExecutingTaskDict.TryAdd(siteId, new List());
- }
- return ExecutingTaskDict[siteId];
- }
- }
-
- private static List GetTaskLogs(int siteId)
- {
- lock (LockObject)
- {
- if (!TaskLogDict.ContainsKey(siteId))
- {
- TaskLogDict.TryAdd(siteId, new List());
- }
- return TaskLogDict[siteId];
- }
- }
-
- ///
- /// 添加一个任务
- ///
- ///
- public void AddPendingTask(CreateTaskInfo task)
- {
- var pendingTasks = GetPendingTasks(task.SiteId); // 查找某站点所有任务
- foreach (var taskInfo in pendingTasks)
- {
- if (task.Equals(taskInfo))
- {
- return;
- }
- }
- pendingTasks.Enqueue(task);
- }
-
- public int GetPendingTaskCount(int siteId)
- {
- var pendingTasks = GetPendingTasks(siteId);
- return pendingTasks.Count == 0 ? 0 : pendingTasks.Sum(taskInfo => taskInfo.PageCount);
- }
-
- public CreateTaskInfo GetAndRemoveLastPendingTask(int siteId)
- {
- lock (LockObject)
- {
- var pendingTasks = GetPendingTasks(siteId);
- CreateTaskInfo taskInfo;
- pendingTasks.TryDequeue(out taskInfo);
-
- if (taskInfo != null)
- {
- var executingTasks = GetExecutingTasks(siteId);
- executingTasks.Add(taskInfo);
- }
-
- return taskInfo;
- }
- }
-
- public void RemoveCurrent(int siteId, CreateTaskInfo taskInfo)
- {
- lock (LockObject)
- {
- var executingTasks = GetExecutingTasks(siteId);
- executingTasks.Remove(taskInfo);
- }
- }
-
- public void AddSuccessLog(CreateTaskInfo taskInfo, string timeSpan)
- {
- var taskLogs = GetTaskLogs(taskInfo.SiteId);
- var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.SiteId, taskInfo.ChannelId, taskInfo.ContentId, taskInfo.TemplateId, taskInfo.Name, timeSpan, true, string.Empty, DateTime.Now);
- if (taskLogs.Count > 20)
- {
- taskLogs.RemoveAt(20);
- }
- taskLogs.Add(taskLog);
- }
-
- public void AddFailureLog(CreateTaskInfo taskInfo, Exception ex)
- {
- var taskLogs = GetTaskLogs(taskInfo.SiteId);
- var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.SiteId, taskInfo.ChannelId, taskInfo.ContentId, taskInfo.TemplateId, taskInfo.Name, string.Empty, false, ex.Message, DateTime.Now);
- if (taskLogs.Count > 20)
- {
- taskLogs.RemoveAt(20);
- }
- taskLogs.Add(taskLog);
- }
-
- public void ClearAllTask()
- {
- foreach (var siteId in PendingTaskDict.Keys)
- {
- PendingTaskDict[siteId] = new ConcurrentQueue();
- }
- }
-
- public void ClearAllTask(int siteId)
- {
- PendingTaskDict[siteId] = new ConcurrentQueue();
- }
-
- public CreateTaskSummary GetTaskSummary(int siteId)
- {
- var executingTasks = GetExecutingTasks(siteId);
- var pendingTasks = GetPendingTasks(siteId);
- var taskLogs = GetTaskLogs(siteId);
-
- var list = new List();
-
- var channelsCount = 0;
- var contentsCount = 0;
- var filesCount = 0;
-
- foreach (var taskInfo in pendingTasks)
- {
- if (taskInfo.CreateType == ECreateType.Channel)
- {
- channelsCount += taskInfo.PageCount;
- }
- else if (taskInfo.CreateType == ECreateType.Content || taskInfo.CreateType == ECreateType.AllContent)
- {
- contentsCount += taskInfo.PageCount;
- }
- else if (taskInfo.CreateType == ECreateType.File)
- {
- filesCount += taskInfo.PageCount;
- }
- }
-
- if (executingTasks.Count > 0)
- {
- foreach (var taskInfo in executingTasks)
- {
- var summaryItem = new CreateTaskSummaryItem(taskInfo, string.Empty, true, false, false, string.Empty);
- list.Add(summaryItem);
- }
- }
-
- var count = pendingTasks.Count >= 10 ? 10 : pendingTasks.Count;
- if (count > 0)
- {
- var pendingTaskList = pendingTasks.ToList();
- for (var i = 0; i < count; i++)
- {
- var taskInfo = pendingTaskList[i];
- var summaryItem = new CreateTaskSummaryItem(taskInfo, string.Empty, false, true, false, string.Empty);
- list.Add(summaryItem);
- }
- }
-
- count = taskLogs.Count >= 20 ? 20 : taskLogs.Count;
- for (var i = 1; i <= count; i++)
- {
- var logInfo = taskLogs[taskLogs.Count - i];
- var summaryItem = new CreateTaskSummaryItem(logInfo);
- list.Add(summaryItem);
- }
-
- var summary = new CreateTaskSummary(list, channelsCount, contentsCount, filesCount);
-
- return summary;
- }
- }
-}
diff --git a/SiteServer.CMS/Core/Create/ICreateTaskManager.cs b/SiteServer.CMS/Core/Create/ICreateTaskManager.cs
deleted file mode 100644
index 46dc5374b..000000000
--- a/SiteServer.CMS/Core/Create/ICreateTaskManager.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.CMS.Core.Create
-{
- public interface ICreateTaskManager
- {
- void AddPendingTask(CreateTaskInfo task);
-
- int GetPendingTaskCount(int siteId);
-
- CreateTaskInfo GetAndRemoveLastPendingTask(int siteId);
-
- void RemoveCurrent(int siteId, CreateTaskInfo taskInfo);
-
- void AddSuccessLog(CreateTaskInfo taskInfo, string timeSpan);
-
- void AddFailureLog(CreateTaskInfo taskInfo, Exception ex);
-
- void ClearAllTask();
-
- void ClearAllTask(int siteId);
-
- CreateTaskSummary GetTaskSummary(int siteId);
- }
-}
diff --git a/SiteServer.CMS/Core/CrossSiteTransUtility.cs b/SiteServer.CMS/Core/CrossSiteTransUtility.cs
deleted file mode 100644
index caf50d154..000000000
--- a/SiteServer.CMS/Core/CrossSiteTransUtility.cs
+++ /dev/null
@@ -1,340 +0,0 @@
-using System.Collections.Generic;
-using System.Text;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class CrossSiteTransUtility
- {
- private CrossSiteTransUtility()
- {
- }
-
- public static bool IsCrossSiteTrans(SiteInfo siteInfo, ChannelInfo channelInfo)
- {
- var isCrossSiteTrans = false;
-
- if (channelInfo != null && channelInfo.Additional.TransType != ECrossSiteTransType.None)
- {
- var transType = channelInfo.Additional.TransType;
- if (transType != ECrossSiteTransType.None)
- {
- if (transType == ECrossSiteTransType.AllParentSite)
- {
- var parentSiteId = SiteManager.GetParentSiteId(siteInfo.Id);
- if (parentSiteId != 0)
- {
- isCrossSiteTrans = true;
- }
- }
- else if (transType == ECrossSiteTransType.SelfSite)
- {
- isCrossSiteTrans = true;
- }
- else if (transType == ECrossSiteTransType.AllSite)
- {
- isCrossSiteTrans = true;
- }
- else if (transType == ECrossSiteTransType.SpecifiedSite)
- {
- if (channelInfo.Additional.TransSiteId > 0)
- {
- var theSiteInfo = SiteManager.GetSiteInfo(channelInfo.Additional.TransSiteId);
- if (theSiteInfo != null)
- {
- isCrossSiteTrans = true;
- }
- }
- }
- else if (transType == ECrossSiteTransType.ParentSite)
- {
- var parentSiteId = SiteManager.GetParentSiteId(siteInfo.Id);
- if (parentSiteId != 0)
- {
- isCrossSiteTrans = true;
- }
- }
- }
- }
-
- return isCrossSiteTrans;
- }
-
- public static bool IsAutomatic(ChannelInfo channelInfo)
- {
- var isAutomatic = false;
-
- if (channelInfo != null)
- {
- if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite || channelInfo.Additional.TransType == ECrossSiteTransType.ParentSite || channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite)
- {
- isAutomatic = channelInfo.Additional.TransIsAutomatic;
- }
- }
-
- return isAutomatic;
- }
-
- public static void LoadSiteIdDropDownList(DropDownList siteIdDropDownList, SiteInfo siteInfo, int channelId)
- {
- siteIdDropDownList.Items.Clear();
-
- var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
- if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite || channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite || channelInfo.Additional.TransType == ECrossSiteTransType.ParentSite)
- {
- int theSiteId;
- if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite)
- {
- theSiteId = siteInfo.Id;
- }
- else if (channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite)
- {
- theSiteId = channelInfo.Additional.TransSiteId;
- }
- else
- {
- theSiteId = SiteManager.GetParentSiteId(siteInfo.Id);
- }
- if (theSiteId > 0)
- {
- var theSiteInfo = SiteManager.GetSiteInfo(theSiteId);
- if (theSiteInfo != null)
- {
- var listitem = new ListItem(theSiteInfo.SiteName, theSiteInfo.Id.ToString());
- siteIdDropDownList.Items.Add(listitem);
- }
- }
- }
- else if (channelInfo.Additional.TransType == ECrossSiteTransType.AllParentSite)
- {
- var siteIdList = SiteManager.GetSiteIdList();
-
- var allParentSiteIdList = new List();
- SiteManager.GetAllParentSiteIdList(allParentSiteIdList, siteIdList, siteInfo.Id);
-
- foreach (var psId in siteIdList)
- {
- if (psId == siteInfo.Id) continue;
- var psInfo = SiteManager.GetSiteInfo(psId);
- var show = psInfo.IsRoot || allParentSiteIdList.Contains(psInfo.Id);
- if (show)
- {
- var listitem = new ListItem(psInfo.SiteName, psId.ToString());
- if (psInfo.IsRoot) listitem.Selected = true;
- siteIdDropDownList.Items.Add(listitem);
- }
- }
- }
- else if (channelInfo.Additional.TransType == ECrossSiteTransType.AllSite)
- {
- var siteIdList = SiteManager.GetSiteIdList();
-
- foreach (var psId in siteIdList)
- {
- var psInfo = SiteManager.GetSiteInfo(psId);
- var listitem = new ListItem(psInfo.SiteName, psId.ToString());
- if (psInfo.IsRoot) listitem.Selected = true;
- siteIdDropDownList.Items.Add(listitem);
- }
- }
- }
-
- public static void LoadChannelIdListBox(ListBox channelIdListBox, SiteInfo siteInfo, int psId, ChannelInfo channelInfo, PermissionManager permissionManager)
- {
- channelIdListBox.Items.Clear();
-
- var isUseNodeNames = channelInfo.Additional.TransType == ECrossSiteTransType.AllParentSite || channelInfo.Additional.TransType == ECrossSiteTransType.AllSite;
-
- if (!isUseNodeNames)
- {
- var channelIdList = TranslateUtils.StringCollectionToIntList(channelInfo.Additional.TransChannelIds);
- foreach (var theChannelId in channelIdList)
- {
- var theNodeInfo = ChannelManager.GetChannelInfo(psId, theChannelId);
- if (theNodeInfo != null)
- {
- var listitem = new ListItem(theNodeInfo.ChannelName, theNodeInfo.Id.ToString());
- channelIdListBox.Items.Add(listitem);
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(channelInfo.Additional.TransChannelNames))
- {
- var nodeNameArrayList = TranslateUtils.StringCollectionToStringList(channelInfo.Additional.TransChannelNames);
- var channelIdList = ChannelManager.GetChannelIdList(psId);
- foreach (var nodeName in nodeNameArrayList)
- {
- foreach (var theChannelId in channelIdList)
- {
- var theNodeInfo = ChannelManager.GetChannelInfo(psId, theChannelId);
- if (theNodeInfo.ChannelName == nodeName)
- {
- var listitem = new ListItem(theNodeInfo.ChannelName, theNodeInfo.Id.ToString());
- channelIdListBox.Items.Add(listitem);
- break;
- }
- }
- }
- }
- else
- {
- ChannelManager.AddListItemsForAddContent(channelIdListBox.Items, SiteManager.GetSiteInfo(psId), false, permissionManager);
- }
- }
- }
-
- public static string GetDescription(int siteId, ChannelInfo channelInfo)
- {
- var results = string.Empty;
-
- if (channelInfo != null)
- {
- results = ECrossSiteTransTypeUtils.GetText(channelInfo.Additional.TransType);
-
- if (channelInfo.Additional.TransType == ECrossSiteTransType.AllParentSite || channelInfo.Additional.TransType == ECrossSiteTransType.AllSite)
- {
- if (!string.IsNullOrEmpty(channelInfo.Additional.TransChannelNames))
- {
- results += $"({channelInfo.Additional.TransChannelNames})";
- }
- }
- else if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite || channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite || channelInfo.Additional.TransType == ECrossSiteTransType.ParentSite)
- {
- SiteInfo siteInfo = null;
-
- if (channelInfo.Additional.TransType == ECrossSiteTransType.SelfSite)
- {
- siteInfo = SiteManager.GetSiteInfo(siteId);
- }
- else if (channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite)
- {
- siteInfo = SiteManager.GetSiteInfo(channelInfo.Additional.TransSiteId);
- }
- else
- {
- var parentSiteId = SiteManager.GetParentSiteId(siteId);
- if (parentSiteId != 0)
- {
- siteInfo = SiteManager.GetSiteInfo(parentSiteId);
- }
- }
-
- if (siteInfo != null && !string.IsNullOrEmpty(channelInfo.Additional.TransChannelIds))
- {
- var nodeNameBuilder = new StringBuilder();
- var channelIdArrayList = TranslateUtils.StringCollectionToIntList(channelInfo.Additional.TransChannelIds);
- foreach (int channelId in channelIdArrayList)
- {
- var theNodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
- if (theNodeInfo != null)
- {
- nodeNameBuilder.Append(theNodeInfo.ChannelName).Append(",");
- }
- }
- if (nodeNameBuilder.Length > 0)
- {
- nodeNameBuilder.Length--;
- results += $"({siteInfo.SiteName}:{nodeNameBuilder})";
- }
- }
- }
- }
- return results;
- }
-
- public static void TransContentInfo(SiteInfo siteInfo, ChannelInfo channelInfo, int contentId, SiteInfo targetSiteInfo, int targetChannelId)
- {
- var targetTableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelId);
-
- var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo);
- contentInfo.SiteId = targetSiteInfo.Id;
- contentInfo.SourceId = channelInfo.Id;
- contentInfo.ChannelId = targetChannelId;
- contentInfo.IsChecked = targetSiteInfo.Additional.IsCrossSiteTransChecked;
- contentInfo.CheckedLevel = 0;
-
- //复制
- if (Equals(channelInfo.Additional.TransDoneType, ETranslateContentType.Copy))
- {
- contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString());
- }
- //引用地址
- else if (Equals(channelInfo.Additional.TransDoneType, ETranslateContentType.Reference))
- {
- contentInfo.SiteId = targetSiteInfo.Id;
- contentInfo.SourceId = channelInfo.Id;
- contentInfo.ChannelId = targetChannelId;
- contentInfo.ReferenceId = contentId;
- contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString());
- }
- //引用内容
- else if (Equals(channelInfo.Additional.TransDoneType, ETranslateContentType.ReferenceContent))
- {
- contentInfo.SiteId = targetSiteInfo.Id;
- contentInfo.SourceId = channelInfo.Id;
- contentInfo.ChannelId = targetChannelId;
- contentInfo.ReferenceId = contentId;
- contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.ReferenceContent.ToString());
- }
-
- if (!string.IsNullOrEmpty(targetTableName))
- {
- DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo);
-
- #region 复制资源
- //资源:图片,文件,视频
- if (!string.IsNullOrEmpty(contentInfo.GetString(BackgroundContentAttribute.ImageUrl)))
- {
- //修改图片
- var sourceImageUrl = PathUtility.MapPath(siteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl));
- CopyReferenceFiles(targetSiteInfo, sourceImageUrl, siteInfo);
-
- }
- else if (!string.IsNullOrEmpty(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))))
- {
- var sourceImageUrls = TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)));
-
- foreach (string imageUrl in sourceImageUrls)
- {
- var sourceImageUrl = PathUtility.MapPath(siteInfo, imageUrl);
- CopyReferenceFiles(targetSiteInfo, sourceImageUrl, siteInfo);
- }
- }
- if (!string.IsNullOrEmpty(contentInfo.GetString(BackgroundContentAttribute.FileUrl)))
- {
- //修改附件
- var sourceFileUrl = PathUtility.MapPath(siteInfo, contentInfo.GetString(BackgroundContentAttribute.FileUrl));
- CopyReferenceFiles(targetSiteInfo, sourceFileUrl, siteInfo);
-
- }
- else if (!string.IsNullOrEmpty(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))))
- {
- var sourceFileUrls = TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)));
-
- foreach (string fileUrl in sourceFileUrls)
- {
- var sourceFileUrl = PathUtility.MapPath(siteInfo, fileUrl);
- CopyReferenceFiles(targetSiteInfo, sourceFileUrl, siteInfo);
- }
- }
- #endregion
- }
- }
-
- private static void CopyReferenceFiles(SiteInfo targetSiteInfo, string sourceUrl, SiteInfo sourceSiteInfo)
- {
- var targetUrl = StringUtils.ReplaceFirst(sourceSiteInfo.SiteDir, sourceUrl, targetSiteInfo.SiteDir);
- if (!FileUtils.IsFileExists(targetUrl))
- {
- FileUtils.CopyFile(sourceUrl, targetUrl, true);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Core/DataProvider.cs b/SiteServer.CMS/Core/DataProvider.cs
deleted file mode 100644
index b585c66ed..000000000
--- a/SiteServer.CMS/Core/DataProvider.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-using System.Collections.Generic;
-using SiteServer.CMS.Data;
-using SiteServer.CMS.Provider;
-using SiteServer.Plugin;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Core
-{
- public class DataProvider
- {
- private static IDataApi _dataApi;
- public static IDataApi DataApi
- {
- get
- {
- if (_dataApi != null) return _dataApi;
-
- if (WebConfigUtils.DatabaseType == DatabaseType.MySql)
- {
- _dataApi = new Data.MySql();
- }
- else if (WebConfigUtils.DatabaseType == DatabaseType.SqlServer)
- {
- _dataApi = new SqlServer();
- }
- else if (WebConfigUtils.DatabaseType == DatabaseType.PostgreSql)
- {
- _dataApi = new PostgreSql();
- }
- else if (WebConfigUtils.DatabaseType == DatabaseType.Oracle)
- {
- _dataApi = new Data.Oracle();
- }
-
- return _dataApi;
- }
- }
-
- private static AdministratorDao _administratorDao;
- public static AdministratorDao AdministratorDao => _administratorDao ?? (_administratorDao = new AdministratorDao());
-
- private static AdministratorsInRolesDao _administratorsInRolesDao;
- public static AdministratorsInRolesDao AdministratorsInRolesDao => _administratorsInRolesDao ?? (_administratorsInRolesDao = new AdministratorsInRolesDao());
-
- private static AreaDao _areaDao;
- public static AreaDao AreaDao => _areaDao ?? (_areaDao = new AreaDao());
-
- private static ChannelDao _channelDao;
- public static ChannelDao ChannelDao => _channelDao ?? (_channelDao = new ChannelDao());
-
- private static ChannelGroupDao _channelGroupDao;
- public static ChannelGroupDao ChannelGroupDao => _channelGroupDao ?? (_channelGroupDao = new ChannelGroupDao());
-
- private static ConfigDao _configDao;
- public static ConfigDao ConfigDao => _configDao ?? (_configDao = new ConfigDao());
-
- private static ContentCheckDao _contentCheckDao;
- public static ContentCheckDao ContentCheckDao => _contentCheckDao ?? (_contentCheckDao = new ContentCheckDao());
-
- private static ContentDao _contentDao;
- public static ContentDao ContentDao => _contentDao ?? (_contentDao = new ContentDao());
-
- private static ContentGroupDao _contentGroupDao;
- public static ContentGroupDao ContentGroupDao => _contentGroupDao ?? (_contentGroupDao = new ContentGroupDao());
-
- private static CountDao _countDao;
- internal static CountDao CountDao => _countDao ?? (_countDao = new CountDao());
-
- private static DatabaseDao _databaseDao;
- public static DatabaseDao DatabaseDao => _databaseDao ?? (_databaseDao = new DatabaseDao());
-
- private static DbCacheDao _dbCacheDao;
- internal static DbCacheDao DbCacheDao => _dbCacheDao ?? (_dbCacheDao = new DbCacheDao());
-
- private static DepartmentDao _departmentDao;
- public static DepartmentDao DepartmentDao => _departmentDao ?? (_departmentDao = new DepartmentDao());
-
- private static ErrorLogDao _errorLogDao;
- public static ErrorLogDao ErrorLogDao => _errorLogDao ?? (_errorLogDao = new ErrorLogDao());
-
- private static KeywordDao _keywordDao;
- public static KeywordDao KeywordDao => _keywordDao ?? (_keywordDao = new KeywordDao());
-
- private static LogDao _logDao;
- public static LogDao LogDao => _logDao ?? (_logDao = new LogDao());
-
- private static PermissionsInRolesDao _permissionsInRolesDao;
- public static PermissionsInRolesDao PermissionsInRolesDao => _permissionsInRolesDao ?? (_permissionsInRolesDao = new PermissionsInRolesDao());
-
- private static PluginConfigDao _pluginConfigDao;
- public static PluginConfigDao PluginConfigDao => _pluginConfigDao ?? (_pluginConfigDao = new PluginConfigDao());
-
- private static PluginDao _pluginDao;
- public static PluginDao PluginDao => _pluginDao ?? (_pluginDao = new PluginDao());
-
- private static SiteDao _siteDao;
- public static SiteDao SiteDao => _siteDao ?? (_siteDao = new SiteDao());
-
- private static SiteLogDao _siteLogDao;
- public static SiteLogDao SiteLogDao => _siteLogDao ?? (_siteLogDao = new SiteLogDao());
-
- private static RecordDao _recordDao;
- public static RecordDao RecordDao => _recordDao ?? (_recordDao = new RecordDao());
-
- private static RelatedFieldDao _relatedFieldDao;
- public static RelatedFieldDao RelatedFieldDao => _relatedFieldDao ?? (_relatedFieldDao = new RelatedFieldDao());
-
- private static RelatedFieldItemDao _relatedFieldItemDao;
- public static RelatedFieldItemDao RelatedFieldItemDao => _relatedFieldItemDao ?? (_relatedFieldItemDao = new RelatedFieldItemDao());
-
- private static RoleDao _roleDao;
- public static RoleDao RoleDao => _roleDao ?? (_roleDao = new RoleDao());
-
- private static SitePermissionsDao _sitePermissionsDao;
- public static SitePermissionsDao SitePermissionsDao => _sitePermissionsDao ?? (_sitePermissionsDao = new SitePermissionsDao());
-
- private static TableDao _tableDao;
- public static TableDao TableDao => _tableDao ?? (_tableDao = new TableDao());
-
- private static TableMatchDao _tableMatchDao;
- public static TableMatchDao TableMatchDao => _tableMatchDao ?? (_tableMatchDao = new TableMatchDao());
-
- private static TableMetadataDao _tableMetadataDao;
- public static TableMetadataDao TableMetadataDao => _tableMetadataDao ?? (_tableMetadataDao = new TableMetadataDao());
-
- private static TableStyleDao _tableStyleDao;
- public static TableStyleDao TableStyleDao => _tableStyleDao ?? (_tableStyleDao = new TableStyleDao());
-
- private static TableStyleItemDao _tableStyleItemDao;
- public static TableStyleItemDao TableStyleItemDao => _tableStyleItemDao ?? (_tableStyleItemDao = new TableStyleItemDao());
-
- private static TagDao _tagDao;
- public static TagDao TagDao => _tagDao ?? (_tagDao = new TagDao());
-
- private static TemplateDao _templateDao;
- public static TemplateDao TemplateDao => _templateDao ?? (_templateDao = new TemplateDao());
-
- private static TemplateLogDao _templateLogDao;
- public static TemplateLogDao TemplateLogDao => _templateLogDao ?? (_templateLogDao = new TemplateLogDao());
-
- private static TemplateMatchDao _templateMatchDao;
- public static TemplateMatchDao TemplateMatchDao => _templateMatchDao ?? (_templateMatchDao = new TemplateMatchDao());
-
- private static UserDao _userDao;
- public static UserDao UserDao => _userDao ?? (_userDao = new UserDao());
-
- private static UserLogDao _userLogDao;
- public static UserLogDao UserLogDao => _userLogDao ?? (_userLogDao = new UserLogDao());
-
- public static List AllProviders => new List
- {
- AdministratorDao,
- AdministratorsInRolesDao,
- AreaDao,
- ChannelDao,
- ChannelGroupDao,
- ConfigDao,
- ContentCheckDao,
- ContentDao,
- ContentGroupDao,
- CountDao,
- DatabaseDao,
- DbCacheDao,
- DepartmentDao,
- ErrorLogDao,
- KeywordDao,
- LogDao,
- PermissionsInRolesDao,
- PluginConfigDao,
- PluginDao,
- SiteDao,
- SiteLogDao,
- RecordDao,
- RelatedFieldDao,
- RelatedFieldItemDao,
- RoleDao,
- SitePermissionsDao,
- TableDao,
- TableMatchDao,
- TableMetadataDao,
- TableStyleDao,
- TableStyleItemDao,
- TagDao,
- TemplateDao,
- TemplateLogDao,
- TemplateMatchDao,
- UserDao,
- UserLogDao
- };
- }
-}
diff --git a/SiteServer.CMS/Core/DepartmentManager.cs b/SiteServer.CMS/Core/DepartmentManager.cs
deleted file mode 100644
index 508cae658..000000000
--- a/SiteServer.CMS/Core/DepartmentManager.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-using System.Collections.Generic;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Core
-{
- public class DepartmentManager
- {
- public static DepartmentInfo GetDepartmentInfo(int departmentId)
- {
- var pairList = GetDepartmentInfoKeyValuePair();
-
- foreach (var pair in pairList)
- {
- if (pair.Key == departmentId)
- {
- return pair.Value;
- }
- }
- return null;
- }
-
- public static string GetThisDepartmentName(int departmentId)
- {
- var departmentInfo = GetDepartmentInfo(departmentId);
- if (departmentInfo != null)
- {
- return departmentInfo.DepartmentName;
- }
- return string.Empty;
- }
-
- public static string GetDepartmentName(int departmentId)
- {
- if (departmentId <= 0) return string.Empty;
-
- var departmentNameList = new List();
-
- var parentsPath = GetParentsPath(departmentId);
- var departmentIdList = new List();
- if (!string.IsNullOrEmpty(parentsPath))
- {
- departmentIdList = TranslateUtils.StringCollectionToIntList(parentsPath);
- }
- departmentIdList.Add(departmentId);
-
- foreach (var theDepartmentId in departmentIdList)
- {
- var departmentInfo = GetDepartmentInfo(theDepartmentId);
- if (departmentInfo != null)
- {
- departmentNameList.Add(departmentInfo.DepartmentName);
- }
- }
-
- return TranslateUtils.ObjectCollectionToString(departmentNameList, " > ");
- }
-
- public static string GetDepartmentCode(int departmentId)
- {
- if (departmentId > 0)
- {
- var departmentInfo = GetDepartmentInfo(departmentId);
- if (departmentInfo != null)
- {
- return departmentInfo.Code;
- }
- }
- return string.Empty;
- }
-
- public static string GetParentsPath(int departmentId)
- {
- var retval = string.Empty;
- var departmentInfo = GetDepartmentInfo(departmentId);
- if (departmentInfo != null)
- {
- retval = departmentInfo.ParentsPath;
- }
- return retval;
- }
-
- public static List GetDepartmentIdList()
- {
- var pairList = GetDepartmentInfoKeyValuePair();
- var list = new List();
- foreach (var pair in pairList)
- {
- list.Add(pair.Key);
- }
- return list;
- }
-
- public static void ClearCache()
- {
- CacheUtils.Remove(CacheKey);
- }
-
- public static List> GetDepartmentInfoKeyValuePair()
- {
- lock (LockObject)
- {
- if (CacheUtils.Get(CacheKey) == null)
- {
- var list = DataProvider.DepartmentDao.GetDepartmentInfoKeyValuePair();
- CacheUtils.Insert(CacheKey, list);
- return list;
- }
- return CacheUtils.Get(CacheKey) as List>;
- }
- }
-
- /****************** Cache *********************/
-
- private static readonly object LockObject = new object();
- private const string CacheKey = "BaiRong.Core.DepartmentManager";
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Core/FileUtility.cs b/SiteServer.CMS/Core/FileUtility.cs
deleted file mode 100644
index 38ae88c17..000000000
--- a/SiteServer.CMS/Core/FileUtility.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using System;
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-using System.Collections.Generic;
-using SiteServer.Utils.Enumerations;
-using SiteServer.Utils.Images;
-
-namespace SiteServer.CMS.Core
-{
- public class FileUtility
- {
- private FileUtility()
- {
- }
-
- public static void AddWaterMark(SiteInfo siteInfo, string imagePath)
- {
- try
- {
- var fileExtName = PathUtils.GetExtension(imagePath);
- if (EFileSystemTypeUtils.IsImage(fileExtName))
- {
- if (siteInfo.Additional.IsWaterMark)
- {
- if (siteInfo.Additional.IsImageWaterMark)
- {
- if (!string.IsNullOrEmpty(siteInfo.Additional.WaterMarkImagePath))
- {
- ImageUtils.AddImageWaterMark(imagePath, PathUtility.MapPath(siteInfo, siteInfo.Additional.WaterMarkImagePath), siteInfo.Additional.WaterMarkPosition, siteInfo.Additional.WaterMarkTransparency, siteInfo.Additional.WaterMarkMinWidth, siteInfo.Additional.WaterMarkMinHeight);
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(siteInfo.Additional.WaterMarkFormatString))
- {
- var now = DateTime.Now;
- ImageUtils.AddTextWaterMark(imagePath, string.Format(siteInfo.Additional.WaterMarkFormatString, DateUtils.GetDateString(now), DateUtils.GetTimeString(now)), siteInfo.Additional.WaterMarkFontName, siteInfo.Additional.WaterMarkFontSize, siteInfo.Additional.WaterMarkPosition, siteInfo.Additional.WaterMarkTransparency, siteInfo.Additional.WaterMarkMinWidth, siteInfo.Additional.WaterMarkMinHeight);
- }
- }
- }
- }
- }
- catch
- {
- // ignored
- }
- }
-
- public static void MoveFile(SiteInfo sourceSiteInfo, SiteInfo destSiteInfo, string relatedUrl)
- {
- if (!string.IsNullOrEmpty(relatedUrl))
- {
- var sourceFilePath = PathUtility.MapPath(sourceSiteInfo, relatedUrl);
- var descFilePath = PathUtility.MapPath(destSiteInfo, relatedUrl);
- if (FileUtils.IsFileExists(sourceFilePath))
- {
- FileUtils.MoveFile(sourceFilePath, descFilePath, false);
- }
- }
- }
-
- public static void MoveFileByContentInfo(SiteInfo sourceSiteInfo, SiteInfo destSiteInfo, ContentInfo contentInfo)
- {
- if (contentInfo == null || sourceSiteInfo.Id == destSiteInfo.Id) return;
-
- try
- {
- var fileUrls = new List
- {
- contentInfo.GetString(BackgroundContentAttribute.ImageUrl),
- contentInfo.GetString(BackgroundContentAttribute.VideoUrl),
- contentInfo.GetString(BackgroundContentAttribute.FileUrl)
- };
-
- foreach (var url in TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl))))
- {
- if (!fileUrls.Contains(url))
- {
- fileUrls.Add(url);
- }
- }
- foreach (var url in TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl))))
- {
- if (!fileUrls.Contains(url))
- {
- fileUrls.Add(url);
- }
- }
- foreach (var url in TranslateUtils.StringCollectionToStringList(contentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl))))
- {
- if (!fileUrls.Contains(url))
- {
- fileUrls.Add(url);
- }
- }
- foreach (var url in RegexUtils.GetOriginalImageSrcs(contentInfo.GetString(BackgroundContentAttribute.Content)))
- {
- if (!fileUrls.Contains(url))
- {
- fileUrls.Add(url);
- }
- }
- foreach (var url in RegexUtils.GetOriginalLinkHrefs(contentInfo.GetString(BackgroundContentAttribute.Content)))
- {
- if (!fileUrls.Contains(url) && PageUtils.IsVirtualUrl(url))
- {
- fileUrls.Add(url);
- }
- }
-
- foreach (var fileUrl in fileUrls)
- {
- if (!string.IsNullOrEmpty(fileUrl) && PageUtility.IsVirtualUrl(fileUrl))
- {
- MoveFile(sourceSiteInfo, destSiteInfo, fileUrl);
- }
- }
- }
- catch
- {
- // ignored
- }
- }
-
- public static void MoveFileByVirtaulUrl(SiteInfo sourceSiteInfo, SiteInfo destSiteInfo, string fileVirtaulUrl)
- {
- if (string.IsNullOrEmpty(fileVirtaulUrl) || sourceSiteInfo.Id == destSiteInfo.Id) return;
-
- try
- {
- if (PageUtility.IsVirtualUrl(fileVirtaulUrl))
- {
- MoveFile(sourceSiteInfo, destSiteInfo, fileVirtaulUrl);
- }
- }
- catch
- {
- // ignored
- }
- }
- }
-}
diff --git a/SiteServer.CMS/Core/InputParserUtility.cs b/SiteServer.CMS/Core/InputParserUtility.cs
deleted file mode 100644
index c41fc89ac..000000000
--- a/SiteServer.CMS/Core/InputParserUtility.cs
+++ /dev/null
@@ -1,369 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using System.Web.UI.HtmlControls;
-using SiteServer.CMS.Api;
-using SiteServer.CMS.Api.Sys.Stl;
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Core
-{
- public class InputParserUtility
- {
- private InputParserUtility()
- {
- }
-
- public static string GetContentByTableStyle(string content, SiteInfo siteInfo, TableStyleInfo styleInfo)
- {
- if (!string.IsNullOrEmpty(content))
- {
- return GetContentByTableStyle(content, ",", siteInfo, styleInfo, string.Empty, null, string.Empty, false);
- }
- return string.Empty;
- }
-
- public static string GetContentByTableStyle(string content, string separator, SiteInfo siteInfo, TableStyleInfo styleInfo, string formatString, Dictionary attributes, string innerXml, bool isStlEntity)
- {
- var parsedContent = content;
-
- var inputType = styleInfo.InputType;
-
- if (inputType == InputType.Date)
- {
- var dateTime = TranslateUtils.ToDateTime(content);
- if (dateTime != DateUtils.SqlMinValue)
- {
- if (string.IsNullOrEmpty(formatString))
- {
- formatString = DateUtils.FormatStringDateOnly;
- }
- parsedContent = DateUtils.Format(dateTime, formatString);
- }
- else
- {
- parsedContent = string.Empty;
- }
- }
- else if (inputType == InputType.DateTime)
- {
- var dateTime = TranslateUtils.ToDateTime(content);
- if (dateTime != DateUtils.SqlMinValue)
- {
- if (string.IsNullOrEmpty(formatString))
- {
- formatString = DateUtils.FormatStringDateTime;
- }
- parsedContent = DateUtils.Format(dateTime, formatString);
- }
- else
- {
- parsedContent = string.Empty;
- }
- }
- else if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)//选择类型
- {
- var selectedTexts = new ArrayList();
- var selectedValues = TranslateUtils.StringCollectionToStringList(content);
- var styleItems = styleInfo.StyleItems ??
- DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id);
- foreach (var itemInfo in styleItems)
- {
- if (selectedValues.Contains(itemInfo.ItemValue))
- {
- selectedTexts.Add(isStlEntity ? itemInfo.ItemValue : itemInfo.ItemTitle);
- }
- }
- parsedContent = separator == null ? TranslateUtils.ObjectCollectionToString(selectedTexts) : TranslateUtils.ObjectCollectionToString(selectedTexts, separator);
- }
- //else if (styleInfo.InputType == InputType.TextArea)
- //{
- // parsedContent = StringUtils.ReplaceNewlineToBR(parsedContent);
- //}
- else if (inputType == InputType.TextEditor)
- {
- parsedContent = ContentUtility.TextEditorContentDecode(siteInfo, parsedContent, true);
- }
- else if (inputType == InputType.Image)
- {
- parsedContent = GetImageOrFlashHtml(siteInfo, parsedContent, attributes, isStlEntity);
- }
- else if (inputType == InputType.Video)
- {
- parsedContent = GetVideoHtml(siteInfo, parsedContent, attributes, isStlEntity);
- }
- else if (inputType == InputType.File)
- {
- parsedContent = GetFileHtmlWithoutCount(siteInfo, parsedContent, attributes, innerXml, isStlEntity);
- }
-
- return parsedContent;
- }
-
- public static string GetContentByTableStyle(ContentInfo contentInfo, string separator, SiteInfo siteInfo, TableStyleInfo styleInfo, string formatString, int no, Dictionary attributes, string innerXml, bool isStlEntity)
- {
- var value = contentInfo.GetString(styleInfo.AttributeName);
- var parsedContent = string.Empty;
-
- var inputType = styleInfo.InputType;
-
- if (inputType == InputType.Date)
- {
- var dateTime = TranslateUtils.ToDateTime(value);
- if (dateTime != DateUtils.SqlMinValue)
- {
- if (string.IsNullOrEmpty(formatString))
- {
- formatString = DateUtils.FormatStringDateOnly;
- }
- parsedContent = DateUtils.Format(dateTime, formatString);
- }
- }
- else if (inputType == InputType.DateTime)
- {
- var dateTime = TranslateUtils.ToDateTime(value);
- if (dateTime != DateUtils.SqlMinValue)
- {
- if (string.IsNullOrEmpty(formatString))
- {
- formatString = DateUtils.FormatStringDateTime;
- }
- parsedContent = DateUtils.Format(dateTime, formatString);
- }
- }
- else if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)//选择类型
- {
- var selectedTexts = new ArrayList();
- var selectedValues = TranslateUtils.StringCollectionToStringList(value);
- var styleItems = styleInfo.StyleItems ??
- DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id);
- foreach (var itemInfo in styleItems)
- {
- if (selectedValues.Contains(itemInfo.ItemValue))
- {
- selectedTexts.Add(isStlEntity ? itemInfo.ItemValue : itemInfo.ItemTitle);
- }
- }
- parsedContent = separator == null ? TranslateUtils.ObjectCollectionToString(selectedTexts) : TranslateUtils.ObjectCollectionToString(selectedTexts, separator);
- }
- else if (inputType == InputType.TextEditor)
- {
- parsedContent = ContentUtility.TextEditorContentDecode(siteInfo, value, true);
- }
- else if (inputType == InputType.Image)
- {
- if (no <= 1)
- {
- parsedContent = GetImageOrFlashHtml(siteInfo, value, attributes, isStlEntity);
- }
- else
- {
- var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
- var extendValues = contentInfo.GetString(extendAttributeName);
- if (!string.IsNullOrEmpty(extendValues))
- {
- var index = 2;
- foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
- {
- if (index == no)
- {
- parsedContent = GetImageOrFlashHtml(siteInfo, extendValue, attributes, isStlEntity);
- break;
- }
- index++;
- }
- }
- }
- }
- else if (inputType == InputType.Video)
- {
- if (no <= 1)
- {
- parsedContent = GetVideoHtml(siteInfo, value, attributes, isStlEntity);
- }
- else
- {
- var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
- var extendValues = contentInfo.GetString(extendAttributeName);
- if (!string.IsNullOrEmpty(extendValues))
- {
- var index = 2;
- foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
- {
- if (index == no)
- {
- parsedContent = GetVideoHtml(siteInfo, extendValue, attributes, isStlEntity);
- break;
- }
- index++;
- }
- }
- }
- }
- else if (inputType == InputType.File)
- {
- if (no <= 1)
- {
- parsedContent = GetFileHtmlWithoutCount(siteInfo, value, attributes, innerXml, isStlEntity);
- }
- else
- {
- var extendAttributeName = ContentAttribute.GetExtendAttributeName(styleInfo.AttributeName);
- var extendValues = contentInfo.GetString(extendAttributeName);
- if (!string.IsNullOrEmpty(extendValues))
- {
- var index = 2;
- foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
- {
- if (index == no)
- {
- parsedContent = GetFileHtmlWithoutCount(siteInfo, extendValue, attributes, innerXml, isStlEntity);
- break;
- }
- index++;
- }
- }
- }
- }
- else
- {
- parsedContent = value;
- }
-
- return parsedContent;
- }
-
- public static string GetImageOrFlashHtml(SiteInfo siteInfo, string imageUrl, Dictionary attributes, bool isStlEntity)
- {
- var retval = string.Empty;
- if (!string.IsNullOrEmpty(imageUrl))
- {
- imageUrl = PageUtility.ParseNavigationUrl(siteInfo, imageUrl, false);
- if (isStlEntity)
- {
- retval = imageUrl;
- }
- else
- {
- if (!imageUrl.ToUpper().Trim().EndsWith(".SWF"))
- {
- var htmlImage = new HtmlImage();
- ControlUtils.AddAttributesIfNotExists(htmlImage, attributes);
- htmlImage.Src = imageUrl;
- retval = ControlUtils.GetControlRenderHtml(htmlImage);
- }
- else
- {
- var width = 100;
- var height = 100;
- if (attributes != null)
- {
- if (!string.IsNullOrEmpty(attributes["width"]))
- {
- try
- {
- width = int.Parse(attributes["width"]);
- }
- catch
- {
- // ignored
- }
- }
- if (!string.IsNullOrEmpty(attributes["height"]))
- {
- try
- {
- height = int.Parse(attributes["height"]);
- }
- catch
- {
- // ignored
- }
- }
- }
- retval = $@"
-
-
-
-
-
-";
- }
- }
- }
- return retval;
- }
-
- public static string GetVideoHtml(SiteInfo siteInfo, string videoUrl, Dictionary attributes, bool isStlEntity)
- {
- var retval = string.Empty;
- if (!string.IsNullOrEmpty(videoUrl))
- {
- videoUrl = PageUtility.ParseNavigationUrl(siteInfo, videoUrl, false);
- if (isStlEntity)
- {
- retval = videoUrl;
- }
- else
- {
- retval = $@"
-
-";
- }
- }
- return retval;
- }
-
- public static string GetFileHtmlWithCount(SiteInfo siteInfo, int channelId, int contentId, string fileUrl, Dictionary attributes, string innerXml, bool isStlEntity)
- {
- var retval = string.Empty;
- if (!string.IsNullOrEmpty(fileUrl))
- {
- if (isStlEntity)
- {
- retval = ApiRouteActionsDownload.GetUrl(ApiManager.OuterApiUrl, siteInfo.Id, channelId, contentId, fileUrl);
- }
- else
- {
- var stlAnchor = new HtmlAnchor();
- ControlUtils.AddAttributesIfNotExists(stlAnchor, attributes);
- stlAnchor.HRef = ApiRouteActionsDownload.GetUrl(ApiManager.OuterApiUrl, siteInfo.Id, channelId, contentId, fileUrl);
- stlAnchor.InnerHtml = string.IsNullOrEmpty(innerXml) ? PageUtils.GetFileNameFromUrl(fileUrl) : innerXml;
-
- retval = ControlUtils.GetControlRenderHtml(stlAnchor);
- }
- }
- return retval;
- }
-
- public static string GetFileHtmlWithoutCount(SiteInfo siteInfo, string fileUrl, Dictionary attributes, string innerXml, bool isStlEntity)
- {
- if (siteInfo != null)
- {
- var retval = string.Empty;
- if (!string.IsNullOrEmpty(fileUrl))
- {
- if (isStlEntity)
- {
- retval = ApiRouteActionsDownload.GetUrl(ApiManager.OuterApiUrl, siteInfo.Id, fileUrl);
- }
- else
- {
- var stlAnchor = new HtmlAnchor();
- ControlUtils.AddAttributesIfNotExists(stlAnchor, attributes);
- stlAnchor.HRef = ApiRouteActionsDownload.GetUrl(ApiManager.OuterApiUrl, siteInfo.Id, fileUrl);
- stlAnchor.InnerHtml = string.IsNullOrEmpty(innerXml) ? PageUtils.GetFileNameFromUrl(fileUrl) : innerXml;
-
- retval = ControlUtils.GetControlRenderHtml(stlAnchor);
- }
- }
- return retval;
- }
- return string.Empty;
- }
-
-
- }
-}
diff --git a/SiteServer.CMS/Core/LogUtils.cs b/SiteServer.CMS/Core/LogUtils.cs
deleted file mode 100644
index b6057558c..000000000
--- a/SiteServer.CMS/Core/LogUtils.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using System;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Core
-{
- public class LogUtils
- {
- private static int AddErrorLog(ErrorLogInfo logInfo)
- {
- if (!ConfigManager.SystemConfigInfo.IsLogError) return 0;
-
- try
- {
- if (ConfigManager.SystemConfigInfo.IsTimeThreshold)
- {
- DataProvider.ErrorLogDao.Delete(ConfigManager.SystemConfigInfo.TimeThreshold);
- }
-
- return DataProvider.ErrorLogDao.Insert(logInfo);
- }
- catch
- {
- // ignored
- }
-
- return 0;
- }
-
- public static void AddErrorLogAndRedirect(Exception ex, string summary = "")
- {
- if (ex.HResult == -2147467259) // 文件名不存在
- {
- PageUtils.RedirectToErrorPage(ex.Message);
- }
- else
- {
- var logId = AddErrorLog(ex, summary);
- if (logId > 0)
- {
- PageUtils.RedirectToErrorPage(logId);
- }
- else
- {
- PageUtils.RedirectToErrorPage(ex.Message);
- }
- }
- }
-
- public static int AddErrorLog(Exception ex, string summary = "")
- {
- return AddErrorLog(new ErrorLogInfo(0, string.Empty, ex.Message, ex.StackTrace, summary, DateTime.Now));
- }
-
- public static int AddErrorLog(string pluginId, Exception ex, string summary = "")
- {
- return AddErrorLog(new ErrorLogInfo(0, pluginId, ex.Message, ex.StackTrace, summary, DateTime.Now));
- }
-
- public static void AddAdminLog(string userName, string action, string summary = "")
- {
- if (!ConfigManager.SystemConfigInfo.IsLogAdmin) return;
-
- try
- {
- if (ConfigManager.SystemConfigInfo.IsTimeThreshold)
- {
- DataProvider.LogDao.Delete(ConfigManager.SystemConfigInfo.TimeThreshold);
- }
-
- if (!string.IsNullOrEmpty(action))
- {
- action = StringUtils.MaxLengthText(action, 250);
- }
- if (!string.IsNullOrEmpty(summary))
- {
- summary = StringUtils.MaxLengthText(summary, 250);
- }
- var logInfo = new LogInfo(0, userName, PageUtils.GetIpAddress(), DateTime.Now, action, summary);
-
- DataProvider.LogDao.Insert(logInfo);
- }
- catch (Exception ex)
- {
- AddErrorLog(ex);
- }
- }
-
- public static void AddUserLoginLog(string userName)
- {
- AddUserLog(userName, "用户登录", string.Empty);
- }
-
- public static void AddUserLog(string userName, string actionType, string summary)
- {
- if (!ConfigManager.SystemConfigInfo.IsLogUser) return;
-
- try
- {
- if (ConfigManager.SystemConfigInfo.IsTimeThreshold)
- {
- DataProvider.UserLogDao.Delete(ConfigManager.SystemConfigInfo.TimeThreshold);
- }
-
- if (!string.IsNullOrEmpty(summary))
- {
- summary = StringUtils.MaxLengthText(summary, 250);
- }
- DataProvider.UserLogDao.Insert(new UserLogInfo(0, userName, PageUtils.GetIpAddress(), DateTime.Now, actionType, summary));
- }
- catch (Exception ex)
- {
- AddErrorLog(ex);
- }
- }
- }
-}
diff --git a/SiteServer.CMS/Core/Office/AccessDao.cs b/SiteServer.CMS/Core/Office/AccessDao.cs
deleted file mode 100644
index 9d0b869a0..000000000
--- a/SiteServer.CMS/Core/Office/AccessDao.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-using System.Data;
-using System.Data.OleDb;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core.Office
-{
- public class AccessDao
- {
- private readonly OleDbConnection _connection;
-
- public AccessDao(string filePath)
- {
- ConnectionString = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={filePath};User Id=;Password=;";
- _connection = new OleDbConnection(ConnectionString);
- }
-
- public string ConnectionString { get; }
-
- public string GetCreateTableSqlString(string nodeName, List tableStyleInfoList, List displayAttributes)
- {
- var createBuilder = new StringBuilder();
- createBuilder.Append($"CREATE TABLE {nodeName} ( ");
-
- foreach (var tableStyleInfo in tableStyleInfoList)
- {
- if (displayAttributes.Contains(tableStyleInfo.AttributeName))
- {
- createBuilder.Append($" [{tableStyleInfo.DisplayName}] memo, ");
- }
- }
-
- createBuilder.Length = createBuilder.Length - 2;
- createBuilder.Append(" )");
-
- return createBuilder.ToString();
- }
-
- public ArrayList GetInsertSqlStringArrayList(string nodeName, int siteId, int channelId, string tableName, List styleInfoList, List displayAttributes, List contentIdList, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState, out bool isExport)
- {
- var insertSqlArrayList = new ArrayList();
-
- var preInsertBuilder = new StringBuilder();
- preInsertBuilder.Append($"INSERT INTO {nodeName} (");
-
- foreach (var tableStyleInfo in styleInfoList)
- {
- if (displayAttributes.Contains(tableStyleInfo.AttributeName))
- {
- preInsertBuilder.Append($"[{tableStyleInfo.DisplayName}], ");
- }
- }
-
- preInsertBuilder.Length = preInsertBuilder.Length - 2;
- preInsertBuilder.Append(") VALUES (");
-
- if (contentIdList == null || contentIdList.Count == 0)
- {
- contentIdList = DataProvider.ContentDao.GetContentIdList(tableName, channelId, isPeriods, dateFrom, dateTo, checkedState);
- }
-
- isExport = contentIdList.Count > 0;
-
- foreach (var contentId in contentIdList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- if (contentInfo != null)
- {
- var insertBuilder = new StringBuilder();
- insertBuilder.Append(preInsertBuilder);
-
- foreach (var tableStyleInfo in styleInfoList)
- {
- if (displayAttributes.Contains(tableStyleInfo.AttributeName))
- {
- var value = contentInfo.GetString(tableStyleInfo.AttributeName);
- insertBuilder.Append($"'{SqlUtils.ToSqlString(StringUtils.StripTags(value))}', ");
- }
- }
-
- insertBuilder.Length = insertBuilder.Length - 2;
- insertBuilder.Append(") ");
-
- insertSqlArrayList.Add(insertBuilder.ToString());
- }
- }
- return insertSqlArrayList;
- }
-
- public bool ExecuteSqlString(string sqlString)
- {
- bool resultState;
- OleDbTransaction myTrans = null;
-
- try
- {
- _connection.Open();
- myTrans = _connection.BeginTransaction();
- var command = new OleDbCommand(sqlString, _connection, myTrans);
- command.ExecuteNonQuery();
- myTrans.Commit();
- resultState = true;
- }
- catch
- {
- myTrans?.Rollback();
- resultState = false;
- }
- finally
- {
- _connection.Close();
- }
-
- return resultState;
- }
-
- public DataSet ReturnDataSet(string strSql)
- {
- var dataSet = new DataSet();
- try
- {
- _connection.Open();
- var oleDbDa = new OleDbDataAdapter(strSql, _connection);
- oleDbDa.Fill(dataSet, "objDataSet");
- }
- finally
- {
- _connection.Close();
- }
- return dataSet;
- }
-
- public string[] GetTableNames()
- {
- try
- {
- _connection.Open();
- var shemaTable = _connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
- var n = shemaTable.Rows.Count;
- var strTable = new string[n];
- var m = shemaTable.Columns.IndexOf("TABLE_NAME");
- for (var i = 0; i < n; i++)
- {
- var m_DataRow = shemaTable.Rows[i];
- strTable[i] = m_DataRow.ItemArray.GetValue(m).ToString();
- }
- return strTable;
- }
- finally
- {
- _connection.Close();
- }
- }
- }
-
-}
diff --git a/SiteServer.CMS/Core/Office/AccessObject.cs b/SiteServer.CMS/Core/Office/AccessObject.cs
deleted file mode 100644
index ad6e684fd..000000000
--- a/SiteServer.CMS/Core/Office/AccessObject.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-using System.Collections;
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Collections.Specialized;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core.Office
-{
- public class AccessObject
- {
- public static bool CreateAccessFileForContents(string filePath, SiteInfo siteInfo, ChannelInfo nodeInfo, List contentIdList, List displayAttributes, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState)
- {
- DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));
- FileUtils.DeleteFileIfExists(filePath);
-
- var sourceFilePath = SiteServerAssets.GetPath(SiteServerAssets.Default.AccessMdb);
- FileUtils.CopyFile(sourceFilePath, filePath);
-
- var relatedidentityes = RelatedIdentities.GetChannelRelatedIdentities(siteInfo.Id, nodeInfo.Id);
-
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- var styleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, relatedidentityes);
- styleInfoList = ContentUtility.GetAllTableStyleInfoList(styleInfoList);
-
- var accessDao = new AccessDao(filePath);
-
- var createTableSqlString = accessDao.GetCreateTableSqlString(nodeInfo.ChannelName, styleInfoList, displayAttributes);
- accessDao.ExecuteSqlString(createTableSqlString);
-
- bool isExport;
-
- var insertSqlArrayList = accessDao.GetInsertSqlStringArrayList(nodeInfo.ChannelName, siteInfo.Id, nodeInfo.Id, tableName, styleInfoList, displayAttributes, contentIdList, isPeriods, dateFrom, dateTo, checkedState, out isExport);
-
- foreach (string insertSql in insertSqlArrayList)
- {
- accessDao.ExecuteSqlString(insertSql);
- }
-
- return isExport;
- }
-
- public static List GetContentsByAccessFile(string filePath, SiteInfo siteInfo, ChannelInfo nodeInfo)
- {
- var contentInfoList = new List();
-
- var accessDao = new AccessDao(filePath);
- var tableNames = accessDao.GetTableNames();
- if (tableNames != null && tableNames.Length > 0)
- {
- foreach (var tableName in tableNames)
- {
- string sqlString = $"SELECT * FROM [{tableName}]";
- var dataset = accessDao.ReturnDataSet(sqlString);
-
- var oleDt = dataset.Tables[0];
-
- if (oleDt.Rows.Count > 0)
- {
- var relatedidentityes = RelatedIdentities.GetChannelRelatedIdentities(siteInfo.Id, nodeInfo.Id);
-
- var theTableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
-
- var tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(theTableName, relatedidentityes);
-
- var nameValueCollection = new NameValueCollection();
-
- foreach (var styleInfo in tableStyleInfoList)
- {
- nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower();
- }
-
- var attributeNames = new ArrayList();
- for (var i = 0; i < oleDt.Columns.Count; i++)
- {
- var columnName = oleDt.Columns[i].ColumnName;
- attributeNames.Add(!string.IsNullOrEmpty(nameValueCollection[columnName])
- ? nameValueCollection[columnName]
- : columnName);
- }
-
- foreach (DataRow row in oleDt.Rows)
- {
- var contentInfo = new ContentInfo();
-
- for (var i = 0; i < oleDt.Columns.Count; i++)
- {
- var attributeName = attributeNames[i] as string;
- if (!string.IsNullOrEmpty(attributeName))
- {
- var value = row[i].ToString();
- contentInfo.Set(attributeName, value);
- }
- }
-
- if (!string.IsNullOrEmpty(contentInfo.Title))
- {
- contentInfo.SiteId = siteInfo.Id;
- contentInfo.ChannelId = nodeInfo.Id;
- contentInfo.LastEditDate = DateTime.Now;
-
- contentInfoList.Add(contentInfo);
- }
- }
- }
- }
- }
-
- return contentInfoList;
- }
- }
-}
diff --git a/SiteServer.CMS/Core/Office/ExcelObject.cs b/SiteServer.CMS/Core/Office/ExcelObject.cs
deleted file mode 100644
index f6b86fddf..000000000
--- a/SiteServer.CMS/Core/Office/ExcelObject.cs
+++ /dev/null
@@ -1,164 +0,0 @@
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-using System;
-using System.Collections.Specialized;
-using System.Collections.Generic;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core.Office
-{
- public class ExcelObject
- {
- public static void CreateExcelFileForContents(string filePath, SiteInfo siteInfo,
- ChannelInfo nodeInfo, List contentIdList, List displayAttributes, bool isPeriods, string startDate,
- string endDate, ETriState checkedState)
- {
- DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));
- FileUtils.DeleteFileIfExists(filePath);
-
- var head = new List();
- var rows = new List>();
-
- var relatedidentityes =
- RelatedIdentities.GetChannelRelatedIdentities(siteInfo.Id, nodeInfo.Id);
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetTableStyleInfoList(tableName, relatedidentityes));
-
- foreach (var styleInfo in styleInfoList)
- {
- if (displayAttributes.Contains(styleInfo.AttributeName))
- {
- head.Add(styleInfo.DisplayName);
- }
- }
-
- if (contentIdList == null || contentIdList.Count == 0)
- {
- contentIdList = DataProvider.ContentDao.GetContentIdList(tableName, nodeInfo.Id, isPeriods,
- startDate, endDate, checkedState);
- }
-
- foreach (var contentId in contentIdList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- if (contentInfo != null)
- {
- var row = new List();
-
- foreach (var styleInfo in styleInfoList)
- {
- if (displayAttributes.Contains(styleInfo.AttributeName))
- {
- var value = contentInfo.GetString(styleInfo.AttributeName);
- row.Add(StringUtils.StripTags(value));
- }
- }
-
- rows.Add(row);
- }
- }
-
- CsvUtils.Export(filePath, head, rows);
- }
-
- public static void CreateExcelFileForUsers(string filePath, ETriState checkedState)
- {
- DirectoryUtils.CreateDirectoryIfNotExists(DirectoryUtils.GetDirectoryPath(filePath));
- FileUtils.DeleteFileIfExists(filePath);
-
- var head = new List
- {
- "用户名",
- "姓名",
- "邮箱",
- "手机",
- "注册时间",
- "最后一次活动时间"
- };
- var rows = new List>();
-
- List userIdList = DataProvider.UserDao.GetIdList(checkedState != ETriState.False);
- if (checkedState == ETriState.All)
- {
- userIdList.AddRange(DataProvider.UserDao.GetIdList(false));
- }
-
- foreach (var userId in userIdList)
- {
- var userInfo = DataProvider.UserDao.GetUserInfo(userId);
-
- rows.Add(new List
- {
- userInfo.UserName,
- userInfo.DisplayName,
- userInfo.Email,
- userInfo.Mobile,
- DateUtils.GetDateAndTimeString(userInfo.CreateDate),
- DateUtils.GetDateAndTimeString(userInfo.LastActivityDate)
- });
- }
-
- CsvUtils.Export(filePath, head, rows);
- }
-
- public static List GetContentsByCsvFile(string filePath, SiteInfo siteInfo,
- ChannelInfo nodeInfo)
- {
- var contentInfoList = new List();
-
- List head;
- List> rows;
- CsvUtils.Import(filePath, out head, out rows);
-
- if (rows.Count <= 0) return contentInfoList;
-
- var relatedidentityes =
- RelatedIdentities.GetChannelRelatedIdentities(
- siteInfo.Id, nodeInfo.Id);
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- // ArrayList tableStyleInfoArrayList = TableStyleManager.GetTableStyleInfoArrayList(ETableStyle.BackgroundContent, siteInfo.AuxiliaryTableForContent, relatedidentityes);
-
- var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetTableStyleInfoList(tableName, relatedidentityes));
- var nameValueCollection = new NameValueCollection();
- foreach (var styleInfo in styleInfoList)
- {
- nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower();
- }
-
- var attributeNames = new List();
- foreach (var columnName in head)
- {
- attributeNames.Add(!string.IsNullOrEmpty(nameValueCollection[columnName])
- ? nameValueCollection[columnName]
- : columnName);
- }
-
- foreach (var row in rows)
- {
- var contentInfo = new ContentInfo();
- if (row.Count != attributeNames.Count) continue;
-
- for (var i = 0; i < attributeNames.Count; i++)
- {
- var attributeName = attributeNames[i];
- if (!string.IsNullOrEmpty(attributeName))
- {
- var value = row[i];
- contentInfo.Set(attributeName, value);
- }
- }
-
- if (!string.IsNullOrEmpty(contentInfo.Title))
- {
- contentInfo.SiteId = siteInfo.Id;
- contentInfo.ChannelId = nodeInfo.Id;
- contentInfo.LastEditDate = DateTime.Now;
-
- contentInfoList.Add(contentInfo);
- }
- }
-
- return contentInfoList;
- }
- }
-}
diff --git a/SiteServer.CMS/Core/Office/TxtObject.cs b/SiteServer.CMS/Core/Office/TxtObject.cs
deleted file mode 100644
index 1386d08b7..000000000
--- a/SiteServer.CMS/Core/Office/TxtObject.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-using System;
-using System.Collections.Generic;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core.Office
-{
- public class TxtObject
- {
- public static List GetContentListByTxtFile(string directoryPath, SiteInfo siteInfo, ChannelInfo nodeInfo)
- {
- var contentInfoList = new List();
-
- var filePaths = DirectoryUtils.GetFilePaths(directoryPath);
- foreach (var filePath in filePaths)
- {
- if (!EFileSystemTypeUtils.Equals(EFileSystemType.Txt, PathUtils.GetExtension(filePath))) continue;
-
- try
- {
- var content = FileUtils.ReadText(filePath, ECharset.gb2312);
- if (!string.IsNullOrEmpty(content))
- {
- content = content.Trim();
- var title = StringUtils.GetFirstOfStringCollection(content, '\r');
- if (!string.IsNullOrEmpty(title))
- {
- var contentInfo = new ContentInfo
- {
- Title = title.Trim(),
- SiteId = siteInfo.Id,
- ChannelId = nodeInfo.Id,
- LastEditDate = DateTime.Now
- };
- contentInfo.Set(BackgroundContentAttribute.Content, StringUtils.ReplaceNewlineToBr(content.Replace(title, string.Empty).Trim()));
-
- contentInfoList.Add(contentInfo);
- }
- }
- }
- catch
- {
- // ignored
- }
- }
-
- return contentInfoList;
- }
- }
-}
diff --git a/SiteServer.CMS/Core/PageUtility.cs b/SiteServer.CMS/Core/PageUtility.cs
deleted file mode 100644
index 13ab0643b..000000000
--- a/SiteServer.CMS/Core/PageUtility.cs
+++ /dev/null
@@ -1,531 +0,0 @@
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-using System;
-using SiteServer.CMS.Api.Preview;
-using SiteServer.CMS.StlParser.Cache;
-using SiteServer.Plugin;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class PageUtility
- {
- private PageUtility()
- {
- }
-
- public static string GetSiteUrl(SiteInfo siteInfo, bool isLocal)
- {
- return GetSiteUrl(siteInfo, string.Empty, isLocal);
- }
-
- public static string GetSiteUrl(SiteInfo siteInfo, string requestPath, bool isLocal)
- {
- return isLocal
- ? GetLocalSiteUrl(siteInfo, requestPath)
- : GetRemoteSiteUrl(siteInfo, requestPath);
- }
-
- public static string GetRemoteSiteUrl(SiteInfo siteInfo)
- {
- return GetRemoteSiteUrl(siteInfo, string.Empty);
- }
-
- public static string GetRemoteSiteUrl(SiteInfo siteInfo, string requestPath)
- {
- var url = siteInfo.Additional.WebUrl;
-
- if (string.IsNullOrEmpty(url))
- {
- url = "/";
- }
- else
- {
- if (url != "/" && url.EndsWith("/"))
- {
- url = url.Substring(0, url.Length - 1);
- }
- }
-
- if (string.IsNullOrEmpty(requestPath)) return url;
-
- requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
- requestPath = PathUtils.RemovePathInvalidChar(requestPath);
- if (requestPath.StartsWith("/"))
- {
- requestPath = requestPath.Substring(1);
- }
-
- url = PageUtils.Combine(url, requestPath);
-
- if (!siteInfo.Additional.IsSeparatedAssets) return url;
-
- var assetsUrl = PageUtils.Combine(siteInfo.Additional.WebUrl,
- siteInfo.Additional.AssetsDir);
- if (StringUtils.StartsWithIgnoreCase(url, assetsUrl))
- {
- url = StringUtils.ReplaceStartsWithIgnoreCase(url, assetsUrl, siteInfo.Additional.AssetsUrl);
- }
-
- return url;
- }
-
- public static string GetLocalSiteUrl(SiteInfo siteInfo)
- {
- return GetLocalSiteUrl(siteInfo, string.Empty);
- }
-
- public static string GetLocalSiteUrl(SiteInfo siteInfo, string requestPath)
- {
- var url = PageUtils.ParseNavigationUrl($"~/{siteInfo.SiteDir}");
-
- if (string.IsNullOrEmpty(url))
- {
- url = "/";
- }
- else
- {
- if (url != "/" && url.EndsWith("/"))
- {
- url = url.Substring(0, url.Length - 1);
- }
- }
-
- if (string.IsNullOrEmpty(requestPath)) return url;
-
- requestPath = requestPath.Replace(PathUtils.SeparatorChar, PageUtils.SeparatorChar);
- requestPath = PathUtils.RemovePathInvalidChar(requestPath);
- if (requestPath.StartsWith("/"))
- {
- requestPath = requestPath.Substring(1);
- }
-
- url = PageUtils.Combine(url, requestPath);
-
- return url;
- }
-
- public static string GetSiteUrlByPhysicalPath(SiteInfo siteInfo, string physicalPath, bool isLocal)
- {
- if (siteInfo == null)
- {
- var publishmentSystemId = PathUtility.GetCurrentSiteId();
- siteInfo = SiteManager.GetSiteInfo(publishmentSystemId);
- }
- if (string.IsNullOrEmpty(physicalPath)) return siteInfo.Additional.WebUrl;
-
- var publishmentSystemPath = PathUtility.GetSitePath(siteInfo);
- var requestPath = StringUtils.StartsWithIgnoreCase(physicalPath, publishmentSystemPath)
- ? StringUtils.ReplaceStartsWithIgnoreCase(physicalPath, publishmentSystemPath, string.Empty)
- : string.Empty;
-
- return GetSiteUrl(siteInfo, requestPath, isLocal);
- }
-
- // 得到发布系统首页地址
- public static string GetIndexPageUrl(SiteInfo siteInfo, bool isLocal)
- {
- var indexTemplateId = TemplateManager.GetIndexTempalteId(siteInfo.Id);
- var createdFileFullName = TemplateManager.GetCreatedFileFullName(siteInfo.Id, indexTemplateId);
-
- return isLocal
- ? ApiRoutePreview.GetSiteUrl(siteInfo.Id)
- : ParseNavigationUrl(siteInfo, createdFileFullName, false);
- }
-
- public static string GetFileUrl(SiteInfo siteInfo, int fileTemplateId, bool isLocal)
- {
- var createdFileFullName = TemplateManager.GetCreatedFileFullName(siteInfo.Id, fileTemplateId);
-
- return isLocal
- ? ApiRoutePreview.GetFileUrl(siteInfo.Id, fileTemplateId)
- : ParseNavigationUrl(siteInfo, createdFileFullName, false);
- }
-
- public static string GetContentUrl(SiteInfo siteInfo, IContentInfo contentInfo, bool isLocal)
- {
- return GetContentUrlById(siteInfo, contentInfo, isLocal);
- }
-
- public static string GetContentUrl(SiteInfo siteInfo, ChannelInfo nodeInfo, int contentId, bool isLocal)
- {
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- var contentInfo = Content.GetContentInfo(tableName, contentId);
- return GetContentUrlById(siteInfo, contentInfo, isLocal);
- }
-
- ///
- /// 对GetContentUrlByID的优化
- /// 通过传入参数contentInfoCurrent,避免对ContentInfo查询太多
- ///
- private static string GetContentUrlById(SiteInfo siteInfo, IContentInfo contentInfoCurrent, bool isLocal)
- {
- if (contentInfoCurrent == null) return PageUtils.UnclickedUrl;
-
- if (isLocal)
- {
- return ApiRoutePreview.GetContentUrl(siteInfo.Id, contentInfoCurrent.ChannelId,
- contentInfoCurrent.Id);
- }
-
- var sourceId = contentInfoCurrent.SourceId;
- var referenceId = contentInfoCurrent.ReferenceId;
- var linkUrl = contentInfoCurrent.GetString(ContentAttribute.LinkUrl);
- var channelId = contentInfoCurrent.ChannelId;
- if (referenceId > 0 && contentInfoCurrent.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
- {
- if (sourceId > 0 && (ChannelManager.IsExists(siteInfo.Id, sourceId) || ChannelManager.IsExists(sourceId)))
- {
- var targetChannelId = sourceId;
- var targetSiteId = Node.GetSiteId(targetChannelId);
- var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
- var targetChannelInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);
-
- var tableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelInfo);
- var contentInfo = Content.GetContentInfo(tableName, referenceId);
- if (contentInfo == null || contentInfo.ChannelId <= 0)
- {
- return PageUtils.UnclickedUrl;
- }
- if (contentInfo.SiteId == targetSiteInfo.Id)
- {
- return GetContentUrlById(targetSiteInfo, contentInfo, false);
- }
- var siteInfoTmp = SiteManager.GetSiteInfo(contentInfo.SiteId);
- return GetContentUrlById(siteInfoTmp, contentInfo, false);
- }
- else
- {
- var tableName = ChannelManager.GetTableName(siteInfo, channelId);
- channelId = Content.GetChannelId(tableName, referenceId);
- linkUrl = Content.GetValue(tableName, referenceId, ContentAttribute.LinkUrl);
- if (ChannelManager.IsExists(siteInfo.Id, channelId))
- {
- return GetContentUrlById(siteInfo, channelId, referenceId, 0, 0, linkUrl, false);
- }
- var targetSiteId = Node.GetSiteId(channelId);
- var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
- return GetContentUrlById(targetSiteInfo, channelId, referenceId, 0, 0, linkUrl, false);
- }
- }
-
- if (!string.IsNullOrEmpty(linkUrl))
- {
- return ParseNavigationUrl(siteInfo, linkUrl, false);
- }
- var contentUrl = PathUtility.ContentFilePathRules.Parse(siteInfo, channelId, contentInfoCurrent);
- return GetSiteUrl(siteInfo, contentUrl, false);
- }
-
- private static string GetContentUrlById(SiteInfo siteInfo, int channelId, int contentId, int sourceId, int referenceId, string linkUrl, bool isLocal)
- {
- if (isLocal)
- {
- return ApiRoutePreview.GetContentUrl(siteInfo.Id, channelId, contentId);
- }
-
- var tableNameCurrent = ChannelManager.GetTableName(siteInfo, channelId);
- var contentInfoCurrent = Content.GetContentInfo(tableNameCurrent, contentId);
-
- if (referenceId > 0 && contentInfoCurrent.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
- {
- if (sourceId > 0 && (ChannelManager.IsExists(siteInfo.Id, sourceId) || ChannelManager.IsExists(sourceId)))
- {
- var targetChannelId = sourceId;
- var targetSiteId = Node.GetSiteId(targetChannelId);
- var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
- var targetChannelInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);
-
- var tableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelInfo);
- var contentInfo = Content.GetContentInfo(tableName, referenceId);
- if (contentInfo == null || contentInfo.ChannelId <= 0)
- {
- return PageUtils.UnclickedUrl;
- }
- if (contentInfo.SiteId == targetSiteInfo.Id)
- {
- return GetContentUrlById(targetSiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetString(ContentAttribute.LinkUrl), false);
- }
- var siteInfoTmp = SiteManager.GetSiteInfo(contentInfo.SiteId);
- return GetContentUrlById(siteInfoTmp, contentInfo.ChannelId, contentInfo.Id, contentInfo.SourceId, contentInfo.ReferenceId, contentInfo.GetString(ContentAttribute.LinkUrl), false);
- }
- else
- {
- var tableName = ChannelManager.GetTableName(siteInfo, channelId);
- channelId = Content.GetChannelId(tableName, referenceId);
- linkUrl = Content.GetValue(tableName, referenceId, ContentAttribute.LinkUrl);
- return GetContentUrlById(siteInfo, channelId, referenceId, 0, 0, linkUrl, false);
- }
- }
- if (!string.IsNullOrEmpty(linkUrl))
- {
- return ParseNavigationUrl(siteInfo, linkUrl, false);
- }
- var contentUrl = PathUtility.ContentFilePathRules.Parse(siteInfo, channelId, contentId);
- return GetSiteUrl(siteInfo, contentUrl, false);
- }
-
- private static string GetChannelUrlNotComputed(SiteInfo siteInfo, int channelId, bool isLocal)
- {
- if (channelId == siteInfo.Id)
- {
- return GetIndexPageUrl(siteInfo, isLocal);
- }
- var linkUrl = string.Empty;
- var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
- if (nodeInfo != null)
- {
- linkUrl = nodeInfo.LinkUrl;
- }
-
- if (string.IsNullOrEmpty(linkUrl))
- {
- if (nodeInfo != null)
- {
- var filePath = nodeInfo.FilePath;
-
- if (string.IsNullOrEmpty(filePath))
- {
- var channelUrl = PathUtility.ChannelFilePathRules.Parse(siteInfo, channelId);
- return GetSiteUrl(siteInfo, channelUrl, isLocal);
- }
- return ParseNavigationUrl(siteInfo, PathUtility.AddVirtualToPath(filePath), isLocal);
- }
- }
-
- return ParseNavigationUrl(siteInfo, linkUrl, isLocal);
- }
-
- //得到栏目经过计算后的连接地址
- public static string GetChannelUrl(SiteInfo siteInfo, ChannelInfo nodeInfo, bool isLocal)
- {
- if (isLocal)
- {
- return ApiRoutePreview.GetChannelUrl(siteInfo.Id, nodeInfo.Id);
- }
- var url = string.Empty;
- if (nodeInfo != null)
- {
- if (nodeInfo.ParentId == 0)
- {
- url = GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- else
- {
- var linkType = ELinkTypeUtils.GetEnumType(nodeInfo.LinkType);
- if (linkType == ELinkType.None)
- {
- url = GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- else if (linkType == ELinkType.NoLink)
- {
- url = PageUtils.UnclickedUrl;
- }
- else
- {
- if (linkType == ELinkType.NoLinkIfContentNotExists)
- {
- url = nodeInfo.ContentNum == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- else if (linkType == ELinkType.LinkToOnlyOneContent)
- {
- if (nodeInfo.ContentNum == 1)
- {
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo);
- var contentId = Content.GetContentId(tableName, nodeInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(nodeInfo.Additional.DefaultTaxisType)));
- url = GetContentUrl(siteInfo, nodeInfo, contentId, false);
- }
- else
- {
- url = GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- }
- else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToOnlyOneContent)
- {
- if (nodeInfo.ContentNum == 0)
- {
- url = PageUtils.UnclickedUrl;
- }
- else if (nodeInfo.ContentNum == 1)
- {
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- var contentId = Content.GetContentId(tableName, nodeInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(nodeInfo.Additional.DefaultTaxisType)));
- //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo);
- url = GetContentUrl(siteInfo, nodeInfo, contentId, false);
- }
- else
- {
- url = GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- }
- else if (linkType == ELinkType.LinkToFirstContent)
- {
- if (nodeInfo.ContentNum >= 1)
- {
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- var contentId = Content.GetContentId(tableName, nodeInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(nodeInfo.Additional.DefaultTaxisType)));
- //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo);
- url = GetContentUrl(siteInfo, nodeInfo, contentId, false);
- }
- else
- {
- url = GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- }
- else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToFirstContent)
- {
- if (nodeInfo.ContentNum >= 1)
- {
- var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);
- var contentId = Content.GetContentId(tableName, nodeInfo.Id, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(nodeInfo.Additional.DefaultTaxisType)));
- //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo);
- url = GetContentUrl(siteInfo, nodeInfo, contentId, false);
- }
- else
- {
- url = PageUtils.UnclickedUrl;
- }
- }
- else if (linkType == ELinkType.NoLinkIfChannelNotExists)
- {
- url = nodeInfo.ChildrenCount == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- else if (linkType == ELinkType.LinkToLastAddChannel)
- {
- var lastAddChannelInfo = Node.GetChannelInfoByLastAddDate(nodeInfo.Id);
- url = lastAddChannelInfo != null ? GetChannelUrl(siteInfo, lastAddChannelInfo, false) : GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- else if (linkType == ELinkType.LinkToFirstChannel)
- {
- var firstChannelInfo = Node.GetChannelInfoByTaxis(nodeInfo.Id);
- url = firstChannelInfo != null ? GetChannelUrl(siteInfo, firstChannelInfo, false) : GetChannelUrlNotComputed(siteInfo, nodeInfo.Id, false);
- }
- else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToLastAddChannel)
- {
- var lastAddChannelInfo = Node.GetChannelInfoByLastAddDate(nodeInfo.Id);
- url = lastAddChannelInfo != null ? GetChannelUrl(siteInfo, lastAddChannelInfo, false) : PageUtils.UnclickedUrl;
- }
- else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToFirstChannel)
- {
- var firstChannelInfo = Node.GetChannelInfoByTaxis(nodeInfo.Id);
- url = firstChannelInfo != null ? GetChannelUrl(siteInfo, firstChannelInfo, false) : PageUtils.UnclickedUrl;
- }
- }
- }
- }
- return url;
- }
-
- public static string GetInputChannelUrl(SiteInfo siteInfo, ChannelInfo nodeInfo, bool isLocal)
- {
- var channelUrl = GetChannelUrl(siteInfo, nodeInfo, isLocal);
- if (string.IsNullOrEmpty(channelUrl)) return channelUrl;
-
- channelUrl = StringUtils.ReplaceStartsWith(channelUrl, siteInfo.Additional.WebUrl, string.Empty);
- channelUrl = channelUrl.Trim('/');
- channelUrl = "/" + channelUrl;
- return channelUrl;
- }
-
- public static string AddVirtualToUrl(string url)
- {
- var resolvedUrl = url;
- if (string.IsNullOrEmpty(url) || PageUtils.IsProtocolUrl(url)) return resolvedUrl;
-
- if (!url.StartsWith("@") && !url.StartsWith("~"))
- {
- resolvedUrl = PageUtils.Combine("@/", url);
- }
- return resolvedUrl;
- }
-
- public static string ParseNavigationUrlAddPrefix(SiteInfo siteInfo, string url, bool isLocal)
- {
- if (string.IsNullOrEmpty(url)) return ParseNavigationUrl(siteInfo, url, isLocal);
-
- if (!url.StartsWith("~/") && !url.StartsWith("@/"))
- {
- url = "@/" + url;
- }
- return ParseNavigationUrl(siteInfo, url, isLocal);
- }
-
- public static string ParseNavigationUrl(int publishmentSystemId, string url, bool isLocal)
- {
- var siteInfo = SiteManager.GetSiteInfo(publishmentSystemId);
- return ParseNavigationUrl(siteInfo, url, isLocal);
- }
-
- //根据发布系统属性判断是否为相对路径并返回解析后路径
- public static string ParseNavigationUrl(SiteInfo siteInfo, string url, bool isLocal)
- {
- if (siteInfo != null)
- {
- if (!string.IsNullOrEmpty(url) && url.StartsWith("@"))
- {
- return GetSiteUrl(siteInfo, url.Substring(1), isLocal);
- }
- return PageUtils.ParseNavigationUrl(url);
- }
- return PageUtils.ParseNavigationUrl(url);
- }
-
- public static string GetVirtualUrl(SiteInfo siteInfo, string url)
- {
- var virtualUrl = StringUtils.ReplaceStartsWith(url, siteInfo.Additional.WebUrl, "@/");
- return StringUtils.ReplaceStartsWith(virtualUrl, "@//", "@/");
- }
-
- public static bool IsVirtualUrl(string url)
- {
- if (string.IsNullOrEmpty(url)) return false;
-
- return url.StartsWith("~") || url.StartsWith("@");
- }
-
- public static string GetSiteFilesUrl(string apiUrl, string relatedUrl)
- {
- if (string.IsNullOrEmpty(apiUrl))
- {
- apiUrl = "/api";
- }
- apiUrl = apiUrl.Trim().ToLower();
- if (apiUrl == "/api")
- {
- apiUrl = "/";
- }
- else if (apiUrl.EndsWith("/api"))
- {
- apiUrl = apiUrl.Substring(0, apiUrl.LastIndexOf("/api", StringComparison.Ordinal));
- }
- else if (apiUrl.EndsWith("/api/"))
- {
- apiUrl = apiUrl.Substring(0, apiUrl.LastIndexOf("/api/", StringComparison.Ordinal));
- }
- if (string.IsNullOrEmpty(apiUrl))
- {
- apiUrl = "/";
- }
- return PageUtils.Combine(apiUrl, DirectoryUtils.SiteFiles.DirectoryName, relatedUrl);
- }
-
- public static string GetUserFilesUrl(string apiUrl, string relatedUrl)
- {
- return GetSiteFilesUrl(apiUrl, PageUtils.Combine(DirectoryUtils.SiteFiles.UserFiles, relatedUrl));
- }
-
- public static string GetUserAvatarUrl(string apiUrl, IUserInfo userInfo)
- {
- var imageUrl = userInfo?.AvatarUrl;
-
- if (!string.IsNullOrEmpty(imageUrl))
- {
- return PageUtils.IsProtocolUrl(imageUrl) ? imageUrl : GetUserFilesUrl(apiUrl, PageUtils.Combine(userInfo.UserName, imageUrl));
- }
-
- return SiteFilesAssets.GetUrl(apiUrl, "default_avatar.png");
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Core/PermissionConfigManager.cs b/SiteServer.CMS/Core/PermissionConfigManager.cs
deleted file mode 100644
index c0d3bfc87..000000000
--- a/SiteServer.CMS/Core/PermissionConfigManager.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using System.Collections.Generic;
-using System.Xml;
-using SiteServer.CMS.Plugin;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Core
-{
- public class PermissionConfigManager
- {
- public class PermissionConfig
- {
- public PermissionConfig(string name, string text)
- {
- Name = name;
- Text = text;
- }
-
- public string Name { get; set; }
-
- public string Text { get; set; }
- }
-
- public const string CacheKey = "SiteServer.CMS.Core.PermissionConfigManager";
-
- public List GeneralPermissions { get; } = new List();
-
- public List WebsitePermissions { get; } = new List();
-
- public List ChannelPermissions { get; } = new List();
-
- private PermissionConfigManager()
- {
- }
-
- public static PermissionConfigManager Instance
- {
- get
- {
- var permissionManager = CacheUtils.Get(CacheKey) as PermissionConfigManager;
- if (permissionManager != null) return permissionManager;
-
- permissionManager = new PermissionConfigManager();
-
- var path = PathUtils.GetMenusPath("Permissions.config");
- if (FileUtils.IsFileExists(path))
- {
- var doc = new XmlDocument();
- doc.Load(path);
- permissionManager.LoadValuesFromConfigurationXml(doc);
- }
-
- CacheUtils.Insert(CacheKey, permissionManager, path);
- return permissionManager;
- }
- }
-
- private void LoadValuesFromConfigurationXml(XmlDocument doc)
- {
- var coreNode = doc.SelectSingleNode("Config");
- if (coreNode != null)
- {
- var isMultiple = true;
- foreach (XmlNode child in coreNode.ChildNodes)
- {
- if (child.NodeType == XmlNodeType.Comment) continue;
- if (child.Name == "generalPermissions")
- {
- GetPermissions(child, GeneralPermissions);
- }
- else if (child.Name == "websitePermissions")
- {
- GetPermissions(child, WebsitePermissions);
- }
- else if (child.Name == "channelPermissions")
- {
- GetPermissions(child, ChannelPermissions);
- }
- else
- {
- isMultiple = false;
- break;
- }
- }
- if (!isMultiple)
- {
- GetPermissions(coreNode, GeneralPermissions);
- }
- }
-
- GeneralPermissions.AddRange(PluginMenuManager.GetTopPermissions());
- WebsitePermissions.AddRange(PluginMenuManager.GetSitePermissions(0));
- }
-
- private static void GetPermissions(XmlNode node, List list)
- {
- foreach (XmlNode permission in node.ChildNodes)
- {
- if (permission.Name == "add" && permission.Attributes != null)
- {
- list.Add(new PermissionConfig(permission.Attributes["name"].Value, permission.Attributes["text"].Value));
- }
- }
- }
- }
-}
diff --git a/SiteServer.CMS/Core/PermissionManager.cs b/SiteServer.CMS/Core/PermissionManager.cs
deleted file mode 100644
index d6904ba87..000000000
--- a/SiteServer.CMS/Core/PermissionManager.cs
+++ /dev/null
@@ -1,598 +0,0 @@
-using System;
-using System.Collections.Generic;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class PermissionManager
- {
- public const string CacheKeyPrefix = "SiteServer.CMS.Core.PermissionManager";
-
- private string[] _roles;
- private List _permissionList;
- private readonly string _rolesKey;
- private readonly string _permissionListKey;
-
- private Dictionary> _websitePermissionDict;
- private Dictionary> _channelPermissionDict;
- private List _channelPermissionListIgnoreChannelId;
- private List _siteIdList;
- private List _owningChannelIdList;
-
- private readonly string _websitePermissionDictKey;
- private readonly string _channelPermissionDictKey;
- private readonly string _channelPermissionListIgnoreChannelIdKey;
- private readonly string _siteIdListKey;
- private readonly string _owningChannelIdListKey;
-
- public static PermissionManager GetInstance(string administratorName)
- {
- return new PermissionManager(administratorName);
- }
-
- private PermissionManager(string userName)
- {
- UserName = string.IsNullOrEmpty(userName) ? AdminManager.AnonymousUserName : userName;
-
- _rolesKey = GetRolesCacheKey(userName);
- _permissionListKey = GetPermissionListCacheKey(userName);
- _websitePermissionDictKey = GetWebsitePermissionDictCacheKey(userName);
- _channelPermissionDictKey = GetChannelPermissionDictCacheKey(userName);
- _channelPermissionListIgnoreChannelIdKey = GetChannelPermissionListIgnoreChannelIdCacheKey(userName);
- _siteIdListKey = GetSiteIdListCacheKey(userName);
- _owningChannelIdListKey = GetOwningChannelIdListCacheKey(userName);
- }
-
- public string UserName { get; }
-
- public bool IsConsoleAdministrator => EPredefinedRoleUtils.IsConsoleAdministrator(Roles);
-
- public bool IsSystemAdministrator => EPredefinedRoleUtils.IsSystemAdministrator(Roles);
-
- public bool IsAdministrator => EPredefinedRoleUtils.IsAdministrator(Roles);
-
- public List PermissionList
- {
- get
- {
- if (_permissionList == null)
- {
- if (!string.IsNullOrEmpty(UserName) && !string.Equals(UserName, AdminManager.AnonymousUserName))
- {
- if (CacheUtils.Get(_permissionListKey) != null)
- {
- _permissionList = CacheUtils.Get(_permissionListKey) as List;
- }
- else
- {
- if (EPredefinedRoleUtils.IsConsoleAdministrator(Roles))
- {
- _permissionList = new List();
- foreach (var permission in PermissionConfigManager.Instance.GeneralPermissions)
- {
- _permissionList.Add(permission.Name);
- }
- }
- else if (EPredefinedRoleUtils.IsSystemAdministrator(Roles))
- {
- _permissionList = new List
- {
- ConfigManager.SettingsPermissions.Admin
- };
- }
- else
- {
- _permissionList = DataProvider.PermissionsInRolesDao.GetGeneralPermissionList(Roles);
- }
-
- CacheUtils.InsertMinutes(_permissionListKey, _permissionList, 30);
- }
- }
- }
- return _permissionList ?? (_permissionList = new List());
- }
- }
-
- public string[] Roles
- {
- get
- {
- if (_roles == null)
- {
- if (!string.IsNullOrEmpty(UserName) && !string.Equals(UserName, AdminManager.AnonymousUserName))
- {
- if (CacheUtils.Get(_rolesKey) != null)
- {
- _roles = (string[])CacheUtils.Get(_rolesKey);
- }
- else
- {
- _roles = DataProvider.AdministratorsInRolesDao.GetRolesForUser(UserName);
- CacheUtils.InsertMinutes(_rolesKey, _roles, 30);
- }
- }
- }
- if (_roles != null && _roles.Length > 0)
- {
- return _roles;
- }
- return new[] { EPredefinedRoleUtils.GetValue(EPredefinedRole.Administrator) };
- }
- }
-
- public bool IsInRole(string role)
- {
- foreach (var r in Roles)
- {
- if (role == r) return true;
- }
- return false;
- }
-
- private Dictionary> WebsitePermissionDict
- {
- get
- {
- if (_websitePermissionDict == null)
- {
- if (!string.IsNullOrEmpty(UserName) && !string.Equals(UserName, AdminManager.AnonymousUserName))
- {
- if (CacheUtils.Get(_websitePermissionDictKey) != null)
- {
- _websitePermissionDict = CacheUtils.Get(_websitePermissionDictKey) as Dictionary>;
- }
- else
- {
- if (EPredefinedRoleUtils.IsSystemAdministrator(Roles))
- {
- var allWebsitePermissionList = new List();
- foreach (var permission in PermissionConfigManager.Instance.WebsitePermissions)
- {
- allWebsitePermissionList.Add(permission.Name);
- }
-
- _websitePermissionDict = new Dictionary>();
- if (SiteIdList.Count > 0)
- {
- foreach (var siteId in SiteIdList)
- {
- _websitePermissionDict[siteId] = allWebsitePermissionList;
- }
- }
- }
- else
- {
- _websitePermissionDict = DataProvider.SitePermissionsDao.GetWebsitePermissionSortedList(Roles);
- }
- CacheUtils.InsertMinutes(_websitePermissionDictKey, _websitePermissionDict, 30);
- }
- }
- }
- return _websitePermissionDict ?? (_websitePermissionDict = new Dictionary>());
- }
- }
-
- public List ChannelPermissionChannelIdList
- {
- get
- {
- var list = new List();
- foreach (var dictKey in ChannelPermissionDict.Keys)
- {
- var kvp = ParseChannelPermissionDictKey(dictKey);
- if (!list.Contains(kvp.Value))
- {
- list.Add(kvp.Value);
- }
- }
- return list;
- }
- }
-
- private Dictionary> ChannelPermissionDict
- {
- get
- {
- if (_channelPermissionDict == null)
- {
- if (!string.IsNullOrEmpty(UserName) && !string.Equals(UserName, AdminManager.AnonymousUserName))
- {
- if (CacheUtils.Get(_channelPermissionDictKey) != null)
- {
- _channelPermissionDict = CacheUtils.Get(_channelPermissionDictKey) as Dictionary>;
- }
- else
- {
- if (EPredefinedRoleUtils.IsSystemAdministrator(Roles))
- {
- var allChannelPermissionList = new List();
- foreach (var permission in PermissionConfigManager.Instance.ChannelPermissions)
- {
- allChannelPermissionList.Add(permission.Name);
- }
-
- _channelPermissionDict = new Dictionary>();
-
- if (SiteIdList.Count > 0)
- {
- foreach (var siteId in SiteIdList)
- {
- _channelPermissionDict[GetChannelPermissionDictKey(siteId, siteId)] = allChannelPermissionList;
- }
- }
- }
- else
- {
- _channelPermissionDict = DataProvider.SitePermissionsDao.GetChannelPermissionSortedList(Roles);
- }
- CacheUtils.InsertMinutes(_channelPermissionDictKey, _channelPermissionDict, 30);
- }
- }
- }
- return _channelPermissionDict ?? (_channelPermissionDict = new Dictionary>());
- }
- }
-
- public List ChannelPermissionListIgnoreChannelId
- {
- get
- {
- if (_channelPermissionListIgnoreChannelId == null)
- {
- if (!string.IsNullOrEmpty(UserName) && !string.Equals(UserName, AdminManager.AnonymousUserName))
- {
- if (CacheUtils.Get(_channelPermissionListIgnoreChannelIdKey) != null)
- {
- _channelPermissionListIgnoreChannelId = CacheUtils.Get(_channelPermissionListIgnoreChannelIdKey) as List;
- }
- else
- {
- if (EPredefinedRoleUtils.IsSystemAdministrator(Roles))
- {
- _channelPermissionListIgnoreChannelId = new List();
- foreach (var permission in PermissionConfigManager.Instance.ChannelPermissions)
- {
- _channelPermissionListIgnoreChannelId.Add(permission.Name);
- }
- }
- else
- {
- _channelPermissionListIgnoreChannelId = DataProvider.SitePermissionsDao.GetChannelPermissionListIgnoreChannelId(Roles);
- }
- CacheUtils.InsertMinutes(_channelPermissionListIgnoreChannelIdKey, _channelPermissionListIgnoreChannelId, 30);
- }
- }
- }
- return _channelPermissionListIgnoreChannelId ?? (_channelPermissionListIgnoreChannelId = new List());
- }
- }
-
- public List SiteIdList
- {
- get
- {
- if (_siteIdList != null) return _siteIdList;
-
- if (CacheUtils.Get(_siteIdListKey) != null)
- {
- _siteIdList = (List)CacheUtils.Get(_siteIdListKey);
- }
- else
- {
- if (EPredefinedRoleUtils.IsConsoleAdministrator(Roles))
- {
- _siteIdList = SiteManager.GetSiteIdList();
- }
- else if (EPredefinedRoleUtils.IsSystemAdministrator(Roles))
- {
- var theSiteIdList = DataProvider.AdministratorDao.GetSiteIdList(UserName);
- _siteIdList = new List();
- foreach (var siteId in SiteManager.GetSiteIdList())
- {
- if (theSiteIdList != null && theSiteIdList.Contains(siteId))
- {
- _siteIdList.Add(siteId);
- }
- }
- }
- else
- {
- _siteIdList = new List();
- foreach (var siteId in WebsitePermissionDict.Keys)
- {
- _siteIdList.Add(siteId);
- }
- }
-
- if (_siteIdList == null)
- {
- _siteIdList = new List();
- }
-
- CacheUtils.InsertMinutes(_siteIdListKey, _siteIdList, 30);
- }
- return _siteIdList;
- }
- }
-
- public List OwningChannelIdList
- {
- get
- {
- if (_owningChannelIdList == null)
- {
- if (!string.IsNullOrEmpty(UserName) && !string.Equals(UserName, AdminManager.AnonymousUserName))
- {
- if (CacheUtils.Get(_owningChannelIdListKey) != null)
- {
- _owningChannelIdList = CacheUtils.Get(_owningChannelIdListKey) as List;
- }
- else
- {
- _owningChannelIdList = new List();
-
- if (!IsSystemAdministrator)
- {
- foreach (var dictKey in ChannelPermissionDict.Keys)
- {
- var kvp = ParseChannelPermissionDictKey(dictKey);
- var channelInfo = ChannelManager.GetChannelInfo(kvp.Key, kvp.Value);
- _owningChannelIdList.AddRange(ChannelManager.GetChannelIdList(channelInfo, EScopeType.All, string.Empty, string.Empty, string.Empty));
- }
- }
-
- CacheUtils.InsertMinutes(_owningChannelIdListKey, _owningChannelIdList, 30);
- }
- }
- }
- return _owningChannelIdList ?? (_owningChannelIdList = new List());
- }
- }
-
- public bool HasAdministratorPermissions(params string[] permissionArray)
- {
- if (IsSystemAdministrator)
- {
- return true;
- }
- var permissionList = PermissionList;
- foreach (var permission in permissionArray)
- {
- if (permissionList.Contains(permission))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public bool HasSitePermissions(int siteId)
- {
- return IsSystemAdministrator || WebsitePermissionDict.ContainsKey(siteId);
- }
-
- public List GetSitePermissions(int siteId)
- {
- List list;
- if (WebsitePermissionDict.TryGetValue(siteId, out list))
- {
- return list;
- }
- return new List();
- }
-
- public bool HasSitePermissions(int siteId, params string[] sitePermissions)
- {
- if (IsSystemAdministrator)
- {
- return true;
- }
- if (WebsitePermissionDict.ContainsKey(siteId))
- {
- var websitePermissionList = WebsitePermissionDict[siteId];
- if (websitePermissionList != null && websitePermissionList.Count > 0)
- {
- foreach (var sitePermission in sitePermissions)
- {
- if (websitePermissionList.Contains(sitePermission))
- {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- public bool HasChannelPermissions(List channelPermissionList, params string[] channelPermissions)
- {
- if (IsSystemAdministrator)
- {
- return true;
- }
- foreach (var channelPermission in channelPermissions)
- {
- if (channelPermissionList.Contains(channelPermission))
- {
- return true;
- }
- }
- return false;
- }
-
- public bool HasChannelPermissions(int siteId, int channelId)
- {
- if (channelId == 0) return false;
- if (IsSystemAdministrator)
- {
- return true;
- }
- var dictKey = GetChannelPermissionDictKey(siteId, channelId);
- if (ChannelPermissionDict.ContainsKey(dictKey))
- {
- return true;
- }
-
- var parentChannelId = ChannelManager.GetParentId(siteId, channelId);
- return HasChannelPermissions(siteId, parentChannelId);
- }
-
- public List GetChannelPermissions(int siteId, int channelId)
- {
- var dictKey = GetChannelPermissionDictKey(siteId, channelId);
- List list;
- if (ChannelPermissionDict.TryGetValue(dictKey, out list))
- {
- return list;
- }
- return new List();
- }
-
- public List GetChannelPermissions(int siteId)
- {
- var list = new List();
- foreach (var dictKey in ChannelPermissionDict.Keys)
- {
- var kvp = ParseChannelPermissionDictKey(dictKey);
- if (kvp.Key == siteId)
- {
- foreach (var permission in ChannelPermissionDict[dictKey])
- {
- if (!list.Contains(permission))
- {
- list.Add(permission);
- }
- }
- }
- }
-
- return list;
- }
-
- public bool HasChannelPermissions(int siteId, int channelId, params string[] channelPermissions)
- {
- if (channelId == 0) return false;
- if (IsSystemAdministrator)
- {
- return true;
- }
- var dictKey = GetChannelPermissionDictKey(siteId, channelId);
- if (ChannelPermissionDict.ContainsKey(dictKey) && HasChannelPermissions(ChannelPermissionDict[dictKey], channelPermissions))
- {
- return true;
- }
-
- var parentChannelId = ChannelManager.GetParentId(siteId, channelId);
- return HasChannelPermissions(siteId, parentChannelId, channelPermissions);
- }
-
- public bool HasChannelPermissionsIgnoreChannelId(params string[] channelPermissions)
- {
- if (IsSystemAdministrator)
- {
- return true;
- }
- if (HasChannelPermissions(ChannelPermissionListIgnoreChannelId, channelPermissions))
- {
- return true;
- }
- return false;
- }
-
- public bool IsOwningChannelId(int channelId)
- {
- if (IsSystemAdministrator)
- {
- return true;
- }
- if (OwningChannelIdList.Contains(channelId))
- {
- return true;
- }
- return false;
- }
-
- public bool IsDescendantOwningChannelId(int siteId, int channelId)
- {
- if (IsSystemAdministrator)
- {
- return true;
- }
-
- var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
- var channelIdList = ChannelManager.GetChannelIdList(channelInfo, EScopeType.Descendant, string.Empty, string.Empty, string.Empty);
- foreach (var theChannelId in channelIdList)
- {
- if (IsOwningChannelId(theChannelId))
- {
- return true;
- }
- }
- return false;
- }
-
- public bool IsViewContentOnlySelf(int siteId, int channelId)
- {
- if (IsConsoleAdministrator || IsSystemAdministrator)
- return false;
- if (HasChannelPermissions(siteId, channelId, ConfigManager.ChannelPermissions.ContentCheck))
- return false;
- return ConfigManager.SystemConfigInfo.IsViewContentOnlySelf;
- }
-
- public static string GetChannelPermissionDictKey(int siteId, int channelId)
- {
- return $"{siteId}_{channelId}";
- }
-
- private static KeyValuePair ParseChannelPermissionDictKey(string dictKey)
- {
- if (string.IsNullOrEmpty(dictKey) || dictKey.IndexOf("_", StringComparison.Ordinal) == -1) return new KeyValuePair(0, 0);
-
- return new KeyValuePair(TranslateUtils.ToInt(dictKey.Split('_')[0]), TranslateUtils.ToInt(dictKey.Split('_')[1]));
- }
-
- private static string GetRolesCacheKey(string userName)
- {
- return $"{CacheKeyPrefix}.{nameof(GetRolesCacheKey)}.{userName}";
- }
-
- private static string GetPermissionListCacheKey(string userName)
- {
- return $"{CacheKeyPrefix}.{nameof(GetPermissionListCacheKey)}.{userName}";
- }
-
- private static string GetWebsitePermissionDictCacheKey(string userName)
- {
- return $"{CacheKeyPrefix}.{nameof(GetWebsitePermissionDictCacheKey)}.{userName}";
- }
-
- private static string GetChannelPermissionDictCacheKey(string userName)
- {
- return $"{CacheKeyPrefix}.{nameof(GetChannelPermissionDictCacheKey)}.{userName}";
- }
-
- private static string GetChannelPermissionListIgnoreChannelIdCacheKey(string userName)
- {
- return $"{CacheKeyPrefix}.{nameof(GetChannelPermissionListIgnoreChannelIdCacheKey)}.{userName}";
- }
-
- private static string GetSiteIdListCacheKey(string userName)
- {
- return $"{CacheKeyPrefix}.{nameof(GetSiteIdListCacheKey)}.{userName}";
- }
-
- private static string GetOwningChannelIdListCacheKey(string userName)
- {
- return $"{CacheKeyPrefix}.{nameof(GetOwningChannelIdListCacheKey)}.{userName}";
- }
-
- public static void ClearAllCache()
- {
- CacheUtils.RemoveByStartString(CacheKeyPrefix);
- }
- }
-}
diff --git a/SiteServer.CMS/Core/RelatedIdentities.cs b/SiteServer.CMS/Core/RelatedIdentities.cs
deleted file mode 100644
index c2f8f4d0c..000000000
--- a/SiteServer.CMS/Core/RelatedIdentities.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System.Collections.Generic;
-using SiteServer.Utils;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.CMS.Core
-{
- public class RelatedIdentities
- {
- private RelatedIdentities()
- {
- }
-
- public static List GetRelatedIdentities(int siteId, int relatedIdentity)
- {
- List relatedIdentities = GetChannelRelatedIdentities(siteId, relatedIdentity);
-
- return relatedIdentities;
- }
-
- public static List GetChannelRelatedIdentities(int siteId, int channelId)
- {
- var arraylist = new List();
- var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
- if (channelInfo != null)
- {
- var channelIdCollection = "0," + channelInfo.Id;
- if (channelInfo.ParentsCount > 0)
- {
- channelIdCollection = "0," + channelInfo.ParentsPath + "," + channelInfo.Id;
- }
-
- arraylist = TranslateUtils.StringCollectionToIntList(channelIdCollection);
- arraylist.Reverse();
- }
- else
- {
- arraylist.Add(0);
- }
- return arraylist;
- }
-
- public static List GetTableStyleInfoList(SiteInfo siteInfo, int channelId)
- {
- List relatedIdentities = GetChannelRelatedIdentities(siteInfo.Id, channelId);
-
- var tableName = ChannelManager.GetTableName(siteInfo, channelId);
-
- return TableStyleManager.GetTableStyleInfoList(tableName, relatedIdentities);
- }
- }
-}
diff --git a/SiteServer.CMS/Core/RoleManager.cs b/SiteServer.CMS/Core/RoleManager.cs
deleted file mode 100644
index e0741649a..000000000
--- a/SiteServer.CMS/Core/RoleManager.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Web;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class RoleManager
- {
- private RoleManager() { }
-
- public static void CreatePredefinedRolesIfNotExists()
- {
- var allPredefinedRoles = EPredefinedRoleUtils.GetAllPredefinedRole();
- foreach (var enumRole in allPredefinedRoles)
- {
- if (!DataProvider.RoleDao.IsRoleExists(EPredefinedRoleUtils.GetValue(enumRole)))
- {
- DataProvider.RoleDao.InsertRole(EPredefinedRoleUtils.GetValue(enumRole), string.Empty, EPredefinedRoleUtils.GetText(enumRole));
- }
- }
- }
-
- public static void DeleteCookie()
- {
- var current = HttpContext.Current;
- if ((current != null) && current.Request.Browser.Cookies)
- {
- var text = string.Empty;
- if (current.Request.Browser["supportsEmptyStringInCookieValue"] == "false")
- {
- text = "NoCookie";
- }
- var cookie = new HttpCookie(CookieName, text)
- {
- Path = "/",
- Domain = string.Empty,
- Expires = new DateTime(0x7cf, 10, 12),
- Secure = false
- };
- current.Response.Cookies.Remove(CookieName);
- current.Response.Cookies.Add(cookie);
- }
- }
-
- public const string CookieName = "BAIRONG.ROLES";
- public const int CookieTimeout = 90;
- public const string CookiePath = "/";
- public const bool CookieSlidingExpiration = true;
- public const int MaxCachedResults = 1000;
- public const string Domain = "";
- public const bool CreatePersistentCookie = true;
- public const bool CookieRequireSsl = false;
- public const bool CacheRolesInCookie = true;
- }
-}
diff --git a/SiteServer.CMS/Core/SiteManager.cs b/SiteServer.CMS/Core/SiteManager.cs
deleted file mode 100644
index bd65db3c8..000000000
--- a/SiteServer.CMS/Core/SiteManager.cs
+++ /dev/null
@@ -1,439 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web.UI.WebControls;
-using SiteServer.Utils;
-using SiteServer.Utils.IO;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Core
-{
- public static class SiteManager
- {
- private static class SiteManagerCache
- {
- private static readonly object LockObject = new object();
- private const string CacheKey = "SiteServer.CMS.Core.SiteManager";
- private static readonly FileWatcherClass FileWatcher;
-
- static SiteManagerCache()
- {
- FileWatcher = new FileWatcherClass(FileWatcherClass.Site);
- FileWatcher.OnFileChange += FileWatcher_OnFileChange;
- }
-
- private static void FileWatcher_OnFileChange(object sender, EventArgs e)
- {
- CacheUtils.Remove(CacheKey);
- }
-
- public static void Clear()
- {
- CacheUtils.Remove(CacheKey);
- FileWatcher.UpdateCacheFile();
- }
-
- public static List> GetSiteInfoKeyValuePairList()
- {
- var retval = CacheUtils.Get>>(CacheKey);
- if (retval != null) return retval;
-
- lock (LockObject)
- {
- retval = CacheUtils.Get>>(CacheKey);
- if (retval == null)
- {
- var list = DataProvider.SiteDao.GetSiteInfoKeyValuePairList();
- retval = new List>();
- foreach (var pair in list)
- {
- var siteInfo = pair.Value;
- if (siteInfo == null) continue;
-
- siteInfo.SiteDir = GetSiteDir(list, siteInfo);
- retval.Add(pair);
- }
-
- CacheUtils.Insert(CacheKey, retval);
- }
- }
-
- return retval;
- }
- }
-
- public static void ClearCache()
- {
- SiteManagerCache.Clear();
- }
-
- public static List GetSiteInfoList()
- {
- var pairList = SiteManagerCache.GetSiteInfoKeyValuePairList();
- return pairList.Select(pair => pair.Value).ToList();
- }
-
- public static SiteInfo GetSiteInfo(int siteId)
- {
- if (siteId <= 0) return null;
-
- var list = SiteManagerCache.GetSiteInfoKeyValuePairList();
-
- foreach (var pair in list)
- {
- var theSiteId = pair.Key;
- if (theSiteId != siteId) continue;
- var siteInfo = pair.Value;
- return siteInfo;
- }
- return null;
- }
-
- public static SiteInfo GetSiteInfoBySiteName(string siteName)
- {
- var list = SiteManagerCache.GetSiteInfoKeyValuePairList();
-
- foreach (var pair in list)
- {
- var siteInfo = pair.Value;
- if (siteInfo == null) continue;
-
- if (StringUtils.EqualsIgnoreCase(siteInfo.SiteName, siteName))
- {
- return siteInfo;
- }
- }
- return null;
- }
-
- public static SiteInfo GetSiteInfoByDirectory(string siteDir)
- {
- var list = SiteManagerCache.GetSiteInfoKeyValuePairList();
-
- foreach (var pair in list)
- {
- var siteInfo = pair.Value;
- if (siteInfo == null) continue;
-
- if (StringUtils.EqualsIgnoreCase(siteInfo.SiteDir, siteDir))
- {
- return siteInfo;
- }
- }
- return null;
- }
-
- public static List GetSiteIdList()
- {
- var pairList = SiteManagerCache.GetSiteInfoKeyValuePairList();
- var list = new List();
- foreach (var pair in pairList)
- {
- list.Add(pair.Key);
- }
- return list;
- }
-
- public static List GetSiteIdListOrderByLevel()
- {
- var retval = new List();
-
- var siteIdList = GetSiteIdList();
- var siteInfoList = new List();
- var parentWithChildren = new Hashtable();
- var hqSiteId = 0;
- foreach (var siteId in siteIdList)
- {
- var siteInfo = GetSiteInfo(siteId);
- if (siteInfo.IsRoot)
- {
- hqSiteId = siteInfo.Id;
- }
- else
- {
- if (siteInfo.ParentId == 0)
- {
- siteInfoList.Add(siteInfo);
- }
- else
- {
- var children = new List();
- if (parentWithChildren.Contains(siteInfo.ParentId))
- {
- children = (List)parentWithChildren[siteInfo.ParentId];
- }
- children.Add(siteInfo);
- parentWithChildren[siteInfo.ParentId] = children;
- }
- }
- }
-
- if (hqSiteId > 0)
- {
- retval.Add(hqSiteId);
- }
- foreach (var siteInfo in siteInfoList)
- {
- AddSiteIdList(retval, siteInfo, parentWithChildren, 0);
- }
- return retval;
- }
-
- private static void AddSiteIdList(List dataSource, SiteInfo siteInfo, Hashtable parentWithChildren, int level)
- {
- dataSource.Add(siteInfo.Id);
-
- if (parentWithChildren[siteInfo.Id] != null)
- {
- var children = (List)parentWithChildren[siteInfo.Id];
- level++;
- foreach (var subSiteInfo in children)
- {
- AddSiteIdList(dataSource, subSiteInfo, parentWithChildren, level);
- }
- }
- }
-
- public static void GetAllParentSiteIdList(List parentSiteIds, List siteIdCollection, int siteId)
- {
- var siteInfo = GetSiteInfo(siteId);
- var parentSiteId = -1;
- foreach (var psId in siteIdCollection)
- {
- if (psId != siteInfo.ParentId) continue;
- parentSiteId = psId;
- break;
- }
- if (parentSiteId == -1) return;
-
- parentSiteIds.Add(parentSiteId);
- GetAllParentSiteIdList(parentSiteIds, siteIdCollection, parentSiteId);
- }
-
- public static bool IsExists(int siteId)
- {
- if (siteId == 0) return false;
- return GetSiteInfo(siteId) != null;
- }
-
- public static List GetTableNameList(SiteInfo siteInfo)
- {
- return new List
- {
- siteInfo.TableName
- };
- }
-
- //public static ETableStyle GetTableStyle(SiteInfo siteInfo, string tableName)
- //{
- // var tableStyle = ETableStyle.Custom;
-
- // if (StringUtils.EqualsIgnoreCase(tableName, siteInfo.AuxiliaryTableForContent))
- // {
- // tableStyle = ETableStyle.BackgroundContent;
- // }
- // else if (StringUtils.EqualsIgnoreCase(tableName, DataProvider.SiteDao.TableName))
- // {
- // tableStyle = ETableStyle.Site;
- // }
- // else if (StringUtils.EqualsIgnoreCase(tableName, DataProvider.ChannelDao.TableName))
- // {
- // tableStyle = ETableStyle.Channel;
- // }
- // //else if (StringUtils.EqualsIgnoreCase(tableName, DataProvider.InputContentDao.TableName))
- // //{
- // // tableStyle = ETableStyle.InputContent;
- // //}
- // return tableStyle;
- //}
-
- public static int GetSiteLevel(int siteId)
- {
- var level = 0;
- var siteInfo = GetSiteInfo(siteId);
- if (siteInfo.ParentId != 0)
- {
- level++;
- level += GetSiteLevel(siteInfo.ParentId);
- }
- return level;
- }
-
- public static void AddListItems(ListControl listControl)
- {
- var siteIdList = GetSiteIdList();
- var mySystemInfoList = new List();
- var parentWithChildren = new Hashtable();
- SiteInfo hqSiteInfo = null;
- foreach (var siteId in siteIdList)
- {
- var siteInfo = GetSiteInfo(siteId);
- if (siteInfo.IsRoot)
- {
- hqSiteInfo = siteInfo;
- }
- else
- {
- if (siteInfo.ParentId == 0)
- {
- mySystemInfoList.Add(siteInfo);
- }
- else
- {
- var children = new List();
- if (parentWithChildren.Contains(siteInfo.ParentId))
- {
- children = (List)parentWithChildren[siteInfo.ParentId];
- }
- children.Add(siteInfo);
- parentWithChildren[siteInfo.ParentId] = children;
- }
- }
- }
- if (hqSiteInfo != null)
- {
- AddListItem(listControl, hqSiteInfo, parentWithChildren, 0);
- }
- foreach (var siteInfo in mySystemInfoList)
- {
- AddListItem(listControl, siteInfo, parentWithChildren, 0);
- }
- }
-
- private static void AddListItem(ListControl listControl, SiteInfo siteInfo, Hashtable parentWithChildren, int level)
- {
- var padding = string.Empty;
- for (var i = 0; i < level; i++)
- {
- padding += " ";
- }
- if (level > 0)
- {
- padding += "└ ";
- }
-
- if (parentWithChildren[siteInfo.Id] != null)
- {
- var children = (List)parentWithChildren[siteInfo.Id];
- listControl.Items.Add(new ListItem(padding + siteInfo.SiteName + $"({children.Count})", siteInfo.Id.ToString()));
- level++;
- foreach (SiteInfo subSiteInfo in children)
- {
- AddListItem(listControl, subSiteInfo, parentWithChildren, level);
- }
- }
- else
- {
- listControl.Items.Add(new ListItem(padding + siteInfo.SiteName, siteInfo.Id.ToString()));
- }
- }
-
- public static int GetParentSiteId(int siteId)
- {
- var parentSiteId = 0;
- var siteInfo = GetSiteInfo(siteId);
- if (siteInfo != null && siteInfo.IsRoot == false)
- {
- parentSiteId = siteInfo.ParentId;
- if (parentSiteId == 0)
- {
- parentSiteId = DataProvider.SiteDao.GetIdByIsRoot();
- }
- }
- return parentSiteId;
- }
-
- private static string GetSiteDir(List> listFromDb, SiteInfo siteInfo)
- {
- if (siteInfo == null || siteInfo.IsRoot) return string.Empty;
- if (siteInfo.ParentId != 0)
- {
- SiteInfo parent = null;
- foreach (var pair in listFromDb)
- {
- var theSiteId = pair.Key;
- if (theSiteId != siteInfo.ParentId) continue;
- parent = pair.Value;
- break;
- }
- return PathUtils.Combine(GetSiteDir(listFromDb, parent), PathUtils.GetDirectoryName(siteInfo.SiteDir, false));
- }
- return PathUtils.GetDirectoryName(siteInfo.SiteDir, false);
- }
-
- public static List GetWritingSiteInfoList(PermissionManager permissionManager)
- {
- var siteInfoList = new List();
-
- if (!string.IsNullOrEmpty(permissionManager.UserName))
- {
- var siteIdList = new List();
-
- if (permissionManager.IsConsoleAdministrator || permissionManager.IsSystemAdministrator)//如果是超级管理员或站点管理员
- {
- foreach (var itemForPsid in permissionManager.SiteIdList)
- {
- if (!siteIdList.Contains(itemForPsid))
- {
- var siteInfo = GetSiteInfo(itemForPsid);
- siteInfoList.Add(siteInfo);
- siteIdList.Add(itemForPsid);
- }
- }
- }
- else
- {
- foreach (var itemForPsid in permissionManager.SiteIdList)
- {
- if (!siteIdList.Contains(itemForPsid))
- {
- var channelIdCollection = DataProvider.SitePermissionsDao.GetAllPermissionList(permissionManager.Roles, itemForPsid, true);
- var siteInfo = GetSiteInfo(itemForPsid);
- if (channelIdCollection.Count > 0)
- {
- siteInfoList.Add(siteInfo);
- siteIdList.Add(itemForPsid);
- }
- }
- }
- }
- }
-
- return siteInfoList;
- }
-
- public static string GetSiteName(SiteInfo siteInfo)
- {
- var padding = string.Empty;
-
- var level = GetSiteLevel(siteInfo.Id);
- string psLogo;
- if (siteInfo.IsRoot)
- {
- psLogo = "siteHQ.gif";
- }
- else
- {
- psLogo = "site.gif";
- if (level > 0 && level < 10)
- {
- psLogo = $"subsite{level + 1}.gif";
- }
- }
- psLogo = SiteServerAssets.GetIconUrl("tree/" + psLogo);
-
- for (var i = 0; i < level; i++)
- {
- padding += " ";
- }
- if (level > 0)
- {
- padding += "└ ";
- }
-
- return $"{padding} {siteInfo.SiteName}";
- }
- }
-}
diff --git a/SiteServer.CMS/Core/SmsManager.cs b/SiteServer.CMS/Core/SmsManager.cs
deleted file mode 100644
index 9c173ee2d..000000000
--- a/SiteServer.CMS/Core/SmsManager.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Text;
-using System.Web;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class SmsManager
- {
- public static bool IsReady()
- {
- return ConfigManager.SystemConfigInfo.SmsProviderType == ESmsProviderType.Yunpian && !string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.SmsAppKey);
- }
-
- public static bool Send(string mobile, string tplId, Dictionary parameters, out string errorMessage)
- {
- if (string.IsNullOrEmpty(mobile) || !StringUtils.IsMobile(mobile))
- {
- errorMessage = "手机号码格式不正确";
- return false;
- }
-
- errorMessage = string.Empty;
- var isSuccess = false;
-
- if (ConfigManager.SystemConfigInfo.SmsProviderType == ESmsProviderType.Yunpian)
- {
- isSuccess = SendByYunpian(mobile, tplId, parameters, out errorMessage);
- }
-
- if (!isSuccess && string.IsNullOrEmpty(errorMessage))
- {
- errorMessage = "后台短信发送功能暂时无法使用,请联系管理员或稍后再试";
- }
-
- return isSuccess;
- }
-
- public static bool SendCode(string mobile, int code, string tplId, out string errorMessage)
- {
- var parameters = new Dictionary { { "code", code.ToString() } };
- return Send(mobile, tplId, parameters, out errorMessage);
- }
-
- private static bool SendByYunpian(string mobile, string tplId, Dictionary parameters, out string errorMessage)
- {
- var param = new StringBuilder();
- if (parameters != null)
- {
- foreach (var key in parameters.Keys)
- {
- var value = parameters[key] ?? string.Empty;
-
- param.Append(HttpUtility.UrlEncode("#" + key + "#", Encoding.UTF8) + "=" +
- HttpUtility.UrlEncode(value, Encoding.UTF8)).Append("&");
- }
- }
-
- param.Length--;
-
- mobile = HttpUtility.UrlEncode(mobile, Encoding.UTF8);
- //var tplValue = HttpUtility.UrlEncode(
- // HttpUtility.UrlEncode("#code#", Encoding.UTF8) + "=" +
- // HttpUtility.UrlEncode(code.ToString(), Encoding.UTF8)
- //, Encoding.UTF8);
- var tplValue = HttpUtility.UrlEncode(param.ToString(), Encoding.UTF8);
-
- return HttpPostToYunpian("https://sms.yunpian.com/v1/sms/tpl_send.json", "apikey=" + ConfigManager.SystemConfigInfo.SmsAppKey + "&mobile=" + mobile + "&tpl_id=" + tplId + "&tpl_value=" + tplValue, out errorMessage);
- }
-
- private static bool HttpPostToYunpian(string url, string data, out string errorMessage)
- {
- errorMessage = null;
- try
- {
- var dataArray = Encoding.UTF8.GetBytes(data);
-
- var request = (HttpWebRequest)WebRequest.Create(url);
- request.Method = "POST";
- request.ContentType = "application/x-www-form-urlencoded";
- request.ContentLength = dataArray.Length;
- var dataStream = request.GetRequestStream();
- dataStream.Write(dataArray, 0, dataArray.Length);
- dataStream.Close();
-
- var response = (HttpWebResponse)request.GetResponse();
- // ReSharper disable once AssignNullToNotNullAttribute
- var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
- reader.ReadToEnd();
- reader.Close();
- return true;
- }
- catch (Exception e)
- {
- errorMessage = e.Message;
- }
- return false;
- }
- }
-}
\ No newline at end of file
diff --git a/SiteServer.CMS/Core/SourceManager.cs b/SiteServer.CMS/Core/SourceManager.cs
deleted file mode 100644
index ebc990f85..000000000
--- a/SiteServer.CMS/Core/SourceManager.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-namespace SiteServer.CMS.Core
-{
- public class SourceManager
- {
- public const int CaiJi = -2; //采集
- public const int Preview = -99; //预览
- public const int Default = 0; //正常录入
-
- public static string GetSourceName(int sourceId)
- {
- if (sourceId == Default)
- {
- return "正常录入";
- }
- if (sourceId == CaiJi)
- {
- return "系统采集";
- }
- if (sourceId == Preview)
- {
- return "预览插入";
- }
- if (sourceId <= 0) return string.Empty;
-
- var siteId = DataProvider.ChannelDao.GetSiteId(sourceId);
- var siteInfo = SiteManager.GetSiteInfo(siteId);
- if (siteInfo == null) return "内容转移";
-
- var nodeNames = ChannelManager.GetChannelNameNavigation(siteId, sourceId);
- if (!string.IsNullOrEmpty(nodeNames))
- {
- return siteInfo.SiteName + ":" + nodeNames;
- }
- return siteInfo.SiteName;
- }
- }
-}
diff --git a/SiteServer.CMS/Core/SystemManager.cs b/SiteServer.CMS/Core/SystemManager.cs
deleted file mode 100644
index 0561ed61a..000000000
--- a/SiteServer.CMS/Core/SystemManager.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Reflection;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Core
-{
- public class SystemManager
- {
- static SystemManager()
- {
- Version = FileVersionInfo.GetVersionInfo(PathUtils.GetBinDirectoryPath("SiteServer.CMS.dll")).ProductVersion;
- PluginVersion = FileVersionInfo.GetVersionInfo(PathUtils.GetBinDirectoryPath("SiteServer.Plugin.dll")).ProductVersion;
-
- //var ssemblyName = assembly.GetName();
- //var assemblyVersion = ssemblyName.Version;
- //var version = assemblyVersion.ToString();
- //if (StringUtils.EndsWith(version, ".0"))
- //{
- // version = version.Substring(0, version.Length - 2);
- //}
- //Version = version;
- }
-
- public static string Version { get; }
-
- public static string PluginVersion { get; }
-
- public static void InstallDatabase(string adminName, string adminPassword)
- {
- SyncDatabase();
-
- if (!string.IsNullOrEmpty(adminName) && !string.IsNullOrEmpty(adminPassword))
- {
- RoleManager.CreatePredefinedRolesIfNotExists();
-
- var administratorInfo = new AdministratorInfo
- {
- UserName = adminName,
- Password = adminPassword
- };
-
- string errorMessage;
- AdminManager.CreateAdministrator(administratorInfo, out errorMessage);
- DataProvider.AdministratorsInRolesDao.AddUserToRole(adminName, EPredefinedRoleUtils.GetValue(EPredefinedRole.ConsoleAdministrator));
- }
- }
-
- public static void SyncDatabase()
- {
- CacheUtils.ClearAll();
-
- foreach (var provider in DataProvider.AllProviders)
- {
- if (string.IsNullOrEmpty(provider.TableName) || provider.TableColumns == null || provider.TableColumns.Count <= 0) continue;
-
- if (!DataProvider.DatabaseDao.IsTableExists(provider.TableName))
- {
- DataProvider.DatabaseDao.CreateSystemTable(provider.TableName, provider.TableColumns);
- }
- else
- {
- DataProvider.DatabaseDao.AlterSystemTable(provider.TableName, provider.TableColumns);
- }
- }
-
- var configInfo = DataProvider.ConfigDao.GetConfigInfo();
- if (configInfo == null)
- {
- configInfo = new ConfigInfo(true, Version, DateTime.Now, string.Empty);
- DataProvider.ConfigDao.Insert(configInfo);
- }
- else
- {
- configInfo.DatabaseVersion = Version;
- configInfo.IsInitialized = true;
- configInfo.UpdateDate = DateTime.Now;
- DataProvider.ConfigDao.Update(configInfo);
- }
-
- DataProvider.TableDao.CreateAllTableCollectionInfoIfNotExists();
- }
-
- public static bool IsNeedUpdate()
- {
- return !StringUtils.EqualsIgnoreCase(Version, DataProvider.ConfigDao.GetDatabaseVersion());
- }
-
- public static bool IsNeedInstall()
- {
- var isNeedInstall = !DataProvider.ConfigDao.IsInitialized();
- if (isNeedInstall)
- {
- isNeedInstall = !DataProvider.ConfigDao.IsInitialized();
- }
- return isNeedInstall;
- }
-
- public static bool DetermineRedirectToInstaller()
- {
- if (!IsNeedInstall()) return false;
- PageUtils.Redirect(PageUtils.GetAdminDirectoryUrl("Installer"));
- return true;
- }
- }
-}
diff --git a/SiteServer.CMS/Core/TabManager.cs b/SiteServer.CMS/Core/TabManager.cs
deleted file mode 100644
index 19dba6a11..000000000
--- a/SiteServer.CMS/Core/TabManager.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using SiteServer.Utils;
-using SiteServer.CMS.Plugin;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Core
-{
- public class TabManager
- {
- public static List GetTopMenuTabs()
- {
- var list = new List();
-
- var menuPath = PathUtils.GetMenusPath("Top.config");
- if (!FileUtils.IsFileExists(menuPath)) return list;
-
- var tabs = TabCollection.GetTabs(menuPath);
- foreach (var parent in tabs.Tabs)
- {
- list.Add(parent);
- }
-
- return list;
- }
-
- public static bool IsValid(Tab tab, IList permissionList)
- {
- if (tab.HasPermissions)
- {
- if (permissionList != null && permissionList.Count > 0)
- {
- var tabPermissions = tab.Permissions.Split(',');
- foreach (var tabPermission in tabPermissions)
- {
- if (permissionList.Contains(tabPermission))
- return true;
- }
- }
-
- //ITab valid, but invalid role set
- return false;
- }
-
- //ITab valid, but no roles
- return true;
- }
-
- private static Tab GetPluginTab(Menu menu, string permission)
- {
- var tab = new Tab
- {
- Id = menu.Id,
- Text = menu.Text,
- IconClass = menu.IconClass,
- Selected = false,
- Href = menu.Href,
- Target = menu.Target,
- Permissions = permission
- };
- if (menu.Menus != null && menu.Menus.Count > 0)
- {
- tab.Children = new Tab[menu.Menus.Count];
- for (var i = 0; i < menu.Menus.Count; i++)
- {
- tab.Children[i] = GetPluginTab(menu.Menus[i], permission);
- }
- }
- return tab;
- }
-
- public static List GetTabList(string topId, int siteId)
- {
- var tabs = new List();
-
- if (!string.IsNullOrEmpty(topId))
- {
- var filePath = PathUtils.GetMenusPath($"{topId}.config");
- var tabCollection = TabCollection.GetTabs(filePath);
- if (tabCollection?.Tabs != null)
- {
- foreach (var tabCollectionTab in tabCollection.Tabs)
- {
- tabs.Add(tabCollectionTab.Clone());
- }
- }
- }
-
- var menus = new Dictionary();
- if (siteId > 0 && topId == string.Empty)
- {
- var siteMenus = PluginMenuManager.GetSiteMenus(siteId);
- if (siteMenus != null)
- {
- foreach (var siteMenu in siteMenus)
- {
- menus.Add(siteMenu.Key, siteMenu.Value);
- }
- }
- }
- else if (topId == "Plugins")
- {
- var topMenus = PluginMenuManager.GetTopMenus();
- if (topMenus != null)
- {
- foreach (var topMenu in topMenus)
- {
- menus.Add(topMenu.Key, topMenu.Value);
- }
- }
- }
-
- foreach (var pluginId in menus.Keys)
- {
- var menu = menus[pluginId];
-
- var isExists = false;
- foreach (var childTab in tabs)
- {
- if (childTab.Id == menu.Id)
- {
- isExists = true;
- }
- }
-
- if (isExists) continue;
-
- tabs.Add(GetPluginTab(menu, pluginId));
-
- //if (string.IsNullOrEmpty(menu.ParentId))
- //{
- // var isExists = false;
- // foreach (var childTab in tabs)
- // {
- // if (childTab.Id == menu.Id)
- // {
- // isExists = true;
- // }
- // }
-
- // if (isExists) continue;
-
- // tabs.Add(GetPluginTab(menu));
- //}
- //else
- //{
- // foreach (var tab in tabs)
- // {
- // if (!StringUtils.EqualsIgnoreCase(menu.ParentId, tab.Id)) continue;
-
- // var isExists = false;
- // foreach (var childTab in tab.Children)
- // {
- // if (childTab.Id == menu.Id)
- // {
- // isExists = true;
- // }
- // }
-
- // if (isExists) continue;
-
- // var list = new List();
- // if (tab.Children != null)
- // {
- // list = tab.Children.ToList();
- // }
- // list.Add(GetPluginTab(menu));
- // tab.Children = list.ToArray();
- // }
- //}
- }
-
- return tabs;
- }
- }
-}
diff --git a/SiteServer.CMS/Core/TableColumnManager.cs b/SiteServer.CMS/Core/TableColumnManager.cs
deleted file mode 100644
index 92265b7b6..000000000
--- a/SiteServer.CMS/Core/TableColumnManager.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using System;
-using System.Collections.Generic;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Utils.IO;
-
-namespace SiteServer.CMS.Core
-{
- public sealed class TableColumnManager
- {
- private static class TableColumnManagerCache
- {
- private static readonly object LockObject = new object();
- private const string CacheKey = "BaiRong.Core.Table.TableColumnManager";
- private static readonly FileWatcherClass FileWatcher;
-
- static TableColumnManagerCache()
- {
- FileWatcher = new FileWatcherClass(FileWatcherClass.TableColumn);
- FileWatcher.OnFileChange += FileWatcher_OnFileChange;
- }
-
- private static void FileWatcher_OnFileChange(object sender, EventArgs e)
- {
- CacheUtils.Remove(CacheKey);
- }
-
- public static void Clear()
- {
- CacheUtils.Remove(CacheKey);
- FileWatcher.UpdateCacheFile();
- }
-
- private static void Update(Dictionary> allDict, List list,
- string key)
- {
- lock (LockObject)
- {
- allDict[key] = list;
- }
- }
-
- private static Dictionary> GetAllDictionary()
- {
- var allDict = CacheUtils.Get(CacheKey) as Dictionary>;
- if (allDict != null) return allDict;
-
- allDict = new Dictionary>();
- CacheUtils.InsertHours(CacheKey, allDict, 24);
- return allDict;
- }
-
- public static List GetTableColumnInfoListLowercase(string tableName)
- {
- var allDict = GetAllDictionary();
-
- List list;
- allDict.TryGetValue(tableName, out list);
-
- if (list != null) return list;
-
- list = DataProvider.DatabaseDao.GetTableColumnInfoListLowercase(WebConfigUtils.ConnectionString, tableName);
- Update(allDict, list, tableName);
- return list;
- }
- }
-
- public static List GetTableColumnInfoListLowercase(string tableName, List excludeAttributeNameListLowercase = null)
- {
- var list = TableColumnManagerCache.GetTableColumnInfoListLowercase(tableName);
- if (excludeAttributeNameListLowercase == null || excludeAttributeNameListLowercase.Count == 0) return list;
-
- var retval = new List();
- foreach (var tableColumnInfo in list)
- {
- if (!excludeAttributeNameListLowercase.Contains(tableColumnInfo.ColumnName.ToLower()))
- {
- retval.Add(tableColumnInfo);
- }
- }
-
- return retval;
- }
-
- public static List GetTableColumnNameListLowercase(string tableName, List excludeAttributeNameListLowercase = null)
- {
- var allTableColumnInfoList = GetTableColumnInfoListLowercase(tableName, excludeAttributeNameListLowercase);
-
- var columnNameList = new List();
-
- foreach (var tableColumnInfo in allTableColumnInfoList)
- {
- columnNameList.Add(tableColumnInfo.ColumnName);
- }
-
- return columnNameList;
- }
-
- public static void ClearCache()
- {
- TableColumnManagerCache.Clear();
- }
- }
-
-}
diff --git a/SiteServer.CMS/Core/TableMetadataManager.cs b/SiteServer.CMS/Core/TableMetadataManager.cs
deleted file mode 100644
index 11a4b90f6..000000000
--- a/SiteServer.CMS/Core/TableMetadataManager.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using SiteServer.CMS.Model;
-using SiteServer.Utils;
-using SiteServer.Utils.IO;
-
-namespace SiteServer.CMS.Core
-{
- public sealed class TableMetadataManager
- {
- private static class TableMetadataManagerCache
- {
- private static readonly object LockObject = new object();
- private const string CacheKey = "BaiRong.Core.Table.TableMetadataManager";
- private static readonly FileWatcherClass FileWatcher;
-
- static TableMetadataManagerCache()
- {
- FileWatcher = new FileWatcherClass(FileWatcherClass.TableMetadata);
- FileWatcher.OnFileChange += FileWatcher_OnFileChange;
- }
-
- private static void FileWatcher_OnFileChange(object sender, EventArgs e)
- {
- CacheUtils.Remove(CacheKey);
- }
-
- public static void Clear()
- {
- CacheUtils.Remove(CacheKey);
- FileWatcher.UpdateCacheFile();
- }
-
- public static Dictionary> GetTableNameWithTableMetadataInfoDictionary()
- {
- var retval = CacheUtils.Get>>(CacheKey);
- if (retval != null) return retval;
-
- lock (LockObject)
- {
- retval = CacheUtils.Get>>(CacheKey);
- if (retval == null)
- {
- retval = DataProvider.TableMetadataDao.GetTableNameWithTableMetadataInfoList();
- CacheUtils.InsertHours(CacheKey, retval, 24);
- }
- }
-
- return retval;
- }
- }
-
- public static void ClearCache()
- {
- TableMetadataManagerCache.Clear();
- }
-
- public static List GetAllLowerAttributeNameList(string tableName)
- {
- var list = new List();
- list.AddRange(ContentAttribute.AllAttributesLowercase);
- list.AddRange(GetAttributeNameList(tableName, true));
- return list;
- }
-
- ///
- /// 得到辅助表tableName数据库中的字段名称的集合
- ///
- public static List GetAttributeNameList(string tableName, bool toLower)
- {
- var tableMetadataInfoList = GetTableMetadataInfoList(tableName);
- return tableMetadataInfoList.Select(tableMetadataInfo => toLower ? tableMetadataInfo.AttributeName.ToLower() : tableMetadataInfo.AttributeName).ToList();
- }
-
- ///
- /// 得到辅助表的所有字段名称的集合
- ///
- public static List GetAttributeNameList(string tableName)
- {
- return GetAttributeNameList(tableName, false);
- }
-
- public static bool IsAttributeNameExists(string tableName, string attributeName)
- {
- var list = GetAttributeNameList(tableName, true);
- return list.Contains(attributeName.ToLower());
- }
-
- public static List GetTableMetadataInfoList(string tableName)
- {
- var dict = TableMetadataManagerCache.GetTableNameWithTableMetadataInfoDictionary();
- List additionMetadataList;
- if (!dict.TryGetValue(tableName, out additionMetadataList)) return new List();
-
- if (additionMetadataList == null || additionMetadataList.Count <= 0) return new List();
-
- var metadataList = new List();
- var attributeNames = new List();
- foreach (var metadataInfo in additionMetadataList)
- {
- if (attributeNames.Contains(metadataInfo.AttributeName.ToLower()) ||
- ContentAttribute.AllAttributesLowercase.Contains(metadataInfo.AttributeName.ToLower()))
- continue;
-
- attributeNames.Add(metadataInfo.AttributeName.ToLower());
- metadataList.Add(metadataInfo);
- }
-
- return metadataList;
- }
-
- public static TableMetadataInfo GetTableMetadataInfo(string tableName, string attributeName)
- {
- var list = GetTableMetadataInfoList(tableName);
- foreach (var tableMetadataInfo in list)
- {
- if (StringUtils.EqualsIgnoreCase(tableMetadataInfo.AttributeName, attributeName))
- {
- return tableMetadataInfo;
- }
- }
- return null;
- }
-
- public static string GetTableMetadataDataType(string tableName, string attributeName)
- {
- var metadataInfo = GetTableMetadataInfo(tableName, attributeName);
- if (metadataInfo != null)
- {
- return DataTypeUtils.GetText(metadataInfo.DataType);
- }
- return string.Empty;
- }
-
- public static int GetTableMetadataId(string tableName, string attributeName)
- {
- var metadataId = 0;
- var list = GetTableMetadataInfoList(tableName);
- foreach (var tableMetadataInfo in list)
- {
- if (StringUtils.EqualsIgnoreCase(tableMetadataInfo.AttributeName, attributeName))
- {
- metadataId = tableMetadataInfo.Id;
- break;
- }
- }
- return metadataId;
- }
-
- public static string GetSerializedString(string tableName)
- {
- var builder = new StringBuilder();
- var list = GetTableMetadataInfoList(tableName);
- var sortedlist = new SortedList();
- foreach (var metadataInfo in list)
- {
- if (metadataInfo.IsSystem == false)
- {
- /*
- * AttributeName,
- * DataType,
- * DataLength,
- * CanBeNull,
- * DBDefaultValue
- * */
- string serialize =
- $"AttributeName:{metadataInfo.AttributeName};DataType:{metadataInfo.DataType.Value};DataLength={metadataInfo.DataLength}";
- sortedlist.Add(metadataInfo.AttributeName, serialize);
- }
- }
-
- foreach (string attributeName in sortedlist.Keys)
- {
- builder.Append(sortedlist[attributeName]);
- }
-
- return builder.ToString();
- }
-
- public static string GetTableNameOfArchive(string tableName)
- {
- return tableName + "_Archive";
- }
- }
-
-}
diff --git a/SiteServer.CMS/Core/TableStyleManager.cs b/SiteServer.CMS/Core/TableStyleManager.cs
deleted file mode 100644
index e5b29ac14..000000000
--- a/SiteServer.CMS/Core/TableStyleManager.cs
+++ /dev/null
@@ -1,401 +0,0 @@
-using System.Collections.Generic;
-using System.Text;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Core
-{
- public sealed class TableStyleManager
- {
- private static readonly object LockObject = new object();
- private static bool _async = true;//缓存与数据库不同步
- private const string CacheKey = "BaiRong.Core.Table.TableStyleManager";
-
- public static PairList GetAllTableStyleInfoPairs()
- {
- lock (LockObject)
- {
- if (!_async && CacheUtils.Get(CacheKey) != null) return (PairList) CacheUtils.Get(CacheKey);
-
- var entries = DataProvider.TableStyleDao.GetAllTableStyleInfoPairs();
- CacheUtils.Insert(CacheKey, entries);
- _async = false;
- return entries;
- }
- }
-
- public static List GetTableStyleInfoList(string tableName, List relatedIdentities)
- {
- var allAttributeNames = new List();
- var styleInfoList = new List();
-
- var entries = GetAllTableStyleInfoPairs();
- relatedIdentities = GetRelatedIdentities(relatedIdentities);
- foreach (var relatedIdentity in relatedIdentities)
- {
- var startKey = GetCacheKeyStart(relatedIdentity, tableName);
- var keyList = entries.GetKeys(startKey);
- foreach (var key in keyList)
- {
- var styleInfo = entries.GetValue(key) as TableStyleInfo;
- if (styleInfo == null) continue;
-
- if (!allAttributeNames.Contains(styleInfo.AttributeName.ToLower()))
- {
- allAttributeNames.Add(styleInfo.AttributeName.ToLower());
- styleInfoList.Add(styleInfo);
- }
- }
- }
-
- var attributeNames = TableMetadataManager.GetAttributeNameList(tableName);
- foreach (var attributeName in attributeNames)
- {
- if (!allAttributeNames.Contains(attributeName.ToLower()))
- {
- allAttributeNames.Add(attributeName.ToLower());
-
- styleInfoList.Add(GetDefaultTableStyleInfo(tableName, attributeName));
- }
- }
-
- styleInfoList.Sort();
-
- return styleInfoList;
- }
-
- public static IAttributes GetDefaultAttributes(List styleInfoList)
- {
- var attributes = new ExtendedAttributes();
-
- foreach (var styleInfo in styleInfoList)
- {
- var defaultValue = string.Empty;
- if (!string.IsNullOrEmpty(styleInfo.DefaultValue))
- {
- defaultValue = styleInfo.DefaultValue;
- }
- else if (styleInfo.StyleItems != null)
- {
- var defaultValues = new List();
- foreach (var styleItem in styleInfo.StyleItems)
- {
- if (styleItem.IsSelected)
- {
- defaultValues.Add(styleItem.ItemValue);
- }
- }
- if (defaultValues.Count > 0)
- {
- defaultValue = TranslateUtils.ObjectCollectionToString(defaultValues);
- }
- }
-
- if (!string.IsNullOrEmpty(defaultValue))
- {
- attributes.Set(styleInfo.AttributeName, defaultValue);
- }
- }
-
- return attributes;
- }
-
- public static bool IsExistsInParents(List relatedIdentities, string tableName, string attributeName)
- {
- var entries = GetAllTableStyleInfoPairs();
- for (var i = 1; i < relatedIdentities.Count - 1; i++)
- {
- var relatedIdentity = relatedIdentities[i];
- var startKey = GetCacheKeyStart(relatedIdentity, tableName);
- var keyArrayList = entries.GetKeys(startKey);
- foreach (string key in keyArrayList)
- {
- var styleInfo = entries.GetValue(key) as TableStyleInfo;
- if (styleInfo != null && styleInfo.AttributeName == attributeName)
- {
- return true;
- }
- }
- }
- return false;
- }
-
- public static bool IsChanged
- {
- set
- {
- lock (LockObject)
- {
- if (value)
- {
- CacheUtils.Remove(CacheKey);
- }
- _async = value;
- }
- }
- }
-
- public static string GetCacheKey(int relatedIdentity, string tableName, string attributeName)
- {
- return $"{relatedIdentity}${tableName}${attributeName}".ToLower();
- }
-
- public static string GetCacheKeyStart(int relatedIdentity, string tableName)
- {
- return $"{relatedIdentity}${tableName}$".ToLower();
- }
-
- //relatedIdentities从大到小,最后是0
- public static TableStyleInfo GetTableStyleInfo(string tableName, string attributeName, List relatedIdentities)
- {
- TableStyleInfo styleInfo = null;
- if (attributeName == null) attributeName = string.Empty;
-
- relatedIdentities = GetRelatedIdentities(relatedIdentities);
-
- var entries = GetAllTableStyleInfoPairs();
-
- foreach (var relatedIdentity in relatedIdentities)
- {
- var key = GetCacheKey(relatedIdentity, tableName, attributeName);
- if (entries.ContainsKey(key))
- {
- styleInfo = entries.GetValue(key) as TableStyleInfo;
- if (styleInfo != null)
- {
- break;
- }
- }
- }
-
- return styleInfo ?? GetDefaultTableStyleInfo(tableName, attributeName);
- }
-
- private static List GetRelatedIdentities(IReadOnlyCollection list)
- {
- var relatedIdentities = new List();
-
- if (list != null && list.Count > 0)
- {
- foreach (var i in list)
- {
- if (!relatedIdentities.Contains(i))
- {
- relatedIdentities.Add(i);
- }
- }
- }
-
- relatedIdentities.Sort();
- relatedIdentities.Reverse();
-
- if (!relatedIdentities.Contains(0))
- {
- relatedIdentities.Add(0);
- }
-
- return relatedIdentities;
- }
-
- public static int Insert(TableStyleInfo styleInfo)
- {
- var tableStyleId = DataProvider.TableStyleDao.Insert(styleInfo);
- IsChanged = true;
- return tableStyleId;
- }
-
- public static void Update(TableStyleInfo info)
- {
- DataProvider.TableStyleDao.Update(info);
- IsChanged = true;
- }
-
- public static void DeleteAndInsertStyleItems(int tableStyleId, List styleItems)
- {
- if (styleItems == null || styleItems.Count <= 0) return;
-
- DataProvider.TableStyleItemDao.DeleteStyleItems(tableStyleId);
- DataProvider.TableStyleItemDao.InsertStyleItems(styleItems);
- }
-
- public static void Delete(int relatedIdentity, string tableName, string attributeName)
- {
- DataProvider.TableStyleDao.Delete(relatedIdentity, tableName, attributeName);
- IsChanged = true;
- }
-
- public static bool IsExists(int relatedIdentity, string tableName, string attributeName)
- {
- var key = GetCacheKey(relatedIdentity, tableName, attributeName);
- var entries = GetAllTableStyleInfoPairs();
- return entries.Keys.Contains(key);
- }
-
- //public static DataSet GetStyleItemDataSet(int styleItemCount, List styleItemInfoList)
- //{
- // var dataset = new DataSet();
-
- // var dataTable = new DataTable("StyleItems");
-
- // dataTable.Columns.Add(new DataColumn
- // {
- // DataType = System.Type.GetType("System.Int32"),
- // ColumnName = "TableStyleItemID"
- // });
-
- // dataTable.Columns.Add(new DataColumn
- // {
- // DataType = System.Type.GetType("System.Int32"),
- // ColumnName = "TableStyleID"
- // });
-
- // dataTable.Columns.Add(new DataColumn
- // {
- // DataType = System.Type.GetType("System.String"),
- // ColumnName = "ItemTitle"
- // });
-
- // dataTable.Columns.Add(new DataColumn
- // {
- // DataType = System.Type.GetType("System.String"),
- // ColumnName = "ItemValue"
- // });
-
- // dataTable.Columns.Add(new DataColumn
- // {
- // DataType = System.Type.GetType("System.String"),
- // ColumnName = "IsSelected"
- // });
-
- // for (var i = 0; i < styleItemCount; i++)
- // {
- // var dataRow = dataTable.NewRow();
-
- // var itemInfo = styleItemInfoList != null && styleItemInfoList.Count > i ? styleItemInfoList[i] : new TableStyleItemInfo();
-
- // dataRow["TableStyleItemID"] = itemInfo.TableStyleItemId;
- // dataRow["TableStyleID"] = itemInfo.TableStyleId;
- // dataRow["ItemTitle"] = itemInfo.ItemTitle;
- // dataRow["ItemValue"] = itemInfo.ItemValue;
- // dataRow["IsSelected"] = itemInfo.IsSelected.ToString();
-
- // dataTable.Rows.Add(dataRow);
- // }
-
- // dataset.Tables.Add(dataTable);
- // return dataset;
- //}
-
- public static Dictionary> GetTableStyleInfoWithItemsDictinary(string tableName, List allRelatedIdentities)
- {
- var dict = new Dictionary>();
-
- var entries = GetAllTableStyleInfoPairs();
- foreach (var key in entries.Keys)
- {
- var identityFromKey = TranslateUtils.ToInt(key.Split('$')[0]);
- var tableNameFromKey = key.Split('$')[1];
- if (!StringUtils.EqualsIgnoreCase(tableNameFromKey, tableName) ||
- !allRelatedIdentities.Contains(identityFromKey)) continue;
-
- var styleInfo = (TableStyleInfo)entries.GetValue(key);
- if (InputTypeUtils.IsWithStyleItems(styleInfo.InputType))
- {
- styleInfo.StyleItems = DataProvider.TableStyleItemDao.GetStyleItemInfoList(styleInfo.Id);
- }
- var tableStyleInfoWithItemList = dict.ContainsKey(styleInfo.AttributeName) ? dict[styleInfo.AttributeName] : new List();
- tableStyleInfoWithItemList.Add(styleInfo);
- dict[styleInfo.AttributeName] = tableStyleInfoWithItemList;
- }
-
- return dict;
- }
-
- public static string GetValidateInfo(TableStyleInfo styleInfo)
- {
- var builder = new StringBuilder();
- if (styleInfo.Additional.IsRequired)
- {
- builder.Append("必填项;");
- }
- if (styleInfo.Additional.MinNum > 0)
- {
- builder.Append($"最少{styleInfo.Additional.MinNum}个字符;");
- }
- if (styleInfo.Additional.MaxNum > 0)
- {
- builder.Append($"最多{styleInfo.Additional.MaxNum}个字符;");
- }
- if (styleInfo.Additional.ValidateType != ValidateType.None)
- {
- builder.Append($"验证:{ValidateTypeUtils.GetText(styleInfo.Additional.ValidateType)};");
- }
-
- if (builder.Length > 0)
- {
- builder.Length = builder.Length - 1;
- }
- else
- {
- builder.Append("无验证");
- }
- return builder.ToString();
- }
-
- public static TableStyleInfo GetDefaultTableStyleInfo(string tableName, string attributeName)
- {
- var lowerAttributeName = attributeName.ToLower();
- var styleInfo = new TableStyleInfo(0, 0, tableName, attributeName, 0, attributeName, string.Empty, false, InputType.Text, string.Empty, true, string.Empty);
-
- if (lowerAttributeName == BackgroundContentAttribute.SubTitle.ToLower())
- {
- styleInfo.DisplayName = "副标题";
- styleInfo.Taxis = 1;
- }
- else if (lowerAttributeName == BackgroundContentAttribute.ImageUrl.ToLower())
- {
- styleInfo.DisplayName = "图片";
- styleInfo.InputType = InputType.Image;
- styleInfo.Taxis = 2;
- }
- else if (lowerAttributeName == BackgroundContentAttribute.VideoUrl.ToLower())
- {
- styleInfo.DisplayName = "视频";
- styleInfo.InputType = InputType.Video;
- styleInfo.Taxis = 3;
- }
- else if (lowerAttributeName == BackgroundContentAttribute.FileUrl.ToLower())
- {
- styleInfo.DisplayName = "附件";
- styleInfo.InputType = InputType.File;
- styleInfo.Taxis = 4;
- }
- else if (lowerAttributeName == BackgroundContentAttribute.Content.ToLower())
- {
- styleInfo.DisplayName = "内容";
- styleInfo.InputType = InputType.TextEditor;
- styleInfo.Taxis = 5;
- }
- else if (lowerAttributeName == BackgroundContentAttribute.Summary.ToLower())
- {
- styleInfo.DisplayName = "内容摘要";
- styleInfo.InputType = InputType.TextArea;
- styleInfo.Taxis = 6;
- }
- else if (lowerAttributeName == BackgroundContentAttribute.Author.ToLower())
- {
- styleInfo.DisplayName = "作者";
- styleInfo.Taxis = 7;
- }
- else if (lowerAttributeName == BackgroundContentAttribute.Source.ToLower())
- {
- styleInfo.DisplayName = "来源";
- styleInfo.Taxis = 8;
- }
-
- return styleInfo;
- }
- }
-
-}
diff --git a/SiteServer.CMS/Core/TemplateTypeUtils.cs b/SiteServer.CMS/Core/TemplateTypeUtils.cs
deleted file mode 100644
index f85f797a2..000000000
--- a/SiteServer.CMS/Core/TemplateTypeUtils.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Web.UI.WebControls;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Core
-{
- public class TemplateTypeUtils
- {
- public static TemplateType GetEnumType(string typeStr)
- {
- var retval = TemplateType.IndexPageTemplate;
-
- if (Equals(TemplateType.ChannelTemplate, typeStr))
- {
- retval = TemplateType.ChannelTemplate;
- }
- else if (Equals(TemplateType.IndexPageTemplate, typeStr))
- {
- retval = TemplateType.IndexPageTemplate;
- }
- else if (Equals(TemplateType.ContentTemplate, typeStr))
- {
- retval = TemplateType.ContentTemplate;
- }
- else if (Equals(TemplateType.FileTemplate, typeStr))
- {
- retval = TemplateType.FileTemplate;
- }
- return retval;
- }
-
- public static bool Equals(TemplateType type, string typeStr)
- {
- if (string.IsNullOrEmpty(typeStr)) return false;
- if (string.Equals(type.Value.ToLower(), typeStr.ToLower()))
- {
- return true;
- }
- return false;
- }
-
- public static bool Equals(string typeStr, TemplateType type)
- {
- return Equals(type, typeStr);
- }
-
- public static ListItem GetListItem(TemplateType type, bool selected)
- {
- var item = new ListItem(GetText(type), type.Value);
- if (selected)
- {
- item.Selected = true;
- }
- return item;
- }
-
- public static void AddListItems(ListControl listControl)
- {
- if (listControl != null)
- {
- listControl.Items.Add(GetListItem(TemplateType.IndexPageTemplate, false));
- listControl.Items.Add(GetListItem(TemplateType.ChannelTemplate, false));
- listControl.Items.Add(GetListItem(TemplateType.ContentTemplate, false));
- listControl.Items.Add(GetListItem(TemplateType.FileTemplate, false));
- }
- }
-
- public static string GetText(TemplateType templateType)
- {
- if (templateType == TemplateType.IndexPageTemplate)
- {
- return "首页模板";
- }
- if (templateType == TemplateType.ChannelTemplate)
- {
- return "栏目模板";
- }
- if (templateType == TemplateType.ContentTemplate)
- {
- return "内容模板";
- }
- if (templateType == TemplateType.FileTemplate)
- {
- return "单页模板";
- }
-
- throw new Exception();
- }
- }
-}
diff --git a/SiteServer.CMS/Data/DataProviderBase.cs b/SiteServer.CMS/Data/DataProviderBase.cs
deleted file mode 100644
index d5149624d..000000000
--- a/SiteServer.CMS/Data/DataProviderBase.cs
+++ /dev/null
@@ -1,280 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Data;
-using System.Text;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Data
-{
- public class DataProviderBase
- {
- protected virtual string ConnectionString => WebConfigUtils.ConnectionString;
-
- public virtual string TableName => string.Empty;
-
- public virtual List TableColumns => null;
-
- protected IDbConnection GetConnection()
- {
- return SqlUtils.GetIDbConnection(WebConfigUtils.DatabaseType, ConnectionString);
- }
-
- protected IDbConnection GetConnection(string connectionString)
- {
- return SqlUtils.GetIDbConnection(WebConfigUtils.DatabaseType, connectionString);
- }
-
- protected IDbConnection GetConnection(DatabaseType databaseType, string connectionString)
- {
- return SqlUtils.GetIDbConnection(databaseType, connectionString);
- }
-
- protected IDbDataParameter GetParameter(string parameterName, DataType dataType, int value)
- {
- return SqlUtils.GetIDbDataParameter(parameterName, dataType, 0, value);
- }
-
- protected IDbDataParameter GetParameter(string parameterName, DataType dataType, bool value)
- {
- return SqlUtils.GetIDbDataParameter(parameterName, dataType, 0, value);
- }
-
- protected IDbDataParameter GetParameter(string parameterName, DataType dataType, decimal value)
- {
- return SqlUtils.GetIDbDataParameter(parameterName, dataType, 0, value);
- }
-
- protected IDbDataParameter GetParameter(string parameterName, DataType dataType, DateTime value)
- {
- return SqlUtils.GetIDbDataParameter(parameterName, dataType, 0, value);
- }
-
- protected IDbDataParameter GetParameter(string parameterName, DataType dataType, string value)
- {
- return SqlUtils.GetIDbDataParameter(parameterName, dataType, 0, value);
- }
-
- protected IDbDataParameter GetParameter(string parameterName, DataType dataType, int size, string value)
- {
- return SqlUtils.GetIDbDataParameter(parameterName, dataType, size, value);
- }
-
- protected IDbDataParameter GetParameter(string parameterName, DataType dataType, int size, decimal value)
- {
- return SqlUtils.GetIDbDataParameter(parameterName, dataType, size, value);
- }
-
- protected List GetInParameterList(string parameterName, DataType dataType, int dataLength, ICollection valueCollection, out string parameterNameList)
- {
- parameterNameList = string.Empty;
- if (valueCollection == null || valueCollection.Count <= 0) return new List();
-
- var parameterList = new List();
-
- var sbCondition = new StringBuilder();
- var i = 0;
- foreach (var obj in valueCollection)
- {
- i++;
-
- var value = obj.ToString();
- var parmName = parameterName + "_" + i;
-
- sbCondition.Append(parmName + ",");
-
- parameterList.Add(dataType == DataType.Integer
- ? GetParameter(parmName, dataType, value)
- : GetParameter(parmName, dataType, dataLength, value));
- }
-
- parameterNameList = sbCondition.ToString().TrimEnd(',');
-
- return parameterList;
- }
-
- protected IDataReader ExecuteReader(string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteReader(ConnectionString, commandText, commandParameters);
- }
-
-
- protected IDataReader ExecuteReader(string commandText)
- {
- return DataProvider.DataApi.ExecuteReader(ConnectionString, commandText);
- }
-
-
- protected IDataReader ExecuteReader(IDbConnection conn, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteReader(conn, commandText, commandParameters);
- }
-
-
- protected IDataReader ExecuteReader(IDbConnection conn, string commandText)
- {
- return DataProvider.DataApi.ExecuteReader(conn, commandText);
- }
-
-
- protected IDataReader ExecuteReader(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteReader(trans, commandText, commandParameters);
- }
-
-
- protected IDataReader ExecuteReader(IDbTransaction trans, string commandText)
- {
- return DataProvider.DataApi.ExecuteReader(trans, commandText);
- }
-
-
- protected IDataReader ExecuteReader(string connectionString, string commandText)
- {
- return DataProvider.DataApi.ExecuteReader(connectionString, commandText);
- }
-
- protected IDataReader ExecuteReader(string connectionString, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteReader(connectionString, commandText, commandParameters);
- }
-
-
- protected DataSet ExecuteDataset(string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteDataset(ConnectionString, commandText, commandParameters);
- }
-
-
- protected DataSet ExecuteDataset(string commandText)
- {
- return DataProvider.DataApi.ExecuteDataset(ConnectionString, commandText);
- }
-
- protected DataSet ExecuteDataset(string connectionString, string commandText)
- {
- return DataProvider.DataApi.ExecuteDataset(connectionString, commandText);
- }
-
- protected int ExecuteNonQuery(IDbConnection conn, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteNonQuery(conn, commandText, commandParameters);
- }
-
-
- protected int ExecuteNonQuery(IDbConnection conn, string commandText)
- {
- return DataProvider.DataApi.ExecuteNonQuery(conn, commandText);
- }
-
-
- protected int ExecuteNonQuery(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteNonQuery(trans, commandText, commandParameters);
- }
-
-
- protected int ExecuteNonQuery(IDbTransaction trans, string commandText)
- {
- return DataProvider.DataApi.ExecuteNonQuery(trans, commandText);
- }
-
- protected int ExecuteNonQuery(string connectionString, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteNonQuery(connectionString, commandText, commandParameters);
- }
-
- protected int ExecuteNonQuery(string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteNonQuery(ConnectionString, commandText, commandParameters);
- }
-
- protected int ExecuteNonQuery(string commandText)
- {
- return DataProvider.DataApi.ExecuteNonQuery(ConnectionString, commandText);
- }
-
- protected int ExecuteNonQueryAndReturnId(string tableName, string idColumnName, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteNonQueryAndReturnId(tableName, idColumnName, ConnectionString, commandText, commandParameters);
- }
-
- protected int ExecuteNonQueryAndReturnId(string tableName, string idColumnName, IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteNonQueryAndReturnId(tableName, idColumnName, trans, commandText, commandParameters);
- }
-
-
- protected object ExecuteScalar(IDbConnection conn, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteScalar(conn, commandText, commandParameters);
- }
-
- protected object ExecuteScalar(IDbConnection conn, string commandText)
- {
- return DataProvider.DataApi.ExecuteScalar(conn, commandText);
- }
-
- protected object ExecuteScalar(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteScalar(trans, commandText, commandParameters);
- }
-
- protected object ExecuteScalar(IDbTransaction trans, string commandText)
- {
- return DataProvider.DataApi.ExecuteScalar(trans, commandText);
- }
-
- protected object ExecuteScalar(string commandText, params IDataParameter[] commandParameters)
- {
- return DataProvider.DataApi.ExecuteScalar(ConnectionString, commandText, commandParameters);
- }
-
- protected object ExecuteScalar(string commandText)
- {
- return DataProvider.DataApi.ExecuteScalar(ConnectionString, commandText);
- }
-
- protected string GetString(IDataReader rdr, int i)
- {
- var value = rdr.IsDBNull(i) ? string.Empty : rdr.GetValue(i).ToString();
- if (!string.IsNullOrEmpty(value))
- {
- value = PageUtils.UnFilterSql(value);
- }
- if (WebConfigUtils.DatabaseType == DatabaseType.Oracle && value == SqlUtils.OracleEmptyValue)
- {
- value = string.Empty;
- }
- return value;
- }
-
- protected bool GetBool(IDataReader rdr, int i)
- {
- return !rdr.IsDBNull(i) && TranslateUtils.ToBool(rdr.GetValue(i).ToString());
- }
-
- protected int GetInt(IDataReader rdr, int i)
- {
- return rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i);
- }
-
- protected decimal GetDecimal(IDataReader rdr, int i)
- {
- return rdr.IsDBNull(i) ? 0 : rdr.GetDecimal(i);
- }
-
- protected double GetDouble(IDataReader rdr, int i)
- {
- return rdr.IsDBNull(i) ? 0 : rdr.GetDouble(i);
- }
-
- protected DateTime GetDateTime(IDataReader rdr, int i)
- {
- return rdr.IsDBNull(i) ? DateTime.Now : rdr.GetDateTime(i);
- }
- }
-}
diff --git a/SiteServer.CMS/Data/DbHelper.cs b/SiteServer.CMS/Data/DbHelper.cs
deleted file mode 100644
index 6023faff7..000000000
--- a/SiteServer.CMS/Data/DbHelper.cs
+++ /dev/null
@@ -1,2575 +0,0 @@
-// ===============================================================================
-// Microsoft Data Access Application Block for .NET 3.0
-//
-// AdoHelper.cs
-//
-// This file contains an abstract implementations of the AdoHelper class.
-//
-// For more information see the Documentation.
-// ===============================================================================
-// Release history
-// VERSION DESCRIPTION
-// 2.0 Added support for FillDataset, UpdateDataset and "Param" helper methods
-// 3.0 New abstract class supporting the same methods using ADO.NET interfaces
-//
-// ===============================================================================
-// Copyright (C) 2000-2001 Microsoft Corporation
-// All rights reserved.
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
-// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
-// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
-// FITNESS FOR A PARTICULAR PURPOSE.
-// ==============================================================================
-
-using System;
-using System.Collections;
-using System.Data;
-using System.Data.Common;
-using System.Reflection;
-using System.Xml;
-using SiteServer.CMS.Core;
-using SiteServer.Plugin;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Data
-{
- ///
- /// The AdoHelper class is intended to encapsulate high performance, scalable best practices for
- /// common data access uses. It uses the Abstract Factory pattern to be easily extensible
- /// to any ADO.NET provider. The current implementation provides helpers for SQL Server, ODBC,
- /// OLEDB, and Oracle.
- ///
- public abstract class DbHelper
- {
- ///
- /// This enum is used to indicate whether the connection was provided by the caller, or created by AdoHelper, so that
- /// we can set the appropriate CommandBehavior when calling ExecuteReader()
- ///
- protected enum AdoConnectionOwnership
- {
- /// Connection is owned and managed by ADOHelper
- Internal,
-
- /// Connection is owned and managed by the caller
- External
- }
-
- #region Declare members
-
- // necessary for handling the general case of needing event handlers for RowUpdating/ed events
- ///
- /// Internal handler used for bubbling up the event to the user
- ///
- protected RowUpdatingHandler MRowUpdating;
-
- ///
- /// Internal handler used for bubbling up the event to the user
- ///
- protected RowUpdatedHandler MRowUpdated;
-
- #endregion
-
- #region Provider specific abstract methods
-
- ///
- /// Returns an IDbConnection object for the given connection string
- ///
- /// The connection string to be used to create the connection
- /// An IDbConnection object
- /// Thrown if connectionString is null
- public abstract IDbConnection GetConnection(string connectionString);
-
- ///
- /// Returns an IDbDataAdapter object
- ///
- /// The IDbDataAdapter
- public abstract IDbDataAdapter GetDataAdapter();
-
- ///
- /// Calls the CommandBuilder.DeriveParameters method for the specified provider, doing any setup and cleanup necessary
- ///
- /// The IDbCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the IDbCommand.
- public abstract void DeriveParameters(IDbCommand cmd);
-
- ///
- /// Returns an IDataParameter object
- ///
- /// The IDataParameter object
- public abstract IDataParameter GetParameter();
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the provided IDbConnection.
- ///
- ///
- ///
- /// XmlReader r = helper.ExecuteXmlReader(command);
- ///
- /// The IDbCommand to execute
- /// An XmlReader containing the resultset generated by the command
- /// Thrown if command is null.
- public abstract XmlReader ExecuteXmlReader(IDbCommand cmd);
-
- ///
- /// Provider specific code to set up the updating/ed event handlers used by UpdateDataset
- ///
- /// DataAdapter to attach the event handlers to
- /// The handler to be called when a row is updating
- /// The handler to be called when a row is updated
- protected abstract void AddUpdateEventHandlers(IDbDataAdapter dataAdapter, RowUpdatingHandler rowUpdatingHandler,
- RowUpdatedHandler rowUpdatedHandler);
-
- ///
- /// Returns an array of IDataParameters of the specified size
- ///
- /// size of the array
- /// The array of IDataParameters
- protected abstract IDataParameter[] GetDataParameters(int size);
-
- ///
- /// Handle any provider-specific issues with BLOBs here by "washing" the IDataParameter and returning a new one that is set up appropriately for the provider.
- ///
- /// The IDbConnection to use in cleansing the parameter
- /// The parameter before cleansing
- /// The parameter after it's been cleansed.
- protected abstract IDataParameter GetBlobParameter(IDbConnection connection, IDataParameter p);
-
- #endregion
-
- #region Delegates
-
- // also used in our general case of RowUpdating/ed events
- ///
- /// Delegate for creating a RowUpdatingEvent handler
- ///
- /// The object that published the event
- /// The RowUpdatingEventArgs for the event
- public delegate void RowUpdatingHandler(object obj, RowUpdatingEventArgs e);
-
- ///
- /// Delegate for creating a RowUpdatedEvent handler
- ///
- /// The object that published the event
- /// The RowUpdatedEventArgs for the event
- public delegate void RowUpdatedHandler(object obj, RowUpdatedEventArgs e);
-
- #endregion
-
- #region Factory
-
- ///
- /// Create an AdoHelper for working with a specific provider (i.e. Sql, Odbc, OleDb, Oracle)
- ///
- /// Assembly containing the specified helper subclass
- /// Specific type of the provider
- /// An AdoHelper instance of the specified type
- ///
- /// AdoHelper helper = AdoHelper.CreateHelper("GotDotNet.ApplicationBlocks.Data", "GotDotNet.ApplicationBlocks.Data.OleDb");
- ///
- public static DbHelper CreateHelper(string providerAssembly, string providerType)
- {
- var assembly = Assembly.Load(providerAssembly);
- var provider = assembly.CreateInstance(providerType);
- if (provider is DbHelper)
- {
- return provider as DbHelper;
- }
- else
- {
- throw new InvalidOperationException(
- "The provider specified does not extend the AdoHelper abstract class.");
- }
- }
-
- #endregion
-
- #region GetParameter
-
- ///
- /// Get an IDataParameter for use in a SQL command
- ///
- /// The name of the parameter to create
- /// The value of the specified parameter
- /// An IDataParameter object
- public virtual IDataParameter GetParameter(string name, object value)
- {
- var parameter = GetParameter();
- parameter.ParameterName = name;
- if (value is DateTime && (DateTime) value < DateUtils.SqlMinValue)
- {
- value = DateUtils.SqlMinValue;
- }
- parameter.Value = value;
-
- return parameter;
- }
-
- ///
- /// Get an IDataParameter for use in a SQL command
- ///
- /// The name of the parameter to create
- /// The System.Data.DbType of the parameter
- /// The size of the parameter
- /// The System.Data.ParameterDirection of the parameter
- /// An IDataParameter object
- public virtual IDataParameter GetParameter(string name, DbType dbType, int size, ParameterDirection direction)
- {
- var dataParameter = GetParameter();
- dataParameter.DbType = dbType;
- dataParameter.Direction = direction;
- dataParameter.ParameterName = name;
-
- if (size > 0 && dataParameter is IDbDataParameter)
- {
- var dbDataParameter = (IDbDataParameter) dataParameter;
- dbDataParameter.Size = size;
- }
- return dataParameter;
- }
-
- ///
- /// Get an IDataParameter for use in a SQL command
- ///
- /// The name of the parameter to create
- /// The System.Data.DbType of the parameter
- /// The size of the parameter
- /// The source column of the parameter
- /// The System.Data.DataRowVersion of the parameter
- /// An IDataParameter object
- public virtual IDataParameter GetParameter(string name, DbType dbType, int size, string sourceColumn,
- DataRowVersion sourceVersion)
- {
- var dataParameter = GetParameter();
- dataParameter.DbType = dbType;
- dataParameter.ParameterName = name;
- dataParameter.SourceColumn = sourceColumn;
- dataParameter.SourceVersion = sourceVersion;
-
- if (size > 0 && dataParameter is IDbDataParameter)
- {
- var dbDataParameter = (IDbDataParameter) dataParameter;
- dbDataParameter.Size = size;
- }
- return dataParameter;
- }
-
- #endregion
-
- #region private utility methods
-
- ///
- /// This method is used to attach array of IDataParameters to an IDbCommand.
- ///
- /// This method will assign a value of DbNull to any parameter with a direction of
- /// InputOutput and a value of null.
- ///
- /// This behavior will prevent default values from being used, but
- /// this will be the less common case than an intended pure output parameter (derived as InputOutput)
- /// where the user provided no input value.
- ///
- /// The command to which the parameters will be added
- /// An array of IDataParameterParameters to be added to command
- /// Thrown if command is null.
- protected virtual void AttachParameters(IDbCommand command, IDataParameter[] commandParameters)
- {
- if (command == null) throw new ArgumentNullException(nameof(command));
- if (commandParameters != null)
- {
- foreach (var p in commandParameters)
- {
- if (p != null)
- {
- // Check for derived output value with no value assigned
- if ((p.Direction == ParameterDirection.InputOutput ||
- p.Direction == ParameterDirection.Input) &&
- p.Value == null)
- {
- p.Value = DBNull.Value;
- }
- command.Parameters.Add(p.DbType == DbType.Binary ? GetBlobParameter(command.Connection, p) : p);
- }
- }
- }
- }
-
- ///
- /// This method assigns dataRow column values to an IDataParameterCollection
- ///
- /// The IDataParameterCollection to be assigned values
- /// The dataRow used to hold the stored procedure's parameter values
- /// Thrown if any of the parameter names are invalid.
- protected internal void AssignParameterValues(IDataParameterCollection commandParameters, DataRow dataRow)
- {
- if (commandParameters == null || dataRow == null)
- {
- // Do nothing if we get no data
- return;
- }
-
- var columns = dataRow.Table.Columns;
-
- var i = 0;
- // Set the parameters values
- foreach (IDataParameter commandParameter in commandParameters)
- {
- // Check the parameter name
- if (commandParameter.ParameterName == null ||
- commandParameter.ParameterName.Length <= 1)
- throw new InvalidOperationException(
- $"Please provide a valid parameter name on the parameter #{i}, the ParameterName property has the following value: '{commandParameter.ParameterName}'.");
-
- if (columns.Contains(commandParameter.ParameterName))
- commandParameter.Value = dataRow[commandParameter.ParameterName];
- else if (columns.Contains(commandParameter.ParameterName.Substring(1)))
- commandParameter.Value = dataRow[commandParameter.ParameterName.Substring(1)];
-
- i++;
- }
- }
-
- ///
- /// This method assigns dataRow column values to an array of IDataParameters
- ///
- /// Array of IDataParameters to be assigned values
- /// The dataRow used to hold the stored procedure's parameter values
- /// Thrown if any of the parameter names are invalid.
- protected void AssignParameterValues(IDataParameter[] commandParameters, DataRow dataRow)
- {
- if ((commandParameters == null) || (dataRow == null))
- {
- // Do nothing if we get no data
- return;
- }
-
- var columns = dataRow.Table.Columns;
-
- var i = 0;
- // Set the parameters values
- foreach (var commandParameter in commandParameters)
- {
- // Check the parameter name
- if (commandParameter.ParameterName == null ||
- commandParameter.ParameterName.Length <= 1)
- throw new InvalidOperationException(
- $"Please provide a valid parameter name on the parameter #{i}, the ParameterName property has the following value: '{commandParameter.ParameterName}'.");
-
- if (columns.Contains(commandParameter.ParameterName))
- commandParameter.Value = dataRow[commandParameter.ParameterName];
- else if (columns.Contains(commandParameter.ParameterName.Substring(1)))
- commandParameter.Value = dataRow[commandParameter.ParameterName.Substring(1)];
-
- i++;
- }
- }
-
- ///
- /// This method assigns an array of values to an array of IDataParameters
- ///
- /// Array of IDataParameters to be assigned values
- /// Array of objects holding the values to be assigned
- /// Thrown if an incorrect number of parameters are passed.
- protected void AssignParameterValues(IDataParameter[] commandParameters, object[] parameterValues)
- {
- if ((commandParameters == null) || (parameterValues == null))
- {
- // Do nothing if we get no data
- return;
- }
-
- // We must have the same number of values as we pave parameters to put them in
- if (commandParameters.Length != parameterValues.Length)
- {
- throw new ArgumentException("Parameter count does not match Parameter Value count.");
- }
-
- // Iterate through the IDataParameters, assigning the values from the corresponding position in the
- // value array
- for (int i = 0, j = commandParameters.Length, k = 0; i < j; i++)
- {
- if (commandParameters[i].Direction != ParameterDirection.ReturnValue)
- {
- // If the current array value derives from IDataParameter, then assign its Value property
- if (parameterValues[k] is IDataParameter)
- {
- var paramInstance = (IDataParameter) parameterValues[k];
- if (paramInstance.Direction == ParameterDirection.ReturnValue)
- {
- paramInstance = (IDataParameter) parameterValues[++k];
- }
- commandParameters[i].Value = paramInstance.Value ?? DBNull.Value;
- }
- else if (parameterValues[k] == null)
- {
- commandParameters[i].Value = DBNull.Value;
- }
- else
- {
- commandParameters[i].Value = parameterValues[k];
- }
- k++;
- }
- }
- }
-
- ///
- /// This method cleans up the parameter syntax for the provider
- ///
- /// The IDbCommand containing the parameters to clean up.
- public virtual void CleanParameterSyntax(IDbCommand command)
- {
- // do nothing by default
- }
-
- ///
- /// This method opens (if necessary) and assigns a connection, transaction, command type and parameters
- /// to the provided command
- ///
- /// The IDbCommand to be prepared
- /// A valid IDbConnection, on which to execute this command
- /// A valid IDbTransaction, or 'null'
- /// SQL command
- /// An array of IDataParameters to be associated with the command or 'null' if no parameters are required
- /// true if the connection was opened by the method, otherwose is false.
- /// Thrown if command is null.
- /// Thrown if commandText is null.
- protected virtual void PrepareCommand(IDbCommand command, IDbConnection connection, IDbTransaction transaction,
- string commandText, IDataParameter[] commandParameters, out bool mustCloseConnection)
- {
- if (command == null) throw new ArgumentNullException(nameof(command));
- if (string.IsNullOrEmpty(commandText)) throw new ArgumentNullException(nameof(commandText));
- if (WebConfigUtils.DatabaseType != DatabaseType.SqlServer)
- {
- commandText = commandText.Replace("[", string.Empty).Replace("]", string.Empty);
- if (WebConfigUtils.DatabaseType == DatabaseType.Oracle)
- {
- commandText = commandText.Replace("@", ":");
- }
- }
-
- // If the provided connection is not open, we will open it
- if (connection.State != ConnectionState.Open)
- {
- mustCloseConnection = true;
- connection.Open();
- }
- else
- {
- mustCloseConnection = false;
- }
-
- // Associate the connection with the command
- command.Connection = connection;
-
- // Set the command text (stored procedure name or SQL statement)
- command.CommandText = commandText;
-
- // If we were provided a transaction, assign it
- if (transaction != null)
- {
- if (transaction.Connection == null)
- throw new ArgumentException(
- "The transaction was rolled back or commited, please provide an open transaction.",
- nameof(transaction));
- command.Transaction = transaction;
- }
-
- // Set the command type
- command.CommandType = CommandType.Text;
-
- // Attach the command parameters if they are provided
- if (commandParameters != null)
- {
- AttachParameters(command, commandParameters);
- }
- }
-
- ///
- /// This method clears (if necessary) the connection, transaction, command type and parameters
- /// from the provided command
- ///
- ///
- /// Not implemented here because the behavior of this method differs on each data provider.
- ///
- /// The IDbCommand to be cleared
- protected virtual void ClearCommand(IDbCommand command)
- {
- // do nothing by default
- }
-
- #endregion private utility methods
-
- #region ExecuteDataset
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the database specified in
- /// the connection string.
- ///
- /// The IDbCommand object to use
- /// A DataSet containing the resultset generated by the command
- /// Thrown if command is null.
- public virtual DataSet ExecuteDataset(IDbCommand command)
- {
- var mustCloseConnection = false;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
- // Create the DataAdapter & DataSet
- IDbDataAdapter da = null;
- try
- {
- da = GetDataAdapter();
- da.SelectCommand = command;
-
- var ds = new DataSet();
-
- // Fill the DataSet using default values for DataTable names, etc
- da.Fill(ds);
-
- // Detach the IDataParameters from the command object, so they can be used again
- // Don't do this...screws up output params -- cjb
- //command.Parameters.Clear();
-
- // Return the DataSet
- return ds;
- }
- finally
- {
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
- if (da != null)
- {
- var id = da as IDisposable;
- if (id != null)
- id.Dispose();
- }
- }
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- ///
- ///
- /// DataSet ds = helper.ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// A DataSet containing the resultset generated by the command
- /// Thrown if connectionString is null
- /// Thrown if commandText is null
- /// A DataSet containing the resultset generated by the command
- public virtual DataSet ExecuteDataset(string connectionString, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteDataset(connectionString, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- ///
- ///
- /// DataSet ds = helper.ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders", new IDbParameter("@prodid", 24));
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDbParamters used to execute the command
- /// A DataSet containing the resultset generated by the command
- /// Thrown if connectionString is null
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- public virtual DataSet ExecuteDataset(string connectionString, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
-
- // Create & open an IDbConnection, and dispose of it after we are done
- using (var connection = GetConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- return ExecuteDataset(connection, commandText, commandParameters);
- }
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the provided IDbConnection.
- ///
- ///
- ///
- /// DataSet ds = helper.ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid IDbConnection
- /// SQL command
- /// A DataSet containing the resultset generated by the command
- /// Thrown if commandText is null
- /// Thrown if connection is null
- public virtual DataSet ExecuteDataset(IDbConnection connection, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteDataset(connection, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the specified IDbConnection
- /// using the provided parameters.
- ///
- ///
- ///
- /// DataSet ds = helper.ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new IDataParameter("@prodid", 24));
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// A DataSet containing the resultset generated by the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if connection is null
- public virtual DataSet ExecuteDataset(IDbConnection connection, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
-
- // Create a command and prepare it for execution
- var cmd = connection.CreateCommand();
- bool mustCloseConnection;
- PrepareCommand(cmd, connection, null, commandText, commandParameters, out mustCloseConnection);
- CleanParameterSyntax(cmd);
-
- var ds = ExecuteDataset(cmd);
-
- if (mustCloseConnection)
- connection.Close();
-
- // Return the DataSet
- return ds;
- }
-
-
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the provided IDbTransaction.
- ///
- ///
- /// DataSet ds = helper.ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// A DataSet containing the resultset generated by the command
- /// Thrown if commandText is null
- /// Thrown if transaction is null
- /// Thrown if transaction.Connection is null
- public virtual DataSet ExecuteDataset(IDbTransaction transaction, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteDataset(transaction, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the specified IDbTransaction
- /// using the provided parameters.
- ///
- ///
- ///
- /// DataSet ds = helper.ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new IDataParameter("@prodid", 24));
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// A DataSet containing the resultset generated by the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if transaction is null
- /// Thrown if transaction.Connection is null
- public virtual DataSet ExecuteDataset(IDbTransaction transaction, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (transaction == null) throw new ArgumentNullException(nameof(transaction));
- if (transaction != null && transaction.Connection == null)
- throw new ArgumentException(
- "The transaction was rolled back or commited, please provide an open transaction.",
- nameof(transaction));
-
- // Create a command and prepare it for execution
- var cmd = transaction.Connection.CreateCommand();
- bool mustCloseConnection;
- PrepareCommand(cmd, transaction.Connection, transaction, commandText, commandParameters,
- out mustCloseConnection);
- CleanParameterSyntax(cmd);
-
- return ExecuteDataset(cmd);
-
- }
-
- #endregion ExecuteDataset
-
- #region ExecuteNonQuery
-
- ///
- /// Execute an IDbCommand (that returns no resultset) against the database
- ///
- /// The IDbCommand to execute
- /// An int representing the number of rows affected by the command
- /// Thrown if command is null.
- public virtual int ExecuteNonQuery(IDbCommand command)
- {
- var mustCloseConnection = false;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
- if (command == null) throw new ArgumentNullException(nameof(command));
-
-#if (DEBUG)
- DataProvider.RecordDao.RecordCommandExecute(command, nameof(ExecuteNonQuery));
-#endif
-
- int returnVal = command.ExecuteNonQuery();
-
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
-
- return returnVal;
- }
-
- ///
- /// Execute an IDbCommand (that returns no resultset and takes no parameters) against the database specified in
- /// the connection string
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An int representing the number of rows affected by the command
- /// Thrown if connectionString is null
- /// Thrown if commandText is null
- public virtual int ExecuteNonQuery(string connectionString, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteNonQuery(connectionString, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns no resultset) against the database specified in the connection string
- /// using the provided parameters
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// An int representing the number of rows affected by the command
- /// Thrown if connectionString is null
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- public virtual int ExecuteNonQuery(string connectionString, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
-
- // Create & open an IDbConnection, and dispose of it after we are done
- using (var connection = GetConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- return ExecuteNonQuery(connection, commandText, commandParameters);
- }
- }
-
- public virtual int ExecuteNonQueryAndReturnId(string tableName, string idColumnName, string connectionString,
- string commandText,
- params IDataParameter[] commandParameters)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
-
- int id;
-
- using (var conn = GetConnection(connectionString))
- {
- conn.Open();
- using (var trans = conn.BeginTransaction())
- {
- try
- {
- id = ExecuteNonQueryAndReturnId(tableName, idColumnName, trans, commandText, commandParameters);
-
- trans.Commit();
- }
- catch
- {
- trans.Rollback();
- throw;
- }
- }
- }
-
- return id;
- }
-
- public virtual int ExecuteNonQueryAndReturnId(string tableName, string idColumnName, IDbTransaction trans,
- string commandText, params IDataParameter[] commandParameters)
- {
- if (string.IsNullOrEmpty(commandText)) return 0;
-
- var id = 0;
-
- if (WebConfigUtils.DatabaseType == DatabaseType.MySql)
- {
- ExecuteNonQuery(trans, commandText, commandParameters);
-
- using (var rdr = ExecuteReader(trans, $"SELECT @@IDENTITY AS '{idColumnName}'"))
- {
- if (rdr.Read() && !rdr.IsDBNull(0))
- {
- id = rdr.GetInt32(0);
- }
- rdr.Close();
- }
-
- if (id == 0)
- {
- trans.Rollback();
- }
- }
- else if (WebConfigUtils.DatabaseType == DatabaseType.SqlServer)
- {
- ExecuteNonQuery(trans, commandText, commandParameters);
-
- using (var rdr = ExecuteReader(trans, $"SELECT @@IDENTITY AS '{idColumnName}'"))
- {
- if (rdr.Read() && !rdr.IsDBNull(0))
- {
- id = Convert.ToInt32(rdr[0]);
- }
- rdr.Close();
- }
-
- if (id == 0)
- {
- trans.Rollback();
- }
- }
- else if (WebConfigUtils.DatabaseType == DatabaseType.PostgreSql)
- {
- commandText += " RETURNING " + idColumnName;
-
- using (var rdr = ExecuteReader(trans, commandText, commandParameters))
- {
- if (rdr.Read() && !rdr.IsDBNull(0))
- {
- id = rdr.GetInt32(0);
- }
- rdr.Close();
- }
-
- if (id == 0)
- {
- trans.Rollback();
- }
- }
- else if (WebConfigUtils.DatabaseType == DatabaseType.Oracle)
- {
- ExecuteNonQuery(trans, commandText, commandParameters);
-
- var sequence = DataProvider.DatabaseDao.GetOracleSequence(tableName, idColumnName);
-
- if (!string.IsNullOrEmpty(sequence))
- {
- using (var rdr = ExecuteReader(trans, $"SELECT {sequence}.currval from dual"))
- {
- if (rdr.Read() && !rdr.IsDBNull(0))
- {
- id = Convert.ToInt32(rdr[0]);
- }
- rdr.Close();
- }
- }
-
- if (id == 0)
- {
- trans.Rollback();
- }
- }
-
- return id;
- }
-
- ///
- /// Execute an IDbCommand (that returns no resultset and takes no parameters) against the provided IDbConnection.
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An int representing the number of rows affected by the command
- /// Thrown if commandText is null
- /// Thrown if connection is null
- public virtual int ExecuteNonQuery(IDbConnection connection, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteNonQuery(connection, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns no resultset) against the specified IDbConnection
- /// using the provided parameters.
- ///
- ///
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An array of IDbParamters used to execute the command
- /// An int representing the number of rows affected by the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if connection is null
- public virtual int ExecuteNonQuery(IDbConnection connection, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
-
- // Create a command and prepare it for execution
- var cmd = connection.CreateCommand();
- bool mustCloseConnection;
- PrepareCommand(cmd, connection, null, commandText, commandParameters, out mustCloseConnection);
- CleanParameterSyntax(cmd);
-
- // Finally, execute the command
- var retval = ExecuteNonQuery(cmd);
-
- // Detach the IDataParameters from the command object, so they can be used again
- // don't do this...screws up output parameters -- cjbreisch
- // cmd.Parameters.Clear();
- if (mustCloseConnection)
- connection.Close();
- return retval;
- }
-
- ///
- /// Execute an IDbCommand (that returns no resultset and takes no parameters) against the provided IDbTransaction.
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// An int representing the number of rows affected by the command
- /// Thrown if commandText is null
- /// Thrown if transaction is null
- /// Thrown if transaction.Connection is null
- public virtual int ExecuteNonQuery(IDbTransaction transaction, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteNonQuery(transaction, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns no resultset) against the specified IDbTransaction
- /// using the provided parameters.
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// An int representing the number of rows affected by the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if transaction is null
- /// Thrown if transaction.Connection is null
- public virtual int ExecuteNonQuery(IDbTransaction transaction, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (transaction == null) throw new ArgumentNullException(nameof(transaction));
- if (transaction != null && transaction.Connection == null)
- throw new ArgumentException(
- "The transaction was rolled back or commited, please provide an open transaction.",
- nameof(transaction));
-
- // Create a command and prepare it for execution
- var cmd = transaction.Connection.CreateCommand();
- bool mustCloseConnection;
- PrepareCommand(cmd, transaction.Connection, transaction, commandText, commandParameters,
- out mustCloseConnection);
- CleanParameterSyntax(cmd);
-
- // Finally, execute the command
- var retval = ExecuteNonQuery(cmd);
-
- // Detach the IDataParameters from the command object, so they can be used again
- // don't do this...screws up output parameters -- cjbreisch
- // cmd.Parameters.Clear();
- return retval;
- }
-
- #endregion ExecuteNonQuery
-
- #region ExecuteReader
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the database specified in
- /// the connection string.
- ///
- /// The IDbCommand object to use
- /// A IDataReader containing the resultset generated by the command
- /// Thrown if command is null.
- public virtual IDataReader ExecuteReader(IDbCommand command)
- {
- return ExecuteReader(command, AdoConnectionOwnership.External);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the database specified in
- /// the connection string.
- ///
- /// The IDbCommand object to use
- /// Enum indicating whether the connection was created internally or externally.
- /// A IDataReader containing the resultset generated by the command
- /// Thrown if command is null.
- protected virtual IDataReader ExecuteReader(IDbCommand command, AdoConnectionOwnership connectionOwnership)
- {
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- connectionOwnership = AdoConnectionOwnership.Internal;
- }
-
- // Create a reader
-
-#if (DEBUG)
- DataProvider.RecordDao.RecordCommandExecute(command, nameof(ExecuteReader));
-#endif
-
- // Call ExecuteReader with the appropriate CommandBehavior
- var dataReader = connectionOwnership == AdoConnectionOwnership.External
- ? command.ExecuteReader()
- : command.ExecuteReader(CommandBehavior.CloseConnection);
-
- ClearCommand(command);
-
- return dataReader;
- }
-
- ///
- /// Create and prepare an IDbCommand, and call ExecuteReader with the appropriate CommandBehavior.
- ///
- ///
- /// If we created and opened the connection, we want the connection to be closed when the DataReader is closed.
- ///
- /// If the caller provided the connection, we want to leave it to them to manage.
- ///
- /// A valid IDbConnection, on which to execute this command
- /// A valid IDbTransaction, or 'null'
- /// SQL command
- /// An array of IDataParameters to be associated with the command or 'null' if no parameters are required
- /// Indicates whether the connection parameter was provided by the caller, or created by AdoHelper
- /// IDataReader containing the results of the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if connection is null
- private IDataReader ExecuteReader(IDbConnection connection, IDbTransaction transaction, string commandText,
- IDataParameter[] commandParameters, AdoConnectionOwnership connectionOwnership)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
-
- var mustCloseConnection = false;
- // Create a command and prepare it for execution
- var cmd = connection.CreateCommand();
- try
- {
- PrepareCommand(cmd, connection, transaction, commandText, commandParameters, out mustCloseConnection);
- CleanParameterSyntax(cmd);
-
- // override conenctionOwnership if we created the connection in PrepareCommand -- cjbreisch
- if (mustCloseConnection)
- {
- connectionOwnership = AdoConnectionOwnership.Internal;
- }
-
- // Create a reader
-
- var dataReader = ExecuteReader(cmd, connectionOwnership);
-
- ClearCommand(cmd);
-
- return dataReader;
- }
- catch
- {
- if (mustCloseConnection)
- connection.Close();
- throw;
- }
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// A IDataReader containing the resultset generated by the command
- /// Thrown if connectionString is null
- /// Thrown if commandText is null
- public virtual IDataReader ExecuteReader(string connectionString, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteReader(connectionString, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// A IDataReader containing the resultset generated by the command
- /// Thrown if connectionString is null
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- public virtual IDataReader ExecuteReader(string connectionString, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
- IDbConnection connection = null;
- try
- {
- connection = GetConnection(connectionString);
- connection.Open();
-
- // Call the private overload that takes an internally owned connection in place of the connection string
- return ExecuteReader(connection, null, commandText, commandParameters, AdoConnectionOwnership.Internal);
- }
- catch
- {
- // If we fail to return the IDataReader, we need to close the connection ourselves
- connection?.Close();
- throw;
- }
-
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the provided IDbConnection.
- ///
- ///
- ///
- /// IDataReader dr = helper.ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid IDbConnection
- /// SQL command
- /// an IDataReader containing the resultset generated by the command
- /// Thrown if commandText is null
- public virtual IDataReader ExecuteReader(IDbConnection connection, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteReader(connection, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the specified IDbConnection
- /// using the provided parameters.
- ///
- ///
- ///
- /// IDataReader dr = helper.ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders", new IDataParameter("@prodid", 24));
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// an IDataReader containing the resultset generated by the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if connection is null
- public virtual IDataReader ExecuteReader(IDbConnection connection, string commandText,
- params IDataParameter[] commandParameters)
- {
- // Pass through the call to the private overload using a null transaction value and an externally owned connection
- return ExecuteReader(connection, null, commandText, commandParameters, AdoConnectionOwnership.External);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the provided IDbTransaction.
- ///
- ///
- /// IDataReader dr = helper.ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// A IDataReader containing the resultset generated by the command
- /// Thrown if commandText is null
- public virtual IDataReader ExecuteReader(IDbTransaction transaction, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteReader(transaction, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the specified IDbTransaction
- /// using the provided parameters.
- ///
- ///
- ///
- /// IDataReader dr = helper.ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders", new IDataParameter("@prodid", 24));
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// A IDataReader containing the resultset generated by the command
- public virtual IDataReader ExecuteReader(IDbTransaction transaction, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (transaction == null) throw new ArgumentNullException(nameof(transaction));
- if (transaction != null && transaction.Connection == null)
- throw new ArgumentException(
- "The transaction was rolled back or commited, please provide an open transaction.",
- nameof(transaction));
-
- // Pass through to private overload, indicating that the connection is owned by the caller
- return ExecuteReader(transaction.Connection, transaction, commandText, commandParameters,
- AdoConnectionOwnership.External);
- }
-
- #endregion ExecuteReader
-
- #region ExecuteScalar
-
- ///
- /// Execute an IDbCommand (that returns a 1x1 resultset) against the database specified in
- /// the connection string.
- ///
- /// The IDbCommand to execute
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if command is null.
- public virtual object ExecuteScalar(IDbCommand command)
- {
- var mustCloseConnection = false;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
-#if (DEBUG)
- DataProvider.RecordDao.RecordCommandExecute(command, nameof(ExecuteScalar));
-#endif
-
- // Execute the command & return the results
- var retval = command.ExecuteScalar();
-
- // Detach the IDataParameters from the command object, so they can be used again
- // don't do this...screws up output params -- cjbreisch
- // command.Parameters.Clear();
-
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
-
- return retval;
- }
-
- ///
- /// Execute an IDbCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- ///
- ///
- /// int orderCount = (int)helper.ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount");
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if connectionString is null
- /// Thrown if commandText is null
- public virtual object ExecuteScalar(string connectionString, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteScalar(connectionString, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a 1x1 resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if connectionString is null
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- public virtual object ExecuteScalar(string connectionString, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
- // Create & open an IDbConnection, and dispose of it after we are done
- IDbConnection connection = null;
- try
- {
- connection = GetConnection(connectionString);
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- return ExecuteScalar(connection, commandText, commandParameters);
- }
- finally
- {
- var id = connection as IDisposable;
- if (id != null) id.Dispose();
- }
- }
-
- ///
- /// Execute an IDbCommand (that returns a 1x1 resultset and takes no parameters) against the provided IDbConnection.
- ///
- ///
- ///
- /// int orderCount = (int)helper.ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount");
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if commandText is null
- public virtual object ExecuteScalar(IDbConnection connection, string commandText)
- {
- // Pass through the call providing null for the set of IDbParameters
- return ExecuteScalar(connection, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a 1x1 resultset) against the specified IDbConnection
- /// using the provided parameters.
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if connection is null
- public virtual object ExecuteScalar(IDbConnection connection, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
-
- // Create a command and prepare it for execution
- var cmd = connection.CreateCommand();
-
- bool mustCloseConnection;
- PrepareCommand(cmd, connection, null, commandText, commandParameters, out mustCloseConnection);
- CleanParameterSyntax(cmd);
-
- // Execute the command & return the results
- var retval = ExecuteScalar(cmd);
-
- // Detach the IDataParameters from the command object, so they can be used again
- // don't do this...screws up output parameters -- cjbreisch
- // cmd.Parameters.Clear();
-
- if (mustCloseConnection)
- connection.Close();
-
- return retval;
- }
-
- ///
- /// Execute an IDbCommand (that returns a 1x1 resultset and takes no parameters) against the provided IDbTransaction.
- ///
- ///
- ///
- /// int orderCount = (int)helper.ExecuteScalar(tran, CommandType.StoredProcedure, "GetOrderCount");
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if commandText is null
- public virtual object ExecuteScalar(IDbTransaction transaction, string commandText)
- {
- // Pass through the call providing null for the set of IDataParameters
- return ExecuteScalar(transaction, commandText, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a 1x1 resultset) against the specified IDbTransaction
- /// using the provided parameters.
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// An array of IDbParamters used to execute the command
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- /// Thrown if transaction is null
- /// Thrown if transaction.Connection is null
- public virtual object ExecuteScalar(IDbTransaction transaction, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (transaction == null) throw new ArgumentNullException(nameof(transaction));
- if (transaction != null && transaction.Connection == null)
- throw new ArgumentException(
- "The transaction was rolled back or commited, please provide an open transaction.",
- nameof(transaction));
-
- // Create a command and prepare it for execution
- var cmd = transaction.Connection.CreateCommand();
- bool mustCloseConnection;
- PrepareCommand(cmd, transaction.Connection, transaction, commandText, commandParameters,
- out mustCloseConnection);
- CleanParameterSyntax(cmd);
-
- // Execute the command & return the results
- var retval = ExecuteScalar(cmd);
-
- // Detach the IDataParameters from the command object, so they can be used again
- // don't do this...screws up output parameters -- cjbreisch
- // cmd.Parameters.Clear();
- return retval;
- }
-
- #endregion ExecuteScalar
-
- #region ExecuteInt
-
- public int ExecuteInt(string connectionString, string commandText)
- {
- var count = 0;
-
- using (var conn = GetConnection(connectionString))
- {
- conn.Open();
- using (var rdr = ExecuteReader(conn, commandText))
- {
- if (rdr.Read() && !rdr.IsDBNull(0))
- {
- count = rdr.GetInt32(0);
- }
- rdr.Close();
- }
- }
- return count;
- }
-
- public int ExecuteInt(string connectionString, string commandText, IDataParameter[] commandParameters)
- {
- var count = 0;
-
- using (var conn = GetConnection(connectionString))
- {
- conn.Open();
- using (var rdr = ExecuteReader(conn, commandText, commandParameters))
- {
- if (rdr.Read() && !rdr.IsDBNull(0))
- {
- count = rdr.GetInt32(0);
- }
- rdr.Close();
- }
- }
- return count;
- }
-
- #endregion ExecuteInt
-
- #region FillDataset
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the database specified in
- /// the connection string.
- ///
- /// The IDbCommand to execute
- /// A DataSet wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- /// Thrown if command is null.
- public virtual void FillDataset(IDbCommand command, DataSet dataSet, string[] tableNames)
- {
- var mustCloseConnection = false;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
- // Create the DataAdapter & DataSet
- IDbDataAdapter dataAdapter = null;
- try
- {
- dataAdapter = GetDataAdapter();
- dataAdapter.SelectCommand = command;
-
- // Add the table mappings specified by the user
- if (tableNames != null && tableNames.Length > 0)
- {
- var tableName = "Table";
- for (var index = 0; index < tableNames.Length; index++)
- {
- if (tableNames[index] == null || tableNames[index].Length == 0)
- throw new ArgumentException(
- "The tableNames parameter must contain a list of tables, a value was provided as null or empty string.",
- nameof(tableNames));
- dataAdapter.TableMappings.Add(
- tableName + (index == 0 ? "" : index.ToString()),
- tableNames[index]);
- }
- }
-
- // Fill the DataSet using default values for DataTable names, etc
- dataAdapter.Fill(dataSet);
-
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
-
- // Detach the IDataParameters from the command object, so they can be used again
- // don't do this...screws up output params --cjb
- // command.Parameters.Clear();
- }
- finally
- {
- var id = dataAdapter as IDisposable;
- if (id != null) id.Dispose();
- }
-
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- ///
- ///
- /// helper.FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// A DataSet wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- /// Thrown if connectionString is null
- /// Thrown if commandText is null
- public virtual void FillDataset(string connectionString, string commandText, DataSet dataSet,
- string[] tableNames)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
- if (dataSet == null) throw new ArgumentNullException(nameof(dataSet));
-
- // Create & open an IDbConnection, and dispose of it after we are done
- IDbConnection connection = null;
- try
- {
- connection = GetConnection(connectionString);
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- FillDataset(connection, commandText, dataSet, tableNames);
- }
- finally
- {
- var id = connection as IDisposable;
- if (id != null) id.Dispose();
- }
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters used to execute the command
- /// A DataSet wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// Thrown if connectionString is null
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if commandText is null
- /// Thrown if the parameter count does not match the number of values supplied
- public virtual void FillDataset(string connectionString,
- string commandText, DataSet dataSet, string[] tableNames,
- params IDataParameter[] commandParameters)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
- if (dataSet == null) throw new ArgumentNullException(nameof(dataSet));
- // Create & open an IDbConnection, and dispose of it after we are done
- IDbConnection connection = null;
- try
- {
- connection = GetConnection(connectionString);
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- FillDataset(connection, commandText, dataSet, tableNames, commandParameters);
- }
- finally
- {
- var id = connection as IDisposable;
- if (id != null) id.Dispose();
- }
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the provided IDbConnection.
- ///
- ///
- ///
- /// helper.FillDataset(conn, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
- ///
- /// A valid IDbConnection
- /// SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// Thrown if commandText is null
- /// Thrown if connection is null
- public virtual void FillDataset(IDbConnection connection,
- string commandText, DataSet dataSet, string[] tableNames)
- {
- FillDataset(connection, commandText, dataSet, tableNames, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the specified IDbConnection
- /// using the provided parameters.
- ///
- /// A valid IDbConnection
- /// SQL command
- /// A DataSet wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of IDataParameters used to execute the command
- /// Thrown if commandText is null
- /// Thrown if connection is null
- public virtual void FillDataset(IDbConnection connection,
- string commandText, DataSet dataSet, string[] tableNames,
- params IDataParameter[] commandParameters)
- {
- FillDataset(connection, null, commandText, dataSet, tableNames, commandParameters);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset and takes no parameters) against the provided IDbTransaction.
- ///
- ///
- ///
- /// helper.FillDataset(tran, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// Thrown if commandText is null
- /// Thrown if transaction is null
- /// Thrown if transaction.Connection is null
- public virtual void FillDataset(IDbTransaction transaction,
- string commandText,
- DataSet dataSet, string[] tableNames)
- {
- FillDataset(transaction, commandText, dataSet, tableNames, null);
- }
-
- ///
- /// Execute an IDbCommand (that returns a resultset) against the specified IDbTransaction
- /// using the provided parameters.
- ///
- /// A valid IDbTransaction
- /// SQL command
- /// A DataSet wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of IDataParameters used to execute the command
- /// Thrown if commandText is null
- /// Thrown if transaction is null
- /// Thrown if transaction.Connection is null
- public virtual void FillDataset(IDbTransaction transaction,
- string commandText, DataSet dataSet, string[] tableNames,
- params IDataParameter[] commandParameters)
- {
- FillDataset(transaction.Connection, transaction, commandText, dataSet, tableNames, commandParameters);
- }
-
- ///
- /// Private helper method that execute an IDbCommand (that returns a resultset) against the specified IDbTransaction and IDbConnection
- /// using the provided parameters.
- ///
- /// A valid IDbConnection
- /// A valid IDbTransaction
- /// SQL command
- /// A DataSet wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of IDataParameters used to execute the command
- private void FillDataset(IDbConnection connection, IDbTransaction transaction,
- string commandText, DataSet dataSet, string[] tableNames,
- params IDataParameter[] commandParameters)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
- if (dataSet == null) throw new ArgumentNullException(nameof(dataSet));
-
- // Create a command and prepare it for execution
- var command = connection.CreateCommand();
- bool mustCloseConnection;
- PrepareCommand(command, connection, transaction, commandText, commandParameters, out mustCloseConnection);
- CleanParameterSyntax(command);
-
- FillDataset(command, dataSet, tableNames);
-
- if (mustCloseConnection)
- connection.Close();
- }
-
- #endregion
-
- #region UpdateDataset
-
- ///
- /// This method consumes the RowUpdatingEvent and passes it on to the consumer specifed in the call to UpdateDataset
- ///
- /// The object that generated the event
- /// The System.Data.Common.RowUpdatingEventArgs
- protected void RowUpdating(object obj, RowUpdatingEventArgs e)
- {
- if (MRowUpdating != null)
- MRowUpdating(obj, e);
- }
-
- ///
- /// This method consumes the RowUpdatedEvent and passes it on to the consumer specifed in the call to UpdateDataset
- ///
- /// The object that generated the event
- /// The System.Data.Common.RowUpdatingEventArgs
- protected void RowUpdated(object obj, RowUpdatedEventArgs e)
- {
- if (MRowUpdated != null)
- MRowUpdated(obj, e);
- }
-
- ///
- /// Set up a command for updating a DataSet.
- ///
- /// command object to prepare
- /// output parameter specifying whether the connection used should be closed by the DAAB
- /// An IDbCommand object
- protected virtual IDbCommand SetCommand(IDbCommand command, out bool mustCloseConnection)
- {
- mustCloseConnection = false;
- if (command != null)
- {
- var commandParameters = new IDataParameter[command.Parameters.Count];
- command.Parameters.CopyTo(commandParameters, 0);
- command.Parameters.Clear();
- PrepareCommand(command, command.Connection, null, command.CommandText, commandParameters,
- out mustCloseConnection);
- CleanParameterSyntax(command);
- }
-
- return command;
- }
-
- ///
- /// Executes the respective command for each inserted, updated, or deleted row in the DataSet.
- ///
- ///
- ///
- /// helper.UpdateDataset(conn, insertCommand, deleteCommand, updateCommand, dataSet, "Order");
- ///
- /// A valid SQL statement or stored procedure to insert new records into the data source
- /// A valid SQL statement or stored procedure to delete records from the data source
- /// A valid SQL statement or stored procedure used to update records in the data source
- /// The DataSet used to update the data source
- /// The DataTable used to update the data source.
- public virtual void UpdateDataset(IDbCommand insertCommand, IDbCommand deleteCommand, IDbCommand updateCommand,
- DataSet dataSet, string tableName)
- {
- UpdateDataset(insertCommand, deleteCommand, updateCommand, dataSet, tableName, null, null);
- }
-
- ///
- /// Executes the IDbCommand for each inserted, updated, or deleted row in the DataSet also implementing RowUpdating and RowUpdated Event Handlers
- ///
- ///
- ///
- /// RowUpdatingEventHandler rowUpdatingHandler = new RowUpdatingEventHandler( OnRowUpdating );
- /// RowUpdatedEventHandler rowUpdatedHandler = new RowUpdatedEventHandler( OnRowUpdated );
- /// helper.UpdateDataSet(sqlInsertCommand, sqlDeleteCommand, sqlUpdateCommand, dataSet, "Order", rowUpdatingHandler, rowUpdatedHandler);
- ///
- /// A valid SQL statement or stored procedure to insert new records into the data source
- /// A valid SQL statement or stored procedure to delete records from the data source
- /// A valid SQL statement or stored procedure used to update records in the data source
- /// The DataSet used to update the data source
- /// The DataTable used to update the data source.
- /// RowUpdatingEventHandler
- /// RowUpdatedEventHandler
- public void UpdateDataset(IDbCommand insertCommand, IDbCommand deleteCommand, IDbCommand updateCommand,
- DataSet dataSet, string tableName, RowUpdatingHandler rowUpdatingHandler,
- RowUpdatedHandler rowUpdatedHandler)
- {
- if (string.IsNullOrEmpty(tableName)) throw new ArgumentNullException(nameof(tableName));
-
- // Create an IDbDataAdapter, and dispose of it after we are done
- IDbDataAdapter dataAdapter = null;
- try
- {
- bool mustCloseUpdateConnection;
- bool mustCloseInsertConnection;
- bool mustCloseDeleteConnection;
-
- dataAdapter = GetDataAdapter();
-
- // Set the data adapter commands
- dataAdapter.UpdateCommand = SetCommand(updateCommand, out mustCloseUpdateConnection);
- dataAdapter.InsertCommand = SetCommand(insertCommand, out mustCloseInsertConnection);
- dataAdapter.DeleteCommand = SetCommand(deleteCommand, out mustCloseDeleteConnection);
-
- AddUpdateEventHandlers(dataAdapter, rowUpdatingHandler, rowUpdatedHandler);
-
- if (dataAdapter is DbDataAdapter)
- {
- // Update the DataSet changes in the data source
- ((DbDataAdapter) dataAdapter).Update(dataSet, tableName);
- }
- else
- {
- dataAdapter.TableMappings.Add(tableName, "Table");
-
- // Update the DataSet changes in the data source
- dataAdapter.Update(dataSet);
- }
-
- // Commit all the changes made to the DataSet
- dataSet.Tables[tableName].AcceptChanges();
-
- if (mustCloseUpdateConnection)
- {
- updateCommand.Connection.Close();
- }
- if (mustCloseInsertConnection)
- {
- insertCommand.Connection.Close();
- }
- if (mustCloseDeleteConnection)
- {
- deleteCommand.Connection.Close();
- }
- }
- finally
- {
- var id = dataAdapter as IDisposable;
- id?.Dispose();
- }
- }
-
- #endregion
-
- #region CreateCommand
-
- ///
- /// Simplify the creation of an IDbCommand object by allowing
- /// a stored procedure and optional parameters to be provided
- ///
- ///
- ///
- /// IDbCommand command = helper.CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");
- ///
- /// A valid connection string for an IDbConnection
- /// The name of the stored procedure
- /// An array of string to be assigned as the source columns of the stored procedure parameters
- /// A valid IDbCommand object
- /// Thrown if connectionString is null
- /// Thrown if any of the IDataParameters.ParameterNames are null, or if the parameter count does not match the number of values supplied
- /// Thrown if spName is null
- /// Thrown if the parameter count does not match the number of values supplied
- public virtual IDbCommand CreateSpCommand(string connectionString, string spName, params string[] sourceColumns)
- {
- return CreateSpCommand(GetConnection(connectionString), spName, sourceColumns);
- }
-
- ///
- /// Simplify the creation of an IDbCommand object by allowing
- /// a stored procedure and optional parameters to be provided
- ///
- ///
- ///
- /// IDbCommand command = helper.CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");
- ///
- /// A valid IDbConnection object
- /// The name of the stored procedure
- /// An array of string to be assigned as the source columns of the stored procedure parameters
- /// A valid IDbCommand object
- /// Thrown if spName is null
- /// Thrown if connection is null
- public virtual IDbCommand CreateSpCommand(IDbConnection connection, string spName, params string[] sourceColumns)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
- if (string.IsNullOrEmpty(spName)) throw new ArgumentNullException(nameof(spName));
-
- // Create an IDbCommand
- var cmd = connection.CreateCommand();
- cmd.CommandText = spName;
- cmd.CommandType = CommandType.StoredProcedure;
-
- // If we receive parameter values, we need to figure out where they go
- if ((sourceColumns != null) && (sourceColumns.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = GetSpParameterSet(connection, spName);
-
- // Assign the provided source columns to these parameters based on parameter order
- for (var index = 0; index < sourceColumns.Length; index++)
- if (commandParameters[index].SourceColumn == String.Empty)
- commandParameters[index].SourceColumn = sourceColumns[index];
-
- // Attach the discovered parameters to the IDbCommand object
- AttachParameters(cmd, commandParameters);
- }
-
- return cmd;
- }
-
- ///
- /// Simplify the creation of an IDbCommand object by allowing
- /// a stored procedure and optional parameters to be provided
- ///
- /// A valid connection string for an IDbConnection
- /// A valid SQL statement
- /// The parameters for the SQL statement
- /// A valid IDbCommand object
- public virtual IDbCommand CreateCommand(string connectionString, string commandText,
- params IDataParameter[] commandParameters)
- {
- return CreateCommand(GetConnection(connectionString), commandText, commandParameters);
- }
-
- ///
- /// Simplify the creation of an IDbCommand object by allowing
- /// a stored procedure and optional parameters to be provided
- ///
- ///
- /// IDbCommand command = helper.CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");
- ///
- /// A valid IDbConnection object
- /// A valid SQL statement
- /// The parameters for the SQL statement
- /// A valid IDbCommand object
- public virtual IDbCommand CreateCommand(IDbConnection connection, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
- if (string.IsNullOrEmpty(commandText)) throw new ArgumentNullException(nameof(commandText));
-
- // Create an IDbCommand
- var cmd = connection.CreateCommand();
- cmd.CommandText = commandText;
- cmd.CommandType = CommandType.Text;
-
- // If we receive parameter values, we need to figure out where they go
- if (commandParameters != null && commandParameters.Length > 0)
- {
- // Assign the provided source columns to these parameters based on parameter order
- for (var index = 0; index < commandParameters.Length; index++)
- commandParameters[index].SourceColumn =
- commandParameters[index].ParameterName.TrimStart(new char[] {'@'});
-
- // Attach the discovered parameters to the IDbCommand object
- AttachParameters(cmd, commandParameters);
- }
-
- return cmd;
- }
-
- #endregion
-
- #region ExecuteNonQueryTypedParams
-
- ///
- /// Execute a stored procedure via an IDbCommand (that returns no resultset)
- /// against the database specified in the connection string using the
- /// dataRow column values as the stored procedure's parameters values.
- /// This method will assign the parameter values based on row values.
- ///
- /// The IDbCommand to execute
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An int representing the number of rows affected by the command
- /// Thrown if command is null.
- public virtual int ExecuteNonQueryTypedParams(IDbCommand command, DataRow dataRow)
- {
- int retVal;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- // If the row has values, the store procedure parameters must be initialized
- if (dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Set the parameters values
- AssignParameterValues(command.Parameters, dataRow);
-
- retVal = ExecuteNonQuery(command);
- }
- else
- {
- retVal = ExecuteNonQuery(command);
- }
-
- return retVal;
- }
-
- #endregion
-
- #region ExecuteDatasetTypedParams
-
- ///
- /// Execute a stored procedure via an IDbCommand (that returns a resultset) against the database specified in
- /// the connection string using the dataRow column values as the stored procedure's parameters values.
- /// This method will assign the paraemter values based on row values.
- ///
- /// The IDbCommand to execute
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A DataSet containing the resultset generated by the command
- /// Thrown if command is null.
- public virtual DataSet ExecuteDatasetTypedParams(IDbCommand command, DataRow dataRow)
- {
- DataSet ds;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- // If the row has values, the store procedure parameters must be initialized
- if (dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Set the parameters values
- AssignParameterValues(command.Parameters, dataRow);
-
-
- ds = ExecuteDataset(command);
- }
- else
- {
- ds = ExecuteDataset(command);
- }
-
- return ds;
- }
-
- #endregion
-
- #region ExecuteReaderTypedParams
-
- ///
- /// Execute a stored procedure via an IDbCommand (that returns a resultset) against the database specified in
- /// the connection string using the dataRow column values as the stored procedure's parameters values.
- /// This method will assign the parameter values based on parameter order.
- ///
- /// The IDbCommand to execute
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A IDataReader containing the resultset generated by the command
- /// Thrown if command is null.
- public virtual IDataReader ExecuteReaderTypedParams(IDbCommand command, DataRow dataRow)
- {
- IDataReader reader;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- // If the row has values, the store procedure parameters must be initialized
- if (dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Set the parameters values
- AssignParameterValues(command.Parameters, dataRow);
-
- reader = ExecuteReader(command);
- }
- else
- {
- reader = ExecuteReader(command);
- }
-
- return reader;
- }
-
- #endregion
-
- #region ExecuteScalarTypedParams
-
- ///
- /// Execute a stored procedure via an IDbCommand (that returns a 1x1 resultset) against the database specified in
- /// the connection string using the dataRow column values as the stored procedure's parameters values.
- /// This method will assign the parameter values based on parameter order.
- ///
- /// The IDbCommand to execute
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An object containing the value in the 1x1 resultset generated by the command
- /// Thrown if command is null.
- public virtual object ExecuteScalarTypedParams(IDbCommand command, DataRow dataRow)
- {
- object retVal;
-
- // Clean Up Parameter Syntax
- CleanParameterSyntax(command);
-
- // If the row has values, the store procedure parameters must be initialized
- if (dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Set the parameters values
- AssignParameterValues(command.Parameters, dataRow);
-
- retVal = ExecuteScalar(command);
- }
- else
- {
- retVal = ExecuteScalar(command);
- }
-
- return retVal;
- }
-
- #endregion
-
- #region Parameter Discovery Functions
-
- ///
- /// Retrieves the set of IDataParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid connection string for an IDbConnection
- /// The name of the stored procedure
- /// An array of IDataParameterParameters
- /// Thrown if connectionString is null
- /// Thrown if spName is null
- public virtual IDataParameter[] GetSpParameterSet(string connectionString, string spName)
- {
- return GetSpParameterSet(connectionString, spName, false);
- }
-
- ///
- /// Retrieves the set of IDataParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid connection string for an IDbConnection
- /// The name of the stored procedure
- /// A bool value indicating whether the return value parameter should be included in the results
- /// An array of IDataParameters
- /// Thrown if connectionString is null
- /// Thrown if spName is null
- public virtual IDataParameter[] GetSpParameterSet(string connectionString, string spName,
- bool includeReturnValueParameter)
- {
- if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
- if (string.IsNullOrEmpty(spName)) throw new ArgumentNullException(nameof(spName));
-
- using (var connection = GetConnection(connectionString))
- {
- return GetSpParameterSetInternal(connection, spName, includeReturnValueParameter);
- }
- }
-
- ///
- /// Retrieves the set of IDataParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid IDataConnection object
- /// The name of the stored procedure
- /// An array of IDataParameters
- /// Thrown if spName is null
- /// Thrown if connection is null
- public virtual IDataParameter[] GetSpParameterSet(IDbConnection connection, string spName)
- {
- return GetSpParameterSet(connection, spName, false);
- }
-
- ///
- /// Retrieves the set of IDataParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid IDbConnection object
- /// The name of the stored procedure
- /// A bool value indicating whether the return value parameter should be included in the results
- /// An array of IDataParameters
- /// Thrown if spName is null
- /// Thrown if connection is null
- public virtual IDataParameter[] GetSpParameterSet(IDbConnection connection, string spName,
- bool includeReturnValueParameter)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
- if (!(connection is ICloneable))
- throw new ArgumentException(
- "can't discover parameters if the connection doesn't implement the ICloneable interface",
- nameof(connection));
-
- var clonedConnection = (IDbConnection) ((ICloneable) connection).Clone();
- return GetSpParameterSetInternal(clonedConnection, spName, includeReturnValueParameter);
- }
-
- ///
- /// Retrieves the set of IDataParameters appropriate for the stored procedure
- ///
- /// A valid IDbConnection object
- /// The name of the stored procedure
- /// A bool value indicating whether the return value parameter should be included in the results
- /// An array of IDataParameters
- /// Thrown if spName is null
- /// Thrown if connection is null
- private IDataParameter[] GetSpParameterSetInternal(IDbConnection connection, string spName,
- bool includeReturnValueParameter)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
- if (string.IsNullOrEmpty(spName)) throw new ArgumentNullException(nameof(spName));
-
- // string hashKey = connection.ConnectionString + ":" + spName + (includeReturnValueParameter ? ":include ReturnValue Parameter":"");
-
- var cachedParameters = GetCachedParameterSet(connection,
- spName + (includeReturnValueParameter ? ":include ReturnValue Parameter" : ""));
-
- if (cachedParameters == null)
- {
- var spParameters = DiscoverSpParameterSet(connection, spName, includeReturnValueParameter);
- CacheParameterSet(connection,
- spName + (includeReturnValueParameter ? ":include ReturnValue Parameter" : ""), spParameters);
-
- cachedParameters = AdoHelperParameterCache.CloneParameters(spParameters);
- }
-
- return cachedParameters;
- }
-
- ///
- /// Retrieve a parameter array from the cache
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters
- /// Thrown if connectionString is null
- /// Thrown if commandText is null
- public IDataParameter[] GetCachedParameterSet(string connectionString, string commandText)
- {
- using (var connection = GetConnection(connectionString))
- {
- return GetCachedParameterSetInternal(connection, commandText);
- }
- }
-
- ///
- /// Retrieve a parameter array from the cache
- ///
- /// A valid IDbConnection object
- /// SQL command
- /// An array of IDataParameters
- /// Thrown if commandText is null
- /// Thrown if connection is null
- public IDataParameter[] GetCachedParameterSet(IDbConnection connection, string commandText)
- {
- return GetCachedParameterSetInternal(connection, commandText);
- }
-
- ///
- /// Retrieve a parameter array from the cache
- ///
- /// A valid IDbConnection object
- /// SQL command
- /// An array of IDataParameters
- private IDataParameter[] GetCachedParameterSetInternal(IDbConnection connection, string commandText)
- {
- var mustCloseConnection = false;
- // this way we control the connection, and therefore the connection string that gets saved as a hash key
- if (connection.State != ConnectionState.Open)
- {
- connection.Open();
- mustCloseConnection = true;
- }
-
- var parameters = AdoHelperParameterCache.GetCachedParameterSet(connection.ConnectionString, commandText);
-
- if (mustCloseConnection)
- {
- connection.Close();
- }
-
- return parameters;
- }
-
- ///
- /// Add parameter array to the cache
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters to be cached
- public void CacheParameterSet(string connectionString, string commandText,
- params IDataParameter[] commandParameters)
- {
- using (var connection = GetConnection(connectionString))
- {
- CacheParameterSetInternal(connection, commandText, commandParameters);
- }
- }
-
- ///
- /// Add parameter array to the cache
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An array of IDataParameters to be cached
- public void CacheParameterSet(IDbConnection connection, string commandText,
- params IDataParameter[] commandParameters)
- {
- if (connection is ICloneable)
- {
- using (var clonedConnection = (IDbConnection) ((ICloneable) connection).Clone())
- {
- CacheParameterSetInternal(clonedConnection, commandText, commandParameters);
- }
- }
- else
- {
- throw new InvalidCastException();
- }
- }
-
- ///
- /// Add parameter array to the cache
- ///
- /// A valid IDbConnection
- /// SQL command
- /// An array of IDataParameters to be cached
- private void CacheParameterSetInternal(IDbConnection connection, string commandText,
- params IDataParameter[] commandParameters)
- {
- // this way we control the connection, and therefore the connection string that gets saved as a hask key
- connection.Open();
- AdoHelperParameterCache.CacheParameterSet(connection.ConnectionString, commandText, commandParameters);
- connection.Close();
- }
-
- ///
- /// Resolve at run time the appropriate set of IDataParameters for a stored procedure
- ///
- /// A valid IDbConnection object
- /// The name of the stored procedure
- /// Whether or not to include their return value parameter
- /// The parameter array discovered.
- /// Thrown if spName is null
- /// Thrown if connection is null
- private IDataParameter[] DiscoverSpParameterSet(IDbConnection connection, string spName,
- bool includeReturnValueParameter)
- {
- if (connection == null) throw new ArgumentNullException(nameof(connection));
- if (string.IsNullOrEmpty(spName)) throw new ArgumentNullException(nameof(spName));
-
- var cmd = connection.CreateCommand();
- cmd.CommandText = spName;
- cmd.CommandType = CommandType.StoredProcedure;
-
- connection.Open();
- DeriveParameters(cmd);
- connection.Close();
-
- if (!includeReturnValueParameter)
- {
- // not all providers have return value parameters...don't just remove this parameter indiscriminately
- if (cmd.Parameters.Count > 0 &&
- ((IDataParameter) cmd.Parameters[0]).Direction == ParameterDirection.ReturnValue)
- {
- cmd.Parameters.RemoveAt(0);
- }
- }
-
- var discoveredParameters = new IDataParameter[cmd.Parameters.Count];
-
- cmd.Parameters.CopyTo(discoveredParameters, 0);
-
- // Init the parameters with a DBNull value
- foreach (var discoveredParameter in discoveredParameters)
- {
- discoveredParameter.Value = DBNull.Value;
- }
- return discoveredParameters;
- }
-
- #endregion Parameter Discovery Functions
-
- #region Utility Functions
-
- public string ToTopSqlString(string connectionString, string tableName, string columns, string whereString, string orderString, int startIndex, int count)
- {
- return DataProvider.DatabaseDao.GetSelectSqlString(connectionString, tableName, startIndex + 1, count,
- columns, whereString, orderString);
- }
-
- public string ToTopSqlString(string tableName, string columns, string whereString, string orderString, int count)
- {
- return SqlUtils.ToTopSqlString(tableName, columns, whereString, orderString, count);
- }
-
- public string ToPlusSqlString(string fieldName, int plusNum)
- {
- return SqlUtils.ToPlusSqlString(fieldName, plusNum);
- }
-
- public string ToMinusSqlString(string fieldName, int minusNum)
- {
- return SqlUtils.ToMinusSqlString(fieldName, minusNum);
- }
-
- public string ToNowSqlString()
- {
- return SqlUtils.GetComparableNow();
- }
-
- public string ToDateSqlString(DateTime date)
- {
- return SqlUtils.GetComparableDate(date);
- }
-
- public string ToDateTimeSqlString(DateTime dateTime)
- {
- return SqlUtils.GetComparableDate(dateTime);
- }
-
- public string Encrypt(string inputString)
- {
- return TranslateUtils.EncryptStringBySecretKey(inputString);
- }
-
- public string Decrypt(string inputString)
- {
- return TranslateUtils.DecryptStringBySecretKey(inputString);
- }
-
- public string FilterXss(string html)
- {
- return PageUtils.FilterXss(html);
- }
-
- public string FilterSql(string sql)
- {
- return PageUtils.FilterSql(sql);
- }
-
- #endregion Utility Functions
-
- }
-
- #region ParameterCache
- ///
- /// ADOHelperParameterCache provides functions to leverage a static cache of procedure parameters, and the
- /// ability to discover parameters for stored procedures at run-time.
- ///
- public sealed class AdoHelperParameterCache
- {
- private static Hashtable paramCache = Hashtable.Synchronized(new Hashtable());
-
- ///
- /// Deep copy of cached IDataParameter array
- ///
- ///
- ///
- internal static IDataParameter[] CloneParameters(IDataParameter[] originalParameters)
- {
- var clonedParameters = new IDataParameter[originalParameters.Length];
-
- for (int i = 0, j = originalParameters.Length; i < j; i++)
- {
- clonedParameters[i] = (IDataParameter)((ICloneable)originalParameters[i]).Clone();
- }
-
- return clonedParameters;
- }
-
-#region caching functions
-
- ///
- /// Add parameter array to the cache
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters to be cached
- /// Thrown if commandText is null
- /// Thrown if connectionString is null
- internal static void CacheParameterSet(string connectionString, string commandText, params IDataParameter[] commandParameters)
- {
- if( string.IsNullOrEmpty(connectionString) ) throw new ArgumentNullException( nameof(connectionString) );
- if( string.IsNullOrEmpty(commandText) ) throw new ArgumentNullException( nameof(commandText) );
-
- var hashKey = connectionString + ":" + commandText;
-
- paramCache[hashKey] = commandParameters;
- }
-
- ///
- /// Retrieve a parameter array from the cache
- ///
- /// A valid connection string for an IDbConnection
- /// SQL command
- /// An array of IDataParameters
- /// Thrown if commandText is null
- /// Thrown if connectionString is null
- internal static IDataParameter[] GetCachedParameterSet(string connectionString, string commandText)
- {
- if( string.IsNullOrEmpty(connectionString) ) throw new ArgumentNullException( nameof(connectionString) );
- if( string.IsNullOrEmpty(commandText) ) throw new ArgumentNullException( nameof(commandText) );
-
- var hashKey = connectionString + ":" + commandText;
-
- var cachedParameters = paramCache[hashKey] as IDataParameter[];
- if (cachedParameters == null)
- {
- return null;
- }
- else
- {
- return CloneParameters(cachedParameters);
- }
- }
-
-#endregion caching functions
- }
-#endregion
-}
diff --git a/SiteServer.CMS/Data/MySql.cs b/SiteServer.CMS/Data/MySql.cs
deleted file mode 100644
index ad0e0335d..000000000
--- a/SiteServer.CMS/Data/MySql.cs
+++ /dev/null
@@ -1,287 +0,0 @@
-using System;
-using System.Data;
-using System.IO;
-using System.Xml;
-using MySql.Data.MySqlClient;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Data
-{
- public class MySql : DbHelper, IDataApi
- {
- #region Overrides
- ///
- /// Returns an array of SqlParameters of the specified size
- ///
- /// size of the array
- /// The array of SqlParameters
- protected override IDataParameter[] GetDataParameters(int size)
- {
- return new MySqlParameter[size];
- }
-
-
- ///
- /// Returns a SqlConnection object for the given connection string
- ///
- /// The connection string to be used to create the connection
- /// A SqlConnection object
- public override IDbConnection GetConnection(string connectionString)
- {
- return new MySqlConnection(connectionString);
- }
-
- public IDbCommand GetCommand()
- {
- return new MySqlCommand();
- }
-
-
- ///
- /// Returns a SqlDataAdapter object
- ///
- /// The SqlDataAdapter
- public override IDbDataAdapter GetDataAdapter()
- {
- return new MySqlDataAdapter();
- }
-
-
- ///
- /// Calls the CommandBuilder.DeriveParameters method for the specified provider, doing any setup and cleanup necessary
- ///
- /// The IDbCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the IDbCommand.
- public override void DeriveParameters(IDbCommand cmd)
- {
- bool mustCloseConnection = false;
-
-
- if (!(cmd is MySqlCommand))
- throw new ArgumentException("The command provided is not a SqlCommand instance.", "cmd");
-
-
- if (cmd.Connection.State != ConnectionState.Open)
- {
- cmd.Connection.Open();
- mustCloseConnection = true;
- }
-
-
- MySqlCommandBuilder.DeriveParameters((MySqlCommand)cmd);
-
-
- if (mustCloseConnection)
- {
- cmd.Connection.Close();
- }
- }
-
-
- ///
- /// Returns a SqlParameter object
- ///
- /// The SqlParameter object
- public override IDataParameter GetParameter()
- {
- return new MySqlParameter();
- }
-
-
- ///
- /// Detach the IDataParameters from the command object, so they can be used again.
- ///
- /// command object to clear
- protected override void ClearCommand(IDbCommand command)
- {
- // HACK: There is a problem here, the output parameter values are fletched
- // when the reader is closed, so if the parameters are detached from the command
- // then the IDataReader can磘 set its values.
- // When this happen, the parameters can磘 be used again in other command.
- bool canClear = true;
-
-
- foreach (IDataParameter commandParameter in command.Parameters)
- {
- if (commandParameter.Direction != ParameterDirection.Input)
- canClear = false;
-
-
- }
- if (canClear)
- {
- command.Parameters.Clear();
- }
- }
-
-
- ///
- /// This cleans up the parameter syntax for an SQL Server call. This was split out from PrepareCommand so that it could be called independently.
- ///
- /// An IDbCommand object containing the CommandText to clean.
- public override void CleanParameterSyntax(IDbCommand command)
- {
- // do nothing for SQL
- }
-
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the provided SqlConnection.
- ///
- ///
- ///
- /// XmlReader r = helper.ExecuteXmlReader(command);
- ///
- /// The IDbCommand to execute
- /// An XmlReader containing the resultset generated by the command
- public override XmlReader ExecuteXmlReader(IDbCommand command)
- {
- bool mustCloseConnection = false;
-
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
-
- CleanParameterSyntax(command);
- MySqlDataAdapter da = new MySqlDataAdapter((MySqlCommand)command);
- DataSet ds = new DataSet();
-
-
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- da.Fill(ds);
-
-
- StringReader stream = new StringReader(ds.GetXml());
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
-
-
- return new XmlTextReader(stream);
- }
-
-
- ///
- /// Provider specific code to set up the updating/ed event handlers used by UpdateDataset
- ///
- /// DataAdapter to attach the event handlers to
- /// The handler to be called when a row is updating
- /// The handler to be called when a row is updated
- protected override void AddUpdateEventHandlers(IDbDataAdapter dataAdapter, RowUpdatingHandler rowUpdatingHandler, RowUpdatedHandler rowUpdatedHandler)
- {
- if (rowUpdatingHandler != null)
- {
- MRowUpdating = rowUpdatingHandler;
- ((MySqlDataAdapter)dataAdapter).RowUpdating += RowUpdating;
- }
-
-
- if (rowUpdatedHandler != null)
- {
- MRowUpdated = rowUpdatedHandler;
- ((MySqlDataAdapter)dataAdapter).RowUpdated += RowUpdated;
- }
- }
-
-
- ///
- /// Handles the RowUpdating event
- ///
- /// The object that published the event
- /// The SqlRowUpdatingEventArgs
- protected void RowUpdating(object obj, MySqlRowUpdatingEventArgs e)
- {
- base.RowUpdating(obj, e);
- }
-
-
- ///
- /// Handles the RowUpdated event
- ///
- /// The object that published the event
- /// The SqlRowUpdatedEventArgs
- protected void RowUpdated(object obj, MySqlRowUpdatedEventArgs e)
- {
- base.RowUpdated(obj, e);
- }
-
-
- ///
- /// Handle any provider-specific issues with BLOBs here by "washing" the IDataParameter and returning a new one that is set up appropriately for the provider.
- ///
- /// The IDbConnection to use in cleansing the parameter
- /// The parameter before cleansing
- /// The parameter after it's been cleansed.
- protected override IDataParameter GetBlobParameter(IDbConnection connection, IDataParameter p)
- {
- // do nothing special for BLOBs...as far as we know now.
- return p;
- }
-
- #endregion
-
- public string GetString(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return string.Empty;
- return rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i);
- }
-
- public bool GetBoolean(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return false;
- return !rdr.IsDBNull(i) && rdr.GetBoolean(i);
- }
-
- public int GetInt(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i);
- }
-
- public decimal GetDecimal(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetDecimal(i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return DateTime.MinValue;
- return rdr.IsDBNull(i) ? DateTime.MinValue : rdr.GetDateTime(i);
- }
-
- public string GetString(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetString(rdr, i);
- }
-
- public bool GetBoolean(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetBoolean(rdr, i);
- }
-
- public int GetInt(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetInt(rdr, i);
- }
-
- public decimal GetDecimal(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDecimal(rdr, i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDateTime(rdr, i);
- }
- }
-}
diff --git a/SiteServer.CMS/Data/Oracle.cs b/SiteServer.CMS/Data/Oracle.cs
deleted file mode 100644
index 09c6a3d6b..000000000
--- a/SiteServer.CMS/Data/Oracle.cs
+++ /dev/null
@@ -1,343 +0,0 @@
-using System;
-using System.Data;
-using System.IO;
-using System.Xml;
-using Oracle.ManagedDataAccess.Client;
-using SiteServer.Plugin;
-using SiteServer.Utils;
-
-namespace SiteServer.CMS.Data
-{
- public class Oracle : DbHelper, IDataApi
- {
- #region Overrides
- ///
- /// Returns an array of SqlParameters of the specified size
- ///
- /// size of the array
- /// The array of SqlParameters
- protected override IDataParameter[] GetDataParameters(int size)
- {
- return new OracleParameter[size];
- }
-
-
- ///
- /// Returns a SqlConnection object for the given connection string
- ///
- /// The connection string to be used to create the connection
- /// A SqlConnection object
- public override IDbConnection GetConnection(string connectionString)
- {
- return new OracleConnection(connectionString);
- }
-
- public IDbCommand GetCommand()
- {
- return new OracleCommand();
- }
-
-
- ///
- /// Returns a SqlDataAdapter object
- ///
- /// The SqlDataAdapter
- public override IDbDataAdapter GetDataAdapter()
- {
- return new OracleDataAdapter();
- }
-
-
- ///
- /// Calls the CommandBuilder.DeriveParameters method for the specified provider, doing any setup and cleanup necessary
- ///
- /// The IDbCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the IDbCommand.
- public override void DeriveParameters(IDbCommand cmd)
- {
- bool mustCloseConnection = false;
-
-
- if (!(cmd is OracleCommand))
- throw new ArgumentException("The command provided is not a SqlCommand instance.", "cmd");
-
-
- if (cmd.Connection.State != ConnectionState.Open)
- {
- cmd.Connection.Open();
- mustCloseConnection = true;
- }
-
-
- OracleCommandBuilder.DeriveParameters((OracleCommand)cmd);
-
-
- if (mustCloseConnection)
- {
- cmd.Connection.Close();
- }
- }
-
-
- ///
- /// Returns a SqlParameter object
- ///
- /// The SqlParameter object
- public override IDataParameter GetParameter()
- {
- return new OracleParameter();
- }
-
- public override IDataParameter GetParameter(string name, object value)
- {
- var parameter = new OracleParameter
- {
- ParameterName = name
- };
- if (value == null)
- {
- parameter.DbType = DbType.String;
- parameter.Value = null;
- }
- else if (value is DateTime)
- {
- parameter.DbType = DbType.DateTime;
- var dbValue = (DateTime) value;
- if (dbValue < DateUtils.SqlMinValue)
- {
- dbValue = DateUtils.SqlMinValue;
- }
- parameter.Value = dbValue;
- }
- else if (value is int)
- {
- parameter.DbType = DbType.Int32;
- parameter.Value = (int)value;
- }
- else if (value is decimal)
- {
- parameter.DbType = DbType.Decimal;
- parameter.Value = (decimal)value;
- }
- else if (value is string)
- {
- parameter.DbType = DbType.String;
- parameter.Value = SqlUtils.ToOracleDbValue(DataType.VarChar, value);
- //parameter.Value = (string)value;
- }
- else if (value is bool)
- {
- parameter.DbType = DbType.Int32;
- parameter.Value = (bool) value ? 1 : 0;
- }
- else
- {
- parameter.DbType = DbType.String;
- parameter.Value = SqlUtils.ToOracleDbValue(DataType.VarChar, value.ToString());
- //parameter.Value = value.ToString();
- }
-
- return parameter;
- }
-
- ///
- /// Detach the IDataParameters from the command object, so they can be used again.
- ///
- /// command object to clear
- protected override void ClearCommand(IDbCommand command)
- {
- // HACK: There is a problem here, the output parameter values are fletched
- // when the reader is closed, so if the parameters are detached from the command
- // then the IDataReader can磘 set its values.
- // When this happen, the parameters can磘 be used again in other command.
- bool canClear = true;
-
-
- foreach (IDataParameter commandParameter in command.Parameters)
- {
- if (commandParameter.Direction != ParameterDirection.Input)
- canClear = false;
-
-
- }
- if (canClear)
- {
- command.Parameters.Clear();
- }
- }
-
-
- ///
- /// This cleans up the parameter syntax for an SQL Server call. This was split out from PrepareCommand so that it could be called independently.
- ///
- /// An IDbCommand object containing the CommandText to clean.
- public override void CleanParameterSyntax(IDbCommand command)
- {
- // do nothing for SQL
- }
-
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the provided SqlConnection.
- ///
- ///
- ///
- /// XmlReader r = helper.ExecuteXmlReader(command);
- ///
- /// The IDbCommand to execute
- /// An XmlReader containing the resultset generated by the command
- public override XmlReader ExecuteXmlReader(IDbCommand command)
- {
- bool mustCloseConnection = false;
-
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
-
- CleanParameterSyntax(command);
- OracleDataAdapter da = new OracleDataAdapter((OracleCommand)command);
- DataSet ds = new DataSet();
-
-
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- da.Fill(ds);
-
-
- StringReader stream = new StringReader(ds.GetXml());
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
-
-
- return new XmlTextReader(stream);
- }
-
-
- ///
- /// Provider specific code to set up the updating/ed event handlers used by UpdateDataset
- ///
- /// DataAdapter to attach the event handlers to
- /// The handler to be called when a row is updating
- /// The handler to be called when a row is updated
- protected override void AddUpdateEventHandlers(IDbDataAdapter dataAdapter, RowUpdatingHandler rowUpdatingHandler, RowUpdatedHandler rowUpdatedHandler)
- {
- if (rowUpdatingHandler != null)
- {
- this.MRowUpdating = rowUpdatingHandler;
- ((OracleDataAdapter)dataAdapter).RowUpdating += new OracleRowUpdatingEventHandler(RowUpdating);
- }
-
-
- if (rowUpdatedHandler != null)
- {
- this.MRowUpdated = rowUpdatedHandler;
- ((OracleDataAdapter)dataAdapter).RowUpdated += new OracleRowUpdatedEventHandler(RowUpdated);
- }
- }
-
-
- ///
- /// Handles the RowUpdating event
- ///
- /// The object that published the event
- /// The SqlRowUpdatingEventArgs
- protected void RowUpdating(object obj, OracleRowUpdatingEventArgs e)
- {
- base.RowUpdating(obj, e);
- }
-
-
- ///
- /// Handles the RowUpdated event
- ///
- /// The object that published the event
- /// The SqlRowUpdatedEventArgs
- protected void RowUpdated(object obj, OracleRowUpdatedEventArgs e)
- {
- base.RowUpdated(obj, e);
- }
-
-
- ///
- /// Handle any provider-specific issues with BLOBs here by "washing" the IDataParameter and returning a new one that is set up appropriately for the provider.
- ///
- /// The IDbConnection to use in cleansing the parameter
- /// The parameter before cleansing
- /// The parameter after it's been cleansed.
- protected override IDataParameter GetBlobParameter(IDbConnection connection, IDataParameter p)
- {
- // do nothing special for BLOBs...as far as we know now.
- return p;
- }
- #endregion
-
- public string GetString(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return string.Empty;
- var retval = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i);
- if (retval == SqlUtils.OracleEmptyValue)
- {
- retval = string.Empty;
- }
- return retval;
- }
-
- public bool GetBoolean(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return false;
- return GetInt(rdr, i) == 1;
- }
-
- public int GetInt(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i);
- }
-
- public decimal GetDecimal(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetDecimal(i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return DateTime.MinValue;
- return rdr.IsDBNull(i) ? DateTime.MinValue : rdr.GetDateTime(i);
- }
-
- public string GetString(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetString(rdr, i);
- }
-
- public bool GetBoolean(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetBoolean(rdr, i);
- }
-
- public int GetInt(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetInt(rdr, i);
- }
-
- public decimal GetDecimal(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDecimal(rdr, i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDateTime(rdr, i);
- }
- }
-}
diff --git a/SiteServer.CMS/Data/PostgreSql.cs b/SiteServer.CMS/Data/PostgreSql.cs
deleted file mode 100644
index 6c577235a..000000000
--- a/SiteServer.CMS/Data/PostgreSql.cs
+++ /dev/null
@@ -1,284 +0,0 @@
-using System;
-using System.Data;
-using System.IO;
-using System.Xml;
-using Npgsql;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Data
-{
- public class PostgreSql : DbHelper, IDataApi
- {
- ///
- /// Returns an array of SqlParameters of the specified size
- ///
- /// size of the array
- /// The array of SqlParameters
- protected override IDataParameter[] GetDataParameters(int size)
- {
- return new NpgsqlParameter[size];
- }
-
-
- ///
- /// Returns a SqlConnection object for the given connection string
- ///
- /// The connection string to be used to create the connection
- /// A SqlConnection object
- public override IDbConnection GetConnection(string connectionString)
- {
- return new NpgsqlConnection(connectionString);
- }
-
- public IDbCommand GetCommand()
- {
- return new NpgsqlCommand();
- }
-
-
- ///
- /// Returns a SqlDataAdapter object
- ///
- /// The SqlDataAdapter
- public override IDbDataAdapter GetDataAdapter()
- {
- return new NpgsqlDataAdapter();
- }
-
-
- ///
- /// Calls the CommandBuilder.DeriveParameters method for the specified provider, doing any setup and cleanup necessary
- ///
- /// The IDbCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the IDbCommand.
- public override void DeriveParameters(IDbCommand cmd)
- {
- bool mustCloseConnection = false;
-
-
- if (!(cmd is NpgsqlCommand))
- throw new ArgumentException("The command provided is not a SqlCommand instance.", "cmd");
-
-
- if (cmd.Connection.State != ConnectionState.Open)
- {
- cmd.Connection.Open();
- mustCloseConnection = true;
- }
-
-
- NpgsqlCommandBuilder.DeriveParameters((NpgsqlCommand)cmd);
-
-
- if (mustCloseConnection)
- {
- cmd.Connection.Close();
- }
- }
-
-
- ///
- /// Returns a SqlParameter object
- ///
- /// The SqlParameter object
- public override IDataParameter GetParameter()
- {
- return new NpgsqlParameter();
- }
-
-
- ///
- /// Detach the IDataParameters from the command object, so they can be used again.
- ///
- /// command object to clear
- protected override void ClearCommand(IDbCommand command)
- {
- // HACK: There is a problem here, the output parameter values are fletched
- // when the reader is closed, so if the parameters are detached from the command
- // then the IDataReader can磘 set its values.
- // When this happen, the parameters can磘 be used again in other command.
- bool canClear = true;
-
-
- foreach (IDataParameter commandParameter in command.Parameters)
- {
- if (commandParameter.Direction != ParameterDirection.Input)
- canClear = false;
-
-
- }
- if (canClear)
- {
- command.Parameters.Clear();
- }
- }
-
-
- ///
- /// This cleans up the parameter syntax for an SQL Server call. This was split out from PrepareCommand so that it could be called independently.
- ///
- /// An IDbCommand object containing the CommandText to clean.
- public override void CleanParameterSyntax(IDbCommand command)
- {
- // do nothing for SQL
- }
-
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the provided SqlConnection.
- ///
- ///
- ///
- /// XmlReader r = helper.ExecuteXmlReader(command);
- ///
- /// The IDbCommand to execute
- /// An XmlReader containing the resultset generated by the command
- public override XmlReader ExecuteXmlReader(IDbCommand command)
- {
- bool mustCloseConnection = false;
-
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
-
- CleanParameterSyntax(command);
- NpgsqlDataAdapter da = new NpgsqlDataAdapter((NpgsqlCommand)command);
- DataSet ds = new DataSet();
-
-
- da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
- da.Fill(ds);
-
-
- StringReader stream = new StringReader(ds.GetXml());
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
-
-
- return new XmlTextReader(stream);
- }
-
-
- ///
- /// Provider specific code to set up the updating/ed event handlers used by UpdateDataset
- ///
- /// DataAdapter to attach the event handlers to
- /// The handler to be called when a row is updating
- /// The handler to be called when a row is updated
- protected override void AddUpdateEventHandlers(IDbDataAdapter dataAdapter, RowUpdatingHandler rowUpdatingHandler, RowUpdatedHandler rowUpdatedHandler)
- {
- if (rowUpdatingHandler != null)
- {
- this.MRowUpdating = rowUpdatingHandler;
- ((NpgsqlDataAdapter)dataAdapter).RowUpdating += new NpgsqlRowUpdatingEventHandler(RowUpdating);
- }
-
-
- if (rowUpdatedHandler != null)
- {
- this.MRowUpdated = rowUpdatedHandler;
- ((NpgsqlDataAdapter)dataAdapter).RowUpdated += new NpgsqlRowUpdatedEventHandler(RowUpdated);
- }
- }
-
-
- ///
- /// Handles the RowUpdating event
- ///
- /// The object that published the event
- /// The SqlRowUpdatingEventArgs
- protected void RowUpdating(object obj, NpgsqlRowUpdatingEventArgs e)
- {
- base.RowUpdating(obj, e);
- }
-
-
- ///
- /// Handles the RowUpdated event
- ///
- /// The object that published the event
- /// The SqlRowUpdatedEventArgs
- protected void RowUpdated(object obj, NpgsqlRowUpdatedEventArgs e)
- {
- base.RowUpdated(obj, e);
- }
-
-
- ///
- /// Handle any provider-specific issues with BLOBs here by "washing" the IDataParameter and returning a new one that is set up appropriately for the provider.
- ///
- /// The IDbConnection to use in cleansing the parameter
- /// The parameter before cleansing
- /// The parameter after it's been cleansed.
- protected override IDataParameter GetBlobParameter(IDbConnection connection, IDataParameter p)
- {
- // do nothing special for BLOBs...as far as we know now.
- return p;
- }
-
- public string GetString(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return string.Empty;
- return rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i);
- }
-
- public bool GetBoolean(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return false;
- return !rdr.IsDBNull(i) && rdr.GetBoolean(i);
- }
-
- public int GetInt(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i);
- }
-
- public decimal GetDecimal(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetDecimal(i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return DateTime.MinValue;
- return rdr.IsDBNull(i) ? DateTime.MinValue : rdr.GetDateTime(i);
- }
-
- public string GetString(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetString(rdr, i);
- }
-
- public bool GetBoolean(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetBoolean(rdr, i);
- }
-
- public int GetInt(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetInt(rdr, i);
- }
-
- public decimal GetDecimal(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDecimal(rdr, i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDateTime(rdr, i);
- }
- }
-}
diff --git a/SiteServer.CMS/Data/SqlHelper.cs b/SiteServer.CMS/Data/SqlHelper.cs
deleted file mode 100644
index 63fd81bae..000000000
--- a/SiteServer.CMS/Data/SqlHelper.cs
+++ /dev/null
@@ -1,2613 +0,0 @@
-// ===============================================================================
-// Microsoft Data Access Application Block for .NET
-// http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp
-//
-// SQLHelper.cs
-//
-// This file contains the implementations of the SqlHelper and SqlHelperParameterCache
-// classes.
-//
-// For more information see the Data Access Application Block Implementation Overview.
-// ===============================================================================
-// Release history
-// VERSION DESCRIPTION
-// 2.0 Added support for FillDataset, UpdateDataset and "Param" helper methods
-//
-// ===============================================================================
-// Copyright (C) 2000-2001 Microsoft Corporation
-// All rights reserved.
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
-// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
-// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
-// FITNESS FOR A PARTICULAR PURPOSE.
-// ==============================================================================
-
-using System;
-using System.Data;
-using System.Xml;
-using System.Data.SqlClient;
-using System.Collections;
-
-namespace SiteServer.CMS.Data
-{
- ///
- /// The SqlHelper class is intended to encapsulate high performance, scalable best practices for
- /// common uses of SqlClient
- ///
- public sealed class SqlHelper
- {
- //Database connection strings
-
- #region private utility methods & constructors
-
- // Since this class provides only static methods, make the default constructor private to prevent
- // instances from being created with "new SqlHelper()"
- private SqlHelper() {}
-
- ///
- /// This method is used to attach array of SqlParameters to a SqlCommand.
- ///
- /// This method will assign a value of DbNull to any parameter with a direction of
- /// InputOutput and a value of null.
- ///
- /// This behavior will prevent default values from being used, but
- /// this will be the less common case than an intended pure output parameter (derived as InputOutput)
- /// where the user provided no input value.
- ///
- /// The command to which the parameters will be added
- /// An array of SqlParameters to be added to command
- private static void AttachParameters(SqlCommand command, SqlParameter[] commandParameters)
- {
- if( command == null ) throw new ArgumentNullException( "command" );
- if( commandParameters != null )
- {
- foreach (var p in commandParameters)
- {
- if( p != null )
- {
- // Check for derived output value with no value assigned
- if ( ( p.Direction == ParameterDirection.InputOutput ||
- p.Direction == ParameterDirection.Input ) &&
- (p.Value == null))
- {
- p.Value = DBNull.Value;
- }
- command.Parameters.Add(p);
- }
- }
- }
- }
-
- ///
- /// This method assigns dataRow column values to an array of SqlParameters
- ///
- /// Array of SqlParameters to be assigned values
- /// The dataRow used to hold the stored procedure's parameter values
- private static void AssignParameterValues(SqlParameter[] commandParameters, DataRow dataRow)
- {
- if ((commandParameters == null) || (dataRow == null))
- {
- // Do nothing if we get no data
- return;
- }
-
- var i = 0;
- // Set the parameters values
- foreach(var commandParameter in commandParameters)
- {
- // Check the parameter name
- if( commandParameter.ParameterName == null ||
- commandParameter.ParameterName.Length <= 1 )
- throw new Exception(
- $"Please provide a valid parameter name on the parameter #{i}, the ParameterName property has the following value: '{commandParameter.ParameterName}'.");
- if (dataRow.Table.Columns.IndexOf(commandParameter.ParameterName.Substring(1)) != -1)
- commandParameter.Value = dataRow[commandParameter.ParameterName.Substring(1)];
- i++;
- }
- }
-
- ///
- /// This method assigns an array of values to an array of SqlParameters
- ///
- /// Array of SqlParameters to be assigned values
- /// Array of objects holding the values to be assigned
- private static void AssignParameterValues(SqlParameter[] commandParameters, object[] parameterValues)
- {
- if ((commandParameters == null) || (parameterValues == null))
- {
- // Do nothing if we get no data
- return;
- }
-
- // We must have the same number of values as we pave parameters to put them in
- if (commandParameters.Length != parameterValues.Length)
- {
- throw new ArgumentException("Parameter count does not match Parameter Value count.");
- }
-
- // Iterate through the SqlParameters, assigning the values from the corresponding position in the
- // value array
- for (int i = 0, j = commandParameters.Length; i < j; i++)
- {
- // If the current array value derives from IDbDataParameter, then assign its Value property
- if (parameterValues[i] is IDbDataParameter)
- {
- var paramInstance = (IDbDataParameter)parameterValues[i];
- if( paramInstance.Value == null )
- {
- commandParameters[i].Value = DBNull.Value;
- }
- else
- {
- commandParameters[i].Value = paramInstance.Value;
- }
- }
- else if (parameterValues[i] == null)
- {
- commandParameters[i].Value = DBNull.Value;
- }
- else
- {
- commandParameters[i].Value = parameterValues[i];
- }
- }
- }
-
- ///
- /// This method opens (if necessary) and assigns a connection, transaction, command type and parameters
- /// to the provided command
- ///
- /// The SqlCommand to be prepared
- /// A valid SqlConnection, on which to execute this command
- /// A valid SqlTransaction, or 'null'
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParameters to be associated with the command or 'null' if no parameters are required
- /// true if the connection was opened by the method, otherwose is false.
- private static void PrepareCommand(SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, out bool mustCloseConnection )
- {
- if( command == null ) throw new ArgumentNullException( "command" );
- if( commandText == null || commandText.Length == 0 ) throw new ArgumentNullException( "commandText" );
-
- // If the provided connection is not open, we will open it
- if (connection.State != ConnectionState.Open)
- {
- mustCloseConnection = true;
- connection.Open();
- }
- else
- {
- mustCloseConnection = false;
- }
-
- // Associate the connection with the command
- command.Connection = connection;
-
- // Set the command text (stored procedure name or SQL statement)
- command.CommandText = commandText;
-
- // If we were provided a transaction, assign it
- if (transaction != null)
- {
- if( transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- command.Transaction = transaction;
- }
-
- // Set the command type
- command.CommandType = commandType;
-
- // Attach the command parameters if they are provided
- if (commandParameters != null)
- {
- AttachParameters(command, commandParameters);
- }
- return;
- }
-
- #endregion private utility methods & constructors
-
- #region ExecuteNonQuery
-
- ///
- /// Execute a SqlCommand (that returns no resultset and takes no parameters) against the database specified in
- /// the connection string
- ///
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders");
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteNonQuery(connectionString, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns no resultset) against the database specified in the connection string
- /// using the provided parameters
- ///
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
-
- // Create & open a SqlConnection, and dispose of it after we are done
- using (var connection = new SqlConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- return ExecuteNonQuery(connection, commandType, commandText, commandParameters);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the database specified in
- /// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(connString, "PublishOrders", 24, 36);
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored prcedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlConnection.
- ///
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders");
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteNonQuery(connection, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns no resultset) against the specified SqlConnection
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
-
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- var mustCloseConnection = false;
- PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Finally, execute the command
- var retval = cmd.ExecuteNonQuery();
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
- if( mustCloseConnection )
- connection.Close();
- return retval;
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection
- /// using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(conn, "PublishOrders", 24, 36);
- ///
- /// A valid SqlConnection
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(SqlConnection connection, string spName, params object[] parameterValues)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteNonQuery(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteNonQuery(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlTransaction.
- ///
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders");
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteNonQuery(transaction, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns no resultset) against the specified SqlTransaction
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
-
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- var mustCloseConnection = false;
- PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Finally, execute the command
- var retval = cmd.ExecuteNonQuery();
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
- return retval;
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified
- /// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// int result = ExecuteNonQuery(conn, trans, "PublishOrders", 24, 36);
- ///
- /// A valid SqlTransaction
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQuery(SqlTransaction transaction, string spName, params object[] parameterValues)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName);
- }
- }
-
- #endregion ExecuteNonQuery
-
- #region ExecuteDataset
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteDataset(connectionString, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
-
- // Create & open a SqlConnection, and dispose of it after we are done
- using (var connection = new SqlConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- return ExecuteDataset(connection, commandType, commandText, commandParameters);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
- /// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(connString, "GetOrders", 24, 36);
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(string connectionString, string spName, params object[] parameterValues)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
- ///
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteDataset(connection, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
-
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- var mustCloseConnection = false;
- PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Create the DataAdapter & DataSet
- using( var da = new SqlDataAdapter(cmd) )
- {
- var ds = new DataSet();
-
- // Fill the DataSet using default values for DataTable names, etc
- da.Fill(ds);
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
-
- if( mustCloseConnection )
- connection.Close();
-
- // Return the dataset
- return ds;
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(conn, "GetOrders", 24, 36);
- ///
- /// A valid SqlConnection
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(SqlConnection connection, string spName, params object[] parameterValues)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteDataset(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteDataset(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
- ///
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteDataset(transaction, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
-
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- var mustCloseConnection = false;
- PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Create the DataAdapter & DataSet
- using( var da = new SqlDataAdapter(cmd) )
- {
- var ds = new DataSet();
-
- // Fill the DataSet using default values for DataTable names, etc
- da.Fill(ds);
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
-
- // Return the dataset
- return ds;
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
- /// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// DataSet ds = ExecuteDataset(trans, "GetOrders", 24, 36);
- ///
- /// A valid SqlTransaction
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDataset(SqlTransaction transaction, string spName, params object[] parameterValues)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteDataset(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteDataset(transaction, CommandType.StoredProcedure, spName);
- }
- }
-
- #endregion ExecuteDataset
-
- #region ExecuteReader
-
- ///
- /// This enum is used to indicate whether the connection was provided by the caller, or created by SqlHelper, so that
- /// we can set the appropriate CommandBehavior when calling ExecuteReader()
- ///
- private enum SqlConnectionOwnership
- {
- /// Connection is owned and managed by SqlHelper
- Internal,
- /// Connection is owned and managed by the caller
- External
- }
-
- ///
- /// Create and prepare a SqlCommand, and call ExecuteReader with the appropriate CommandBehavior.
- ///
- ///
- /// If we created and opened the connection, we want the connection to be closed when the DataReader is closed.
- ///
- /// If the caller provided the connection, we want to leave it to them to manage.
- ///
- /// A valid SqlConnection, on which to execute this command
- /// A valid SqlTransaction, or 'null'
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParameters to be associated with the command or 'null' if no parameters are required
- /// Indicates whether the connection parameter was provided by the caller, or created by SqlHelper
- /// SqlDataReader containing the results of the command
- private static SqlDataReader ExecuteReader(SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, SqlConnectionOwnership connectionOwnership)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
-
- var mustCloseConnection = false;
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- try
- {
- PrepareCommand(cmd, connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Create a reader
- SqlDataReader dataReader;
-
- // Call ExecuteReader with the appropriate CommandBehavior
- if (connectionOwnership == SqlConnectionOwnership.External)
- {
- dataReader = cmd.ExecuteReader();
- }
- else
- {
- dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
- }
-
- // Detach the SqlParameters from the command object, so they can be used again.
- // HACK: There is a problem here, the output parameter values are fletched
- // when the reader is closed, so if the parameters are detached from the command
- // then the SqlReader can磘 set its values.
- // When this happen, the parameters can磘 be used again in other command.
- var canClear = true;
- foreach(SqlParameter commandParameter in cmd.Parameters)
- {
- if (commandParameter.Direction != ParameterDirection.Input)
- canClear = false;
- }
-
- if (canClear)
- {
- cmd.Parameters.Clear();
- }
-
- return dataReader;
- }
- catch
- {
- if( mustCloseConnection )
- connection.Close();
- throw;
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteReader(connectionString, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- SqlConnection connection = null;
- try
- {
- connection = new SqlConnection(connectionString);
- connection.Open();
-
- // Call the private overload that takes an internally owned connection in place of the connection string
- return ExecuteReader(connection, null, commandType, commandText, commandParameters,SqlConnectionOwnership.Internal);
- }
- catch
- {
- // If we fail to return the SqlDatReader, we need to close the connection ourselves
- if( connection != null ) connection.Close();
- throw;
- }
-
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
- /// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(connString, "GetOrders", 24, 36);
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(string connectionString, string spName, params object[] parameterValues)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- AssignParameterValues(commandParameters, parameterValues);
-
- return ExecuteReader(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteReader(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
- ///
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteReader(connection, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- // Pass through the call to the private overload using a null transaction value and an externally owned connection
- return ExecuteReader(connection, (SqlTransaction)null, commandType, commandText, commandParameters, SqlConnectionOwnership.External);
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(conn, "GetOrders", 24, 36);
- ///
- /// A valid SqlConnection
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(SqlConnection connection, string spName, params object[] parameterValues)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- AssignParameterValues(commandParameters, parameterValues);
-
- return ExecuteReader(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteReader(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
- ///
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteReader(transaction, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
-
- // Pass through to private overload, indicating that the connection is owned by the caller
- return ExecuteReader(transaction.Connection, transaction, commandType, commandText, commandParameters, SqlConnectionOwnership.External);
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
- /// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// SqlDataReader dr = ExecuteReader(trans, "GetOrders", 24, 36);
- ///
- /// A valid SqlTransaction
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReader(SqlTransaction transaction, string spName, params object[] parameterValues)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- AssignParameterValues(commandParameters, parameterValues);
-
- return ExecuteReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteReader(transaction, CommandType.StoredProcedure, spName);
- }
- }
-
- #endregion ExecuteReader
-
- #region ExecuteScalar
-
- ///
- /// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount");
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteScalar(connectionString, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a 1x1 resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- // Create & open a SqlConnection, and dispose of it after we are done
- using (var connection = new SqlConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- return ExecuteScalar(connection, commandType, commandText, commandParameters);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in
- /// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(connString, "GetOrderCount", 24, 36);
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(string connectionString, string spName, params object[] parameterValues)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlConnection.
- ///
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount");
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteScalar(connection, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
-
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
-
- var mustCloseConnection = false;
- PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Execute the command & return the results
- var retval = cmd.ExecuteScalar();
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
-
- if( mustCloseConnection )
- connection.Close();
-
- return retval;
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection
- /// using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(conn, "GetOrderCount", 24, 36);
- ///
- /// A valid SqlConnection
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(SqlConnection connection, string spName, params object[] parameterValues)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteScalar(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteScalar(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a 1x1 resultset and takes no parameters) against the provided SqlTransaction.
- ///
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount");
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteScalar(transaction, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
-
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- var mustCloseConnection = false;
- PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Execute the command & return the results
- var retval = cmd.ExecuteScalar();
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
- return retval;
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified
- /// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36);
- ///
- /// A valid SqlTransaction
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalar(SqlTransaction transaction, string spName, params object[] parameterValues)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // PPull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteScalar(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteScalar(transaction, CommandType.StoredProcedure, spName);
- }
- }
-
- #endregion ExecuteScalar
-
- #region ExecuteXmlReader
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
- ///
- ///
- /// e.g.:
- /// XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command using "FOR XML AUTO"
- /// An XmlReader containing the resultset generated by the command
- public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteXmlReader(connection, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// XmlReader r = ExecuteXmlReader(conn, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command using "FOR XML AUTO"
- /// An array of SqlParamters used to execute the command
- /// An XmlReader containing the resultset generated by the command
- public static XmlReader ExecuteXmlReader(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
-
- var mustCloseConnection = false;
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- try
- {
- PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Create the DataAdapter & DataSet
- var retval = cmd.ExecuteXmlReader();
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
-
- return retval;
- }
- catch
- {
- if( mustCloseConnection )
- connection.Close();
- throw;
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// XmlReader r = ExecuteXmlReader(conn, "GetOrders", 24, 36);
- ///
- /// A valid SqlConnection
- /// The name of the stored procedure using "FOR XML AUTO"
- /// An array of objects to be assigned as the input values of the stored procedure
- /// An XmlReader containing the resultset generated by the command
- public static XmlReader ExecuteXmlReader(SqlConnection connection, string spName, params object[] parameterValues)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteXmlReader(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteXmlReader(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
- ///
- ///
- /// e.g.:
- /// XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders");
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command using "FOR XML AUTO"
- /// An XmlReader containing the resultset generated by the command
- public static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText)
- {
- // Pass through the call providing null for the set of SqlParameters
- return ExecuteXmlReader(transaction, commandType, commandText, (SqlParameter[])null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// XmlReader r = ExecuteXmlReader(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command using "FOR XML AUTO"
- /// An array of SqlParamters used to execute the command
- /// An XmlReader containing the resultset generated by the command
- public static XmlReader ExecuteXmlReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
-
- // Create a command and prepare it for execution
- var cmd = new SqlCommand();
- var mustCloseConnection = false;
- PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Create the DataAdapter & DataSet
- var retval = cmd.ExecuteXmlReader();
-
- // Detach the SqlParameters from the command object, so they can be used again
- cmd.Parameters.Clear();
- return retval;
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
- /// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// XmlReader r = ExecuteXmlReader(trans, "GetOrders", 24, 36);
- ///
- /// A valid SqlTransaction
- /// The name of the stored procedure
- /// An array of objects to be assigned as the input values of the stored procedure
- /// A dataset containing the resultset generated by the command
- public static XmlReader ExecuteXmlReader(SqlTransaction transaction, string spName, params object[] parameterValues)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- return ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- return ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName);
- }
- }
-
- #endregion ExecuteXmlReader
-
- #region FillDataset
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in
- /// the connection string.
- ///
- ///
- /// e.g.:
- /// FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- public static void FillDataset(string connectionString, CommandType commandType, string commandText, DataSet dataSet, string[] tableNames)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( dataSet == null ) throw new ArgumentNullException( "dataSet" );
-
- // Create & open a SqlConnection, and dispose of it after we are done
- using (var connection = new SqlConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- FillDataset(connection, commandType, commandText, dataSet, tableNames);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the database specified in the connection string
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
- ///
- /// A valid connection string for a SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters used to execute the command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- public static void FillDataset(string connectionString, CommandType commandType,
- string commandText, DataSet dataSet, string[] tableNames,
- params SqlParameter[] commandParameters)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( dataSet == null ) throw new ArgumentNullException( "dataSet" );
- // Create & open a SqlConnection, and dispose of it after we are done
- using (var connection = new SqlConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- FillDataset(connection, commandType, commandText, dataSet, tableNames, commandParameters);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
- /// the connection string using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// FillDataset(connString, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, 24);
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of objects to be assigned as the input values of the stored procedure
- public static void FillDataset(string connectionString, string spName,
- DataSet dataSet, string[] tableNames,
- params object[] parameterValues)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( dataSet == null ) throw new ArgumentNullException( "dataSet" );
- // Create & open a SqlConnection, and dispose of it after we are done
- using (var connection = new SqlConnection(connectionString))
- {
- connection.Open();
-
- // Call the overload that takes a connection in place of the connection string
- FillDataset (connection, spName, dataSet, tableNames, parameterValues);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
- ///
- ///
- /// e.g.:
- /// FillDataset(conn, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- public static void FillDataset(SqlConnection connection, CommandType commandType,
- string commandText, DataSet dataSet, string[] tableNames)
- {
- FillDataset(connection, commandType, commandText, dataSet, tableNames, null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// FillDataset(conn, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlConnection
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of SqlParamters used to execute the command
- public static void FillDataset(SqlConnection connection, CommandType commandType,
- string commandText, DataSet dataSet, string[] tableNames,
- params SqlParameter[] commandParameters)
- {
- FillDataset(connection, null, commandType, commandText, dataSet, tableNames, commandParameters);
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// FillDataset(conn, "GetOrders", ds, new string[] {"orders"}, 24, 36);
- ///
- /// A valid SqlConnection
- /// The name of the stored procedure
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of objects to be assigned as the input values of the stored procedure
- public static void FillDataset(SqlConnection connection, string spName,
- DataSet dataSet, string[] tableNames,
- params object[] parameterValues)
- {
- if ( connection == null ) throw new ArgumentNullException( "connection" );
- if (dataSet == null ) throw new ArgumentNullException( "dataSet" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- FillDataset(connection, CommandType.StoredProcedure, spName, dataSet, tableNames, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- FillDataset(connection, CommandType.StoredProcedure, spName, dataSet, tableNames);
- }
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
- ///
- ///
- /// e.g.:
- /// FillDataset(trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"});
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- public static void FillDataset(SqlTransaction transaction, CommandType commandType,
- string commandText,
- DataSet dataSet, string[] tableNames)
- {
- FillDataset (transaction, commandType, commandText, dataSet, tableNames, null);
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// FillDataset(trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of SqlParamters used to execute the command
- public static void FillDataset(SqlTransaction transaction, CommandType commandType,
- string commandText, DataSet dataSet, string[] tableNames,
- params SqlParameter[] commandParameters)
- {
- FillDataset(transaction.Connection, transaction, commandType, commandText, dataSet, tableNames, commandParameters);
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified
- /// SqlTransaction using the provided parameter values. This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- ///
- /// This method provides no access to output parameters or the stored procedure's return value parameter.
- ///
- /// e.g.:
- /// FillDataset(trans, "GetOrders", ds, new string[]{"orders"}, 24, 36);
- ///
- /// A valid SqlTransaction
- /// The name of the stored procedure
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of objects to be assigned as the input values of the stored procedure
- public static void FillDataset(SqlTransaction transaction, string spName,
- DataSet dataSet, string[] tableNames,
- params object[] parameterValues)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( dataSet == null ) throw new ArgumentNullException( "dataSet" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If we receive parameter values, we need to figure out where they go
- if ((parameterValues != null) && (parameterValues.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Assign the provided values to these parameters based on parameter order
- AssignParameterValues(commandParameters, parameterValues);
-
- // Call the overload that takes an array of SqlParameters
- FillDataset(transaction, CommandType.StoredProcedure, spName, dataSet, tableNames, commandParameters);
- }
- else
- {
- // Backgroundwise we can just call the SP without params
- FillDataset(transaction, CommandType.StoredProcedure, spName, dataSet, tableNames);
- }
- }
-
- ///
- /// Private helper method that execute a SqlCommand (that returns a resultset) against the specified SqlTransaction and SqlConnection
- /// using the provided parameters.
- ///
- ///
- /// e.g.:
- /// FillDataset(conn, trans, CommandType.StoredProcedure, "GetOrders", ds, new string[] {"orders"}, new SqlParameter("@prodid", 24));
- ///
- /// A valid SqlConnection
- /// A valid SqlTransaction
- /// The CommandType (stored procedure, text, etc.)
- /// The stored procedure name or T-SQL command
- /// A dataset wich will contain the resultset generated by the command
- /// This array will be used to create table mappings allowing the DataTables to be referenced
- /// by a user defined name (probably the actual table name)
- ///
- /// An array of SqlParamters used to execute the command
- private static void FillDataset(SqlConnection connection, SqlTransaction transaction, CommandType commandType,
- string commandText, DataSet dataSet, string[] tableNames,
- params SqlParameter[] commandParameters)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( dataSet == null ) throw new ArgumentNullException( "dataSet" );
-
- // Create a command and prepare it for execution
- var command = new SqlCommand();
- var mustCloseConnection = false;
- PrepareCommand(command, connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection );
-
- // Create the DataAdapter & DataSet
- using( var dataAdapter = new SqlDataAdapter(command) )
- {
-
- // Add the table mappings specified by the user
- if (tableNames != null && tableNames.Length > 0)
- {
- var tableName = "Table";
- for (var index=0; index < tableNames.Length; index++)
- {
- if( tableNames[index] == null || tableNames[index].Length == 0 ) throw new ArgumentException( "The tableNames parameter must contain a list of tables, a value was provided as null or empty string.", "tableNames" );
- dataAdapter.TableMappings.Add(tableName, tableNames[index]);
- tableName += (index + 1).ToString();
- }
- }
-
- // Fill the DataSet using default values for DataTable names, etc
- dataAdapter.Fill(dataSet);
-
- // Detach the SqlParameters from the command object, so they can be used again
- command.Parameters.Clear();
- }
-
- if( mustCloseConnection )
- connection.Close();
- }
- #endregion
-
- #region UpdateDataset
- ///
- /// Executes the respective command for each inserted, updated, or deleted row in the DataSet.
- ///
- ///
- /// e.g.:
- /// UpdateDataset(conn, insertCommand, deleteCommand, updateCommand, dataSet, "Order");
- ///
- /// A valid transact-SQL statement or stored procedure to insert new records into the data source
- /// A valid transact-SQL statement or stored procedure to delete records from the data source
- /// A valid transact-SQL statement or stored procedure used to update records in the data source
- /// The DataSet used to update the data source
- /// The DataTable used to update the data source.
- public static void UpdateDataset(SqlCommand insertCommand, SqlCommand deleteCommand, SqlCommand updateCommand, DataSet dataSet, string tableName)
- {
- if( insertCommand == null ) throw new ArgumentNullException( "insertCommand" );
- if( deleteCommand == null ) throw new ArgumentNullException( "deleteCommand" );
- if( updateCommand == null ) throw new ArgumentNullException( "updateCommand" );
- if( tableName == null || tableName.Length == 0 ) throw new ArgumentNullException( "tableName" );
-
- // Create a SqlDataAdapter, and dispose of it after we are done
- using (var dataAdapter = new SqlDataAdapter())
- {
- // Set the data adapter commands
- dataAdapter.UpdateCommand = updateCommand;
- dataAdapter.InsertCommand = insertCommand;
- dataAdapter.DeleteCommand = deleteCommand;
-
- // Update the dataset changes in the data source
- dataAdapter.Update (dataSet, tableName);
-
- // Commit all the changes made to the DataSet
- dataSet.AcceptChanges();
- }
- }
- #endregion
-
- #region CreateCommand
- ///
- /// Simplify the creation of a Sql command object by allowing
- /// a stored procedure and optional parameters to be provided
- ///
- ///
- /// e.g.:
- /// SqlCommand command = CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// An array of string to be assigned as the source columns of the stored procedure parameters
- /// A valid SqlCommand object
- public static SqlCommand CreateCommand(SqlConnection connection, string spName, params string[] sourceColumns)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // Create a SqlCommand
- var cmd = new SqlCommand( spName, connection );
- cmd.CommandType = CommandType.StoredProcedure;
-
- // If we receive parameter values, we need to figure out where they go
- if ((sourceColumns != null) && (sourceColumns.Length > 0))
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Assign the provided source columns to these parameters based on parameter order
- for (var index=0; index < sourceColumns.Length; index++)
- commandParameters[index].SourceColumn = sourceColumns[index];
-
- // Attach the discovered parameters to the SqlCommand object
- AttachParameters (cmd, commandParameters);
- }
-
- return cmd;
- }
- #endregion
-
- #region ExecuteNonQueryTypedParams
- ///
- /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the database specified in
- /// the connection string using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQueryTypedParams(String connectionString, String spName, DataRow dataRow)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if (dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQueryTypedParams(SqlConnection connection, String spName, DataRow dataRow)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if (dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteNonQuery(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteNonQuery(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified
- /// SqlTransaction using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
- ///
- /// A valid SqlTransaction object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An int representing the number of rows affected by the command
- public static int ExecuteNonQueryTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // Sf the row has values, the store procedure parameters must be initialized
- if (dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteNonQuery(transaction, CommandType.StoredProcedure, spName);
- }
- }
- #endregion
-
- #region ExecuteDatasetTypedParams
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
- /// the connection string using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDatasetTypedParams(string connectionString, String spName, DataRow dataRow)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- //If the row has values, the store procedure parameters must be initialized
- if ( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteDataset(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the dataRow column values as the store procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDatasetTypedParams(SqlConnection connection, String spName, DataRow dataRow)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteDataset(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteDataset(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
- ///
- /// A valid SqlTransaction object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A dataset containing the resultset generated by the command
- public static DataSet ExecuteDatasetTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteDataset(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteDataset(transaction, CommandType.StoredProcedure, spName);
- }
- }
-
- #endregion
-
- #region ExecuteReaderTypedParams
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the database specified in
- /// the connection string using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReaderTypedParams(String connectionString, String spName, DataRow dataRow)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if ( dataRow != null && dataRow.ItemArray.Length > 0 )
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteReader(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteReader(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReaderTypedParams(SqlConnection connection, String spName, DataRow dataRow)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteReader(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteReader(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid SqlTransaction object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// A SqlDataReader containing the resultset generated by the command
- public static SqlDataReader ExecuteReaderTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0 )
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteReader(transaction, CommandType.StoredProcedure, spName);
- }
- }
- #endregion
-
- #region ExecuteScalarTypedParams
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the database specified in
- /// the connection string using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalarTypedParams(String connectionString, String spName, DataRow dataRow)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteScalar(connectionString, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlConnection
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalarTypedParams(SqlConnection connection, String spName, DataRow dataRow)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteScalar(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteScalar(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid SqlTransaction object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An object containing the value in the 1x1 resultset generated by the command
- public static object ExecuteScalarTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteScalar(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteScalar(transaction, CommandType.StoredProcedure, spName);
- }
- }
- #endregion
-
- #region ExecuteXmlReaderTypedParams
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An XmlReader containing the resultset generated by the command
- public static XmlReader ExecuteXmlReaderTypedParams(SqlConnection connection, String spName, DataRow dataRow)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteXmlReader(connection, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteXmlReader(connection, CommandType.StoredProcedure, spName);
- }
- }
-
- ///
- /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlTransaction
- /// using the dataRow column values as the stored procedure's parameters values.
- /// This method will query the database to discover the parameters for the
- /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order.
- ///
- /// A valid SqlTransaction object
- /// The name of the stored procedure
- /// The dataRow used to hold the stored procedure's parameter values.
- /// An XmlReader containing the resultset generated by the command
- public static XmlReader ExecuteXmlReaderTypedParams(SqlTransaction transaction, String spName, DataRow dataRow)
- {
- if( transaction == null ) throw new ArgumentNullException( "transaction" );
- if( transaction != null && transaction.Connection == null ) throw new ArgumentException( "The transaction was rollbacked or commited, please provide an open transaction.", "transaction" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- // If the row has values, the store procedure parameters must be initialized
- if( dataRow != null && dataRow.ItemArray.Length > 0)
- {
- // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
- var commandParameters = SqlHelperParameterCache.GetSpParameterSet(transaction.Connection, spName);
-
- // Set the parameters values
- AssignParameterValues(commandParameters, dataRow);
-
- return ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName, commandParameters);
- }
- else
- {
- return ExecuteXmlReader(transaction, CommandType.StoredProcedure, spName);
- }
- }
- #endregion
-
- }
-
- ///
- /// SqlHelperParameterCache provides functions to leverage a static cache of procedure parameters, and the
- /// ability to discover parameters for stored procedures at run-time.
- ///
- public sealed class SqlHelperParameterCache
- {
- #region private methods, variables, and constructors
-
- //Since this class provides only static methods, make the default constructor private to prevent
- //instances from being created with "new SqlHelperParameterCache()"
- private SqlHelperParameterCache() {}
-
- private static Hashtable paramCache = Hashtable.Synchronized(new Hashtable());
-
- ///
- /// Resolve at run time the appropriate set of SqlParameters for a stored procedure
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// Whether or not to include their return value parameter
- /// The parameter array discovered.
- private static SqlParameter[] DiscoverSpParameterSet(SqlConnection connection, string spName, bool includeReturnValueParameter)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- var cmd = new SqlCommand(spName, connection);
- cmd.CommandType = CommandType.StoredProcedure;
-
- connection.Open();
- SqlCommandBuilder.DeriveParameters(cmd);
- connection.Close();
-
- if (!includeReturnValueParameter)
- {
- cmd.Parameters.RemoveAt(0);
- }
-
- var discoveredParameters = new SqlParameter[cmd.Parameters.Count];
-
- cmd.Parameters.CopyTo(discoveredParameters, 0);
-
- // Init the parameters with a DBNull value
- foreach (var discoveredParameter in discoveredParameters)
- {
- discoveredParameter.Value = DBNull.Value;
- }
- return discoveredParameters;
- }
-
- ///
- /// Deep copy of cached SqlParameter array
- ///
- ///
- ///
- private static SqlParameter[] CloneParameters(SqlParameter[] originalParameters)
- {
- var clonedParameters = new SqlParameter[originalParameters.Length];
-
- for (int i = 0, j = originalParameters.Length; i < j; i++)
- {
- clonedParameters[i] = (SqlParameter)((ICloneable)originalParameters[i]).Clone();
- }
-
- return clonedParameters;
- }
-
- #endregion private methods, variables, and constructors
-
- #region caching functions
-
- ///
- /// Add parameter array to the cache
- ///
- /// A valid connection string for a SqlConnection
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters to be cached
- public static void CacheParameterSet(string connectionString, string commandText, params SqlParameter[] commandParameters)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( commandText == null || commandText.Length == 0 ) throw new ArgumentNullException( "commandText" );
-
- var hashKey = connectionString + ":" + commandText;
-
- paramCache[hashKey] = commandParameters;
- }
-
- ///
- /// Retrieve a parameter array from the cache
- ///
- /// A valid connection string for a SqlConnection
- /// The stored procedure name or T-SQL command
- /// An array of SqlParamters
- public static SqlParameter[] GetCachedParameterSet(string connectionString, string commandText)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( commandText == null || commandText.Length == 0 ) throw new ArgumentNullException( "commandText" );
-
- var hashKey = connectionString + ":" + commandText;
-
- var cachedParameters = paramCache[hashKey] as SqlParameter[];
- if (cachedParameters == null)
- {
- return null;
- }
- else
- {
- return CloneParameters(cachedParameters);
- }
- }
-
- #endregion caching functions
-
- #region Parameter Discovery Functions
-
- ///
- /// Retrieves the set of SqlParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// An array of SqlParameters
- public static SqlParameter[] GetSpParameterSet(string connectionString, string spName)
- {
- return GetSpParameterSet(connectionString, spName, false);
- }
-
- ///
- /// Retrieves the set of SqlParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid connection string for a SqlConnection
- /// The name of the stored procedure
- /// A bool value indicating whether the return value parameter should be included in the results
- /// An array of SqlParameters
- public static SqlParameter[] GetSpParameterSet(string connectionString, string spName, bool includeReturnValueParameter)
- {
- if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- using(var connection = new SqlConnection(connectionString))
- {
- return GetSpParameterSetInternal(connection, spName, includeReturnValueParameter);
- }
- }
-
- ///
- /// Retrieves the set of SqlParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// An array of SqlParameters
- internal static SqlParameter[] GetSpParameterSet(SqlConnection connection, string spName)
- {
- return GetSpParameterSet(connection, spName, false);
- }
-
- ///
- /// Retrieves the set of SqlParameters appropriate for the stored procedure
- ///
- ///
- /// This method will query the database for this information, and then store it in a cache for future requests.
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// A bool value indicating whether the return value parameter should be included in the results
- /// An array of SqlParameters
- internal static SqlParameter[] GetSpParameterSet(SqlConnection connection, string spName, bool includeReturnValueParameter)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- using (var clonedConnection = (SqlConnection)((ICloneable)connection).Clone())
- {
- return GetSpParameterSetInternal(clonedConnection, spName, includeReturnValueParameter);
- }
- }
-
- ///
- /// Retrieves the set of SqlParameters appropriate for the stored procedure
- ///
- /// A valid SqlConnection object
- /// The name of the stored procedure
- /// A bool value indicating whether the return value parameter should be included in the results
- /// An array of SqlParameters
- private static SqlParameter[] GetSpParameterSetInternal(SqlConnection connection, string spName, bool includeReturnValueParameter)
- {
- if( connection == null ) throw new ArgumentNullException( "connection" );
- if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
-
- var hashKey = connection.ConnectionString + ":" + spName + (includeReturnValueParameter ? ":include ReturnValue Parameter":"");
-
- SqlParameter[] cachedParameters;
-
- cachedParameters = paramCache[hashKey] as SqlParameter[];
- if (cachedParameters == null)
- {
- var spParameters = DiscoverSpParameterSet(connection, spName, includeReturnValueParameter);
- paramCache[hashKey] = spParameters;
- cachedParameters = spParameters;
- }
-
- return CloneParameters(cachedParameters);
- }
-
- #endregion Parameter Discovery Functions
-
- }
-}
diff --git a/SiteServer.CMS/Data/SqlServer.cs b/SiteServer.CMS/Data/SqlServer.cs
deleted file mode 100644
index 984433a7b..000000000
--- a/SiteServer.CMS/Data/SqlServer.cs
+++ /dev/null
@@ -1,695 +0,0 @@
-
-// ===============================================================================
-// Microsoft Data Access Application Block for .NET 3.0
-//
-// SqlServer.cs
-//
-// This file contains the implementations of the AdoHelper supporting SqlServer.
-//
-// For more information see the Documentation.
-// ===============================================================================
-// Release history
-// VERSION DESCRIPTION
-// 2.0 Added support for FillDataset, UpdateDataset and "Param" helper methods
-// 3.0 New abstract class supporting the same methods using ADO.NET interfaces
-//
-// ===============================================================================
-// Copyright (C) 2000-2001 Microsoft Corporation
-// All rights reserved.
-// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
-// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
-// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
-// FITNESS FOR A PARTICULAR PURPOSE.
-// ==============================================================================
-
-using System;
-using System.Collections;
-using System.Data;
-using System.Data.SqlClient;
-using System.Data.OleDb;
-using System.Xml;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Data
-{
- ///
- /// The SqlServer class is intended to encapsulate high performance, scalable best practices for
- /// common uses of the SqlClient ADO.NET provider. It is created using the abstract factory in AdoHelper.
- ///
- public class SqlServer : DbHelper, IDataApi
- {
- #region Overrides
- ///
- /// Returns an array of SqlParameters of the specified size
- ///
- /// size of the array
- /// The array of SqlParameters
- protected override IDataParameter[] GetDataParameters(int size)
- {
- return new SqlParameter[size];
- }
-
- ///
- /// Returns a SqlConnection object for the given connection string
- ///
- /// The connection string to be used to create the connection
- /// A SqlConnection object
- public override IDbConnection GetConnection( string connectionString )
- {
- return new SqlConnection( connectionString );
- }
-
- public IDbCommand GetCommand()
- {
- return new SqlCommand();
- }
-
- ///
- /// Returns a SqlDataAdapter object
- ///
- /// The SqlDataAdapter
- public override IDbDataAdapter GetDataAdapter()
- {
- return new SqlDataAdapter();
- }
-
- ///
- /// Calls the CommandBuilder.DeriveParameters method for the specified provider, doing any setup and cleanup necessary
- ///
- /// The IDbCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the IDbCommand.
- public override void DeriveParameters( IDbCommand cmd )
- {
- var mustCloseConnection = false;
-
- if( !( cmd is SqlCommand ) )
- throw new ArgumentException( "The command provided is not a SqlCommand instance.", "cmd" );
-
- if (cmd.Connection.State != ConnectionState.Open)
- {
- cmd.Connection.Open();
- mustCloseConnection = true;
- }
-
- SqlDeriveParameters.DeriveParameters((SqlCommand)cmd );
-
- if (mustCloseConnection)
- {
- cmd.Connection.Close();
- }
- }
-
- ///
- /// Returns a SqlParameter object
- ///
- /// The SqlParameter object
- public override IDataParameter GetParameter()
- {
- return new SqlParameter();
- }
-
- ///
- /// Detach the IDataParameters from the command object, so they can be used again.
- ///
- /// command object to clear
- protected override void ClearCommand( IDbCommand command )
- {
- // HACK: There is a problem here, the output parameter values are fletched
- // when the reader is closed, so if the parameters are detached from the command
- // then the IDataReader can磘 set its values.
- // When this happen, the parameters can磘 be used again in other command.
- var canClear = true;
-
- foreach(IDataParameter commandParameter in command.Parameters)
- {
- if (commandParameter.Direction != ParameterDirection.Input)
- canClear = false;
-
- }
- if (canClear)
- {
- command.Parameters.Clear();
- }
- }
-
- ///
- /// This cleans up the parameter syntax for an SQL Server call. This was split out from PrepareCommand so that it could be called independently.
- ///
- /// An IDbCommand object containing the CommandText to clean.
- public override void CleanParameterSyntax(IDbCommand command)
- {
- // do nothing for SQL
- }
-
- ///
- /// Execute a SqlCommand (that returns a resultset) against the provided SqlConnection.
- ///
- ///
- ///
- /// XmlReader r = helper.ExecuteXmlReader(command);
- ///
- /// The IDbCommand to execute
- /// An XmlReader containing the resultset generated by the command
- public override XmlReader ExecuteXmlReader(IDbCommand command)
- {
- var mustCloseConnection = false;
-
- if (command.Connection.State != ConnectionState.Open)
- {
- command.Connection.Open();
- mustCloseConnection = true;
- }
-
- CleanParameterSyntax(command);
- // Create the DataAdapter & DataSet
- var retval = ((SqlCommand)command).ExecuteXmlReader();
-
- // Detach the SqlParameters from the command object, so they can be used again
- // don't do this...screws up output parameters -- cjbreisch
- // cmd.Parameters.Clear();
-
- if (mustCloseConnection)
- {
- command.Connection.Close();
- }
-
- return retval;
- }
-
- ///
- /// Provider specific code to set up the updating/ed event handlers used by UpdateDataset
- ///
- /// DataAdapter to attach the event handlers to
- /// The handler to be called when a row is updating
- /// The handler to be called when a row is updated
- protected override void AddUpdateEventHandlers(IDbDataAdapter dataAdapter, RowUpdatingHandler rowUpdatingHandler, RowUpdatedHandler rowUpdatedHandler)
- {
- if (rowUpdatingHandler != null)
- {
- MRowUpdating = rowUpdatingHandler;
- ((SqlDataAdapter)dataAdapter).RowUpdating += RowUpdating;
- }
-
- if (rowUpdatedHandler != null)
- {
- MRowUpdated = rowUpdatedHandler;
- ((SqlDataAdapter)dataAdapter).RowUpdated += RowUpdated;
- }
- }
-
- ///
- /// Handles the RowUpdating event
- ///
- /// The object that published the event
- /// The SqlRowUpdatingEventArgs
- protected void RowUpdating(object obj, SqlRowUpdatingEventArgs e)
- {
- base.RowUpdating(obj, e);
- }
-
- ///
- /// Handles the RowUpdated event
- ///
- /// The object that published the event
- /// The SqlRowUpdatedEventArgs
- protected void RowUpdated(object obj, SqlRowUpdatedEventArgs e)
- {
- base.RowUpdated(obj, e);
- }
-
- ///
- /// Handle any provider-specific issues with BLOBs here by "washing" the IDataParameter and returning a new one that is set up appropriately for the provider.
- ///
- /// The IDbConnection to use in cleansing the parameter
- /// The parameter before cleansing
- /// The parameter after it's been cleansed.
- protected override IDataParameter GetBlobParameter(IDbConnection connection, IDataParameter p)
- {
- // do nothing special for BLOBs...as far as we know now.
- return p;
- }
- #endregion
-
- public string GetString(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return string.Empty;
- return rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i);
- }
-
- public bool GetBoolean(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return false;
- return !rdr.IsDBNull(i) && rdr.GetBoolean(i);
- }
-
- public int GetInt(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i);
- }
-
- public decimal GetDecimal(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return 0;
- return rdr.IsDBNull(i) ? 0 : rdr.GetDecimal(i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, int i)
- {
- if (i < 0 || i >= rdr.FieldCount) return DateTime.MinValue;
- return rdr.IsDBNull(i) ? DateTime.MinValue : rdr.GetDateTime(i);
- }
-
- public string GetString(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetString(rdr, i);
- }
-
- public bool GetBoolean(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetBoolean(rdr, i);
- }
-
- public int GetInt(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetInt(rdr, i);
- }
-
- public decimal GetDecimal(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDecimal(rdr, i);
- }
-
- public DateTime GetDateTime(IDataReader rdr, string name)
- {
- var i = rdr.GetOrdinal(name);
- return GetDateTime(rdr, i);
- }
- }
-
-#region Derive Parameters
-// We create our own class to do this because the existing ADO.NET 1.1 implementation is broken.
- internal class SqlDeriveParameters
- {
- internal static void DeriveParameters(SqlCommand cmd)
- {
- string cmdText;
- SqlCommand newCommand;
- SqlDataReader reader;
- ArrayList parameterList;
- SqlParameter sqlParam;
- CommandType cmdType;
- string procedureSchema;
- string procedureName;
- int groupNumber;
- var trnSql = cmd.Transaction;
-
- cmdType = cmd.CommandType;
-
- if ((cmdType == CommandType.Text) )
- {
- throw new InvalidOperationException();
- }
- else if ((cmdType == CommandType.TableDirect) )
- {
- throw new InvalidOperationException();
- }
- else if ((cmdType != CommandType.StoredProcedure) )
- {
- throw new InvalidOperationException();
- }
-
- procedureName = cmd.CommandText;
- string server = null;
- string database = null;
- procedureSchema = null;
-
- // split out the procedure name to get the server, database, etc.
- GetProcedureTokens(ref procedureName, ref server, ref database, ref procedureSchema);
-
- // look for group numbers
- groupNumber = ParseGroupNumber(ref procedureName);
-
- newCommand = null;
-
- // set up the command string. We use sp_procuedure_params_rowset to get the parameters
- if (database != null)
- {
- cmdText = string.Concat("[", database, "]..sp_procedure_params_rowset");
- if (server != null )
- {
- cmdText = string.Concat(server, ".", cmdText);
- }
-
- // be careful of transactions
- if (trnSql != null )
- {
- newCommand = new SqlCommand(cmdText, cmd.Connection, trnSql);
- }
- else
- {
- newCommand = new SqlCommand(cmdText, cmd.Connection);
- }
- }
- else
- {
- // be careful of transactions
- if (trnSql != null )
- {
- newCommand = new SqlCommand("sp_procedure_params_rowset", cmd.Connection, trnSql);
- }
- else
- {
- newCommand = new SqlCommand("sp_procedure_params_rowset", cmd.Connection);
- }
- }
-
- newCommand.CommandType = CommandType.StoredProcedure;
- newCommand.Parameters.Add(new SqlParameter("@procedure_name", SqlDbType.NVarChar, 255));
- newCommand.Parameters[0].Value = procedureName;
-
- // make sure we specify
- if (! IsEmptyString(procedureSchema) )
- {
- newCommand.Parameters.Add(new SqlParameter("@procedure_schema", SqlDbType.NVarChar, 255));
- newCommand.Parameters[1].Value = procedureSchema;
- }
-
- // make sure we specify the groupNumber if we were given one
- if ( groupNumber != 0 )
- {
- newCommand.Parameters.Add(new SqlParameter("@group_number", groupNumber));
- }
-
- reader = null;
- parameterList = new ArrayList();
-
- try
- {
- // get a reader full of our params
- reader = newCommand.ExecuteReader();
- sqlParam = null;
-
- while ( reader.Read())
- {
- // get all the parameter properties that we can get, Name, type, length, direction, precision
- sqlParam = new SqlParameter();
- sqlParam.ParameterName = (string)(reader["PARAMETER_NAME"]);
- sqlParam.SqlDbType = GetSqlDbType((short)(reader["DATA_TYPE"]), (string)(reader["TYPE_NAME"]));
-
- if (reader["CHARACTER_MAXIMUM_LENGTH"] != DBNull.Value )
- {
- sqlParam.Size = (int)(reader["CHARACTER_MAXIMUM_LENGTH"]);
- }
-
- sqlParam.Direction = GetParameterDirection((short)(reader["PARAMETER_TYPE"]));
-
- if ((sqlParam.SqlDbType == SqlDbType.Decimal) )
- {
- sqlParam.Scale = (byte)(((short)(reader["NUMERIC_SCALE"]) & 255));
- sqlParam.Precision = (byte)(((short)(reader["NUMERIC_PRECISION"]) & 255));
- }
- parameterList.Add(sqlParam);
- }
- }
- finally
- {
- // close our reader and connection when we're done
- if (reader != null)
- {
- reader.Close();
- }
- newCommand.Connection = null;
- }
-
- // we didn't get any parameters
- if ((parameterList.Count == 0) )
- {
- throw new InvalidOperationException();
- }
-
- cmd.Parameters.Clear();
-
- // add the parameters to the command object
-
- foreach ( var parameter in parameterList )
- {
- cmd.Parameters.Add(parameter);
- }
- }
-
- ///
- /// Checks to see if the stored procedure being called is part of a group, then gets the group number if necessary
- ///
- /// Stored procedure being called. This method may change this parameter by removing the group number if it exists.
- /// the group number
- private static int ParseGroupNumber(ref string procedure)
- {
- string newProcName;
- var groupPos = procedure.IndexOf(';');
- var groupIndex = 0;
-
- if ( groupPos > 0 )
- {
- newProcName = procedure.Substring(0, groupPos);
- try
- {
- groupIndex = int.Parse(procedure.Substring(groupPos + 1));
- }
- catch
- {
- throw new InvalidOperationException();
- }
- }
- else
- {
- newProcName = procedure;
- groupIndex = 0;
- }
-
- procedure = newProcName;
- return groupIndex;
- }
-
- ///
- /// Tokenize the procedure string
- ///
- /// The procedure name
- /// The server name
- /// The database name
- /// The owner name
- private static void GetProcedureTokens( ref string procedure, ref string server, ref string database, ref string owner)
- {
- string [] spNameTokens;
- int arrIndex;
- int nextPos;
- int currPos;
- int tokenCount;
-
- server = null;
- database = null;
- owner = null;
-
- spNameTokens = new string [4];
-
- if ( ! IsEmptyString(procedure) )
- {
- arrIndex = 0;
- nextPos = 0;
- currPos = 0;
-
- while ((arrIndex < 4))
- {
- currPos = procedure.IndexOf('.', nextPos);
- if ((-1 == currPos) )
- {
- spNameTokens[arrIndex] = procedure.Substring(nextPos);
- break;
- }
- spNameTokens[arrIndex] = procedure.Substring(nextPos, (currPos - nextPos));
- nextPos = (currPos + 1);
- if ((procedure.Length <= nextPos) )
- {
- break;
- }
- arrIndex = (arrIndex + 1);
- }
-
- tokenCount = arrIndex + 1;
-
- // based on how many '.' we found, we know what tokens we found
- switch (tokenCount)
- {
- case 1:
- procedure = spNameTokens[0];
- break;
- case 2:
- procedure = spNameTokens[1];
- owner = spNameTokens[0];
- break;
- case 3:
- procedure = spNameTokens[2];
- owner = spNameTokens[1];
- database = spNameTokens[0];
- break;
- case 4:
- procedure = spNameTokens[3];
- owner = spNameTokens[2];
- database = spNameTokens[1];
- server = spNameTokens[0];
- break;
- }
- }
- }
-
- ///
- /// Checks for an empty string
- ///
- /// String to check
- /// boolean value indicating whether string is empty
- private static bool IsEmptyString( string str)
- {
- if (str != null )
- {
- return (0 == str.Length);
- }
- return true;
- }
-
- ///
- /// Convert OleDbType to SQlDbType
- ///
- /// The OleDbType to convert
- /// The typeName to convert for items such as Money and SmallMoney which both map to OleDbType.Currency
- /// The converted SqlDbType
- private static SqlDbType GetSqlDbType( short paramType, string typeName)
- {
- SqlDbType cmdType;
- OleDbType oleDbType;
- cmdType = SqlDbType.Variant;
- oleDbType = (OleDbType)(paramType);
-
- switch (oleDbType)
- {
- case OleDbType.SmallInt:
- cmdType = SqlDbType.SmallInt;
- break;
- case OleDbType.Integer:
- cmdType = SqlDbType.Int;
- break;
- case OleDbType.Single:
- cmdType = SqlDbType.Real;
- break;
- case OleDbType.Double:
- cmdType = SqlDbType.Float;
- break;
- case OleDbType.Currency:
- cmdType = (typeName == "money") ? SqlDbType.Money : SqlDbType.SmallMoney;
- break;
- case OleDbType.Date:
- cmdType = (typeName == "datetime") ? SqlDbType.DateTime : SqlDbType.SmallDateTime;
- break;
- case OleDbType.BSTR:
- cmdType = (typeName == "nchar") ? SqlDbType.NChar : SqlDbType.NVarChar;
- break;
- case OleDbType.Boolean:
- cmdType = SqlDbType.Bit;
- break;
- case OleDbType.Variant:
- cmdType = SqlDbType.Variant;
- break;
- case OleDbType.Decimal:
- cmdType = SqlDbType.Decimal;
- break;
- case OleDbType.TinyInt:
- cmdType = SqlDbType.TinyInt;
- break;
- case OleDbType.UnsignedTinyInt:
- cmdType = SqlDbType.TinyInt;
- break;
- case OleDbType.UnsignedSmallInt:
- cmdType = SqlDbType.SmallInt;
- break;
- case OleDbType.BigInt:
- cmdType = SqlDbType.BigInt;
- break;
- case OleDbType.Filetime:
- cmdType = (typeName == "datetime") ? SqlDbType.DateTime : SqlDbType.SmallDateTime;
- break;
- case OleDbType.Guid:
- cmdType = SqlDbType.UniqueIdentifier;
- break;
- case OleDbType.Binary:
- cmdType = (typeName == "binary") ? SqlDbType.Binary : SqlDbType.VarBinary;
- break;
- case OleDbType.Char:
- cmdType = (typeName == "char") ? SqlDbType.Char : SqlDbType.VarChar;
- break;
- case OleDbType.WChar:
- cmdType = (typeName == "nchar") ? SqlDbType.NChar : SqlDbType.NVarChar;
- break;
- case OleDbType.Numeric:
- cmdType = SqlDbType.Decimal;
- break;
- case OleDbType.DBDate:
- cmdType = (typeName == "datetime") ? SqlDbType.DateTime : SqlDbType.SmallDateTime;
- break;
- case OleDbType.DBTime:
- cmdType = (typeName == "datetime") ? SqlDbType.DateTime : SqlDbType.SmallDateTime;
- break;
- case OleDbType.DBTimeStamp:
- cmdType = (typeName == "datetime") ? SqlDbType.DateTime : SqlDbType.SmallDateTime;
- break;
- case OleDbType.VarChar:
- cmdType = (typeName == "char") ? SqlDbType.Char : SqlDbType.VarChar;
- break;
- case OleDbType.LongVarChar:
- cmdType = SqlDbType.Text;
- break;
- case OleDbType.VarWChar:
- cmdType = (typeName == "nchar") ? SqlDbType.NChar : SqlDbType.NVarChar;
- break;
- case OleDbType.LongVarWChar:
- cmdType = SqlDbType.NText;
- break;
- case OleDbType.VarBinary:
- cmdType = (typeName == "binary") ? SqlDbType.Binary : SqlDbType.VarBinary;
- break;
- case OleDbType.LongVarBinary:
- cmdType = SqlDbType.Image;
- break;
- }
- return cmdType;
- }
-
- ///
- /// Converts the OleDb parameter direction
- ///
- /// The integer parameter direction
- /// A ParameterDirection
- private static ParameterDirection GetParameterDirection( short oledbDirection)
- {
- ParameterDirection pd;
- switch (oledbDirection)
- {
- case 1:
- pd = ParameterDirection.Input;
- break;
- case 2:
- pd = ParameterDirection.Output;
- break;
- case 4:
- pd = ParameterDirection.ReturnValue;
- break;
- default:
- pd = ParameterDirection.InputOutput;
- break;
- }
- return pd;
- }
- }
-#endregion
-}
diff --git a/SiteServer.CMS/ImportExport/Components/ChannelIe.cs b/SiteServer.CMS/ImportExport/Components/ChannelIe.cs
deleted file mode 100644
index 34be6f112..000000000
--- a/SiteServer.CMS/ImportExport/Components/ChannelIe.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using Atom.AdditionalElements;
-using Atom.Core;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.ImportExport.Components
-{
- internal class ChannelIe
- {
- private readonly SiteInfo _siteInfo;
-
- //保存除内容表本身字段外的属性
- private const string ChannelTemplateName = "ChannelTemplateName";
- private const string ContentTemplateName = "ContentTemplateName";
-
- public ChannelIe(SiteInfo siteInfo)
- {
- _siteInfo = siteInfo;
- }
-
- public void ImportNodeInfo(ChannelInfo nodeInfo, ScopedElementCollection additionalElements, int parentId, IList indexNameList)
- {
- nodeInfo.ChannelName = AtomUtility.GetDcElementContent(additionalElements, new List{ ChannelAttribute.ChannelName, "NodeName" });
- nodeInfo.SiteId = _siteInfo.Id;
- var contentModelPluginId = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.ContentModelPluginId);
- if (!string.IsNullOrEmpty(contentModelPluginId))
- {
- nodeInfo.ContentModelPluginId = contentModelPluginId;
- }
- var contentRelatedPluginIds = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.ContentRelatedPluginIds);
- if (!string.IsNullOrEmpty(contentRelatedPluginIds))
- {
- nodeInfo.ContentRelatedPluginIds = contentRelatedPluginIds;
- }
- nodeInfo.ParentId = parentId;
- var indexName = AtomUtility.GetDcElementContent(additionalElements, new List { ChannelAttribute.IndexName, "NodeIndexName" });
- if (!string.IsNullOrEmpty(indexName) && indexNameList.IndexOf(indexName) == -1)
- {
- nodeInfo.IndexName = indexName;
- indexNameList.Add(indexName);
- }
- nodeInfo.GroupNameCollection = AtomUtility.GetDcElementContent(additionalElements, new List { ChannelAttribute.GroupNameCollection, "NodeGroupNameCollection" });
- nodeInfo.AddDate = DateTime.Now;
- nodeInfo.ImageUrl = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.ImageUrl);
- nodeInfo.Content = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.Content));
- nodeInfo.FilePath = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.FilePath);
- nodeInfo.ChannelFilePathRule = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.ChannelFilePathRule);
- nodeInfo.ContentFilePathRule = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.ContentFilePathRule);
-
- nodeInfo.LinkUrl = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.LinkUrl);
- nodeInfo.LinkType = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.LinkType);
-
- var channelTemplateName = AtomUtility.GetDcElementContent(additionalElements, ChannelTemplateName);
- if (!string.IsNullOrEmpty(channelTemplateName))
- {
- nodeInfo.ChannelTemplateId = TemplateManager.GetTemplateIdByTemplateName(_siteInfo.Id, TemplateType.ChannelTemplate, channelTemplateName);
- }
- var contentTemplateName = AtomUtility.GetDcElementContent(additionalElements, ContentTemplateName);
- if (!string.IsNullOrEmpty(contentTemplateName))
- {
- nodeInfo.ContentTemplateId = TemplateManager.GetTemplateIdByTemplateName(_siteInfo.Id, TemplateType.ContentTemplate, contentTemplateName);
- }
-
- nodeInfo.Keywords = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.Keywords);
- nodeInfo.Description = AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.Description);
-
- nodeInfo.SetExtendValues(AtomUtility.GetDcElementContent(additionalElements, ChannelAttribute.ExtendValues));
- }
-
- public AtomFeed ExportNodeInfo(ChannelInfo nodeInfo)
- {
- var feed = AtomUtility.GetEmptyFeed();
-
- AtomUtility.AddDcElement(feed.AdditionalElements, new List{ ChannelAttribute.Id, "NodeId" }, nodeInfo.Id.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { ChannelAttribute.ChannelName, "NodeName" }, nodeInfo.ChannelName);
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { ChannelAttribute.SiteId, "PublishmentSystemId" }, nodeInfo.SiteId.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ContentModelPluginId, nodeInfo.ContentModelPluginId);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ContentRelatedPluginIds, nodeInfo.ContentRelatedPluginIds);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ParentId, nodeInfo.ParentId.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ParentsPath, nodeInfo.ParentsPath);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ParentsCount, nodeInfo.ParentsCount.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ChildrenCount, nodeInfo.ChildrenCount.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.IsLastNode, nodeInfo.IsLastNode.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { ChannelAttribute.IndexName, "NodeIndexName" }, nodeInfo.IndexName);
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { ChannelAttribute.GroupNameCollection, "NodeGroupNameCollection" }, nodeInfo.GroupNameCollection);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.Taxis, nodeInfo.Taxis.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.AddDate, nodeInfo.AddDate.ToLongDateString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ImageUrl, nodeInfo.ImageUrl);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.Content, AtomUtility.Encrypt(nodeInfo.Content));
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ContentNum, nodeInfo.ContentNum.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.FilePath, nodeInfo.FilePath);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ChannelFilePathRule, nodeInfo.ChannelFilePathRule);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ContentFilePathRule, nodeInfo.ContentFilePathRule);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.LinkUrl, nodeInfo.LinkUrl);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.LinkType, nodeInfo.LinkType);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ChannelTemplateId, nodeInfo.ChannelTemplateId.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ContentTemplateId, nodeInfo.ContentTemplateId.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.Keywords, nodeInfo.Keywords);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.Description, nodeInfo.Description);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelAttribute.ExtendValues, nodeInfo.Additional.ToString());
-
- if (nodeInfo.ChannelTemplateId != 0)
- {
- var channelTemplateName = TemplateManager.GetTemplateName(nodeInfo.SiteId, nodeInfo.ChannelTemplateId);
- AtomUtility.AddDcElement(feed.AdditionalElements, ChannelTemplateName, channelTemplateName);
- }
-
- if (nodeInfo.ContentTemplateId != 0)
- {
- var contentTemplateName = TemplateManager.GetTemplateName(nodeInfo.SiteId, nodeInfo.ContentTemplateId);
- AtomUtility.AddDcElement(feed.AdditionalElements, ContentTemplateName, contentTemplateName);
- }
-
- return feed;
- }
- }
-}
diff --git a/SiteServer.CMS/ImportExport/Components/ConfigurationIe.cs b/SiteServer.CMS/ImportExport/Components/ConfigurationIe.cs
deleted file mode 100644
index 7339f0c62..000000000
--- a/SiteServer.CMS/ImportExport/Components/ConfigurationIe.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Atom.Core;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.ImportExport.Components
-{
- public class ConfigurationIe
- {
- private readonly int _siteId;
- private readonly string _filePath;
-
- private const string DefaultIndexTemplateName = "DefaultIndexTemplateName";
- private const string DefaultChannelTemplateName = "DefaultChannelTemplateName";
- private const string DefaultContentTemplateName = "DefaultContentTemplateName";
- private const string DefaultFileTemplateName = "DefaultFileTemplateName";
-
- public ConfigurationIe(int siteId, string filePath)
- {
- _siteId = siteId;
- _filePath = filePath;
- }
-
- public void Export()
- {
- var psInfo = SiteManager.GetSiteInfo(_siteId);
-
- var feed = AtomUtility.GetEmptyFeed();
-
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { SiteAttribute.Id, "PublishmentSystemId" }, psInfo.Id.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { SiteAttribute.SiteName, "PublishmentSystemName" }, psInfo.SiteName);
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { SiteAttribute.SiteDir, "PublishmentSystemDir" }, psInfo.SiteDir);
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { SiteAttribute.TableName, "AuxiliaryTableForContent" }, psInfo.TableName);
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { SiteAttribute.IsRoot, "IsHeadquarters" }, psInfo.IsRoot.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { SiteAttribute.ParentId, "ParentPublishmentSystemId" }, psInfo.ParentId.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, SiteAttribute.Taxis, psInfo.Taxis.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, SiteAttribute.SettingsXml, psInfo.Additional.ToString());
-
- var indexTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.IndexPageTemplate);
- if (indexTemplateId != 0)
- {
- var indexTemplateName = TemplateManager.GetTemplateName(_siteId, indexTemplateId);
- AtomUtility.AddDcElement(feed.AdditionalElements, DefaultIndexTemplateName, indexTemplateName);
- }
-
- var channelTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.ChannelTemplate);
- if (channelTemplateId != 0)
- {
- var channelTemplateName = TemplateManager.GetTemplateName(_siteId, channelTemplateId);
- AtomUtility.AddDcElement(feed.AdditionalElements, DefaultChannelTemplateName, channelTemplateName);
- }
-
- var contentTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.ContentTemplate);
- if (contentTemplateId != 0)
- {
- var contentTemplateName = TemplateManager.GetTemplateName(_siteId, contentTemplateId);
- AtomUtility.AddDcElement(feed.AdditionalElements, DefaultContentTemplateName, contentTemplateName);
- }
-
- var fileTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.FileTemplate);
- if (fileTemplateId != 0)
- {
- var fileTemplateName = TemplateManager.GetTemplateName(psInfo.Id, fileTemplateId);
- AtomUtility.AddDcElement(feed.AdditionalElements, DefaultFileTemplateName, fileTemplateName);
- }
-
- var channelGroupInfoList = DataProvider.ChannelGroupDao.GetGroupInfoList(psInfo.Id);
- channelGroupInfoList.Reverse();
-
- foreach (var channelGroupInfo in channelGroupInfoList)
- {
- var entry = ChannelGroupIe.Export(channelGroupInfo);
- feed.Entries.Add(entry);
- }
-
- var contentGroupInfoList = DataProvider.ContentGroupDao.GetContentGroupInfoList(psInfo.Id);
- contentGroupInfoList.Reverse();
-
- foreach (var contentGroupInfo in contentGroupInfoList)
- {
- var entry = ContentGroupIe.Export(contentGroupInfo);
- feed.Entries.Add(entry);
- }
-
- feed.Save(_filePath);
- }
-
- public static SiteInfo GetSiteInfo(string filePath)
- {
- var siteInfo = new SiteInfo();
- if (!FileUtils.IsFileExists(filePath)) return siteInfo;
-
- var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));
-
- siteInfo.SiteName = AtomUtility.GetDcElementContent(feed.AdditionalElements, new List { SiteAttribute.SiteName, "PublishmentSystemName" });
- siteInfo.SiteDir = AtomUtility.GetDcElementContent(feed.AdditionalElements, new List { SiteAttribute.SiteDir, "PublishmentSystemDir" });
- if (siteInfo.SiteDir != null && siteInfo.SiteDir.IndexOf("\\", StringComparison.Ordinal) != -1)
- {
- siteInfo.SiteDir = siteInfo.SiteDir.Substring(siteInfo.SiteDir.LastIndexOf("\\", StringComparison.Ordinal) + 1);
- }
- siteInfo.SettingsXml = AtomUtility.GetDcElementContent(feed.AdditionalElements, SiteAttribute.SettingsXml);
- siteInfo.Additional.IsCreateDoubleClick = false;
- return siteInfo;
- }
-
- public void Import()
- {
- if (!FileUtils.IsFileExists(_filePath)) return;
-
- var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(_filePath));
-
- var siteInfo = SiteManager.GetSiteInfo(_siteId);
-
- siteInfo.SettingsXml = AtomUtility.GetDcElementContent(feed.AdditionalElements, SiteAttribute.SettingsXml, siteInfo.SettingsXml);
-
- siteInfo.Additional.IsSeparatedWeb = false;
- siteInfo.Additional.IsCreateDoubleClick = false;
-
- DataProvider.SiteDao.Update(siteInfo);
-
- var indexTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultIndexTemplateName);
- if (!string.IsNullOrEmpty(indexTemplateName))
- {
- var indexTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.IndexPageTemplate, indexTemplateName);
- if (indexTemplateId != 0)
- {
- DataProvider.TemplateDao.SetDefault(siteInfo.Id, indexTemplateId);
- }
- }
-
- var channelTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultChannelTemplateName);
- if (!string.IsNullOrEmpty(channelTemplateName))
- {
- var channelTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.ChannelTemplate, channelTemplateName);
- if (channelTemplateId != 0)
- {
- DataProvider.TemplateDao.SetDefault(siteInfo.Id, channelTemplateId);
- }
- }
-
- var contentTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultContentTemplateName);
- if (!string.IsNullOrEmpty(contentTemplateName))
- {
- var contentTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.ContentTemplate, contentTemplateName);
- if (contentTemplateId != 0)
- {
- DataProvider.TemplateDao.SetDefault(siteInfo.Id, contentTemplateId);
- }
- }
-
- var fileTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultFileTemplateName);
- if (!string.IsNullOrEmpty(fileTemplateName))
- {
- var fileTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.FileTemplate, fileTemplateName);
- if (fileTemplateId != 0)
- {
- DataProvider.TemplateDao.SetDefault(siteInfo.Id, fileTemplateId);
- }
- }
-
- foreach (AtomEntry entry in feed.Entries)
- {
- if (!ChannelGroupIe.Import(entry, siteInfo.Id))
- {
- ContentGroupIe.Import(entry, siteInfo.Id);
- }
- }
- }
-
- }
-}
diff --git a/SiteServer.CMS/ImportExport/Components/ContentIe.cs b/SiteServer.CMS/ImportExport/Components/ContentIe.cs
deleted file mode 100644
index 690b09520..000000000
--- a/SiteServer.CMS/ImportExport/Components/ContentIe.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Globalization;
-using Atom.Core;
-using Atom.Core.Collections;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.ImportExport.Components
-{
- internal class ContentIe
- {
- private readonly SiteInfo _siteInfo;
- private readonly string _siteContentDirectoryPath;
-
- public ContentIe(SiteInfo siteInfo, string siteContentDirectoryPath)
- {
- _siteContentDirectoryPath = siteContentDirectoryPath;
- _siteInfo = siteInfo;
- }
-
- public void ImportContents(string filePath, bool isOverride, ChannelInfo nodeInfo, int taxis, int importStart, int importCount, bool isChecked, int checkedLevel, string adminName)
- {
- if (!FileUtils.IsFileExists(filePath)) return;
- var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));
-
- ImportContents(feed.Entries, nodeInfo, taxis, importStart, importCount, false, isChecked, checkedLevel, isOverride, adminName);
- }
-
- public void ImportContents(AtomEntryCollection entries, ChannelInfo nodeInfo, int taxis, bool isOverride, string adminName)
- {
- ImportContents(entries, nodeInfo, taxis, 0, 0, true, true, 0, isOverride, adminName);
- }
-
- // 内部消化掉错误
- public void ImportContents(AtomEntryCollection entries, ChannelInfo nodeInfo, int taxis, int importStart, int importCount, bool isCheckedBySettings, bool isChecked, int checkedLevel, bool isOverride, string adminName)
- {
- if (importStart > 1 || importCount > 0)
- {
- var theEntries = new AtomEntryCollection();
-
- if (importStart == 0)
- {
- importStart = 1;
- }
- if (importCount == 0)
- {
- importCount = entries.Count;
- }
-
- var firstIndex = entries.Count - importStart - importCount + 1;
- if (firstIndex <= 0)
- {
- firstIndex = 0;
- }
-
- var addCount = 0;
- for (var i = 0; i < entries.Count; i++)
- {
- if (addCount >= importCount) break;
- if (i >= firstIndex)
- {
- theEntries.Add(entries[i]);
- addCount++;
- }
- }
-
- entries = theEntries;
- }
-
- var tableName = ChannelManager.GetTableName(_siteInfo, nodeInfo);
-
- foreach (AtomEntry entry in entries)
- {
- try
- {
- taxis++;
- var lastEditDate = AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.LastEditDate);
- var groupNameCollection = AtomUtility.GetDcElementContent(entry.AdditionalElements, new List{ ContentAttribute.GroupNameCollection , "ContentGroupNameCollection" });
- if (isCheckedBySettings)
- {
- isChecked = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.IsChecked));
- checkedLevel = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.CheckedLevel));
- }
- var hits = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.Hits));
- var hitsByDay = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.HitsByDay));
- var hitsByWeek = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.HitsByWeek));
- var hitsByMonth = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.HitsByMonth));
- var lastHitsDate = AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.LastHitsDate);
- var title = AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.Title);
- var isTop = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.IsTop));
- var isRecommend = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.IsRecommend));
- var isHot = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.IsHot));
- var isColor = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.IsColor));
- var linkUrl = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.LinkUrl));
- var addDate = AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.AddDate);
-
- var topTaxis = 0;
- if (isTop)
- {
- topTaxis = taxis - 1;
- taxis = DataProvider.ContentDao.GetMaxTaxis(tableName, nodeInfo.Id, true) + 1;
- }
- var tags = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(entry.AdditionalElements, ContentAttribute.Tags));
-
- var contentInfo = new ContentInfo
- {
- ChannelId= nodeInfo.Id,
- SiteId = _siteInfo.Id,
- AddUserName = adminName,
- AddDate = TranslateUtils.ToDateTime(addDate)
- };
- contentInfo.LastEditUserName = contentInfo.AddUserName;
- contentInfo.LastEditDate = TranslateUtils.ToDateTime(lastEditDate);
- contentInfo.GroupNameCollection = groupNameCollection;
- contentInfo.Tags = tags;
- contentInfo.IsChecked = isChecked;
- contentInfo.CheckedLevel = checkedLevel;
- contentInfo.Hits = hits;
- contentInfo.HitsByDay = hitsByDay;
- contentInfo.HitsByWeek = hitsByWeek;
- contentInfo.HitsByMonth = hitsByMonth;
- contentInfo.LastHitsDate = TranslateUtils.ToDateTime(lastHitsDate);
- contentInfo.Title = AtomUtility.Decrypt(title);
- contentInfo.IsTop = isTop;
- contentInfo.IsRecommend = isRecommend;
- contentInfo.IsHot = isHot;
- contentInfo.IsColor = isColor;
- contentInfo.LinkUrl = linkUrl;
-
- var attributes = AtomUtility.GetDcElementNameValueCollection(entry.AdditionalElements);
- foreach (string attributeName in attributes.Keys)
- {
- if (!contentInfo.ContainsKey(attributeName.ToLower()))
- {
- contentInfo.Set(attributeName, AtomUtility.Decrypt(attributes[attributeName]));
- }
- }
-
- var isInsert = false;
- if (isOverride)
- {
- var existsIDs = DataProvider.ContentDao.GetIdListBySameTitle(tableName, contentInfo.ChannelId, contentInfo.Title);
- if (existsIDs.Count > 0)
- {
- foreach (int id in existsIDs)
- {
- contentInfo.Id = id;
- DataProvider.ContentDao.Update(tableName, _siteInfo, contentInfo);
- }
- }
- else
- {
- isInsert = true;
- }
- }
- else
- {
- isInsert = true;
- }
-
- if (isInsert)
- {
- var contentId = DataProvider.ContentDao.Insert(tableName, _siteInfo, contentInfo, false, taxis);
-
- if (!string.IsNullOrEmpty(tags))
- {
- var tagCollection = TagUtils.ParseTagsString(tags);
- TagUtils.AddTags(tagCollection, _siteInfo.Id, contentId);
- }
- }
-
- if (isTop)
- {
- taxis = topTaxis;
- }
- }
- catch
- {
- // ignored
- }
- }
- }
-
- public bool ExportContents(SiteInfo siteInfo, int channelId, List contentIdList, bool isPeriods, string dateFrom, string dateTo, ETriState checkedState)
- {
- var filePath = _siteContentDirectoryPath + PathUtils.SeparatorChar + "contents.xml";
- var tableName = ChannelManager.GetTableName(siteInfo, channelId);
- var feed = AtomUtility.GetEmptyFeed();
-
- if (contentIdList == null || contentIdList.Count == 0)
- {
- contentIdList = DataProvider.ContentDao.GetContentIdList(tableName, channelId, isPeriods, dateFrom, dateTo, checkedState);
- }
- if (contentIdList.Count == 0) return false;
-
- var collection = new NameValueCollection();
-
- foreach (var contentId in contentIdList)
- {
- var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
- try
- {
- ContentUtility.PutImagePaths(siteInfo, contentInfo, collection);
- }
- catch
- {
- // ignored
- }
- var entry = ExportContentInfo(contentInfo);
- feed.Entries.Add(entry);
- }
- feed.Save(filePath);
-
- foreach (string imageUrl in collection.Keys)
- {
- var sourceFilePath = collection[imageUrl];
- var destFilePath = PathUtility.MapPath(_siteContentDirectoryPath, imageUrl);
- DirectoryUtils.CreateDirectoryIfNotExists(destFilePath);
- FileUtils.MoveFile(sourceFilePath, destFilePath, true);
- }
-
- return true;
- }
-
- public AtomEntry ExportContentInfo(ContentInfo contentInfo)
- {
- var entry = AtomUtility.GetEmptyEntry();
-
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.Id, contentInfo.Id.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, new List{ ContentAttribute.ChannelId, "NodeId" }, contentInfo.ChannelId.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, new List { ContentAttribute.SiteId, "PublishmentSystemId" }, contentInfo.SiteId.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.AddUserName, contentInfo.AddUserName);
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.LastEditUserName, contentInfo.LastEditUserName);
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.WritingUserName, contentInfo.WritingUserName);
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.LastEditDate, contentInfo.LastEditDate.ToString(CultureInfo.InvariantCulture));
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.Taxis, contentInfo.Taxis.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, new List{ ContentAttribute.GroupNameCollection, "ContentGroupNameCollection" }, contentInfo.GroupNameCollection);
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.Tags, AtomUtility.Encrypt(contentInfo.Tags));
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.SourceId, contentInfo.SourceId.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.ReferenceId, contentInfo.ReferenceId.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.IsChecked, contentInfo.IsChecked.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.CheckedLevel, contentInfo.CheckedLevel.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.Hits, contentInfo.Hits.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.HitsByDay, contentInfo.HitsByDay.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.HitsByWeek, contentInfo.HitsByWeek.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.HitsByMonth, contentInfo.HitsByMonth.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.LastHitsDate, contentInfo.LastHitsDate.ToString(CultureInfo.InvariantCulture));
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.Title, AtomUtility.Encrypt(contentInfo.Title));
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.IsTop, contentInfo.IsTop.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.IsRecommend, contentInfo.IsRecommend.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.IsHot, contentInfo.IsHot.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.IsColor, contentInfo.IsColor.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.LinkUrl, AtomUtility.Encrypt(contentInfo.LinkUrl));
- AtomUtility.AddDcElement(entry.AdditionalElements, ContentAttribute.AddDate, contentInfo.AddDate.ToString(CultureInfo.InvariantCulture));
-
- foreach (string attributeName in contentInfo.ToNameValueCollection().Keys)
- {
- if (!ContentAttribute.AllAttributesLowercase.Contains(attributeName.ToLower()))
- {
- AtomUtility.AddDcElement(entry.AdditionalElements, attributeName, AtomUtility.Encrypt(contentInfo.GetString(attributeName)));
- }
- }
-
- return entry;
- }
- }
-}
diff --git a/SiteServer.CMS/ImportExport/Components/TableIe.cs b/SiteServer.CMS/ImportExport/Components/TableIe.cs
deleted file mode 100644
index 9fb2edf74..000000000
--- a/SiteServer.CMS/ImportExport/Components/TableIe.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using Atom.Core;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Model;
-
-namespace SiteServer.CMS.ImportExport.Components
-{
- internal class TableIe
- {
- private readonly string _directoryPath;
-
- public TableIe(string directoryPath)
- {
- _directoryPath = directoryPath;
- }
-
- public void ExportAuxiliaryTable(string tableName)
- {
- var tableInfo = DataProvider.TableDao.GetTableCollectionInfo(tableName);
- if (tableInfo == null) return;
-
- var metaInfoList = TableMetadataManager.GetTableMetadataInfoList(tableInfo.TableName);
- var filePath = _directoryPath + PathUtils.SeparatorChar + tableInfo.TableName + ".xml";
-
- var feed = AtomUtility.GetEmptyFeed();
-
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { nameof(TableInfo.TableName), "TableENName" }, tableInfo.TableName);
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { nameof(TableInfo.DisplayName), "TableCNName" }, tableInfo.DisplayName);
- AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableInfo.AttributeNum), tableInfo.AttributeNum.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { nameof(TableInfo.IsCreatedInDb), "IsCreatedInDB" }, tableInfo.IsCreatedInDb.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, new List { nameof(TableInfo.IsChangedAfterCreatedInDb), "IsChangedAfterCreatedInDB" }, tableInfo.IsChangedAfterCreatedInDb.ToString());
- AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableInfo.Description), tableInfo.Description);
- AtomUtility.AddDcElement(feed.AdditionalElements, "SerializedString", TableMetadataManager.GetSerializedString(tableInfo.TableName)); //表唯一序列号
-
- foreach (var metaInfo in metaInfoList)
- {
- var entry = AtomUtility.GetEmptyEntry();
-
- AtomUtility.AddDcElement(entry.AdditionalElements, new List { nameof(TableMetadataInfo.Id), "TableMetadataID" }, metaInfo.Id.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, new List { nameof(TableMetadataInfo.TableName), "AuxiliaryTableENName" }, metaInfo.TableName);
- AtomUtility.AddDcElement(entry.AdditionalElements, nameof(TableMetadataInfo.AttributeName), metaInfo.AttributeName);
- AtomUtility.AddDcElement(entry.AdditionalElements, nameof(TableMetadataInfo.DataType), metaInfo.DataType.Value);
- AtomUtility.AddDcElement(entry.AdditionalElements, nameof(TableMetadataInfo.DataLength), metaInfo.DataLength.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, nameof(TableMetadataInfo.Taxis), metaInfo.Taxis.ToString());
- AtomUtility.AddDcElement(entry.AdditionalElements, nameof(TableMetadataInfo.IsSystem), metaInfo.IsSystem.ToString());
-
- feed.Entries.Add(entry);
- }
- feed.Save(filePath);
- }
-
- ///
- /// 将频道模板中的辅助表导入发布系统中,返回修改了的表名对照
- /// 在导入辅助表的同时检查发布系统辅助表并替换对应表
- ///
- public NameValueCollection ImportAuxiliaryTables(int siteId, bool isUserTables)
- {
- if (!DirectoryUtils.IsDirectoryExists(_directoryPath)) return null;
-
- var siteInfo = SiteManager.GetSiteInfo(siteId);
-
- var nameValueCollection = new NameValueCollection();
- var tableNamePrefix = siteInfo.SiteDir + "_";
-
- var filePaths = DirectoryUtils.GetFilePaths(_directoryPath);
-
- foreach (var filePath in filePaths)
- {
- var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));
-
- var tableName = AtomUtility.GetDcElementContent(feed.AdditionalElements, new List { nameof(TableInfo.TableName), "TableENName" });
-
- if (!isUserTables)
- {
- nameValueCollection[tableName] = siteInfo.TableName;
- continue;
- }
-
- var displayName = AtomUtility.GetDcElementContent(feed.AdditionalElements, new List { nameof(TableInfo.DisplayName), "TableCNName" });
-
- var serializedString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "SerializedString");
-
- var tableNameToInsert = string.Empty;//需要增加的表名,空代表不需要添加辅助表
-
- var tableInfo = DataProvider.TableDao.GetTableCollectionInfo(tableName);
- if (tableInfo == null)//如果当前系统无此表名
- {
- tableNameToInsert = tableName;
- }
- else
- {
- var serializedStringForExistTable = TableMetadataManager.GetSerializedString(tableName);
-
- if (!string.IsNullOrEmpty(serializedString))
- {
- if (serializedString != serializedStringForExistTable)//仅有此时,导入表需要修改表名
- {
- tableNameToInsert = tableNamePrefix + tableName;
- displayName = tableNamePrefix + displayName;
- nameValueCollection[tableName] = tableNameToInsert;
- }
- }
- }
-
- if (!string.IsNullOrEmpty(tableNameToInsert))//需要添加
- {
- if (!DataProvider.DatabaseDao.IsTableExists(tableNameToInsert))
- {
- tableInfo = new TableInfo
- {
- TableName = tableNameToInsert,
- DisplayName = displayName,
- AttributeNum = 0,
- IsCreatedInDb = false,
- IsChangedAfterCreatedInDb = false,
- Description = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableInfo.Description))
- };
-
- var metadataInfoList = new List();
- foreach (AtomEntry entry in feed.Entries)
- {
- var metaInfo = new TableMetadataInfo
- {
- TableName = tableNameToInsert,
- AttributeName = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.AttributeName)),
- DataType = DataTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.DataType))),
- DataLength = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.DataLength))),
- Taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.Taxis))),
- IsSystem = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.IsSystem)))
- };
-
- if (string.IsNullOrEmpty(metaInfo.AttributeName) ||
- ContentAttribute.AllAttributesLowercase.Contains(metaInfo.AttributeName.ToLower()))
- continue;
-
- metadataInfoList.Add(metaInfo);
- }
-
- DataProvider.TableDao.Insert(tableInfo, metadataInfoList);
-
- DataProvider.TableDao.CreateDbTable(tableNameToInsert);
- }
- }
-
- var tableNameToChange = !string.IsNullOrEmpty(tableNameToInsert) ? tableNameToInsert : tableName;
- //更新发布系统后台内容表及栏目表
- siteInfo.TableName = tableNameToChange;
- DataProvider.SiteDao.Update(siteInfo);
- }
-
- return nameValueCollection;
- }
-
- }
-}
diff --git a/SiteServer.CMS/ImportExport/ImportObject.cs b/SiteServer.CMS/ImportExport/ImportObject.cs
deleted file mode 100644
index d12501ca7..000000000
--- a/SiteServer.CMS/ImportExport/ImportObject.cs
+++ /dev/null
@@ -1,581 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Text;
-using Atom.Core;
-using SiteServer.Utils;
-using SiteServer.CMS.Core;
-using SiteServer.CMS.Core.Office;
-using SiteServer.CMS.ImportExport.Components;
-using SiteServer.CMS.Model;
-using SiteServer.CMS.Model.Enumerations;
-
-namespace SiteServer.CMS.ImportExport
-{
- public class ImportObject
- {
- private readonly SiteInfo _siteInfo;
- private readonly string _sitePath;
- private readonly string _adminName;
-
- public ImportObject(int siteId, string adminName)
- {
- _siteInfo = SiteManager.GetSiteInfo(siteId);
- _sitePath = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, _siteInfo.SiteDir);
- _adminName = adminName;
- }
-
- //获取保存辅助表名称对应集合数据库缓存键
- private string GetTableNameNameValueCollectionDbCacheKey()
- {
- return "SiteServer.CMS.Core.ImportObject.TableNameNameValueCollection_" + _siteInfo.Id;
- }
-
- public NameValueCollection GetTableNameCache()
- {
- NameValueCollection nameValueCollection = null;
- var cacheValue = CacheDbUtils.GetValue(GetTableNameNameValueCollectionDbCacheKey());
- if (!string.IsNullOrEmpty(cacheValue))
- {
- nameValueCollection = TranslateUtils.ToNameValueCollection(cacheValue);
- }
- return nameValueCollection;
- }
-
- public void SaveTableNameCache(NameValueCollection nameValueCollection)
- {
- if (nameValueCollection != null && nameValueCollection.Count > 0)
- {
- var cacheKey = GetTableNameNameValueCollectionDbCacheKey();
- var cacheValue = TranslateUtils.NameValueCollectionToString(nameValueCollection);
- CacheDbUtils.RemoveAndInsert(cacheKey, cacheValue);
- }
- }
-
- public void RemoveDbCache()
- {
- var cacheKey = GetTableNameNameValueCollectionDbCacheKey();
- CacheDbUtils.GetValueAndRemove(cacheKey);
- }
-
- public void ImportFiles(string siteTemplatePath, bool isOverride)
- {
- //if (this.FSO.IsRoot)
- //{
- // string[] filePaths = DirectoryUtils.GetFilePaths(siteTemplatePath);
- // foreach (string filePath in filePaths)
- // {
- // string fileName = PathUtils.GetFileName(filePath);
- // if (!PathUtility.IsSystemFile(fileName))
- // {
- // string destFilePath = PathUtils.Combine(FSO.SitePath, fileName);
- // FileUtils.MoveFile(filePath, destFilePath, isOverride);
- // }
- // }
-
- // ArrayList siteDirArrayList = DataProvider.SiteDAO.GetLowerSiteDirArrayListThatNotIsRoot();
-
- // string[] directoryPaths = DirectoryUtils.GetDirectoryPaths(siteTemplatePath);
- // foreach (string subDirectoryPath in directoryPaths)
- // {
- // string directoryName = PathUtils.GetDirectoryName(subDirectoryPath);
- // if (!PathUtility.IsSystemDirectory(directoryName) && !siteDirArrayList.Contains(directoryName.ToLower()))
- // {
- // string destDirectoryPath = PathUtils.Combine(FSO.SitePath, directoryName);
- // DirectoryUtils.MoveDirectory(subDirectoryPath, destDirectoryPath, isOverride);
- // }
- // }
- //}
- //else
- //{
- // DirectoryUtils.MoveDirectory(siteTemplatePath, FSO.SitePath, isOverride);
- //}
- //string siteTemplateMetadataPath = PathUtils.Combine(FSO.SitePath, DirectoryUtility.SiteTemplates.SiteTemplateMetadata);
- //DirectoryUtils.DeleteDirectoryIfExists(siteTemplateMetadataPath);
- DirectoryUtility.ImportSiteFiles(_siteInfo, siteTemplatePath, isOverride);
- }
-
- public void ImportSiteContent(string siteContentDirectoryPath, string filePath, bool isImportContents)
- {
- var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath);
- siteIe.ImportChannelsAndContents(filePath, isImportContents, false, 0, _adminName);
- }
-
-
- ///
- /// 从指定的地址导入网站模板至站点中
- ///
- public void ImportTemplates(string filePath, bool overwrite, string administratorName)
- {
- var templateIe = new TemplateIe(_siteInfo.Id, filePath);
- templateIe.ImportTemplates(overwrite, administratorName);
- }
-
- public void ImportRelatedFieldByZipFile(string zipFilePath, bool overwrite)
- {
- var directoryPath = PathUtils.GetTemporaryFilesPath("RelatedField");
- DirectoryUtils.DeleteDirectoryIfExists(directoryPath);
- DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);
-
- ZipUtils.UnpackFiles(zipFilePath, directoryPath);
-
- var relatedFieldIe = new RelatedFieldIe(_siteInfo.Id, directoryPath);
- relatedFieldIe.ImportRelatedField(overwrite);
- }
-
- public void ImportAuxiliaryTables(string tableDirectoryPath, bool isUseTables)
- {
- NameValueCollection nameValueCollection = null;
- if (DirectoryUtils.IsDirectoryExists(tableDirectoryPath))
- {
- var tableIe = new TableIe(tableDirectoryPath);
- nameValueCollection = tableIe.ImportAuxiliaryTables(_siteInfo.Id, isUseTables);
- }
- SaveTableNameCache(nameValueCollection);
- }
-
-
- public void ImportTableStyles(string tableDirectoryPath)
- {
- if (DirectoryUtils.IsDirectoryExists(tableDirectoryPath))
- {
- var tableStyleIe = new TableStyleIe(tableDirectoryPath, _adminName);
- tableStyleIe.ImportTableStyles(_siteInfo.Id);
- }
- }
-
- public static void ImportTableStyleByZipFile(string tableName, int channelId, string zipFilePath)
- {
- var styleDirectoryPath = PathUtils.GetTemporaryFilesPath("TableStyle");
- DirectoryUtils.DeleteDirectoryIfExists(styleDirectoryPath);
- DirectoryUtils.CreateDirectoryIfNotExists(styleDirectoryPath);
-
- ZipUtils.UnpackFiles(zipFilePath, styleDirectoryPath);
-
- TableStyleIe.SingleImportTableStyle(tableName, styleDirectoryPath, channelId);
- }
-
- public void ImportConfiguration(string configurationFilePath)
- {
- var configIe = new ConfigurationIe(_siteInfo.Id, configurationFilePath);
- configIe.Import();
- }
-
-
- public void ImportChannelsAndContentsByZipFile(int parentId, string zipFilePath, bool isOverride)
- {
- var siteContentDirectoryPath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.ChannelsAndContents));
- DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath);
- DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath);
-
- ZipUtils.UnpackFiles(zipFilePath, siteContentDirectoryPath);
-
- ImportChannelsAndContentsFromZip(parentId, siteContentDirectoryPath, isOverride);
-
- DataProvider.ChannelDao.UpdateContentNum(_siteInfo);
-
- var uploadFolderPath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName);
- var uploadFilePath = PathUtils.Combine(uploadFolderPath, BackupUtility.UploadFileName);
- if (!FileUtils.IsFileExists(uploadFilePath))
- {
- return;
- }
- var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(uploadFilePath));
- if (feed != null)
- {
- AtomEntry entry = feed.Entries[0];
- string imageUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ImageUploadDirectoryName");
- if(imageUploadDirectoryPath != null)
- {
- DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, imageUploadDirectoryPath), PathUtils.Combine(_sitePath, _siteInfo.Additional.ImageUploadDirectoryName), isOverride);
- }
- string videoUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "VideoUploadDirectoryName");
- if (videoUploadDirectoryPath != null)
- {
- DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, videoUploadDirectoryPath), PathUtils.Combine(_sitePath, _siteInfo.Additional.VideoUploadDirectoryName), isOverride);
- }
- string fileUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "FileUploadDirectoryName");
- if (fileUploadDirectoryPath != null)
- {
- DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, fileUploadDirectoryPath), PathUtils.Combine(_sitePath, _siteInfo.Additional.FileUploadDirectoryName), isOverride);
- }
- }
- }
-
- public void ImportChannelsAndContentsFromZip(int parentId, string siteContentDirectoryPath, bool isOverride)
- {
- var filePathList = GetSiteContentFilePathList(siteContentDirectoryPath);
-
- var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath);
-
- Hashtable levelHashtable = null;
- foreach (var filePath in filePathList)
- {
- var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1;
- var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal);
- var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex);
-
- var level = StringUtils.GetCount("_", orderString);
-
- if (levelHashtable == null)
- {
- levelHashtable = new Hashtable
- {
- [level] = parentId
- };
- }
-
- var insertChannelId = siteIe.ImportChannelsAndContents(filePath, true, isOverride, (int)levelHashtable[level], _adminName);
- levelHashtable[level + 1] = insertChannelId;
- }
- }
-
- public void ImportChannelsAndContents(int parentId, string siteContentDirectoryPath, bool isOverride)
- {
- var filePathList = GetSiteContentFilePathList(siteContentDirectoryPath);
-
- var siteIe = new SiteIe(_siteInfo, siteContentDirectoryPath);
-
- var parentOrderString = "none";
- //int parentID = 0;
- foreach (var filePath in filePathList)
- {
- var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1;
- var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal);
- var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex);
-
- if (StringUtils.StartsWithIgnoreCase(orderString, parentOrderString))
- {
- parentId = siteIe.ImportChannelsAndContents(filePath, true, isOverride, parentId, _adminName);
- parentOrderString = orderString;
- }
- else
- {
- siteIe.ImportChannelsAndContents(filePath, true, isOverride, parentId, _adminName);
- }
- }
- }
-
- public void ImportContentsByZipFile(ChannelInfo nodeInfo, string zipFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
- {
- var siteContentDirectoryPath = PathUtils.GetTemporaryFilesPath("contents");
- DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath);
- DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath);
-
- ZipUtils.UnpackFiles(zipFilePath, siteContentDirectoryPath);
-
- var tableName = ChannelManager.GetTableName(_siteInfo, nodeInfo);
-
- var taxis = DataProvider.ContentDao.GetMaxTaxis(tableName, nodeInfo.Id, false);
-
- ImportContents(nodeInfo, siteContentDirectoryPath, isOverride, taxis, importStart, importCount, isChecked, checkedLevel);
-
- DataProvider.ChannelDao.UpdateContentNum(_siteInfo);
- }
-
- public void ImportContentsByAccessFile(int channelId, string excelFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
- {
- var nodeInfo = ChannelManager.GetChannelInfo(_siteInfo.Id, channelId);
- var contentInfoList = AccessObject.GetContentsByAccessFile(excelFilePath, _siteInfo, nodeInfo);
-
- if (importStart > 1 || importCount > 0)
- {
- var theList = new List();
-
- if (importStart == 0)
- {
- importStart = 1;
- }
- if (importCount == 0)
- {
- importCount = contentInfoList.Count;
- }
-
- var firstIndex = contentInfoList.Count - importStart - importCount + 1;
- if (firstIndex <= 0)
- {
- firstIndex = 0;
- }
-
- var addCount = 0;
- for (var i = 0; i < contentInfoList.Count; i++)
- {
- if (addCount >= importCount) break;
- if (i >= firstIndex)
- {
- theList.Add(contentInfoList[i]);
- addCount++;
- }
- }
-
- contentInfoList = theList;
- }
-
- var tableName = ChannelManager.GetTableName(_siteInfo, nodeInfo);
-
- foreach (var contentInfo in contentInfoList)
- {
- contentInfo.IsChecked = isChecked;
- contentInfo.CheckedLevel = checkedLevel;
-
- //contentInfo.ID = DataProvider.ContentDAO.Insert(tableName, this.FSO.SiteInfo, contentInfo);
- if (isOverride)
- {
- var existsIDs = DataProvider.ContentDao.GetIdListBySameTitle(tableName, contentInfo.ChannelId, contentInfo.Title);
- if (existsIDs.Count > 0)
- {
- foreach (int id in existsIDs)
- {
- contentInfo.Id = id;
- DataProvider.ContentDao.Update(tableName, _siteInfo, contentInfo);
- }
- }
- else
- {
- contentInfo.Id = DataProvider.ContentDao.Insert(tableName, _siteInfo, contentInfo);
- }
- }
- else
- {
- contentInfo.Id = DataProvider.ContentDao.Insert(tableName, _siteInfo, contentInfo);
- }
- }
- }
-
- public void ImportContentsByCsvFile(int channelId, string csvFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
- {
- var channelInfo = ChannelManager.GetChannelInfo(_siteInfo.Id, channelId);
- var contentInfoList = ExcelObject.GetContentsByCsvFile(csvFilePath, _siteInfo, channelInfo);
- contentInfoList.Reverse();
-
- if (importStart > 1 || importCount > 0)
- {
- var theList = new List();
-
- if (importStart == 0)
- {
- importStart = 1;
- }
- if (importCount == 0)
- {
- importCount = contentInfoList.Count;
- }
-
- var firstIndex = contentInfoList.Count - importStart - importCount + 1;
- if (firstIndex <= 0)
- {
- firstIndex = 0;
- }
-
- var addCount = 0;
- for (var i = 0; i < contentInfoList.Count; i++)
- {
- if (addCount >= importCount) break;
- if (i >= firstIndex)
- {
- theList.Add(contentInfoList[i]);
- addCount++;
- }
- }
-
- contentInfoList = theList;
- }
-
- var tableName = ChannelManager.GetTableName(_siteInfo, channelInfo);
-
- foreach (var contentInfo in contentInfoList)
- {
- contentInfo.IsChecked = isChecked;
- contentInfo.CheckedLevel = checkedLevel;
- if (isOverride)
- {
- var existsIds = DataProvider.ContentDao.GetIdListBySameTitle(tableName, contentInfo.ChannelId, contentInfo.Title);
- if (existsIds.Count > 0)
- {
- foreach (var id in existsIds)
- {
- contentInfo.Id = id;
- DataProvider.ContentDao.Update(tableName, _siteInfo, contentInfo);
- }
- }
- else
- {
- contentInfo.Id = DataProvider.ContentDao.Insert(tableName, _siteInfo, contentInfo);
- }
- }
- else
- {
- contentInfo.Id = DataProvider.ContentDao.Insert(tableName, _siteInfo, contentInfo);
- }
- //this.FSO.AddContentToWaitingCreate(contentInfo.ChannelId, contentID);
- }
- }
-
- public void ImportContentsByTxtZipFile(int channelId, string zipFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
- {
- var directoryPath = PathUtils.GetTemporaryFilesPath("contents");
- DirectoryUtils.DeleteDirectoryIfExists(directoryPath);
- DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);
-
- ZipUtils.UnpackFiles(zipFilePath, directoryPath);
-
- var nodeInfo = ChannelManager.GetChannelInfo(_siteInfo.Id, channelId);
-
- var contentInfoList = TxtObject.GetContentListByTxtFile(directoryPath, _siteInfo, nodeInfo);
-
- if (importStart > 1 || importCount > 0)
- {
- var theList = new List();
-
- if (importStart == 0)
- {
- importStart = 1;
- }
- if (importCount == 0)
- {
- importCount = contentInfoList.Count;
- }
-
- var firstIndex = contentInfoList.Count - importStart - importCount + 1;
- if (firstIndex <= 0)
- {
- firstIndex = 0;
- }
-
- var addCount = 0;
- for (var i = 0; i < contentInfoList.Count; i++)
- {
- if (addCount >= importCount) break;
- if (i >= firstIndex)
- {
- theList.Add(contentInfoList[i]);
- addCount++;
- }
- }
-
- contentInfoList = theList;
- }
-
- var tableName = ChannelManager.GetTableName(_siteInfo, nodeInfo);
-
- foreach (var contentInfo in contentInfoList)
- {
- contentInfo.IsChecked = isChecked;
- contentInfo.CheckedLevel = checkedLevel;
-
- //int contentID = DataProvider.ContentDAO.Insert(tableName, this.FSO.SiteInfo, contentInfo);
-
- if (isOverride)
- {
- var existsIDs = DataProvider.ContentDao.GetIdListBySameTitle(tableName, contentInfo.ChannelId, contentInfo.Title);
- if (existsIDs.Count > 0)
- {
- foreach (int id in existsIDs)
- {
- contentInfo.Id = id;
- DataProvider.ContentDao.Update(tableName, _siteInfo, contentInfo);
- }
- }
- else
- {
- contentInfo.Id = DataProvider.ContentDao.Insert(tableName, _siteInfo, contentInfo);
- }
- }
- else
- {
- contentInfo.Id = DataProvider.ContentDao.Insert(tableName, _siteInfo, contentInfo);
- }
-
- //this.FSO.AddContentToWaitingCreate(contentInfo.ChannelId, contentID);
- }
- }
-
- public void ImportContents(ChannelInfo nodeInfo, string siteContentDirectoryPath, bool isOverride, int taxis, int importStart, int importCount, bool isChecked, int checkedLevel)
- {
- var filePath = PathUtils.Combine(siteContentDirectoryPath, "contents.xml");
-
- var contentIe = new ContentIe(_siteInfo, siteContentDirectoryPath);
-
- contentIe.ImportContents(filePath, isOverride, nodeInfo, taxis, importStart, importCount, isChecked, checkedLevel, _adminName);
-
- FileUtils.DeleteFileIfExists(filePath);
-
- DirectoryUtils.MoveDirectory(siteContentDirectoryPath, _sitePath, isOverride);
- }
-
- //public void ImportInputContentsByCsvFile(InputInfo inputInfo, string excelFilePath, int importStart, int importCount, bool isChecked)
- //{
- // var contentInfoList = ExcelObject.GetInputContentsByCsvFile(excelFilePath, _siteInfo, inputInfo);
- // contentInfoList.Reverse();
-
- // if (importStart > 1 || importCount > 0)
- // {
- // var theList = new List();
-
- // if (importStart == 0)
- // {
- // importStart = 1;
- // }
- // if (importCount == 0)
- // {
- // importCount = contentInfoList.Count;
- // }
-
- // var firstIndex = contentInfoList.Count - importStart - importCount + 1;
- // if (firstIndex <= 0)
- // {
- // firstIndex = 0;
- // }
-
- // var addCount = 0;
- // for (var i = 0; i < contentInfoList.Count; i++)
- // {
- // if (addCount >= importCount) break;
- // if (i >= firstIndex)
- // {
- // theList.Add(contentInfoList[i]);
- // addCount++;
- // }
- // }
-
- // contentInfoList = theList;
- // }
-
- // foreach (var contentInfo in contentInfoList)
- // {
- // contentInfo.IsChecked = isChecked;
- // DataProvider.InputContentDao.Insert(contentInfo);
- // }
- //}
-
- public static IList GetSiteContentFilePathList(string siteContentDirectoryPath)
- {
- var filePaths = DirectoryUtils.GetFilePaths(siteContentDirectoryPath);
- var filePathSortedList = new SortedList();
- foreach (var filePath in filePaths)
- {
- var keyBuilder = new StringBuilder();
- var fileName = PathUtils.GetFileName(filePath).ToLower().Replace(".xml", "");
- var nums = fileName.Split('_');
- foreach (var numStr in nums)
- {
- var count = 7 - numStr.Length;
- if (count > 0)
- {
- for (var i = 0; i < count; i++)
- {
- keyBuilder.Append("0");
- }
- }
- keyBuilder.Append(numStr);
- keyBuilder.Append("_");
- }
- if (keyBuilder.Length > 0) keyBuilder.Remove(keyBuilder.Length - 1, 1);
- filePathSortedList.Add(keyBuilder.ToString(), filePath);
- }
- return filePathSortedList.Values;
- }
-
- }
-}
diff --git a/SiteServer.CMS/Model/AdministratorInfo.cs b/SiteServer.CMS/Model/AdministratorInfo.cs
deleted file mode 100644
index 6820d0e15..000000000
--- a/SiteServer.CMS/Model/AdministratorInfo.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using SiteServer.Plugin;
-using SiteServer.Utils;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Model
-{
- public class AdministratorInfo: IAdministratorInfo
- {
- private string _displayName;
-
- public AdministratorInfo()
- {
- Id = 0;
- UserName = string.Empty;
- Password = string.Empty;
- PasswordFormat = EPasswordFormat.Encrypted;
- PasswordSalt = string.Empty;
- CreationDate = DateUtils.SqlMinValue;
- LastActivityDate = DateUtils.SqlMinValue;
- CountOfLogin = 0;
- CountOfFailedLogin = 0;
- CreatorUserName = string.Empty;
- IsLockedOut = false;
- SiteIdCollection = string.Empty;
- SiteId = 0;
- DepartmentId = 0;
- AreaId = 0;
- _displayName = string.Empty;
- Email = string.Empty;
- Mobile = string.Empty;
- }
-
- public AdministratorInfo(int id, string userName, string password, EPasswordFormat passwordFormat, string passwordSalt, DateTime creationDate, DateTime lastActivityDate, int countOfLogin, int countOfFailedLogin, string creatorUserName, bool isLockedOut, string siteIdCollection, int siteId, int departmentId, int areaId, string displayName, string email, string mobile)
- {
- Id = id;
- UserName = userName;
- Password = password;
- PasswordFormat = passwordFormat;
- PasswordSalt = passwordSalt;
- CreationDate = creationDate;
- LastActivityDate = lastActivityDate;
- CountOfLogin = countOfLogin;
- CountOfFailedLogin = countOfFailedLogin;
- CreatorUserName = creatorUserName;
- IsLockedOut = isLockedOut;
- SiteIdCollection = siteIdCollection;
- SiteId = siteId;
- DepartmentId = departmentId;
- AreaId = areaId;
- _displayName = displayName;
- Email = email;
- Mobile = mobile;
- }
-
- public int Id { get; set; }
-
- public string UserName { get; set; }
-
- public string Password { get; set; }
-
- public EPasswordFormat PasswordFormat { get; set; }
-
- public string PasswordSalt { get; set; }
-
- public DateTime CreationDate { get; set; }
-
- public DateTime LastActivityDate { get; set; }
-
- public int CountOfLogin { get; set; }
-
- public int CountOfFailedLogin { get; set; }
-
- public string CreatorUserName { get; set; }
-
- public bool IsLockedOut { get; set; }
-
- public string SiteIdCollection { get; set; }
-
- public int SiteId { get; set; }
-
- public int DepartmentId { get; set; }
-
- public int AreaId { get; set; }
-
- public string DisplayName
- {
- get
- {
- if (string.IsNullOrEmpty(_displayName))
- {
- _displayName = UserName;
- }
- return _displayName;
- }
- set { _displayName = value; }
- }
-
- public string Email { get; set; }
-
- public string Mobile { get; set; }
- }
-}
diff --git a/SiteServer.CMS/Model/AreaInfo.cs b/SiteServer.CMS/Model/AreaInfo.cs
deleted file mode 100644
index d34cfb51d..000000000
--- a/SiteServer.CMS/Model/AreaInfo.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-namespace SiteServer.CMS.Model
-{
- public class AreaInfo
- {
- public AreaInfo()
- {
- Id = 0;
- AreaName = string.Empty;
- ParentId = 0;
- ParentsPath = string.Empty;
- ParentsCount = 0;
- ChildrenCount = 0;
- IsLastNode = false;
- Taxis = 0;
- CountOfAdmin = 0;
- }
-
- public AreaInfo(int id, string areaName, int parentId, string parentsPath, int parentsCount, int childrenCount, bool isLastNode, int taxis, int countOfAdmin)
- {
- Id = id;
- AreaName = areaName;
- ParentId = parentId;
- ParentsPath = parentsPath;
- ParentsCount = parentsCount;
- ChildrenCount = childrenCount;
- IsLastNode = isLastNode;
- Taxis = taxis;
- CountOfAdmin = countOfAdmin;
- }
-
- public int Id { get; set; }
-
- public string AreaName { get; set; }
-
- public int ParentId { get; set; }
-
- public string ParentsPath { get; set; }
-
- public int ParentsCount { get; set; }
-
- public int ChildrenCount { get; set; }
-
- public bool IsLastNode { get; set; }
-
- public int Taxis { get; set; }
-
- public int CountOfAdmin { get; set; }
- }
-}
diff --git a/SiteServer.CMS/Model/BackgroundContentAttribute.cs b/SiteServer.CMS/Model/BackgroundContentAttribute.cs
deleted file mode 100644
index 3761be93d..000000000
--- a/SiteServer.CMS/Model/BackgroundContentAttribute.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections.Generic;
-
-namespace SiteServer.CMS.Model
-{
- public class BackgroundContentAttribute
- {
- protected BackgroundContentAttribute()
- {
- }
-
- //system
- public const string SubTitle = "SubTitle";
- public const string ImageUrl = "ImageUrl";
- public const string VideoUrl = "VideoUrl";
- public const string FileUrl = "FileUrl";
- public const string Author = "Author";
- public const string Source = "Source";
- public const string Summary = "Summary";
- public const string Content = "Content";
- //not exists
- public const string TitleFormatString = "TitleFormatString";
- public const string PageContent = "PageContent";
- public const string NavigationUrl = "NavigationUrl";
- public const string CountOfPhotos = "CountOfPhotos";
-
- public static List AllAttributes
- {
- get
- {
- var list = new List(ContentAttribute.AllAttributesLowercase);
- list.AddRange(SystemAttributes);
- return list;
- }
- }
-
- private static List _systemAttributes;
- public static List SystemAttributes => _systemAttributes ?? (_systemAttributes = new List
- {
- SubTitle.ToLower(),
- ImageUrl.ToLower(),
- VideoUrl.ToLower(),
- FileUrl.ToLower(),
- Content.ToLower(),
- Author.ToLower(),
- Source.ToLower(),
- Summary.ToLower()
- });
- }
-}
diff --git a/SiteServer.CMS/Model/ChannelAttribute.cs b/SiteServer.CMS/Model/ChannelAttribute.cs
deleted file mode 100644
index 0f3364c80..000000000
--- a/SiteServer.CMS/Model/ChannelAttribute.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using SiteServer.CMS.StlParser.Model;
-
-namespace SiteServer.CMS.Model
-{
- public static class ChannelAttribute
- {
- [StlField(Description = "栏目Id")]
- public const string Id = nameof(ChannelInfo.Id);
-
- [StlField(Description = "栏目名称")]
- public const string ChannelName = nameof(ChannelInfo.ChannelName);
-
- [StlField(Description = "站点Id")]
- public const string SiteId = nameof(ChannelInfo.SiteId);
-
- [StlField(Description = "内容模型插件Id")]
- public const string ContentModelPluginId = nameof(ChannelInfo.ContentModelPluginId);
-
- [StlField(Description = "内容关联插件Id列表")]
- public const string ContentRelatedPluginIds = nameof(ChannelInfo.ContentRelatedPluginIds);
-
- [StlField(Description = "父栏目Id")]
- public const string ParentId = nameof(ChannelInfo.ParentId);
-
- [StlField(Description = "上级栏目路径")]
- public const string ParentsPath = nameof(ChannelInfo.ParentsPath);
-
- [StlField(Description = "上级栏目数量")]
- public const string ParentsCount = nameof(ChannelInfo.ParentsCount);
-
- [StlField(Description = "下级栏目数量")]
- public const string ChildrenCount = nameof(ChannelInfo.ChildrenCount);
-
- [StlField(Description = "是否最后一级栏目")]
- public const string IsLastNode = nameof(ChannelInfo.IsLastNode);
-
- [StlField(Description = "栏目索引")]
- public const string IndexName = nameof(ChannelInfo.IndexName);
-
- [StlField(Description = "栏目组")]
- public const string GroupNameCollection = nameof(ChannelInfo.GroupNameCollection);
-
- [StlField(Description = "栏目排序")]
- public const string Taxis = nameof(ChannelInfo.Taxis);
-
- [StlField(Description = "栏目添加时间")]
- public const string AddDate = nameof(ChannelInfo.AddDate);
-
- [StlField(Description = "栏目图片")]
- public const string ImageUrl = nameof(ChannelInfo.ImageUrl);
-
- [StlField(Description = "栏目正文")]
- public const string Content = nameof(ChannelInfo.Content);
-
- [StlField(Description = "包含内容数")]
- public const string ContentNum = nameof(ChannelInfo.ContentNum);
-
- [StlField(Description = "页面路径")]
- public const string FilePath = nameof(ChannelInfo.FilePath);
-
- [StlField(Description = "下级栏目页面命名规则")]
- public const string ChannelFilePathRule = nameof(ChannelInfo.ChannelFilePathRule);
-
- [StlField(Description = "下级内容页面命名规则")]
- public const string ContentFilePathRule = nameof(ChannelInfo.ContentFilePathRule);
-
- [StlField(Description = "外部链接")]
- public const string LinkUrl = nameof(ChannelInfo.LinkUrl);
-
- [StlField(Description = "链接类型")]
- public const string LinkType = nameof(ChannelInfo.LinkType);
-
- [StlField(Description = "栏目模板Id")]
- public const string ChannelTemplateId = nameof(ChannelInfo.ChannelTemplateId);
-
- [StlField(Description = "内容模板Id")]
- public const string ContentTemplateId = nameof(ChannelInfo.ContentTemplateId);
-
- [StlField(Description = "关键字列表")]
- public const string Keywords = nameof(ChannelInfo.Keywords);
-
- [StlField(Description = "页面描述")]
- public const string Description = nameof(ChannelInfo.Description);
-
- [StlField(Description = "栏目扩展值")]
- public const string ExtendValues = nameof(ExtendValues);
-
- [StlField(Description = "栏目名称")]
- public const string Title = nameof(Title);
-
- [StlField(Description = "栏目索引")]
- public const string ChannelIndex = nameof(ChannelIndex);
-
- [StlField(Description = "栏目正文(翻页)")]
- public const string PageContent = nameof(PageContent);
-
- [StlField(Description = "下级栏目数")]
- public const string CountOfChannels = nameof(CountOfChannels);
-
- [StlField(Description = "包含内容数")]
- public const string CountOfContents = nameof(CountOfContents);
-
- [StlField(Description = "包含图片内容数")]
- public const string CountOfImageContents = nameof(CountOfImageContents);
- }
-}
diff --git a/SiteServer.CMS/Model/ChannelGroupInfo.cs b/SiteServer.CMS/Model/ChannelGroupInfo.cs
deleted file mode 100644
index 8c529aa3d..000000000
--- a/SiteServer.CMS/Model/ChannelGroupInfo.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-namespace SiteServer.CMS.Model
-{
- public class ChannelGroupInfo
- {
- public ChannelGroupInfo()
- {
- GroupName = string.Empty;
- SiteId = 0;
- Taxis = 0;
- Description = string.Empty;
- }
-
- public ChannelGroupInfo(string groupName, int siteId, int taxis, string description)
- {
- GroupName = groupName;
- SiteId = siteId;
- Taxis = taxis;
- Description = description;
- }
-
- public int Id { get; set; }
-
- public string GroupName { get; set; }
-
- public int SiteId { get; set; }
-
- public int Taxis { get; set; }
-
- public string Description { get; set; }
- }
-}
diff --git a/SiteServer.CMS/Model/ChannelInfo.cs b/SiteServer.CMS/Model/ChannelInfo.cs
deleted file mode 100644
index 179b32331..000000000
--- a/SiteServer.CMS/Model/ChannelInfo.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-using System;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Plugin;
-
-namespace SiteServer.CMS.Model
-{
- public class ChannelInfo : IChannelInfo
- {
- private string _extendValues;
-
- public ChannelInfo()
- {
- Id = 0;
- ChannelName = string.Empty;
- SiteId = 0;
- ContentModelPluginId = string.Empty;
- ContentRelatedPluginIds = string.Empty;
- ParentId = 0;
- ParentsPath = string.Empty;
- ParentsCount = 0;
- ChildrenCount = 0;
- IsLastNode = false;
- IndexName = string.Empty;
- GroupNameCollection = string.Empty;
- Taxis = 0;
- AddDate = DateTime.Now;
- ImageUrl = string.Empty;
- Content = string.Empty;
- ContentNum = 0;
- FilePath = string.Empty;
- ChannelFilePathRule = string.Empty;
- ContentFilePathRule = string.Empty;
- LinkUrl = string.Empty;
- LinkType = string.Empty;
- ChannelTemplateId = 0;
- ContentTemplateId = 0;
- Keywords = string.Empty;
- Description = string.Empty;
- _extendValues = string.Empty;
- }
-
- public ChannelInfo(int id, string channelName, int siteId, string contentModelPluginId, string contentRelatedPluginIds, int parentId, string parentsPath, int parentsCount, int childrenCount, bool isLastNode, string indexName, string groupNameCollection, int taxis, DateTime addDate, string imageUrl, string content, int contentNum, string filePath, string channelFilePathRule, string contentFilePathRule, string linkUrl, ELinkType linkType, int channelTemplateId, int contentTemplateId, string keywords, string description, string extendValues)
- {
- Id = id;
- ChannelName = channelName;
- SiteId = siteId;
- ContentModelPluginId = contentModelPluginId;
- ContentRelatedPluginIds = contentRelatedPluginIds;
- ParentId = parentId;
- ParentsPath = parentsPath;
- ParentsCount = parentsCount;
- ChildrenCount = childrenCount;
- IsLastNode = isLastNode;
- IndexName = indexName;
- GroupNameCollection = groupNameCollection;
- Taxis = taxis;
- AddDate = addDate;
- ImageUrl = imageUrl;
- Content = content;
- ContentNum = contentNum;
- FilePath = filePath;
- ChannelFilePathRule = channelFilePathRule;
- ContentFilePathRule = contentFilePathRule;
- LinkUrl = linkUrl;
- LinkType = ELinkTypeUtils.GetValue(linkType);
- ChannelTemplateId = channelTemplateId;
- ContentTemplateId = contentTemplateId;
- Keywords = keywords;
- Description = description;
- _extendValues = extendValues;
- }
-
- public ChannelInfo(ChannelInfo channelInfo)
- {
- Id = channelInfo.Id;
- ChannelName = channelInfo.ChannelName;
- SiteId = channelInfo.SiteId;
- ContentModelPluginId = channelInfo.ContentModelPluginId;
- ContentRelatedPluginIds = channelInfo.ContentRelatedPluginIds;
- ParentId = channelInfo.ParentId;
- ParentsPath = channelInfo.ParentsPath;
- ParentsCount = channelInfo.ParentsCount;
- ChildrenCount = channelInfo.ChildrenCount;
- IsLastNode = channelInfo.IsLastNode;
- IndexName = channelInfo.IndexName;
- GroupNameCollection = channelInfo.GroupNameCollection;
- Taxis = channelInfo.Taxis;
- AddDate = channelInfo.AddDate;
- ImageUrl = channelInfo.ImageUrl;
- Content = channelInfo.Content;
- ContentNum = channelInfo.ContentNum;
- FilePath = channelInfo.FilePath;
- ChannelFilePathRule = channelInfo.ChannelFilePathRule;
- ContentFilePathRule = channelInfo.ContentFilePathRule;
- LinkUrl = channelInfo.LinkUrl;
- LinkType = channelInfo.LinkType;
- ChannelTemplateId = channelInfo.ChannelTemplateId;
- ContentTemplateId = channelInfo.ContentTemplateId;
- Keywords = channelInfo.Keywords;
- Description = channelInfo.Description;
- _extendValues = channelInfo._extendValues;
- }
-
- public int Id { get; set; }
-
- public string ChannelName { get; set; }
-
- public int SiteId { get; set; }
-
- public string ContentModelPluginId { get; set; }
-
- public string ContentRelatedPluginIds { get; set; }
-
- public int ParentId { get; set; }
-
- public string ParentsPath { get; set; }
-
- public int ParentsCount { get; set; }
-
- public int ChildrenCount { get; set; }
-
- public bool IsLastNode { get; set; }
-
- public string IndexName { get; set; }
-
- public string GroupNameCollection { get; set; }
-
- public int Taxis { get; set; }
-
- public DateTime AddDate { get; set; }
-
- public string ImageUrl { get; set; }
-
- public string Content { get; set; }
-
- public int ContentNum { get; set; }
-
- public string FilePath { get; set; }
-
- public string ChannelFilePathRule { get; set; }
-
- public string ContentFilePathRule { get; set; }
-
- public string LinkUrl { get; set; }
-
- public string LinkType { get; set; }
-
- public int ChannelTemplateId { get; set; }
-
- public int ContentTemplateId { get; set; }
-
- public string Keywords { get; set; }
-
- public string Description { get; set; }
-
- public void SetExtendValues(string extendValues)
- {
- _extendValues = extendValues;
- }
-
- private ChannelInfoExtend _additional;
- public ChannelInfoExtend Additional => _additional ?? (_additional = new ChannelInfoExtend(_extendValues));
-
- public IAttributes Attributes => Additional;
- }
-}
diff --git a/SiteServer.CMS/Model/ChannelInfoExtend.cs b/SiteServer.CMS/Model/ChannelInfoExtend.cs
deleted file mode 100644
index 412891e23..000000000
--- a/SiteServer.CMS/Model/ChannelInfoExtend.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using SiteServer.Utils;
-using SiteServer.CMS.Model.Enumerations;
-using SiteServer.Utils.Enumerations;
-
-namespace SiteServer.CMS.Model
-{
- public class ChannelInfoExtend : ExtendedAttributes
- {
- public ChannelInfoExtend(string settings) : base(settings)
- {
-
- }
-
- //是否可以添加栏目
- public bool IsChannelAddable
- {
- get { return GetBool("IsChannelAddable", true); }
- set { Set("IsChannelAddable", value.ToString()); }
- }
-
- //是否可以添加内容
- public bool IsContentAddable
- {
- get { return GetBool("IsContentAddable", true); }
- set { Set("IsContentAddable", value.ToString()); }
- }
-
- public bool IsChannelCreatable
- {
- get { return GetBool("IsChannelCreatable", true); }
- set { Set("IsChannelCreatable", value.ToString()); }
- }
-
- public bool IsContentCreatable
- {
- get { return GetBool("IsContentCreatable", true); }
- set { Set("IsContentCreatable", value.ToString()); }
- }
-
- public bool IsCreateChannelIfContentChanged
- {
- get { return GetBool("IsCreateChannelIfContentChanged", true); }
- set { Set("IsCreateChannelIfContentChanged", value.ToString()); }
- }
-
- public string CreateChannelIDsIfContentChanged
- {
- get { return GetString("CreateChannelIDsIfContentChanged"); }
- set { Set("CreateChannelIDsIfContentChanged", value); }
- }
-
- public string ContentAttributesOfDisplay
- {
- get { return GetString("ContentAttributesOfDisplay"); }
- set { Set("ContentAttributesOfDisplay", value); }
- }
-
- public ECrossSiteTransType TransType
- {
- get { return ECrossSiteTransTypeUtils.GetEnumType(GetString("TransType")); }
- set { Set("TransType", ECrossSiteTransTypeUtils.GetValue(value)); }
- }
-
- public int TransSiteId
- {
- get { return TranslateUtils.ToInt(GetString("TransSiteId")); }
- set { Set("TransSiteId", value.ToString()); }
- }
-
- public string TransChannelIds
- {
- get { return GetString("TransChannelIds"); }
- set { Set("TransChannelIds", value); }
- }
-
- public string TransChannelNames
- {
- get { return GetString("TransChannelNames"); }
- set { Set("TransChannelNames", value); }
- }
-
- public bool TransIsAutomatic
- {
- get { return GetBool("TransIsAutomatic"); }
- set { Set("TransIsAutomatic", value.ToString()); }
- }
-
- //跨站转发操作类型:复制 引用地址 引用内容
- public ETranslateContentType TransDoneType
- {
- get { return ETranslateContentTypeUtils.GetEnumType(GetString("TransDoneType")); }
- set { Set("TransDoneType", ETranslateContentTypeUtils.GetValue(value)); }
- }
-
- public bool IsPreviewContents
- {
- get { return GetBool("IsPreviewContents"); }
- set { Set("IsPreviewContents", value.ToString()); }
- }
-
- public string DefaultTaxisType
- {
- get { return GetString("DefaultTaxisType", ETaxisTypeUtils.GetValue(ETaxisType.OrderByTaxisDesc)); }
- set { Set("DefaultTaxisType", value); }
- }
- }
-}
diff --git a/SiteServer.CMS/Model/ConfigInfo.cs b/SiteServer.CMS/Model/ConfigInfo.cs
deleted file mode 100644
index 4f3480c41..000000000
--- a/SiteServer.CMS/Model/ConfigInfo.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-
-namespace SiteServer.CMS.Model
-{
- public class ConfigInfo
- {
- public ConfigInfo()
- {
- Id = 0;
- IsInitialized = false;
- DatabaseVersion = string.Empty;
- UpdateDate = DateTime.Now;
- SystemConfig = string.Empty;
- }
-
- public ConfigInfo(bool isInitialized, string databaseVersion, DateTime updateDate, string systemConfig)
- {
- IsInitialized = isInitialized;
- DatabaseVersion = databaseVersion;
- UpdateDate = updateDate;
- SystemConfig = systemConfig;
- }
-
- public int Id { get; set; }
-
- public bool IsInitialized { get; set; }
-
- public string DatabaseVersion { get; set; }
-
- public DateTime UpdateDate { get; set; }
-
- public string SystemConfig { get; set; }
-
- private SystemConfigInfo _systemConfigInfo;
- public SystemConfigInfo SystemConfigInfo => _systemConfigInfo ?? (_systemConfigInfo = new SystemConfigInfo(SystemConfig));
- }
-}
diff --git a/SiteServer.CMS/Model/ContentAttribute.cs b/SiteServer.CMS/Model/ContentAttribute.cs
deleted file mode 100644
index cae775141..000000000
--- a/SiteServer.CMS/Model/ContentAttribute.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System.Collections.Generic;
-
-namespace SiteServer.CMS.Model
-{
- public class ContentAttribute
- {
- protected ContentAttribute()
- {
- }
-
- public const string Id = nameof(Id);
- public const string ChannelId = nameof(ChannelId);
- public const string SiteId = nameof(SiteId);
- public const string AddUserName = nameof(AddUserName);
- public const string LastEditUserName = nameof(LastEditUserName);
- public const string WritingUserName = nameof(WritingUserName);
- public const string LastEditDate = nameof(LastEditDate);
- public const string Taxis = nameof(Taxis);
- public const string GroupNameCollection = nameof(GroupNameCollection);
- public const string Tags = nameof(Tags);
- public const string SourceId = nameof(SourceId);
- public const string ReferenceId = nameof(ReferenceId);
- public const string IsChecked = nameof(IsChecked);
- public const string CheckedLevel = nameof(CheckedLevel);
- public const string Hits = nameof(Hits);
- public const string HitsByDay = nameof(HitsByDay);
- public const string HitsByWeek = nameof(HitsByWeek);
- public const string HitsByMonth = nameof(HitsByMonth);
- public const string LastHitsDate = nameof(LastHitsDate);
- public const string SettingsXml = nameof(SettingsXml);
- public const string Title = nameof(Title);
- public const string IsTop = nameof(IsTop);
- public const string IsRecommend = nameof(IsRecommend);
- public const string IsHot = nameof(IsHot);
- public const string IsColor = nameof(IsColor);
- public const string LinkUrl = nameof(LinkUrl);
- public const string AddDate = nameof(AddDate);
-
- public static string GetFormatStringAttributeName(string attributeName)
- {
- return attributeName + "FormatString";
- }
-
- public static string GetExtendAttributeName(string attributeName)
- {
- return attributeName + "_Extend";
- }
-
- public const string CheckIsAdmin = "Check_IsAdmin"; //审核者是否为管理员
- public const string CheckUserName = "Check_UserName"; //审核者
- public const string CheckCheckDate = "Check_CheckDate"; //审核时间
- public const string CheckReasons = "Check_Reasons"; //审核原因
- public const string TranslateContentType = "TranslateContentType"; //转移内容类型
-
- private static List _allAttributesLowercase;
-
- public static List AllAttributesLowercase => _allAttributesLowercase ?? (_allAttributesLowercase = new List