Skip to content

Commit 10923a9

Browse files
committed
logger service
1 parent 271fa73 commit 10923a9

11 files changed

Lines changed: 158 additions & 35 deletions

File tree

Source/ImageProcessing.App.PresentationLayer/Presenters/ColorMatrixPresenter.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Drawing;
34
using System.Threading.Tasks;
45

@@ -13,6 +14,7 @@
1314
using ImageProcessing.App.ServiceLayer.Providers.Rgb.Interface;
1415
using ImageProcessing.App.ServiceLayer.Services.LockerService.Operation.Interface;
1516
using ImageProcessing.App.ServiceLayer.Services.Pipeline.Block.Implementation;
17+
using ImageProcessing.App.ServiceLayer.Win.Services.Logger.Interface;
1618
using ImageProcessing.Microkernel.MVP.Aggregator.Subscriber;
1719
using ImageProcessing.Microkernel.MVP.Presenter.Implementation;
1820

@@ -27,15 +29,18 @@ internal sealed class ColorMatrixPresenter : BasePresenter<IColorMatrixView, Col
2729
ISubscriber<RestoreFocusEventArgs>
2830
{
2931
private readonly IRgbProvider _provider;
30-
private readonly IAsyncOperationLocker _locker;
32+
private readonly ILoggerService _logger;
3133
private readonly IColorMatrixFactory _factory;
34+
private readonly IAsyncOperationLocker _locker;
3235

3336
public ColorMatrixPresenter(
34-
IRgbProvider provider,
3537
IAsyncOperationLocker locker,
36-
IColorMatrixFactory factory)
38+
IColorMatrixFactory factory,
39+
ILoggerService logger,
40+
IRgbProvider provider)
3741
{
3842
_provider = provider;
43+
_logger = logger;
3944
_factory = factory;
4045
_locker = locker;
4146
}
@@ -65,6 +70,7 @@ public async Task OnEventHandler(object publisher, ApplyColorMatrixEventArgs e)
6570
catch (Exception ex)
6671
{
6772
View.Tooltip(Errors.ApplyColorMatrix);
73+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
6874
}
6975
}
7076

@@ -90,6 +96,7 @@ public async Task OnEventHandler(object publisher, ApplyCustomColorMatrixEventAr
9096
catch (Exception ex)
9197
{
9298
View.Tooltip(Errors.ApplyCustomColorMatrix);
99+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
93100
}
94101
}
95102

@@ -107,6 +114,7 @@ public async Task OnEventHandler(object publisher, CustomColorMatrixEventArgs e)
107114
catch(Exception ex)
108115
{
109116
View.Tooltip(Errors.CustomColorMatrix);
117+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
110118
}
111119
}
112120

@@ -120,6 +128,7 @@ public async Task OnEventHandler(object publisher, ChangeColorMatrixEventArgs e)
120128
catch(Exception ex)
121129
{
122130
View.Tooltip(Errors.UpdateColorMatrix);
131+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
123132
}
124133
}
125134

@@ -142,6 +151,7 @@ await _locker.LockOperationAsync(() =>
142151
catch(Exception ex)
143152
{
144153
View.Tooltip(Errors.UpdatingViewModel);
154+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
145155
}
146156
}
147157

Source/ImageProcessing.App.PresentationLayer/Presenters/ConvolutionPresenter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Drawing;
34
using System.Threading.Tasks;
45

@@ -12,6 +13,7 @@
1213
using ImageProcessing.App.ServiceLayer.Providers.Interface.Convolution;
1314
using ImageProcessing.App.ServiceLayer.Services.LockerService.Operation.Interface;
1415
using ImageProcessing.App.ServiceLayer.Services.Pipeline.Block.Implementation;
16+
using ImageProcessing.App.ServiceLayer.Win.Services.Logger.Interface;
1517
using ImageProcessing.Microkernel.MVP.Aggregator.Subscriber;
1618
using ImageProcessing.Microkernel.MVP.Presenter.Implementation;
1719

