Skip to content

Commit

Permalink
Optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne-KTCSZ committed Aug 5, 2020
1 parent 90b8bd2 commit 553fd98
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DataBase/MySql/Dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ CREATE TABLE `CMS_Redirection` (

/*!40000 ALTER TABLE `CMS_Redirection` DISABLE KEYS */;
INSERT INTO `CMS_Redirection` VALUES
(1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',1);
(1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',0);
/*!40000 ALTER TABLE `CMS_Redirection` ENABLE KEYS */;

DROP TABLE IF EXISTS `CMS_Rule`;
Expand Down
2 changes: 1 addition & 1 deletion DataBase/SQLite/ZKEACMS.sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4784,7 +4784,7 @@ INSERT INTO [HtmlWidget] ([ID],[HTML]) VALUES ('f6de0d62d3974ee2bf2ded3fbbc82c2b
INSERT INTO [CMS_Theme] ([ID],[Title],[Url],[UrlDebugger],[Thumbnail],[IsActived],[Status],[Description],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate]) VALUES ('Default','默认','~/themes/Default/css/Theme.min.css','~/themes/Default/css/Theme.css','~/themes/Default/thumbnail.jpg',1,1,NULL,'admin','ZKEASOFT','2016-04-04 22:17:10.790','admin','ZKEASOFT','2016-04-04 22:21:01.487');
INSERT INTO [CMS_Rule] ([RuleID],[Title],[ZoneName],[RuleExpression],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[RuleItems]) VALUES (1,'所有页面','顶部','StartsWith(ValueOf(''Url''),''/'')',NULL,1,'admin','ZKEASOFT','2018-05-21 23:43:34.623','admin','ZKEASOFT','2018-05-21 23:43:34.623','[{"Condition":"and","FunctionName":"StartsWith","Property":"ValueOf(''Url'')","Value":"/","Title":null,"Description":null,"Status":null,"CreateBy":null,"CreatebyName":null,"CreateDate":null,"LastUpdateBy":null,"LastUpdateByName":null,"LastUpdateDate":null,"ActionType":1}]');
INSERT INTO [CMS_Rule] ([RuleID],[Title],[ZoneName],[RuleExpression],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[RuleItems]) VALUES (2,'所有页面','底部','StartsWith(ValueOf(''Url''),''/'')',NULL,1,'admin','ZKEASOFT','2018-05-21 23:43:52.343','admin','ZKEASOFT','2018-05-21 23:43:52.343','[{"Condition":"and","FunctionName":"StartsWith","Property":"ValueOf(''Url'')","Value":"/","Title":null,"Description":null,"Status":null,"CreateBy":null,"CreatebyName":null,"CreateDate":null,"LastUpdateBy":null,"LastUpdateByName":null,"LastUpdateDate":null,"ActionType":1}]');
INSERT INTO [CMS_Redirection] ([ID],[Title],[InComingUrl],[DestinationURL],[IsPermanent],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[IsPattern]) VALUES (1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',1);
INSERT INTO [CMS_Redirection] ([ID],[Title],[InComingUrl],[DestinationURL],[IsPermanent],[Description],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[IsPattern]) VALUES (1,'默认','~/','~/index',0,NULL,1,'admin','ZKEASOFT','2017-08-14 14:58:06.000','admin','ZKEASOFT','2020-08-01 22:21:26.837',0);
INSERT INTO [CMS_Message] ([ID],[Title],[Email],[PostMessage],[Reply],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[Description]) VALUES (1,'ZKEASOFT','[email protected]','ZKEACMS是基于ASP.NET MVC4开发的开源CMS,提供免费下载学习使用。','KEACMS使用可视化编辑设计,所见即所得,可直接在页面上设计你要的页面。',1,'admin','ZKEASOFT','2017-03-19 21:02:34.260','admin','ZKEASOFT','2017-03-19 21:02:34.260',NULL);
INSERT INTO [CMS_Message] ([ID],[Title],[Email],[PostMessage],[Reply],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[Description]) VALUES (2,'ZKEASOFT','[email protected]','ZKEACMS使用可视化编辑设计','ZKEACMS是一个内容管理软件(网站),不仅只是管理内容,更是重新定义了布局、页面和组件,让用户可以自由规划页面的布局,页面和内容。',1,'admin','ZKEASOFT','2017-03-19 21:03:09.967','admin','ZKEASOFT','2017-03-19 21:03:09.967',NULL);
INSERT INTO [CMS_Media] ([ID],[ParentID],[Title],[MediaType],[Url],[Status],[CreateBy],[CreatebyName],[CreateDate],[LastUpdateBy],[LastUpdateByName],[LastUpdateDate],[Description]) VALUES ('6056810a7ede46bb94b55b2756323640','#','图片',1,NULL,NULL,'admin','ZKEASOFT','2016-04-01 21:42:14.960','admin','ZKEASOFT','2016-04-01 21:42:14.960',NULL);
Expand Down
2 changes: 1 addition & 1 deletion DataBase/script.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ INSERT [dbo].[CMS_Page] ([ID], [ReferencePageID], [IsPublishedPage], [ParentId],
INSERT [dbo].[CMS_Page] ([ID], [ReferencePageID], [IsPublishedPage], [ParentId], [PageName], [IsHomePage], [Url], [LayoutId], [Title], [Content], [DisplayOrder], [Description], [Status], [IsPublish], [PublishDate], [MetaKeyWorlds], [MetaDescription], [Script], [Style], [CreateBy], [CreatebyName], [CreateDate], [LastUpdateBy], [LastUpdateByName], [LastUpdateDate]) VALUES (N'e371628aa3ff46c3a167f121c7a3f32b', NULL, 0, N'#', N'文章', 0, N'~/article', N'0846a33e56bf45d5aae602ef40d87444', N'文章', NULL, 3, NULL, 1, 1, CAST(N'2017-10-15T18:11:44.940' AS DateTime), NULL, NULL, NULL, NULL, N'admin', N'ZKEASOFT', CAST(N'2016-03-09T12:45:01.000' AS DateTime), N'admin', N'ZKEASOFT', CAST(N'2017-10-15T18:11:44.940' AS DateTime))
SET IDENTITY_INSERT [dbo].[CMS_Redirection] ON

INSERT [dbo].[CMS_Redirection] ([ID], [Title], [InComingUrl], [DestinationURL], [IsPermanent], [Description], [Status], [CreateBy], [CreatebyName], [CreateDate], [LastUpdateBy], [LastUpdateByName], [LastUpdateDate], [IsPattern]) VALUES (1, N'默认', N'~/', N'~/index', 0, NULL, 1, N'admin', N'ZKEASOFT', CAST(N'2017-08-14T14:58:06.000' AS DateTime), N'admin', N'ZKEASOFT', CAST(N'2020-08-01T22:21:26.837' AS DateTime), 1)
INSERT [dbo].[CMS_Redirection] ([ID], [Title], [InComingUrl], [DestinationURL], [IsPermanent], [Description], [Status], [CreateBy], [CreatebyName], [CreateDate], [LastUpdateBy], [LastUpdateByName], [LastUpdateDate], [IsPattern]) VALUES (1, N'默认', N'~/', N'~/index', 0, NULL, 1, N'admin', N'ZKEASOFT', CAST(N'2017-08-14T14:58:06.000' AS DateTime), N'admin', N'ZKEASOFT', CAST(N'2020-08-01T22:21:26.837' AS DateTime), 0)
SET IDENTITY_INSERT [dbo].[CMS_Redirection] OFF
SET IDENTITY_INSERT [dbo].[CMS_Rule] ON

Expand Down
17 changes: 11 additions & 6 deletions src/ZKEACMS/Page/PageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public PageService(IWidgetBasePartService widgetService,
_layoutHtmlService = layoutHtmlService;
_eventManager = eventManager;
_localize = localize;
_cachedPage = new Dictionary<string, IEnumerable<PageEntity>>();
_cachedPage = new Dictionary<string, IEnumerable<PageEntity>>(StringComparer.OrdinalIgnoreCase);
}

private string FormatPath(string path)
Expand All @@ -77,6 +77,7 @@ private void InitAssets(PageEntity page)
{
if (page.Style.IsNotNullAndWhiteSpace())
{
page.Styles.Clear();
if (page.Style.StartsWith("["))
{
foreach (var item in JsonConvert.DeserializeObject<string[]>(page.Style))
Expand All @@ -91,6 +92,7 @@ private void InitAssets(PageEntity page)
}
if (page.Script.IsNotNullAndWhiteSpace())
{
page.Scripts.Clear();
if (page.Script.StartsWith("["))
{
foreach (var item in JsonConvert.DeserializeObject<string[]>(page.Script))
Expand Down Expand Up @@ -378,16 +380,19 @@ public void Move(string id, int position, int oldPosition)
public PageEntity GetByPath(string path, bool isPreView)
{
string formatedPath = FormatPath(path);
PageEntity page = null;
if (_cachedPage.ContainsKey(formatedPath))
{
return _cachedPage[formatedPath].Where(m => m.Url.Equals(formatedPath, StringComparison.OrdinalIgnoreCase) && m.IsPublishedPage == !isPreView)
page = _cachedPage[formatedPath].Where(m => m.IsPublishedPage == !isPreView)
.OrderByDescending(m => m.PublishDate)
.FirstOrDefault();
}
PageEntity page = Get()
.Where(m => m.Url == formatedPath && m.IsPublishedPage == !isPreView)
.OrderByDescending(m => m.PublishDate)
.FirstOrDefault();
else
{
page = Get().Where(m => m.Url == formatedPath && m.IsPublishedPage == !isPreView)
.OrderByDescending(m => m.PublishDate)
.FirstOrDefault();
}
InitAssets(page);
return page;
}
Expand Down
35 changes: 34 additions & 1 deletion src/ZKEACMS/PluginBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,40 @@ public virtual void Setup(params object[] args)
if (serviceCollection != null)
{
ConfigureServices(serviceCollection);
Assembly.DefinedTypes.Where(type => IsController(type)).Each(c => serviceCollection.TryAddTransient(c));
Assembly.DefinedTypes.Where(type => IsController(type)).Each(c =>
{
// RouteAttribute[] controllerRoutes = c.GetCustomAttributes(typeof(RouteAttribute), false) as RouteAttribute[];
// if (controllerRoutes != null)
// {
// foreach (var route in controllerRoutes)
// {
// RouteDescriptors.Routes.Add(new RouteDescriptor()
// {
// RouteName = $"ControllerRoute_{c.Name}",
// Template = route.Template,
// Priority = 10
// });
// }
// }
// MemberInfo[] actions = c.GetMethods();
// foreach (var action in actions)
// {
// RouteAttribute[] actionRoutes = action.GetCustomAttributes(typeof(RouteAttribute), false) as RouteAttribute[];
// if (actionRoutes != null)
// {
// foreach (var route in actionRoutes)
// {
// RouteDescriptors.Routes.Add(new RouteDescriptor()
// {
// RouteName = $"ActionRoute_{c.Name}",
// Template = route.Template,
// Priority = 11
// });
// }
// }
// }
serviceCollection.TryAddTransient(c);
});
}
}
else if (item is IMvcBuilder)
Expand Down

0 comments on commit 553fd98

Please sign in to comment.