182 lines
7.0 KiB
VB.net
182 lines
7.0 KiB
VB.net
Option Explicit On
|
|
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
Imports Microsoft.Office.Tools.Ribbon
|
|
Imports System.Windows.Forms
|
|
Imports Microsoft.Office.Interop
|
|
Imports VERAGAddIn.ThisAddIn
|
|
Imports System.Runtime.InteropServices
|
|
|
|
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()
|
|
End Function
|
|
|
|
Private Function CreateRibbonMenu() As RibbonMenu
|
|
Return Me.Factory.CreateRibbonMenu()
|
|
End Function
|
|
|
|
Private Function CreateRibbonButton() As RibbonButton
|
|
Dim button As RibbonButton = Me.Factory.CreateRibbonButton()
|
|
' AddHandler (button.Click), AddressOf Button_Click
|
|
Return button
|
|
End Function
|
|
|
|
Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
|
|
|
|
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False
|
|
initFirmaUser()
|
|
End Sub
|
|
|
|
Sub initFirmaUser()
|
|
Dim ADMIN As New cADMIN
|
|
Try
|
|
Dim WI = System.Security.Principal.WindowsIdentity.GetCurrent().Name
|
|
If WI.Contains("\") Then
|
|
Dim Split() = WI.Split("\")
|
|
If Split(0).Contains("VERAG-NCTS") Then VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "ATILLA"
|
|
If Split(0).Contains("VERAG") Then VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "VERAG"
|
|
If Split(0).Contains("IMEX") Then VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "IMEX"
|
|
|
|
Dim UsernameTMP = ADMIN.getUstName_ByAD(Split(0), Split(1))
|
|
|
|
If UsernameTMP <> "" Then
|
|
LOGIN_OK = ADMIN.checkLogin(UsernameTMP, ADMIN.getPwdFromUsrname(UsernameTMP, VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA), VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA)
|
|
End If
|
|
End If
|
|
Catch ex As Exception
|
|
' MsgBox(ex.Message & ex.StackTrace)
|
|
End Try
|
|
If Not LOGIN_OK Then
|
|
LOGIN_OK = ADMIN.checkLogin("MAIL_USER", "VERAG_MAIL_USER_2017", "VERAG")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs)
|
|
'MsgBox("HI")
|
|
' Dim ThisAddIn As New ThisAddIn
|
|
Dim s As String = ""
|
|
'Dim app = ThisAddIn.getapp()
|
|
' ThisAddIn.PrintAPageFromEmail()
|
|
RaiseEvent bla()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub Button2_Click(sender As Object, e As RibbonControlEventArgs) Handles Button2.Click
|
|
If LOGIN_OK Then
|
|
' For Each ft As Form In My.Application.OpenForms
|
|
'If ft.GetType.ToString = "AVISO.frmEintragAviso" Then
|
|
'ft.BringToFront()
|
|
' Exit Sub
|
|
' End If
|
|
' Next
|
|
|
|
Dim ATTACHMENTS_LIST As New List(Of String)
|
|
|
|
Dim KundenNr = -1
|
|
Dim EingangsDatum As Date = CDate("01.01.1990")
|
|
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
|
|
If mailItem IsNot Nothing Then
|
|
EingangsDatum = mailItem.ReceivedTime
|
|
Dim senderMail = ""
|
|
If mailItem.SenderEmailType = "EX" Then
|
|
senderMail = (mailItem.Sender.GetExchangeUser.PrimarySmtpAddress)
|
|
Else
|
|
senderMail = (mailItem.SenderEmailAddress)
|
|
End If
|
|
|
|
KundenNr = VERAG_PROG_ALLGEMEIN.cKundenKontakte.getKdNrFromMailAdress(senderMail, False) ' false, wenn mehrere Niederlassungen von Frimen im KdStamm vorhanden... falsche KdNr...
|
|
|
|
End If
|
|
saveAttachment(mailItem, ATTACHMENTS_LIST)
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
End Try
|
|
|
|
|
|
VERAG_PROG_ALLGEMEIN.cGlobal.Aktive_ID = 0
|
|
Dim mainForm As New AVISO.frmEintragAviso
|
|
If KundenNr > 0 Then
|
|
AddHandler mainForm.Shown, Sub()
|
|
mainForm.kdAvisierer.KdNr = KundenNr
|
|
End Sub
|
|
End If
|
|
If EingangsDatum > CDate("01.01.1990") Then
|
|
mainForm.EingangsDatum = EingangsDatum
|
|
End If
|
|
mainForm.TopMost = True
|
|
mainForm.StartFromOUTLOOK = True
|
|
mainForm.ShowDialog()
|
|
|
|
|
|
Try
|
|
If VERAG_PROG_ALLGEMEIN.cGlobal.Aktive_ID > 0 Then
|
|
For Each ATT In ATTACHMENTS_LIST
|
|
Dim fi As New IO.FileInfo(ATT)
|
|
Dim typ = ""
|
|
If AVISO.frmSendungAnhangImport.getFileTypeValid(typ, fi.Extension) Then
|
|
AVISO.frmSendungAnhangImport.saveToDS(VERAG_PROG_ALLGEMEIN.cGlobal.Aktive_ID, fi.Name, ATT, "", typ)
|
|
End If
|
|
Next
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message & ex.StackTrace)
|
|
End Try
|
|
Else
|
|
MsgBox("Fehler beim Login!")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub saveAttachment(mail As Outlook.MailItem, ByRef ATTACHMENTS_LIST As List(Of String))
|
|
|
|
Dim attachments As Outlook.Attachments = Nothing
|
|
|
|
Try
|
|
attachments = mail.Attachments
|
|
For Each attachment As Outlook.Attachment In mail.Attachments
|
|
'Next
|
|
'For i As Integer = 1 To attachments.Count
|
|
' Dim attachment As Outlook.Attachment = attachments.Item(i)
|
|
' MsgBox(attachment.FileName)
|
|
Dim specialFolder = "OutlookAttach\Outlook_" & Now.ToString("ddMMyy_HHmmss")
|
|
While IO.Directory.Exists(specialFolder)
|
|
specialFolder = "OutlookAttach\Outlook_" & Now.ToString("ddMMyy_HHmmss")
|
|
End While
|
|
' Dim io As New IO.FileInfo(attachment.PathName)
|
|
Dim TMP_PATH As String = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath(attachment.FileName, " io.Extension", False, False, specialFolder)
|
|
attachment.SaveAsFile(TMP_PATH)
|
|
ATTACHMENTS_LIST.Add(TMP_PATH)
|
|
Marshal.ReleaseComObject(attachment)
|
|
Next
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, ex.StackTrace)
|
|
Finally
|
|
If attachments IsNot Nothing Then
|
|
Marshal.ReleaseComObject(attachments)
|
|
End If
|
|
If mail IsNot Nothing Then
|
|
Marshal.ReleaseComObject(mail)
|
|
End If
|
|
'If currInspector IsNot Nothing Then
|
|
' Marshal.ReleaseComObject(currInspector)
|
|
'End If
|
|
End Try
|
|
End Sub
|
|
End Class
|