Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriaWei committed Sep 11, 2024
2 parents 0a401b8 + b56bb72 commit f60fe16
Show file tree
Hide file tree
Showing 38 changed files with 396 additions and 123 deletions.
167 changes: 163 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,167 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store
.git
.svn
.vs
.vscode
bin
obj
*.mdf
*.ldf
src/ZKEACMS.WebHost/wwwroot/UpLoad
src/ZKEACMS.WebHost/wwwroot/Logs
Database/App_Data
node_modules
Release
*.userprefs
/*.userprefs

# ZKEACMS App Data
App_Data/
*.db
/src/ZKEACMS.WebHost/Temp
2 changes: 1 addition & 1 deletion src/EasyFrameWork/EasyFrameWork.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
<PackageReference Include="System.Reflection.Extensions" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="YamlDotNet" Version="16.0.0" />
<PackageReference Include="YamlDotNet" Version="16.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Easy.StartTask
{
public interface IStartTask
public interface IAppStartTask
{
void Excute();
void OnStartup();
}
}
7 changes: 7 additions & 0 deletions src/EasyFrameWork/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ public static Version Parse(string version)
return false;
}

public static implicit operator Version(string version)
{
if (string.IsNullOrEmpty(version)) return null;

return Parse(version);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
Expand Down
4 changes: 2 additions & 2 deletions src/ZKEACMS.GlobalScripts/Models/StatisticsScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ protected override void ViewConfigure()
ViewConfig(m => m.Location).AsDropDownList().DataSource(() =>
{
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add(ScriptLocation.Footer.ToString("D"), "Head");
data.Add(ScriptLocation.Header.ToString("D"), "Foot");
data.Add(ScriptLocation.Header.ToString("D"), "Head");
data.Add(ScriptLocation.Footer.ToString("D"), "Foot");
return data;
});
ViewConfig(m => m.Script).AsTextArea();
Expand Down
7 changes: 4 additions & 3 deletions src/ZKEACMS.Product/Controllers/ProductController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ public JsonResult Sort([FromBody] IEnumerable<ProductEntity> products)
}
public JsonResult GetProducts(int ProductCategoryID)
{
var ids = _productCategoryService.Get(m => m.ParentID == ProductCategoryID || m.ID == ProductCategoryID).Select(m => m.ID);
return Json(Service.Get(m => ids.Contains(m.ProductCategoryID))
var ids = _productCategoryService.Get(m => m.ParentID == ProductCategoryID || m.ID == ProductCategoryID).Select(m => m.ID).ToArray();
return Json(Service.Get(m => ids.Contains(m.ProductCategoryID.Value))
.OrderBy(m => m.OrderIndex)
.ThenByDescending(m => m.ID).Select(m => new { m.ID, m.Title }));
.ThenByDescending(m => m.ID)
.Select(m => new { m.ID, m.Title }));
}
[HttpPost]
public IActionResult ProduceTags(int productId, int ProductCategoryId)
Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Product/Service/ProductListWidgetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public override object Display(WidgetDisplayContext widgetDisplayContext)
else
{
var ids = _productCategoryService.Get(m => m.ID == currentWidget.ProductCategoryID || m.ParentID == currentWidget.ProductCategoryID).Select(m => m.ID).ToList();
filter = m => m.Status == (int)RecordStatus.Active && m.IsPublish && ids.Contains(m.ProductCategoryID);
filter = m => m.Status == (int)RecordStatus.Active && m.IsPublish && ids.Contains(m.ProductCategoryID.Value);
}
if (currentWidget.IsPageable)
{
Expand Down
6 changes: 3 additions & 3 deletions src/ZKEACMS.Product/Service/ProductUrlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public IEnumerable<ProductUrl> GetAllPublicUrls()
if (item.DetailPageUrl.IsNotNullAndWhiteSpace() && !excuted.Contains(typeDetail))
{
var ids = _productCategoryService.Get(m => m.ID == item.ProductCategoryID || m.ParentID == item.ProductCategoryID).Select(m => m.ID).ToList();
var products = _productService.Get(m => m.IsPublish && ids.Contains(m.ProductCategoryID));
var products = _productService.Get(m => m.IsPublish && ids.Contains(m.ProductCategoryID.Value));
foreach (var product in products)
{
string post = product.Url.IsNullOrWhiteSpace() ? $"post-{product.ID}" : product.Url;
Expand Down Expand Up @@ -66,8 +66,8 @@ public string[] GetPublicUrl(int ID)

public string[] GetPublicUrl(ProductEntity product)
{
int categoryId = product.ProductCategoryID;
if (categoryId == 0) return null;
var categoryId = product.ProductCategoryID;
if ((categoryId ?? 0) == 0) return null;

ProductCategory productCategory = _productCategoryService.Get(categoryId);

Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Swagger/ZKEACMS.Swagger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions src/ZKEACMS.Updater/ApplicationStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

namespace ZKEACMS.Updater
{
public class ApplicationStartup : IStartTask
public class ApplicationStartup : IAppStartTask
{
private readonly IDbUpdaterService _dbUpdaterService;
public ApplicationStartup(IDbUpdaterService dbUpdaterService)
{
_dbUpdaterService = dbUpdaterService;
}
public void Excute()
public void OnStartup()
{
_dbUpdaterService.UpdateDatabase();
}
Expand Down
1 change: 1 addition & 0 deletions src/ZKEACMS.Updater/Models/DBVersionOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace ZKEACMS.Updater.Models
{
public class DBVersionOption
{
public string DBVersion { get; set; }
public string BaseVersion { get; set; }
public string[] Source { get; set; }
}
Expand Down
31 changes: 27 additions & 4 deletions src/ZKEACMS.Updater/Service/DbUpdaterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Easy.Extend;
using Easy.Mvc.Plugin;
using Easy.Net;
using Easy.Serializer;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
Expand All @@ -26,7 +27,7 @@ namespace ZKEACMS.Updater.Service
{
public class DbUpdaterService : IDbUpdaterService
{
private readonly IOptions<DBVersionOption> _dbVersionOption;
private readonly DBVersionOption _dbVersionOption;
private readonly IWebClient _webClient;
private readonly ILogger<DbUpdaterService> _logger;
private readonly IDBContextProvider _dbContextProvider;
Expand All @@ -39,7 +40,7 @@ public DbUpdaterService(DatabaseOption databaseOption,
IDBContextProvider dbContextProvider,
ILogger<DbUpdaterService> logger)
{
_dbVersionOption = dbVersionOption;
_dbVersionOption = dbVersionOption.Value;
_webClient = webClient;
_scriptFileName = $"{databaseOption.DbType}.sql";//MsSql.sql, MySql.sql, Sqlite.sql
_logger = logger;
Expand All @@ -56,6 +57,8 @@ public void UpdateDatabase()
private void UpgradeDbToLatest()
{
var appVersion = Easy.Version.Parse(Version.VersionInfo);
if (GetVersionFromFile() == appVersion) return;

bool allSuccess = true;
foreach (var dbContext in _dbContextProvider.GetAvailableDbContexts())
{
Expand All @@ -67,6 +70,7 @@ private void UpgradeDbToLatest()
}
if (allSuccess)
{
SaveVersionToFile(appVersion);
DeleteAllCachedScripts();
}
}
Expand Down Expand Up @@ -124,11 +128,30 @@ private Easy.Version GetDbVersion(DbContext dbContext)
}
if (version == null)
{
version = Easy.Version.Parse(_dbVersionOption.Value.BaseVersion);
version = Easy.Version.Parse(_dbVersionOption.BaseVersion);
}
return version;
}
private Easy.Version GetVersionFromFile()
{
return _dbVersionOption.DBVersion;
}

private void SaveVersionToFile(Easy.Version version)
{
try
{
var plugPath = PluginBase.GetPath<UpdaterPlug>();
var versionFile = Path.Combine(plugPath, "appsettings.json");
_dbVersionOption.DBVersion = version.ToString();
string versionJson = JsonConverter.Serialize(new { DBVersionOption = _dbVersionOption });
File.WriteAllText(versionFile, versionJson);
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
}
}
private void ExcuteLocalScripts()
{
List<string> localScripts = ReadLocalScripts();
Expand Down Expand Up @@ -223,7 +246,7 @@ private IEnumerable<string> ReadRemoteScripts(Easy.Version versionFrom, Easy.Ver
private ReleaseVersion GetReleaseVersions()
{
ReleaseVersion releaseVersion = null;
foreach (var item in _dbVersionOption.Value.Source)
foreach (var item in _dbVersionOption.Source)
{
availableSource = item;
string source = $"{availableSource}/index.json";
Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Updater/UpdaterPlug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override IEnumerable<WidgetTemplateEntity> WidgetServiceTypes()
public override void ConfigureServices(IServiceCollection serviceCollection)
{
serviceCollection.AddTransient<IOnModelCreating, EntityFrameWorkModelCreating>();
serviceCollection.AddTransient<IStartTask, ApplicationStartup>();
serviceCollection.AddTransient<IAppStartTask, ApplicationStartup>();
serviceCollection.AddTransient<IDbUpdaterService, DbUpdaterService>();
serviceCollection.AddTransient<IDashboardPartDriveService, UpdateDbFailedDashboardService>();
serviceCollection.RegistEvent<UpdateDbOnDbCreatedEventHandler>(Events.OnDatabaseCreated);
Expand Down
Loading

0 comments on commit f60fe16

Please sign in to comment.