Skip to content

Commit cb6a0ba

Browse files
committed
UPDATE: complete server localizer exception -> Ws.Desktop.Api
1 parent dfc1963 commit cb6a0ba

File tree

39 files changed

+286
-171
lines changed

39 files changed

+286
-171
lines changed

.editorconfig

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ trim_trailing_whitespace = true
1515
dotnet_sort_system_directives_first = true
1616
dotnet_separate_import_directive_groups = false
1717

18-
# [**/{Migrations}/**]
19-
# generated_code = true
18+
[**/{Migrations}/**]
19+
generated_code = true
2020

2121
[**.{html,css,scss,js,cshtml,razor,json}]
2222
indent_size = 2
@@ -137,4 +137,5 @@ dotnet_naming_symbols.types.applicable_accessibilities = public, internal, priva
137137
# Roslynator
138138
dotnet_diagnostic.rcs1123.severity = none
139139
dotnet_diagnostic.rcs1001.severity = none
140-
dotnet_diagnostic.rcs1003.severity = none
140+
dotnet_diagnostic.rcs1003.severity = none
141+
dotnet_diagnostic.ca1824.severity = none

Src/Apps/Desktop/ScalesDesktop/GlobalUsings.cs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
global using Refit;
1616

1717
// 4. Internal
18-
global using ScalesDesktop.Source.Shared.Services;
1918
global using ScalesDesktop.Source.Shared.Localization;
2019
global using ScalesDesktop.Source.Shared.Services.Endpoints;
2120
global using ScalesDesktop.Source.Shared.Services.Stores;

Src/Apps/Desktop/ScalesDesktop/MauiProgram.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Microsoft.Extensions.Configuration;
44
using Microsoft.Extensions.Logging;
55
using ScalesDesktop.Source.Shared.Extensions;
6-
using ScalesDesktop.Source.Shared.Refit;
76
using ScalesDesktop.Source.Shared.Services.Devices;
87
using Ws.Shared.Extensions;
98

@@ -16,7 +15,6 @@ public static MauiAppBuilder CreateMauiApp()
1615
MauiAppBuilder builder = MauiApp.CreateBuilder();
1716

1817
builder.SetupLocalizer();
19-
builder.Services.AddTransient<HostNameMessageHandler>();
2018
builder.RegisterRefitClients();
2119
builder.UseMauiApp<App>().UseFullScreen();
2220

@@ -26,9 +24,10 @@ public static MauiAppBuilder CreateMauiApp()
2624
builder.Services.AddMauiBlazorWebView();
2725

2826
builder.Services
27+
.AddRefitEndpoints<IScalesDesktopAssembly>()
28+
.AddDelegatingHandlers<IScalesDesktopAssembly>()
2929
.AddScoped<HtmlRenderer>()
3030
.AddScoped<IPrintingService, PrintingService>()
31-
.AddRefitEndpoints<IScalesDesktopAssembly>()
3231
.AddFluentUIComponents(c => c.ValidateClassNames = false);
3332

3433
#if DEBUG
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Globalization;
2+
3+
namespace ScalesDesktop.Source.Shared;
4+
5+
public class AcceptLanguageHandler : DelegatingHandler
6+
{
7+
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
8+
{
9+
string currentCulture = CultureInfo.CurrentUICulture.Name;
10+
request.Headers.AcceptLanguage.Add(new(currentCulture));
11+
return await base.SendAsync(request, cancellationToken);
12+
}
13+
}

Src/Apps/Desktop/ScalesDesktop/Source/Shared/Localization/ApplicationResources.Designer.cs

-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Src/Apps/Desktop/ScalesDesktop/Source/Shared/Localization/ApplicationResources.en-US.resx

-18
Original file line numberDiff line numberDiff line change
@@ -287,24 +287,6 @@
287287
<data name="LabelsPrintingToastDescription" xml:space="preserve">
288288
<value>Printed labels are removed from the list</value>
289289
</data>
290-
<data name="LabelGenExcInvalid" xml:space="preserve">
291-
<value>Label validation error</value>
292-
</data>
293-
<data name="LabelGenExcBarcodeInvalid" xml:space="preserve">
294-
<value>Barcode generation error</value>
295-
</data>
296-
<data name="LabelGenExcTemplateNotFound" xml:space="preserve">
297-
<value>The template was not found</value>
298-
</data>
299-
<data name="LabelGenExcBarcodeVariableNotFound" xml:space="preserve">
300-
<value>Barcode variables are not defined</value>
301-
</data>
302-
<data name="LabelGenExcStorageMethodNotFound" xml:space="preserve">
303-
<value>The storage method is not set</value>
304-
</data>
305-
<data name="LabelGenExcExchangeFailed" xml:space="preserve">
306-
<value>Integration error with 1C</value>
307-
</data>
308290
<data name="СolPalletProductDt" xml:space="preserve">
309291
<value>Date of pallet products</value>
310292
</data>

Src/Apps/Desktop/ScalesDesktop/Source/Shared/Localization/ApplicationResources.resx

-18
Original file line numberDiff line numberDiff line change
@@ -287,24 +287,6 @@
287287
<data name="LabelsPrintingToastDescription" xml:space="preserve">
288288
<value/>
289289
</data>
290-
<data name="LabelGenExcInvalid" xml:space="preserve">
291-
<value/>
292-
</data>
293-
<data name="LabelGenExcBarcodeInvalid" xml:space="preserve">
294-
<value/>
295-
</data>
296-
<data name="LabelGenExcTemplateNotFound" xml:space="preserve">
297-
<value/>
298-
</data>
299-
<data name="LabelGenExcBarcodeVariableNotFound" xml:space="preserve">
300-
<value/>
301-
</data>
302-
<data name="LabelGenExcStorageMethodNotFound" xml:space="preserve">
303-
<value/>
304-
</data>
305-
<data name="LabelGenExcExchangeFailed" xml:space="preserve">
306-
<value/>
307-
</data>
308290
<data name="СolPalletProductDt" xml:space="preserve">
309291
<value/>
310292
</data>

Src/Apps/Desktop/ScalesDesktop/Source/Shared/Localization/ApplicationResources.ru-RU.resx

-18
Original file line numberDiff line numberDiff line change
@@ -284,24 +284,6 @@
284284
<data name="LabelsPrintingToastDescription" xml:space="preserve">
285285
<value>Распечатанные этикетки убираются из списка</value>
286286
</data>
287-
<data name="LabelGenExcInvalid" xml:space="preserve">
288-
<value>Ошибка валидации этикетки</value>
289-
</data>
290-
<data name="LabelGenExcBarcodeInvalid" xml:space="preserve">
291-
<value>Ошибка генерации штрихкода</value>
292-
</data>
293-
<data name="LabelGenExcTemplateNotFound" xml:space="preserve">
294-
<value>Шаблон не найден</value>
295-
</data>
296-
<data name="LabelGenExcBarcodeVariableNotFound" xml:space="preserve">
297-
<value>Переменные штрихкода не определенны</value>
298-
</data>
299-
<data name="LabelGenExcStorageMethodNotFound" xml:space="preserve">
300-
<value>Способ хранения не установлен</value>
301-
</data>
302-
<data name="LabelGenExcExchangeFailed" xml:space="preserve">
303-
<value>Ошибка интеграции с 1С</value>
304-
</data>
305287
<data name="СolPalletProductDt" xml:space="preserve">
306288
<value>Дата продукции на паллете</value>
307289
</data>

Src/Apps/Desktop/Ws.Desktop.Api/Program.cs

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Globalization;
12
using System.Net.Mime;
23
using System.Text.Json;
34
using Microsoft.AspNetCore.Mvc.Authorization;
@@ -6,8 +7,12 @@
67
using Ws.Desktop.Api.App.Shared.Middlewares;
78
using Ws.Labels.Service;
89
using Ws.Labels.Service.Settings;
10+
using Ws.Shared.Constants;
911
using Ws.Shared.Extensions;
1012

13+
CultureInfo.DefaultThreadCurrentCulture = Cultures.Ru;
14+
CultureInfo.DefaultThreadCurrentUICulture = Cultures.Ru;
15+
1116
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
1217

1318
PalychSettings palychSettings = builder.Configuration
@@ -23,6 +28,7 @@
2328
builder.Services
2429
.AddEfCore()
2530
.AddLabelsServices(palychSettings)
31+
.AddLocalization()
2632
.AddHelpers<IDesktopApiAssembly>()
2733
.AddMiddlewares<IDesktopApiAssembly>()
2834
.AddApiServices<IDesktopApiAssembly>();
@@ -49,11 +55,19 @@
4955

5056
builder.Services.AddHttpContextAccessor();
5157

58+
CultureInfo[] supportedCultures = [Cultures.Ru, Cultures.En];
59+
RequestLocalizationOptions localizationOptions = new()
60+
{
61+
SupportedCultures = supportedCultures,
62+
SupportedUICultures = supportedCultures,
63+
DefaultRequestCulture = new(Cultures.En.Name)
64+
};
5265

5366
WebApplication app = builder.Build();
5467

5568
app.UseHttpsRedirection();
5669
app.MapControllers();
70+
app.UseRequestLocalization(localizationOptions);
5771
app.UseAuthentication();
5872
app.UseAuthorization();
5973

Src/Apps/Exchange/Ws.PalychExchange.Api/App/Features/Brands/Dto/BrandDto.cs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public sealed record BrandDto : BaseDto
1717
};
1818
}
1919

20-
2120
// ReSharper disable once ClassNeverInstantiated.Global
2221
internal sealed class BrandDtoValidator : AbstractValidator<BrandDto>
2322
{

Src/Apps/Exchange/Ws.PalychExchange.Api/App/Features/Pallets/Dto/PalletUpdateDto.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace Ws.PalychExchange.Api.App.Features.Pallets.Dto;
22

3-
43
[XmlRoot(ElementName = "PalletType")]
54
public class PalletUpdateWrapper
65
{

Src/Apps/Exchange/Ws.PalychExchange.Api/App/Features/Plus/Impl/PluApiService.private.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Ws.PalychExchange.Api.App.Features.Plus.Impl;
1111

12-
1312
internal sealed partial class PluApiService
1413
{
1514
#region Resolve uniques db
@@ -34,7 +33,7 @@ private void ResolveUniqueNumberDb(HashSet<PluDto> dtos)
3433

3534
#endregion
3635

37-
private void SetDefaultFk(HashSet<PluDto> validDtos)
36+
private static void SetDefaultFk(HashSet<PluDto> validDtos)
3837
{
3938
foreach (PluDto i in validDtos)
4039
{
@@ -79,7 +78,7 @@ private void DeleteNestings(HashSet<PluDto> dtos)
7978
{
8079
List<object> parameters = uidToDelete.Select((uid, index) => new SqlParameter($"@p{index}", uid)).ToList<object>();
8180

82-
string inClause = string.Join(", ", parameters.Select((p, index) => $"@p{index}"));
81+
string inClause = string.Join(", ", parameters.Select((_, index) => $"@p{index}"));
8382
string sql = $@"
8483
DELETE FROM [dbo].[ARMS_PLUS_FK] WHERE PLU_UID IN ({inClause});
8584
UPDATE [PRINT].[LABELS] SET PLU_UID = NULL WHERE PLU_UID IN ({inClause});

Src/Apps/Exchange/Ws.PalychExchange.Api/Program.cs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
#pragma warning restore CA1416
3333

34-
3534
WebApplication app = builder.Build();
3635

3736
app.UseMiddleware<LoggingMiddleware>();

Src/Apps/Mobile/ScalesMobile/Platforms/Android/MainActivity.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33

44
namespace ScalesMobile;
55
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
6-
public class MainActivity : MauiAppCompatActivity
7-
{
8-
}
6+
public class MainActivity : MauiAppCompatActivity;

Src/Apps/Web/Ws.DeviceControl.Models/Features/Devices/Printers/Queries/PrinterDto.cs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public record PrinterDto
1414
[JsonPropertyName("productionSite")]
1515
public required ProxyDto ProductionSite { get; set; }
1616

17-
1817
[JsonPropertyName("ip")]
1918
[JsonConverter(typeof(IpAddressJsonConverter))]
2019
public required IPAddress Ip { get; set; }

Src/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
3-
<PropertyGroup>
3+
<PropertyGroup Label="Default settings">
44
<Configurations>DevelopVS;ReleaseVS</Configurations>
55
<Platforms>x64</Platforms>
66
<TargetFramework>net8.0</TargetFramework>

Src/Directory.Packages.props

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<ItemGroup>
77
<!--Microsoft.Extensions-->
88
<PackageVersion Include="Microsoft.Extensions.Localization" Version="8.0.8" />
9+
<PackageVersion Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.8" />
910
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
1011
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
1112
<!--Blazor-->

Src/Infrastructure/Ws.Database.EntityFramework/DbContext.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Ws.Database.EntityFramework.Shared.Interceptors;
33
using Ws.Database.EntityFramework.Shared.Models;
44

5-
65
namespace Ws.Database.EntityFramework;
76

87
public class WsDbContext : DbContext

Src/Infrastructure/Ws.Database.EntityFramework/Entities/Print/Labels/LabelEntity.cs

-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ public sealed class LabelEntity : EfEntityBase
77
public Guid? PalletId { get; set; }
88
public PalletEntity? Pallet { get; set; }
99

10-
1110
public Guid? PluId { get; set; }
1211
public PluEntity? Plu { get; set; }
1312

14-
1513
public Guid LineId { get; set; }
1614
public LineEntity Line { get; set; } = null!;
1715

Src/Infrastructure/Ws.Database.EntityFramework/Entities/Print/LabelsZpl/LabelZplMapConfig.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ namespace Ws.Database.EntityFramework.Entities.Print.LabelsZpl;
22

33
internal sealed class LabelZplMapConfig : IEntityTypeConfiguration<LabelZplEntity>
44
{
5-
65
public void Configure(EntityTypeBuilder<LabelZplEntity> builder)
76
{
87
#region Base

Src/Infrastructure/Ws.Database.EntityFramework/Entities/Ref/PalletMen/PalletManMapConfig.cs

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ namespace Ws.Database.EntityFramework.Entities.Ref.PalletMen;
22

33
internal sealed class PalletManMapConfig : IEntityTypeConfiguration<PalletManEntity>
44
{
5-
65
public void Configure(EntityTypeBuilder<PalletManEntity> builder)
76
{
87
#region Base
@@ -13,7 +12,6 @@ public void Configure(EntityTypeBuilder<PalletManEntity> builder)
1312
.HasDatabaseName($"UQ_{SqlTables.PalletMen}__FIO")
1413
.IsUnique();
1514

16-
1715
builder.HasIndex(e => e.Uid1C)
1816
.HasDatabaseName($"UQ_{SqlTables.PalletMen}__UID_1C")
1917
.IsUnique();

Src/Infrastructure/Ws.Database.EntityFramework/Entities/Ref/Warehouses/WarehouseMapConfig.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace Ws.Database.EntityFramework.Entities.Ref.Warehouses;
22

3-
43
internal sealed class WarehouseMapConfig : IEntityTypeConfiguration<WarehouseEntity>
54
{
65
public void Configure(EntityTypeBuilder<WarehouseEntity> builder)

Src/Libs/Ws.Barcodes/Shared/Models/BarcodeResult.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ public sealed record BarcodeResult(string Barcode)
88
public readonly string Clean = string.Concat(Barcode.Where(char.IsDigit));
99
public readonly string Zpl = string.Concat(Barcode.Where("0123456789#".Contains));
1010
public readonly string Friendly = string.Concat(Barcode.Where("0123456789()".Contains));
11-
};
11+
}

0 commit comments

Comments
 (0)