From 440031ce01a2939d453b82c7d00ef7b148a724a1 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 10 Jul 2026 16:15:56 +0330 Subject: [PATCH] #494 backup ftp server --- .../Implementation/RecitationService.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index a6db5af4..73d2f8d9 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -1450,6 +1450,31 @@ namespace RMuseum.Services.Implementationa await ftpClient.Disconnect(); } + if (bool.Parse(Configuration.GetSection("BackupFTPServer")["UploadEnabled"])) + { + var ftpClient = new AsyncFtpClient + ( + Configuration.GetSection("BackupFTPServer")["Host"], + Configuration.GetSection("BackupFTPServer")["Username"], + Configuration.GetSection("BackupFTPServer")["Password"] + ); + ftpClient.ValidateCertificate += FtpClient_ValidateCertificate; + await ftpClient.AutoConnect(); + ftpClient.Config.RetryAttempts = 3; + + if (true == await ftpClient.FileExists($"{Configuration.GetSection("BackupFTPServer")["RootPath"]}{narration.RemoteXMLFilePath}")) + { + await ftpClient.DeleteFile($"{Configuration.GetSection("BackupFTPServer")["RootPath"]}{narration.RemoteXMLFilePath}"); + } + + if (true == await ftpClient.FileExists($"{Configuration.GetSection("BackupFTPServer")["RootPath"]}{narration.RemoteXMLFilePath}")) + { + await ftpClient.DeleteFile($"{Configuration.GetSection("BackupFTPServer")["RootPath"]}{narration.RemoteXMLFilePath}"); + } + + await ftpClient.Disconnect(); + } + string audioTitle = narration.AudioTitle; int GanjoorPostId = narration.GanjoorPostId; Guid userId = narration.OwnerId;