Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

イベントログ送信時のイベントログ削除処理の実装漏れ対応 #1083

Merged
2 commits merged into from
Jul 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

using System;
using System.Threading.Tasks;
using Android.Content;
using Android.Runtime;
using AndroidX.Work;
using Covid19Radar.Common;
using Covid19Radar.Repository;
using Covid19Radar.Services;
using Covid19Radar.Services.Logs;
using Java.Util.Concurrent;
Expand Down Expand Up @@ -66,6 +68,7 @@ public class BackgroundWorker : Worker
{
private Lazy<ILoggerService> _loggerService => new Lazy<ILoggerService>(() => ContainerLocator.Current.Resolve<ILoggerService>());
private Lazy<IEventLogService> _eventLogService => new Lazy<IEventLogService>(() => ContainerLocator.Current.Resolve<IEventLogService>());
private Lazy<IEventLogRepository> _eventLogRepository => new Lazy<IEventLogRepository>(() => ContainerLocator.Current.Resolve<IEventLogRepository>());

public BackgroundWorker(Context context, WorkerParameters workerParams) : base(context, workerParams)
{
Expand All @@ -76,14 +79,25 @@ public override Result DoWork()
{
var loggerService = _loggerService.Value;
var eventLogService = _eventLogService.Value;
var eventLogRepository = _eventLogRepository.Value;

loggerService.StartMethod();

try
{
eventLogService.SendAllAsync(
AppConstants.EventLogMaxRequestSizeInBytes,
AppConstants.EventLogMaxRetry);
_ = Task.Run(async () =>
{
loggerService.Info("Start event log submission background work.");

await eventLogRepository.RotateAsync(
AppConstants.EventLogFileExpiredSeconds);

await eventLogService.SendAllAsync(
AppConstants.EventLogMaxRequestSizeInBytes,
AppConstants.EventLogMaxRetry);

loggerService.Info("Start event log submission background work.");
});
return Result.InvokeSuccess();
}
catch (Exception exception)
Expand Down