Initial commit

This commit is contained in:
2020-10-21 10:43:18 +02:00
commit 56bd02798f
5848 changed files with 2659025 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
Imports System.IO
Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class DB
Public dsDaten As New DataSet
Public dsdaten1 As New DataSet
Public dsdatendocm As New DataSet
Public dadaten As SqlDataAdapter
Public dadatendocm As SqlDataAdapter
Dim sql As String
Public Sub Get_Dokumente()
Try
dsDaten.Clear()
sql = "Select * from View_Covid_Mail order by erstelltam desc"
dadaten = New SqlDataAdapter(sql, Globals.sConnectionstring)
dadaten.Fill(dsDaten, "Dokumente")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Function Get_From_DB(ByVal DokumentID As String, ByVal Filename As String) As Boolean
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From doks where DokumentID='" + DokumentID + "'", connection)
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
Try
'Connectionstring zur Datenbank
connection.ConnectionString = Globals.sConnectionstring
connection.Open()
da.Fill(ds, "docs")
Dim myRow As DataRow
myRow = ds.Tables(0).Rows(0)
Dim MyData() As Byte
MyData = myRow.Item(1)
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream(Filename, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
Catch ex As Exception
' MsgBox(ex.Message)
Return False
End Try
CB = Nothing
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
Return True
End Function
End Class
Public Class DB_Connection
''' <summary>
''' Liest sämtlcihe CFG-Dateien mit dem Namen "Vertragsverwaltung...". Sind meherere Dateien vorhanden,
''' wird ein Auswahldialog zur Datenbank-Selektion angezeigt.
''' Standardmässig wird Vertragsverwaltung.cfg als CFG-Datei benutzt.
'''
''' Die CFG-Datei ist verschlüsselt und wird über die Crypto-Funktionen entschlüsselt.
''' </summary>
''' <remarks></remarks>
Shared Sub New()
Dim path As String = ""
Dim fc As Integer = 0
If fc < 2 Then Globals.ConnectionFilename = "edokaconn.cfg"
Dim ofile As System.IO.File
Dim oread As System.IO.StreamReader
oread = ofile.OpenText(ApplicationPath() + "\" + Globals.ConnectionFilename)
sConnectionstring = oread.ReadLine
sConnectionstring = Crypto.DecryptText(sConnectionstring, "HutterundMueller")
sConnectionstring = Left(sConnectionstring, Len(sConnectionstring) - 1)
Globals.sConnectionstring = sConnectionstring
oread.Close()
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select beschreibung from pluginparameter where pluginparamnr=1", connection)
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
Try
connection.ConnectionString = Globals.sConnectionstring
connection.Open()
da.Fill(ds, "params")
path = ds.Tables(0).Rows(0).Item(0)
Catch ex As Exception
path = ""
CB = Nothing
End Try
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
Globals.ConnectionFilename = "edokaconn.cfg"
oread = ofile.OpenText(path + "\" + Globals.ConnectionFilename)
sConnectionstring = oread.ReadLine
sConnectionstring = Crypto.DecryptText(sConnectionstring, "HutterundMueller")
sConnectionstring = Left(sConnectionstring, Len(sConnectionstring) - 1)
Globals.sConnectionstring = sConnectionstring
oread.Close()
End Sub
End Class

View File

@@ -0,0 +1,43 @@
Public Class clsMailClient
Dim m_empfaenger As String
Public Sub CreateOutlookMail(mailclient As String, absender As String, empfaenger As String, betreff As String, inhalt As String, attachment As String)
Select Case mailclient
Case "OUTLOOK"
Dim Outl As Object
Outl = CreateObject("Outlook.Application")
If Outl IsNot Nothing Then
Dim omsg As Object
omsg = Outl.CreateItem(0)
omsg.sender = absender
omsg.SentOnBehalfOfName = absender
omsg.ReadReceiptRequested = True
omsg.To = empfaenger
omsg.bcc = ""
omsg.subject = betreff
omsg.body = inhalt
omsg.Attachments.Add(attachment)
omsg.Display(True)
End If
Case "MAPI"
Dim mapi As New MapiMail
mapi.AddAttachment(attachment)
mapi.AddRecipientTo(empfaenger)
mapi.SendMailPopup(betreff, inhalt)
Case Else
MsgBox("Kein Mail-Client verfügbar.")
End Select
End Sub
End Class

View File

@@ -0,0 +1,206 @@
Imports System
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Collections.Generic
Imports System.Windows.Forms
Public Class MapiMail
Public Function AddRecipientTo(ByVal email As String) As Boolean
Return AddRecipient(email, howTo.MAPI_TO)
End Function
Public Function AddRecipientCC(ByVal email As String) As Boolean
Return AddRecipient(email, howTo.MAPI_TO)
End Function
Public Function AddRecipientBCC(ByVal email As String) As Boolean
Return AddRecipient(email, howTo.MAPI_TO)
End Function
Public Sub AddAttachment(ByVal strAttachmentFileName As String)
m_attachments.Add(strAttachmentFileName)
End Sub
Public Function SendMailPopup(ByVal strSubject As String, ByVal strBody As String) As Integer
Return SendMail(strSubject, strBody, MAPI_LOGON_UI Or MAPI_DIALOG)
End Function
Public Function SendMailDirect(ByVal strSubject As String, ByVal strBody As String) As Integer
Return SendMail(strSubject, strBody, MAPI_LOGON_UI)
End Function
<DllImport("MAPI32.DLL")>
Private Shared Function MAPISendMail(ByVal sess As IntPtr, ByVal hwnd As IntPtr, ByVal message As MapiMessage, ByVal flg As Integer, ByVal rsv As Integer) As Integer
End Function
Private Function SendMail(ByVal strSubject As String, ByVal strBody As String, ByVal how As Integer) As Integer
Dim msg As MapiMessage = New MapiMessage()
msg.subject = strSubject
msg.noteText = strBody
msg.recips = GetRecipients(msg.recipCount)
msg.files = GetAttachments(msg.fileCount)
m_lastError = MAPISendMail(New IntPtr(0), New IntPtr(0), msg, how, 0)
If m_lastError > 1 Then
MessageBox.Show("MAPISendMail failed! " + GetLastError(), "MAPISendMail")
End If
Cleanup(msg)
Return m_lastError
End Function
Private Function AddRecipient(ByVal email As String, ByVal howTo As howTo) As Boolean
Dim recipient As MapiRecipDesc = New MapiRecipDesc()
recipient.recipClass = CType(howTo, Integer)
recipient.name = email
m_recipients.Add(recipient)
Return True
End Function
Private Function GetRecipients(ByRef recipCount As Integer) As IntPtr
recipCount = 0
If m_recipients.Count = 0 Then
Return 0
End If
Dim size As Integer = Marshal.SizeOf(GetType(MapiRecipDesc))
Dim intPtr As IntPtr = Marshal.AllocHGlobal(m_recipients.Count * size)
'Dim ptr As Integer = CType(intPtr, Integer)
Dim ptr As Long = intPtr.ToInt64()
Dim mapiDesc As MapiRecipDesc
For Each mapiDesc In m_recipients
Marshal.StructureToPtr(mapiDesc, CType(ptr, IntPtr), False)
ptr += size
Next
recipCount = m_recipients.Count
Return intPtr
End Function
Private Function GetAttachments(ByRef fileCount As Integer) As IntPtr
fileCount = 0
If m_attachments Is Nothing Then
Return 0
End If
If (m_attachments.Count <= 0) Or (m_attachments.Count > maxAttachments) Then
Return 0
End If
Dim size As Integer = Marshal.SizeOf(GetType(MapiFileDesc))
Dim intPtr As IntPtr = Marshal.AllocHGlobal(m_attachments.Count * size)
Dim mapiFileDesc As MapiFileDesc = New MapiFileDesc()
mapiFileDesc.position = -1
'Dim ptr As Integer = CType(intPtr, Integer)
Dim ptr As Long = intPtr.ToInt64()
Dim strAttachment As String
For Each strAttachment In m_attachments
mapiFileDesc.name = Path.GetFileName(strAttachment)
mapiFileDesc.path = strAttachment
Marshal.StructureToPtr(mapiFileDesc, CType(ptr, IntPtr), False)
ptr += size
Next
fileCount = m_attachments.Count
Return intPtr
End Function
Private Sub Cleanup(ByRef msg As MapiMessage)
Dim size As Integer = Marshal.SizeOf(GetType(MapiRecipDesc))
'Dim ptr As Integer = 0
Dim ptr As Long = 0
If msg.recips <> IntPtr.Zero Then
ptr = CType(msg.recips, Long)
Dim i As Integer
For i = 0 To msg.recipCount - 1 Step i + 1
Marshal.DestroyStructure(CType(ptr, IntPtr), GetType(MapiRecipDesc))
ptr += size
Next
Marshal.FreeHGlobal(msg.recips)
End If
If msg.files <> IntPtr.Zero Then
size = Marshal.SizeOf(GetType(MapiFileDesc))
ptr = CType(msg.files, Long)
Dim i As Integer
For i = 0 To msg.fileCount - 1 Step i + 1
Marshal.DestroyStructure(CType(ptr, IntPtr), GetType(MapiFileDesc))
ptr += size
Next
Marshal.FreeHGlobal(msg.files)
End If
m_recipients.Clear()
m_attachments.Clear()
m_lastError = 0
End Sub
Public Function GetLastError() As String
If m_lastError <= 26 Then
Return errors(m_lastError)
End If
Return "MAPI error [" + m_lastError.ToString() + "]"
End Function
ReadOnly errors() As String = New String() {"OK [0]", "User abort [1]", "General MAPI failure [2]", "MAPI login failure [3]", "Disk full [4]", "Insufficient memory [5]", "Access denied [6]", "-unknown- [7]", "Too many sessions [8]", "Too many files were specified [9]", "Too many recipients were specified [10]", "A specified attachment was not found [11]", "Attachment open failure [12]", "Attachment write failure [13]", "Unknown recipient [14]", "Bad recipient type [15]", "No messages [16]", "Invalid message [17]", "Text too large [18]", "Invalid session [19]", "Type not supported [20]", "A recipient was specified ambiguously [21]", "Message in use [22]", "Network failure [23]", "Invalid edit fields [24]", "Invalid recipients [25]", "Not supported [26]"}
Dim m_recipients As New List(Of MapiRecipDesc)
Dim m_attachments As New List(Of String)
Dim m_lastError As Integer = 0
Private Const MAPI_LOGON_UI As Integer = &H1
Private Const MAPI_DIALOG As Integer = &H8
Private Const maxAttachments As Integer = 20
Enum howTo
MAPI_ORIG = 0
MAPI_TO
MAPI_CC
MAPI_BCC
End Enum
End Class
<StructLayout(LayoutKind.Sequential)>
Public Class MapiMessage
Public reserved As Integer
Public subject As String
Public noteText As String
Public messageType As String
Public dateReceived As String
Public conversationID As String
Public flags As Integer
Public originator As IntPtr
Public recipCount As Integer
Public recips As IntPtr
Public fileCount As Integer
Public files As IntPtr
End Class
<StructLayout(LayoutKind.Sequential)>
Public Class MapiFileDesc
Public reserved As Integer
Public flags As Integer
Public position As Integer
Public path As String
Public name As String
Public type As IntPtr
End Class
<StructLayout(LayoutKind.Sequential)>
Public Class MapiRecipDesc
Public reserved As Integer
Public recipClass As Integer
Public name As String
Public address As String
Public eIDSize As Integer
Public enTryID As IntPtr
End Class