|
|
'DocMgmt Klasse
|
|
|
'Autor: Stefan Hutter, Unternehmensberatung
|
|
|
'
|
|
|
'01.04.2003
|
|
|
'
|
|
|
Imports System
|
|
|
Imports System.IO
|
|
|
Imports System.Data
|
|
|
Imports System.Data.SqlTypes
|
|
|
Imports System.Data.SqlClient
|
|
|
Imports System.ComponentModel
|
|
|
Imports UtilityLibrary.Win32
|
|
|
|
|
|
Public Class EdokaUpd
|
|
|
|
|
|
#Region "Deklarationen"
|
|
|
Dim m_FileToRun
|
|
|
Property FileToRun()
|
|
|
Get
|
|
|
Return m_FileToRun
|
|
|
End Get
|
|
|
Set(ByVal Value)
|
|
|
m_FileToRun = Value
|
|
|
End Set
|
|
|
End Property
|
|
|
|
|
|
Dim m_file1 As String
|
|
|
Property File1() As String
|
|
|
Get
|
|
|
Return m_file1
|
|
|
End Get
|
|
|
Set(ByVal Value As String)
|
|
|
m_file1 = Value
|
|
|
End Set
|
|
|
End Property
|
|
|
|
|
|
Property m_file2() As String
|
|
|
Get
|
|
|
Return m_file2
|
|
|
End Get
|
|
|
Set(ByVal Value As String)
|
|
|
m_file2 = Value
|
|
|
End Set
|
|
|
End Property
|
|
|
#End Region
|
|
|
|
|
|
#Region "Save"
|
|
|
Public Function Save_To_DB(ByVal filename1 As String, ByVal filename2 As String, ByVal filetorun As String)
|
|
|
|
|
|
Dim Connection As New SqlConnection()
|
|
|
Dim DA As New SqlDataAdapter("select * from edokaupdate", Connection)
|
|
|
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(DA)
|
|
|
Dim ds As New DataSet()
|
|
|
Dim fs1 As New FileStream(filename1, FileMode.OpenOrCreate, FileAccess.Read)
|
|
|
Dim fs2 As New FileStream(filename2, FileMode.OpenOrCreate, FileAccess.Read)
|
|
|
Dim mydata(fs1.Length) As Byte
|
|
|
Dim mydata1(fs2.Length) As Byte
|
|
|
|
|
|
fs1.Read(mydata, 0, fs1.Length)
|
|
|
fs1.Close()
|
|
|
|
|
|
fs2.Read(mydata1, 0, fs2.Length)
|
|
|
fs2.Close()
|
|
|
Try
|
|
|
'Connectionstring zur Datenbank
|
|
|
Connection.ConnectionString = Globals.sConnectionString
|
|
|
Connection.Open()
|
|
|
DA.Fill(ds, "edokaupdate")
|
|
|
Dim myRow As DataRow
|
|
|
myRow = ds.Tables(0).Rows(0)
|
|
|
myRow.Item(0) = mydata
|
|
|
myRow.Item(1) = mydata1
|
|
|
myRow.Item(2) = filetorun
|
|
|
DA.Update(ds, "edokaupdate")
|
|
|
Catch ex As Exception
|
|
|
MsgBox("Automatischer Update von EDOKA kann nicht ausgef<65>hrt werden." & vbCrLf & ex.Message)
|
|
|
Return False
|
|
|
End Try
|
|
|
fs1 = Nothing
|
|
|
fs2 = Nothing
|
|
|
cb = Nothing
|
|
|
ds = Nothing
|
|
|
DA = Nothing
|
|
|
|
|
|
Connection.Close()
|
|
|
Connection = Nothing
|
|
|
Return True
|
|
|
End Function
|
|
|
#End Region
|
|
|
|
|
|
#Region "Get"
|
|
|
|
|
|
Public Function Get_From_DB(ByVal filename1 As String, ByVal filename2 As String, ByVal filetorun As String) As String
|
|
|
Dim connection As New SqlConnection()
|
|
|
Dim da As New SqlDataAdapter("Select * From edokaupdate", connection)
|
|
|
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
|
|
Dim ds As New DataSet()
|
|
|
Get_From_DB = ""
|
|
|
Try
|
|
|
'Connectionstring zur Datenbank
|
|
|
connection.ConnectionString = Globals.sConnectionString
|
|
|
connection.Open()
|
|
|
da.Fill(ds, "edokaupdate")
|
|
|
Dim myRow As DataRow
|
|
|
myRow = ds.Tables(0).Rows(0)
|
|
|
Dim MyData() As Byte
|
|
|
MyData = myRow.Item(0)
|
|
|
Dim MyData1() As Byte
|
|
|
MyData1 = myRow.Item(1)
|
|
|
Dim K As Long
|
|
|
Dim k1 As Long
|
|
|
K = UBound(MyData)
|
|
|
k1 = UBound(MyData1)
|
|
|
|
|
|
Dim fs1 As New FileStream(filename1, FileMode.OpenOrCreate, FileAccess.Write)
|
|
|
fs1.Write(MyData, 0, K)
|
|
|
fs1.Close()
|
|
|
fs1 = Nothing
|
|
|
|
|
|
Dim fs2 As New FileStream(filename2, FileMode.OpenOrCreate, FileAccess.Write)
|
|
|
fs2.Write(MyData1, 0, k1)
|
|
|
fs2.Close()
|
|
|
fs2 = Nothing
|
|
|
|
|
|
Me.FileToRun = myRow.Item(2)
|
|
|
Return Me.FileToRun
|
|
|
Catch ex As Exception
|
|
|
Return False
|
|
|
End Try
|
|
|
CB = Nothing
|
|
|
ds = Nothing
|
|
|
da = Nothing
|
|
|
connection.Close()
|
|
|
connection = Nothing
|
|
|
Return True
|
|
|
|
|
|
End Function
|
|
|
#End Region
|
|
|
|
|
|
#Region "Start"
|
|
|
Public Function PrepareUpdate() As String
|
|
|
Dim file1 As String
|
|
|
Dim file2 As String
|
|
|
Dim filetorun As String
|
|
|
Me.Get_From_DB(DivFnkt.Get_Filename("EdokaUpdate.dat", ""), DivFnkt.Get_Filename("UpdateEdoka.cmd", ""), filetorun)
|
|
|
Return Me.FileToRun
|
|
|
End Function
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
End Class
|