Aktuelle Woche kann manuell überschrieben werden
This commit is contained in:
BIN
09.12.2024.pdf
Normal file
BIN
09.12.2024.pdf
Normal file
Binary file not shown.
@@ -49,10 +49,41 @@
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\BouncyCastle.Cryptography.2.4.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Renci.SshNet, Version=2024.2.0.1, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SSH.NET.2024.2.0\lib\net462\Renci.SshNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Formats.Asn1, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Formats.Asn1.8.0.1\lib\net462\System.Formats.Asn1.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -119,6 +150,7 @@
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Gastro\Gastro.vbproj">
|
||||
|
||||
12
FTPUpload/Form1.Designer.vb
generated
12
FTPUpload/Form1.Designer.vb
generated
@@ -25,6 +25,7 @@ Partial Class Form1
|
||||
Me.btnUpload = New System.Windows.Forms.Button()
|
||||
Me.bntUploadAndClose = New System.Windows.Forms.Button()
|
||||
Me.Button1 = New System.Windows.Forms.Button()
|
||||
Me.Button2 = New System.Windows.Forms.Button()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'btnUpload
|
||||
@@ -54,11 +55,21 @@ Partial Class Form1
|
||||
Me.Button1.Text = "Do SQL!"
|
||||
Me.Button1.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Button2
|
||||
'
|
||||
Me.Button2.Location = New System.Drawing.Point(280, 362)
|
||||
Me.Button2.Name = "Button2"
|
||||
Me.Button2.Size = New System.Drawing.Size(200, 23)
|
||||
Me.Button2.TabIndex = 3
|
||||
Me.Button2.Text = "Aktuelle überschreiben"
|
||||
Me.Button2.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(800, 450)
|
||||
Me.Controls.Add(Me.Button2)
|
||||
Me.Controls.Add(Me.Button1)
|
||||
Me.Controls.Add(Me.bntUploadAndClose)
|
||||
Me.Controls.Add(Me.btnUpload)
|
||||
@@ -71,4 +82,5 @@ Partial Class Form1
|
||||
Friend WithEvents btnUpload As Button
|
||||
Friend WithEvents bntUploadAndClose As Button
|
||||
Friend WithEvents Button1 As Button
|
||||
Friend WithEvents Button2 As Button
|
||||
End Class
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Imports System.IO.File
|
||||
Imports System.Net.Mail
|
||||
Imports Renci.SshNet
|
||||
Imports System.IO
|
||||
|
||||
Public Class Form1
|
||||
|
||||
@@ -8,11 +10,12 @@ Public Class Form1
|
||||
Public PDFUploadPath As String = ""
|
||||
|
||||
Public DatumNextMonday As String
|
||||
Public DatumThisWeeksMonday As String
|
||||
Public Silent As Boolean = False
|
||||
|
||||
Public Shared HighwayFTPUser As String = "u78672691"
|
||||
Public Shared HighwayFTPPwd As String = "verag#2"
|
||||
Public Shared HighwayFTPSrv As String = "ftp://home546285429.1and1-data.host"
|
||||
Public Shared HighwayFTPPwd As String = "LmZAK6x!Ur6^7BaUkCV^5Zk*G"
|
||||
Public Shared HighwayFTPSrv As String = "home546285429.1and1-data.host"
|
||||
|
||||
Private Function LoadParameters()
|
||||
Try
|
||||
@@ -61,7 +64,7 @@ Public Class Form1
|
||||
End If
|
||||
End If
|
||||
|
||||
Upload2FTP(HighwayFTPSrv & "/speisekarte/Mittagsmenue.pdf", HighwayFTPUser, HighwayFTPPwd, anhang)
|
||||
Upload2SFTP(HighwayFTPSrv, 22, HighwayFTPUser, HighwayFTPPwd, anhang)
|
||||
End Function
|
||||
|
||||
|
||||
@@ -79,25 +82,51 @@ Public Class Form1
|
||||
Return (DatumNextMonday)
|
||||
End Function
|
||||
|
||||
Public Function Upload2FTP(server As String, user As String, pwd As String, file As String)
|
||||
Dim clsRequest As System.Net.FtpWebRequest =
|
||||
DirectCast(System.Net.WebRequest.Create(server), System.Net.FtpWebRequest)
|
||||
clsRequest.Credentials = New System.Net.NetworkCredential(user, pwd)
|
||||
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
|
||||
Public Function GetThisWeeksMonday()
|
||||
Dim datum As Date = Now.Date.AddDays(0)
|
||||
|
||||
' read in file...
|
||||
Dim bFile() As Byte = System.IO.File.ReadAllBytes(file)
|
||||
For i = 0 To 10
|
||||
If datum.DayOfWeek = 1 Then
|
||||
Exit For
|
||||
Else
|
||||
datum = datum.AddDays(-1)
|
||||
End If
|
||||
Next
|
||||
DatumThisWeeksMonday = datum.Date.ToString.Substring(0, 10)
|
||||
Return (DatumThisWeeksMonday)
|
||||
End Function
|
||||
|
||||
' upload file...
|
||||
Dim clsStream As System.IO.Stream =
|
||||
clsRequest.GetRequestStream()
|
||||
clsStream.Write(bFile, 0, bFile.Length)
|
||||
clsStream.Close()
|
||||
clsStream.Dispose()
|
||||
|
||||
If Silent = False Then MsgBox("Ok, erledigt.")
|
||||
sendMail("FTP Upload ausgeführt", "Der automatische Upload wurde ausgeführt. Datei: " & PDFUploadPath & DatumNextMonday & ".pdf")
|
||||
Public Function Upload2SFTP(server As String, port As Integer, user As String, pwd As String, filePath As String, Optional Silent As Boolean = False) As Boolean
|
||||
Try
|
||||
' Verbindung zu SFTP herstellen
|
||||
Using sftpClient As New SftpClient(server, port, user, pwd)
|
||||
sftpClient.Connect()
|
||||
|
||||
' Datei einlesen
|
||||
Dim fileBytes() As Byte = File.ReadAllBytes(filePath)
|
||||
Dim remoteFileName As String = "/speisekarte/Mittagsmenue.pdf" 'Path.GetFileName(filePath)
|
||||
|
||||
' Datei hochladen
|
||||
Using stream As New MemoryStream(fileBytes)
|
||||
sftpClient.UploadFile(stream, remoteFileName)
|
||||
End Using
|
||||
|
||||
sftpClient.Disconnect()
|
||||
End Using
|
||||
|
||||
' Rückmeldung und optional E-Mail
|
||||
If Not Silent Then
|
||||
MsgBox("Upload erfolgreich abgeschlossen.")
|
||||
End If
|
||||
sendMail("SFTP-Upload ausgeführt", $"Der automatische Upload wurde ausgeführt. Datei: {filePath}")
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
' Fehlerbehandlung
|
||||
MsgBox("Fehler beim SFTP-Upload: " & ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
|
||||
@@ -135,7 +164,7 @@ Public Class Form1
|
||||
Dim sql As New Gastro.cSQL
|
||||
|
||||
Dim Upload2SQLGuide As String = "INSERT INTO [SQLGUIDE01.verag.ost.dmn].[AVISO].dbo.[tblEBMenu]
|
||||
Select *, 5 as [MenuBestellungBisTageVorher] from [192.168.2.17].[Gastro].dbo.[GMenu] as table1
|
||||
Select *, 4 as [MenuBestellungBisTageVorher] from [192.168.2.17].[Gastro].dbo.[GMenu] as table1
|
||||
WHERE NOT EXISTS (
|
||||
select * from [SQLGUIDE01.verag.ost.dmn].[AVISO].dbo.[tblEBMenu] as table2 WHERE table1.MenuTitel = table2.MenuTitel AND table1.[MenuDateVon] = table2.[MenuDateVon]
|
||||
)
|
||||
@@ -177,4 +206,10 @@ WHERE NOT EXISTS (
|
||||
sqlsendinator()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||
GetThisWeeksMonday()
|
||||
DatumNextMonday = DatumThisWeeksMonday
|
||||
Upload()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
13
FTPUpload/packages.config
Normal file
13
FTPUpload/packages.config
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle.Cryptography" version="2.4.0" targetFramework="net47" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net47" />
|
||||
<package id="SSH.NET" version="2024.2.0" targetFramework="net47" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net47" />
|
||||
<package id="System.Formats.Asn1" version="8.0.1" targetFramework="net47" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net47" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net47" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net47" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net47" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net47" />
|
||||
</packages>
|
||||
2
FTPUpload/start.ini
Normal file
2
FTPUpload/start.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
DBConnection;Debug;--------------------------------------------------------Debug oder Highway;
|
||||
PDFUploadPath;D:\repos\Gastro\FTPUpload\bin\Debug\Menues\;----------------Pfad für PDF Upload;
|
||||
Reference in New Issue
Block a user