public async Task ReadDbFileAsync(string path, Action <DbFileRow> action) { using var reader = new DbFileReader(path); DbFileRow?row; while ((row = await reader.ReadRowAsync()) is not null) { action(row); } }
public void ReadDbFile(string path, Action <DbFileRow> action) { using var reader = new DbFileReader(path); DbFileRow?row; while ((row = reader.ReadRow()) is not null) { action(row); } }
public async Task ImportDriveFile(ImportFile msg) { if (string.IsNullOrEmpty(msg.FileId)) { _log.Warning("Attempt to download an empty file id"); return; } _log.Info($"Starting importing file [{msg.Type}] from {msg.FileId}"); var zipFile = await _googleService.DownloadFile(msg.FileId); if (zipFile is null) { _log.Error("Can't download file from google drive"); return; } var fileName = _zipService.ExtractZip(zipFile); var reader = new DbFileReader(fileName); DbFileRow?row; while ((row = reader.ReadRow()) != null) { SendToSerializer(row, msg.Type); } File.Delete(zipFile); var dir = Path.GetDirectoryName(fileName); if (dir is not null) { Directory.Delete(dir, true); } _log.Info($"Finish importing file [{msg.Type}] from {msg.FileId}"); }