Improve code readability
This commit is contained in:
@@ -18,14 +18,12 @@ public class HandleDbBackup
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
var json = (await _db.Find(new BsonDocument()).ToListAsync()).ToJson();
|
var json = (await _db.Find(new BsonDocument()).ToListAsync()).ToJson();
|
||||||
|
|
||||||
var bytes = Encoding.UTF8.GetBytes(json);
|
var bytes = Encoding.UTF8.GetBytes(json);
|
||||||
var stream = new MemoryStream(bytes);
|
var stream = new MemoryStream(bytes);
|
||||||
|
var postCount = await _db.CountDocumentsAsync(new BsonDocument());
|
||||||
await _bot.SendDocument(adminId, InputFile.FromStream(stream, "backup.json"),
|
var caption =
|
||||||
"Backup of your collection\nCreated at " +
|
$"Backup of the database {dbname}<br>Created at {DateTime.Now:yyyy-MM-dd HH:mm:ss}<br>Current post count: {postCount}";
|
||||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss" + "\nCurrent post count: " + _db.CountDocumentsAsync(new BsonDocument())),
|
await _bot.SendDocument(adminId, InputFile.FromStream(stream, "backup.json"), caption, ParseMode.Html);
|
||||||
ParseMode.Html);
|
|
||||||
logger?.LogInformation("Backup sent");
|
logger?.LogInformation("Backup sent");
|
||||||
}
|
}
|
||||||
catch(Exception ex){
|
catch(Exception ex){
|
||||||
|
Reference in New Issue
Block a user