private async Task <bool> RunExportAndUploadTaskAsync <T>(List <T> _list) where T : class { string _methodName = nameof(RunExportAndUploadTaskAsync); bool success = false; if (_list != null && _list.Count > 0) { ExcelMapper <T> _excel_mapper = new ExcelMapper <T>(); bool exported = await _excel_mapper.Export(_list); if (exported) { string exportedFile = _excel_mapper.OldPath; this.Logger.WriteEntry($"On {_methodName}: Excel File ({Path.GetFileName(exportedFile)}) created and exported successfully", EventLogEntryType.Information); ClienteFTP ftpClient = new ClienteFTP(exportedFile); bool wasUploaded = ftpClient.UploadFile(); if (wasUploaded) { this.Logger.WriteEntry($"On {_methodName}: {Path.GetFileName(exportedFile)} uploaded successfully", EventLogEntryType.Information); } success = exported && wasUploaded; } } return(success); }
private static async Task <bool> RunExportAndUploadTaskAsync <T>(List <T> _list) where T : class { bool exported = false; if (_list != null && _list.Count > 0) { ExcelMapper <T> _excel_mapper = new ExcelMapper <T>(); exported = await _excel_mapper.Export(_list); if (exported) { string exportedFile = _excel_mapper.OldPath; Console.WriteLine(exportedFile); ClienteFTP ftpClient = new ClienteFTP(exportedFile); bool wasUploaded = ftpClient.UploadFile(); if (wasUploaded) { Console.WriteLine($"{Path.GetFileName(exportedFile)} uploaded successfully"); } } } return(exported); }