Skip to content

Commit 459f775

Browse files
committed
Trying to add logging of archive app versions.
1 parent aa68273 commit 459f775

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/EformBackendConfigurationPlugin.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525

2626
using System.Runtime.InteropServices;
2727
using System.Text.RegularExpressions;
28+
using Microting.EformAngularFrontendBase.Infrastructure.Data;
2829
using Microting.EformAngularFrontendBase.Infrastructure.Data.Factories;
2930
using QuestPDF.Infrastructure;
3031
using Sentry;
@@ -451,6 +452,10 @@ public void ConfigureDbContext(IServiceCollection services, string connectionStr
451452
"eform-backend-configuration-plugin",
452453
"eform-angular-case-template-plugin");
453454

455+
var frontendBaseConnectionString = connectionString.Replace(
456+
"eform-backend-configuration-plugin",
457+
"Angular");
458+
454459
_connectionString = connectionString;
455460
services.AddDbContext<BackendConfigurationPnDbContext>(o =>
456461
o.UseMySql(connectionString, new MariaDbServerVersion(
@@ -492,6 +497,14 @@ public void ConfigureDbContext(IServiceCollection services, string connectionStr
492497
builder.MigrationsAssembly(PluginAssembly().FullName);
493498
}));
494499

500+
services.AddDbContext<BaseDbContext>(
501+
o => o.UseMySql(frontendBaseConnectionString, new MariaDbServerVersion(
502+
ServerVersion.AutoDetect(frontendBaseConnectionString)), mySqlOptionsAction: builder =>
503+
{
504+
builder.EnableRetryOnFailure();
505+
builder.MigrationsAssembly(PluginAssembly().FullName);
506+
}));
507+
495508
var chemicalsContextFactory = new ChemicalsContextFactory();
496509
var chemicalsDbContext = chemicalsContextFactory.CreateDbContext([chemicalBaseConnectionString]);
497510
chemicalsDbContext.Database.Migrate();

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Infrastructure/Models/Files/BackendConfigurationFileRequestModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ public class BackendConfigurationFileRequestModel : FilterAndSortModel
3939
public DateTime? DateFrom { get; set; }
4040

4141
public DateTime? DateTo { get; set; }
42+
43+
public string? SoftwareVersion { get; set; }
44+
45+
public string? Model { get; set; }
46+
47+
public string? Manufacturer { get; set; }
48+
49+
public string? OsVersion { get; set; }
4250
}

eFormAPI/Plugins/BackendConfiguration.Pn/BackendConfiguration.Pn/Services/BackendConfigurationFilesService/BackendConfigurationFilesService.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2424

2525
using System.Collections.Generic;
2626
using System.Security.Cryptography;
27+
using Microting.EformAngularFrontendBase.Infrastructure.Data;
2728

2829
namespace BackendConfiguration.Pn.Services.BackendConfigurationFilesService;
2930

@@ -51,20 +52,22 @@ public class BackendConfigurationFilesService : IBackendConfigurationFilesServic
5152
private readonly ILogger<BackendConfigurationTagsService> _logger;
5253
private readonly IBackendConfigurationLocalizationService _localizationService;
5354
private readonly BackendConfigurationPnDbContext _dbContext;
55+
private readonly BaseDbContext _baseDbContext;
5456
private readonly IUserService _userService;
5557
private readonly IEFormCoreService _coreHelper;
5658

5759
public BackendConfigurationFilesService(
5860
ILogger<BackendConfigurationTagsService> logger,
5961
IBackendConfigurationLocalizationService localizationService,
6062
BackendConfigurationPnDbContext dbContext,
61-
IUserService userService, IEFormCoreService coreHelper)
63+
IUserService userService, IEFormCoreService coreHelper, BaseDbContext baseDbContext)
6264
{
6365
_logger = logger;
6466
_localizationService = localizationService;
6567
_dbContext = dbContext;
6668
_userService = userService;
6769
_coreHelper = coreHelper;
70+
_baseDbContext = baseDbContext;
6871
}
6972

7073
public async Task<OperationDataResult<Paged<BackendConfigurationFilesModel>>> Index(
@@ -159,6 +162,18 @@ public async Task<OperationDataResult<Paged<BackendConfigurationFilesModel>>> In
159162
Total = total
160163
};
161164

165+
if (request.Model != null)
166+
{
167+
var currentUserAsync = await _userService.GetCurrentUserAsync();
168+
var currentUser = _baseDbContext.Users
169+
.Single(x => x.Id == currentUserAsync.Id);
170+
currentUser.ArchiveModel = request.Model;
171+
currentUser.ArchiveManufacturer = request.Manufacturer;
172+
currentUser.ArchiveSoftwareVersion = request.SoftwareVersion;
173+
currentUser.ArchiveOsVersion = request.OsVersion;
174+
await _baseDbContext.SaveChangesAsync();
175+
}
176+
162177
return new OperationDataResult<Paged<BackendConfigurationFilesModel>>(true, pagedFilesModel);
163178
}
164179
catch (Exception e)

0 commit comments

Comments
 (0)