noch mehr Funktionen zum Versenden hinzugefügt

This commit is contained in:
Daniel Schick 2022-10-31 18:16:38 +01:00
parent 02c619011c
commit c59e9f7e76
6 changed files with 65 additions and 18 deletions

View File

@ -976,7 +976,7 @@ namespace bsmd.dakosy
// all das nur weil die Blödmänner andere Enums angelegt haben!!!
static IdentityDocumentType CrewDocumentFromNSWEnumeration(byte nswValue)
internal static IdentityDocumentType CrewDocumentFromNSWEnumeration(byte nswValue)
{
switch(nswValue)
{
@ -990,7 +990,7 @@ namespace bsmd.dakosy
}
}
static GeneralCargoType CargoTypeFromNSWEnumeration(byte nswValue)
internal static GeneralCargoType CargoTypeFromNSWEnumeration(byte nswValue)
{
switch(nswValue)
{
@ -1005,7 +1005,7 @@ namespace bsmd.dakosy
}
}
static WasteDisposalDeliveryType WDDTypeFromNSWEnumeration(byte nswValue)
internal static WasteDisposalDeliveryType WDDTypeFromNSWEnumeration(byte nswValue)
{
switch(nswValue)
{
@ -1017,13 +1017,13 @@ namespace bsmd.dakosy
}
}
static CargoHandlingType CHTFromNSWEnumeration(byte nswValue)
internal static CargoHandlingType CHTFromNSWEnumeration(byte nswValue)
{
if (nswValue == 0) return CargoHandlingType.LOAD;
return CargoHandlingType.DISCHARGE;
}
static ShippingAreaType SATFromNSWEnumeration(byte nswValue)
internal static ShippingAreaType SATFromNSWEnumeration(byte nswValue)
{
switch (nswValue)
{
@ -1035,6 +1035,5 @@ namespace bsmd.dakosy
#endregion
}
}

View File

@ -31,7 +31,7 @@ namespace bsmd.dakosy
string localDir = Properties.Settings.Default.SFTPInDir;
string remoteDir = Properties.Settings.Default.RemoteOutgoingDir;
SFtp.GetAll(remoteDir, localDir);
SFtp.TransmitAll(remoteDir, localDir, SFtp.Direction.INCOMING);
// lokale Dateien verarbeiten
foreach (string inputFile in Directory.GetFiles(localDir))

View File

