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

Commit

Permalink
Merge pull request #1083 from cocoa-mhlw/feature/rotate-android
Browse files Browse the repository at this point in the history
イベントログ送信時のイベントログ削除処理の実装漏れ対応
  • Loading branch information
cocoa-dev004 authored Jul 19, 2022
2 parents eaf5fed + 765f211 commit 68c4836
Showing 1 changed file with 17 additions and 3 deletions.
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("Complete event log submission background work.");
});
return Result.InvokeSuccess();
}
catch (Exception exception)
Expand Down

0 comments on commit 68c4836

Please sign in to comment.