// Common.WriteLogService(" Downloading SFTP file: " + FileName + " Started!","",false);
ConnectSftp(ref dSftp);
if (!(File.Exists(LocalPath + FileName) == true && File.ReadAllBytes(LocalPath + FileName).Length > 0))
{
try
{
dSftp.GetFile(GetServerFilePath(FileType).ToString() + "//" + FileName, LocalPath + FileName);
ExtendedLogger.Log("Downloading SFTP file: " + FileName + " Finished!", 4, "SFTP_Download");
//Common.WriteLogService(" Downloading SFTP file: " + FileName + " Finished!", "", false);
}
catch (Exception ex)
{
Common.WriteLogService(" Downloading SFTP file: " + FileName + " Failed!", "", false);
Common.WriteLogService(ex.Message,ex.StackTrace,true);
}
}
else
{
Common.WriteLogService(" SFTP file: " + FileName + " downloaded already !", "", false);
}
return true;
}
catch (Exception ex)
{
Common.WriteLogService(" Downloading SFTP file: " + FileName + " Error:" + ex.Message,ex.StackTrace,true);
if (File.ReadAllBytes(LocalPath + FileName).Length <= 0)
{
try
{
dSftp.GetFile(GetServerFilePath(FileType).ToString() + "//OLD//" +FileName, LocalPath + FileName);
return true;
}
catch
{
//dSftp.Disconnect();commented by aswathy vm for SFTP Download issue after Server Upgrade - 17112020
return false;
}
}
else
{
//dSftp.Disconnect();commented by aswathy vm for SFTP Download issue after Server Upgrade - 17112020
return false;
}
}
}
#endregion