@ -26,6 +26,12 @@ namespace bsmd.dakosy
{
private static readonly ILog _log = LogManager.GetLogger(typeof(SFtp));
public enum Direction
{
INCOMING,
OUTGOING
}
public static void Put(string filename, string targetDir)
{
Process winscp = new Process();
@ -95,7 +101,7 @@ namespace bsmd.dakosy
}
public static void GetAll(string remoteDir, string localDir)
public static void TransmitAll(string remoteDir, string localDir, Direction direction)
{
Process winscp = new Process();
winscp.StartInfo.FileName = Properties.Settings.Default.WINSCPFullPath;
@ -114,7 +120,10 @@ namespace bsmd.dakosy
// winscp.StandardInput.WriteLine("ls");
if (remoteDir != null)
winscp.StandardInput.WriteLine("cd " + remoteDir);
winscp.StandardInput.WriteLine("get *.xml");
if(direction == Direction.INCOMING)
winscp.StandardInput.WriteLine("get *.xml");
if(direction == Direction.OUTGOING)
winscp.StandardInput.WriteLine("put *.xml");
winscp.StandardInput.Close();
// Collect all output

View File

@ -36,10 +36,11 @@ namespace bsmd.dbh
}
string messageFile = RequestUtil.CreateMessageFile(core, message);
if (messageFile != null)
{
// move file to output directory
File.Move(messageFile, Properties.Settings.Default.OutgoingFolder);
}
else
{
@ -64,16 +65,19 @@ namespace bsmd.dbh
public static void SendAndReceive()
{
// sent unsent messages in output folder
// remove files from output folder to archive folder
bsmd.dakosy.SFtp.TransmitAll(Properties.Settings.Default.RemoteIncomingFolder, Properties.Settings.Default.OutgoingFolder, dakosy.SFtp.Direction.OUTGOING);
// move files from output folder to archive folder
foreach(string sentFile in Directory.GetFiles(Properties.Settings.Default.OutgoingFolder))
{
_log.InfoFormat("sent {0}", sentFile);
File.Move(sentFile, Properties.Settings.Default.OutgoingArchiveFolder);
}
// receive files from remote host
// SFTP verbindung öffnen und alle Dateien herunterladen
string localDir = Properties.Settings.Default.OutgoingFolder;
bsmd.dakosy.SFtp.TransmitAll(Properties.Settings.Default.RemoteOutgoingFolder, Properties.Settings.Default.IncomingFolder, dakosy.SFtp.Direction.INCOMING);
bsmd.dakosy.SFtp.GetAll(Properties.Settings.Default.RemoteOutgoingFolder, Properties.Settings.Default.IncomingFolder);
foreach (string inputFile in Directory.GetFiles(localDir))
foreach (string inputFile in Directory.GetFiles(Properties.Settings.Default.IncomingFolder))
{
// lokale Dateien verarbeiten
if (!ResponseUtil.Read(inputFile))

26
bsmd.dbh/misc/sshkey.ppk Normal file
View File

@ -0,0 +1,26 @@
PuTTY-User-Key-File-2: ssh-rsa
Encryption: aes256-cbc
Comment: rsa-key-20221031 dbh
Public-Lines: 6
AAAAB3NzaC1yc2EAAAABJQAAAQEAujJ+P4nqiTRaPaorpEyBJvhjsU1DQ19GD4wN
XvbawZg2qHnIoEFt/0QItgHo5qij72cU//A2owCgEMrvaiXwPKk/ey1f1O3VlP3G
uK92aSYx+kwvqzjq4NKG2d/OVImcu5Y7KF7WaPNs44F7KvPI/yu5ZSJ7eL3+d9Tz
8Xtkw0Cca121+KrSmrEEot0PPjvl/ltrRc/MZwpdHBaahhfdNShAFYW9YI9/Jx8R
MNZ8PvN6KqE0GRvyYoNWQ839LJTmV4TDovc/Q30OaxvkpfV/JVzlSK34NZf4L2Av
V84PNSSMMmS1ZyPlIivol4iorsMFL4ExWCD5RFT1TJtnHAT7sQ==
Private-Lines: 14
mM+ucPZK+y4ZO6hmpxOzLGKsGtLQK0Z61x0KO9e68jq7gdyaj1uNRbE8k6hwgs+a
/3yh9BJRG70F/FR0xcwhxVbyd38JFKjhb5l563twAzql1iM3+rfeM+HB3pRGHr/a
glK2MVErCIaP+DxpwoAgMBP8PlpRkbwA9kJ7AxqfN/CtIbjPRVxONBIAcEWG2hY4
TCS7OVS4GMQA/hObytd8rGgFF/f6VSpMwHM2+ztXNgj6+oFHJh2/SrxkM2zVdj65
I63Z83oxM3fxW69oJ7od5jXGHq2qzd5PQoUz+W5WSwjWsDKDYH2T7xNc5oI0D0g6
cYtNnwHRmbj+oxVgyqORn9kVCM4MaRlqJVU5y9C29fEIUPl7x4Xc5b7SppSm3HOd
vrLtftP7OlYjAapm+G3hMMZ0V5kSOxllx9wSEPYQW9qxWIgEZ0ytladFrwHu2NGa
xTRNn4JjP6LkfadJLdTciVwRujTmteLGq7dqSrrv2GasoWPMMON8usgxCLokBapP
fz/4hPxrKxJNbjkcbbsVn3UhY2OfeUiAgW5R+ms1MKHw3hewI3+psDVfYuJeFsFp
A/J453Ypmi/89hqMkPOCpy7aBWO9SorRFakYgeE1Tq0dYChK8+nu60MpALBU1mQK
xXhj9fUYEF7voJcsWN0ZH3oAo+/840blQuV4o+DQZVFwcKzpOOm1wPzQZgvqcz4c
lTnLg/xUiMKNpVdzc8sJz3nIlXkDo6rrkIVMf40ergGz7So6nij9DIh/ZsUeQ6Yb
z23HtiG0s17O3iJLSOgoFcXrAh9sWkp0k/Vg8aVvLVzp2VBLC9cejRFBRG1z0lM2
qYv61RQLU2r3b8gpqQzBT1HLgy8N7I51AhfUUlBHs+UxdXy0NrYvS4eEiXksGK/5
Private-MAC: 91ed4f6f4074a6c4ebb5cacf53e39989e737774e

9
bsmd.dbh/misc/sshkey.pub Normal file
View File

@ -0,0 +1,9 @@
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20221031 dbh"
AAAAB3NzaC1yc2EAAAABJQAAAQEAujJ+P4nqiTRaPaorpEyBJvhjsU1DQ19GD4wN
XvbawZg2qHnIoEFt/0QItgHo5qij72cU//A2owCgEMrvaiXwPKk/ey1f1O3VlP3G
uK92aSYx+kwvqzjq4NKG2d/OVImcu5Y7KF7WaPNs44F7KvPI/yu5ZSJ7eL3+d9Tz
8Xtkw0Cca121+KrSmrEEot0PPjvl/ltrRc/MZwpdHBaahhfdNShAFYW9YI9/Jx8R
MNZ8PvN6KqE0GRvyYoNWQ839LJTmV4TDovc/Q30OaxvkpfV/JVzlSK34NZf4L2Av
V84PNSSMMmS1ZyPlIivol4iorsMFL4ExWCD5RFT1TJtnHAT7sQ==
---- END SSH2 PUBLIC KEY ----