diff --git a/Database/SQLite/ZKEACMS.sqlite.sql b/Database/SQLite/ZKEACMS.sqlite.sql index 4708733c3..f9602acdb 100644 --- a/Database/SQLite/ZKEACMS.sqlite.sql +++ b/Database/SQLite/ZKEACMS.sqlite.sql @@ -984,7 +984,7 @@ CREATE TABLE [CMS_Page] ( , [ParentId] nvarchar(100) NULL , [PageName] nvarchar(100) NULL , [IsHomePage] bit NOT NULL -, [Url] nvarchar(255) NULL +, [Url] nvarchar(255) NULL COLLATE NOCASE , [LayoutId] nvarchar(100) NULL , [Title] nvarchar(255) NULL , [Content] ntext NULL @@ -1177,7 +1177,7 @@ CREATE TABLE [Article] ( , FOREIGN KEY ([ArticleTypeID]) REFERENCES [ArticleType] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION ); CREATE TABLE [ApplicationSetting] ( - [SettingKey] nvarchar(50) NOT NULL + [SettingKey] nvarchar(50) NOT NULL COLLATE NOCASE , [Value] ntext NULL , [Title] nvarchar(200) NULL , [Description] nvarchar(500) NULL diff --git a/Database/Update/4.1/Enterprise.MsSql.sql b/Database/Update/4.1/Enterprise.MsSql.sql new file mode 100644 index 000000000..f14beff75 --- /dev/null +++ b/Database/Update/4.1/Enterprise.MsSql.sql @@ -0,0 +1,150 @@ +IF NOT EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = 'ArticleTypeRelation') +BEGIN + CREATE TABLE [dbo].[ArticleTypeRelation]( + [ArticleId] [nvarchar](100) NOT NULL, + [ArticleTypeId] [nvarchar](100) NOT NULL, + CONSTRAINT [PK_ArticleTypeRelation] PRIMARY KEY CLUSTERED + ( + [ArticleId] ASC, + [ArticleTypeId] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] + ) ON [PRIMARY] +END +GO +TRUNCATE TABLE [dbo].[ArticleTypeRelation] +GO +INSERT INTO [dbo].[ArticleTypeRelation] (ArticleId, ArticleTypeId) +SELECT DISTINCT ISNULL(ContentID,ID),ArticleTypeID FROM dbo.[Article] +GO + +IF NOT EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = 'CMS_WidgetArticleTypeRelation') +BEGIN + CREATE TABLE [dbo].[CMS_WidgetArticleTypeRelation]( + [WidgetId] [nvarchar](100) NOT NULL, + [ArticleTypeId] [int] NOT NULL, + CONSTRAINT [PK_CMS_WidgetArticleTypeRelation] PRIMARY KEY CLUSTERED + ( + [WidgetId] ASC, + [ArticleTypeId] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] + ) ON [PRIMARY] +END +GO +TRUNCATE TABLE dbo.CMS_WidgetArticleTypeRelation +GO +INSERT INTO [dbo].[CMS_WidgetArticleTypeRelation](WidgetId,ArticleTypeId) +SELECT T0.ID, T1.ID FROM dbo.ArticleListWidget T0 +INNER JOIN dbo.ArticleType T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID =T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM dbo.ArticleTopWidget T0 +INNER JOIN dbo.ArticleType T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID =T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM dbo.ArticleTypeWidget T0 +INNER JOIN dbo.ArticleType T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID = T1.ParentID +GO + + +IF NOT EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = 'ProductCategoryRelation') +BEGIN + CREATE TABLE [dbo].[ProductCategoryRelation]( + [ProductId] [nvarchar](100) NOT NULL, + [ProductCategoryId] [nvarchar](100) NOT NULL, + CONSTRAINT [PK_ProductCategoryRelation] PRIMARY KEY CLUSTERED + ( + [ProductId] ASC, + [ProductCategoryId] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] + ) ON [PRIMARY] +END +GO +TRUNCATE TABLE [dbo].[ProductCategoryRelation] +GO +INSERT INTO [dbo].[ProductCategoryRelation] (ProductId, ProductCategoryId) +SELECT DISTINCT ISNULL(ContentID,ID), ProductCategoryID FROM dbo.[Product] +GO + +IF NOT EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = 'CMS_WidgetProductCategoryRelation') +BEGIN + CREATE TABLE [dbo].[CMS_WidgetProductCategoryRelation]( + [WidgetId] [nvarchar](100) NOT NULL, + [ProductCategoryId] [int] NOT NULL, + CONSTRAINT [PK_CMS_WidgetProductCategoryRelation] PRIMARY KEY CLUSTERED + ( + [WidgetId] ASC, + [ProductCategoryId] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] + ) ON [PRIMARY] +END +GO +TRUNCATE TABLE dbo.[CMS_WidgetProductCategoryRelation] +GO +INSERT INTO [dbo].[CMS_WidgetProductCategoryRelation](WidgetId, ProductCategoryId) +SELECT T0.ID, T1.ID FROM dbo.ProductListWidget T0 +INNER JOIN dbo.ProductCategory T1 ON T0.ProductCategoryID = T1.ID OR T0.ProductCategoryID =T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM dbo.ProductCategoryWidget T0 +INNER JOIN dbo.ProductCategory T1 ON T0.ProductCategoryID = T1.ID OR T0.ProductCategoryID = T1.ParentID +GO + +IF NOT EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = 'VideoTypeRelation') +BEGIN + CREATE TABLE [dbo].[VideoTypeRelation]( + [VideoId] [nvarchar](100) NOT NULL, + [VideoTypeId] [nvarchar](100) NOT NULL, + CONSTRAINT [PK_VideoTypeRelation] PRIMARY KEY CLUSTERED + ( + [VideoId] ASC, + [VideoTypeId] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] + ) ON [PRIMARY] +END +GO +TRUNCATE TABLE [dbo].[VideoTypeRelation] +GO +INSERT INTO [dbo].[VideoTypeRelation] (VideoId, VideoTypeId) +SELECT DISTINCT ISNULL(ContentID,ID),VideoTypeID FROM dbo.[Video] +GO + +IF NOT EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = 'CMS_WidgetVideoTypeRelation') +BEGIN + CREATE TABLE [dbo].[CMS_WidgetVideoTypeRelation]( + [WidgetId] [nvarchar](100) NOT NULL, + [VideoTypeId] [int] NOT NULL, + CONSTRAINT [PK_CMS_WidgetVideoTypeRelation] PRIMARY KEY CLUSTERED + ( + [WidgetId] ASC, + [VideoTypeId] ASC + )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY] + ) ON [PRIMARY] +END +GO +TRUNCATE TABLE dbo.CMS_WidgetVideoTypeRelation +GO +INSERT INTO [dbo].[CMS_WidgetVideoTypeRelation](WidgetId,VideoTypeId) +SELECT T0.ID, T1.ID FROM dbo.VideoListWidget T0 +INNER JOIN dbo.VideoType T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID =T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM dbo.VideoTopWidget T0 +INNER JOIN dbo.VideoType T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID =T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM dbo.VideoTypeWidget T0 +INNER JOIN dbo.VideoType T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID = T1.ParentID +GO \ No newline at end of file diff --git a/Database/Update/4.1/Enterprise.MySql.sql b/Database/Update/4.1/Enterprise.MySql.sql new file mode 100644 index 000000000..6ffcacb05 --- /dev/null +++ b/Database/Update/4.1/Enterprise.MySql.sql @@ -0,0 +1,83 @@ +CREATE TABLE IF NOT EXISTS `ArticleTypeRelation` ( + `ArticleId` VARCHAR(100) NOT NULL, + `ArticleTypeId` VARCHAR(100) NOT NULL, + PRIMARY KEY (`ArticleId`, `ArticleTypeId`) +); + +DELETE FROM `ArticleTypeRelation`; + +INSERT INTO `ArticleTypeRelation` (ArticleId, ArticleTypeId) +SELECT DISTINCT IFNULL(ContentID, ID), ArticleTypeID FROM `Article`; + +CREATE TABLE IF NOT EXISTS `CMS_WidgetArticleTypeRelation` ( + `WidgetId` VARCHAR(100) NOT NULL, + `ArticleTypeId` INT NOT NULL, + PRIMARY KEY (`WidgetId`, `ArticleTypeId`) +); + +DELETE FROM `CMS_WidgetArticleTypeRelation`; + +INSERT INTO `CMS_WidgetArticleTypeRelation` (WidgetId, ArticleTypeId) +SELECT T0.ID, T1.ID FROM `ArticleListWidget` T0 +INNER JOIN `ArticleType` T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM `ArticleTopWidget` T0 +INNER JOIN `ArticleType` T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM `ArticleTypeWidget` T0 +INNER JOIN `ArticleType` T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID = T1.ParentID; + +CREATE TABLE IF NOT EXISTS `ProductCategoryRelation` ( + `ProductId` VARCHAR(100) NOT NULL, + `ProductCategoryId` VARCHAR(100) NOT NULL, + PRIMARY KEY (`ProductId`, `ProductCategoryId`) +); + +DELETE FROM `ProductCategoryRelation`; + +INSERT INTO `ProductCategoryRelation` (ProductId, ProductCategoryId) +SELECT DISTINCT IFNULL(ContentID, ID), ProductCategoryID FROM `Product`; + +CREATE TABLE IF NOT EXISTS `CMS_WidgetProductCategoryRelation` ( + `WidgetId` VARCHAR(100) NOT NULL, + `ProductCategoryId` INT NOT NULL, + PRIMARY KEY (`WidgetId`, `ProductCategoryId`) +); + +DELETE FROM `CMS_WidgetProductCategoryRelation`; + +INSERT INTO `CMS_WidgetProductCategoryRelation` (WidgetId, ProductCategoryId) +SELECT T0.ID, T1.ID FROM `ProductListWidget` T0 +INNER JOIN `ProductCategory` T1 ON T0.ProductCategoryID = T1.ID OR T0.ProductCategoryID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM `ProductCategoryWidget` T0 +INNER JOIN `ProductCategory` T1 ON T0.ProductCategoryID = T1.ID OR T0.ProductCategoryID = T1.ParentID; + +CREATE TABLE IF NOT EXISTS `VideoTypeRelation` ( + `VideoId` VARCHAR(100) NOT NULL, + `VideoTypeId` VARCHAR(100) NOT NULL, + PRIMARY KEY (`VideoId`, `VideoTypeId`) +); + +DELETE FROM `VideoTypeRelation`; + +INSERT INTO `VideoTypeRelation` (VideoId, VideoTypeId) +SELECT DISTINCT IFNULL(ContentID, ID), VideoTypeID FROM `Video`; + +CREATE TABLE IF NOT EXISTS `CMS_WidgetVideoTypeRelation` ( + `WidgetId` VARCHAR(100) NOT NULL, + `VideoTypeId` INT NOT NULL, + PRIMARY KEY (`WidgetId`, `VideoTypeId`) +); + +DELETE FROM `CMS_WidgetVideoTypeRelation`; + +INSERT INTO `CMS_WidgetVideoTypeRelation` (WidgetId, VideoTypeId) +SELECT T0.ID, T1.ID FROM `VideoListWidget` T0 +INNER JOIN `VideoType` T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM `VideoTopWidget` T0 +INNER JOIN `VideoType` T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM `VideoTypeWidget` T0 +INNER JOIN `VideoType` T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID = T1.ParentID; \ No newline at end of file diff --git a/Database/Update/4.1/Enterprise.Sqlite.sql b/Database/Update/4.1/Enterprise.Sqlite.sql new file mode 100644 index 000000000..c2c0fea01 --- /dev/null +++ b/Database/Update/4.1/Enterprise.Sqlite.sql @@ -0,0 +1,83 @@ +CREATE TABLE IF NOT EXISTS ArticleTypeRelation ( + ArticleId TEXT NOT NULL, + ArticleTypeId TEXT NOT NULL, + PRIMARY KEY (ArticleId, ArticleTypeId) +); + +DELETE FROM ArticleTypeRelation; + +INSERT INTO ArticleTypeRelation (ArticleId, ArticleTypeId) +SELECT DISTINCT IFNULL(ContentID, ID), ArticleTypeID FROM Article; + +CREATE TABLE IF NOT EXISTS CMS_WidgetArticleTypeRelation ( + WidgetId TEXT NOT NULL, + ArticleTypeId INTEGER NOT NULL, + PRIMARY KEY (WidgetId, ArticleTypeId) +); + +DELETE FROM CMS_WidgetArticleTypeRelation; + +INSERT INTO CMS_WidgetArticleTypeRelation (WidgetId, ArticleTypeId) +SELECT T0.ID, T1.ID FROM ArticleListWidget T0 +INNER JOIN ArticleType T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM ArticleTopWidget T0 +INNER JOIN ArticleType T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM ArticleTypeWidget T0 +INNER JOIN ArticleType T1 ON T0.ArticleTypeID = T1.ID OR T0.ArticleTypeID = T1.ParentID; + +CREATE TABLE IF NOT EXISTS ProductCategoryRelation ( + ProductId TEXT NOT NULL, + ProductCategoryId TEXT NOT NULL, + PRIMARY KEY (ProductId, ProductCategoryId) +); + +DELETE FROM ProductCategoryRelation; + +INSERT INTO ProductCategoryRelation (ProductId, ProductCategoryId) +SELECT DISTINCT IFNULL(ContentID, ID), ProductCategoryID FROM Product; + +CREATE TABLE IF NOT EXISTS CMS_WidgetProductCategoryRelation ( + WidgetId TEXT NOT NULL, + ProductCategoryId INTEGER NOT NULL, + PRIMARY KEY (WidgetId, ProductCategoryId) +); + +DELETE FROM CMS_WidgetProductCategoryRelation; + +INSERT INTO CMS_WidgetProductCategoryRelation (WidgetId, ProductCategoryId) +SELECT T0.ID, T1.ID FROM ProductListWidget T0 +INNER JOIN ProductCategory T1 ON T0.ProductCategoryID = T1.ID OR T0.ProductCategoryID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM ProductCategoryWidget T0 +INNER JOIN ProductCategory T1 ON T0.ProductCategoryID = T1.ID OR T0.ProductCategoryID = T1.ParentID; + +CREATE TABLE IF NOT EXISTS VideoTypeRelation ( + VideoId TEXT NOT NULL, + VideoTypeId TEXT NOT NULL, + PRIMARY KEY (VideoId, VideoTypeId) +); + +DELETE FROM VideoTypeRelation; + +INSERT INTO VideoTypeRelation (VideoId, VideoTypeId) +SELECT DISTINCT IFNULL(ContentID, ID), VideoTypeID FROM Video; + +CREATE TABLE IF NOT EXISTS CMS_WidgetVideoTypeRelation ( + WidgetId TEXT NOT NULL, + VideoTypeId INTEGER NOT NULL, + PRIMARY KEY (WidgetId, VideoTypeId) +); + +DELETE FROM CMS_WidgetVideoTypeRelation; + +INSERT INTO CMS_WidgetVideoTypeRelation (WidgetId, VideoTypeId) +SELECT T0.ID, T1.ID FROM VideoListWidget T0 +INNER JOIN VideoType T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM VideoTopWidget T0 +INNER JOIN VideoType T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID = T1.ParentID +UNION +SELECT T0.ID, T1.ID FROM VideoTypeWidget T0 +INNER JOIN VideoType T1 ON T0.VideoTypeID = T1.ID OR T0.VideoTypeID = T1.ParentID; \ No newline at end of file diff --git a/Database/Update/4.1/package.zip b/Database/Update/4.1/package.zip new file mode 100644 index 000000000..643cfa22f Binary files /dev/null and b/Database/Update/4.1/package.zip differ diff --git a/Database/index.json b/Database/index.json index bac7174b2..88ad07ecd 100644 --- a/Database/index.json +++ b/Database/index.json @@ -60,6 +60,10 @@ { "Version": "4.0", "Resolved": "Update/4.0/package.zip" + }, + { + "Version": "4.1", + "Resolved": "Update/4.1/package.zip" } ] } \ No newline at end of file diff --git a/src/EasyFrameWork/EasyFrameWork.csproj b/src/EasyFrameWork/EasyFrameWork.csproj index 1482e7632..dfd57f771 100644 --- a/src/EasyFrameWork/EasyFrameWork.csproj +++ b/src/EasyFrameWork/EasyFrameWork.csproj @@ -27,6 +27,6 @@ - + diff --git a/src/EasyFrameWork/Extend/ExtObject.cs b/src/EasyFrameWork/Extend/ExtObject.cs new file mode 100644 index 000000000..e440fe9cc --- /dev/null +++ b/src/EasyFrameWork/Extend/ExtObject.cs @@ -0,0 +1,21 @@ +/* http://www.zkea.net/ + * Copyright (c) ZKEASOFT. All rights reserved. + * http://www.zkea.net/licenses */ + +using Easy.Serializer; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Easy.Extend +{ + public static class ExtObject + { + public static T Clone(this T obj) where T : class + { + return JsonConverter.Deserialize(JsonConverter.Serialize(obj)); + } + } +} diff --git a/src/EasyFrameWork/Mvc/RazorPages/LocalizeString.cs b/src/EasyFrameWork/Mvc/RazorPages/LocalizeString.cs index 0a1337f86..efe4ba3bf 100644 --- a/src/EasyFrameWork/Mvc/RazorPages/LocalizeString.cs +++ b/src/EasyFrameWork/Mvc/RazorPages/LocalizeString.cs @@ -33,8 +33,6 @@ public LocalizeString(string content, string cultureCode, HttpContext httpContex } private string _translatedContent; public string Content { get; set; } - - public string CultureCode { get; set; } public string Text { get { return Get(); } } private HttpContext _httpContext; @@ -65,5 +63,10 @@ public override string ToString() { return this.Get(); } + + public static implicit operator string(LocalizeString content) + { + return content.ToString(); + } } } diff --git a/src/EasyFrameWork/RepositoryPattern/ServiceBase.cs b/src/EasyFrameWork/RepositoryPattern/ServiceBase.cs index d85988c10..e00ac1584 100644 --- a/src/EasyFrameWork/RepositoryPattern/ServiceBase.cs +++ b/src/EasyFrameWork/RepositoryPattern/ServiceBase.cs @@ -360,6 +360,7 @@ private void SaveChanges() if(!isInBulkSaving) { DbContext.SaveChanges(); + DbContext.ChangeTracker.Clear(); } } diff --git a/src/ZKEACMS.Animation/Service/AnimationScriptsService.cs b/src/ZKEACMS.Animation/Service/AnimationScriptsService.cs index 9b71e61f1..2939f8fa6 100644 --- a/src/ZKEACMS.Animation/Service/AnimationScriptsService.cs +++ b/src/ZKEACMS.Animation/Service/AnimationScriptsService.cs @@ -35,14 +35,12 @@ public void Handle(object entity, EventArg e) HtmlContentBuilder styleBuilder = new HtmlContentBuilder(); HtmlContentBuilder scriptBuilder = new HtmlContentBuilder(); #if DEBUG - styleBuilder.AppendHtml(""); - scriptBuilder.AppendHtml(""); + applicationContext.CurrentPage.StyleSheets.Add(new Page.StyleSheetTag("/Plugins/ZKEACMS.Animation/Content/animate.css")); + applicationContext.CurrentPage.FooterScripts.Add(new Page.ScriptTag("/Plugins/ZKEACMS.Animation/Scripts/animate.js")); #else - styleBuilder.AppendHtml(""); - scriptBuilder.AppendHtml(""); + applicationContext.CurrentPage.StyleSheets.Add(new Page.StyleSheetTag("/Plugins/ZKEACMS.Animation/Content/animate.min.css")); + applicationContext.CurrentPage.FooterScripts.Add(new Page.ScriptTag("/Plugins/ZKEACMS.Animation/Scripts/animate.min.js")); #endif - applicationContext.HeaderPart.Add(styleBuilder); - applicationContext.FooterPart.Add(scriptBuilder); } } } diff --git a/src/ZKEACMS.Article/ArticlePlug.cs b/src/ZKEACMS.Article/ArticlePlug.cs index d0bfdc84b..7d1391741 100644 --- a/src/ZKEACMS.Article/ArticlePlug.cs +++ b/src/ZKEACMS.Article/ArticlePlug.cs @@ -35,7 +35,7 @@ public override IEnumerable AdminMenu() { Title = "Article Manager", Icon = "glyphicon-font", - Order = 10, + Order = 31, Children = new List { new AdminMenu diff --git a/src/ZKEACMS.Article/Models/ArticleListWidget.cs b/src/ZKEACMS.Article/Models/ArticleListWidget.cs index 62aea6ebf..af93c5f3f 100644 --- a/src/ZKEACMS.Article/Models/ArticleListWidget.cs +++ b/src/ZKEACMS.Article/Models/ArticleListWidget.cs @@ -32,7 +32,7 @@ protected override void ViewConfigure() { base.ViewConfigure(); ViewConfig(m => m.Title).AsHidden(); - ViewConfig(m => m.ArticleTypeID).AsDropDownList().Order(NextOrder()).SetTemplate("ArticleTypeTree").Required(); + ViewConfig(m => m.ArticleTypeID).AsDropDownTree("GetArticleTypeTree", "ArticleType", "admin").Order(NextOrder()).Required(); ViewConfig(m => m.DetailPageUrl).AsTextBox().Order(NextOrder()).PageSelector().InnerUrl(); diff --git a/src/ZKEACMS.Article/Models/ArticleTopWidget.cs b/src/ZKEACMS.Article/Models/ArticleTopWidget.cs index 568b7420d..090f57ee9 100644 --- a/src/ZKEACMS.Article/Models/ArticleTopWidget.cs +++ b/src/ZKEACMS.Article/Models/ArticleTopWidget.cs @@ -33,7 +33,7 @@ protected override void ViewConfigure() { base.ViewConfigure(); ViewConfig(m => m.SubTitle).AsTextBox().Order(NextOrder()); - ViewConfig(m => m.ArticleTypeID).AsDropDownList().Order(NextOrder()).SetTemplate("ArticleTypeTree").Required(); + ViewConfig(m => m.ArticleTypeID).AsDropDownTree("GetArticleTypeTree", "ArticleType", "admin").Order(NextOrder()).Required(); ViewConfig(m => m.Tops).AsTextBox().Order(NextOrder()).RegularExpression(RegularExpression.PositiveIntegers).Required(); ViewConfig(m => m.MoreLink).AsTextBox().Order(NextOrder()).PageSelector(); ViewConfig(m => m.DetailPageUrl).AsTextBox().Order(NextOrder()).PageSelector().InnerUrl(); diff --git a/src/ZKEACMS.Article/Models/ArticleTypeWidget.cs b/src/ZKEACMS.Article/Models/ArticleTypeWidget.cs index 978ec66b8..12fee5fc6 100644 --- a/src/ZKEACMS.Article/Models/ArticleTypeWidget.cs +++ b/src/ZKEACMS.Article/Models/ArticleTypeWidget.cs @@ -26,7 +26,7 @@ class ArticleTypeWidgetMetaData : WidgetMetaData protected override void ViewConfigure() { base.ViewConfigure(); - ViewConfig(m => m.ArticleTypeID).AsDropDownList().Order(NextOrder()).SetTemplate("ArticleTypeTree").Required(); + ViewConfig(m => m.ArticleTypeID).AsDropDownTree("GetArticleTypeTree", "ArticleType", "admin").Order(NextOrder()).Required(); ViewConfig(m => m.PartialView).AsDropDownList().Order(NextOrder()).DataSource(SourceType.Dictionary).AsWidgetTemplateChooser(); ViewConfig(m => m.TargetPage).AsHidden(); } diff --git a/src/ZKEACMS.Article/Service/ArticleDetailWidgetService.cs b/src/ZKEACMS.Article/Service/ArticleDetailWidgetService.cs index 94f315cb8..fb4e89c5b 100644 --- a/src/ZKEACMS.Article/Service/ArticleDetailWidgetService.cs +++ b/src/ZKEACMS.Article/Service/ArticleDetailWidgetService.cs @@ -96,7 +96,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext) else { var latest = _articleService.GetLatestPublished(); - if (ApplicationContext.CurrentAppContext().IsDesignMode || ApplicationContext.CurrentAppContext().IsPreViewMode) + if (ApplicationContext.Current().IsDesignMode || ApplicationContext.Current().IsPreViewMode) { viewModel.Current = latest; } @@ -113,12 +113,8 @@ public override object Display(WidgetDisplayContext widgetDisplayContext) return null; } - var layout = widgetDisplayContext.PageLayout; - if (layout != null && layout.Page != null) - { - layout.Page.ConfigSEO(viewModel.Current.Title, viewModel.Current.MetaKeyWords, viewModel.Current.MetaDescription); - AddStructuredDataToPageHeader(viewModel.Current); - } + ApplicationContext.Current().CurrentPage.ConfigSEO(viewModel.Current.Title, viewModel.Current.MetaKeyWords, viewModel.Current.MetaDescription); + AddStructuredDataToPageHeader(viewModel.Current); return viewModel; } private void AddStructuredDataToPageHeader(ArticleEntity article) @@ -131,8 +127,11 @@ private void AddStructuredDataToPageHeader(ArticleEntity article) DateModified = article.LastUpdateDate, Author = new Person[] { new Person { Name = article.CreatebyName } } }; - IHtmlContent jsonLinkingData = HtmlHelper.SerializeToJsonLinkingData(structuredData); - ApplicationContext.CurrentAppContext().HeaderPart.Add(jsonLinkingData); + ApplicationContext.Current().CurrentPage.HeaderScripts.Add(new Page.ScriptTag() + { + Type = "application/ld+json", + InnerScript = new HtmlString(JsonConverter.Serialize(structuredData)) + }); } private IEnumerable GetImages(ArticleEntity article) { diff --git a/src/ZKEACMS.Article/Service/ArticleService.cs b/src/ZKEACMS.Article/Service/ArticleService.cs index b2778a858..f5d678363 100644 --- a/src/ZKEACMS.Article/Service/ArticleService.cs +++ b/src/ZKEACMS.Article/Service/ArticleService.cs @@ -19,10 +19,10 @@ public class ArticleService : ServiceBase, IArticle { private readonly ILocalize _localize; private readonly IEventManager _eventManager; - public ArticleService(IApplicationContext applicationContext, - ILocalize localize, + public ArticleService(IApplicationContext applicationContext, + ILocalize localize, CMSDbContext dbContext, - IEventManager eventManager) + IEventManager eventManager) : base(applicationContext, dbContext) { _localize = localize; @@ -98,10 +98,7 @@ public ArticleEntity GetPrev(ArticleEntity article) public void IncreaseCount(ArticleEntity article) { - article.Counter = (article.Counter ?? 0) + 1; - DbContext.Attach(article); - DbContext.Entry(article).Property(x => x.Counter).IsModified = true; - DbContext.SaveChanges(); + Get().Where(m => m.ID == article.ID).ExecuteUpdate(m => m.SetProperty(m => m.Counter, m => (m.Counter ?? 0) + 1)); } public void Publish(int ID) @@ -115,7 +112,7 @@ public void Publish(ArticleEntity article) if (article.PublishDate == null) { article.PublishDate = DateTime.Now; - } + } if (article.ID > 0) { Update(article); diff --git a/src/ZKEACMS.Article/Service/ArticleSpecialDetailWidgetService.cs b/src/ZKEACMS.Article/Service/ArticleSpecialDetailWidgetService.cs index dfa75ce50..06fdd3e34 100644 --- a/src/ZKEACMS.Article/Service/ArticleSpecialDetailWidgetService.cs +++ b/src/ZKEACMS.Article/Service/ArticleSpecialDetailWidgetService.cs @@ -45,11 +45,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext) else { _articleService.IncreaseCount(article); - var layout = widgetDisplayContext.PageLayout; - if (layout != null && layout.Page != null) - { - layout.Page.ConfigSEO(article.Title, article.MetaKeyWords, article.MetaDescription); - } + ApplicationContext.Current().CurrentPage.ConfigSEO(article.Title, article.MetaKeyWords, article.MetaDescription); } viewModel.Current = article; diff --git a/src/ZKEACMS.Article/Service/ArticleTypeWidgetService.cs b/src/ZKEACMS.Article/Service/ArticleTypeWidgetService.cs index 608a807ad..ba7e594e6 100644 --- a/src/ZKEACMS.Article/Service/ArticleTypeWidgetService.cs +++ b/src/ZKEACMS.Article/Service/ArticleTypeWidgetService.cs @@ -72,11 +72,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext) } if (articleType != null && articleType.SEOTitle.IsNotNullAndWhiteSpace()) { - var layout = widgetDisplayContext.PageLayout; - if (layout != null && layout.Page != null) - { - layout.Page.ConfigSEO(articleType.SEOTitle, articleType.SEOKeyWord, articleType.SEODescription); - } + _articleTypeService.ApplicationContext.Current().CurrentPage.ConfigSEO(articleType.SEOTitle, articleType.SEOKeyWord, articleType.SEODescription); } return new ArticleTypeWidgetViewModel { diff --git a/src/ZKEACMS.Article/Views/Article/Edit.cshtml b/src/ZKEACMS.Article/Views/Article/Edit.cshtml index fd99efc0c..04dca1915 100644 --- a/src/ZKEACMS.Article/Views/Article/Edit.cshtml +++ b/src/ZKEACMS.Article/Views/Article/Edit.cshtml @@ -2,26 +2,21 @@ @{ Script.Reqiured("validate").AtFoot(); Script.Reqiured("tinymce").AtFoot(); - string publicUrl = articleUrlService.GetPublicUrl(Model).FirstOrDefault(); + string publicUrl = articleUrlService.GetPublicUrl(Model)?.FirstOrDefault(); } @inject ZKEACMS.Article.Service.IArticleUrlService articleUrlService
- @L("Edit") - - @if (!Model.IsPublish) - { - - @L("Unpublished") - - } - else - { - - @L("Published") - - } + + @(Model.IsPublish ? L("Published") : L("Unpublished")) + @if (Model.IsPublish && publicUrl.IsNotNullAndWhiteSpace()) + { + + + + + }
@using (Html.BeginForm()) diff --git a/src/ZKEACMS.EventAction/EventActionPlug.cs b/src/ZKEACMS.EventAction/EventActionPlug.cs index 0f5ada0f8..c42550204 100644 --- a/src/ZKEACMS.EventAction/EventActionPlug.cs +++ b/src/ZKEACMS.EventAction/EventActionPlug.cs @@ -32,7 +32,7 @@ public override IEnumerable AdminMenu() { Title = "Event/Notification", Icon = "glyphicon-flash", - Order = 14, + Order = 80, Children = new List { new AdminMenu diff --git a/src/ZKEACMS.FormGenerator/FormPlug.cs b/src/ZKEACMS.FormGenerator/FormPlug.cs index 8db6370fc..71dd9a428 100644 --- a/src/ZKEACMS.FormGenerator/FormPlug.cs +++ b/src/ZKEACMS.FormGenerator/FormPlug.cs @@ -67,7 +67,7 @@ public override IEnumerable AdminMenu() } }, Icon = "glyphicon-list-alt", - Order = 12 + Order = 60 }; } diff --git a/src/ZKEACMS.GlobalScripts/Service/GlobalScriptsProviderService.cs b/src/ZKEACMS.GlobalScripts/Service/GlobalScriptsProviderService.cs index e28e094cf..a01a68161 100644 --- a/src/ZKEACMS.GlobalScripts/Service/GlobalScriptsProviderService.cs +++ b/src/ZKEACMS.GlobalScripts/Service/GlobalScriptsProviderService.cs @@ -41,11 +41,11 @@ public virtual void Handle(object entity, EventArg e) htmlContentBuilder.AppendHtml(script.Script); if (script.Location == (int)ScriptLocation.Header) { - applicationContext.HeaderPart.Add(htmlContentBuilder); + applicationContext.CurrentPage.Header.Add(htmlContentBuilder); } else { - applicationContext.FooterPart.Add(htmlContentBuilder); + applicationContext.CurrentPage.BodyFooter.Add(htmlContentBuilder); } } else @@ -56,11 +56,11 @@ public virtual void Handle(object entity, EventArg e) htmlContentBuilder.AppendHtml(""); if (script.Location == (int)ScriptLocation.Header) { - applicationContext.HeaderPart.Add(htmlContentBuilder); + applicationContext.CurrentPage.Header.Add(htmlContentBuilder); } else { - applicationContext.FooterPart.Add(htmlContentBuilder); + applicationContext.CurrentPage.BodyFooter.Add(htmlContentBuilder); } } } diff --git a/src/ZKEACMS.Message/MessagePlug.cs b/src/ZKEACMS.Message/MessagePlug.cs index 234f8ae88..7439249f4 100644 --- a/src/ZKEACMS.Message/MessagePlug.cs +++ b/src/ZKEACMS.Message/MessagePlug.cs @@ -34,7 +34,7 @@ public override IEnumerable AdminMenu() { Title = "Message And Comments", Icon = "glyphicon-volume-up", - Order = 7, + Order = 70, Children = new List { new AdminMenu diff --git a/src/ZKEACMS.PinNav/Service/PinNavScriptsService.cs b/src/ZKEACMS.PinNav/Service/PinNavScriptsService.cs index befd230d4..7ead44817 100644 --- a/src/ZKEACMS.PinNav/Service/PinNavScriptsService.cs +++ b/src/ZKEACMS.PinNav/Service/PinNavScriptsService.cs @@ -35,14 +35,12 @@ public void Handle(object entity, EventArg e) HtmlContentBuilder styleBuilder = new HtmlContentBuilder(); HtmlContentBuilder scriptBuilder = new HtmlContentBuilder(); #if DEBUG - styleBuilder.AppendHtml(""); - scriptBuilder.AppendHtml(""); + applicationContext.CurrentPage.StyleSheets.Add(new Page.StyleSheetTag("/Plugins/ZKEACMS.PinNav/Content/pin-nav.css")); + applicationContext.CurrentPage.FooterScripts.Add(new Page.ScriptTag("/Plugins/ZKEACMS.PinNav/Scripts/pin-nav.js")); #else - styleBuilder.AppendHtml(""); - scriptBuilder.AppendHtml(""); + applicationContext.CurrentPage.StyleSheets.Add(new Page.StyleSheetTag("/Plugins/ZKEACMS.PinNav/Content/pin-nav.min.css")); + applicationContext.CurrentPage.FooterScripts.Add(new Page.ScriptTag("/Plugins/ZKEACMS.PinNav/Scripts/pin-nav.min.js")); #endif - applicationContext.HeaderPart.Add(styleBuilder); - applicationContext.FooterPart.Add(scriptBuilder); } } } diff --git a/src/ZKEACMS.Product/Models/ProductCategoryWidget.cs b/src/ZKEACMS.Product/Models/ProductCategoryWidget.cs index 76eb851b0..e93d3ef1b 100644 --- a/src/ZKEACMS.Product/Models/ProductCategoryWidget.cs +++ b/src/ZKEACMS.Product/Models/ProductCategoryWidget.cs @@ -29,7 +29,7 @@ class ProductCategoryWidgetMedata : WidgetMetaData protected override void ViewConfigure() { base.ViewConfigure(); - ViewConfig(m => m.ProductCategoryID).AsDropDownList().Order(NextOrder()).SetTemplate("ProductCategoryTree").Required(); + ViewConfig(m => m.ProductCategoryID).AsDropDownTree("GetProductCategoryTree", "ProductCategory", "admin").Order(NextOrder()).Required(); ViewConfig(m => m.PartialView).AsDropDownList().Order(NextOrder()).DataSource(SourceType.Dictionary).AsWidgetTemplateChooser(); ViewConfig(m => m.TargetPage).AsHidden(); } diff --git a/src/ZKEACMS.Product/Models/ProductListWidget.cs b/src/ZKEACMS.Product/Models/ProductListWidget.cs index da2e7f04c..54607a4c7 100644 --- a/src/ZKEACMS.Product/Models/ProductListWidget.cs +++ b/src/ZKEACMS.Product/Models/ProductListWidget.cs @@ -36,7 +36,7 @@ protected override void ViewConfigure() { base.ViewConfigure(); ViewConfig(m => m.Title).AsHidden(); - ViewConfig(m => m.ProductCategoryID).AsDropDownList().SetTemplate("ProductCategoryTree").Required().Order(NextOrder()); + ViewConfig(m => m.ProductCategoryID).AsDropDownTree("GetProductCategoryTree", "ProductCategory", "admin").Required().Order(NextOrder()); ViewConfig(m => m.DetailPageUrl).AsTextBox().Order(NextOrder()).PageSelector().InnerUrl(); ViewConfig(m => m.IsPageable).AsCheckBox().Order(NextOrder()); diff --git a/src/ZKEACMS.Product/ProductPlug.cs b/src/ZKEACMS.Product/ProductPlug.cs index cf12c31d8..4105c6939 100644 --- a/src/ZKEACMS.Product/ProductPlug.cs +++ b/src/ZKEACMS.Product/ProductPlug.cs @@ -33,7 +33,7 @@ public override IEnumerable AdminMenu() { Title = "Manage Product", Icon = "glyphicon-list-alt", - Order = 11, + Order = 32, Children = new List { new AdminMenu diff --git a/src/ZKEACMS.Product/Service/ProductCategoryWidgetService.cs b/src/ZKEACMS.Product/Service/ProductCategoryWidgetService.cs index 2930a53b5..66cafbeaf 100644 --- a/src/ZKEACMS.Product/Service/ProductCategoryWidgetService.cs +++ b/src/ZKEACMS.Product/Service/ProductCategoryWidgetService.cs @@ -71,11 +71,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext) } if (productCategory != null && productCategory.SEOTitle.IsNotNullAndWhiteSpace()) { - var layout = widgetDisplayContext.PageLayout; - if (layout != null && layout.Page != null) - { - layout.Page.ConfigSEO(productCategory.SEOTitle, productCategory.SEOKeyWord, productCategory.SEODescription); - } + ApplicationContext.Current().CurrentPage.ConfigSEO(productCategory.SEOTitle, productCategory.SEOKeyWord, productCategory.SEODescription); } return new ProductCategoryWidgetViewModel { diff --git a/src/ZKEACMS.Product/Service/ProductDetailWidgetService.cs b/src/ZKEACMS.Product/Service/ProductDetailWidgetService.cs index 5fd1afcab..74aaf037e 100644 --- a/src/ZKEACMS.Product/Service/ProductDetailWidgetService.cs +++ b/src/ZKEACMS.Product/Service/ProductDetailWidgetService.cs @@ -18,6 +18,8 @@ using ZKEACMS.StructuredData; using Easy.Cache; using Microsoft.Extensions.Caching.Memory; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Easy.Serializer; namespace ZKEACMS.Product.Service { @@ -79,7 +81,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext) } else { - if (ApplicationContext.CurrentAppContext().IsDesignMode || ApplicationContext.CurrentAppContext().IsPreViewMode) + if (ApplicationContext.Current().IsDesignMode || ApplicationContext.Current().IsPreViewMode) { product = _productService.GetLatestPublished(); } @@ -95,12 +97,9 @@ public override object Display(WidgetDisplayContext widgetDisplayContext) return null; } - var layout = widgetDisplayContext.PageLayout; - if (layout != null && layout.Page != null) - { - layout.Page.ConfigSEO(product.SEOTitle ?? product.Title, product.SEOKeyWord, product.SEODescription); - AddStructuredDataToPageHeader(product); - } + ApplicationContext.Current().CurrentPage.ConfigSEO(product.SEOTitle ?? product.Title, product.SEOKeyWord, product.SEODescription); + AddStructuredDataToPageHeader(product); + return product; } @@ -113,8 +112,11 @@ private void AddStructuredDataToPageHeader(ProductEntity product) Description = product.Description, MPN = product.PartNumber }; - IHtmlContent jsonLinkingData = HtmlHelper.SerializeToJsonLinkingData(structuredData); - ApplicationContext.CurrentAppContext().HeaderPart.Add(jsonLinkingData); + ApplicationContext.Current().CurrentPage.HeaderScripts.Add(new Page.ScriptTag() + { + Type = "application/ld+json", + InnerScript = new HtmlString(JsonConverter.Serialize(structuredData)) + }); } private IEnumerable GetImages(ProductEntity product) { diff --git a/src/ZKEACMS.Product/Views/Product/Edit.cshtml b/src/ZKEACMS.Product/Views/Product/Edit.cshtml index 0daf78da8..e7f39c0a4 100644 --- a/src/ZKEACMS.Product/Views/Product/Edit.cshtml +++ b/src/ZKEACMS.Product/Views/Product/Edit.cshtml @@ -2,26 +2,21 @@ @{ Script.Reqiured("validate").AtFoot(); Script.Reqiured("tinymce").AtFoot(); - string publicUrl = productUrlService.GetPublicUrl(Model).FirstOrDefault(); + string publicUrl = productUrlService.GetPublicUrl(Model)?.FirstOrDefault(); } @inject ZKEACMS.Product.Service.IProductUrlService productUrlService
- @L("Edit") - - @if (!Model.IsPublish) - { - - @L("Unpublished") - - } - else - { - - @L("Published") - - } + + @(Model.IsPublish ? L("Published") : L("Unpublished")) + @if (Model.IsPublish && publicUrl.IsNotNullAndWhiteSpace()) + { + + + + + }
@using (Html.BeginForm()) diff --git a/src/ZKEACMS.SectionWidget/Controllers/SectionContentVideoController.cs b/src/ZKEACMS.SectionWidget/Controllers/SectionContentVideoController.cs index c1f26cb51..5e25c6d72 100644 --- a/src/ZKEACMS.SectionWidget/Controllers/SectionContentVideoController.cs +++ b/src/ZKEACMS.SectionWidget/Controllers/SectionContentVideoController.cs @@ -9,6 +9,7 @@ using Easy.Mvc.Authorize; using Easy.Extend; using System.Text.RegularExpressions; +using ZKEACMS.Filter; namespace ZKEACMS.SectionWidget.Controllers { @@ -62,6 +63,7 @@ public JsonResult Delete(string Id) return Json(true); } + [Themed] public ActionResult Play(string Id) { SectionContentVideo video = _sectionContentProviderService.GetContent(Id) as SectionContentVideo; diff --git a/src/ZKEACMS.Shop/ShopPlug.cs b/src/ZKEACMS.Shop/ShopPlug.cs index 64c31b3c1..49feb0bdb 100644 --- a/src/ZKEACMS.Shop/ShopPlug.cs +++ b/src/ZKEACMS.Shop/ShopPlug.cs @@ -54,7 +54,7 @@ public override IEnumerable AdminMenu() { Title = "E-commerce", Icon = "glyphicon-shopping-cart", - Order = 9, + Order = 40, Children = new List { new AdminMenu diff --git a/src/ZKEACMS.StyleEditor/Views/StyleEditor/Edit.cshtml b/src/ZKEACMS.StyleEditor/Views/StyleEditor/Edit.cshtml index 752c45459..9f364825a 100644 --- a/src/ZKEACMS.StyleEditor/Views/StyleEditor/Edit.cshtml +++ b/src/ZKEACMS.StyleEditor/Views/StyleEditor/Edit.cshtml @@ -66,13 +66,8 @@ - - + + diff --git a/src/ZKEACMS.Swagger/ZKEACMS.Swagger.csproj b/src/ZKEACMS.Swagger/ZKEACMS.Swagger.csproj index 82142fbb0..a1ca7d5ff 100644 --- a/src/ZKEACMS.Swagger/ZKEACMS.Swagger.csproj +++ b/src/ZKEACMS.Swagger/ZKEACMS.Swagger.csproj @@ -16,7 +16,7 @@ - + false runtime diff --git a/src/ZKEACMS.Updater/Service/DbUpdaterService.cs b/src/ZKEACMS.Updater/Service/DbUpdaterService.cs index 05e846ca6..780301a78 100644 --- a/src/ZKEACMS.Updater/Service/DbUpdaterService.cs +++ b/src/ZKEACMS.Updater/Service/DbUpdaterService.cs @@ -31,6 +31,7 @@ public class DbUpdaterService : IDbUpdaterService private readonly IWebClient _webClient; private readonly ILogger _logger; private readonly IDBContextProvider _dbContextProvider; + private readonly bool isDevelopment; private const int DBVersionRecord = 1; private readonly string _scriptFileName; private string availableSource; @@ -38,13 +39,15 @@ public DbUpdaterService(DatabaseOption databaseOption, IOptions dbVersionOption, IWebClient webClient, IDBContextProvider dbContextProvider, - ILogger logger) + ILogger logger, + IWebHostEnvironment hostEnvironment) { _dbVersionOption = dbVersionOption.Value; _webClient = webClient; _scriptFileName = $"{databaseOption.DbType}.sql";//MsSql.sql, MySql.sql, Sqlite.sql _logger = logger; _dbContextProvider = dbContextProvider; + isDevelopment = hostEnvironment.IsDevelopment(); } public void UpdateDatabase() @@ -141,6 +144,8 @@ private void SaveVersionToFile(Easy.Version version) { try { + if (isDevelopment) return; + var plugPath = PluginBase.GetPath(); var versionFile = Path.Combine(plugPath, "appsettings.json"); _dbVersionOption.DBVersion = version.ToString(); @@ -289,11 +294,12 @@ private IEnumerable ConvertToScripts(byte[] package) { using (ZipArchive archive = new ZipArchive(memoryStream, ZipArchiveMode.Read)) { + string rankScriptFileName = $"{Version.Rank}.{_scriptFileName}"; foreach (ZipArchiveEntry entry in archive.Entries) { //There three scripts in the package, MsSql.sql, MySql.sql, Sqlite.sql //Pick up matched script to execute. - if (!entry.Name.Equals(_scriptFileName, StringComparison.OrdinalIgnoreCase)) continue; + if (!entry.Name.Equals(_scriptFileName, StringComparison.OrdinalIgnoreCase) && !entry.Name.Equals(rankScriptFileName, StringComparison.OrdinalIgnoreCase)) continue; using (StreamReader reader = new StreamReader(entry.Open())) { @@ -302,7 +308,7 @@ private IEnumerable ConvertToScripts(byte[] package) } } } - throw new Exception($"{_scriptFileName} is not in the update package."); + return Enumerable.Empty(); } private byte[] GetUpdateScriptsFromLocalCache(string version) { @@ -387,6 +393,7 @@ private bool ExecuteScripts(DbContext dbContext, IEnumerable sqlScripts) foreach (var sql in sqlScripts) { if (sql.IsNullOrWhiteSpace()) continue; + using (var command = dbConnection.CreateCommand()) { command.Transaction = dbTransaction; @@ -396,9 +403,7 @@ private bool ExecuteScripts(DbContext dbContext, IEnumerable sqlScripts) } } - dbTransaction.Commit(); - return true; } catch (Exception ex) @@ -413,7 +418,6 @@ private bool ExecuteScripts(DbContext dbContext, IEnumerable sqlScripts) dbConnection.Close(); } } - } return false; } diff --git a/src/ZKEACMS.Updater/appsettings.json b/src/ZKEACMS.Updater/appsettings.json index 7165174d7..763abcabe 100644 --- a/src/ZKEACMS.Updater/appsettings.json +++ b/src/ZKEACMS.Updater/appsettings.json @@ -1,6 +1,5 @@ { "DBVersionOption": { - "DBVersion": "4.0.0.0", "BaseVersion": "3.3.5", "Source": [ "https://gitee.com/seriawei/ZKEACMS.Core/raw/develop/Database", diff --git a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ArticleSelector.cshtml b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ArticleSelector.cshtml index 90f53c6a9..b706f4b35 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ArticleSelector.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ArticleSelector.cshtml @@ -9,12 +9,7 @@ diff --git a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ProductSelector.cshtml b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ProductSelector.cshtml index 29530cfa9..7a234d370 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ProductSelector.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ProductSelector.cshtml @@ -9,12 +9,7 @@ diff --git a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/String.cshtml b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/String.cshtml index bc83f9709..909b3156f 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/String.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/String.cshtml @@ -37,12 +37,7 @@ } - +
diff --git a/src/ZKEACMS.WebHost/Views/Shared/Partial.PageFooter.cshtml b/src/ZKEACMS.WebHost/Views/Shared/Partial.PageFooter.cshtml new file mode 100644 index 000000000..e67de8764 --- /dev/null +++ b/src/ZKEACMS.WebHost/Views/Shared/Partial.PageFooter.cshtml @@ -0,0 +1,10 @@ +@StyleAtFoot() +@ScriptAtFoot() +@foreach (var item in this.WorkContext().CurrentPage.FooterScripts) +{ + @item.Render() +} +@foreach (var item in this.WorkContext().CurrentPage.BodyFooter) +{ + @item +} \ No newline at end of file diff --git a/src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml b/src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml new file mode 100644 index 000000000..2de2fa297 --- /dev/null +++ b/src/ZKEACMS.WebHost/Views/Shared/Partial.PageHeader.cshtml @@ -0,0 +1,59 @@ +@inject IApplicationSettingService applicationSettingService +@{ + var currentPage = this.WorkContext().CurrentPage; + foreach (var item in currentPage.StyleNames) + { + Style.Reqiured(item).AtHead(); + } + foreach (var item in currentPage.ScriptNames) + { + Script.Reqiured(item).AtFoot(); + } + var favicon = applicationSettingService.Get(SettingKeys.Favicon, "~/favicon.ico"); +} +@currentPage.Title +@if (currentPage.MetaKeyWords.IsNotNullAndWhiteSpace()) +{ + +} +@if (currentPage.MetaDescription.IsNotNullAndWhiteSpace()) +{ + +} + + + + + +@if (this.WorkContext().EnableResponsiveDesign) +{ + +} +@if (this.WorkContext().OuterChainPicture) +{ + +} +@foreach (var item in currentPage.Meta) +{ + @item.Render() +} + + +@StyleAtHead() +@ScriptAtHead() +@foreach (var item in currentPage.Header) +{ + @item +} +@foreach (var item in currentPage.StyleSheets) +{ + @item.Render() +} +@foreach (var item in currentPage.Style) +{ + @item.Render() +} +@foreach (var item in currentPage.HeaderScripts) +{ + @item.Render() +} \ No newline at end of file diff --git a/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml index a915b301b..939b026dd 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_AdminLayout.cshtml @@ -8,25 +8,16 @@ Style.Reqiured("admin").AtHead(); Script.Reqiured("admin").AtHead(); List menus = adminMenuProvider.GetAdminMenus().ToList(); + if (this.WorkContext().CurrentPage.Title.IsNullOrEmpty()) + { + this.WorkContext().CurrentPage.Title = ZKEACMS.Version.CurrentVersion + " " + ZKEACMS.Version.Rank; + } } @inject IOptions cultureOption - - - @(ZKEACMS.Version.CurrentVersion + " " + ZKEACMS.Version.Rank) - - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - @StyleAtHead() - @ScriptAtHead() + @await Html.PartialAsync("Partial.PageHeader")
@@ -143,7 +134,6 @@
-
@if (ViewContext.ModelState.GetFieldValidationState("Unknown") == ModelValidationState.Invalid) @@ -157,7 +147,6 @@
- @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter") diff --git a/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml index 55c6e0bae..5ff8efae4 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_CustomerCenterLayout.cshtml @@ -6,26 +6,17 @@ Style.Reqiured("Customer").AtHead(); Style.Reqiured("Easy").AtHead(); IEnumerable menu = userCenterLinkService.GetLinks(); + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } @inject IUserCenterLinkService userCenterLinkService @inject IOptions cultureOption - - - @ViewBag.Title - - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - @StyleAtHead() - @ScriptAtHead() + @await Html.PartialAsync("Partial.PageHeader")
@@ -72,9 +63,7 @@ @RenderBody()
-
- @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter") \ No newline at end of file diff --git a/src/ZKEACMS.WebHost/Views/Shared/_DesignLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_DesignLayout.cshtml index d68b2c653..9587f57b2 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_DesignLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_DesignLayout.cshtml @@ -7,28 +7,14 @@ Script.Reqiured("admin").AtFoot(); Script.Reqiured("code-editor").AtFoot(); Model.ContainerClass = Model.ContainerClass ?? "container"; + this.WorkContext().CurrentPage.Title = $"[{L("Design")}]{Model.LayoutName}"; } @model LayoutEntity @inject IOptions cultureOption - - - - - - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - [@L("Design")]@Model.LayoutName - @StyleAtHead() - @ScriptAtHead() + @await Html.PartialAsync("Partial.PageHeader")
@@ -121,11 +107,6 @@
@await Html.PartialAsync("Layout/Templates") - @if (!Model.Style.IsNullOrEmpty()) - { - - - } - @if (!Model.Script.IsNullOrEmpty()) - { - - } - @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter") diff --git a/src/ZKEACMS.WebHost/Views/Shared/_DesignPageLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_DesignPageLayout.cshtml index 95528315c..356060a34 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_DesignPageLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_DesignPageLayout.cshtml @@ -8,52 +8,13 @@ { return; } - CMSApplicationContext appContext = ApplicationContext as CMSApplicationContext; + this.WorkContext().CurrentPage.Title = $"[{L("Design")}]{Model.Page.Title}"; } @inject IOptions cultureOption - - - - - - @if (appContext.OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - [@L("Design")]@Model.Page.Title - - @StyleAtHead() - @ScriptAtHead() - @foreach (var item in appContext.HeaderPart) - { - @item - } - @if (!Model.Style.IsNullOrEmpty()) - { - - } - @foreach (var style in Model.Page.Styles) - { - - } - @if (Model.CurrentTheme != null) - { - if (ApplicationContext.HostingEnvironment.IsDevelopment()) - { - - } - else - { - - } - } + @await Html.PartialAsync("Partial.PageHeader")
- @StyleAtFoot() - @ScriptAtFoot() - @if (!Model.Script.IsNullOrEmpty()) - { - - } - @foreach (var script in Model.Page.Scripts) - { - - } - @foreach (var item in appContext.FooterPart) - { - @item - } + @await Html.PartialAsync("Partial.PageFooter") diff --git a/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml index ce7092f7b..22b0fa8e5 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_EmptyLayout.cshtml @@ -1,25 +1,20 @@ @using Microsoft.AspNetCore.Hosting @using Microsoft.Extensions.Hosting +@{ + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } +} - @ViewBag.Title - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - @StyleAtHead() - @ScriptAtHead() + @await Html.PartialAsync("Partial.PageHeader")
@RenderBody()
- @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter") diff --git a/src/ZKEACMS.WebHost/Views/Shared/_Layout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_Layout.cshtml index a0db57343..3a8395bfe 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_Layout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_Layout.cshtml @@ -9,63 +9,12 @@ return; } Style.Reqiured("Easy").AtFoot(); - CMSApplicationContext appContext = ApplicationContext as CMSApplicationContext; - foreach (var item in appContext.Styles) - { - Style.Reqiured(item).AtHead(); - } - foreach (var item in appContext.Scripts) - { - Script.Reqiured(item).AtFoot(); - } } @inject IOptions cultureOption - - - @Model.Page.Title - - - - - - - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - - @StyleAtHead() - @ScriptAtHead() - @foreach (var item in appContext.HeaderPart) - { - @item - } - @if (!Model.Style.IsNullOrEmpty()) - { - - } - @foreach (var style in Model.Page.Styles) - { - - } - @if (Model.CurrentTheme != null) - { - if (ApplicationContext.HostingEnvironment.IsDevelopment()) - { - - } - else - { - - } - } + @await Html.PartialAsync("Partial.PageHeader") @if (Authorizer.Authorize(PermissionKeys.ManagePage) && (ApplicationContext as CMSApplicationContext).PageMode != ZKEACMS.Filter.PageViewMode.ViewOnly) @@ -144,25 +93,9 @@ } } -
@RenderBody()
- - @StyleAtFoot() - @ScriptAtFoot() - @if (!Model.Script.IsNullOrEmpty()) - { - - } - @foreach (var script in Model.Page.Scripts) - { - - } - @foreach (var item in appContext.FooterPart) - { - @item - } + @await Html.PartialAsync("Partial.PageFooter") - \ No newline at end of file diff --git a/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml index f95529869..84e045f00 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_LayoutGeneric.cshtml @@ -3,40 +3,19 @@ @using Microsoft.Extensions.Options @using Easy.Options @{ - ThemeEntity theme = themeService.GetCurrentTheme(); - if (theme == null) + if (ViewBag.Title != null) { - Style.Reqiured("bootStrap").AtHead(); + this.WorkContext().CurrentPage.Title = ViewBag.Title; } } -@inject IThemeService themeService @inject IOptions cultureOption - - - @ViewBag.Title - - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - @StyleAtHead() - @ScriptAtHead() - @if (theme != null) - { - string themeFile = ApplicationContext.HostingEnvironment.IsDevelopment() ? theme.UrlDebugger : theme.Url; - - } + @await Html.PartialAsync("Partial.PageHeader") @RenderBody() - @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter") \ No newline at end of file diff --git a/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml index fac867bd1..a9081ca58 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_LayoutNormal.cshtml @@ -3,45 +3,21 @@ @using Microsoft.Extensions.Options @using Easy.Options @{ - ThemeEntity theme = themeService.GetCurrentTheme(); - if (theme == null) + if (ViewBag.Title != null) { - Style.Reqiured("bootStrap").AtHead(); + this.WorkContext().CurrentPage.Title = ViewBag.Title; } } -@inject IThemeService themeService @inject IOptions cultureOption - - - @ViewBag.Title - - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - @StyleAtHead() - @ScriptAtHead() - @if (theme != null && ApplicationContext.HostingEnvironment.IsDevelopment()) - { - - } - else - { - - } + @await Html.PartialAsync("Partial.PageHeader")
@RenderBody()
- @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter") \ No newline at end of file diff --git a/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml index 98d4a9b34..a07deb412 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_PopUpClientLayout.cshtml @@ -1,41 +1,20 @@ @using Microsoft.AspNetCore.Hosting @using Microsoft.Extensions.Hosting @{ - var theme = themeService.GetCurrentTheme(); + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } -@inject IThemeService themeService - - @ViewBag.Title - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - @if (theme != null) - { - if (ApplicationContext.HostingEnvironment.IsDevelopment()) - { - - } - else - { - - } - } - @StyleAtHead() - @ScriptAtHead() + @await Html.PartialAsync("Partial.PageHeader")
@RenderBody()
- @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter") diff --git a/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml b/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml index 62fbec0b2..1c6b50e59 100644 --- a/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml +++ b/src/ZKEACMS.WebHost/Views/Shared/_PopUpLayout.cshtml @@ -3,23 +3,16 @@ Script.Reqiured("admin").AtHead(); Style.Reqiured("bootStrap").AtHead(); Style.Reqiured("admin").AtHead(); + if (ViewBag.Title != null) + { + this.WorkContext().CurrentPage.Title = ViewBag.Title; + } } - - @ViewBag.Title - @if (this.WorkContext().OuterChainPicture) - { - - } - @if (this.WorkContext().EnableResponsiveDesign) - { - - } - @StyleAtHead() - @ScriptAtHead() + @await Html.PartialAsync("Partial.PageHeader")
@@ -32,8 +25,7 @@
} - @StyleAtFoot() - @ScriptAtFoot() + @await Html.PartialAsync("Partial.PageFooter")