initial add
This commit is contained in:
59
Fab2ApprovalSystem/Misc/FTPWrapper.cs
Normal file
59
Fab2ApprovalSystem/Misc/FTPWrapper.cs
Normal file
@ -0,0 +1,59 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user