-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
support
committed
Sep 30, 2023
1 parent
30b78c2
commit f902675
Showing
3 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/Business/Grand.Business.System/Services/Migrations/2.2/MigrationUpdateAdminSiteMap.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Grand.Business.Core.Interfaces.Common.Logging; | ||
using Grand.Business.Core.Utilities.Common.Security; | ||
using Grand.Domain.Admin; | ||
using Grand.Domain.Data; | ||
using Grand.Infrastructure.Migrations; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Grand.Business.System.Services.Migrations._2._2 | ||
{ | ||
public class MigrationUpdateAdminSiteMap : IMigration | ||
{ | ||
|
||
public int Priority => 0; | ||
public DbVersion Version => new(2, 2); | ||
public Guid Identity => new("1025D405-FFF3-45E1-A240-2E5F2A92535F"); | ||
public string Name => "Update standard admin site map - add admin menu"; | ||
|
||
/// <summary> | ||
/// Upgrade process | ||
/// </summary> | ||
/// <param name="database"></param> | ||
/// <param name="serviceProvider"></param> | ||
/// <returns></returns> | ||
public bool UpgradeProcess(IDatabaseContext database, IServiceProvider serviceProvider) | ||
{ | ||
var repository = serviceProvider.GetRequiredService<IRepository<Domain.Admin.AdminSiteMap>>(); | ||
var logService = serviceProvider.GetRequiredService<ILogger>(); | ||
|
||
try | ||
{ | ||
var sitemapSystem = repository.Table.FirstOrDefault(x => x.SystemName == "Configuration"); | ||
if (sitemapSystem != null) | ||
{ | ||
sitemapSystem.ChildNodes.Add(new AdminSiteMap() { | ||
SystemName = "Admin menu", | ||
ResourceName = "Admin.Configuration.Menu", | ||
PermissionNames = new List<string> { PermissionSystemName.Maintenance }, | ||
ControllerName = "Menu", | ||
ActionName = "Index", | ||
DisplayOrder = 7, | ||
IconClass = "fa fa-dot-circle-o" | ||
}); | ||
repository.Update(sitemapSystem); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
logService.InsertLog(Domain.Logging.LogLevel.Error, "UpgradeProcess - UpdateAdminSiteMap", ex.Message).GetAwaiter().GetResult(); | ||
} | ||
return true; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Business/Grand.Business.System/Services/Migrations/2.2/MigrationUpdateResourceString.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Grand.Domain.Data; | ||
using Grand.Infrastructure.Migrations; | ||
|
||
namespace Grand.Business.System.Services.Migrations._2._2 | ||
{ | ||
public class MigrationUpdateResourceString : IMigration | ||
{ | ||
public int Priority => 0; | ||
public DbVersion Version => new(2, 2); | ||
public Guid Identity => new("40AE285E-247E-4ABA-A892-479F22297580"); | ||
public string Name => "Update resource string for english language 2.2"; | ||
|
||
/// <summary> | ||
/// Upgrade process | ||
/// </summary> | ||
/// <param name="database"></param> | ||
/// <param name="serviceProvider"></param> | ||
/// <returns></returns> | ||
public bool UpgradeProcess(IDatabaseContext database, IServiceProvider serviceProvider) | ||
{ | ||
return serviceProvider.ImportLanguageResourcesFromXml("App_Data/Resources/Upgrade/en_220.xml"); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Business/Grand.Business.System/Services/Migrations/2.2/MigrationUpgradeDbVersion_22.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Grand.Domain.Common; | ||
using Grand.Domain.Data; | ||
using Grand.Infrastructure; | ||
using Grand.Infrastructure.Migrations; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Grand.Business.System.Services.Migrations._2._2 | ||
{ | ||
public class MigrationUpgradeDbVersion_22 : IMigration | ||
{ | ||
|
||
public int Priority => 0; | ||
|
||
public DbVersion Version => new(2, 2); | ||
|
||
public Guid Identity => new("9B9FD138-7E67-44AA-913B-273F3D5B5DE9"); | ||
|
||
public string Name => "Upgrade version of the database to 2.2"; | ||
|
||
/// <summary> | ||
/// Upgrade process | ||
/// </summary> | ||
/// <param name="database"></param> | ||
/// <param name="serviceProvider"></param> | ||
/// <returns></returns> | ||
public bool UpgradeProcess(IDatabaseContext database, IServiceProvider serviceProvider) | ||
{ | ||
var repository = serviceProvider.GetRequiredService<IRepository<GrandNodeVersion>>(); | ||
|
||
var dbversion = repository.Table.ToList().FirstOrDefault(); | ||
dbversion.DataBaseVersion = $"{GrandVersion.SupportedDBVersion}"; | ||
repository.Update(dbversion); | ||
|
||
return true; | ||
} | ||
} | ||
} |