My query is can i enable rebex communication logging to track the connection issues. Also where i can place the code in the existing connectivity/upload code
connectivity code
private void ConnectSftp(ref Sftp objSFTP)
{
try
{
Common.WriteLogService("ConnectSftp()-Process Started", "", false);
SftpConnectionState IsActive = null;
string[] sSFTPHost = ConfigurationSettings.AppSettings["SFTPHost"].Split('|');
string Active = string.Empty;
if (objSFTP == null)
{
objSFTP = new Sftp();
}
//--------------------------------------------------
// IsActive = objSFTP.GetConnectionState(); //--- commented by mathew for SFTP Rebex connectivity issue on 20240516 -
//if (IsActive == null || IsActive.Connected == false)
//{
Common.WriteLogService("ConnectSftp()-SFTP Connectivity Process via Socket Started", "", false);
objSFTP.SetSocketFactory(MySocketFactory.Instance);
objSFTP.Connect(sSFTPHost[0], int.Parse(sSFTPHost[1]));
objSFTP.Login(sSFTPHost[2], sSFTPHost[3]);
Common.WriteLogService("ConnectSftp()-Successfully via Socket connected with SFTP Host", "", false);
//}
try
{
SetSFTPStatus("C", 2);
}
catch { }
Common.WriteLogService("ConnectSftp()-Process Completed", "", false);
}
catch (Exception ex)
{
//--- try catch block added on 20240516
try
{
objSFTP.Disconnect();
Common.WriteLogService("ConnectSftp()-SFTP connection disconnected", "", false);
}
catch (Exception ex1)
{
Common.WriteLogService("ConnectSftp()-Error while disconnecting to SFTP: Exception:" + ex1.Message
+ ",Inner Exception:" + ex1.InnerException + ",Stack Trace:" + ex1.StackTrace, "", true);
}
objSFTP = null; // added on 20240516
Common.WriteLogService("ConnectSftp()-Error while calling ConnectSftp(): Exception:" + ex.Message
+ ",Inner Exception:" + ex.InnerException + ",Stack Trace:" + ex.StackTrace, "", true);
try
{
SetSFTPStatus("E", 2);
}
catch { }
}
}
upload code
public void Upload()
{
try
{
variableIsUploadLiveSetTime = DateTime.Now;
objSFTPBLL = new DAL_SFTPEngine();
DataSet dsUploadFileList = objSFTPBLL.GetFTPFileDetails("U");
if (dsUploadFileList.Tables[0].Rows.Count > 0)
{
string FileList = "File Uploads" + Environment.NewLine;
foreach (DataRow drU in dsUploadFileList.Tables[0].Rows)
{
string strFTPUploadId = drU["SFTPFileId"].ToString();
string strFileType = drU["FileType"].ToString();
string strFileName = drU["FileName"].ToString();
string strMode = drU["Mode"].ToString();
string strStatus = drU["Status"].ToString();
FileList += strFileName;
if (SFTP_Upload_Rebex(strFTPUploadId, strFileType, strFileName, strMode, strStatus))
{
FileList += strFileName + " Upload Succeeded" + Environment.NewLine;
objSFTPBLL.UpdateFTPFileUploadQueueDtls(strFTPUploadId, "C");
string source = GetFilePath("FP") + "" + strFileName;
string destination = GetFilePath("FPDONE") + "" + strFileName;
File.Move(source, destination);
}
else
{
FileList += strFileName + " Uploading Failed " + Environment.NewLine;
}
}
//Common.WriteLogService(FileList,"",false);
DisConnectSftp(ref uSftp);
}
}
catch (Exception ex)
{
Common.WriteLogService(ex.Message, ex.StackTrace, true);
SetSFTPStatus("E", 2);
}
}