Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Minor changes - Move IGoogleAnalyticsService to Admin project

support18bfe240d423
diff --git a/src/Business/Grand.Business.Common/Grand.Business.Common.csproj b/src/Business/Grand.Business.Common/Grand.Business.Common.csproj
index 44948a7f4..123e2192c 100644
--- a/src/Business/Grand.Business.Common/Grand.Business.Common.csproj
+++ b/src/Business/Grand.Business.Common/Grand.Business.Common.csproj
@@ -6,8 +6,9 @@
<ProjectReference Include="..\..\Core\Grand.SharedKernel\Grand.SharedKernel.csproj" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Google.Apis" Version="1.57.0" />
- <PackageReference Include="Google.Apis.AnalyticsReporting.v4" Version="1.57.0.2484" />
<PackageReference Include="MaxMind.GeoIP2" Version="5.1.0" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Utilities\" />
+ </ItemGroup>
</Project>
diff --git a/src/Business/Grand.Business.Common/Interfaces/Directory/IGoogleAnalyticsService.cs b/src/Business/Grand.Business.Common/Interfaces/Directory/IGoogleAnalyticsService.cs
deleted file mode 100644
index 62bb3d160..000000000
--- a/src/Business/Grand.Business.Common/Interfaces/Directory/IGoogleAnalyticsService.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Grand.Business.Common.Utilities;
-
-namespace Grand.Business.Common.Interfaces.Directory
-{
- public partial interface IGoogleAnalyticsService
- {
- Task<GoogleAnalyticsResult> GetDataByGeneral(DateTime startDate, DateTime endDate);
- Task<GoogleAnalyticsResult> GetDataByLocalization(DateTime startDate, DateTime endDate);
- Task<GoogleAnalyticsResult> GetDataBySource(DateTime startDate, DateTime endDate);
- Task<GoogleAnalyticsResult> GetDataByExit(DateTime startDate, DateTime endDate);
- Task<GoogleAnalyticsResult> GetDataByDevice(DateTime startDate, DateTime endDate);
- }
-}
diff --git a/src/Business/Grand.Business.Common/Startup/StartupApplication.cs b/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
index 946ec2898..03f1821ec 100644
--- a/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
+++ b/src/Business/Grand.Business.Common/Startup/StartupApplication.cs
@@ -70,7 +70,6 @@ namespace Grand.Business.Common.Startup
private void RegisterConfigurationService(IServiceCollection serviceCollection)
{
serviceCollection.AddScoped<ISettingService, SettingService>();
- serviceCollection.AddScoped<IGoogleAnalyticsService, GoogleAnalyticsService>();
}
private void RegisterLocalizationService(IServiceCollection serviceCollection)
{
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByDevice.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByDevice.cshtml
index 3be4d3430..41329c6a0 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByDevice.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByDevice.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Business.Common.Utilities.GoogleAnalyticsResult
+@model Grand.Web.Admin.Models.Common.GoogleAnalyticsResultModel
@if(!String.IsNullOrEmpty(Model.Message))
{
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByExit.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByExit.cshtml
index 3be4d3430..41329c6a0 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByExit.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByExit.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Business.Common.Utilities.GoogleAnalyticsResult
+@model Grand.Web.Admin.Models.Common.GoogleAnalyticsResultModel
@if(!String.IsNullOrEmpty(Model.Message))
{
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByLocalization.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByLocalization.cshtml
index 3be4d3430..41329c6a0 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByLocalization.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataByLocalization.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Business.Common.Utilities.GoogleAnalyticsResult
+@model Grand.Web.Admin.Models.Common.GoogleAnalyticsResultModel
@if(!String.IsNullOrEmpty(Model.Message))
{
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataBySource.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataBySource.cshtml
index 3be4d3430..41329c6a0 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataBySource.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardDataBySource.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Business.Common.Utilities.GoogleAnalyticsResult
+@model Grand.Web.Admin.Models.Common.GoogleAnalyticsResultModel
@if(!String.IsNullOrEmpty(Model.Message))
{
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardGeneralData.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardGeneralData.cshtml
index 30edbd28a..3a716ee10 100644
--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardGeneralData.cshtml
+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/GoogleAnalytics/DashboardGeneralData.cshtml
@@ -1,4 +1,4 @@
-@model Grand.Business.Common.Utilities.GoogleAnalyticsResult
+@model Grand.Web.Admin.Models.Common.GoogleAnalyticsResultModel
@if(!String.IsNullOrEmpty(Model.Message))
{
diff --git a/src/Web/Grand.Web.Admin/Controllers/GoogleAnalyticsController.cs b/src/Web/Grand.Web.Admin/Controllers/GoogleAnalyticsController.cs
index 0b6dc4ba2..a05ec43f8 100644
--- a/src/Web/Grand.Web.Admin/Controllers/GoogleAnalyticsController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/GoogleAnalyticsController.cs
@@ -1,4 +1,4 @@
-using Grand.Business.Common.Interfaces.Directory;
+using Grand.Web.Admin.Interfaces;
using Microsoft.AspNetCore.Mvc;
@@ -6,10 +6,10 @@ namespace Grand.Web.Admin.Controllers
{
public partial class GoogleAnalyticsController : BaseAdminController
{
- private readonly IGoogleAnalyticsService _googleAnalyticsService;
+ private readonly IGoogleAnalyticsViewModelService _googleAnalyticsService;
public GoogleAnalyticsController(
- IGoogleAnalyticsService googleAnalyticsService)
+ IGoogleAnalyticsViewModelService googleAnalyticsService)
{
_googleAnalyticsService = googleAnalyticsService;
}
diff --git a/src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj b/src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
index 074c74753..9cd5afac4 100644
--- a/src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
+++ b/src/Web/Grand.Web.Admin/Grand.Web.Admin.csproj
@@ -12,6 +12,8 @@
<PackageReference Include="elFinder.Net.AspNetCore" Version="1.4.4" />
<PackageReference Include="elFinder.Net.Core" Version="1.4.4" />
<PackageReference Include="elFinder.Net.Drivers.FileSystem" Version="1.4.4" />
+ <PackageReference Include="Google.Apis" Version="1.57.0" />
+ <PackageReference Include="Google.Apis.AnalyticsReporting.v4" Version="1.57.0.2484" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Business\Grand.Business.Authentication\Grand.Business.Authentication.csproj" />
diff --git a/src/Web/Grand.Web.Admin/Interfaces/IGoogleAnalyticsViewModelService.cs b/src/Web/Grand.Web.Admin/Interfaces/IGoogleAnalyticsViewModelService.cs
new file mode 100644
index 000000000..a158f6373
--- /dev/null
+++ b/src/Web/Grand.Web.Admin/Interfaces/IGoogleAnalyticsViewModelService.cs
@@ -0,0 +1,13 @@
+using Grand.Web.Admin.Models.Common;
+
+namespace Grand.Web.Admin.Interfaces
+{
+ public partial interface IGoogleAnalyticsViewModelService
+ {
+ Task<GoogleAnalyticsResultModel> GetDataByGeneral(DateTime startDate, DateTime endDate);
+ Task<GoogleAnalyticsResultModel> GetDataByLocalization(DateTime startDate, DateTime endDate);
+ Task<GoogleAnalyticsResultModel> GetDataBySource(DateTime startDate, DateTime endDate);
+ Task<GoogleAnalyticsResultModel> GetDataByExit(DateTime startDate, DateTime endDate);
+ Task<GoogleAnalyticsResultModel> GetDataByDevice(DateTime startDate, DateTime endDate);
+ }
+}
diff --git a/src/Business/Grand.Business.Common/Utilities/GoogleAnalyticsResult.cs b/src/Web/Grand.Web.Admin/Models/Common/GoogleAnalyticsResultModel.cs
similarity index 75%
rename from src/Business/Grand.Business.Common/Utilities/GoogleAnalyticsResult.cs
rename to src/Web/Grand.Web.Admin/Models/Common/GoogleAnalyticsResultModel.cs
index 916bd3cf3..d11ce47dc 100644
--- a/src/Business/Grand.Business.Common/Utilities/GoogleAnalyticsResult.cs
+++ b/src/Web/Grand.Web.Admin/Models/Common/GoogleAnalyticsResultModel.cs
@@ -1,8 +1,8 @@
-namespace Grand.Business.Common.Utilities
+namespace Grand.Web.Admin.Models.Common
{
- public partial class GoogleAnalyticsResult
+ public partial class GoogleAnalyticsResultModel
{
- public GoogleAnalyticsResult()
+ public GoogleAnalyticsResultModel()
{
Records = new List<Dictionary<string, string>>();
}
diff --git a/src/Business/Grand.Business.Common/Services/Directory/GoogleAnalyticsService.cs b/src/Web/Grand.Web.Admin/Services/GoogleAnalyticsViewModelService.cs
similarity index 87%
rename from src/Business/Grand.Business.Common/Services/Directory/GoogleAnalyticsService.cs
rename to src/Web/Grand.Web.Admin/Services/GoogleAnalyticsViewModelService.cs
index f981b27ec..c9fee8d9b 100644
--- a/src/Business/Grand.Business.Common/Services/Directory/GoogleAnalyticsService.cs
+++ b/src/Web/Grand.Web.Admin/Services/GoogleAnalyticsViewModelService.cs
@@ -2,15 +2,15 @@
using Google.Apis.AnalyticsReporting.v4.Data;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
-using Grand.Business.Common.Interfaces.Directory;
using Grand.Business.Common.Interfaces.Localization;
using Grand.Business.Common.Interfaces.Logging;
-using Grand.Business.Common.Utilities;
using Grand.Domain.Seo;
+using Grand.Web.Admin.Interfaces;
+using Grand.Web.Admin.Models.Common;
-namespace Grand.Business.Common.Services.Directory
+namespace Grand.Web.Admin.Services
{
- public partial class GoogleAnalyticsService : IGoogleAnalyticsService
+ public partial class GoogleAnalyticsViewModelService : IGoogleAnalyticsViewModelService
{
#region Fields
@@ -28,8 +28,7 @@ namespace Grand.Business.Common.Services.Directory
string privateKey = _googleAnalyticsSettings.gaprivateKey.Replace("\\n", "\n");
var credential = new ServiceAccountCredential(temp.FromPrivateKey(privateKey));
- return new AnalyticsReportingService(new BaseClientService.Initializer()
- {
+ return new AnalyticsReportingService(new BaseClientService.Initializer() {
HttpClientInitializer = credential,
ApplicationName = "GrandNode",
});
@@ -44,7 +43,7 @@ namespace Grand.Business.Common.Services.Directory
#endregion
#region Ctor
- public GoogleAnalyticsService(GoogleAnalyticsSettings googleAnalyticsSettings,
+ public GoogleAnalyticsViewModelService(GoogleAnalyticsSettings googleAnalyticsSettings,
ITranslationService translationService, ILogger logger)
{
_googleAnalyticsSettings = googleAnalyticsSettings;
@@ -55,9 +54,9 @@ namespace Grand.Business.Common.Services.Directory
#region Utilities
- private GoogleAnalyticsResult ParseResponse(GetReportsResponse response, DateTime startDate, DateTime endDate)
+ private GoogleAnalyticsResultModel ParseResponse(GetReportsResponse response, DateTime startDate, DateTime endDate)
{
- var result = new GoogleAnalyticsResult();
+ var result = new GoogleAnalyticsResultModel();
result.StartDate = startDate.ToString();
result.EndDate = endDate.ToString();
@@ -97,17 +96,17 @@ namespace Grand.Business.Common.Services.Directory
return result;
}
- private GoogleAnalyticsResult ReturnEmpty()
+ private GoogleAnalyticsResultModel ReturnEmpty()
{
- if (String.IsNullOrEmpty(_googleAnalyticsSettings.gaprivateKey))
- return new GoogleAnalyticsResult() { Message = _translationService.GetResource("Admin.Settings.GeneralCommon.GoogleAnalytics.help") };
+ if (string.IsNullOrEmpty(_googleAnalyticsSettings.gaprivateKey))
+ return new GoogleAnalyticsResultModel() { Message = _translationService.GetResource("Admin.Settings.GeneralCommon.GoogleAnalytics.help") };
else
- return new GoogleAnalyticsResult() { Message = _translationService.GetResource("Admin.Settings.GeneralCommon.GoogleAnalytics.help2") };
+ return new GoogleAnalyticsResultModel() { Message = _translationService.GetResource("Admin.Settings.GeneralCommon.GoogleAnalytics.help2") };
}
#endregion
- public virtual async Task<GoogleAnalyticsResult> GetDataByGeneral(DateTime startDate, DateTime endDate)
+ public virtual async Task<GoogleAnalyticsResultModel> GetDataByGeneral(DateTime startDate, DateTime endDate)
{
if (await _analyticsReportingService() == null)
{
@@ -140,8 +139,7 @@ namespace Grand.Business.Common.Services.Directory
orderBys.Add(new OrderBy() { FieldName = "ga:pageviews", SortOrder = "DESCENDING", OrderType = "VALUE" });
//final assembling
- ReportRequest request = new ReportRequest()
- {
+ ReportRequest request = new ReportRequest() {
ViewId = _googleAnalyticsSettings.gaviewID,
DateRanges = dateRanges,
Metrics = metrics,
@@ -159,7 +157,7 @@ namespace Grand.Business.Common.Services.Directory
return ParseResponse(response, startDate, endDate);
}
- public virtual async Task<GoogleAnalyticsResult> GetDataByLocalization(DateTime startDate, DateTime endDate)
+ public virtual async Task<GoogleAnalyticsResultModel> GetDataByLocalization(DateTime startDate, DateTime endDate)
{
if (await _analyticsReportingService() == null)
{
@@ -185,8 +183,7 @@ namespace Grand.Business.Common.Services.Directory
orderBys.Add(new OrderBy() { FieldName = "ga:pageviews", SortOrder = "DESCENDING", OrderType = "VALUE" });
//ReportRequest - final assembling
- ReportRequest request = new ReportRequest()
- {
+ ReportRequest request = new ReportRequest() {
ViewId = _googleAnalyticsSettings.gaviewID,
DateRanges = dateRanges,
Metrics = metrics,
@@ -205,7 +202,7 @@ namespace Grand.Business.Common.Services.Directory
return ParseResponse(response, startDate, endDate);
}
- public virtual async Task<GoogleAnalyticsResult> GetDataBySource(DateTime startDate, DateTime endDate)
+ public virtual async Task<GoogleAnalyticsResultModel> GetDataBySource(DateTime startDate, DateTime endDate)
{
if (await _analyticsReportingService() == null)
{
@@ -230,8 +227,7 @@ namespace Grand.Business.Common.Services.Directory
orderBys.Add(new OrderBy() { FieldName = "ga:pageviews", SortOrder = "DESCENDING", OrderType = "VALUE" });
//final assembling
- ReportRequest request = new ReportRequest()
- {
+ ReportRequest request = new ReportRequest() {
ViewId = _googleAnalyticsSettings.gaviewID,
DateRanges = dateRanges,
Metrics = metrics,
@@ -250,7 +246,7 @@ namespace Grand.Business.Common.Services.Directory
return ParseResponse(response, startDate, endDate);
}
- public virtual async Task<GoogleAnalyticsResult> GetDataByExit(DateTime startDate, DateTime endDate)
+ public virtual async Task<GoogleAnalyticsResultModel> GetDataByExit(DateTime startDate, DateTime endDate)
{
if (await _analyticsReportingService() == null)
{
@@ -275,8 +271,7 @@ namespace Grand.Business.Common.Services.Directory
orderBys.Add(new OrderBy() { FieldName = "ga:pageviews", SortOrder = "DESCENDING", OrderType = "VALUE" });
//final assembling
- ReportRequest request = new ReportRequest()
- {
+ ReportRequest request = new ReportRequest() {
ViewId = _googleAnalyticsSettings.gaviewID,
DateRanges = dateRanges,
Metrics = metrics,
@@ -295,7 +290,7 @@ namespace Grand.Business.Common.Services.Directory
return ParseResponse(response, startDate, endDate);
}
- public virtual async Task<GoogleAnalyticsResult> GetDataByDevice(DateTime startDate, DateTime endDate)
+ public virtual async Task<GoogleAnalyticsResultModel> GetDataByDevice(DateTime startDate, DateTime endDate)
{
if (await _analyticsReportingService() == null)
{
@@ -320,8 +315,7 @@ namespace Grand.Business.Common.Services.Directory
orderBys.Add(new OrderBy() { FieldName = "ga:pageviews", SortOrder = "DESCENDING", OrderType = "VALUE" });
//final assembling
- var request = new ReportRequest()
- {
+ var request = new ReportRequest() {
ViewId = _googleAnalyticsSettings.gaviewID,
DateRanges = dateRanges,
Metrics = metrics,
diff --git a/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs b/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs
index e9e92d2c4..cba0aded8 100644
--- a/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs
+++ b/src/Web/Grand.Web.Admin/Startup/StartupApplication.cs
@@ -59,6 +59,7 @@ namespace Grand.Web.Admin.Startup
services.AddScoped<IProductViewModelService, ProductViewModelService>();
services.AddScoped<IPictureViewModelService, PictureViewModelService>();
services.AddScoped<IElFinderViewModelService, ElFinderViewModelService>();
+ services.AddScoped<IGoogleAnalyticsViewModelService, GoogleAnalyticsViewModelService>();
}
public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
{