Jonathan Ouellette 580e90f6a2 initial add
2022-09-27 14:10:30 -07:00

59 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Fab2ApprovalSystem.Misc
{
class FTPWrapper
{
string m_OutputFile;
string m_DestinationFileName;
//Functions functions = new Functions();
public FTPWrapper(string outputFile, string destinationFileName)
{
m_OutputFile = outputFile;
m_DestinationFileName = destinationFileName;
}
/// <summary>
///
/// </summary>
public void FTPToSPN()
{
FTP ftpLib = new FTP();
//Connect to the FTP server
try
{
ftpLib.Connect(Functions.FTPServer(), Functions.FTPUser(), Functions.FTPPassword());
}
catch (Exception ec)
{
Functions.WriteEvent("Listener - ProcessFile(): FTP Connection Error " + m_OutputFile + " - " + ec.Source +
": " + ec.Message, System.Diagnostics.EventLogEntryType.Error);
}
//Upload the file
try
{
int pct = 0;
ftpLib.OpenUpload(m_OutputFile, m_DestinationFileName);
while (ftpLib.DoUpload() > 0)
pct = (int)((ftpLib.BytesTotal * 100) / ftpLib.FileSize);
Functions.WriteEvent(m_OutputFile + " was sucessfully FTPed to SPN.", System.Diagnostics.EventLogEntryType.Information);
}
catch (Exception eu)
{
Functions.WriteEvent("MRB - FTPToSPN(): FTP Upload Error " + m_OutputFile + " - " + eu.Source +
": " + eu.Message, System.Diagnostics.EventLogEntryType.Error);
throw new Exception(eu.Source + ": " + eu.Message);
}
}
}
}