Initial commit
This commit is contained in:
618
EDKB07WS/Backup1/ModPrintjob.vb
Normal file
618
EDKB07WS/Backup1/ModPrintjob.vb
Normal file
@@ -0,0 +1,618 @@
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.IO
|
||||
Imports Microsoft.Office.Interop
|
||||
|
||||
Module ModPrintjob
|
||||
'Dim objword As New Microsoft.Office.Interop.Word.ApplicationClass()
|
||||
'Dim objword As New Word.ApplicationClass()
|
||||
'Dim docword As New Word.DocumentClass()
|
||||
Dim objword As New Word.Application()
|
||||
Dim docword As New Word.Document()
|
||||
Dim alnr As Integer
|
||||
Dim TmpData As New DataTable()
|
||||
|
||||
Dim Dokumentname_Dokumente As String
|
||||
Dim Dokumentname_Quittung As String
|
||||
Dim Dokumentname_Quittung_PS As String
|
||||
Dim Dokumentname_Quittung_PDF As String
|
||||
Dim Dokumentname_Summary As String
|
||||
Dim Dokumentname_Summary_PS As String
|
||||
Dim Dokumentname_Summary_PDF As String
|
||||
Dim Dokumentname_Startblatt As String
|
||||
Dim Dokumentname_Schlussblatt As String
|
||||
Dim Dokumentname_Startblatt_PDF As String
|
||||
Dim Dokumentname_Schlussblatt_PDF As String
|
||||
Dim Dokumentname_Dokumente_PDF As String
|
||||
|
||||
Dim DokPrefix As String
|
||||
Dim dokumentid As String
|
||||
Dim FileExtension As String = ""
|
||||
|
||||
Function Print_Docs(ByVal intalnr As Integer, ByVal partno As Integer) As Boolean
|
||||
Try
|
||||
alnr = intalnr
|
||||
TmpData = Get_ALDaten(alnr)
|
||||
dokumentid = TmpData.Rows(0).Item("dokumentid_quittung")
|
||||
Dim tmpfn As String = Get_Filename(dokumentid)
|
||||
Dim extension As String = Right(tmpfn, 5)
|
||||
extension = UCase(extension)
|
||||
FileExtension = extension
|
||||
Select Case extension
|
||||
Case ".DOCX"
|
||||
Dokumentname_Quittung = DokPrefix + "_" + dokumentid + ".docx"
|
||||
Dokumentname_Summary = DokPrefix + "_" + dokumentid + "_Su.docx"
|
||||
Case ".DOTX"
|
||||
Dokumentname_Quittung = DokPrefix + "_" + dokumentid + ".dotx"
|
||||
Dokumentname_Summary = DokPrefix + "_" + dokumentid + "_Su.dotx"
|
||||
Case ".DOTM"
|
||||
Dokumentname_Quittung = DokPrefix + "_" + dokumentid + ".dotm"
|
||||
Dokumentname_Summary = DokPrefix + "_" + dokumentid + "_Su.dotm"
|
||||
Case ".DOCM"
|
||||
Dokumentname_Quittung = DokPrefix + "_" + dokumentid + ".docm"
|
||||
Dokumentname_Summary = DokPrefix + "_" + dokumentid + "_Su.docm"
|
||||
Case Else
|
||||
Dokumentname_Quittung = DokPrefix + "_" + dokumentid + ".doc"
|
||||
Dokumentname_Summary = DokPrefix + "_" + dokumentid + "_Su.doc"
|
||||
End Select
|
||||
|
||||
|
||||
DokPrefix = Format(Now, "yyyyMMddHHmmss")
|
||||
Dokumentname_Quittung_PS = DokPrefix + "_" + dokumentid + ".ps"
|
||||
Dokumentname_Quittung_PDF = DokPrefix + "_" + dokumentid + ".pdf"
|
||||
Dokumentname_Summary_PS = DokPrefix + "_" + dokumentid + "_Su.ps"
|
||||
Dokumentname_Summary_PDF = DokPrefix + "_" + dokumentid + "_Su.pdf"
|
||||
Dokumentname_Startblatt_PDF = DokPrefix + "_" + dokumentid + "_DB.pdf"
|
||||
Dokumentname_Schlussblatt_PDF = DokPrefix + "_" + dokumentid + "_SB.pdf"
|
||||
Dokumentname_Dokumente_PDF = DokPrefix + "_" + dokumentid + "_docs.pdf"
|
||||
|
||||
Dokumente_Bereitstellen(partno)
|
||||
|
||||
|
||||
StartWord()
|
||||
PrintLog("Generate Quittung:" + alnr.ToString + ":" + partno.ToString, EventLogEntryType.Information)
|
||||
Generate_Quittung(alnr, partno)
|
||||
|
||||
Dim i As Integer
|
||||
If partno = 0 Then
|
||||
For i = 1 To 50
|
||||
If File.Exists(PDFdir + Dokumentname_Quittung_PDF) And File.Exists(PDFdir + Dokumentname_Summary_PDF) Then
|
||||
Exit For
|
||||
End If
|
||||
Threading.Thread.Sleep(1000)
|
||||
Next
|
||||
Else
|
||||
For i = 1 To 50
|
||||
If File.Exists(PDFdir + Dokumentname_Summary_PDF) Then
|
||||
Exit For
|
||||
End If
|
||||
Threading.Thread.Sleep(1000)
|
||||
Next
|
||||
End If
|
||||
Generate_PDF(partno)
|
||||
SavePdf(partno)
|
||||
|
||||
|
||||
File.Delete(Workverzeichnis + Dokumentname_Summary)
|
||||
File.Delete(Workverzeichnis + Dokumentname_Summary_PDF)
|
||||
File.Delete(Workverzeichnis + Dokumentname_Quittung)
|
||||
File.Delete(Workverzeichnis + Dokumentname_Quittung_PDF)
|
||||
File.Delete(Workverzeichnis + Dokumentname_Schlussblatt_PDF)
|
||||
File.Delete(Workverzeichnis + Dokumentname_Startblatt_PDF)
|
||||
File.Delete(PDFdir + Dokumentname_Summary_PDF)
|
||||
File.Delete(PDFdir + Dokumentname_Summary_PS)
|
||||
File.Delete(PDFdir + Dokumentname_Quittung_PDF)
|
||||
File.Delete(PDFdir + Dokumentname_Quittung_PS)
|
||||
File.Delete(Workverzeichnis + Dokumentname_Dokumente_PDF)
|
||||
File.Delete(Workverzeichnis + "Done_" + Dokumentname_Dokumente_PDF)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Globals.PrintLog("Printjob:" + LTrim(Str(alnr)) + ":" + ex.Message)
|
||||
m_log.Log("ModPrintJob:Print_Docs:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Private Sub SavePdf(ByVal partno As Integer)
|
||||
If partno = 0 Then
|
||||
Dim con As New SqlConnection(Globals.sConnectionString)
|
||||
Dim da As New SqlDataAdapter("Select * From edex_bl_druckjob where druckjobnr=" + Trim(Str(TmpData.Rows(0).Item("druckjobnr"))), con)
|
||||
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
|
||||
Dim fs As New FileStream(Workverzeichnis + "Done_" + Dokumentname_Dokumente_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_aufbereitet") = MyData
|
||||
da.Update(ds, "edex_bl_druckjob")
|
||||
fs = Nothing
|
||||
MyCB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
con.Close()
|
||||
con = Nothing
|
||||
Else
|
||||
Dim con As New SqlConnection(Globals.sConnectionString)
|
||||
Dim da As New SqlDataAdapter("Select * From edex_bl_druckjob_part where druckjobnr=" + Trim(Str(TmpData.Rows(0).Item("druckjobnr"))) + " and partno=" + LTrim(Str(partno)), con)
|
||||
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
|
||||
Dim fs As New FileStream(Workverzeichnis + "Done_" + Dokumentname_Dokumente_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_aufbereitet") = MyData
|
||||
da.Update(ds, "edex_bl_druckjob_part")
|
||||
fs = Nothing
|
||||
MyCB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
con.Close()
|
||||
con = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Dokumente_Bereitstellen(ByVal partno As Integer)
|
||||
'FileCopy(Vorlagenverzeichnis + "Startblatt.pdf", Workverzeichnis + Dokumentname_Startblatt_PDF)
|
||||
'Anpassung Cutover 01.08.2008 - Werbeversand für BL Kunen
|
||||
If check_Werbung(alnr) Then
|
||||
FileCopy(Vorlagenverzeichnis + "StartblattWerbung.pdf", Workverzeichnis + Dokumentname_Startblatt_PDF)
|
||||
Else
|
||||
FileCopy(Vorlagenverzeichnis + "Startblatt.pdf", Workverzeichnis + Dokumentname_Startblatt_PDF)
|
||||
End If
|
||||
|
||||
FileCopy(Vorlagenverzeichnis + "Schlussblatt.pdf", Workverzeichnis + Dokumentname_Schlussblatt_PDF)
|
||||
|
||||
Select Case FileExtension
|
||||
Case ".DOCX"
|
||||
FileCopy(Vorlagenverzeichnis + "SummaryLyt.docx", Workverzeichnis + Dokumentname_Summary)
|
||||
Case ".DOTX"
|
||||
FileCopy(Vorlagenverzeichnis + "SummaryLyt.dotx", Workverzeichnis + Dokumentname_Summary)
|
||||
Case ".DOTM"
|
||||
FileCopy(Vorlagenverzeichnis + "SummaryLyt.dotx", Workverzeichnis + Dokumentname_Summary)
|
||||
Case ".DOCM"
|
||||
FileCopy(Vorlagenverzeichnis + "SummaryLyt.docm", Workverzeichnis + Dokumentname_Summary)
|
||||
Case Else
|
||||
FileCopy(Vorlagenverzeichnis + "SummaryLyt.doc", Workverzeichnis + Dokumentname_Summary)
|
||||
End Select
|
||||
|
||||
|
||||
Get_Quittung()
|
||||
Get_Dokumente(partno)
|
||||
End Sub
|
||||
|
||||
Private Function Get_Quittung() As Boolean
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From doks where DokumentID='" + dokumentid + "'", connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.Fill(ds, "docs")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Dim MyData() As Byte
|
||||
MyData = myRow.Item(1)
|
||||
Dim K As Long
|
||||
K = UBound(MyData)
|
||||
Dim fs As New FileStream(Workverzeichnis + Dokumentname_Quittung, FileMode.OpenOrCreate, FileAccess.Write)
|
||||
fs.Write(MyData, 0, K)
|
||||
fs.Close()
|
||||
fs = Nothing
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:Get_Quittung:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Return False
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function Get_Dokumente(ByVal partno As Integer) As Boolean
|
||||
If partno = 0 Then
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From edex_bl_druckjob where druckjobnr=" + LTrim(Str(TmpData.Rows(0).Item("Druckjobnr"))), connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.Fill(ds, "docs")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Dim MyData() As Byte
|
||||
MyData = myRow.Item("pdfdokument")
|
||||
Dim K As Long
|
||||
K = UBound(MyData)
|
||||
Dim fs As New FileStream(Workverzeichnis + Dokumentname_Dokumente_PDF, FileMode.OpenOrCreate, FileAccess.Write)
|
||||
fs.Write(MyData, 0, K)
|
||||
fs.Close()
|
||||
fs = Nothing
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:Get_Dokumente:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Return False
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
Else
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From edex_bl_druckjob_part where druckjobnr=" + LTrim(Str(TmpData.Rows(0).Item("Druckjobnr"))) + " and partno=" + LTrim(Str(partno)), connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
Try
|
||||
connection.ConnectionString = Globals.sConnectionString
|
||||
connection.Open()
|
||||
da.Fill(ds, "docs")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
Dim MyData() As Byte
|
||||
MyData = myRow.Item("pdfdokument")
|
||||
Dim K As Long
|
||||
K = UBound(MyData)
|
||||
Dim fs As New FileStream(Workverzeichnis + Dokumentname_Dokumente_PDF, FileMode.OpenOrCreate, FileAccess.Write)
|
||||
fs.Write(MyData, 0, K)
|
||||
fs.Close()
|
||||
fs = Nothing
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:Get_Dokumente:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Return False
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
End If
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub Generate_Quittung(ByVal alnr As Integer, ByVal partno As Integer)
|
||||
If partno = 0 Then
|
||||
objword.Documents.Open(Workverzeichnis + Dokumentname_Quittung)
|
||||
objword.Visible = True
|
||||
'objword.WindowState = Word.WdWindowState.wdWindowStateMinimize
|
||||
docword = objword.ActiveDocument
|
||||
If Globals.Office2010 = True Then
|
||||
Try
|
||||
' docword.ExportAsFixedFormat(PDFdir + Dokumentname_Quittung_PDF, Word.WdExportFormat.wdExportFormatPDF)
|
||||
docword.ExportAsFixedFormat(PDFdir + Dokumentname_Quittung_PDF, Word.WdExportFormat.wdExportFormatPDF, , Word.WdExportOptimizeFor.wdExportOptimizeForPrint, Word.WdExportRange.wdExportAllDocument, , , Word.WdExportItem.wdExportDocumentContent, True, True, Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, True, False, False)
|
||||
|
||||
Threading.Thread.CurrentThread.Sleep(1000)
|
||||
Catch ex As Exception
|
||||
PrintLog(ex.Message, EventLogEntryType.Information)
|
||||
End Try
|
||||
|
||||
Else
|
||||
objword.ActivePrinter = PSPrinter
|
||||
docword.PrintOut(OutputFileName:=psdir + Dokumentname_Quittung_PS, PrintToFile:=False, Copies:=1)
|
||||
End If
|
||||
docword.Saved = True
|
||||
docword.Close(SaveChanges:=False)
|
||||
End If
|
||||
Dim i As Integer
|
||||
Dim f3 As Acrobat.CAcroPDDoc
|
||||
f3 = CreateObject("AcroExch.PDDoc")
|
||||
PrintLog(Workverzeichnis + Dokumentname_Dokumente_PDF, EventLogEntryType.Information)
|
||||
i = f3.Open(Workverzeichnis + Dokumentname_Dokumente_PDF)
|
||||
|
||||
objword.Documents.Open(Workverzeichnis + Dokumentname_Summary)
|
||||
objword.Visible = True
|
||||
docword = objword.ActiveDocument
|
||||
Try
|
||||
docword.Bookmarks.Item("Besteller").Select()
|
||||
objword.Selection.Text = TmpData.Rows(0).Item("Besteller")
|
||||
docword.Bookmarks.Item("Partner").Select()
|
||||
objword.Selection.Text = Trim(Str(TmpData.Rows(0).Item("nrpar00")) + " " + TmpData.Rows(0).Item("bkpar00"))
|
||||
docword.Bookmarks.Item("AnzahlDokumente").Select()
|
||||
objword.Selection.Text = Trim(Str(TmpData.Rows(0).Item("anzahl_dokument")))
|
||||
docword.Bookmarks.Item("AnzahlSeiten").Select()
|
||||
objword.Selection.Text = Trim(Str(f3.GetNumPages))
|
||||
docword.Bookmarks.Item("DatumZeit").Select()
|
||||
objword.Selection.Text = Now.ToShortDateString + " " + Now.ToShortTimeString
|
||||
|
||||
docword.Bookmarks.Item("AnzahlVertraege").Select()
|
||||
objword.Selection.Text = Get_Anzahl_Vertraege(alnr)
|
||||
|
||||
If TmpData.Rows(0).Item("Anzparts") > 0 Then
|
||||
docword.Bookmarks.Item("AnzahlTeile").Select()
|
||||
objword.Selection.Text = "Teil " + LTrim(Str(partno + 1)) + " von " + LTrim(Str(TmpData.Rows(0).Item("anzparts") + 1))
|
||||
docword.Bookmarks.Item("Teil1").Select()
|
||||
objword.Selection.Text = "(Total über alle Druckteile)"
|
||||
docword.Bookmarks.Item("Teil2").Select()
|
||||
objword.Selection.Text = "(Total über alle Druckteile)"
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:Generate_Quittung:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Finally
|
||||
f3.Close()
|
||||
f3 = Nothing
|
||||
End Try
|
||||
If Globals.Office2010 = True Then
|
||||
docword.ExportAsFixedFormat(PDFdir + Dokumentname_Summary_PDF, Word.WdExportFormat.wdExportFormatPDF, , Word.WdExportOptimizeFor.wdExportOptimizeForPrint, Word.WdExportRange.wdExportAllDocument, , , Word.WdExportItem.wdExportDocumentContent, True, True, Word.WdExportCreateBookmarks.wdExportCreateNoBookmarks, True, False, False)
|
||||
' docword.ExportAsFixedFormat(PDFdir + Dokumentname_Summary_PDF, Word.WdExportFormat.wdExportFormatPDF)
|
||||
Threading.Thread.CurrentThread.Sleep(1000)
|
||||
Else
|
||||
objword.ActivePrinter = PSPrinter
|
||||
docword.PrintOut(OutputFileName:=psdir + Dokumentname_Summary_PS, PrintToFile:=False, Copies:=1)
|
||||
End If
|
||||
docword.Close(SaveChanges:=False)
|
||||
objword = Nothing
|
||||
End Sub
|
||||
|
||||
Private Sub Generate_PDF(ByVal partno As Integer)
|
||||
Dim f1 As Acrobat.CAcroPDDoc
|
||||
Dim f2 As Acrobat.CAcroPDDoc
|
||||
Dim f3 As Acrobat.CAcroPDDoc
|
||||
Dim f4 As Acrobat.CAcroPDDoc
|
||||
Dim f5 As Acrobat.CAcroPDDoc
|
||||
f1 = CreateObject("AcroExch.PDDoc")
|
||||
f2 = CreateObject("AcroExch.PDDoc")
|
||||
f3 = CreateObject("AcroExch.PDDoc")
|
||||
f4 = CreateObject("AcroExch.PDDoc")
|
||||
f5 = CreateObject("AcroExch.PDDoc")
|
||||
|
||||
Dim i As Integer
|
||||
i = f1.Open(Workverzeichnis + Dokumentname_Schlussblatt_PDF)
|
||||
|
||||
If IsDate(Globals.Beilage_1_ab) Then
|
||||
If IO.File.Exists(Globals.Beilage_1) Then
|
||||
If check_Beilage(alnr, Globals.Beilage_1_ab) Then
|
||||
Dim fbeilage As Acrobat.CAcroPDDoc
|
||||
fbeilage = CreateObject("AcroExch.PDDoc")
|
||||
fbeilage.Open(Globals.Beilage_1)
|
||||
i = f1.InsertPages(-1, fbeilage, 0, fbeilage.GetNumPages, 1)
|
||||
fbeilage.Close()
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
If IsDate(Globals.Beilage_2_ab) Then
|
||||
If IO.File.Exists(Globals.Beilage_2) Then
|
||||
If check_Beilage(alnr, Globals.Beilage_2_ab) Then
|
||||
Dim fbeilage As Acrobat.CAcroPDDoc
|
||||
fbeilage = CreateObject("AcroExch.PDDoc")
|
||||
fbeilage.Open(Globals.Beilage_2)
|
||||
i = f1.InsertPages(-1, fbeilage, 0, fbeilage.GetNumPages, 1)
|
||||
fbeilage.Close()
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
If IsDate(Globals.Beilage_3_ab) Then
|
||||
If IO.File.Exists(Globals.Beilage_3) Then
|
||||
If check_Beilage(alnr, Globals.Beilage_3_ab) Then
|
||||
Dim fbeilage As Acrobat.CAcroPDDoc
|
||||
fbeilage = CreateObject("AcroExch.PDDoc")
|
||||
fbeilage.Open(Globals.Beilage_3)
|
||||
i = f1.InsertPages(-1, fbeilage, 0, fbeilage.GetNumPages, 1)
|
||||
fbeilage.Close()
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
i = f2.Open(Workverzeichnis + Dokumentname_Dokumente_PDF)
|
||||
i = f3.Open(PDFdir + Dokumentname_Summary_PDF)
|
||||
If partno = 0 Then
|
||||
i = f4.Open(PDFdir + Dokumentname_Quittung_PDF)
|
||||
End If
|
||||
i = f5.Open(Workverzeichnis + Dokumentname_Startblatt_PDF)
|
||||
i = f1.InsertPages(-1, f2, 0, f2.GetNumPages, 1)
|
||||
i = f1.InsertPages(-1, f3, 0, f3.GetNumPages, 1)
|
||||
If partno = 0 Then
|
||||
i = f1.InsertPages(-1, f4, 0, f4.GetNumPages, 1)
|
||||
End If
|
||||
'i = f1.InsertPages(-1, f5, 0, 1, 1)
|
||||
'Anpassung MNK - Cutover 01.08.2008 BL-Beilagen
|
||||
i = f1.InsertPages(-1, f5, 0, f5.GetNumPages, 1)
|
||||
i = f1.Save(Acrobat.PDSaveFlags.PDSaveFull, Workverzeichnis + "Done_" + Dokumentname_Dokumente_PDF)
|
||||
'i = f1.Save(Acrobat.PDDocFlags.PDDocOldVersion, Workverzeichnis + "Done_" + Dokumentname_Dokumente_PDF)
|
||||
|
||||
f1.Close()
|
||||
f2.Close()
|
||||
f3.Close()
|
||||
f4.Close()
|
||||
f5.Close()
|
||||
f1 = Nothing
|
||||
f2 = Nothing
|
||||
f3 = Nothing
|
||||
f4 = Nothing
|
||||
f5 = Nothing
|
||||
'System.Runtime.InteropServices.Marshal.ReleaseComObject(f1)
|
||||
End Sub
|
||||
|
||||
#Region "Datenzugriffe"
|
||||
Public Function Get_ALDaten(ByVal alnr As Integer) As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.SP_edex_bl_get_aldaten"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@alnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, alnr))
|
||||
scmCmdToExecute.Connection = Globals.conn_edoka.scoDBConnection
|
||||
Globals.conn_edoka.OpenConnection()
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("Dokumenterstellung::Generic_Select::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
Globals.conn_edoka.CloseConnection(True)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Get_Filename(ByVal DokId As String) As String
|
||||
Dim result As String = ""
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "Select dokumentname from dokument where dokumentid='" + DokId + "'"
|
||||
scmCmdToExecute.CommandType = CommandType.Text
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@alnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, alnr))
|
||||
scmCmdToExecute.Connection = Globals.conn_edoka.scoDBConnection
|
||||
Globals.conn_edoka.OpenConnection()
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
result = dtToReturn.Rows(0).Item(0)
|
||||
Catch ex As Exception
|
||||
result = "error.doc"
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
Throw New Exception("Dokumenterstellung::Generic_Select::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
Globals.conn_edoka.CloseConnection(True)
|
||||
End Try
|
||||
Return result
|
||||
End Function
|
||||
Public Function Get_Anzahl_Vertraege(ByVal alnr As Integer) As String
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.SP_edex_bl_get_anzahl_vertraege"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@alnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, alnr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@anzahl", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
|
||||
scmCmdToExecute.Connection = Globals.conn_edoka.scoDBConnection
|
||||
Globals.conn_edoka.OpenConnection()
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return LTrim(Str(scmCmdToExecute.Parameters("@anzahl").Value))
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:Get_Anzahl_Vertraege:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Return "?"
|
||||
' // some error occured. Bubble it to caller and encapsulate Exception object
|
||||
'Throw New Exception("Dokumenterstellung::Generic_Select::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
Globals.conn_edoka.CloseConnection(True)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Methode, welche prueft ob der Aushaendigung Werbung beigelegt werden soll
|
||||
''' </summary>
|
||||
''' <param name="alnr"></param>
|
||||
''' <returns>boolean</returns>
|
||||
''' <remarks></remarks>
|
||||
Private Function check_Werbung(ByVal alnr As Integer) As Boolean
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.sp_edex_bl_check_Werbung"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@alnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, alnr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@werbung", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
|
||||
scmCmdToExecute.Connection = Globals.conn_edoka.scoDBConnection
|
||||
Globals.conn_edoka.OpenConnection()
|
||||
|
||||
Dim returnValue As Boolean
|
||||
|
||||
returnValue = False
|
||||
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
If scmCmdToExecute.Parameters("@werbung").Value > 0 Then
|
||||
returnValue = True
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:check_Werbung:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Finally
|
||||
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
Globals.conn_edoka.CloseConnection(True)
|
||||
End Try
|
||||
Return returnValue
|
||||
End Function
|
||||
|
||||
|
||||
Private Function check_Beilage(ByVal alnr As Integer, ByVal beilagedatum As String) As Boolean
|
||||
If beilagedatum > Now Then
|
||||
Return False
|
||||
Exit Function
|
||||
End If
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
scmCmdToExecute.CommandText = "dbo.sp_edex_bl_check_beilage"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@alnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, alnr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@beilagedatum", SqlDbType.VarChar, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, beilagedatum))
|
||||
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@Beilage", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
|
||||
scmCmdToExecute.Connection = Globals.conn_edoka.scoDBConnection
|
||||
Globals.conn_edoka.OpenConnection()
|
||||
|
||||
Dim returnValue As Boolean
|
||||
|
||||
returnValue = False
|
||||
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
If scmCmdToExecute.Parameters("@Beilage").Value > 0 Then
|
||||
returnValue = True
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:check_Beilage:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
Globals.conn_edoka.CloseConnection(True)
|
||||
End Try
|
||||
Return returnValue
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Office Funktionen"
|
||||
|
||||
Public Sub StartWord()
|
||||
'Auskommentiert durch MNK 20080902 - Sinnlos - kann nicht genutzt werden
|
||||
'Try
|
||||
' Kill("WINWORD")
|
||||
'Catch ex As Exception
|
||||
' m_log.Log("ModPrintJob:StartWord_Kill:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
'End Try
|
||||
|
||||
Try
|
||||
objword = GetObject(, "Word.application")
|
||||
objword.Visible = False
|
||||
Catch ex As Exception
|
||||
m_log.Log("ModPrintJob:StartWord_GetObject:" + ex.Message + ex.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
Try
|
||||
objword = CreateObject("Word.application")
|
||||
|
||||
objword.Visible = False
|
||||
Catch ex1 As Exception
|
||||
m_log.Log("ModPrintJob:StartWord_CreateObject:" + ex1.Message + ex1.StackTrace, Common.Common.JournalEntryType.Warning)
|
||||
End Try
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
End Module
|
||||
Reference in New Issue
Block a user