VeragAddIn

This commit is contained in:
2026-02-10 14:29:00 +01:00
parent b24d57cd2a
commit 4856d4e6d9
5 changed files with 146 additions and 4 deletions

View File

@@ -36,7 +36,7 @@
<PublishUrl>\\ftps.verag.ag\g\FTP\Programme\VeragAddin\</PublishUrl>
<InstallUrl>http://ftps.verag.ag/VERAGAddin/</InstallUrl>
<TargetCulture>de</TargetCulture>
<ApplicationVersion>1.0.1.133</ApplicationVersion>
<ApplicationVersion>1.0.1.134</ApplicationVersion>
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
<UpdateEnabled>true</UpdateEnabled>
<UpdateInterval>0</UpdateInterval>
@@ -164,6 +164,9 @@
-->
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="HtmlAgilityPack, Version=1.12.4.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\..\Aviso\AVISO\packages\HtmlAgilityPack.1.12.4\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Office.Tools.Outlook.v4.0.Utilities, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Data" />
@@ -269,6 +272,7 @@
<None Include="AL20231110.pfx" />
<None Include="app.config" />
<None Include="Ich habe keine Ahnung, was ich hier mache.pfx" />
<None Include="packages.config" />
<None Include="PrivateCodeSignaturDaniel2024.pfx" />
<None Include="PrivateCodeSignaturDaniel20240131.pfx" />
<None Include="Resources\GS\gsdll32.lib">

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HtmlAgilityPack" version="1.12.4" targetFramework="net48" />
</packages>

View File

@@ -41,7 +41,6 @@
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.Tab1 = Me.Factory.CreateRibbonTab
Me.Group1 = Me.Factory.CreateRibbonGroup
Me.Button1 = Me.Factory.CreateRibbonButton
@@ -52,7 +51,7 @@
Me.btnGestellungsgarantien = Me.Factory.CreateRibbonButton
Me.btnInfo = Me.Factory.CreateRibbonButton
Me.btnUnsichtbar = Me.Factory.CreateRibbonButton
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon()
Me.Tab1.SuspendLayout()
Me.Group1.SuspendLayout()
Me.SuspendLayout()

View File

@@ -52,6 +52,7 @@
Me.btnGestellungsgarantien = Me.Factory.CreateRibbonButton
Me.SplitButton1 = Me.Factory.CreateRibbonSplitButton
Me.Button1 = Me.Factory.CreateRibbonButton
Me.btnDFDS = Me.Factory.CreateRibbonButton
Me.Button3 = Me.Factory.CreateRibbonButton
Me.Button4 = Me.Factory.CreateRibbonButton
Me.Tab1.SuspendLayout()
@@ -132,6 +133,7 @@
Me.SplitButton1.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge
Me.SplitButton1.Image = Global.VERAGAddIn.My.Resources.Resources.wheel
Me.SplitButton1.Items.Add(Me.Button1)
Me.SplitButton1.Items.Add(Me.btnDFDS)
Me.SplitButton1.Items.Add(Me.Button3)
Me.SplitButton1.Items.Add(Me.Button4)
Me.SplitButton1.Label = "Spezielle Optionen"
@@ -144,6 +146,13 @@
Me.Button1.Name = "Button1"
Me.Button1.ShowImage = True
'
'btnDFDS
'
Me.btnDFDS.Image = Global.VERAGAddIn.My.Resources.Resources.pdf
Me.btnDFDS.Label = "DFDS PDFs auslesen"
Me.btnDFDS.Name = "btnDFDS"
Me.btnDFDS.ShowImage = True
'
'Button3
'
Me.Button3.Image = Global.VERAGAddIn.My.Resources.Resources.pdf
@@ -184,6 +193,7 @@
Friend WithEvents btnVertraege As Microsoft.Office.Tools.Ribbon.RibbonButton
Friend WithEvents btnGestellungsgarantien As Microsoft.Office.Tools.Ribbon.RibbonButton
Friend WithEvents Button3 As Microsoft.Office.Tools.Ribbon.RibbonButton
Friend WithEvents btnDFDS As Microsoft.Office.Tools.Ribbon.RibbonButton
End Class
Partial Class ThisRibbonCollection

View File

