public async Task <bool> ExportRewards(string type) { var inputPath = _configuration.GetSection("FileExport:inputFilePath").Value; var outputPath = _configuration.GetSection("FileExport:outputFilePath").Value; var publicKeyPath = _configuration.GetSection("FileExport:publicKeyFilePath").Value; var sftpHost = _configuration.GetSection("Sftp:Host").Value; var sftpPort = int.Parse(_configuration.GetSection("Sftp:Port").Value); var sftpUsername = _configuration.GetSection("Sftp:Username").Value; var sftpKeyPath = _configuration.GetSection("Sftp:KeyPath").Value; var exportfileName = _configuration.GetSection("FileExport:" + type + "EncryptedFileName").Value; var startDate = DateTime.Now.AddDays(-1); var query = _context.UserTransactions.Where(x => x.Type == type && x.Date >= startDate && x.Date <= DateTime.Now); var dataList = new Object(); if (type == "burn") { dataList = await query.ProjectTo <BurnReport>(_mapper.ConfigurationProvider).ToListAsync(); } else { dataList = await query.ProjectTo <SubscribeReport>(_mapper.ConfigurationProvider).ToListAsync(); } var dataJson = JsonSerializer.Serialize(dataList); var txtFile = _fileExporter.JsonStringToTXT(dataJson, exportfileName + "Unencrypted_", inputPath); var encryptedFile = _fileExporter.PgpEncryptedFile(txtFile, exportfileName + DateTime.Now.ToString("yyyyMMdd"), outputPath, Environment.CurrentDirectory + publicKeyPath); // _sFTPUploader.UploadSFTPFile(sftpHost, sftpUsername, sftpPort, sftpKeyPath, exportfileName + DateTime.Now.ToString("yyyyMMdd"), outputPath); return(true); }
public async Task GetUsersReport() { var inputPath = _configuration.GetSection("FileExport:inputFilePath").Value; var outputPath = _configuration.GetSection("FileExport:outputFilePath").Value; var publicKeyPath = _configuration.GetSection("FileExport:publicKeyFilePath").Value; var exportfileName = _configuration.GetSection("FileExport:UserReportFileName").Value; var sftpHost = _configuration.GetSection("Sftp:Host").Value; var sftpPort = int.Parse(_configuration.GetSection("Sftp:Port").Value); var sftpUsername = _configuration.GetSection("Sftp:Username").Value; var sftpKeyPath = _configuration.GetSection("Sftp:KeyPath").Value; var startDate = DateTime.Now.AddDays(-1); var users = await _context.Users .Where(c => c.LastModificationDate >= startDate && c.LastModificationDate <= DateTime.Now) .ProjectTo <UserReportDto>(_mapper.ConfigurationProvider).ToListAsync(); var usersJson = JsonConvert.SerializeObject(users); var txtFile = _fileExporter.JsonStringToTXT(usersJson, "Profile_Daily_Unencrypted_", inputPath); var encryptedFile = _fileExporter.PgpEncryptedFile(txtFile, exportfileName + DateTime.Now.ToString("yyyyMMdd"), outputPath, Environment.CurrentDirectory + publicKeyPath); //_sFTPUploader.UploadSFTPFile(sftpHost, sftpUsername, sftpPort, sftpKeyPath, exportfileName + DateTime.Now.ToString("yyyyMMdd"), outputPath); }