diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj index abdb9013..c7ab8d4c 100644 --- a/ENI2/ENI2.csproj +++ b/ENI2/ENI2.csproj @@ -84,7 +84,7 @@ - 94D98790E3B6C4CC9F4B57C8FD305E3225894DF8 + F2C2D0164244EC89955EF50201EE24C2A300FF0B true diff --git a/bsmd.LockingService/bsmd.LockingService.csproj.user b/bsmd.LockingService/bsmd.LockingService.csproj.user index 3517ad61..afa33dd1 100644 --- a/bsmd.LockingService/bsmd.LockingService.csproj.user +++ b/bsmd.LockingService/bsmd.LockingService.csproj.user @@ -2,7 +2,7 @@ true - Release|Any CPU + Debug|Any CPU diff --git a/bsmd.dakosy/Response.cs b/bsmd.dakosy/Response.cs index ba55245a..61dc18c9 100644 --- a/bsmd.dakosy/Response.cs +++ b/bsmd.dakosy/Response.cs @@ -31,7 +31,7 @@ namespace bsmd.dakosy string localDir = Properties.Settings.Default.SFTPInDir; string remoteDir = Properties.Settings.Default.RemoteOutgoingDir; - SFtp.TransmitAll(remoteDir, localDir, SFtp.Direction.INCOMING); + SFtp.TransmitAll(remoteDir, localDir, SFtp.Direction.INCOMING, Properties.Settings.Default.SFTPSessionName); // lokale Dateien verarbeiten foreach (string inputFile in Directory.GetFiles(localDir)) diff --git a/bsmd.dakosy/sftp.cs b/bsmd.dakosy/sftp.cs index ddc0bec9..2b8b3694 100644 --- a/bsmd.dakosy/sftp.cs +++ b/bsmd.dakosy/sftp.cs @@ -101,7 +101,7 @@ namespace bsmd.dakosy } - public static void TransmitAll(string remoteDir, string localDir, Direction direction) + public static void TransmitAll(string remoteDir, string localDir, Direction direction, string sessionName) { Process winscp = new Process(); winscp.StartInfo.FileName = Properties.Settings.Default.WINSCPFullPath; @@ -109,13 +109,14 @@ namespace bsmd.dakosy winscp.StartInfo.UseShellExecute = false; winscp.StartInfo.RedirectStandardInput = true; winscp.StartInfo.RedirectStandardOutput = true; + winscp.StartInfo.RedirectStandardError = true; winscp.StartInfo.CreateNoWindow = true; winscp.Start(); // Feed in the scripting commands winscp.StandardInput.WriteLine("option batch abort"); winscp.StandardInput.WriteLine("option confirm off"); - winscp.StandardInput.WriteLine("open " + Properties.Settings.Default.SFTPSessionName); + winscp.StandardInput.WriteLine("open " + sessionName); winscp.StandardInput.WriteLine("lcd " + localDir); // winscp.StandardInput.WriteLine("ls"); if (remoteDir != null) @@ -124,6 +125,9 @@ namespace bsmd.dakosy winscp.StandardInput.WriteLine("get *.xml"); if(direction == Direction.OUTGOING) winscp.StandardInput.WriteLine("put *.xml"); + // move back up since winscp session remembers the last folder + winscp.StandardInput.WriteLine("cd .."); + winscp.StandardInput.WriteLine("cd .."); winscp.StandardInput.Close(); // Collect all output diff --git a/bsmd.database/DBManager.cs b/bsmd.database/DBManager.cs index e4d2c521..ed3c9426 100644 --- a/bsmd.database/DBManager.cs +++ b/bsmd.database/DBManager.cs @@ -1620,7 +1620,11 @@ namespace bsmd.database { this.CheckConnection(); cmd.Connection = this._con; - result = (int?)cmd.ExecuteScalar(); + object r = cmd.ExecuteScalar(); + if (r == null) { result = null; } + else if (r == DBNull.Value) { result = null; } + else { result = (int)r; } + } catch (SqlException ex) { diff --git a/bsmd.dbh/MessageController.cs b/bsmd.dbh/MessageController.cs index f57a0a4b..08978a50 100644 --- a/bsmd.dbh/MessageController.cs +++ b/bsmd.dbh/MessageController.cs @@ -48,8 +48,10 @@ namespace bsmd.dbh if (messageFile != null) { + string onlyFileName = Path.GetFileName(messageFile); + string moveTarget = Path.Combine(Properties.Settings.Default.OutgoingFolder, onlyFileName); // move file to output directory - File.Move(messageFile, Properties.Settings.Default.OutgoingFolder); + File.Move(messageFile, moveTarget); } else { @@ -74,17 +76,19 @@ namespace bsmd.dbh public static void SendAndReceive() { // sent unsent messages in output folder - bsmd.dakosy.SFtp.TransmitAll(Properties.Settings.Default.RemoteIncomingFolder, Properties.Settings.Default.OutgoingFolder, dakosy.SFtp.Direction.OUTGOING); + bsmd.dakosy.SFtp.TransmitAll(Properties.Settings.Default.RemoteIncomingFolder, Properties.Settings.Default.OutgoingFolder, dakosy.SFtp.Direction.OUTGOING, Properties.Settings.Default.SFTPSessionName); // 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); + string onlyFileName = Path.GetFileName(sentFile); + string moveTarget = Path.Combine(Properties.Settings.Default.OutgoingArchiveFolder, onlyFileName); + File.Move(sentFile, moveTarget); } // receive files from remote host // SFTP verbindung öffnen und alle Dateien herunterladen - bsmd.dakosy.SFtp.TransmitAll(Properties.Settings.Default.RemoteOutgoingFolder, Properties.Settings.Default.IncomingFolder, dakosy.SFtp.Direction.INCOMING); + bsmd.dakosy.SFtp.TransmitAll(Properties.Settings.Default.RemoteOutgoingFolder, Properties.Settings.Default.IncomingFolder, dakosy.SFtp.Direction.INCOMING, Properties.Settings.Default.SFTPSessionName); foreach (string inputFile in Directory.GetFiles(Properties.Settings.Default.IncomingFolder)) { diff --git a/bsmd.dbh/Properties/Settings.Designer.cs b/bsmd.dbh/Properties/Settings.Designer.cs index 8d0c6e35..dbf02fe4 100644 --- a/bsmd.dbh/Properties/Settings.Designer.cs +++ b/bsmd.dbh/Properties/Settings.Designer.cs @@ -34,7 +34,7 @@ namespace bsmd.dbh.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dbh\\out")] public string OutgoingFolder { get { return ((string)(this["OutgoingFolder"])); @@ -43,7 +43,7 @@ namespace bsmd.dbh.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dbh\\out_archive")] public string OutgoingArchiveFolder { get { return ((string)(this["OutgoingArchiveFolder"])); @@ -52,7 +52,7 @@ namespace bsmd.dbh.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dbh\\in")] public string IncomingFolder { get { return ((string)(this["IncomingFolder"])); @@ -61,7 +61,7 @@ namespace bsmd.dbh.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dbh\\in_archive")] public string IncomingArchiveFolder { get { return ((string)(this["IncomingArchiveFolder"])); diff --git a/bsmd.dbh/Properties/Settings.settings b/bsmd.dbh/Properties/Settings.settings index aad7d1c4..f3f78a19 100644 --- a/bsmd.dbh/Properties/Settings.settings +++ b/bsmd.dbh/Properties/Settings.settings @@ -6,16 +6,16 @@ 00003050 - + e:\temp\dbh\out - + e:\temp\dbh\out_archive - + e:\temp\dbh\in - + e:\temp\dbh\in_archive test/bsmd_2_dbh diff --git a/bsmd.dbh/RequestUtil.cs b/bsmd.dbh/RequestUtil.cs index 99908637..73f19307 100644 --- a/bsmd.dbh/RequestUtil.cs +++ b/bsmd.dbh/RequestUtil.cs @@ -1649,7 +1649,7 @@ namespace bsmd.dbh serializer.Serialize(tw, root); } - return filename; + return filePath; } catch(Exception ex) { diff --git a/bsmd.dbh/app.config b/bsmd.dbh/app.config index da6387f3..52806f8b 100644 --- a/bsmd.dbh/app.config +++ b/bsmd.dbh/app.config @@ -11,16 +11,16 @@ 00003050 - + e:\temp\dbh\out - + e:\temp\dbh\out_archive - + e:\temp\dbh\in - + e:\temp\dbh\in_archive test/bsmd_2_dbh