Prüfung auf DB-Verbindung bei starten des Addins -> bei Fehler entsprechende Fehlermeldung inkl. Beendigung des Programmes
This commit is contained in:
@@ -9,13 +9,15 @@ Imports System.Runtime.InteropServices
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.IO
|
||||
Imports SDL
|
||||
Imports System.Net
|
||||
Imports System.Security.Policy
|
||||
Imports System.Diagnostics.Eventing.Reader
|
||||
|
||||
Public Class VERAGRibbon
|
||||
Dim LOGIN_OK = False
|
||||
Public Shared Event bla()
|
||||
Private Sub CustomerRibbon_Load(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonUIEventArgs) Handles MyBase.Load
|
||||
|
||||
|
||||
End Sub
|
||||
Private Function CreateRibbonDropDownItem() As RibbonDropDownItem
|
||||
Return Me.Factory.CreateRibbonDropDownItem()
|
||||
@@ -36,6 +38,9 @@ Public Class VERAGRibbon
|
||||
'VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False
|
||||
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True
|
||||
LOGIN_OK = AVISO_Mail_Functions.initFirmaUser()
|
||||
If testConnection() = False Then
|
||||
Windows.Forms.Application.Exit()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -77,11 +82,24 @@ Public Class VERAGRibbon
|
||||
End Sub
|
||||
|
||||
Private Sub btnVM_Click(sender As Object, e As RibbonControlEventArgs) Handles btnVM.Click
|
||||
' ToDo -> Logik für das Einfügen eines PDFs aus einer Mail in eine Vollmacht im Aviso.
|
||||
If LOGIN_OK Then AVISO_Mail_Functions.addMailToAviso_Hauptfenster(True)
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function testConnection() As Boolean
|
||||
|
||||
Dim connection = New VERAG_PROG_ALLGEMEIN.SQL
|
||||
If connection.getValueTxtBySql("SELECT 1", "FMZOLL") = 1 Then
|
||||
Return True
|
||||
Else
|
||||
MsgBox("ACHTUNG: Server nicht erreichbar!" & vbCrLf & "VERAG ADD In wird beendet")
|
||||
Return False
|
||||
End If
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Public Class AVISO_Mail_Functions
|
||||
@@ -135,7 +153,13 @@ Public Class AVISO_Mail_Functions
|
||||
End If
|
||||
End If
|
||||
Dim Bezeichnung = strFileName
|
||||
Dim AvisoId = getAvisoId(Bezeichnung, pdf_mail, SendungsId, Art, ATTACHMENTS_LIST, kdNr, isFormular) ')getAttachmentStringList(mailItem))
|
||||
Dim AvisoId = Nothing
|
||||
If isFormular Then
|
||||
AvisoId = getAvisoFormularId(Bezeichnung, pdf_mail, Art, ATTACHMENTS_LIST, kdNr) ')getAttachmentStringList(mailItem))
|
||||
Else
|
||||
AvisoId = getAvisoId(Bezeichnung, pdf_mail, SendungsId, Art, ATTACHMENTS_LIST) ')getAttachmentStringList(mailItem))
|
||||
End If
|
||||
|
||||
If AvisoId < 0 Then Exit Sub
|
||||
|
||||
Dim BezAnhang = If(Bezeichnung <> strFileName, Bezeichnung, "") 'Wenn die Bezeichnung geändert wurde --> und wenn nur 1 Anhang, dann wird die Bezeichnung für den Anhang verwendet.
|
||||
@@ -146,10 +170,10 @@ Public Class AVISO_Mail_Functions
|
||||
saveMail(mailItem, AvisoId, Bezeichnung,, SendungsId, Art)
|
||||
saveAttachment(ATTACHMENTS_LIST, AvisoId, SendungsId, Art, BezAnhang)
|
||||
ElseIf pdf_mail = "PDF_DATENSERVER" Then
|
||||
saveMailOnDatenserver(mailItem, AvisoId, Bezeichnung,, Art, kdNr, True)
|
||||
saveAttachmentOnDatenserver(ATTACHMENTS_LIST, AvisoId, Art, BezAnhang, kdNr, True)
|
||||
saveMailOnDatenserver(mailItem, AvisoId, Bezeichnung,, kdNr)
|
||||
saveAttachmentOnDatenserver(ATTACHMENTS_LIST, AvisoId, BezAnhang, kdNr)
|
||||
ElseIf pdf_mail = "ONLYMAIL_DATENSERVER" Then
|
||||
saveMailOnDatenserver(mailItem, AvisoId, Bezeichnung,, Art, kdNr)
|
||||
saveMailOnDatenserver(mailItem, AvisoId, Bezeichnung,, kdNr)
|
||||
Else 'ONLYMAIL
|
||||
saveMail(mailItem, AvisoId, Bezeichnung,, SendungsId, Art)
|
||||
End If
|
||||
@@ -395,7 +419,7 @@ Public Class AVISO_Mail_Functions
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Shared Sub saveAttachmentOnDatenserver(ByRef ATTACHMENTS_LIST As List(Of String), AvisoId As Integer, Art As String, BezeichnungAnh As String, Optional kdNr As Integer = -1, Optional multifiles As Boolean = False)
|
||||
Shared Sub saveAttachmentOnDatenserver(ByRef ATTACHMENTS_LIST As List(Of String), AvisoId As Integer, BezeichnungAnh As String, Optional kdNr As Integer = -1)
|
||||
Try
|
||||
If AvisoId > 0 Then
|
||||
If ATTACHMENTS_LIST.Count > 1 Then BezeichnungAnh = "" ' nur wenn 1 Anhang wird die Bezeichnung übernommen.
|
||||
@@ -404,12 +428,8 @@ Public Class AVISO_Mail_Functions
|
||||
Dim Bezeichnung = BezeichnungAnh
|
||||
If Bezeichnung = "" Then Bezeichnung = fi.Name
|
||||
|
||||
Dim DS As Object = Nothing
|
||||
If multifiles Then
|
||||
DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", Bezeichnung, kdNr, multifiles)
|
||||
Else
|
||||
DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", Bezeichnung)
|
||||
End If
|
||||
|
||||
Dim DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", Bezeichnung, kdNr)
|
||||
Dim path = DS.uploadDataToDATENSERVER(fi.FullName)
|
||||
If path Then
|
||||
Dim c As New cKundenVollmachten(AvisoId)
|
||||
@@ -425,10 +445,6 @@ Public Class AVISO_Mail_Functions
|
||||
MsgBox(System.Reflection.MethodInfo.GetCurrentMethod.Name & ex.Message & ex.StackTrace)
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -553,9 +569,14 @@ Public Class AVISO_Mail_Functions
|
||||
If cnt > 0 AndAlso l.Contains(""">") Then ' ENDE
|
||||
Dim link = ("https://web01.ekol.com/documentservice/download/" & l.ToString.Substring(0, l.ToString.IndexOf(""">")))
|
||||
|
||||
'Ansonten stüzt der Webservice-Aufruf ab! ABER -> For .NET 4.7 or later, the System.Net.ServicePointManager.SecurityProtocol should not be set manualy!
|
||||
System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
|
||||
|
||||
Dim TMP_PATH = GetTempFilePathWithExtension(".pdf")
|
||||
|
||||
My.Computer.Network.DownloadFile(link, TMP_PATH)
|
||||
|
||||
|
||||
If IO.File.Exists(TMP_PATH) Then
|
||||
ATT.Add(TMP_PATH)
|
||||
End If
|
||||
@@ -620,7 +641,7 @@ Public Class AVISO_Mail_Functions
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Shared Sub saveMailOnDatenserver(mailItem As Outlook.MailItem, AvisoId As Integer, Optional bezeichnung As String = "", Optional saveAttachments As Boolean = True, Optional Art As String = "", Optional kdNr As Integer = -1, Optional multifiles As Boolean = False)
|
||||
Shared Sub saveMailOnDatenserver(mailItem As Outlook.MailItem, AvisoId As Integer, Optional bezeichnung As String = "", Optional saveAttachments As Boolean = True, Optional kdNr As Integer = -1)
|
||||
Try
|
||||
If AvisoId > 0 Then
|
||||
|
||||
@@ -630,16 +651,11 @@ Public Class AVISO_Mail_Functions
|
||||
|
||||
mailItem.SaveAs(strTmpPath, Outlook.OlSaveAsType.olMSG)
|
||||
|
||||
Dim DS As Object = Nothing
|
||||
If multifiles Then
|
||||
DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", bezeichnung, kdNr, multifiles)
|
||||
Else
|
||||
DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", bezeichnung)
|
||||
End If
|
||||
Dim DS = New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", bezeichnung, kdNr)
|
||||
Dim path = DS.uploadDataToDATENSERVER(strTmpPath)
|
||||
If path Then
|
||||
Dim c As New cKundenVollmachten(AvisoId)
|
||||
c.kdvm_datenarchivId = DS.da_id
|
||||
c.kdvm_emailId = DS.da_id
|
||||
c.SAVE()
|
||||
End If
|
||||
|
||||
@@ -657,28 +673,8 @@ Public Class AVISO_Mail_Functions
|
||||
End Sub
|
||||
|
||||
|
||||
Shared Function getAvisoId(ByRef Bezeichnung, ByRef pdf_mail, ByRef SendungsId, ByRef Art, ByRef Att, ByVal isFormular, ByRef kdNr) As Integer
|
||||
Shared Function getAvisoId(ByRef Bezeichnung, ByRef pdf_mail, ByRef SendungsId, ByRef Art, ByRef Att) As Integer
|
||||
|
||||
If (isFormular = True) Then
|
||||
Dim frmAvisoFormularAnfuegen As New frmAvisoFormularAnfuegen(Bezeichnung)
|
||||
frmAvisoFormularAnfuegen.ATT = Att
|
||||
If frmAvisoFormularAnfuegen.ShowDialog = DialogResult.OK Then
|
||||
Dim AvisoId = frmAvisoFormularAnfuegen.vollmachtId
|
||||
kdNr = frmAvisoFormularAnfuegen.KdNr
|
||||
SendungsId = frmAvisoFormularAnfuegen.SendungsId
|
||||
Bezeichnung = frmAvisoFormularAnfuegen.Bezeichnung
|
||||
pdf_mail = frmAvisoFormularAnfuegen.PDF_MAIL
|
||||
Att = frmAvisoFormularAnfuegen.ATT
|
||||
|
||||
|
||||
Return AvisoId
|
||||
|
||||
End If
|
||||
|
||||
Return -1
|
||||
Exit Function
|
||||
|
||||
End If
|
||||
|
||||
Dim frmAvisoAnfügen As New frmAvisoAnfuegen(Bezeichnung)
|
||||
frmAvisoAnfügen.ATT = Att
|
||||
@@ -697,4 +693,25 @@ Public Class AVISO_Mail_Functions
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Shared Function getAvisoFormularId(ByRef Bezeichnung, ByRef pdf_mail, ByRef Art, ByRef Att, ByRef kdNr) As Integer
|
||||
|
||||
Dim frmAvisoFormularAnfuegen As New frmAvisoFormularAnfuegen(Bezeichnung)
|
||||
frmAvisoFormularAnfuegen.ATT = Att
|
||||
If frmAvisoFormularAnfuegen.ShowDialog = DialogResult.OK Then
|
||||
Dim AvisoId = frmAvisoFormularAnfuegen.vollmachtId
|
||||
kdNr = frmAvisoFormularAnfuegen.KdNr
|
||||
Bezeichnung = frmAvisoFormularAnfuegen.Bezeichnung
|
||||
pdf_mail = frmAvisoFormularAnfuegen.PDF_MAIL
|
||||
Att = frmAvisoFormularAnfuegen.ATT
|
||||
|
||||
Return AvisoId
|
||||
|
||||
End If
|
||||
|
||||
Return -1
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user