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

Commit

Permalink
Add log
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-dev004 committed Jul 7, 2022
1 parent a09ea73 commit 426c6ee
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Covid19Radar/Covid19Radar/Repository/EventLogRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public Task<List<EventLog>> GetLogsAsync(
public Task AddEventNotifiedAsync(
long maxSize = AppConstants.EventLogMaxRequestSizeInBytes
);

public Task<bool> IsExist();
}

public class EventLogRepository : IEventLogRepository
Expand Down Expand Up @@ -305,6 +307,48 @@ private void RemoveAllAsyncInternal()
_loggerService.EndMethod();
}
}

public async Task<bool> IsExist()
{
_loggerService.StartMethod();

await _semaphore.WaitAsync();

try
{
return IsExistInternal();
}
finally
{
_semaphore.Release();

_loggerService.EndMethod();
}
}

private bool IsExistInternal()
{
_loggerService.StartMethod();
try
{
if (!Directory.Exists(_basePath))
{
return false;
}

string[] filesInDirectory = Directory.GetFiles(_basePath);
if (filesInDirectory.Length == 0)
{
return false;
}

return true;
}
finally
{
_loggerService.EndMethod();
}
}
}

public class EventContentExposureNotified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ IEssentialsService essentialsService
this.closeApplicationService = closeApplicationService;
}

public override async void Initialize(INavigationParameters parameters)
{
loggerService.StartMethod();
base.Initialize(parameters);

try
{
bool isExistEventLogs = await _eventLogRepository.IsExist();
loggerService.Info($"isExistEventLogs: {isExistEventLogs}");
}
finally
{
loggerService.EndMethod();
}
}

public IAsyncCommand OnEventLogSend => new AsyncCommand(async () =>
{
loggerService.StartMethod();
Expand Down

0 comments on commit 426c6ee

Please sign in to comment.