From d5a02cd1be31adac55f7e7241427fcf6c5d701f5 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Tue, 12 Nov 2024 10:29:50 +0100 Subject: [PATCH] fix zzAktivitaet --- initATLASAufschubkonten/frmStartOptions.vb | 137 +++++++++++++++++++-- 1 file changed, 126 insertions(+), 11 deletions(-) diff --git a/initATLASAufschubkonten/frmStartOptions.vb b/initATLASAufschubkonten/frmStartOptions.vb index 0081f8e..7fd57c1 100644 --- a/initATLASAufschubkonten/frmStartOptions.vb +++ b/initATLASAufschubkonten/frmStartOptions.vb @@ -1,9 +1,12 @@ Imports System.Data.OleDb Imports System.IO +Imports System.Linq.Expressions Imports System.Net +Imports System.Runtime.InteropServices Imports System.Text Imports System.Xml Imports com.sun.corba.se.spi.orb +Imports Microsoft.Office.Interop Imports Renci.SshNet Imports VERAG_PROG_ALLGEMEIN @@ -313,7 +316,7 @@ Public Class frmStartOptions If von.Contains("@q8.com") Or betreff.Contains("IDSPRD: Platts Price Report") Then '---------------------IDS---------------------- - importFileFromIDSMailAnhang(pfad, betreff) + importFileFromIDSMailAnhang(pfad, betreff, PARAM) ElseIf von.Contains("@miccustoms.com") Or betreff.Contains("FORWARDING EMAIL | BEZUGSNUMMER") Or betreff = "Report nctsTransDeclGuarantees generated successfully" Then '---------------------MIC---------------------- importFileFromMICMailAnhang(pfad, betreff) @@ -332,12 +335,19 @@ Public Class frmStartOptions Dim betreff = "" Dim von = "" + + If (parameter.Count - 1) >= 3 Then 'Höher als 1 weil der index 0 der Pfad zum programm ist 'mdm_mail_attach %file% %subject% %datetimereceived% %from%" pfad = parameter(2) betreff = parameter(3) + + 'pfad = "C:\Users\d.breimaier\Downloads\ids_customer_0060003360_invoice_de00360936_from_150615 (5).msg" + 'betreff = "IDS, customer: 0060003360 Invoice: DE00360936 from 15/06/15" + 'von = "ids.de@q8.com" + If (parameter.Count - 1) >= 5 Then von = parameter(5) VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False @@ -345,7 +355,12 @@ Public Class frmStartOptions If von.Contains("ebilling@uta.com") Then '---------------------UTA---------------------- importFileFromUTAMailAnhang(pfad, betreff) + ElseIf von.Contains("ids.de@q8.com") Or von.Contains("isselh@q8.com") Then + '---------------------IDS---------------------- + importFileFromIDSMailAnhang(pfad, betreff, PARAM) + End If + End If closeMe() @@ -689,7 +704,7 @@ Public Class frmStartOptions For Each r As DataRow In distinctInv.Rows Dim totalPages = 0 Dim batchrequestNr = 0 - fehler = mse.getSettlementsFromInvoiceID(token, transactions, r("invoice_id"), batchrequestNr, totalPages, 0) + fehler = mse.getSettlementsFromInvoiceID(token, transactions, r("invoice_id"), batchrequestNr, totalPages, 1) If fehler <> "" Then API.UPDTAE_ERR("Batch-Nr: " & batchrequestNr & "-" & totalPages, fehler, "getSettlementsFromInvoiceID") closeMe() @@ -768,7 +783,7 @@ Public Class frmStartOptions Case "UNISPED" : db = "EZOLL_UNISPED" End Select Dim sql As New VERAG_PROG_ALLGEMEIN.SQL - Dim dt As DataTable = sql.loadDgvBySql("SELECT [zzAktivitaet].LizenzNr,[zzAktivitaet].Operatorid,[zzAktivitaet].AnmID,MsgTyp,[zzAktivitaet].ErstelltAm,pfad,LRN,CRN ,[zzAktivitaet].VorgangID FROM [zzAktivitaet] INNER JOIN zsAnmRefs On zsAnmrefs.AnmID=zzAktivitaet.AnmID + Dim dt As DataTable = sql.loadDgvBySql("SELECT [zzAktivitaet].LizenzNr,[zzAktivitaet].Operatorid,[zzAktivitaet].AnmID,MsgTyp,[zzAktivitaet].ErstelltAm,pfad,zsAnmRefs.LRN,zsAnmRefs.CRN ,[zzAktivitaet].VorgangID FROM [zzAktivitaet] INNER JOIN zsAnmRefs On zsAnmrefs.AnmID=zzAktivitaet.AnmID where MsgTyp IN ('EZ922','EZ923','TR109', 'EX431') and ErstelltAm>='" & datum.ToShortDateString & " 00:00:00' and pfad is not null", db, 200) If dt IsNot Nothing Then For Each row In dt.Rows @@ -1554,13 +1569,13 @@ Public Class frmStartOptions End Try End Sub - Sub importFileFromIDSMailAnhang(pfad, betreff) + Sub importFileFromIDSMailAnhang(pfad, betreff, type) Try Dim sql As New VERAG_PROG_ALLGEMEIN.SQL Dim DS As VERAG_PROG_ALLGEMEIN.cDATENSERVER = Nothing - If betreff.contains("IDSPRD: Platts Price Report") Then + If betreff.contains("IDSPRD: Platts Price Report") AndAlso type = "zoll_mail_attach" Then Dim ZIEL_PFAD = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getRootDir() & "IDS\IDS_XLS\Platts_Price_Report\NEW\" If Not System.IO.Directory.Exists(ZIEL_PFAD) Then System.IO.Directory.CreateDirectory(ZIEL_PFAD) @@ -1568,10 +1583,104 @@ Public Class frmStartOptions Dim destFull = "" moveFile(pfad, ZIEL_PFAD, destFull) + ElseIf betreff.contains("Einlesedatei IDS Rechnungen vom letzten Rechnungslauf") AndAlso type = "mdm_mail_attach" Then 'CSV einarbeiten + + Dim ids As New cIDS + ids.initImportPfade("IDS") + Dim Zielpfad = ids.VERARBEITUNG_PFAD + + + If betreff.ToString.ToLower.Contains("IDS") Then 'zusätzlicher Check + Dim found = False + betreff = betreff.replace("WG: ", "") + betreff = betreff.replace("FW: ", "") + moveFile(pfad, Zielpfad) + End If + + + ElseIf betreff.contains("IDS, customer:") AndAlso type = "mdm_mail_attach" Then 'Email mit Rechnungslink + + Dim ids As New cIDS + ids.initImportPfade("IDS") + Dim Zielpfad = ids.VERARBEITUNG_PFAD + + If betreff.ToString.ToLower.Contains("ids") Then + + Dim customerNo = "" + Dim invoiceNo = "" + Dim dateNo = "" + Dim outputDate = "" + Dim customerString = "customer: " + Dim InvoiceString = "Invoice: " + Dim dateString = "from " + Dim filename = "" + + If betreff.Length > 58 AndAlso betreff.Contains(customerString) Then + customerNo = betreff.Substring(betreff.IndexOf(customerString) + customerString.Length, 10) + End If + + If betreff.Length > 58 AndAlso betreff.Contains(InvoiceString) Then + invoiceNo = betreff.Substring(betreff.IndexOf(InvoiceString) + InvoiceString.Length, 10) + End If + + If betreff.Length > 58 AndAlso betreff.Contains(dateString) Then + dateNo = betreff.Substring(betreff.IndexOf(dateString) + dateString.Length, 8) + Dim parsedDate As DateTime = DateTime.ParseExact(dateNo, "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture) + outputDate = parsedDate.ToString("dd.MM.yyyy") + + End If + + If outputDate IsNot Nothing AndAlso customerNo <> "" AndAlso invoiceNo <> "" Then + + Dim idsInvoice As New cIDSInvoice(outputDate, customerNo, invoiceNo) + idsInvoice.SAVE() + + + Dim outlookApp As Object + Dim mailItem As Outlook.MailItem + + Try + + outlookApp = CreateObject("Outlook.Application") + mailItem = outlookApp.Session.OpenSharedItem(pfad) + + If mailItem IsNot Nothing Then + If idsInvoice.isMail_IDS(mailItem) Then + If idsInvoice.getPDF_IDS(mailItem, filename, Zielpfad) Then + idsInvoice.DocumentName = filename + End If + + End If + + End If + idsInvoice.SAVE() + Catch ex As Exception + mailItem = Nothing + outlookApp = Nothing + + Finally + Try + + If mailItem IsNot Nothing Then + Marshal.ReleaseComObject(mailItem) + End If + Catch ex As Exception + + End Try + + End Try + + + End If + + End If + End If + Catch ex As Exception - VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.LOG) + End Try End Sub @@ -4586,7 +4695,7 @@ Public Class frmStartOptions Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxTestsystem.Checked - cbxMSEBatchNr.DataSource = SQL.loadCboBySql("SELECT distinct top 10 ([batch_seq_nr]) FROM [VERAG].[dbo].[tblMSETransactions] order by batch_seq_nr desc", "FMZOLL") + cbxMSEBatchNr.DataSource = SQL.loadCboBySql("SELECT distinct top 20 ([batch_seq_nr]) FROM [VERAG].[dbo].[tblMSETransactions] order by batch_seq_nr desc", "FMZOLL") End Sub @@ -4879,7 +4988,7 @@ Public Class frmStartOptions End If - fehler = mse.getTransactionsFromBatchNrAndPage(token, transactions, batchrequestNr, totalPages, 0) + fehler = mse.getTransactionsFromBatchNrAndPage(token, transactions, batchrequestNr, totalPages, 1) If fehler <> "" Then MsgBox(fehler) Me.Visible = True @@ -5065,7 +5174,7 @@ Public Class frmStartOptions Dim totalPages = 0 Dim batchrequestNr = 0 - fehler = mse.getNewestSettlements(token, dt, batchrequestNr, totalPages, 0) + fehler = mse.getNewestSettlements(token, dt, batchrequestNr, totalPages, 1) If fehler <> "" Then MsgBox(fehler) @@ -5188,7 +5297,7 @@ Public Class frmStartOptions Dim sql As New VERAG_PROG_ALLGEMEIN.SQL - Dim dt_CSV_selected = SQL.loadDgvBySql_Param("SELECT TOP (10) controller_id as [Controller ID], 'VERAG 360 GmbH' as [Controller Name] , inv.[invoice_id] as [Invoice ID], inv.invoice_date as [Invoice Date], + Dim dt_CSV_selected = sql.loadDgvBySql_Param("SELECT TOP (10) controller_id as [Controller ID], 'VERAG 360 GmbH' as [Controller Name] , inv.[invoice_id] as [Invoice ID], inv.invoice_date as [Invoice Date], cust.customer_id as [CustomerID], cust.partner_customer_number as [Customer No], cust.customer_name as [Customer name], bills.specification_page_name as [Specification Page], bills.specification_page_id as [Specification ID], trans.purchase_datetime as [Transaction date], trans.transaction_id as [Transaction ID], trans.supplier_name as [Transaction Supplier/Terminal], trans.transaction_country as [Transaction Country], trans.transaction_product_name as [Product description], trans.transaction_product_id as [Product Description ID], trans.device_product_type as [Card Type], trans.device_product_number as [Card number], trans.license_plate_number as [Load File Licence Plate Number], '' as [Card Licence Plate Number], trans.license_plate_number as [Truck Licence Plate Number], '' as [Truck Fleet Code], '' as [Truck Driver Name], trans.entry_point_name as [Entry Terminal/Direction], trans.entry_datetime as [Start date], trans.entry_datetime as [Start Time], trans.exit_point_name as [Exit Terminal Description], trans.exit_datetime as [End Date], trans.exit_datetime as [End Time], @@ -5244,5 +5353,11 @@ Public Class frmStartOptions End Sub - + Private Sub LinkLabel65_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel65.LinkClicked + Me.Visible = False + VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxTestsystem.Checked + Dim f As New frmNachrichtenVerarbeitung_MDM_divers("IDS", False, False, False) + f.ShowDialog() + Me.Visible = True + End Sub End Class \ No newline at end of file