Logik für AddIn Vollmachten eingebaut.

This commit is contained in:
2022-09-28 13:15:48 +02:00
parent 76518d49cf
commit 95f0a62c89
4 changed files with 154 additions and 43 deletions

View File

@@ -77,7 +77,7 @@ Public Class VERAGRibbon
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_Vollmachten()
If LOGIN_OK Then AVISO_Mail_Functions.addMailToAviso_Hauptfenster(True)
End Sub
@@ -85,7 +85,7 @@ End Class
Public Class AVISO_Mail_Functions
Shared Sub addMailToAviso_Hauptfenster()
Shared Sub addMailToAviso_Hauptfenster(Optional isFormular As Boolean = False)
Try
Dim explorer As Outlook.Explorer = Globals.ThisAddIn.Application.ActiveExplorer
Dim selection As Outlook.Selection = explorer.Selection
@@ -94,7 +94,7 @@ Public Class AVISO_Mail_Functions
Dim mailItem As Outlook.MailItem = selectedItem
mailItem = DirectCast(mailItem, Outlook.MailItem)
addMailToAviso(mailItem)
addMailToAviso(mailItem, isFormular)
End If
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)
@@ -143,6 +143,10 @@ Public Class AVISO_Mail_Functions
ElseIf pdf_mail = "PDFMAIL" Then
saveMail(mailItem, AvisoId, Bezeichnung,, SendungsId, Art)
saveAttachment(ATTACHMENTS_LIST, AvisoId, SendungsId, Art, BezAnhang)
ElseIf pdf_mail = "PDF_DATENSERVER" Then
saveAttachmentOnDatenserver(ATTACHMENTS_LIST, AvisoId, Art, BezAnhang)
ElseIf pdf_mail = "ONLYMAIL_DATENSERVER" Then
saveMailOnDatenserver(mailItem, AvisoId, Bezeichnung,, Art)
Else 'ONLYMAIL
saveMail(mailItem, AvisoId, Bezeichnung,, SendungsId, Art)
End If
@@ -386,6 +390,32 @@ Public Class AVISO_Mail_Functions
Catch ex As Exception
MsgBox(System.Reflection.MethodInfo.GetCurrentMethod.Name & ex.Message & ex.StackTrace)
End Try
End Sub
Shared Sub saveAttachmentOnDatenserver(ByRef ATTACHMENTS_LIST As List(Of String), AvisoId As Integer, Art As String, BezeichnungAnh As String)
Try
If AvisoId > 0 Then
If ATTACHMENTS_LIST.Count > 1 Then BezeichnungAnh = "" ' nur wenn 1 Anhang wird die Bezeichnung übernommen.
For Each ATT In ATTACHMENTS_LIST
Dim fi As New IO.FileInfo(ATT)
Dim Bezeichnung = BezeichnungAnh
If Bezeichnung = "" Then Bezeichnung = fi.Name
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", Bezeichnung)
Dim path = DS.uploadDataToDATENSERVER(fi.FullName)
'If AVISO.frmSendungAnhangImport.getFileTypeValid(fi.Extension, typ) Then
' AVISO.frmSendungAnhangImport.saveToDS(AvisoId, Bezeichnung, ATT, Art, typ, ,,, If(SendungsId > 0, SendungsId, Nothing))
Next
End If
Catch ex As Exception
MsgBox(System.Reflection.MethodInfo.GetCurrentMethod.Name & ex.Message & ex.StackTrace)
End Try
End Sub
@@ -577,20 +607,55 @@ 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 = "")
Try
If AvisoId > 0 Then
If bezeichnung = "" Then bezeichnung = Left(Regex.Replace(mailItem.Subject, "[\/\\\:\?\*\<\>\|""]", ""), 100).Replace("""", "").Replace(vbTab, " ") & ".msg"
Dim strTmpPath As String = System.IO.Path.GetTempPath() & bezeichnung & If(bezeichnung.EndsWith(".msg"), "", ".msg")
mailItem.SaveAs(strTmpPath, Outlook.OlSaveAsType.olMSG)
'If AVISO.frmSendungAnhangImport.saveToDS(AvisoId, bezeichnung, strTmpPath, Art, "MSG",,,, If(SendungsId, SendungsId, Nothing)) Then
' End If
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", bezeichnung)
Dim path = DS.uploadDataToDATENSERVER(strTmpPath)
' Clean up the temporary .MSG file from the user's temporary folder
System.IO.File.Delete(strTmpPath)
End If
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)
Finally
If mailItem IsNot Nothing Then
Marshal.ReleaseComObject(mailItem)
End If
End Try
End Sub
Shared Function getAvisoId(ByRef Bezeichnung, ByRef pdf_mail, ByRef SendungsId, ByRef Art, ByRef Att, ByVal isFormular) 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
SendungsId = frmAvisoFormularAnfuegen.SendungsId
Bezeichnung = frmAvisoFormularAnfuegen.Bezeichnung
pdf_mail = frmAvisoFormularAnfuegen.PDF_MAIL
Att = frmAvisoFormularAnfuegen.ATT
Return 1
Exit Function
Return AvisoId
End If
Return -1
Exit Function
End If
Dim frmAvisoAnfügen As New frmAvisoAnfuegen(Bezeichnung)
@@ -610,22 +675,4 @@ Public Class AVISO_Mail_Functions
End Function
Shared Sub addMailToAviso_Vollmachten()
Try
Dim explorer As Outlook.Explorer = Globals.ThisAddIn.Application.ActiveExplorer
Dim selection As Outlook.Selection = explorer.Selection
If selection.Count > 0 Then
Dim selectedItem = selection(1)
Dim mailItem As Outlook.MailItem = selectedItem
mailItem = DirectCast(mailItem, Outlook.MailItem)
addMailToAviso(mailItem, True)
End If
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)
End Try
End Sub
End Class