@@ -23,14 +25,17 @@ internal sealed class ConvolutionPresenter : BasePresenter<IConvolutionView, Con
2325
ISubscriber<ContainerUpdatedEventArgs>,
2426
ISubscriber<RestoreFocusEventArgs>
2527
{
28+
private readonly ILoggerService _logger;
2629
private readonly IConvolutionProvider _provider;
2730
private readonly IAsyncOperationLocker _locker;
2831

2932
public ConvolutionPresenter(
33+
ILoggerService logger,
3034
IConvolutionProvider provider,
3135
IAsyncOperationLocker locker)
3236
{
3337
_provider = provider;
38+
_logger = logger;
3439
_locker = locker;
3540
}
3641

@@ -60,6 +65,7 @@ public async Task OnEventHandler(object publisher, ApplyConvolutionKernelEventAr
6065
catch(Exception ex)
6166
{
6267
View.Tooltip(Errors.ApplyConvolutionFilter);
68+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
6369
}
6470
}
6571

@@ -82,6 +88,7 @@ await _locker.LockOperationAsync(() =>
8288
catch(Exception ex)
8389
{
8490
View.Tooltip(Errors.UpdatingViewModel);
91+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
8592
}
8693
}
8794

Source/ImageProcessing.App.PresentationLayer/Presenters/DistributionPresenter.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Drawing;
34
using System.Globalization;
45
using System.Threading.Tasks;
@@ -14,6 +15,7 @@
1415
using ImageProcessing.App.ServiceLayer.Services.Bmp.Interface;
1516
using ImageProcessing.App.ServiceLayer.Services.LockerService.Operation.Interface;
1617
using ImageProcessing.App.ServiceLayer.Services.Pipeline.Block.Implementation;
18+
using ImageProcessing.App.ServiceLayer.Win.Services.Logger.Interface;
1719
using ImageProcessing.Microkernel.MVP.Aggregator.Subscriber;
1820
using ImageProcessing.Microkernel.MVP.Presenter.Implementation;
1921

@@ -30,15 +32,18 @@ internal sealed class DistributionPresenter : BasePresenter<IDistributionView, D
3032
ISubscriber<ContainerUpdatedEventArgs>
3133
{
3234
private readonly IBitmapService _service;
35+
private readonly ILoggerService _logger;
3336
private readonly IAsyncOperationLocker _locker;
3437
private readonly IBitmapLuminanceProvider _provider;
3538

3639
public DistributionPresenter(
3740
IBitmapService service,
41+
ILoggerService logger,
3842
IAsyncOperationLocker locker,
3943
IBitmapLuminanceProvider provider)
4044
{
4145
_locker = locker;
46+
_logger = logger;
4247
_service = service;
4348
_provider = provider;
4449
}
@@ -71,6 +76,7 @@ public async Task OnEventHandler(object publisher, TransformHistogramEventArgs e
7176
catch (Exception ex)
7277
{
7378
View.Tooltip(Errors.TransformHistogram);
79+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
7480
}
7581
}
7682

@@ -94,6 +100,7 @@ public async Task OnEventHandler(object publisher, ShuffleEventArgs e)
94100
catch(Exception ex)
95101
{
96102
View.Tooltip(Errors.Shuffle);
103+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
97104
}
98105
}
99106

@@ -112,6 +119,7 @@ public async Task OnEventHandler(object publisher, BuildRandomVariableFunctionEv
112119
catch (Exception ex)
113120
{
114121
View.Tooltip(Errors.BuildFunction);
122+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
115123
}
116124
}
117125

@@ -128,6 +136,7 @@ public async Task OnEventHandler(object publisher, ShowQualityMeasureMenuEventAr
128136
catch (Exception ex)
129137
{
130138
View.Tooltip(Errors.QualityHistogram);
139+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
131140
}
132141
}
133142

@@ -151,6 +160,7 @@ public async Task OnEventHandler(object publisher, GetRandomVariableInfoEventArg
151160
catch (Exception ex)
152161
{
153162
View.Tooltip(Errors.RandomVariableInfo);
163+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
154164
}
155165
}
156166

@@ -173,6 +183,7 @@ await _locker.LockOperationAsync(() =>
173183
catch (Exception ex)
174184
{
175185
View.Tooltip(Errors.UpdatingViewModel);
186+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
176187
}
177188
}
178189

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1+
using System;
2+
using System.Diagnostics;
13
using System.Threading.Tasks;
24

35
using ImageProcessing.App.PresentationLayer.ViewModels;
46
using ImageProcessing.App.PresentationLayer.Views;
57
using ImageProcessing.App.ServiceLayer.Win.Services.Histogram.Interface;
8+
using ImageProcessing.App.ServiceLayer.Win.Services.Logger.Interface;
69
using ImageProcessing.Microkernel.MVP.Presenter.Implementation;
710

811
namespace ImageProcessing.App.PresentationLayer.Presenters
912
{
1013
internal sealed class HistogramPresenter
1114
: BasePresenter<IHistogramView, HistogramViewModel>
1215
{
16+
private readonly ILoggerService _logger;
1317
private readonly IHistogramService _service;
1418

1519
public HistogramPresenter(
20+
ILoggerService logger,
1621
IHistogramService service)
1722
{
23+
_logger = logger;
1824
_service = service;
1925
}
2026

@@ -23,13 +29,20 @@ public override void Run(HistogramViewModel vm)
2329

2430
private async Task DoWorkBeforeShow(HistogramViewModel vm)
2531
{
26-
var info = await Task.Run(
27-
() => _service.BuildPlot(vm.Mode, vm.Source)
28-
).ConfigureAwait(true);
32+
try
33+
{
34+
var info = await Task.Run(
35+
() => _service.BuildPlot(vm.Mode, vm.Source)
36+
).ConfigureAwait(true);
2937

30-
View.DataChart.Series.Add(info.Plot);
31-
View.YAxisMaximum = (double)info.Max;
32-
View.Show();
38+
View.DataChart.Series.Add(info.Plot);
39+
View.YAxisMaximum = (double)info.Max;
40+
View.Show();
41+
}
42+
catch(Exception ex)
43+
{
44+
_logger.WriteEntry(ex.Message, EventLogEntryType.Error);
45+
}
3346
}
3447
}
3548
}

0 commit comments

Comments
 (0)