Vorbereitung der Verwendung von SFTP aus dem Dakosy Projekt
This commit is contained in:
parent
fe2db2fa6b
commit
ca58d091c5
80
bsmd.dakosy/Properties/Settings.Designer.cs
generated
80
bsmd.dakosy/Properties/Settings.Designer.cs
generated
@ -13,7 +13,7 @@ namespace bsmd.dakosy.Properties {
|
|||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
@ -23,123 +23,75 @@ namespace bsmd.dakosy.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("dakosy")]
|
[global::System.Configuration.DefaultSettingValueAttribute("dakosy")]
|
||||||
public string SFTPSessionName {
|
public string SFTPSessionName {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["SFTPSessionName"]));
|
return ((string)(this["SFTPSessionName"]));
|
||||||
}
|
}
|
||||||
set {
|
|
||||||
this["SFTPSessionName"] = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("c:\\temp\\sftp_log.xml")]
|
[global::System.Configuration.DefaultSettingValueAttribute("c:\\temp\\sftp_log.xml")]
|
||||||
public string SFTPLog {
|
public string SFTPLog {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["SFTPLog"]));
|
return ((string)(this["SFTPLog"]));
|
||||||
}
|
}
|
||||||
set {
|
|
||||||
this["SFTPLog"] = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dakosy\\out")]
|
[global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dakosy\\out")]
|
||||||
public string SFTPOutDir {
|
public string SFTPOutDir {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["SFTPOutDir"]));
|
return ((string)(this["SFTPOutDir"]));
|
||||||
}
|
}
|
||||||
set {
|
|
||||||
this["SFTPOutDir"] = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dakosy\\in")]
|
[global::System.Configuration.DefaultSettingValueAttribute("e:\\temp\\dakosy\\in")]
|
||||||
public string SFTPInDir {
|
public string SFTPInDir {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["SFTPInDir"]));
|
return ((string)(this["SFTPInDir"]));
|
||||||
}
|
}
|
||||||
set {
|
|
||||||
this["SFTPInDir"] = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
|
||||||
public bool TestMode {
|
|
||||||
get {
|
|
||||||
return ((bool)(this["TestMode"]));
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
this["TestMode"] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("E:\\Tools\\WinScp\\WinSCP.com")]
|
[global::System.Configuration.DefaultSettingValueAttribute("E:\\Tools\\WinScp\\WinSCP.com")]
|
||||||
public string WINSCPFullPath {
|
public string WINSCPFullPath {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["WINSCPFullPath"]));
|
return ((string)(this["WINSCPFullPath"]));
|
||||||
}
|
}
|
||||||
set {
|
|
||||||
this["WINSCPFullPath"] = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("in/prod/ed02")]
|
[global::System.Configuration.DefaultSettingValueAttribute("in/prod/ed02")]
|
||||||
public string RemoteProdIncomingDir {
|
public string RemoteIncomingDir {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["RemoteProdIncomingDir"]));
|
return ((string)(this["RemoteIncomingDir"]));
|
||||||
}
|
|
||||||
set {
|
|
||||||
this["RemoteProdIncomingDir"] = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("in/test/ed02")]
|
|
||||||
public string RemoteTestIncomingDir {
|
|
||||||
get {
|
|
||||||
return ((string)(this["RemoteTestIncomingDir"]));
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
this["RemoteTestIncomingDir"] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("out/prod")]
|
[global::System.Configuration.DefaultSettingValueAttribute("out/prod")]
|
||||||
public string RemoteProdOutgoingDir {
|
public string RemoteOutgoingDir {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["RemoteProdOutgoingDir"]));
|
return ((string)(this["RemoteOutgoingDir"]));
|
||||||
}
|
|
||||||
set {
|
|
||||||
this["RemoteProdOutgoingDir"] = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("out/test")]
|
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||||
public string RemoteTestOutgoingDir {
|
public bool TestMode {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["RemoteTestOutgoingDir"]));
|
return ((bool)(this["TestMode"]));
|
||||||
}
|
|
||||||
set {
|
|
||||||
this["RemoteTestOutgoingDir"] = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,35 +2,29 @@
|
|||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="bsmd.dakosy.Properties" GeneratedClassName="Settings">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="bsmd.dakosy.Properties" GeneratedClassName="Settings">
|
||||||
<Profiles />
|
<Profiles />
|
||||||
<Settings>
|
<Settings>
|
||||||
<Setting Name="SFTPSessionName" Type="System.String" Scope="User">
|
<Setting Name="SFTPSessionName" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">dakosy</Value>
|
<Value Profile="(Default)">dakosy</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="SFTPLog" Type="System.String" Scope="User">
|
<Setting Name="SFTPLog" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">c:\temp\sftp_log.xml</Value>
|
<Value Profile="(Default)">c:\temp\sftp_log.xml</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="SFTPOutDir" Type="System.String" Scope="User">
|
<Setting Name="SFTPOutDir" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">e:\temp\dakosy\out</Value>
|
<Value Profile="(Default)">e:\temp\dakosy\out</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="SFTPInDir" Type="System.String" Scope="User">
|
<Setting Name="SFTPInDir" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">e:\temp\dakosy\in</Value>
|
<Value Profile="(Default)">e:\temp\dakosy\in</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="TestMode" Type="System.Boolean" Scope="User">
|
<Setting Name="WINSCPFullPath" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">True</Value>
|
|
||||||
</Setting>
|
|
||||||
<Setting Name="WINSCPFullPath" Type="System.String" Scope="User">
|
|
||||||
<Value Profile="(Default)">E:\Tools\WinScp\WinSCP.com</Value>
|
<Value Profile="(Default)">E:\Tools\WinScp\WinSCP.com</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="RemoteProdIncomingDir" Type="System.String" Scope="User">
|
<Setting Name="RemoteIncomingDir" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">in/prod/ed02</Value>
|
<Value Profile="(Default)">in/prod/ed02</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="RemoteTestIncomingDir" Type="System.String" Scope="User">
|
<Setting Name="RemoteOutgoingDir" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">in/test/ed02</Value>
|
|
||||||
</Setting>
|
|
||||||
<Setting Name="RemoteProdOutgoingDir" Type="System.String" Scope="User">
|
|
||||||
<Value Profile="(Default)">out/prod</Value>
|
<Value Profile="(Default)">out/prod</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="RemoteTestOutgoingDir" Type="System.String" Scope="User">
|
<Setting Name="TestMode" Type="System.Boolean" Scope="Application">
|
||||||
<Value Profile="(Default)">out/test</Value>
|
<Value Profile="(Default)">True</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@ -155,8 +155,7 @@ namespace bsmd.dakosy
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Message.NotificationClass.NOA_NOD:
|
case Message.NotificationClass.NOA_NOD:
|
||||||
bsmd.database.NOA_NOD noa_nod = aMessage.Elements[0] as bsmd.database.NOA_NOD;
|
if (!(aMessage.Elements[0] is bsmd.database.NOA_NOD noa_nod)) throw new ApplicationException("dbEntity is no NOA_NOD message!");
|
||||||
if (noa_nod == null) throw new ApplicationException("dbEntity is no NOA_NOD message!");
|
|
||||||
vList.Visit[0].NOA_NOD = new NOA_NOD();
|
vList.Visit[0].NOA_NOD = new NOA_NOD();
|
||||||
//vList.Visit[0].NOA_NOD.CallPurpose
|
//vList.Visit[0].NOA_NOD.CallPurpose
|
||||||
vList.Visit[0].NOA_NOD.EtaToKielCanalSpecified = noa_nod.ETAToKielCanal.HasValue;
|
vList.Visit[0].NOA_NOD.EtaToKielCanalSpecified = noa_nod.ETAToKielCanal.HasValue;
|
||||||
@ -800,7 +799,7 @@ namespace bsmd.dakosy
|
|||||||
if (!serializationFailed)
|
if (!serializationFailed)
|
||||||
{
|
{
|
||||||
// call sftp client to send
|
// call sftp client to send
|
||||||
sftp.Put(fileName, Properties.Settings.Default.RemoteProdIncomingDir);
|
SFtp.Put(fileName, Properties.Settings.Default.RemoteIncomingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
File.Delete(fileName);
|
File.Delete(fileName);
|
||||||
@ -865,12 +864,10 @@ namespace bsmd.dakosy
|
|||||||
}
|
}
|
||||||
|
|
||||||
// call sftp client to send
|
// call sftp client to send
|
||||||
sftp.Put(fileName,
|
SFtp.Put(fileName, Properties.Settings.Default.RemoteIncomingDir);
|
||||||
Properties.Settings.Default.TestMode ?
|
|
||||||
Properties.Settings.Default.RemoteTestIncomingDir : Properties.Settings.Default.RemoteProdIncomingDir);
|
|
||||||
|
|
||||||
// remove sent file if not test mode
|
// remove sent file if not test mode
|
||||||
if (!Properties.Settings.Default.TestMode)
|
// if (!Properties.Settings.Default.TestMode)
|
||||||
File.Delete(fileName);
|
File.Delete(fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,20 +21,17 @@ using bsmd.database;
|
|||||||
|
|
||||||
namespace bsmd.dakosy
|
namespace bsmd.dakosy
|
||||||
{
|
{
|
||||||
public class Response
|
public static class Response
|
||||||
{
|
{
|
||||||
private static ILog _log = LogManager.GetLogger(typeof(Request));
|
private static readonly ILog _log = LogManager.GetLogger(typeof(Request));
|
||||||
|
|
||||||
public static void ReadAll()
|
public static void ReadAll()
|
||||||
{
|
{
|
||||||
// SFTP verbindung öffnen und alle Dateien herunterladen
|
// SFTP verbindung öffnen und alle Dateien herunterladen
|
||||||
|
|
||||||
string localDir = Properties.Settings.Default.SFTPInDir;
|
string localDir = Properties.Settings.Default.SFTPInDir;
|
||||||
|
string remoteDir = Properties.Settings.Default.RemoteOutgoingDir;
|
||||||
|
|
||||||
string remoteDir = Properties.Settings.Default.TestMode ?
|
SFtp.GetAll(remoteDir);
|
||||||
Properties.Settings.Default.RemoteTestOutgoingDir : Properties.Settings.Default.RemoteProdOutgoingDir;
|
|
||||||
|
|
||||||
sftp.GetAll(remoteDir);
|
|
||||||
|
|
||||||
// lokale Dateien verarbeiten
|
// lokale Dateien verarbeiten
|
||||||
foreach (string inputFile in Directory.GetFiles(localDir))
|
foreach (string inputFile in Directory.GetFiles(localDir))
|
||||||
@ -48,7 +45,7 @@ namespace bsmd.dakosy
|
|||||||
File.Delete(inputFile); // alternativ: move to archive folder
|
File.Delete(inputFile); // alternativ: move to archive folder
|
||||||
}
|
}
|
||||||
// remote Dateien löschen
|
// remote Dateien löschen
|
||||||
sftp.RemoveProcessedFile(remoteDir, Path.GetFileName(inputFile));
|
SFtp.RemoveProcessedFile(remoteDir, Path.GetFileName(inputFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,13 +67,11 @@ namespace bsmd.dakosy
|
|||||||
eDeclarationMessageInterchangeBodyEdiResponseList responseList = eDeclaration.InterchangeBody.Item as eDeclarationMessageInterchangeBodyEdiResponseList;
|
eDeclarationMessageInterchangeBodyEdiResponseList responseList = eDeclaration.InterchangeBody.Item as eDeclarationMessageInterchangeBodyEdiResponseList;
|
||||||
foreach(EdiResponse ediResponse in responseList.EdiResponse)
|
foreach(EdiResponse ediResponse in responseList.EdiResponse)
|
||||||
{
|
{
|
||||||
|
if (!Guid.TryParseExact(ediResponse.LocalReferenceNumber, "N", out Guid localReferenceId))
|
||||||
Guid localReferenceId, messageReferenceId;
|
|
||||||
if (!Guid.TryParseExact(ediResponse.LocalReferenceNumber, "N", out localReferenceId))
|
|
||||||
{
|
{
|
||||||
_log.ErrorFormat("unable to parse local reference number {0}", ediResponse.LocalReferenceNumber);
|
_log.ErrorFormat("unable to parse local reference number {0}", ediResponse.LocalReferenceNumber);
|
||||||
}
|
}
|
||||||
if (!Guid.TryParseExact(ediResponse.PreviousMessageNumber, "N", out messageReferenceId))
|
if (!Guid.TryParseExact(ediResponse.PreviousMessageNumber, "N", out Guid messageReferenceId))
|
||||||
{
|
{
|
||||||
_log.ErrorFormat("unable to parse message reference id {0}", ediResponse.MessageHeader.MessageReferenceNumber);
|
_log.ErrorFormat("unable to parse message reference id {0}", ediResponse.MessageHeader.MessageReferenceNumber);
|
||||||
}
|
}
|
||||||
@ -126,8 +121,8 @@ namespace bsmd.dakosy
|
|||||||
foreach (ResponseError responseError in ediResponse.Errors)
|
foreach (ResponseError responseError in ediResponse.Errors)
|
||||||
{
|
{
|
||||||
MessageError messageError = new MessageError();
|
MessageError messageError = new MessageError();
|
||||||
int errCode;
|
|
||||||
if (Int32.TryParse(responseError.ErrorCode, out errCode))
|
if (Int32.TryParse(responseError.ErrorCode, out int errCode))
|
||||||
messageError.ErrorCode = errCode;
|
messageError.ErrorCode = errCode;
|
||||||
else
|
else
|
||||||
_log.WarnFormat("cannot parse error code [{0}]", responseError.ErrorCode);
|
_log.WarnFormat("cannot parse error code [{0}]", responseError.ErrorCode);
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
<section name="bsmd.dakosy.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
|
<section name="bsmd.dakosy.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
<userSettings>
|
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup><applicationSettings>
|
||||||
<bsmd.dakosy.Properties.Settings>
|
<bsmd.dakosy.Properties.Settings>
|
||||||
<setting name="SFTPSessionName" serializeAs="String">
|
<setting name="SFTPSessionName" serializeAs="String">
|
||||||
<value>dakosy</value>
|
<value>dakosy</value>
|
||||||
@ -19,24 +19,18 @@
|
|||||||
<setting name="SFTPInDir" serializeAs="String">
|
<setting name="SFTPInDir" serializeAs="String">
|
||||||
<value>e:\temp\dakosy\in</value>
|
<value>e:\temp\dakosy\in</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="TestMode" serializeAs="String">
|
|
||||||
<value>True</value>
|
|
||||||
</setting>
|
|
||||||
<setting name="WINSCPFullPath" serializeAs="String">
|
<setting name="WINSCPFullPath" serializeAs="String">
|
||||||
<value>E:\Tools\WinScp\WinSCP.com</value>
|
<value>E:\Tools\WinScp\WinSCP.com</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="RemoteProdIncomingDir" serializeAs="String">
|
<setting name="RemoteIncomingDir" serializeAs="String">
|
||||||
<value>in/prod/ed02</value>
|
<value>in/prod/ed02</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="RemoteTestIncomingDir" serializeAs="String">
|
<setting name="RemoteOutgoingDir" serializeAs="String">
|
||||||
<value>in/test/ed02</value>
|
|
||||||
</setting>
|
|
||||||
<setting name="RemoteProdOutgoingDir" serializeAs="String">
|
|
||||||
<value>out/prod</value>
|
<value>out/prod</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="RemoteTestOutgoingDir" serializeAs="String">
|
<setting name="TestMode" serializeAs="String">
|
||||||
<value>out/test</value>
|
<value>True</value>
|
||||||
</setting>
|
</setting>
|
||||||
</bsmd.dakosy.Properties.Settings>
|
</bsmd.dakosy.Properties.Settings>
|
||||||
</userSettings>
|
</applicationSettings>
|
||||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
</configuration>
|
||||||
|
|||||||
@ -70,14 +70,14 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Request.cs" />
|
<Compile Include="Request.cs" />
|
||||||
<Compile Include="Response.cs" />
|
<Compile Include="Response.cs" />
|
||||||
<Compile Include="sftp.cs" />
|
<Compile Include="SFtp.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\bsmdKey.snk" />
|
<None Include="..\bsmdKey.snk" />
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>PublicSettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -14,14 +14,18 @@ using System.Xml;
|
|||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using log4net;
|
||||||
|
|
||||||
namespace bsmd.dakosy
|
namespace bsmd.dakosy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hilfsklasse zur Kommunikation via SFTP. Wir machen es uns hier leicht und verwenden das beliebte WINSCP im
|
/// Hilfsklasse zur Kommunikation via SFTP. Wir machen es uns hier leicht und verwenden das beliebte WINSCP im
|
||||||
/// Process-Modus. (http://winscp.net/eng/docs/guide_dotnet)
|
/// Process-Modus. (http://winscp.net/eng/docs/guide_dotnet)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class sftp
|
public static class SFtp
|
||||||
{
|
{
|
||||||
|
private static readonly ILog _log = LogManager.GetLogger(typeof(SFtp));
|
||||||
|
|
||||||
public static void Put(string filename, string targetDir)
|
public static void Put(string filename, string targetDir)
|
||||||
{
|
{
|
||||||
Process winscp = new Process();
|
Process winscp = new Process();
|
||||||
@ -47,8 +51,11 @@ namespace bsmd.dakosy
|
|||||||
winscp.StandardInput.WriteLine(string.Format("mv {0} {1}", filename, dotlessFilename));
|
winscp.StandardInput.WriteLine(string.Format("mv {0} {1}", filename, dotlessFilename));
|
||||||
winscp.StandardInput.Close();
|
winscp.StandardInput.Close();
|
||||||
|
|
||||||
// Collect all output (not used in this example)
|
// Collect all output
|
||||||
string output = winscp.StandardOutput.ReadToEnd();
|
string output = winscp.StandardOutput.ReadToEnd();
|
||||||
|
_log.Info(output);
|
||||||
|
output = winscp.StandardError.ReadToEnd();
|
||||||
|
_log.Warn(output);
|
||||||
|
|
||||||
// Wait until WinSCP finishes
|
// Wait until WinSCP finishes
|
||||||
winscp.WaitForExit();
|
winscp.WaitForExit();
|
||||||
@ -110,8 +117,11 @@ namespace bsmd.dakosy
|
|||||||
winscp.StandardInput.WriteLine("get *.xml");
|
winscp.StandardInput.WriteLine("get *.xml");
|
||||||
winscp.StandardInput.Close();
|
winscp.StandardInput.Close();
|
||||||
|
|
||||||
// Collect all output (not used in this example)
|
// Collect all output
|
||||||
string output = winscp.StandardOutput.ReadToEnd();
|
string output = winscp.StandardOutput.ReadToEnd();
|
||||||
|
_log.Info(output);
|
||||||
|
output = winscp.StandardError.ReadToEnd();
|
||||||
|
_log.Warn(output);
|
||||||
|
|
||||||
// Wait until WinSCP finishes
|
// Wait until WinSCP finishes
|
||||||
winscp.WaitForExit();
|
winscp.WaitForExit();
|
||||||
@ -139,8 +149,11 @@ namespace bsmd.dakosy
|
|||||||
winscp.StandardInput.WriteLine("rm " + filename);
|
winscp.StandardInput.WriteLine("rm " + filename);
|
||||||
winscp.StandardInput.Close();
|
winscp.StandardInput.Close();
|
||||||
|
|
||||||
// Collect all output (not used in this example)
|
// Collect all output
|
||||||
string output = winscp.StandardOutput.ReadToEnd();
|
string output = winscp.StandardOutput.ReadToEnd();
|
||||||
|
_log.Info(output);
|
||||||
|
output = winscp.StandardError.ReadToEnd();
|
||||||
|
_log.Warn(output);
|
||||||
|
|
||||||
// Wait until WinSCP finishes
|
// Wait until WinSCP finishes
|
||||||
winscp.WaitForExit();
|
winscp.WaitForExit();
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using log4net;
|
using log4net;
|
||||||
using bsmd.database;
|
using bsmd.database;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace bsmd.dbh
|
namespace bsmd.dbh
|
||||||
{
|
{
|
||||||
@ -67,7 +68,26 @@ namespace bsmd.dbh
|
|||||||
// remove files from output folder to archive folder
|
// remove files from output folder to archive folder
|
||||||
|
|
||||||
// receive files from remote host
|
// receive files from remote host
|
||||||
|
// SFTP verbindung öffnen und alle Dateien herunterladen
|
||||||
|
string localDir = bsmd.dakosy.Properties.Settings.Default.SFTPInDir;
|
||||||
|
string remoteDir = bsmd.dakosy.Properties.Settings.Default.RemoteOutgoingDir;
|
||||||
|
|
||||||
|
bsmd.dakosy.SFtp.GetAll(remoteDir);
|
||||||
|
|
||||||
|
// lokale Dateien verarbeiten
|
||||||
|
foreach (string inputFile in Directory.GetFiles(localDir))
|
||||||
|
{
|
||||||
|
if (!ResponseUtil.Read(inputFile))
|
||||||
|
{
|
||||||
|
_log.ErrorFormat("Error reading input file {0}", inputFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.Delete(inputFile); // alternativ: move to archive folder
|
||||||
|
}
|
||||||
|
// remote Dateien löschen
|
||||||
|
bsmd.dakosy.SFtp.RemoveProcessedFile(remoteDir, Path.GetFileName(inputFile));
|
||||||
|
}
|
||||||
// process result files
|
// process result files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,5 +8,9 @@ namespace bsmd.dbh
|
|||||||
{
|
{
|
||||||
internal static class ResponseUtil
|
internal static class ResponseUtil
|
||||||
{
|
{
|
||||||
|
internal static bool Read(string inputFile)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,6 +84,10 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\bsmd.dakosy\bsmd.dakosy.csproj">
|
||||||
|
<Project>{6255f8c4-b0b5-4e77-860e-10ebcd7b368f}</Project>
|
||||||
|
<Name>bsmd.dakosy</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\bsmd.database\bsmd.database.csproj">
|
<ProjectReference Include="..\bsmd.database\bsmd.database.csproj">
|
||||||
<Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project>
|
<Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project>
|
||||||
<Name>bsmd.database</Name>
|
<Name>bsmd.database</Name>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user