Initial commit
This commit is contained in:
92
EDKB07WS/Verarbeitung.vb
Normal file
92
EDKB07WS/Verarbeitung.vb
Normal file
@@ -0,0 +1,92 @@
|
||||
Imports System.Xml
|
||||
Imports System.IO
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Data.SqlTypes
|
||||
|
||||
Public Class Verarbeitung
|
||||
|
||||
Public Function AddPageToPDF(ByVal TGNr As String, ByVal timestmp As String, ByVal AnzahlDokumente As Integer, ByVal PartnerNr As Integer, ByVal PartnerKurzname As String, ByVal partno As Integer) As Boolean
|
||||
Dim log As New clsLog
|
||||
Dim spartno As String = LTrim(Str(partno))
|
||||
While Len(spartno) < 2
|
||||
spartno = "0" + spartno
|
||||
End While
|
||||
Try
|
||||
'Normal - mit einer Returndatei
|
||||
If partno = 0 Then
|
||||
Dim con As New SqlConnection(Globals.sConnectionString)
|
||||
Dim da As New SqlDataAdapter("Select * From edex_bl_druckjob where tgnummer ='" & TGNr & "' and filetimestamp=@erstelltam", con)
|
||||
da.SelectCommand.Parameters.AddWithValue("@erstelltam", timestmp)
|
||||
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet
|
||||
|
||||
' Dim fs As New FileStream(Globals.OutputFolder & "\" & TGNr & timestmp & "_done.pdf", FileMode.OpenOrCreate, FileAccess.Read)
|
||||
Dim fs As New FileStream(Globals.OutputFolder & "\" & TGNr & spartno + timestmp & ".pdf", FileMode.OpenOrCreate, FileAccess.Read)
|
||||
Dim MyData(fs.Length) As Byte
|
||||
fs.Read(MyData, 0, fs.Length)
|
||||
fs.Close()
|
||||
con.Open()
|
||||
da.Fill(ds, "edex_bl_druckjob")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables("edex_bl_druckjob").Rows(0)
|
||||
myRow("pdfdokument") = MyData
|
||||
da.Update(ds, "edex_bl_druckjob")
|
||||
fs = Nothing
|
||||
MyCB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
con.Close()
|
||||
con = Nothing
|
||||
File.Delete(Globals.TempPath & "\" & TGNr & spartno & timestmp & "_summary.pdf")
|
||||
log.InsertJournale("EDKB07: PDF-Ergänzung erfolgreich " & CType(Now, String) & " TGNr: " & TGNr & " Erstelltam: " & timestmp, clsLog.Enum_InfoTyp.Keine)
|
||||
Return True
|
||||
Else
|
||||
Dim con1 As New SqlConnection(Globals.sConnectionString)
|
||||
Dim da1 As New SqlDataAdapter("Select * From edex_bl_druckjob where tgnummer ='" & TGNr & "' and filetimestamp=@erstelltam", con1)
|
||||
da1.SelectCommand.Parameters.AddWithValue("@erstelltam", timestmp)
|
||||
Dim MyCB1 As SqlCommandBuilder = New SqlCommandBuilder(da1)
|
||||
Dim ds1 As New DataSet
|
||||
da1.Fill(ds1, "druckjob")
|
||||
Dim druckjobnr As Integer = ds1.Tables(0).Rows(0).Item("druckjobnr")
|
||||
con1.Dispose()
|
||||
da1.Dispose()
|
||||
MyCB1.Dispose()
|
||||
ds1.Dispose()
|
||||
|
||||
Dim con As New SqlConnection(Globals.sConnectionString)
|
||||
Dim da As New SqlDataAdapter("Select * From edex_bl_druckjob_part where druckjobnr=" + LTrim(Str(druckjobnr)) + " and partno=" + LTrim(Str(partno)), con)
|
||||
'da.SelectCommand.Parameters.Add("@erstelltam", timestmp)
|
||||
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet
|
||||
|
||||
'Dim fs As New FileStream(Globals.OutputFolder & "\" & TGNr & timestmp & "_done.pdf", FileMode.OpenOrCreate, FileAccess.Read)
|
||||
Dim fs As New FileStream(Globals.OutputFolder & "\" & TGNr & spartno & timestmp & ".pdf", FileMode.OpenOrCreate, FileAccess.Read)
|
||||
Dim MyData(fs.Length) As Byte
|
||||
fs.Read(MyData, 0, fs.Length)
|
||||
fs.Close()
|
||||
con.Open()
|
||||
da.Fill(ds, "edex_bl_druckjob_part")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables("edex_bl_druckjob_part").Rows(0)
|
||||
myRow("pdfdokument") = MyData
|
||||
da.Update(ds, "edex_bl_druckjob_part")
|
||||
fs = Nothing
|
||||
MyCB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
con.Close()
|
||||
con = Nothing
|
||||
File.Delete(Globals.TempPath & "\" & TGNr & spartno & timestmp & "_summary.pdf")
|
||||
log.InsertJournale("EDKB07: PDF-Ergänzung erfolgreich " & CType(Now, String) & " TGNr: " & TGNr & " Erstelltam: " & timestmp, clsLog.Enum_InfoTyp.Keine)
|
||||
Return True
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
log.InsertJournale("EDKB07: PDF-Ergänzung gescheitert " & CType(Now, String) & " Error: " & ex.Message & " TGNr: " & TGNr & " Erstelltam: " + timestmp, clsLog.Enum_InfoTyp.Warnung)
|
||||
Return False
|
||||
Finally
|
||||
log = Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user