diff --git a/GR.sln b/GR.sln index 4a8aeecb..cc356455 100644 --- a/GR.sln +++ b/GR.sln @@ -217,7 +217,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Calendar.NetCore.Api.Gra EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.ECommerce.Payments", "GR.ECommerce.Payments", "{A7B5EA4E-8A86-4F5D-820C-443A6C54BF36}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.ECommerce.Payments.Providers", "GR.ECommerce.Payments.Providers", "{E7023FD7-77DB-4A24-9ED4-A6054977BC22}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.Providers", "GR.Providers", "{E7023FD7-77DB-4A24-9ED4-A6054977BC22}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.ECommerce.Paypal", "GR.ECommerce.Paypal", "{9BEA7DC3-0498-4E31-805C-40E09C36F88F}" EndProject @@ -279,17 +279,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.ECommerce.Infrastructure EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.ECommerce.Modules", "GR.ECommerce.Modules", "{688A8EA1-8902-4AED-A503-AF1CC129F993}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.MobilPay.Abstractions", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.MobilPay\GR.MobilPay.Abstractions\GR.MobilPay.Abstractions.csproj", "{55FC695F-3F4D-4CF9-9EE0-42E51A2AEC44}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.MobilPay.Abstractions", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.MobilPay\GR.MobilPay.Abstractions\GR.MobilPay.Abstractions.csproj", "{55FC695F-3F4D-4CF9-9EE0-42E51A2AEC44}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.MobilPay", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.MobilPay\GR.MobilPay\GR.MobilPay.csproj", "{DE7B26A1-55DA-4615-A7B3-52AE931AA0E3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.MobilPay", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.MobilPay\GR.MobilPay\GR.MobilPay.csproj", "{DE7B26A1-55DA-4615-A7B3-52AE931AA0E3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.MobilPay.Razor", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.MobilPay\GR.MobilPay.Razor\GR.MobilPay.Razor.csproj", "{835B2DF3-C7CB-4120-ACC4-1793C9AF8EA0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.MobilPay.Razor", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.MobilPay\GR.MobilPay.Razor\GR.MobilPay.Razor.csproj", "{835B2DF3-C7CB-4120-ACC4-1793C9AF8EA0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Paypal.Abstractions", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.Paypal\GR.Paypal.Abstractions\GR.Paypal.Abstractions.csproj", "{DE2990AB-133B-4E60-8706-FB12C053DFCE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Paypal.Abstractions", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.Paypal\GR.Paypal.Abstractions\GR.Paypal.Abstractions.csproj", "{DE2990AB-133B-4E60-8706-FB12C053DFCE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Paypal", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.Paypal\GR.Paypal\GR.Paypal.csproj", "{57E23449-A099-4B70-8585-322DB2CECCEE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Paypal", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.Paypal\GR.Paypal\GR.Paypal.csproj", "{57E23449-A099-4B70-8585-322DB2CECCEE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Paypal.Razor", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.Paypal\GR.Paypal.Razor\GR.Paypal.Razor.csproj", "{42E837B7-66F8-45E3-9F8F-FFE019CB83C6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Paypal.Razor", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.Paypal\GR.Paypal.Razor\GR.Paypal.Razor.csproj", "{42E837B7-66F8-45E3-9F8F-FFE019CB83C6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.ECommerce.Payments.Abstractions", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Abstractions\GR.ECommerce.Payments.Abstractions.csproj", "{475F1FC4-62BD-416B-A5E1-56E02F09595E}" EndProject @@ -307,15 +307,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Subscriptions.Razor", "s EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.ECommerce.Braintree", "GR.ECommerce.Braintree", "{AB58D5FE-AFC9-4BD6-9371-EFE689A05AFF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Braintree.Abstractions", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.Braintree\GR.Braintree.Abstractions\GR.Braintree.Abstractions.csproj", "{120E621A-C97F-4104-942A-2359F973BF2E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Braintree.Abstractions", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.Braintree\GR.Braintree.Abstractions\GR.Braintree.Abstractions.csproj", "{120E621A-C97F-4104-942A-2359F973BF2E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Braintree", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.Braintree\GR.Braintree\GR.Braintree.csproj", "{F7DA2F5E-95AC-4909-976C-A0CD0FA74A51}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Braintree", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.Braintree\GR.Braintree\GR.Braintree.csproj", "{F7DA2F5E-95AC-4909-976C-A0CD0FA74A51}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Braintree.Razor", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.ECommerce.Payments.Providers\GR.ECommerce.Braintree\GR.Braintree.Razor\GR.Braintree.Razor.csproj", "{663F27FE-FFAC-4F3D-B390-B4617A75A0F9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Braintree.Razor", "src\GR.Extensions\GR.Ecommerce.Extension\GR.ECommerce.Payments\GR.Providers\GR.ECommerce.Braintree\GR.Braintree.Razor\GR.Braintree.Razor.csproj", "{663F27FE-FFAC-4F3D-B390-B4617A75A0F9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.Entities.Providers", "GR.Entities.Providers", "{BCF212C6-8AFE-490D-A10D-57869EFDC75C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GR.Notifications.Hub", "src\GR.Extensions\GR.Notifications.Extension\GR.Notifications.Hub\GR.Notifications.Hub.csproj", "{D889432D-A38A-4C22-87B0-8522192DCA49}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GR.Notifications.Hub", "src\GR.Extensions\GR.Notifications.Extension\GR.Notifications.Hub\GR.Notifications.Hub.csproj", "{D889432D-A38A-4C22-87B0-8522192DCA49}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.Permissions", "GR.Permissions", "{A9CDA9C0-A7EE-4B79-8DB0-CAA036A01B7C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.Profile", "GR.Profile", "{1896A6F8-56E1-4C56-ACBB-C9350014EB85}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GR.Ldap", "GR.Ldap", "{9E32496B-C795-45E7-B22F-FB382D8208BD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1067,8 +1073,8 @@ Global {AC174814-1F8C-4960-9B4A-067EED8B5546} = {6FE2EAEF-E294-4D4D-BE94-A03D3ABC1653} {9F68CC74-9147-497E-B15F-70A2D5A7F2DA} = {BCF212C6-8AFE-490D-A10D-57869EFDC75C} {B7AB42C6-3D13-4A40-B1DE-850917E795C9} = {BCF212C6-8AFE-490D-A10D-57869EFDC75C} - {6D6984F4-EB54-4107-AED8-DFA3F0E7B890} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} - {400C2124-8B49-49E0-B15F-C940A30DF2FE} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} + {6D6984F4-EB54-4107-AED8-DFA3F0E7B890} = {1896A6F8-56E1-4C56-ACBB-C9350014EB85} + {400C2124-8B49-49E0-B15F-C940A30DF2FE} = {1896A6F8-56E1-4C56-ACBB-C9350014EB85} {228BABBE-1F74-438F-B756-FBD8E28F2582} = {F1554EFC-257E-4B7C-9FD2-49CF1E2AD3B6} {9A6EBD6D-8BBD-4D5E-9922-35F129D3537B} = {F1554EFC-257E-4B7C-9FD2-49CF1E2AD3B6} {5EE32D18-3642-4FC8-9439-DA12B76D3AC5} = {4B6C8C28-B2EC-4EDD-B6D8-F90B125CB109} @@ -1086,8 +1092,8 @@ Global {4ADAD96E-E01B-47C5-9589-7C6DEF589D66} = {7AE24405-9DE2-4131-904B-F3ED0F6B104B} {2D22B7C1-DC4A-41AF-9132-D60276D5B94F} = {4ADAD96E-E01B-47C5-9589-7C6DEF589D66} {817AD117-DE1E-4DB5-8F94-4D9653D51CC8} = {4ADAD96E-E01B-47C5-9589-7C6DEF589D66} - {E71932BB-6CE9-4668-AE67-C87AE3738645} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} - {5AD326F8-C456-4D22-B846-14DB8D5E8FAF} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} + {E71932BB-6CE9-4668-AE67-C87AE3738645} = {A9CDA9C0-A7EE-4B79-8DB0-CAA036A01B7C} + {5AD326F8-C456-4D22-B846-14DB8D5E8FAF} = {A9CDA9C0-A7EE-4B79-8DB0-CAA036A01B7C} {827C1E40-3FCE-44A8-A0E9-DA9B6466C4B1} = {3D0F6210-272F-410D-AEAA-A5722E8C6D95} {DD8B27D9-E5F4-48BC-BADD-97C85DBCAB89} = {7AE24405-9DE2-4131-904B-F3ED0F6B104B} {F154FDB8-6FDD-4D69-AED5-80990E464B53} = {DD8B27D9-E5F4-48BC-BADD-97C85DBCAB89} @@ -1140,8 +1146,8 @@ Global {A0C4C692-A987-47C7-9437-36457BA49EFB} = {B595C1E9-D7E5-4A9D-8995-55720F89A815} {43E024A7-9842-4F33-BE70-600C764F5593} = {A45A887D-97C6-4B42-B1F4-F319CBD39038} {C2317862-8F23-4183-8289-6CC6761467D3} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} - {C0597030-10CE-488C-BEF6-9ECBAD6BEE06} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} - {77056BF2-D0DC-4BEA-BFC6-205728235A47} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} + {C0597030-10CE-488C-BEF6-9ECBAD6BEE06} = {9E32496B-C795-45E7-B22F-FB382D8208BD} + {77056BF2-D0DC-4BEA-BFC6-205728235A47} = {9E32496B-C795-45E7-B22F-FB382D8208BD} {4AD4A550-3E6C-4453-A025-D7FEA1E992CE} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} {A19141B5-44D4-4789-9157-C34718521F17} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} {67772CD9-5D26-40A4-8E04-B2EF02AB9B25} = {7AE24405-9DE2-4131-904B-F3ED0F6B104B} @@ -1173,6 +1179,9 @@ Global {663F27FE-FFAC-4F3D-B390-B4617A75A0F9} = {AB58D5FE-AFC9-4BD6-9371-EFE689A05AFF} {BCF212C6-8AFE-490D-A10D-57869EFDC75C} = {4B6C8C28-B2EC-4EDD-B6D8-F90B125CB109} {D889432D-A38A-4C22-87B0-8522192DCA49} = {3D0F6210-272F-410D-AEAA-A5722E8C6D95} + {A9CDA9C0-A7EE-4B79-8DB0-CAA036A01B7C} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} + {1896A6F8-56E1-4C56-ACBB-C9350014EB85} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} + {9E32496B-C795-45E7-B22F-FB382D8208BD} = {E75A6593-EA57-45A2-AC38-EBBBD7E7465E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6A849486-D7B5-49D1-94F6-9D173ACBA581} diff --git a/GR.sln.DotSettings b/GR.sln.DotSettings index bf28d37b..0c0994ed 100644 --- a/GR.sln.DotSettings +++ b/GR.sln.DotSettings @@ -24,6 +24,7 @@ True True True + True True True True diff --git a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Extensions/ServiceCollectionsExtensions.cs b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Extensions/ServiceCollectionsExtensions.cs index 3b8c3fb8..ba182b57 100644 --- a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Extensions/ServiceCollectionsExtensions.cs +++ b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Extensions/ServiceCollectionsExtensions.cs @@ -3,8 +3,10 @@ using System.Linq; using Castle.MicroKernel.Registration; using Castle.Windsor.MsDependencyInjection; -using GR.Cache.Abstractions.Exceptions; using GR.Cache.Abstractions.Extensions; +using GR.Cache.Exceptions; +using GR.Cache.Extensions; +using GR.Cache.Helpers; using GR.Cache.Services; using GR.Core; using GR.Core.Extensions; @@ -12,10 +14,9 @@ using GR.Core.Helpers.ModelBinders.ModelBinderProviders; using GR.Core.Razor.Extensions; using GR.Localization.Abstractions.Extensions; -using GR.Localization.Abstractions.Models; +using GR.Localization.Abstractions.Models.Config; using GR.Notifications.Abstractions.Extensions; using GR.Notifications.Hub.Hubs; -using GR.PageRender.Abstractions.Extensions; using GR.WebApplication.Helpers; using GR.WebApplication.Helpers.AppConfigurations; using Microsoft.AspNetCore.Builder; @@ -97,11 +98,12 @@ public static IServiceProvider RegisterGearWebApp(this IServiceCollection servic if (configuration.CacheConfiguration.UseDistributedCache) { services.AddDistributedMemoryCache() - .AddCacheModule(configuration.HostingEnvironment, configuration.Configuration); + .AddCacheModule() + .AddRedisCacheConfiguration(configuration.HostingEnvironment, configuration.Configuration); } else if (configuration.CacheConfiguration.UseInMemoryCache) { - services.AddCacheModule(configuration.HostingEnvironment, configuration.Configuration); + services.AddCacheModule(); } //---------------------------------Api version Module------------------------------------- @@ -176,9 +178,6 @@ public static IGearAppBuilder UseGearWebApp(this IApplicationBuilder app, Action app.UseExceptionHandler("/Home/Error"); } - //-----------------------Custom url redirection Usage------------------------------------- - if (configuration.UseCustomUrlRewrite) app.UseUrlRewriteModule(); - //----------------------------------Origin Cors Usage------------------------------------- if (configuration.UseDefaultCorsConfiguration) app.UseConfiguredCors(); @@ -267,4 +266,4 @@ public static IApplicationBuilder UseAppMvc(this IApplicationBuilder app, IConfi return app; } } -} +} \ No newline at end of file diff --git a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/GR.WebApplication.csproj b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/GR.WebApplication.csproj index fd93db1c..20cee6d1 100644 --- a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/GR.WebApplication.csproj +++ b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/GR.WebApplication.csproj @@ -2,15 +2,15 @@ netcoreapp2.2 - 1.9.1 + 1.9.2 Lupei Nicolae Indrivo Web app for run gear product https://i.ibb.co/KFYfF4D/indrivo-logo.jpg c# gear app .net core web webapp framework -Move app extensions - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 @@ -28,6 +28,7 @@ + diff --git a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Helpers/AppConfigurations/GearAppBuilderConfig.cs b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Helpers/AppConfigurations/GearAppBuilderConfig.cs index fedcbdeb..acb17317 100644 --- a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Helpers/AppConfigurations/GearAppBuilderConfig.cs +++ b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Helpers/AppConfigurations/GearAppBuilderConfig.cs @@ -23,11 +23,6 @@ public class GearAppBuilderConfig /// public IConfiguration Configuration { get; set; } - /// - /// Use dynamic pages url rewrite - /// - public virtual bool UseCustomUrlRewrite { get; set; } = true; - /// /// Use default cors /// diff --git a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Models/AppSettingsModel.cs b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Models/AppSettingsModel.cs index 266650a3..80ecabd0 100644 --- a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Models/AppSettingsModel.cs +++ b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Models/AppSettingsModel.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using GR.Backup.Abstractions.Models; -using GR.Cache.Abstractions; +using GR.Cache.Abstractions.Models; using GR.Core; using GR.Email.Abstractions.Models.EmailViewModels; using GR.Localization.Abstractions.ViewModels.LocalizationViewModels; @@ -61,7 +61,7 @@ public sealed class RootObject /// /// Redis connection configuration /// - public RedisConnectionConfig RedisConnection { get; set; } = new RedisConnectionConfig(); + public CacheConfiguration RedisConnection { get; set; } = new CacheConfiguration(); } public sealed class ConnectionStrings diff --git a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Services/ExportDataIO.cs b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Services/ExportDataIO.cs deleted file mode 100644 index b6898b2a..00000000 --- a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Services/ExportDataIO.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace GR.WebApplication.Services -{ - public static class ExportDataIo - { - /// - /// - /// - /// - /// - public static MemoryStream CreateZipArchive(IDictionary files) - { - var zipStream = new MemoryStream(); - using (var zip = new ZipArchive(zipStream, ZipArchiveMode.Create, true)) - { - foreach (var o in files) - { - try - { - var pageEntry = zip.CreateEntry(o.Key); - - using (var entryStream = pageEntry.Open()) - { - o.Value.CopyTo(entryStream); - } - } - catch (Exception e) - { - Console.WriteLine(e); - } - } - } - zipStream.Position = 0; - return zipStream; - } - - /// - /// Decompress - /// - /// - /// - public static void Decompress(MemoryStream stream, Action action) - { - var zip = new ZipArchive(stream, ZipArchiveMode.Read, true); - action.Invoke(zip); - } - - /// - /// GetConnectionString data from zip archive - /// - /// - /// - /// - /// - public static async Task GetDataFromZipArchiveEntry(this IEnumerable entries, string file) - { - var entities = entries.FirstOrDefault(x => x.Name.Equals(file)); - if (entities == null) return default; - - var entStream = entities.Open(); - using (var strReader = new StreamReader(entStream)) - { - var data = await strReader.ReadToEndAsync(); - if (string.IsNullOrEmpty(data)) return default; - try - { - return JsonConvert.DeserializeObject(data); - } - catch (Exception e) - { - Console.WriteLine(e); - } - } - - return default; - } - } -} diff --git a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Services/ExportManager.cs b/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Services/ExportManager.cs deleted file mode 100644 index 91d2e5dc..00000000 --- a/src/GR.Extensions/GR.Application.Extension/GR.WebApplication/Services/ExportManager.cs +++ /dev/null @@ -1,196 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using GR.Core.Helpers; -using GR.Core.Helpers.ConnectionStrings; -using GR.DynamicEntityStorage.Abstractions; -using GR.DynamicEntityStorage.Abstractions.Extensions; -using GR.Entities.Abstractions; -using GR.Entities.Abstractions.Models.Tables; -using GR.Entities.Abstractions.ViewModels.Table; -using GR.Entities.Data; -using GR.Forms.Abstractions; -using GR.Identity.Data; -using GR.PageRender.Abstractions; -using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json; - -namespace GR.WebApplication.Services -{ - public static class ExportManager - { - /// - /// CreateZipArchive data async - /// - /// - public static async Task<(MemoryStream, string, string)> ExportAsync() - { - var entitiesDbContext = IoC.Resolve(); - var dynamicService = IoC.Resolve(); - var applicationDbContext = IoC.Resolve(); - var formContext = IoC.Resolve(); - var pageContext = IoC.Resolve(); - var dynamicEntities = entitiesDbContext.Table - .Where(x => !x.IsPartOfDbContext) - .Include(x => x.TableFields); - - //var entityFrameWorkEntities = entitiesDbContext.Table - // .Where(x => x.IsPartOfDbContext) - // .Include(x => x.TableFields); - - var dynamicData = new Dictionary>(); - var frameworkData = new Dictionary>(); - - //Extract values from from dynamic entities - foreach (var entity in dynamicEntities) - { - var req = await dynamicService.Table(entity.Name).GetAllWithInclude(); - if (req.IsSuccess) - { - dynamicData.Add(entity.Name, req.Result); - } - } - - //Extract values from Entity FrameWork DbSet declarations - //foreach (var entity in entityFrameWorkEntities) - //{ - // var req = await dynamicService.Table(entity.Name).GetAll(); - // if (req.IsSuccess) - // { - // frameworkData.Add(entity.Name, req.Result); - // } - //} - - var zipStream = ExportDataIo.CreateZipArchive(new Dictionary - { - { - "forms.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(formContext.Forms - .Include(x => x.Columns) - .Include(x => x.Rows) - .Include(x => x.Fields) - .Include(x => x.Stages) - .Include(x => x.Settings).ToList()))) - }, - { - "pages.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(pageContext.Pages - .Include(x => x.PageScripts) - .Include(x => x.PageStyles) - .Include(x => x.PageType) - .Include(x => x.Settings).ToArray()))) - }, - { - "dynamicEntities.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(dynamicEntities))) - }, - { - "templates.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(pageContext.Templates.ToList()))) - }, - { - "roles.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(applicationDbContext.Roles.ToList()))) - }, - { - "tenants.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(applicationDbContext.Tenants.ToList()))) - }, - { - "users.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(applicationDbContext.Users.ToList()))) - }, - { - "userRoles.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(applicationDbContext.UserRoles.ToList()))) - }, - { - "rolePermissions.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(applicationDbContext.RolePermissions.ToList()))) - }, - { - "blocksCategories.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(pageContext.BlockCategories.ToList()))) - }, - { - "blocks.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(pageContext.Blocks.ToList()))) - }, - { - "dynamicEntitiesData.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(dynamicData))) - }, - { - "frameworkEntitiesData.json", new MemoryStream(Encoding.ASCII.GetBytes(Serialize(frameworkData))) - } - }); - var date = DateTime.Now; - return (zipStream, "application/octet-stream", $"export_system_{date.Minute}_{date.Hour}_{date.Day}_{date.Month}_{date.Year}.zip"); - } - - /// - /// Import async - /// - /// - /// - public static ResultModel Import(MemoryStream memStream) - { - var result = new ResultModel(); - - ExportDataIo.Decompress(memStream, async zip => - { - var context = IoC.Resolve(); - var tableService = IoC.Resolve(); - var dynamicContext = IoC.Resolve(); - var dynamicValues = await zip.Entries.GetDataFromZipArchiveEntry>>("dynamicEntitiesData.json"); - if (dynamicValues == null) return; - - //Import dynamic entities - var dynamicEntities = await zip.Entries.GetDataFromZipArchiveEntry>("dynamicEntities.json"); - if (dynamicEntities == null) return; - foreach (var entity in dynamicEntities) - { - if (await context.Table.AnyAsync(x => x.Name == entity.Name && x.TenantId == entity.TenantId)) - continue; - await context.Table.AddAsync(entity); - tableService.CreateSqlTable(entity, context.GetConnectionString()); - foreach (var tableField in entity.TableFields) - { - tableService.AddFieldSql(new CreateTableFieldViewModel - { - Name = tableField.Name, - DisplayName = tableField.DisplayName, - AllowNull = tableField.AllowNull, - Id = tableField.Id, - TableId = entity.Id, - DataType = tableField.DataType, - Description = tableField.Description - }, entity.Name, context.GetConnectionString(), true, entity.EntityType); - } - if (dynamicValues.ContainsKey(entity.Name)) - { - await dynamicContext.Table(entity.Name).AddRange(dynamicValues[entity.Name]); - } - } - await context.SaveChangesAsync(); - }); - - result.IsSuccess = true; - return result; - } - - /// - /// Serialize - /// - /// - /// - /// - private static string Serialize(TObject obj) - { - try - { - return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings - { - ReferenceLoopHandling = ReferenceLoopHandling.Ignore - }); - } - catch (Exception e) - { - Console.WriteLine(e); - } - - return string.Empty; - } - } -} diff --git a/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Abstractions/GR.Audit.Abstractions.csproj b/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Abstractions/GR.Audit.Abstractions.csproj index 626fb74f..73253f35 100755 --- a/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Abstractions/GR.Audit.Abstractions.csproj +++ b/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Abstractions/GR.Audit.Abstractions.csproj @@ -3,11 +3,11 @@ netstandard2.0 Lupei Nicolae - 1.9.1 + 1.9.2 https://i.ibb.co/KFYfF4D/indrivo-logo.jpg Indrivo - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 diff --git a/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Razor/GR.Audit.Razor.csproj b/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Razor/GR.Audit.Razor.csproj index 1b8bd189..8bbe7ed2 100755 --- a/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Razor/GR.Audit.Razor.csproj +++ b/src/GR.Extensions/GR.Audit.Extension/GR.Audit.Razor/GR.Audit.Razor.csproj @@ -4,10 +4,10 @@ netstandard2.0 Lupei Nicolae Indrivo - 1.9.1 + 1.9.2 https://i.ibb.co/KFYfF4D/indrivo-logo.jpg - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 diff --git a/src/GR.Extensions/GR.Audit.Extension/GR.Audit/GR.Audit.csproj b/src/GR.Extensions/GR.Audit.Extension/GR.Audit/GR.Audit.csproj index 5ac1345b..98922c92 100755 --- a/src/GR.Extensions/GR.Audit.Extension/GR.Audit/GR.Audit.csproj +++ b/src/GR.Extensions/GR.Audit.Extension/GR.Audit/GR.Audit.csproj @@ -4,15 +4,15 @@ netstandard2.0 Lupei Nicolae Indrivo - 1.9.1 + 1.9.2 Tracking changes from an entity audit false Debug;Release;Stage 7.3 https://i.ibb.co/KFYfF4D/indrivo-logo.jpg - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/BackgroundServices/BackupTimeService.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/BackgroundServices/BackupTimeService.cs index 5fc304b7..3cfacc27 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/BackgroundServices/BackupTimeService.cs +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/BackgroundServices/BackupTimeService.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Hosting; @@ -30,9 +29,9 @@ namespace GR.Backup.Abstractions.BackgroundServices /// /// Inject backup service /// - private readonly IBackupService _backupService; + private readonly IBackupService _backupService; - public BackupTimeService(ILogger> logger, IOptions options, IBackupService backupService) + public BackupTimeService(ILogger> logger, IOptions options, IBackupService backupService) { _logger = logger; _backupService = backupService; diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/Extensions/ServiceCollectionExtensions.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/Extensions/ServiceCollectionExtensions.cs index b4e0c68f..4ec86864 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/Extensions/ServiceCollectionExtensions.cs +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/Extensions/ServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using GR.Backup.Abstractions.Models; +using GR.Core.Extensions; namespace GR.Backup.Abstractions.Extensions { @@ -13,15 +14,26 @@ public static class ServiceCollectionExtensions /// /// /// - public static IServiceCollection RegisterDatabaseBackupRunnerModule(this IServiceCollection services, IConfiguration configuration) - where TRunner : class, IHostedService + public static IServiceCollection RegisterDatabaseBackupRunnerModule(this IServiceCollection services, IConfiguration configuration) where TBackupSettings : BackupSettings - where TBackupService : class, IBackupService + where TBackupService : class, IBackupService { - services.AddTransient, TBackupService>(); + services.AddGearSingleton(); + services.Configure(configuration.GetSection(nameof(BackupSettings))); + return services; + } - //Run background service for backup database + /// + /// Register auto backup runner + /// + /// + /// + /// + public static IServiceCollection RegisterDatabaseBackgroundService(this IServiceCollection services) + where TRunner : class, IHostedService + { + //Register background service for backup database services.AddHostedService(); return services; } diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/GR.Backup.Abstractions.csproj b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/GR.Backup.Abstractions.csproj index 5b57d4fe..a829f316 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/GR.Backup.Abstractions.csproj +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/GR.Backup.Abstractions.csproj @@ -4,10 +4,10 @@ netstandard2.0 Lupei Nicolae Indrivo - 1.9.1 + 1.9.2 https://i.ibb.co/KFYfF4D/indrivo-logo.jpg - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/IBackupService.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/IBackupService.cs index f854e75f..382496a8 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/IBackupService.cs +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/IBackupService.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; -using GR.Backup.Abstractions.Models; +using GR.Backup.Abstractions.ViewModels; +using GR.Core.Helpers; namespace GR.Backup.Abstractions { - public interface IBackupService where TSettings : BackupSettings + public interface IBackupService { /// /// Make backup @@ -20,6 +21,19 @@ public interface IBackupService where TSettings : BackupSettings /// List of backups /// /// - IEnumerable GetBackups(); + IEnumerable GetBackups(); + + /// + /// Download backup + /// + /// + /// + DownloadBackupResultModel DownloadBackup(string backupName); + + /// + /// Clear backups + /// + /// + ResultModel Clear(); } } \ No newline at end of file diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/ViewModels/BackupViewModel.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/ViewModels/BackupViewModel.cs new file mode 100644 index 00000000..8ace1f6b --- /dev/null +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/ViewModels/BackupViewModel.cs @@ -0,0 +1,32 @@ +using System; + +namespace GR.Backup.Abstractions.ViewModels +{ + public sealed class BackupViewModel + { + /// + /// File name + /// + public string Name { get; set; } + + /// + /// Physic file path + /// + public string Path { get; set; } + + /// + /// File size + /// + public long Size { get; set; } + + /// + /// Creation date + /// + public DateTime CreationDate { get; set; } + + /// + /// Backup extension + /// + public string Extension { get; set; } + } +} \ No newline at end of file diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/ViewModels/DownloadBackupResultModel.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/ViewModels/DownloadBackupResultModel.cs new file mode 100644 index 00000000..fbf060d7 --- /dev/null +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Abstractions/ViewModels/DownloadBackupResultModel.cs @@ -0,0 +1,10 @@ +using GR.Core.Helpers; + +namespace GR.Backup.Abstractions.ViewModels +{ + public sealed class DownloadBackupResultModel : ResultModel + { + public string Name { get; set; } + public string FullPath { get; set; } + } +} diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/GR.Backup.PostgresSql.csproj b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/GR.Backup.PostgresSql.csproj index cf349d55..13a5ec95 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/GR.Backup.PostgresSql.csproj +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/GR.Backup.PostgresSql.csproj @@ -4,10 +4,10 @@ netstandard2.0 Lupei Nicolae Indrivo - 1.9.1 + 1.9.2 https://i.ibb.co/KFYfF4D/indrivo-logo.jpg - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreBackupService.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreBackupService.cs index 15d339e0..7652615c 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreBackupService.cs +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreBackupService.cs @@ -9,12 +9,14 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; +using GR.Backup.Abstractions.ViewModels; +using GR.Core.Helpers; namespace GR.Backup.PostGresSql { //Special folders https://developers.redhat.com/blog/2018/11/07/dotnet-special-folder-api-linux/ [Author(Authors.LUPEI_NICOLAE)] - public class PostGreBackupService : IBackupService + public class PostGreBackupService : IBackupService { #region Injectable @@ -46,14 +48,117 @@ public virtual void Backup() else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { //TODO: Backup on mac os env + ExecuteLinuxDump(); + } + } + + /// + /// Get provider name + /// + /// + public virtual string GetProviderName() => GetType().Name; + + /// + /// Get backups + /// + /// + public virtual IEnumerable GetBackups() + { + var files = Directory.GetFiles(GetDirectoryPath()) + .ToList(); + + foreach (var file in files) + { + var fileInfo = new FileInfo(file); + yield return new BackupViewModel + { + Name = fileInfo.Name, + Path = file, + CreationDate = fileInfo.CreationTime, + Size = fileInfo.Length, + Extension = fileInfo.Extension + }; + } + } + + /// + /// Clear all + /// + public virtual ResultModel Clear() + { + var response = new ResultModel(); + var backups = GetBackups(); + foreach (var backup in backups) + { + try + { + File.Delete(backup.Path); + } + catch (Exception e) + { + Console.WriteLine(e); + response.Errors.Add(new ErrorModel(e.HelpLink, e.Message)); + } + } + + response.IsSuccess = !response.Errors.Any(); + return response; + } + + /// + /// Download file + /// + /// + /// + public virtual DownloadBackupResultModel DownloadBackup(string backupName) + { + var path = Path.Combine(GetDirectoryPath(), backupName); + var result = new DownloadBackupResultModel + { + FullPath = path, + Name = backupName + }; + + if (!File.Exists(path)) + { + result.Errors.Add(new ErrorModel + { + Key = string.Empty, + Message = "File not found" + }); + return result; + } + + var blob = File.ReadAllBytes(path); + result.Result = blob; + result.IsSuccess = true; + return result; + } + + #region Helpers + + /// + /// Get directory path + /// + /// + protected virtual string GetDirectoryPath() + { + var userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + var directoryPath = Path.Combine(userProfilePath, $"backup\\{_options.Value.BackupFolder}"); + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); } + + return directoryPath; } + /// /// Build dump output file /// /// - protected string BuildDumpOutputFile() + protected virtual string BuildDumpOutputFile() { var directoryPath = GetDirectoryPath(); var currentDate = DateTime.Now; @@ -65,7 +170,7 @@ protected string BuildDumpOutputFile() /// /// Execute dump in windows /// - protected void ExecuteWindowsDump() + protected virtual void ExecuteWindowsDump() { var outputFile = BuildDumpOutputFile(); var dumpCommand = "\"" + _options.Value.PgDumpPath + "\"" + " -Fc" + " -h " + _options.Value.Host + " -p " + @@ -126,7 +231,7 @@ protected void ExecuteWindowsDump() /// /// Execute linux dump file backup /// - protected void ExecuteLinuxDump() + protected virtual void ExecuteLinuxDump() { var outputFile = BuildDumpOutputFile(); var command = $"PGPASSWORD=\"{_options.Value.Password}\" pg_dump -h {_options.Value.Host} -p {_options.Value.Port} -U {_options.Value.User} -F c -b -v -f \"{outputFile}\" {_options.Value.Database}"; @@ -149,36 +254,6 @@ protected void ExecuteLinuxDump() Debug.WriteLine(result); } - /// - /// Get provider name - /// - /// - public virtual string GetProviderName() => GetType().Name; - - /// - /// Get backups - /// - /// - public virtual IEnumerable GetBackups() - { - var files = Directory.GetFiles(GetDirectoryPath()).ToList(); - return files; - } - - /// - /// Get directory path - /// - /// - protected virtual string GetDirectoryPath() - { - var userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - var directoryPath = Path.Combine(userProfilePath, $"backup\\{_options.Value.BackupFolder}"); - if (!Directory.Exists(directoryPath)) - { - Directory.CreateDirectory(directoryPath); - } - - return directoryPath; - } + #endregion } } \ No newline at end of file diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreSqlBackupSettings.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreSqlBackupSettings.cs index 0e807482..86a3334c 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreSqlBackupSettings.cs +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.PostgresSql/PostGreSqlBackupSettings.cs @@ -37,6 +37,6 @@ public sealed class PostGreSqlBackupSettings : BackupSettings /// /// File extension /// - public string FileExtension { get; set; } = "pgbackup"; + public string FileExtension { get; set; } = "backup"; } } diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Controllers/DataBaseBackupController.cs b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Controllers/DataBaseBackupController.cs index 38e588e1..ba8ec0cc 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Controllers/DataBaseBackupController.cs +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Controllers/DataBaseBackupController.cs @@ -1,19 +1,63 @@ -using Microsoft.AspNetCore.Authorization; +using System.Linq; +using GR.Backup.Abstractions; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using GR.Core; +using GR.Core.Razor.BaseControllers; namespace GR.Backup.Razor.Controllers { [Authorize(Roles = GlobalResources.Roles.ADMINISTRATOR)] - public class DataBaseBackupController : Controller + public class DataBaseBackupController : BaseGearController { + #region Injectable + + /// + /// Inject backup + /// + private readonly IBackupService _backupService; + + #endregion + + public DataBaseBackupController(IBackupService backupService) + { + _backupService = backupService; + } + /// /// Backup manager /// /// + [HttpGet] public IActionResult Index() { - return View(); + var backups = _backupService.GetBackups() + .OrderByDescending(x => x.CreationDate) + .ToList(); + return View(backups); + } + + /// + /// Download backup + /// + /// + /// + [HttpGet] + [Route(DefaultApiRouteTemplate)] + public IActionResult DownloadBackup(string backupName) + { + var blobRequest = _backupService.DownloadBackup(backupName); + if (!blobRequest.IsSuccess) return NotFound(); + return File(blobRequest.Result, "application/octet-stream", blobRequest.Name); } + + /// + /// Clear all + /// + /// + [HttpPost] + [Route(DefaultApiRouteTemplate)] + public JsonResult ClearAll() + => Json(_backupService.Clear()); } } \ No newline at end of file diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/GR.Backup.Razor.csproj b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/GR.Backup.Razor.csproj index fcfe5d79..6cc6812b 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/GR.Backup.Razor.csproj +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/GR.Backup.Razor.csproj @@ -4,21 +4,26 @@ netstandard2.0 Lupei Nicolae Indrivo - 1.9.1 + 1.9.2 https://i.ibb.co/KFYfF4D/indrivo-logo.jpg - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 + + + + PreserveNewest + false diff --git a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Views/DataBaseBackup/Index.cshtml b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Views/DataBaseBackup/Index.cshtml index ea728188..95e4a404 100755 --- a/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Views/DataBaseBackup/Index.cshtml +++ b/src/GR.Extensions/GR.Backup.Extension/GR.Backup.Razor/Views/DataBaseBackup/Index.cshtml @@ -1,5 +1,75 @@ -@{ - ViewData["Title"] = "Backup manager"; +@using ByteSizeLib + +@model IEnumerable + +@{ + ViewData["Title"] = "Database Backups"; } -

Incoming...

\ No newline at end of file +
+
+ Clear +
+
+ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + + @if (!Model.Any()) + { + + + + } + +
NameExtensionCreation dateSizeActions
@item.Name@item.Extension@item.CreationDate@ByteSize.FromBytes(item.Size).ToString() + Download +
No backups!
+
+
+ + +@section Scripts{ + +} \ No newline at end of file diff --git a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/Extensions/ServiceProviderExtensions.cs b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/Extensions/ServiceProviderExtensions.cs index 22bf73b3..6404b583 100644 --- a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/Extensions/ServiceProviderExtensions.cs +++ b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/Extensions/ServiceProviderExtensions.cs @@ -1,10 +1,4 @@ -using System; -using GR.Cache.Abstractions.Exceptions; -using GR.Core; -using GR.Core.Extensions; -using GR.Core.Helpers; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using GR.Core.Extensions; using Microsoft.Extensions.DependencyInjection; namespace GR.Cache.Abstractions.Extensions @@ -15,52 +9,11 @@ public static class ServiceProviderExtensions /// Use custom cache service /// /// - /// - /// - /// /// - public static IServiceCollection AddCacheModule(this IServiceCollection services, IHostingEnvironment environment, IConfiguration configuration, string customSystemIdentifier = null) + public static IServiceCollection AddCacheModule(this IServiceCollection services) where TCacheService : class, ICacheService - where TRedisConnection : class, IRedisConnection { - services.AddCacheModule(environment, configuration); - services.AddSingleton(); - IoC.RegisterSingletonService(); - return services; - } - - /// - /// Add cache module - /// - /// - /// - /// - /// - /// - public static IServiceCollection AddCacheModule(this IServiceCollection services, IHostingEnvironment environment, IConfiguration configuration, string customSystemIdentifier = null) - where TRedisConnection : class, IRedisConnection - { - if (customSystemIdentifier == null) - { - var systemIdentifier = configuration.GetSection(nameof(SystemConfig)) - .GetValue(nameof(SystemConfig.MachineIdentifier)); - - if (string.IsNullOrEmpty(systemIdentifier)) - throw new NullReferenceException("System identifier was not registered in appsettings file"); - customSystemIdentifier = systemIdentifier; - } - var redisSection = configuration.GetSection("RedisConnection"); - var redisConfig = redisSection.Get(); - if (redisConfig == null) throw new InvalidCacheConfigurationException(); - services.ConfigureWritable(configuration.GetSection("RedisConnection")); - services.AddDistributedRedisCache(opts => - { - opts.Configuration = redisConfig.Host; - opts.InstanceName = $"{customSystemIdentifier}.{environment.EnvironmentName}@"; - }); - - services.AddSingleton(); - IoC.RegisterSingletonService(); + services.AddGearSingleton(); return services; } } diff --git a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/GR.Cache.Abstractions.csproj b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/GR.Cache.Abstractions.csproj index 8503ef32..fbb3ff6b 100644 --- a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/GR.Cache.Abstractions.csproj +++ b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/GR.Cache.Abstractions.csproj @@ -5,16 +5,14 @@ Lupei Nicolae Indrivo https://i.ibb.co/KFYfF4D/indrivo-logo.jpg - 1.9.1 + 1.9.2 -Add in memory cache provider - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 - - diff --git a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/ICacheService.cs b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/ICacheService.cs index b05b80e5..dd05b2e8 100755 --- a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/ICacheService.cs +++ b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/ICacheService.cs @@ -54,5 +54,11 @@ public interface ICacheService /// Flush all keys /// void FlushAll(); + + /// + /// Get provider name + /// + /// + string GetImplementationProviderName(); } } diff --git a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/RedisConnectionConfig.cs b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/Models/CacheConfiguration.cs old mode 100755 new mode 100644 similarity index 76% rename from src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/RedisConnectionConfig.cs rename to src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/Models/CacheConfiguration.cs index 2c86fb19..48a656be --- a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/RedisConnectionConfig.cs +++ b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Abstractions/Models/CacheConfiguration.cs @@ -1,6 +1,6 @@ -namespace GR.Cache.Abstractions +namespace GR.Cache.Abstractions.Models { - public sealed class RedisConnectionConfig + public class CacheConfiguration { /// /// Host of redis diff --git a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Controllers/CacheController.cs b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Controllers/CacheController.cs index 15cb2912..c1e87113 100755 --- a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Controllers/CacheController.cs +++ b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Controllers/CacheController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using GR.Cache.Abstractions; +using GR.Cache.Abstractions.Models; using GR.Core; using GR.Core.Abstractions; using GR.Core.Helpers; @@ -20,14 +21,14 @@ public class CacheController : Controller /// /// Cache options /// - private readonly IWritableOptions _writableOptions; + private readonly IWritableOptions _writableOptions; /// /// Constructor /// /// /// - public CacheController(ICacheService cacheService, IWritableOptions writableOptions) + public CacheController(ICacheService cacheService, IWritableOptions writableOptions) { _cacheService = cacheService; _writableOptions = writableOptions; @@ -87,7 +88,7 @@ public IActionResult Settings() /// /// [HttpPost] - public IActionResult Settings(RedisConnectionConfig model) + public IActionResult Settings(CacheConfiguration model) { _writableOptions.Update(opt => { diff --git a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/GR.Cache.Razor.csproj b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/GR.Cache.Razor.csproj index 38826135..686546e6 100755 --- a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/GR.Cache.Razor.csproj +++ b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/GR.Cache.Razor.csproj @@ -4,11 +4,11 @@ netstandard2.0 https://i.ibb.co/KFYfF4D/indrivo-logo.jpg Lupei Nicolae - 1.9.1 + 1.9.2 redis cache ui gear - Fix container scroll - 1.9.1 - 1.9.1 + 1.9.2 + 1.9.2 @@ -16,8 +16,6 @@ - - diff --git a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Views/Cache/Index.cshtml b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Views/Cache/Index.cshtml index cc1eba64..44237c12 100755 --- a/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Views/Cache/Index.cshtml +++ b/src/GR.Extensions/GR.Cache.Extension/GR.Cache.Razor/Views/Cache/Index.cshtml @@ -1,7 +1,4 @@ -@using Newtonsoft.Json -@using GR.Cache.Abstractions -@using GR.Cache.Services -@using GR.Core +@using GR.Cache.Abstractions @using GR.Core.Extensions @model IEnumerable @inject ICacheService CacheService @@ -42,7 +39,7 @@ { foreach (var item in Model) { - var key = CacheService is DistributedCacheService ? item.Key.Split('@')?[1] : item.Key; + var key = CacheService.GetImplementationProviderName() == "DistributedCacheService" ? item.Key.Split('@')[1] : item.Key; var pre = await CacheService.GetAsync (key); @@ -153,6 +150,7 @@ @section Styles {