Align .editorconfig files Move Controller logic to DMO classes GlobalVars.AppSettings = Models.AppSettings.GetFromConfigurationManager(); Question EditorConfig Project level editorconfig Format White Spaces AppSetting when EnvironmentVariable not set Corrective Actions Tests Schedule Actions Tests DMO Tests Controller Tests Get ready to use VSCode IDE
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System;
|
|
|
|
using Fab2ApprovalSystem.Models;
|
|
|
|
namespace Fab2ApprovalSystem.Misc;
|
|
|
|
internal class FTPWrapper {
|
|
|
|
private readonly string _OutputFile;
|
|
private readonly string _DestinationFileName;
|
|
private readonly AppSettings _AppSettings;
|
|
|
|
public FTPWrapper(AppSettings appSettings, string outputFile, string destinationFileName) {
|
|
_OutputFile = outputFile;
|
|
_AppSettings = appSettings;
|
|
_DestinationFileName = destinationFileName;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void FTPToSPN() {
|
|
FTP ftpLib = new();
|
|
|
|
//Connect to the FTP server
|
|
try {
|
|
ftpLib.Connect(_AppSettings.FTPServer, _AppSettings.FTPUser, _AppSettings.FTPPassword);
|
|
} catch (Exception ec) {
|
|
Functions.WriteEvent(_AppSettings, "Listener - ProcessFile(): FTP Connection Error " + _OutputFile + " - " + ec.Source +
|
|
": " + ec.Message, System.Diagnostics.EventLogEntryType.Error);
|
|
}
|
|
|
|
//Upload the file
|
|
try {
|
|
int pct = 0;
|
|
ftpLib.OpenUpload(_OutputFile, _DestinationFileName);
|
|
while (ftpLib.DoUpload() > 0)
|
|
pct = (int)((ftpLib.BytesTotal * 100) / ftpLib.FileSize);
|
|
Functions.WriteEvent(_AppSettings, _OutputFile + " was sucessfully FTPed to SPN.", System.Diagnostics.EventLogEntryType.Information);
|
|
} catch (Exception eu) {
|
|
Functions.WriteEvent(_AppSettings, "MRB - FTPToSPN(): FTP Upload Error " + _OutputFile + " - " + eu.Source +
|
|
": " + eu.Message, System.Diagnostics.EventLogEntryType.Error);
|
|
throw new Exception(eu.Source + ": " + eu.Message);
|
|
}
|
|
|
|
}
|
|
|
|
} |