@@ -1,10 +1,13 @@
Option Explicit On
Imports System.Data
Imports System.Net
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Text.RegularExpressions
Imports System.Windows.Forms
'Imports System.Windows.Forms.LinkLabel
Imports HtmlAgilityPack
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Tools.Ribbon
Imports VERAG_PROG_ALLGEMEIN
@@ -95,6 +98,10 @@ Public Class VERAGRibbon
Private Sub Button3_Click_1(sender As Object, e As RibbonControlEventArgs) Handles Button3.Click
If LOGIN_OK Then AVISO_Mail_Functions.newBarsanMAIL()
End Sub
Private Sub btnDFDS_Click(sender As Object, e As RibbonControlEventArgs) Handles btnDFDS.Click
If LOGIN_OK Then AVISO_Mail_Functions.newDSDFMAIL()
End Sub
End Class
Public Class AVISO_Mail_Functions
@@ -158,7 +165,7 @@ Public Class AVISO_Mail_Functions
loadAttachment(mailItem, ATTACHMENTS_LIST)
If isMail_EKOL(mailItem) Then
If vbYes = MsgBox("EKOL-Anhänge laden?", vbYesNoCancel) Then getATT_EKOL(mailItem, ATTACHMENTS_LIST)
If vbYes = MsgBox("DFDS-Anhänge laden?", vbYesNoCancel) Then getATT_DFDS(mailItem, ATTACHMENTS_LIST)
End If
If isMail_Barsan(mailItem) Then
@@ -251,6 +258,25 @@ Public Class AVISO_Mail_Functions
End Try
End Sub
Shared Sub newDSDFMAIL()
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
If AVISO_Mail_Functions.isMail_EKOL(mailItem) Then
VERAG_PROG_ALLGEMEIN.cFormularManager.PrintViaSpirePDF(AVISO_Mail_Functions.getATT_EKOL(mailItem))
End If
End If
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Shared Sub newBarsanMAIL()
Try
Dim explorer As Outlook.Explorer = Globals.ThisAddIn.Application.ActiveExplorer
@@ -653,6 +679,105 @@ Public Class AVISO_Mail_Functions
End Function
Shared Function getATT_DFDS(mailItem As Outlook.MailItem, Optional ByRef ATT As List(Of String) = Nothing, Optional ByRef LKW_Nr As String = "", Optional ByRef RefNr As String = "", Optional ByRef INFO As String = "") As DataTable
Try
If ATT Is Nothing Then ATT = New List(Of String)
Dim dt As New DataTable()
dt.Columns.AddRange({
New DataColumn("Record"),
New DataColumn("Consignee"),
New DataColumn("Quantity"),
New DataColumn("GrossWeight"),
New DataColumn("OrderCustoms"),
New DataColumn("OperationType"),
New DataColumn("Description"),
New DataColumn("LinkText"),
New DataColumn("LinkUrl")
})
Dim doc As New HtmlAgilityPack.HtmlDocument()
doc.LoadHtml(mailItem.HTMLBody)
' all data rows (skip header)
Dim rows = doc.DocumentNode.SelectNodes("//tr[td]")
If rows Is Nothing Then Return dt
For Each row In rows
Dim cells = row.SelectNodes("td")
If cells Is Nothing OrElse cells.Count < 8 Then Continue For
Dim linkNode = cells(7).SelectSingleNode(".//a")
dt.Rows.Add(
Clean(cells(0).InnerText),
Clean(cells(1).InnerText),
Clean(cells(2).InnerText),
Clean(cells(3).InnerText),
Clean(cells(4).InnerText),
Clean(cells(5).InnerText),
Clean(cells(6).InnerText),
If(linkNode IsNot Nothing, Clean(linkNode.InnerText), ""),
If(linkNode IsNot Nothing, linkNode.GetAttributeValue("href", ""), "")
)
Next
Dim counter As Integer = 1
Dim sendungsNrOld As String = ""
For Each r In dt.Rows
If r("LinkUrl") <> "" AndAlso r("LinkUrl").ToString.Contains("https://web01.ekoltransport.com.tr/dfdsdocumentservice/download/") Then
Dim sendungsNr As String = r("Record")
Dim Descr As String = r("Description")
If Descr <> "" Then
Descr.ToString.Replace(";", "_")
Descr.ToString.Replace(".", "_")
Descr.ToString.Replace(" ", "_")
Descr = VERAG_PROG_ALLGEMEIN.cDATENSERVER.replaceInvalidCahr(Descr)
End If
If sendungsNrOld <> "" AndAlso sendungsNrOld <> sendungsNr Then
counter = 1
End If
Dim pdf = VERAG_PROG_ALLGEMEIN.cFormularManager.getPDFViaSpirePDF_FromURLStream(r("LinkUrl"), r("Record") & "_" & counter & "_" & IIf(Descr <> "", Descr, ""),, False)
If IO.File.Exists(pdf) Then
ATT.Add(pdf)
counter += 1
End If
sendungsNrOld = r("Record")
End If
Next
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Function
Private Shared Function Clean(input As String) As String
If String.IsNullOrWhiteSpace(input) Then Return ""
Return HtmlEntity.DeEntitize(input).
Replace("o:p", "").
Replace(vbCr, "").
Replace(vbLf, "").
Trim()
End Function
Shared Function getATT_Barsan(mailItem As Outlook.MailItem, Optional ByRef ATT As List(Of String) = Nothing, Optional ByRef art As String = "") As List(Of String)