You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

395 lines
15 KiB

' ///////////////////////////////////////////////////////////////////////////
' // Description: Data Access class for the table 'Reporting_Dokumenttyp'
' // Generated by LLBLGen v1.2.1045.38210 Final on: Donnerstag, 30. Januar 2003, 20:31:17
' // Because the Base Class already implements IDispose, this class doesn't.
' ///////////////////////////////////////////////////////////////////////////
Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports UtilityLibrary.Win32
Namespace edokadb
' /// <summary>
' /// Purpose: Data Access class for the table 'Reporting_Dokumenttyp'.
' /// </summary>
Public Class clsReporting_Dokumenttyp
Inherits clsDBInteractionBase
#Region " Class Member Declarations "
Private m_dokumentname As String
Private m_dokumentid As String
Private m_bUsed As SqlBoolean
Private m_iType As SqlInt32
Private m_sDEFFELD, m_sDEFDESC, m_sDEFVALUE, m_sOFBM, m_sID, m_sOFFeld, m_sDEFBME, m_sDEFBMB As SqlString
#End Region
#Region " Class Property Declarations "
Property Dokumentname() As String
Get
Return m_dokumentname
End Get
Set(ByVal Value As String)
m_dokumentname = Value
End Set
End Property
Property DokumentID() As String
Get
Return m_dokumentid
End Get
Set(ByVal Value As String)
m_dokumentid = Value
End Set
End Property
Public Property [sID]() As SqlString
Get
Return m_sID
End Get
Set(ByVal Value As SqlString)
m_sID = Value
End Set
End Property
Public Property [sOFBM]() As SqlString
Get
Return m_sOFBM
End Get
Set(ByVal Value As SqlString)
m_sOFBM = Value
End Set
End Property
Public Property [sOFFeld]() As SqlString
Get
Return m_sOFFeld
End Get
Set(ByVal Value As SqlString)
m_sOFFeld = Value
End Set
End Property
Public Property [sDEFBMB]() As SqlString
Get
Return m_sDEFBMB
End Get
Set(ByVal Value As SqlString)
m_sDEFBMB = Value
End Set
End Property
Public Property [sDEFBME]() As SqlString
Get
Return m_sDEFBME
End Get
Set(ByVal Value As SqlString)
m_sDEFBME = Value
End Set
End Property
Public Property [sDEFFELD]() As SqlString
Get
Return m_sDEFFELD
End Get
Set(ByVal Value As SqlString)
m_sDEFFELD = Value
End Set
End Property
Public Property [sDEFDESC]() As SqlString
Get
Return m_sDEFDESC
End Get
Set(ByVal Value As SqlString)
m_sDEFDESC = Value
End Set
End Property
Public Property [sDEFVALUE]() As SqlString
Get
Return m_sDEFVALUE
End Get
Set(ByVal Value As SqlString)
m_sDEFVALUE = Value
End Set
End Property
Public Property [iType]() As SqlInt32
Get
Return m_iType
End Get
Set(ByVal Value As SqlInt32)
m_iType = Value
End Set
End Property
Public Property [bUsed]() As SqlBoolean
Get
Return m_bUsed
End Get
Set(ByVal Value As SqlBoolean)
m_bUsed = Value
End Set
End Property
#End Region
#Region "Save Reportdocument To DB"
Public Function Save_To_DB(ByVal sDokumentID As String, ByVal sDokumentName As String, ByVal DokumentSpaltenname As String, ByVal RowIndex As Integer) As Boolean
'===============================================================================
'Beschr: Einlesen eines Reportfile in die Datenbank
'Input : Dataset
' DokumentNr = Identifikation des Dokument
' Dokumentname(inkl.Pfad)
' DokumentSpaltenname = Spaltenname f<>r das Dokunent
' RowIndex = aktuelle Datasetreihe
'Output: True/False
'Erstellt : koe 20.10.2003
'Geaendert :
'===============================================================================
Try
Me.DokumentID = sDokumentID
Me.Dokumentname = sDokumentName
Dim Connection As New SqlConnection()
Dim DA As New SqlDataAdapter("select * from report where reportNr= " + sDokumentID, Connection)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(DA)
Dim ds As New DataSet()
Dim fs As New FileStream(sDokumentName, FileMode.OpenOrCreate, FileAccess.Read)
Dim mydata(fs.Length) As Byte
Try
Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Dokument von Filesystem lesen")
fs.Read(mydata, 0, fs.Length)
fs.Close()
Connection.ConnectionString = Globals.sConnectionString
Connection.Open()
DA.Fill(ds, "docs")
Dim myRow As DataRow
If ds.Tables(0).Rows.Count = 0 Then
' Neues Dokument speichern
myRow = ds.Tables(0).NewRow
myRow.Item(0) = Me.DokumentID
myRow.Item(1) = mydata
ds.Tables(0).Rows.Add(myRow)
DA.Update(ds, "docs")
Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Neues Dokument gespeichert")
Else
'Bestehendes Dokument sichenr
myRow = ds.Tables("docs").Rows(0)
myRow.Item("reportfile") = mydata
DA.Update(ds, "docs")
Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Bestehendes Dokument ersetzt")
End If
Catch ex As Exception
Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Fehler bei der Dokumentspeicherung")
MyMsg.show_standardmessage(86, MsgBoxStyle.Critical)
' MsgBox(ex.Message)
Return False
End Try
fs = Nothing
cb = Nothing
ds = Nothing
DA = Nothing
Connection.Close()
Connection = Nothing
Return True
Catch
Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Fehler bei der Dokumentspeicherung")
MyMsg.show_standardmessage(86, MsgBoxStyle.Critical)
Return False
End Try
'---------------------------------------------------------------------------------------
'Me.DokumentID = sDokumentID
'Me.Dokumentname = sDokumentName
'Dim fs As New FileStream(Me.Dokumentname, FileMode.OpenOrCreate, FileAccess.Read)
'Dim mydata(fs.Length) As Byte
'Try
' '============ Dokument von Filesystem lesen
' Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Report von Filesystem lesen")
' fs.Read(mydata, 0, fs.Length)
' fs.Close()
' Dim myRow As DataRow
' '============ Dokument speichern
' ds.Tables(0).Rows(RowIndex).Item(DokumentSpaltenname) = mydata
' Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Neuer Report gespeichert")
'Catch ex As Exception
' Globals.PerfMon.insert_entry(Me.DokumentID + " ---- Fehler bei der Reportspeicherung")
' MyMsg.show_standardmessage(86, MsgBoxStyle.Critical)
' Return False
'End Try
'fs = Nothing
''ds = Nothing
'Return True
End Function
#End Region
#Region "Get Reportdocument From DB"
Public Function Get_DocumentFrom_DB(ByVal DokumentIDSpaltenname As String, ByVal DokumentID As String, ByVal Tabellenname As String, ByVal DokumentSpaltenname As String, ByVal DokumentePfad As String, ByVal DokumentenName As String) As Boolean
'===============================================================================
'Beschr: Liest ein Dokument aus der Datenbank und speichert die auf den Fileserver
' Ein bestehendes File wird <20>berschrieben
'Input : DokumentIDSpaltenname = Spalte f<>r die Identifikation des Dokument
' DokumentID = Eindeutige Identifikation des Dokument
' Tabellenname = Tabell in der das File gespeichert ist
' Spaltenname = Spaltenname in der das Dokument gespeichert ist
' Dokumentenname = Name des Dokumentes inkl. Pfadangaben
'Output: Speicherung erfolgreich True/False
'Erstellt : koe 20.10.2003
'Geaendert :
'===============================================================================
Me.DokumentID = DokumentID
Me.Dokumentname = DokumentenName
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From " & Tabellenname & " where " & DokumentIDSpaltenname & " = '" + Me.DokumentID + "'", connection)
Dim ds As New DataSet()
'===============================================================================
'Verzeichnispr<70>ffung
'===============================================================================
Try
If Right(DokumentePfad, 1) <> "\" Then
DokumentePfad = DokumentePfad & "\"
End If
If Not System.IO.Directory.Exists(DokumentePfad) Then
System.IO.Directory.CreateDirectory(DokumentePfad)
End If
Catch ex As Exception
MessageBox.Show("Vereichnis " & DokumentePfad & " kann nicht hergestellt werden!", "Verzeichnis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return False
End Try
Try
'Connectionstring zur Datenbank
connection.ConnectionString = Globals.sConnectionString
connection.Open()
da.Fill(ds, "Dokument")
Dim myRow As DataRow
myRow = ds.Tables(0).Rows(0)
Dim MyData() As Byte
MyData = myRow.Item(DokumentSpaltenname)
Dim lCnt As Long
lCnt = UBound(MyData)
Dim fs As New FileStream(DokumentePfad & DokumentenName, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(MyData, 0, lCnt)
fs.Close()
fs = Nothing
Catch ex As Exception
MsgBox(ex.Message)
'If Not DivFnkt.isbck(Me.DokumentID) Then
'MyMsg.show_standardmessage(93, MsgBoxStyle.Critical)
'End If
Return False
End Try
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
Return True
End Function
Public Function Get_From_DB(ByVal sDokumentID As String, ByVal sDokumentName As String) As Boolean
Me.DokumentID = sDokumentID
Me.Dokumentname = sDokumentName
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From doks where DokumentID='" + Me.DokumentID + "'", connection)
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet()
Try
'Connectionstring zur Datenbank
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(sDokumentName, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
Catch ex As Exception
If Not DivFnkt.isbck(Me.DokumentID) Then
MyMsg.show_standardmessage(93, MsgBoxStyle.Critical)
End If
Return False
End Try
CB = Nothing
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
Return True
End Function
Public Function Get_layout_from_DB(ByVal profilnr As Integer, ByVal sdokumentname As String) As String
Me.Dokumentname = LTrim(Str(profilnr)) + ".lyt"
Dim connection As New SqlConnection()
Dim da As New SqlDataAdapter("Select * From profillayout where profilnr=" + Str(profilnr), 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
If Right(sdokumentname, 8) = "HOST.lyt" Then
MyData = myRow.Item(2)
Else
MyData = myRow.Item(1)
End If
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream(sdokumentname, FileMode.OpenOrCreate, FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
Catch ex As Exception
Return False
End Try
CB = Nothing
ds = Nothing
da = Nothing
connection.Close()
connection = Nothing
Return True
End Function
#End Region
End Class
End Namespace