commit a335fed25633a831b4e500e5d2970eb0afdda164 Author: Stefan Hutter Date: Mon Sep 16 10:52:57 2024 +0200 Initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..502fef8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vs/ +EDOKA_2024/.vs \ No newline at end of file diff --git a/EDKB04OP.sln b/EDKB04OP.sln new file mode 100644 index 0000000..2d60e0c --- /dev/null +++ b/EDKB04OP.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EDKB04OP", "EDKB04OP\EDKB04OP.vbproj", "{4D4E0D27-5773-452F-BA0B-7A18EC833470}" +EndProject +Global + GlobalSection(TeamFoundationVersionControl) = preSolution + SccNumberOfProjects = 2 + SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} + SccTeamFoundationServer = http://sb001580/tfs/defaultcollection + SccLocalPath0 = . + SccProjectUniqueName1 = EDKB04OP\\EDKB04OP.vbproj + SccProjectName1 = EDKB04OP + SccLocalPath1 = EDKB04OP + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4D4E0D27-5773-452F-BA0B-7A18EC833470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D4E0D27-5773-452F-BA0B-7A18EC833470}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D4E0D27-5773-452F-BA0B-7A18EC833470}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D4E0D27-5773-452F-BA0B-7A18EC833470}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/EDKB04OP/Determination.vb b/EDKB04OP/Determination.vb new file mode 100644 index 0000000..a3ce8d9 --- /dev/null +++ b/EDKB04OP/Determination.vb @@ -0,0 +1,3 @@ +Public Interface Determination + Function Render() As Boolean +End Interface diff --git a/EDKB04OP/DocumentsDetermination.vb b/EDKB04OP/DocumentsDetermination.vb new file mode 100644 index 0000000..caf7816 --- /dev/null +++ b/EDKB04OP/DocumentsDetermination.vb @@ -0,0 +1,23 @@ +Imports System.Xml + +Public MustInherit Class DocumentsDetermination + Implements Determination + + Public MustOverride Function Render() As Boolean Implements Determination.Render + + Public Property Contract As XmlDocument + ''' + ''' Connection String für die EDOKA Datenbank + ''' + ''' + Public Property ConnectionString As String + Public Property Items As List(Of EdokaDokument) + + Public Property Results As List(Of Result) + + Public Sub New() + Items = New List(Of EdokaDokument) + Results = New List(Of Result) + End Sub + +End Class diff --git a/EDKB04OP/Dokument/DokumentList.vb b/EDKB04OP/Dokument/DokumentList.vb new file mode 100644 index 0000000..ae941d7 --- /dev/null +++ b/EDKB04OP/Dokument/DokumentList.vb @@ -0,0 +1,141 @@ +Imports System.Data.SqlClient +Imports System.Xml + +''' +''' Zum Suchen von LSV-BEs eines Partners mit Hilfe von zusäztlichen Kriterein (Selektoren). +''' Grundlage für die Klasse bildet die Tatsache, dass man mit einem SELECT Statement wie +''' select d.dokumentid, diw.inhalt from dbo.dokument d +''' inner join dbo.dokumentinfo_wert diw on d.dokumentid = diw.dokumentid +''' where d.dokumenttypnr = 1176 +''' and d.nrpar00= 1339632 +''' and diw.inhalt in ( 'IBAN;CH4400784013396322002', 'Paginatornummer;02180305004720', 'BE_LSV-ID_gueltig_ab;20180305', 'LSV-ID;SCW1W', 'Referenz1;60211909') +''' schon sehr gut eine LSV-BE finden kann und auch sieht, ob alle Suchkriterien aus dbo.dokumentinfo_wert mitberücksichtigt wurden. +''' +Public Class DokumentList + + Public Sub New(xmlDocument As XmlDocument, ByVal partnerNr As Int32) + Me.XmlDocument = xmlDocument + Me.PartnerNr = partnerNr + Me.Selektors = New List(Of DokumentSelektor)() + End Sub + + Public Sub AddSelektor(xmlTagId As String, dokumentWertInhaltId As String, Optional ignoreSpaces As Boolean = False, Optional useValueIndex As Integer = -1, + Optional isDate As Boolean = False) + Dim dokumentSelektor As DokumentSelektor = New DokumentSelektor() + dokumentSelektor.XmlTagId = xmlTagId + dokumentSelektor.DokumentWertInhaltId = dokumentWertInhaltId + dokumentSelektor.Wert = XmlHelper.GetItemValueByTagName(Me.XmlDocument, dokumentSelektor.XmlTagId) + If Not String.IsNullOrEmpty(dokumentSelektor.Wert) Then + If ignoreSpaces Then + dokumentSelektor.Wert = dokumentSelektor.Wert.Replace(" ", "") + End If + If useValueIndex >= 0 Then + Dim values As String() = dokumentSelektor.Wert.Split(";") + dokumentSelektor.Wert = values(useValueIndex) + End If + If isDate Then + dokumentSelektor.Wert = GetInhaltDatumFromXmlDatum(dokumentSelektor.Wert) + End If + Me.Selektors.Add(dokumentSelektor) + End If + End Sub + + Private Function GetInhaltDatumFromXmlDatum(wert As String) As String + Dim ret As String = "" + ret = wert.Substring(6, 2) + "." + wert.Substring(4, 2) + "." + wert.Substring(0, 4) + Return ret + End Function + + Public Sub Fill() + DokumentIds = New List(Of String) + Dim connectionString As String = Globals.sConnectionString_edoka + Me.SelektorFromInhalt = New Dictionary(Of String, DokumentSelektor) + Using connection As New SqlConnection(connectionString), + dtDokument As New DataTable, + daDokument As New SqlDataAdapter, + scDokument As New SqlCommand + scDokument.Connection = connection + Dim selektorString As String = "" + Dim counter As Integer = 0 + + ' Mit den Selektoren das SqlCommand parametrisieren + For Each selektor As DokumentSelektor In Me.Selektors + Dim paramName As String = "@Inhalt" + counter.ToString() + If selektorString.Length > 0 Then + selektorString = selektorString + "," + End If + selektorString = selektorString + paramName + Dim paramValue As String = selektor.DokumentWertInhaltId + ";" + selektor.Wert + Me.SelektorFromInhalt.Item(paramValue) = selektor + scDokument.Parameters.AddWithValue(paramName, paramValue) + counter = counter + 1 + Next + + If counter > 0 Then ' wenigstens ein Selektor muss vorhanden sein + Dim commandTextFormat As String = "select d.dokumentid, diw.inhalt from dbo.dokument d +inner join dbo.dokumentinfo_wert diw on d.dokumentid = diw.dokumentid +where d.dokumenttypnr = 1176 +and d.nrpar00= {0} +and diw.inhalt in ({1}) +order by d.dokumentid, diw.inhalt" + Dim commandText As String = String.Format(commandTextFormat, PartnerNr, selektorString) + scDokument.CommandText = commandText + daDokument.SelectCommand = scDokument + daDokument.Fill(dtDokument) + + ' In der Tabelle darf nur eine DokumentId aufgeführt sein und zu dieser DokumentId + ' müssen alle Selektoren aufgeführt (Property Filled) sein + Dim lastDokumentId As String = "" + For Each row As DataRow In dtDokument.Rows + Dim dokumentId As String = row.Item(0) + If lastDokumentId = "" Then + lastDokumentId = dokumentId + End If + If lastDokumentId <> dokumentId Then + If Me.AllSelektorsFilled() Then + DokumentIds.Add(lastDokumentId) + End If + Me.EmptyAllSelektors() + lastDokumentId = dokumentId + End If + If lastDokumentId = dokumentId Then + Dim inhalt As String = row.Item(1) + Dim selektor As DokumentSelektor = New DokumentSelektor + If SelektorFromInhalt.TryGetValue(inhalt, selektor) Then + selektor.Filled = True + End If + End If + Next + If lastDokumentId <> "" Then + If Me.AllSelektorsFilled() Then + DokumentIds.Add(lastDokumentId) + End If + End If + End If + End Using + End Sub + + Private Function AllSelektorsFilled() As Boolean + Dim ret As Boolean = True + For Each selektor As DokumentSelektor In Selektors + If Not selektor.Filled Then + ret = False + Exit For + End If + Next + Return ret + End Function + + Private Sub EmptyAllSelektors() + For Each selektor As DokumentSelektor In Selektors + selektor.Filled = False + Next + End Sub + + Public Property Selektors As List(Of DokumentSelektor) + Public Property SelektorFromInhalt As Dictionary(Of String, DokumentSelektor) + Public Property XmlDocument As XmlDocument + Public Property PartnerNr As Int32 + Public Property DokumentIds As List(Of String) + +End Class diff --git a/EDKB04OP/Dokument/DokumentSelektor.vb b/EDKB04OP/Dokument/DokumentSelektor.vb new file mode 100644 index 0000000..d20f2d4 --- /dev/null +++ b/EDKB04OP/Dokument/DokumentSelektor.vb @@ -0,0 +1,27 @@ +Public Class DokumentSelektor + + ''' + ''' Tag Id des Selektors in der XML Message von Avaloq + ''' + ''' + Public Property XmlTagId As String + + ''' + ''' Id (das ist der Teil vor dem ;) von dbo.dokumentinfo_wert.inhalt + ''' + ''' + Public Property DokumentWertInhaltId As String + + ''' + ''' Wert des XML Tags aus der Message von Avaloq + ''' + ''' + Public Property Wert As String + + ''' + ''' True: Der Selektor wurde in die DataTable abgefüllt + ''' False: Der Selektor fehlt in der DataTable + ''' + ''' + Public Property Filled As Boolean = False +End Class diff --git a/EDKB04OP/EDKB04OP.Designer.vb b/EDKB04OP/EDKB04OP.Designer.vb new file mode 100644 index 0000000..942bc26 --- /dev/null +++ b/EDKB04OP/EDKB04OP.Designer.vb @@ -0,0 +1,76 @@ +Imports System.ServiceProcess + + _ +Partial Class EDKB04OP + Inherits System.ServiceProcess.ServiceBase + 'UserService überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + ' Der Haupteinstiegspunkt für den Prozess + _ + _ + Shared Sub Main() + +#If CONFIG = "Release" Then + Dim ServicesToRun() As System.ServiceProcess.ServiceBase + ServicesToRun = New System.ServiceProcess.ServiceBase() {New EDKB04OP} + System.ServiceProcess.ServiceBase.Run(ServicesToRun) +#Else + Dim myServ As New EDKB04OP() + myServ.OnStart({""}) + While (True) + System.Threading.Thread.Sleep(2000) + End While +#End If + ''#If DEBUG Then + '' Dim myServ As New EDKB04OP() + '' myServ.OnStart({""}) + '' While (True) + '' System.Threading.Thread.Sleep(2000) + '' End While + + ''#Else + '' Dim ServicesToRun() As System.ServiceProcess.ServiceBase + '' ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1()} + ''System.ServiceProcess.ServiceBase.Run(ServicesToRun) + + + 'Dim ServicesToRun() As System.ServiceProcess.ServiceBase + + '' Innerhalb eines Prozesses können mehrere NT-Dienste ausgeführt werden. Um einen + '' weiteren Dienst zu diesem Prozess hinzuzufügen, ändern Sie die folgende Zeile, + '' um ein zweites Dienstobjekt zu erstellen. Zum Beispiel + '' + '' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService} + '' + 'ServicesToRun = New System.ServiceProcess.ServiceBase() {New EDKB04OP} + + 'System.ServiceProcess.ServiceBase.Run(ServicesToRun) + ''#End If + + + + End Sub + + 'Wird vom Komponenten-Designer benötigt. + Private components As System.ComponentModel.IContainer + + ' Hinweis: Die folgende Prozedur ist für den Komponenten-Designer erforderlich. + ' Das Bearbeiten ist mit dem Komponenten-Designer möglich. + ' Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + Me.ServiceName = "Service1" + End Sub + +End Class diff --git a/EDKB04OP/EDKB04OP.vb b/EDKB04OP/EDKB04OP.vb new file mode 100644 index 0000000..c4652ee --- /dev/null +++ b/EDKB04OP/EDKB04OP.vb @@ -0,0 +1,497 @@ +''--------------------------------------------------------------------------------------------------------------------- +'' Copyright TKB - all rights reserved +'' Erstellt am : Unbekannt +'' Erstellt durch: Stefan Hutter, TKB +'' Fachbereich : TEC +'' Beschreibung : +'' +'' History : +''-------------------------------------------------------------------------------------------------------------------- +'' Datum Name, Firma Beschreibung +''-------------------------------------------------------------------------------------------------------------------- +'' 22.05.2017 Tobias Verstappen, TKB Programm so ergänzt, dass neue XML Files erkannt werden und in die EDOKA +'' Datenbank gespeichert werden. +''-------------------------------------------------------------------------------------------------------------------- +Imports System.Timers +Imports IBM.WMQ +Imports System.ServiceProcess +Imports System.Runtime.Remoting +Imports System.Runtime.Remoting.Channels +Imports System.Xml +Imports System.Data.SqlClient +Imports System.IO +Imports System.Reflection +Imports bms +Imports System.Text.RegularExpressions + +Public Class EDKB04OP + Inherits System.ServiceProcess.ServiceBase + Dim WithEvents tmrQueuePolling As Timer = New Timer(2000) + Dim myStopper As ErrorStopper + Dim fileWatch As New FileSystemWatcher() + + +#Region " Vom Component Designer generierter Code " + + Public Sub New() + MyBase.New() + + ' Dieser Aufruf wird vom Komponenten-Designer benötigt. + InitializeComponent() + + ' Fügen Sie Initialisierungscode hinter dem InitializeComponent()-Aufruf ein + + End Sub + + ''UserService überschreibt den Löschvorgang zum Bereinigen der Komponentenliste. + 'Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + ' If disposing Then + ' If Not (components Is Nothing) Then + ' components.Dispose() + ' End If + ' End If + ' MyBase.Dispose(disposing) + 'End Sub + + '' Der Haupteinstiegspunkt für den Vorgang + ' _ + 'Shared Sub Main() + ' Dim ServicesToRun() As System.ServiceProcess.ServiceBase + ' ServicesToRun = New System.ServiceProcess.ServiceBase() {New EDKB04OP} + ' System.ServiceProcess.ServiceBase.Run(ServicesToRun) + 'End Sub + + + +#End Region + +#Region "StartStop" + + Protected Overrides Sub OnStart(ByVal args() As String) + Try + 'init BMS +#If CONFIG = "Release" Then + Dim m_log1 As New bms.Logging(6, Common.Common.JobType.WatchJob) + m_logOld = m_log1 +#Else + Dim m_log1 As New Globals.log + m_logOld = m_log1 + +#End If + '#If DEBUG Then + ' Dim m_log1 As New Globals.log + ' m_log = m_log1 + '#Else + 'Dim m_log1 As New bms.Logging(6, Common.Common.JobType.WatchJob) + 'm_log = m_log1 + '#End If + + Dim m_logAdapter As New Globals.LogAdapter + m_log = m_logAdapter + + m_log.start() + m_log.log("EDKB04: Start", Common.Common.JournalEntryType.Information) + + 'Init Params + Params.Loadparameters() + m_log.log("EDKB04: Params.WaitForBrake= " & Params.WaitForBrake, Common.Common.JournalEntryType.Information) + + 'Init File Watcher + fileWatch.Path = Params.Watchdir + fileWatch.IncludeSubdirectories = False + fileWatch.Filter = "*.xml" + AddHandler fileWatch.Created, New FileSystemEventHandler(AddressOf OnFileEvent) + fileWatch.EnableRaisingEvents = True + + 'init DB-Connection + Dim sconnection = New DB_Connection() + + 'init Timer + tmrQueuePolling.AutoReset = False + If CInt(Params.TimerInterval) > 0 Then + tmrQueuePolling.Start() + m_log.Log("EDKB04: tmrQueuePolling.Started") + Else + tmrQueuePolling.Enabled = False + End If + + 'Init Error Stopper + Me.myStopper = New ErrorStopper + Me.myStopper.init(Params.nb_errors, Params.nb_seconds) + + Catch ex As Exception + WriteLog("BMS-Connection / XML: " + ex.Message, appPath + "Error.txt") + m_log.log(ex.Message, Common.Common.JournalEntryType.Error) + Exit Sub + End Try + End Sub + + Protected Overrides Sub OnStop() + ' Hier Code zum Ausführen erforderlicher Löschvorgänge zum Beenden des Dienstes einfügen. + m_log.log("EDKB04 Stop", Common.Common.JournalEntryType.Information) + m_log.ende() + End Sub +#End Region + +#Region "Log" + + Private Sub WriteLog(ByVal stext As String, ByVal sPfad As String) + Try + Dim FiStr As FileStream = New FileStream(sPfad, FileMode.Append) + Dim StrWr As StreamWriter = New StreamWriter(FiStr) + StrWr.WriteLine("Fehler: " + Now() & " Text:" & stext) + StrWr.Close() + Catch ex As Exception + End Try + End Sub + + Private Function writeDebug(ByVal xmlstring As String, Optional ByVal filenameSuffix As String = "", Optional ByVal filenameBase As String = "") As String + Dim result As Boolean = True + Dim filename As String = "" + Try + Dim writer As System.IO.StreamWriter + Dim filetimestamp As String = GetFormatNow() + If filenameBase <> "" Then + filetimestamp = filenameBase + End If + filename = Params.DebugDir & filetimestamp & filenameSuffix & ".xml" + writer = IO.File.AppendText(filename) + writer.WriteLine(xmlstring) + writer.Close() + Catch ex As Exception + m_log.Log("EDKB04: Error beim Abspeichern der Debug .xml Daten") + result = False + End Try + Return filename + End Function + + Private Sub renameFromXmlToErr(ByVal filename As String) + Try + If filename.EndsWith(".xml") Then + filename = filename.Substring(0, filename.Length - 4) + File.Move(filename & ".xml", filename & ".err") + End If + Catch ex As Exception + m_log.log("EDKB04: Error in renameFromXmlToErr()") + End Try + End Sub + +#End Region + +#Region "Timer" + Public Sub OnTimedEvent(ByVal source As Object, ByVal e As ElapsedEventArgs) Handles tmrQueuePolling.Elapsed + Try + m_log.Log("EDKB04: OnTimedEvent called", Common.Common.JournalEntryType.Information) + ReadfromMQ() + Catch ex As Exception + m_log.Log("EDKB04: Exception catched in OnTimedEvent()") + Finally + tmrQueuePolling.Start() + m_log.Log("EDKB04: tmrQueuePolling.Started") + End Try + End Sub +#End Region + + Public Function IsKreditantragWizardMessage(Message As String) As Boolean + Dim ret As Boolean + ret = False + Dim regex As Regex = New Regex("DokumentTypNr") + Dim match As Match = regex.Match(Message) + If match.Success Then + ret = True + End If + Return ret + End Function + + Private Function GetXmlFromDoc(XmlDoc As XmlDocument) As String + Dim ret As String + Using stringWriter = New StringWriter() + Using xmlTextWriter = New System.Xml.XmlTextWriter(stringWriter) + xmlTextWriter.Formatting = Formatting.Indented + XmlDoc.WriteTo(xmlTextWriter) + xmlTextWriter.Flush() + ret = stringWriter.GetStringBuilder().ToString() + End Using + End Using + Return ret + End Function + + + ''' + ''' Fügt die TGNummer des Erstellers und die XML-Datei in die Datenbank (edk_data) ein. + ''' + ''' + ''' + Sub InsertMessageIntoTableEdkData(Message As String) + Dim sql As String + Dim doc As New XmlDocument + Dim node As XmlNode + + doc.LoadXml(Message) + node = doc.SelectSingleNode("/action/actionId") + 'node.InnerText = "3" + + Message = Message.Replace("" + node.InnerText + "", "3") + vbCrLf + + 'Message = doc.OuterXml + 'Message = GetXmlFromDoc(doc) + 'Holt die TGNummer des Erstellers aus dem XML + Dim TGNummer As String = XmlHelper.GetItemValueByTagName(doc, "creatorTg") + TGNummer = TGNummer.ToLower + + Using adapter As SqlDataAdapter = New SqlDataAdapter + Using connection As SqlConnection = New SqlConnection(Globals.sConnectionString_edoka) + + sql = "insert into edk_data (TGNummer, Status, xmldata) values(@tgNummer, 0, @data)" + Try + connection.Open() + Using insertCommand As SqlCommand = New SqlCommand(sql, connection) + adapter.InsertCommand = insertCommand + Dim dataBytes As Byte() + dataBytes = System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(Message) + adapter.InsertCommand.Parameters.AddWithValue("@data", dataBytes) + adapter.InsertCommand.Parameters.AddWithValue("@tgNummer", TGNummer) + adapter.InsertCommand.ExecuteNonQuery() + End Using + Catch ex As Exception + m_log.log("EDKB04: InsertMessageIntoTableXmlData Error: " & ex.ToString()) + End Try + End Using + End Using + End Sub + +#Region "File Watcher" + Private Sub OnFileEvent(ByVal source As Object, ByVal e As FileSystemEventArgs) + Globals.archiveFilename = "" + Try + 'Threading.Thread.Sleep(2000) + Dim di As New IO.DirectoryInfo(Params.Watchdir) + Dim diar1 As IO.FileInfo() = di.GetFiles("*.xml") + Dim dra As IO.FileInfo + Dim data As String + Dim counter As Integer = 0 + For Each dra In diar1 + counter = counter + 1 + Dim fil As New StreamReader(dra.FullName) + data = fil.ReadToEnd() + fil.Close() + HandleXmlContent(data, dra.Name) + File.Delete(dra.FullName) + Next + Catch ex As Exception + m_log.log("EDKB04: FileWatcher Error: " & ex.Message, Common.Common.JournalEntryType.Error) + End Try + End Sub +#End Region + +#Region "MQ" + + Private lastFormatNow As String = Format(Now, "yyyyMMddHHmmssffff") + Private Function GetFormatNow() As String + Dim thisFormatNow = Format(Now, "yyyyMMddHHmmssffff") + While thisFormatNow = lastFormatNow + Threading.Thread.Sleep(5) + thisFormatNow = Format(Now, "yyyyMMddHHmmssffff") + End While + lastFormatNow = thisFormatNow + Return thisFormatNow + End Function + + Private Function GetFilenameIndex(ByVal indexCounter As Integer) + + End Function + + Private Sub HandleXmlContent(ByVal strXMLContent As String, Optional ByVal givenFilename As String = "") + Dim filename1 As String = "" + Dim filename2 As String = "" + 'Me.Log("Message Content:" & strMsg) + If Params.DebugMode Then + If givenFilename <> "" Then + If givenFilename.ToLower().EndsWith(".xml") Then + givenFilename = givenFilename.Substring(0, givenFilename.Length - 4) + End If + filename1 = givenFilename & "_" & GetFormatNow() + Else + filename1 = GetFormatNow() + End If + End If + Globals.archiveFilename = filename1 + 'm_log.Log("EDKB04: filename1 = " & filename1) + 'm_log.Log("EDKB04: Message Length:" & Len(strMsg) & " Chars", Common.Common.JournalEntryType.Information) + + Dim splitter() As String + Dim splitstring = " "" Then + numberOfXmls = numberOfXmls + 1 + End If + Next + + Dim filenameIndex As Integer = 1 + If numberOfXmls > 1 Then + If Params.WriteUnsplittedFile > 0 Then + Me.writeDebug(strXMLContent, "unsplitted", filename1) + End If + Else + 'kein Filename Index, wenn nur ein Xml da ist + filenameIndex = 0 + End If + + For i As Integer = 0 To splitter.Length - 1 + Dim xml As String = splitter(i) + If xml.Trim() <> "" Then + + xml = splitstring + splitter(i) + If Params.DebugMode Then + Dim filenameIndexText As String = "" + If filenameIndex > 0 Then + filenameIndexText = String.Format("split{0,5:D5}", filenameIndex) + End If + filename2 = Me.writeDebug(xml, filenameIndexText, filename1) + 'm_log.Log("EDKB04: filename2 = " & filename2) + filenameIndex = filenameIndex + 1 + End If + If Not XMLtoObj(xml) Then + If Params.DebugMode Then + Me.renameFromXmlToErr(filename2) + End If + End If + + If Params.WaitForBrake > 0 Then + Dim currentDate1 As DateTime = DateTime.Now + Threading.Thread.Sleep(Params.WaitForBrake) + Dim currentDate2 As DateTime = DateTime.Now + Dim elapsedTicks As Long = currentDate2.Ticks - currentDate1.Ticks + Dim elapsedSpan As TimeSpan = New TimeSpan(elapsedTicks) + m_log.Log(String.Format("EDKB04: elapsedTicks = {0}", elapsedTicks)) + End If + End If + Next + End Sub + + + Private Function ReadfromMQ() As Boolean + + Globals.archiveFilename = "" + Dim mqQMgr As MQQueueManager '* MQQueueManager instance + Dim mqQueue As MQQueue = Nothing '* MQQueue instance + Dim queueName As String '* Name of queue to use + Dim strMsg As String + Dim result As Boolean + + 'tmrQueuePolling.Stop() + 'm_log.Log("EDKB04: Start MQ Verbindungsaufbau", Common.Common.JournalEntryType.Information) + queueName = Params.MQQueueName + Try + MQEnvironment.Hostname = Params.MQHostname 'Bsp: "vb0049d" + MQEnvironment.Port = Params.MQPort 'Bsp: 1416 + MQEnvironment.Channel = Params.MQChannel 'Bsp: "TGKB.D16.EDOKA.CL" + Try + mqQMgr = New MQQueueManager() + mqQueue = mqQMgr.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING) '* open queue for input but not if MQM stopping + Catch ex As Exception + m_log.Log("EDKB04: MQ Error: " & ex.Message, Common.Common.JournalEntryType.Error) + End Try + + Catch mqe As IBM.WMQ.MQException + m_log.Log("EDKB04: Error: " & mqe.Message, Common.Common.JournalEntryType.Error) + m_log.Log("EDKB04: Errorcode: " & mqe.CompletionCode, Common.Common.JournalEntryType.Error) + m_log.Log("EDKB04: Reasoncode: " & mqe.ReasonCode, Common.Common.JournalEntryType.Error) + End Try + + Try + Dim isContinue As Boolean = True + Dim strXMLContent As String + Do While (isContinue = True) + Globals.archiveFilename = "" + Dim mqMsg As MQMessage '* MQMessage instance + Dim mqGetMsgOpts As MQGetMessageOptions '* MQGetMessageOptions instance + + mqMsg = New MQMessage() + mqGetMsgOpts = New MQGetMessageOptions() + Try + If CInt(Params.TimerInterval) > 0 Then + mqGetMsgOpts.WaitInterval = CInt(Params.TimerInterval) + Else + mqGetMsgOpts.WaitInterval = 15000 '* 15 second limit for waiting + End If + Catch ex As Exception + mqGetMsgOpts.WaitInterval = 15000 '* 15 second limit for waiting + End Try + mqGetMsgOpts.Options = MQC.MQGMO_WAIT + + Try + mqQueue.Get(mqMsg, mqGetMsgOpts) + 'mqQueue. + If (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) = 0) Then + strMsg = mqMsg.ReadString(mqMsg.MessageLength) + strMsg = strMsg + strXMLContent = strMsg + HandleXmlContent(strXMLContent) + result = True + Else + If Me.myStopper.insert Then m_log.log("EDKB04: Non-text message", Common.Common.JournalEntryType.Error) + result = False + End If + Catch mqe As IBM.WMQ.MQException + '* report reason, if any + If (mqe.Reason = MQC.MQRC_NO_MSG_AVAILABLE) Then + '* special report for normal end + m_log.log("EDKB04: no more messages", Common.Common.JournalEntryType.Information) + isContinue = False + Else + '* general report for other reasons + If Me.myStopper.insert Then m_log.log("EDKB04: MQQueue::Get ended with {0}: " & mqe.Message, Common.Common.JournalEntryType.Error) + + '* treat truncated message as a failure for this sample + 'If (mqe.Reason = MQC.MQRC_TRUNCATED_MSG_FAILED) Then + isContinue = False + 'End If + End If + result = False + End Try + If LCase(Params.LoopQueue) = "false" Then + isContinue = False + End If + Loop + Catch ex As Exception + If Me.myStopper.insert Then m_log.log("EDKB04: Error bei GET: " & ex.Message, Common.Common.JournalEntryType.Error) + result = False + Finally + If CInt(Params.TimerInterval) > 0 Then + 'tmrQueuePolling.Start() + End If + End Try + Return result + End Function + + Private Function XMLtoObj(ByVal strXMLContent As String) As Boolean + Dim result As Boolean + If (IsKreditantragWizardMessage(strXMLContent)) Then + InsertMessageIntoTableEdkData(strXMLContent) + result = True + Else + Try + 'm_log.Log("EDKB04: Lese XML String in Objekt", Common.Common.JournalEntryType.Information) + Dim xmlh As New xmlHandling(strXMLContent) + result = xmlh.Result + xmlh = Nothing + 'm_log.Log("EDKB04: Lese XML String in Objekt ENDE", Common.Common.JournalEntryType.Information) + Catch ex As Exception + m_log.log("EDKB04: Error bei XML->Obj: " & ex.Message, Common.Common.JournalEntryType.Error) + result = False + End Try + End If + Return result + End Function +#End Region + + + + +End Class diff --git a/EDKB04OP/EDKB04OP.vbproj b/EDKB04OP/EDKB04OP.vbproj new file mode 100644 index 0000000..96b5c9d --- /dev/null +++ b/EDKB04OP/EDKB04OP.vbproj @@ -0,0 +1,206 @@ + + + + + Debug + AnyCPU + {4D4E0D27-5773-452F-BA0B-7A18EC833470} + WinExe + EDKB04.EDKB04OP + EDKB04 + EDKB04 + 512 + Console + v2.0 + SAK + SAK + SAK + SAK + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + true + true + bin\Debug\ + EDKB04.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + EDKB04.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + dlls\amqmdnet.dll + + + dlls\BMS.dll + + + dlls\Common.dll + + + dlls\DataAccess.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + Component + + + EDKB04OP.vb + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + Component + + + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + ProjectInstaller.vb + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + + + PreserveNewest + + + + + + + + + + + \ No newline at end of file diff --git a/EDKB04OP/EDKB04OP.vbproj.vspscc b/EDKB04OP/EDKB04OP.vbproj.vspscc new file mode 100644 index 0000000..b6d3289 --- /dev/null +++ b/EDKB04OP/EDKB04OP.vbproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/EDKB04OP/EdokaDokument.vb b/EDKB04OP/EdokaDokument.vb new file mode 100644 index 0000000..a23c2eb --- /dev/null +++ b/EDKB04OP/EdokaDokument.vb @@ -0,0 +1,30 @@ +Public Class EdokaDokument + + Public Function Cancel(ByVal message As String) As Boolean + Dim ret As Boolean = False + If Me.IsAbgeschlossen() Then + Dim edokaSqlDb As EdokaSqlDb = New EdokaSqlDb(Globals.sConnectionString_edoka) + edokaSqlDb.CancelDocument(Me.Id, message) + ret = Me.IsAufgehoben() + End If + Return ret + End Function + + Public Function IsAbgeschlossen() As Boolean + Dim ret As Boolean = False + Dim edokaSqlDb As EdokaSqlDb = New EdokaSqlDb(Globals.sConnectionString_edoka) + ret = edokaSqlDb.IsDokumentAbgeschlossen(Me.Id) + Return ret + End Function + + Public Function IsAufgehoben() As Boolean + Dim ret As Boolean = False + Dim edokaSqlDb As EdokaSqlDb = New EdokaSqlDb(Globals.sConnectionString_edoka) + ret = edokaSqlDb.IsDokumentAufgehoben(Me.Id) + Return ret + End Function + + + Public Property Id As String + +End Class diff --git a/EDKB04OP/EdokaSqlDb.vb b/EDKB04OP/EdokaSqlDb.vb new file mode 100644 index 0000000..b198c16 --- /dev/null +++ b/EDKB04OP/EdokaSqlDb.vb @@ -0,0 +1,77 @@ +Imports System.Data.SqlClient + +''' +''' Adapter für Edoka Datenbank auf dem SQL Server +''' +Public Class EdokaSqlDb + Public Sub New(connectionString As String) + Me.ConnectionString = connectionString + End Sub + + Public Function GetDokumentStatusBezeichnungsNr(dokumentId As String) As Integer + Dim ret As Integer = 0 + Using connection As New SqlConnection(ConnectionString), + cmd As SqlCommand = New SqlCommand("select top 1 ds.status_bezeichnungnr from dbo.statushistory sh +inner join dbo.dokument_status ds on ds.dokument_statusnr = sh.status +where dokumentid = @dokumentid +order by sh.erstellt_am desc", connection), + DataTable As DataTable = New DataTable(), + sqlDataAdapter As SqlDataAdapter = New SqlDataAdapter() + cmd.Parameters.AddWithValue("@dokumentid", dokumentId) + sqlDataAdapter.SelectCommand = cmd + sqlDataAdapter.Fill(DataTable) + If DataTable.Rows.Count = 1 Then + ret = DataTable.Rows(0)(0) + End If + End Using + Return ret + End Function + + Public Function IsDokumentAbgeschlossen(dokumentId As String) As Boolean + Dim ret As Boolean = False + Dim dokumentStatusBezeichnungsNr As Integer = + GetDokumentStatusBezeichnungsNr(dokumentId) + If dokumentStatusBezeichnungsNr = -2 Then ret = True + Return ret + End Function + + Public Function IsDokumentAufgehoben(dokumentId As String) As Boolean + Dim ret As Boolean = False + Dim dokumentStatusBezeichnungsNr As Integer = + GetDokumentStatusBezeichnungsNr(dokumentId) + If dokumentStatusBezeichnungsNr = -3 Then ret = True + Return ret + End Function + + ''' + ''' gemäss Stackoverflow https://stackoverflow.com/a/10373384 + ''' + ''' + ''' + ''' + Public Sub SendMail(ByVal email As String, ByVal betreff As String, ByVal meldung As String) + If meldung.Length > 1020 Then meldung = meldung.Substring(0, 1020) + Using connection As New SqlConnection(ConnectionString), + cmd As SqlCommand = New SqlCommand("dbo.sp_sendmail", connection) + connection.Open() + cmd.CommandType = CommandType.StoredProcedure + cmd.Parameters.AddWithValue("@email", email) + cmd.Parameters.AddWithValue("@betreff", betreff) + cmd.Parameters.AddWithValue("@meldung", meldung) + cmd.ExecuteNonQuery() + End Using + End Sub + + Public Sub CancelDocument(ByVal dokumentId As String, ByVal meldung As String) + Using connection As New SqlConnection(ConnectionString), + cmd As SqlCommand = New SqlCommand("dbo.sp_dokument_aufheben_nach_dokumentid", connection) + connection.Open() + cmd.CommandType = CommandType.StoredProcedure + cmd.Parameters.AddWithValue("@dokumentid", dokumentId) + cmd.Parameters.AddWithValue("@Meldung ", meldung) + cmd.ExecuteNonQuery() + End Using + End Sub + + Property ConnectionString As String +End Class diff --git a/EDKB04OP/ErrorStopper.vb b/EDKB04OP/ErrorStopper.vb new file mode 100644 index 0000000..0bb5441 --- /dev/null +++ b/EDKB04OP/ErrorStopper.vb @@ -0,0 +1,34 @@ +Public Class ErrorStopper + + Private nb_events As Integer = 0 + Private nb_seconds As Integer = 0 + + Private myStack As ArrayList + + Public Function insert() As Boolean + Dim result As Boolean = True + 'Neues Element rein + Dim new_el As New DateTime + new_el = Now() + myStack.Add(new_el) + 'Alte lschen + Dim check_el As DateTime + Dim i As Integer = myStack.Count + Do While i > 0 + check_el = myStack.Item(0) + If DateAdd(DateInterval.Second, nb_seconds, check_el) < Now() Then + myStack.RemoveAt(0) + End If + i = i - 1 + Loop + 'Check ob Menge berschritten + If myStack.Count >= nb_events Then result = False + Return result + End Function + + Public Sub init(ByVal numberOfEvents As Integer, ByVal periodInSeconds As Integer) + Me.nb_events = numberOfEvents + Me.nb_seconds = periodInSeconds + Me.myStack = New ArrayList + End Sub +End Class diff --git a/EDKB04OP/Globals.vb b/EDKB04OP/Globals.vb new file mode 100644 index 0000000..ad286ce --- /dev/null +++ b/EDKB04OP/Globals.vb @@ -0,0 +1,90 @@ +Imports System.Reflection +Imports System.IO + +#If CONFIG = "Debug" Then +Imports System.Diagnostics +#End If + +Module Globals + Public Applikationsdaten As DataTable + Public AppldataRow As Integer + + Public sConnectionString_edoka As String + Public sConnectionString_journale As String + Public sConnectionString_tgdata As String + + Public args As String() = Environment.GetCommandLineArgs() + + Public Params As New ClsParameter() + + Public conn_edoka As New edokadb.clsConnectionProvider() + Public conn_journale As New edokadb.clsConnectionProvider() + Public conn_tgdata As New edokadb.clsConnectionProvider() + + Public Fehler As Integer = 0 + Public Warning As Integer = 0 + Public DokumentID As String + Public ColdDokumentID As String + Public KeyNr As Long + + Public ofile As System.IO.File + Public oread As System.IO.StreamReader + 'test + + 'NEU + Public appPath As String = Path.GetDirectoryName([Assembly].GetEntryAssembly().Location) + "\" + + Public archiveFilename As String = "" + Public ReadOnly Property LogId As String + Get + Dim ret As String = "" + If archiveFilename <> "" Then + ret = " [" & archiveFilename & "]" + End If + Return ret + End Get + End Property + +#Region "BMS - Normal" + + Public Class LogAdapter + Sub log(ByVal msg As String, Optional type As Integer = 0) + m_logOld.Log(msg & LogId, type) + End Sub + + Public Sub start() + m_logOld.Start() + End Sub + + Public Sub ende() + m_logOld.Ende() + End Sub + + End Class + + Public m_log As LogAdapter + +#If CONFIG = "Release" Then + Public m_logOld As bms.Logging +#Else + Public m_logOld As log + + Public Class log + Sub log(ByVal msg As String, Optional type As Integer = 0) + Debug.Print("{0}: {1}", type, msg) + End Sub + + Public Sub start() + + End Sub + + Public Sub ende() + + End Sub + End Class + +#End If + +#End Region + +End Module \ No newline at end of file diff --git a/EDKB04OP/LsvBe/CanceledDocuments.vb b/EDKB04OP/LsvBe/CanceledDocuments.vb new file mode 100644 index 0000000..ada4752 --- /dev/null +++ b/EDKB04OP/LsvBe/CanceledDocuments.vb @@ -0,0 +1,32 @@ +Imports System.Xml + +Namespace LsvBe + Public Class CanceledDocuments + Inherits DocumentsDetermination + + ''' + ''' Hebt die LSV BEs gemäss Contract auf. + ''' Dazu wird der ConnectionString benötigt + ''' + ''' True, wenn ein einziges Dokument identifiziert und aufgehoben werden konnte. Sonst False + Public Overrides Function Render() As Boolean + Dim ret As Boolean = False + + Dim existingDocuments As ExistingDocuments = New ExistingDocuments() + existingDocuments.ConnectionString = Me.ConnectionString + existingDocuments.Contract = Me.Contract + existingDocuments.Render() + Me.Results.AddRange(existingDocuments.Results) + + If existingDocuments.Items.Count = 1 Then + For Each dokument As EdokaDokument In existingDocuments.Items + ret = dokument.Cancel("EDKB04 hat eine LSV Stammdaten Message von Avaloq erhalten und deshalb das Dokument aufgehoben") + If ret Then Me.Items.Add(dokument) + Next + End If + + Return ret + End Function + End Class + +End Namespace diff --git a/EDKB04OP/LsvBe/ExistingDocuments.vb b/EDKB04OP/LsvBe/ExistingDocuments.vb new file mode 100644 index 0000000..3901383 --- /dev/null +++ b/EDKB04OP/LsvBe/ExistingDocuments.vb @@ -0,0 +1,48 @@ +Namespace LsvBe + Public Class ExistingDocuments + Inherits DocumentsDetermination + + ''' + ''' Füllt Items mit passenden Dokumenten. Zuerst wird nur mit Partner- und Paginatornummer gesucht. + ''' Die restlichen Suchkriterien werden erst angewendet, wenn mit Partner- und Paginatornummer + ''' keine passenden Dokumente gefunden werden können. + ''' + ''' Always true + Public Overrides Function Render() As Boolean + Dim ret As Boolean = True + Dim partnerNummer As String = XmlHelper.GetItemValueByTagName(Me.Contract, "partnerNummer") + If Not String.IsNullOrEmpty(partnerNummer) Then + Dim dokumentList As DokumentList = New DokumentList(Me.Contract, partnerNummer) + dokumentList.AddSelektor("pagi_nr", "Paginatornummer", True) + dokumentList.Fill() + For Each dokumentId As String In dokumentList.DokumentIds + Dim edokaDokument As EdokaDokument = New EdokaDokument() + edokaDokument.Id = dokumentId + Me.Items.Add(edokaDokument) + Next + If Me.Items.Count = 0 Then + Dim lsvIds As String = XmlHelper.GetItemValueByTagName(Me.Contract, "lsvId") + Dim numberOfLists As Integer = lsvIds.Split(";").Length + If numberOfLists = 0 Then numberOfLists = 1 + + For counter As Integer = 0 To numberOfLists - 1 + dokumentList = New DokumentList(Me.Contract, partnerNummer) + dokumentList.AddSelektor("iban", "IBAN") + dokumentList.AddSelektor("lsvId", "LSV-ID", False, counter) + dokumentList.AddSelektor("openDate", "BE_LSV-ID_gueltig_ab", False, -1, True) + dokumentList.AddSelektor("ref1", "Referenz1") + dokumentList.AddSelektor("ref2", "Referenz2") + dokumentList.Fill() + For Each dokumentId As String In dokumentList.DokumentIds + Dim edokaDokument As EdokaDokument = New EdokaDokument() + edokaDokument.Id = dokumentId + Me.Items.Add(edokaDokument) + Next + Next + End If + End If + Return ret + End Function + End Class +End Namespace + diff --git a/EDKB04OP/My Project/Application.Designer.vb b/EDKB04OP/My Project/Application.Designer.vb new file mode 100644 index 0000000..8d60a96 --- /dev/null +++ b/EDKB04OP/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.34014 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/EDKB04OP/My Project/Application.myapp b/EDKB04OP/My Project/Application.myapp new file mode 100644 index 0000000..602de37 --- /dev/null +++ b/EDKB04OP/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 3 + true + diff --git a/EDKB04OP/My Project/AssemblyInfo.vb b/EDKB04OP/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..dd93c13 --- /dev/null +++ b/EDKB04OP/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die mit einer Assembly verknüpft sind. + +' Die Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/EDKB04OP/My Project/Resources.Designer.vb b/EDKB04OP/My Project/Resources.Designer.vb new file mode 100644 index 0000000..8107dfc --- /dev/null +++ b/EDKB04OP/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.34014 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("EDKB04.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/EDKB04OP/My Project/Resources.resx b/EDKB04OP/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/EDKB04OP/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/EDKB04OP/My Project/Settings.Designer.vb b/EDKB04OP/My Project/Settings.Designer.vb new file mode 100644 index 0000000..41cfc3b --- /dev/null +++ b/EDKB04OP/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.34014 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Funktion zum automatischen Speichern von My.Settings" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.EDKB04.My.MySettings + Get + Return Global.EDKB04.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/EDKB04OP/My Project/Settings.settings b/EDKB04OP/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/EDKB04OP/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/EDKB04OP/ParameterCfgDescription.txt b/EDKB04OP/ParameterCfgDescription.txt new file mode 100644 index 0000000..a8b818e --- /dev/null +++ b/EDKB04OP/ParameterCfgDescription.txt @@ -0,0 +1,24 @@ +WaitForBrake +============ +Damit kann nach jeder XML Verarbeitung eine Pause eingelegt werden. +Die Pause wird mit einer Zahl umschrieben. Die Zahl sagt aus +wie viele Millisekunden die Pause dauern soll. Default = 0 + +Beispiel: +WaitForBrake =1000 + +WriteUnsplittedFile +=================== +Gibt es mehrere XMLs in einem Verarbeitungsblock, so werden die +einzeln verarbeitet. Jedes XML wird in einer eigenen Datei mit +einem Index a..z, a1...z1 gespeichert. +Mit diesem Parameter kann gesteuert werden, ob in diesem Fall auch der ganze +Verarbeitungsblock ungesplittet als Datei gespeichert werden soll. +Ob ein UnsplittedFile geschrieben werden soll, wird mit einer Zahl umschrieben. +Die Zahl hat folgende Bedeutung +0: Unsplitted File wird nicht geschrieben +1: Unsplitted File wird geschrieben +Default ist 0 + +Beispiel: +WriteUnsplittedFile =1 diff --git a/EDKB04OP/ProjectInstaller.resx b/EDKB04OP/ProjectInstaller.resx new file mode 100644 index 0000000..9563461 --- /dev/null +++ b/EDKB04OP/ProjectInstaller.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + 17, 17 + + + Assembly + + + 188, 17 + + + ProjectInstaller + + + False + + \ No newline at end of file diff --git a/EDKB04OP/ProjectInstaller.vb b/EDKB04OP/ProjectInstaller.vb new file mode 100644 index 0000000..2113be2 --- /dev/null +++ b/EDKB04OP/ProjectInstaller.vb @@ -0,0 +1,60 @@ +Imports System.ComponentModel +Imports System.Configuration.Install + + Public Class ProjectInstaller + Inherits System.Configuration.Install.Installer + +#Region " Vom Component Designer generierter Code " + + Public Sub New() + MyBase.New() + + ' Dieser Aufruf ist fr den Komponenten-Designer erforderlich. + InitializeComponent() + + ' Initialisierungen nach dem Aufruf InitializeComponent() hinzufgen + + End Sub + + 'Installer berschreibt den Lschvorgang zum Bereinigen der Komponentenliste. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + ' Fr Komponenten-Designer erforderlich + Private components As System.ComponentModel.IContainer + + 'HINWEIS: Die folgende Prozedur ist fr den Komponenten-Designer erforderlich + 'Sie kann mit dem Komponenten-Designer modifiziert werden. + 'Verwenden Sie nicht den Code-Editor zur Bearbeitung. + Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller + Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller + Private Sub InitializeComponent() + Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller() + Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller() + ' + 'ServiceProcessInstaller1 + ' + Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem + Me.ServiceProcessInstaller1.Password = Nothing + Me.ServiceProcessInstaller1.Username = Nothing + ' + 'ServiceInstaller1 + ' + Me.ServiceInstaller1.DisplayName = "EDKB04" + Me.ServiceInstaller1.ServiceName = "EDKB04" + ' + 'ProjectInstaller + ' + Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) + + End Sub + +#End Region + +End Class diff --git a/EDKB04OP/Result.vb b/EDKB04OP/Result.vb new file mode 100644 index 0000000..b06445e --- /dev/null +++ b/EDKB04OP/Result.vb @@ -0,0 +1,14 @@ +Public Class Result + Property Text As String + Property Type As Common.Common.JournalEntryType + + Public Sub New() + Text = "no text set until now" + Type = Common.Common.JournalEntryType.Information + End Sub + + Public Sub New(ByVal text As String, ByVal type As Common.Common.JournalEntryType) + Me.Text = text + Me.Type = type + End Sub +End Class diff --git a/EDKB04OP/app.config b/EDKB04OP/app.config new file mode 100644 index 0000000..808e2f7 --- /dev/null +++ b/EDKB04OP/app.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EDKB04OP/bin/Debug/BMS.dll b/EDKB04OP/bin/Debug/BMS.dll new file mode 100644 index 0000000..b8da491 Binary files /dev/null and b/EDKB04OP/bin/Debug/BMS.dll differ diff --git a/EDKB04OP/bin/Debug/Common.dll b/EDKB04OP/bin/Debug/Common.dll new file mode 100644 index 0000000..1cb73a8 Binary files /dev/null and b/EDKB04OP/bin/Debug/Common.dll differ diff --git a/EDKB04OP/bin/Debug/DataAccess.dll b/EDKB04OP/bin/Debug/DataAccess.dll new file mode 100644 index 0000000..ae5ea94 Binary files /dev/null and b/EDKB04OP/bin/Debug/DataAccess.dll differ diff --git a/EDKB04OP/bin/Debug/EDKB04.exe b/EDKB04OP/bin/Debug/EDKB04.exe new file mode 100644 index 0000000..0217993 Binary files /dev/null and b/EDKB04OP/bin/Debug/EDKB04.exe differ diff --git a/EDKB04OP/bin/Debug/EDKB04.exe.config b/EDKB04OP/bin/Debug/EDKB04.exe.config new file mode 100644 index 0000000..808e2f7 --- /dev/null +++ b/EDKB04OP/bin/Debug/EDKB04.exe.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EDKB04OP/bin/Debug/EDKB04.pdb b/EDKB04OP/bin/Debug/EDKB04.pdb new file mode 100644 index 0000000..150018a Binary files /dev/null and b/EDKB04OP/bin/Debug/EDKB04.pdb differ diff --git a/EDKB04OP/bin/Debug/EDKB04.xml b/EDKB04OP/bin/Debug/EDKB04.xml new file mode 100644 index 0000000..e5ba6f1 --- /dev/null +++ b/EDKB04OP/bin/Debug/EDKB04.xml @@ -0,0 +1,489 @@ + + + + +EDKB04 + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Connection String für die EDOKA Datenbank + + + + + + Zum Suchen von LSV-BEs eines Partners mit Hilfe von zusäztlichen Kriterein (Selektoren). + Grundlage für die Klasse bildet die Tatsache, dass man mit einem SELECT Statement wie + select d.dokumentid, diw.inhalt from dbo.dokument d + inner join dbo.dokumentinfo_wert diw on d.dokumentid = diw.dokumentid + where d.dokumenttypnr = 1176 + and d.nrpar00= 1339632 + and diw.inhalt in ( 'IBAN;CH4400784013396322002', 'Paginatornummer;02180305004720', 'BE_LSV-ID_gueltig_ab;20180305', 'LSV-ID;SCW1W', 'Referenz1;60211909') + schon sehr gut eine LSV-BE finden kann und auch sieht, ob alle Suchkriterien aus dbo.dokumentinfo_wert mitberücksichtigt wurden. + + + + + Tag Id des Selektors in der XML Message von Avaloq + + + + + + Id (das ist der Teil vor dem ;) von dbo.dokumentinfo_wert.inhalt + + + + + + Wert des XML Tags aus der Message von Avaloq + + + + + + True: Der Selektor wurde in die DataTable abgefüllt + False: Der Selektor fehlt in der DataTable + + + + + + Adapter für Edoka Datenbank auf dem SQL Server + + + + + gemäss Stackoverflow https://stackoverflow.com/a/10373384 + + + + + + + + Hebt die LSV BEs gemäss Contract auf. + Dazu wird der ConnectionString benötigt + + True, wenn ein einziges Dokument identifiziert und aufgehoben werden konnte. Sonst False + + + + Füllt Items mit passenden Dokumenten. Zuerst wird nur mit Partner- und Paginatornummer gesucht. + Die restlichen Suchkriterien werden erst angewendet, wenn mit Partner- und Paginatornummer + keine passenden Dokumente gefunden werden können. + + Always true + + + + Fügt die TGNummer des Erstellers und die XML-Datei in die Datenbank (edk_data) ein. + + + + + + + Teil von Update_Partner() + Aktualisiert alle berechtigte Email Adressen eines Parnters + Die Daten (siehe Parameter) kommen alle aus der XML Message + + aus XML Message + + + + + + True: Alles OK, False: nicht alles OK + + + + Gibt den InnerText eines Tags zurück. Falls eine Ausnahme auftritt, wird diese abgefangen und + ein Leerstring ("") zurückgegeben. + + + + + + + + + Erstellt aus einer Serie von XML Objekten eine DataTable. + Haben die XML Objekte gleichnamige Subnodes, so wird der Spaltenname in der Tabelle mit einer + angehängten Indexnummer eindeutig gemacht. + Falls eine Ausnahme Auftritt, wird eine leere DataTable mit einer Spalte "Dummy" zurückgegeben. + + + + + + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if node is found and value is retrieved successfully. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + s + Converts a list of Xml nodes to a DataTable. + + List of Xml nodes + DataTable + + This method convert + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a list of Xml nodes to a DataTable and sets one of the columns as a primary key. + + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Updates the child nodes of "parentNode" by using the fields from a datatable. + + + + + + The child nodes that will be updated must have attribute fields that correspond to + the DataTable. The "keyField" will be used to identify the attribute that serves as + an identifier of the rows. The datatable can have less fields than the nodes so + you have the chance to update smaller subsets. + Make sure that you did not call "AcceptChanges" before passing the datatable or this + function will not find any change. + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Returns contents of an XmlNode in a string. + + The XmlNode whose contents will be read into a string. + Xml formatted string with contents of "node" parameter. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Convert a XmlNodeList to string + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Method to convert a XmlDocument to string. + + XmlDocument that will be converted to string. + A xml formatted string. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a string array to XmlNodes and appends all those nodes to a root node. + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + + + + + + + + ----------------------------------------------------------------------------- + + + + Inserts an empty record at the bottom of the hierarchy, creating the + tree as required. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The XmlNode inserted into the hierarchy. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts an record with a multiple fields at the bottom of the hierarchy. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The attribute names that will be created for the node inserted. + The corresponding value of each field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with a single field at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The field to add to the record. + The value assigned to the field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Insert a record with multiple fields at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The array of fields as field/value pairs. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + The columns names of the DataRow will become the attribute names and + the row values of the DataRow will be the attribute values. + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields from a DataTable at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + + + Inserts a record with multiple values at bottom of hierarchy. This is analogous to inserting + a column of data. + + + The xml XPath query to get to the bottom node. + Name of the attribute to be created at node inserted. + Values that will be inserted that correspond to the field name. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Update a single field in all records in the specified path. + + The XmlDocument whose node will be udpated. + The xml path. + The field name to update. + The new value. + The number of records affected. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to update an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Deletes all records of the specified path. + + The xml XPath query to get to the bottom node. + The number of records deleted. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Deletes a field from all records on the specified path. + + The xml path. + The field to delete. + The number of records affected. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Return a single string representing the value of the specified field + for the first record encountered. + + The xml path. + The desired field. + A string with the field's value or null. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns a DataTable for all rows on the path. + + The xml path. + The DataTable with the returned rows. + The row count will be 0 if no rows returned. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns an array of values for the specified field for all rows on + the path. + + The xml path. + The desired field. + The array of string values for each row qualified by the path. + A null is returned if the query results in 0 rows. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Inserts a node at the specified segment if it doesn't exist, otherwise + traverses the node. + + The current node. + The path segment list. + The current segment. + + + + + Creates columns given an XmlNode. + + The target DataTable. + The source XmlNode. + + + diff --git a/EDKB04OP/bin/Debug/amqmdnet.dll b/EDKB04OP/bin/Debug/amqmdnet.dll new file mode 100644 index 0000000..97cebeb Binary files /dev/null and b/EDKB04OP/bin/Debug/amqmdnet.dll differ diff --git a/EDKB04OP/bin/Debug/bms_conn.cfg b/EDKB04OP/bin/Debug/bms_conn.cfg new file mode 100644 index 0000000..eb6589c --- /dev/null +++ b/EDKB04OP/bin/Debug/bms_conn.cfg @@ -0,0 +1 @@ +¹µÈ¦rȽ¹¿¸ª‰¿­Çx†°Ç­Ç…~¶Ã®Àµ¦¾h¸µÈ¦¾Äµ¢˜‡¼ªÄ»¾ÇÈeź±¹¿¾¹Ål®À®Ä‘š¦¾È³ÄÄ··¿¹³¼¾ÃÂe»¹‹½¶¨·±¹r»¾Î¹‚†…‡zˆÊ¸±¾e»¬’ǵ€Â¶Á·ÄÄ·°‰oŰʆ€ diff --git a/EDKB04OP/bin/Debug/bms_settings.xml b/EDKB04OP/bin/Debug/bms_settings.xml new file mode 100644 index 0000000..387768d --- /dev/null +++ b/EDKB04OP/bin/Debug/bms_settings.xml @@ -0,0 +1,46 @@ + + + + + 1 + + + 2 + + + 2 + + + 2 + + + 3 + + + BMS + + + 1 + + + server01 + + + bms@tkb.ch + + + + 0 + mailUser + mailPassword + + + \ No newline at end of file diff --git a/EDKB04OP/bin/Debug/edokaconn.cfg b/EDKB04OP/bin/Debug/edokaconn.cfg new file mode 100644 index 0000000..bbe7ecd --- /dev/null +++ b/EDKB04OP/bin/Debug/edokaconn.cfg @@ -0,0 +1 @@ +Data Source=shu01\shu00;Initial Catalog=edoka_dms;Persist Security Info=True;User ID=sa;Password=*shu29; diff --git a/EDKB04OP/bin/Debug/journaleconn.cfg b/EDKB04OP/bin/Debug/journaleconn.cfg new file mode 100644 index 0000000..1454125 --- /dev/null +++ b/EDKB04OP/bin/Debug/journaleconn.cfg @@ -0,0 +1 @@ +Data Source=shu01\shu00;Initial Catalog=edoka_journale;Persist Security Info=True;User ID=sa;Password=*shu29 \ No newline at end of file diff --git a/EDKB04OP/bin/Debug/parameter.cfg b/EDKB04OP/bin/Debug/parameter.cfg new file mode 100644 index 0000000..33b92ff --- /dev/null +++ b/EDKB04OP/bin/Debug/parameter.cfg @@ -0,0 +1,18 @@ +MQHostname =vb0049d +MQPort =1416 +MQChannel =TGKB.D16.EDOKA.CL +MQQueueName =test +SqlTimeOut =500000 +CDMUTER =EDKB04 +MuterNr =9996 +WatchDir =k:\edoka\00_EDK_Files\EDKB04 +TimerIntervall =0 +Loop =false +Debugmode =true +DebugDir =k:\edoka\00_EDK_Files\EDKB04\Archiv +DefaultBetreuerID =1166755 +nb_Errors =10 +nb_seconds =10 +len_TXADZ =35 +WaitForBrake =0 +WriteUnsplittedFile =1 diff --git a/EDKB04OP/bin/Release/BMS.dll b/EDKB04OP/bin/Release/BMS.dll new file mode 100644 index 0000000..b8da491 Binary files /dev/null and b/EDKB04OP/bin/Release/BMS.dll differ diff --git a/EDKB04OP/bin/Release/Common.dll b/EDKB04OP/bin/Release/Common.dll new file mode 100644 index 0000000..1cb73a8 Binary files /dev/null and b/EDKB04OP/bin/Release/Common.dll differ diff --git a/EDKB04OP/bin/Release/DataAccess.dll b/EDKB04OP/bin/Release/DataAccess.dll new file mode 100644 index 0000000..ae5ea94 Binary files /dev/null and b/EDKB04OP/bin/Release/DataAccess.dll differ diff --git a/EDKB04OP/bin/Release/EDKB04.exe b/EDKB04OP/bin/Release/EDKB04.exe new file mode 100644 index 0000000..0fbacb2 Binary files /dev/null and b/EDKB04OP/bin/Release/EDKB04.exe differ diff --git a/EDKB04OP/bin/Release/EDKB04.exe.config b/EDKB04OP/bin/Release/EDKB04.exe.config new file mode 100644 index 0000000..808e2f7 --- /dev/null +++ b/EDKB04OP/bin/Release/EDKB04.exe.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EDKB04OP/bin/Release/EDKB04.pdb b/EDKB04OP/bin/Release/EDKB04.pdb new file mode 100644 index 0000000..4b42bb3 Binary files /dev/null and b/EDKB04OP/bin/Release/EDKB04.pdb differ diff --git a/EDKB04OP/bin/Release/EDKB04.xml b/EDKB04OP/bin/Release/EDKB04.xml new file mode 100644 index 0000000..e5ba6f1 --- /dev/null +++ b/EDKB04OP/bin/Release/EDKB04.xml @@ -0,0 +1,489 @@ + + + + +EDKB04 + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Connection String für die EDOKA Datenbank + + + + + + Zum Suchen von LSV-BEs eines Partners mit Hilfe von zusäztlichen Kriterein (Selektoren). + Grundlage für die Klasse bildet die Tatsache, dass man mit einem SELECT Statement wie + select d.dokumentid, diw.inhalt from dbo.dokument d + inner join dbo.dokumentinfo_wert diw on d.dokumentid = diw.dokumentid + where d.dokumenttypnr = 1176 + and d.nrpar00= 1339632 + and diw.inhalt in ( 'IBAN;CH4400784013396322002', 'Paginatornummer;02180305004720', 'BE_LSV-ID_gueltig_ab;20180305', 'LSV-ID;SCW1W', 'Referenz1;60211909') + schon sehr gut eine LSV-BE finden kann und auch sieht, ob alle Suchkriterien aus dbo.dokumentinfo_wert mitberücksichtigt wurden. + + + + + Tag Id des Selektors in der XML Message von Avaloq + + + + + + Id (das ist der Teil vor dem ;) von dbo.dokumentinfo_wert.inhalt + + + + + + Wert des XML Tags aus der Message von Avaloq + + + + + + True: Der Selektor wurde in die DataTable abgefüllt + False: Der Selektor fehlt in der DataTable + + + + + + Adapter für Edoka Datenbank auf dem SQL Server + + + + + gemäss Stackoverflow https://stackoverflow.com/a/10373384 + + + + + + + + Hebt die LSV BEs gemäss Contract auf. + Dazu wird der ConnectionString benötigt + + True, wenn ein einziges Dokument identifiziert und aufgehoben werden konnte. Sonst False + + + + Füllt Items mit passenden Dokumenten. Zuerst wird nur mit Partner- und Paginatornummer gesucht. + Die restlichen Suchkriterien werden erst angewendet, wenn mit Partner- und Paginatornummer + keine passenden Dokumente gefunden werden können. + + Always true + + + + Fügt die TGNummer des Erstellers und die XML-Datei in die Datenbank (edk_data) ein. + + + + + + + Teil von Update_Partner() + Aktualisiert alle berechtigte Email Adressen eines Parnters + Die Daten (siehe Parameter) kommen alle aus der XML Message + + aus XML Message + + + + + + True: Alles OK, False: nicht alles OK + + + + Gibt den InnerText eines Tags zurück. Falls eine Ausnahme auftritt, wird diese abgefangen und + ein Leerstring ("") zurückgegeben. + + + + + + + + + Erstellt aus einer Serie von XML Objekten eine DataTable. + Haben die XML Objekte gleichnamige Subnodes, so wird der Spaltenname in der Tabelle mit einer + angehängten Indexnummer eindeutig gemacht. + Falls eine Ausnahme Auftritt, wird eine leere DataTable mit einer Spalte "Dummy" zurückgegeben. + + + + + + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if node is found and value is retrieved successfully. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + s + Converts a list of Xml nodes to a DataTable. + + List of Xml nodes + DataTable + + This method convert + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a list of Xml nodes to a DataTable and sets one of the columns as a primary key. + + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Updates the child nodes of "parentNode" by using the fields from a datatable. + + + + + + The child nodes that will be updated must have attribute fields that correspond to + the DataTable. The "keyField" will be used to identify the attribute that serves as + an identifier of the rows. The datatable can have less fields than the nodes so + you have the chance to update smaller subsets. + Make sure that you did not call "AcceptChanges" before passing the datatable or this + function will not find any change. + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Returns contents of an XmlNode in a string. + + The XmlNode whose contents will be read into a string. + Xml formatted string with contents of "node" parameter. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Convert a XmlNodeList to string + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Method to convert a XmlDocument to string. + + XmlDocument that will be converted to string. + A xml formatted string. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a string array to XmlNodes and appends all those nodes to a root node. + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + + + + + + + + ----------------------------------------------------------------------------- + + + + Inserts an empty record at the bottom of the hierarchy, creating the + tree as required. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The XmlNode inserted into the hierarchy. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts an record with a multiple fields at the bottom of the hierarchy. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The attribute names that will be created for the node inserted. + The corresponding value of each field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with a single field at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The field to add to the record. + The value assigned to the field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Insert a record with multiple fields at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The array of fields as field/value pairs. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + The columns names of the DataRow will become the attribute names and + the row values of the DataRow will be the attribute values. + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields from a DataTable at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + + + Inserts a record with multiple values at bottom of hierarchy. This is analogous to inserting + a column of data. + + + The xml XPath query to get to the bottom node. + Name of the attribute to be created at node inserted. + Values that will be inserted that correspond to the field name. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Update a single field in all records in the specified path. + + The XmlDocument whose node will be udpated. + The xml path. + The field name to update. + The new value. + The number of records affected. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to update an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Deletes all records of the specified path. + + The xml XPath query to get to the bottom node. + The number of records deleted. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Deletes a field from all records on the specified path. + + The xml path. + The field to delete. + The number of records affected. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Return a single string representing the value of the specified field + for the first record encountered. + + The xml path. + The desired field. + A string with the field's value or null. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns a DataTable for all rows on the path. + + The xml path. + The DataTable with the returned rows. + The row count will be 0 if no rows returned. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns an array of values for the specified field for all rows on + the path. + + The xml path. + The desired field. + The array of string values for each row qualified by the path. + A null is returned if the query results in 0 rows. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Inserts a node at the specified segment if it doesn't exist, otherwise + traverses the node. + + The current node. + The path segment list. + The current segment. + + + + + Creates columns given an XmlNode. + + The target DataTable. + The source XmlNode. + + + diff --git a/EDKB04OP/bin/Release/amqmdnet.dll b/EDKB04OP/bin/Release/amqmdnet.dll new file mode 100644 index 0000000..97cebeb Binary files /dev/null and b/EDKB04OP/bin/Release/amqmdnet.dll differ diff --git a/EDKB04OP/bin/Release/bms_conn.cfg b/EDKB04OP/bin/Release/bms_conn.cfg new file mode 100644 index 0000000..eb6589c --- /dev/null +++ b/EDKB04OP/bin/Release/bms_conn.cfg @@ -0,0 +1 @@ +¹µÈ¦rȽ¹¿¸ª‰¿­Çx†°Ç­Ç…~¶Ã®Àµ¦¾h¸µÈ¦¾Äµ¢˜‡¼ªÄ»¾ÇÈeź±¹¿¾¹Ål®À®Ä‘š¦¾È³ÄÄ··¿¹³¼¾ÃÂe»¹‹½¶¨·±¹r»¾Î¹‚†…‡zˆÊ¸±¾e»¬’ǵ€Â¶Á·ÄÄ·°‰oŰʆ€ diff --git a/EDKB04OP/bin/Release/bms_settings.xml b/EDKB04OP/bin/Release/bms_settings.xml new file mode 100644 index 0000000..387768d --- /dev/null +++ b/EDKB04OP/bin/Release/bms_settings.xml @@ -0,0 +1,46 @@ + + + + + 1 + + + 2 + + + 2 + + + 2 + + + 3 + + + BMS + + + 1 + + + server01 + + + bms@tkb.ch + + + + 0 + mailUser + mailPassword + + + \ No newline at end of file diff --git a/EDKB04OP/bin/Release/edkb04.zip b/EDKB04OP/bin/Release/edkb04.zip new file mode 100644 index 0000000..53edf26 Binary files /dev/null and b/EDKB04OP/bin/Release/edkb04.zip differ diff --git a/EDKB04OP/bin/Release/edokaconn.cfg b/EDKB04OP/bin/Release/edokaconn.cfg new file mode 100644 index 0000000..bbe7ecd --- /dev/null +++ b/EDKB04OP/bin/Release/edokaconn.cfg @@ -0,0 +1 @@ +Data Source=shu01\shu00;Initial Catalog=edoka_dms;Persist Security Info=True;User ID=sa;Password=*shu29; diff --git a/EDKB04OP/bin/Release/journaleconn.cfg b/EDKB04OP/bin/Release/journaleconn.cfg new file mode 100644 index 0000000..1454125 --- /dev/null +++ b/EDKB04OP/bin/Release/journaleconn.cfg @@ -0,0 +1 @@ +Data Source=shu01\shu00;Initial Catalog=edoka_journale;Persist Security Info=True;User ID=sa;Password=*shu29 \ No newline at end of file diff --git a/EDKB04OP/bin/Release/parameter.cfg b/EDKB04OP/bin/Release/parameter.cfg new file mode 100644 index 0000000..33b92ff --- /dev/null +++ b/EDKB04OP/bin/Release/parameter.cfg @@ -0,0 +1,18 @@ +MQHostname =vb0049d +MQPort =1416 +MQChannel =TGKB.D16.EDOKA.CL +MQQueueName =test +SqlTimeOut =500000 +CDMUTER =EDKB04 +MuterNr =9996 +WatchDir =k:\edoka\00_EDK_Files\EDKB04 +TimerIntervall =0 +Loop =false +Debugmode =true +DebugDir =k:\edoka\00_EDK_Files\EDKB04\Archiv +DefaultBetreuerID =1166755 +nb_Errors =10 +nb_seconds =10 +len_TXADZ =35 +WaitForBrake =0 +WriteUnsplittedFile =1 diff --git a/EDKB04OP/bms_conn.cfg b/EDKB04OP/bms_conn.cfg new file mode 100644 index 0000000..eb6589c --- /dev/null +++ b/EDKB04OP/bms_conn.cfg @@ -0,0 +1 @@ +¹µÈ¦rȽ¹¿¸ª‰¿­Çx†°Ç­Ç…~¶Ã®Àµ¦¾h¸µÈ¦¾Äµ¢˜‡¼ªÄ»¾ÇÈeź±¹¿¾¹Ål®À®Ä‘š¦¾È³ÄÄ··¿¹³¼¾ÃÂe»¹‹½¶¨·±¹r»¾Î¹‚†…‡zˆÊ¸±¾e»¬’ǵ€Â¶Á·ÄÄ·°‰oŰʆ€ diff --git a/EDKB04OP/bms_settings.xml b/EDKB04OP/bms_settings.xml new file mode 100644 index 0000000..387768d --- /dev/null +++ b/EDKB04OP/bms_settings.xml @@ -0,0 +1,46 @@ + + + + + 1 + + + 2 + + + 2 + + + 2 + + + 3 + + + BMS + + + 1 + + + server01 + + + bms@tkb.ch + + + + 0 + mailUser + mailPassword + + + \ No newline at end of file diff --git a/EDKB04OP/clsParameter.vb b/EDKB04OP/clsParameter.vb new file mode 100644 index 0000000..f75d6a4 --- /dev/null +++ b/EDKB04OP/clsParameter.vb @@ -0,0 +1,261 @@ +Public Class ClsParameter + +#Region "Deklarationen" + + Dim p_MQHostname As String + Public Property MQHostname() As String + Get + Return p_MQHostname + End Get + Set(ByVal value As String) + p_MQHostname = value + End Set + End Property + + Dim p_MQPort As String + Public Property MQPort() As String + Get + Return p_MQPort + End Get + Set(ByVal value As String) + p_MQPort = value + End Set + End Property + + Dim p_MQChannel As String + Public Property MQChannel() As String + Get + Return p_MQChannel + End Get + Set(ByVal value As String) + p_MQChannel = value + End Set + End Property + + Dim p_MQQueueName As String + Public Property MQQueueName() As String + Get + Return p_MQQueueName + End Get + Set(ByVal value As String) + p_MQQueueName = value + End Set + End Property + + Dim p_SqlTimeout As String + Public Property SqlTimeout() As String + Get + Return p_SqlTimeout + End Get + Set(ByVal value As String) + p_SqlTimeout = value + End Set + End Property + + Dim p_CDMuter As String + Public Property CDMuter() As String + Get + Return p_CDMuter + End Get + Set(ByVal value As String) + p_CDMuter = value + End Set + End Property + + Dim p_MuterNr As String + Public Property MuterNr() As String + Get + Return p_MuterNr + End Get + Set(ByVal value As String) + p_MuterNr = value + End Set + End Property + + Dim p_Watchdir As String + Public Property Watchdir() As String + Get + Return p_Watchdir + End Get + Set(ByVal value As String) + p_Watchdir = value + End Set + End Property + + Dim p_TimerInterval As String + Public Property TimerInterval() As String + Get + Return p_TimerInterval + End Get + Set(ByVal value As String) + p_TimerInterval = value + End Set + End Property + + Dim p_LoopQueue As String + Public Property LoopQueue() As String + Get + Return p_LoopQueue + End Get + Set(ByVal value As String) + p_LoopQueue = value + End Set + End Property + + Dim p_DebugMode As Boolean + Public Property DebugMode() As Boolean + Get + Return p_DebugMode + End Get + Set(ByVal value As Boolean) + p_DebugMode = value + End Set + End Property + + Dim p_DebugDir As String + Public Property DebugDir() As String + Get + Return p_DebugDir + End Get + Set(ByVal value As String) + p_DebugDir = value + End Set + End Property + + Dim p_DefaultBetreuerID As String + Public Property DefaultBetreuerID() As String + Get + Return p_DefaultBetreuerID + End Get + Set(ByVal value As String) + p_DefaultBetreuerID = value + End Set + End Property + + Dim p_nb_errors As Integer + Public Property nb_errors() As Integer + Get + Return p_nb_errors + End Get + Set(ByVal value As Integer) + p_nb_errors = value + End Set + End Property + + Dim p_nb_seconds As Integer + Public Property nb_seconds() As Integer + Get + Return p_nb_seconds + End Get + Set(ByVal value As Integer) + p_nb_seconds = value + End Set + End Property + + Dim p_len_TXADZ As Integer + Public Property len_TXADZ() As Integer + Get + Return p_len_TXADZ + End Get + Set(ByVal value As Integer) + p_len_TXADZ = value + End Set + End Property + + Dim p_WaitForBrake As Integer + Public Property WaitForBrake() As Integer + Get + Return p_WaitForBrake + End Get + Set(value As Integer) + p_WaitForBrake = value + End Set + + End Property + + Dim p_WriteUnsplittedFile As Integer + Public Property WriteUnsplittedFile() As Integer + Get + Return p_WriteUnsplittedFile + End Get + Set(value As Integer) + p_WriteUnsplittedFile = value + End Set + + End Property + + + Dim m_writeeventlog As Boolean + Property WriteEventLog As Boolean + Get + Return m_writeeventlog + End Get + Set(value As Boolean) + m_writeeventlog = value + End Set + End Property +#End Region + + Public Function Loadparameters() As String + Try + WriteEventLog = False + m_log.Log("EDKB04: Loading Parameters", Common.Common.JournalEntryType.Information) + oread = IO.File.OpenText(appPath & "parameter.cfg") + Me.p_MQHostname = ParamValue(oread.ReadLine) + Me.p_MQPort = ParamValue(oread.ReadLine) + Me.p_MQChannel = ParamValue(oread.ReadLine) + Me.p_MQQueueName = ParamValue(oread.ReadLine) + Me.p_SqlTimeout = ParamValue(oread.ReadLine) + Me.p_CDMuter = ParamValue(oread.ReadLine) + Me.p_MuterNr = ParamValue(oread.ReadLine) + Me.p_Watchdir = ParamValue(oread.ReadLine) + Me.p_TimerInterval = ParamValue(oread.ReadLine) + Me.p_LoopQueue = ParamValue(oread.ReadLine) + Me.p_DebugMode = CBool(ParamValue(oread.ReadLine)) + Me.p_DebugDir = ParamValue(oread.ReadLine) + Me.p_DefaultBetreuerID = ParamValue(oread.ReadLine) + Try + Me.p_nb_errors = CInt(ParamValue(oread.ReadLine)) + Catch ex As Exception + ' Keine Zahl + Me.p_nb_errors = 999999 + End Try + Try + Me.p_nb_seconds = CInt(ParamValue(oread.ReadLine)) + Catch ex As Exception + 'Keine Zahl + Me.p_nb_seconds = 1 + End Try + Try + Me.p_len_TXADZ = CInt(ParamValue(oread.ReadLine)) + Catch ex As Exception + 'Keine Zahl + Me.p_len_TXADZ = 35 + End Try + Try + Me.WaitForBrake = CInt(ParamValue(oread.ReadLine)) + Catch ex As Exception + 'Keine Zahl + Me.WaitForBrake = 0 + End Try + Try + Me.WriteUnsplittedFile = CInt(ParamValue(oread.ReadLine)) + Catch ex As Exception + 'Keine Zahl + Me.WriteUnsplittedFile = 0 + End Try + oread.Close() + m_log.Log("EDKB04: Loading Parameters Ended", Common.Common.JournalEntryType.Information) + Return "" + Catch ex As Exception + m_log.Log("EDKB04: Error Loading Params: " & ex.Message, Common.Common.JournalEntryType.Error) + Return ex.Message + End Try + End Function + + Private Function ParamValue(ByVal sinput As String) As String + Dim splitter() As String + splitter = Split(sinput, "=") + ParamValue = splitter(1) + End Function +End Class diff --git a/EDKB04OP/clsconnectionprovider.vb b/EDKB04OP/clsconnectionprovider.vb new file mode 100644 index 0000000..57723d0 --- /dev/null +++ b/EDKB04OP/clsconnectionprovider.vb @@ -0,0 +1,289 @@ +' /////////////////////////////////////////////////////////////////////////// +' // Description: Connection Provider class for Database connection sharing +' // Generated by LLBLGen v1.2.1045.38210 Final on: Sonntag, 18. Mai 2003, 00:06:25 +' // This class implements IDisposable. +' /////////////////////////////////////////////////////////////////////////// +Imports System +Imports System.Configuration +Imports System.Data +Imports System.Data.SqlClient +Imports System.Collections + +Namespace edokadb + ' /// + ' /// Purpose: provides a SqlConnection object which can be shared among data-access tier objects + ' /// to provide a way to do ADO.NET transaction coding without the hassling with SqlConnection objects + ' /// on a high level. + ' /// + Public Class clsConnectionProvider + Implements IDisposable + +#Region " Class Member Declarations " + + Private m_scoDBConnection As SqlConnection + Private m_bIsTransactionPending, m_bIsDisposed As Boolean + Private m_stCurrentTransaction As SqlTransaction + Private m_alSavePoints As ArrayList + +#End Region + + + Public Sub New() + ' // Init the class + InitClass() + End Sub + + + ' /// + ' /// Purpose: Implements the IDispose' method Dispose. + ' /// + Public Overloads Sub Dispose() Implements IDisposable.Dispose + Dispose(True) + GC.SuppressFinalize(Me) + End Sub + + + ' /// + ' /// Purpose: Implements the Dispose functionality. + ' /// + Protected Overridable Overloads Sub Dispose(ByVal bIsDisposing As Boolean) + ' // Check to see if Dispose has already been called. + If Not m_bIsDisposed Then + If bIsDisposing Then + ' // Dispose managed resources. + If Not (m_stCurrentTransaction Is Nothing) Then + m_stCurrentTransaction.Dispose() + m_stCurrentTransaction = Nothing + End If + If Not (m_scoDBConnection Is Nothing) Then + ' // closing the connection will abort (rollback) any pending transactions + m_scoDBConnection.Close() + m_scoDBConnection.Dispose() + m_scoDBConnection = Nothing + End If + End If + End If + m_bIsDisposed = True + End Sub + + + ' /// + ' /// Purpose: Initializes class members. + ' /// + Private Sub InitClass() + ' // Create all the objects and initialize other members. + m_scoDBConnection = New SqlConnection() + m_bIsDisposed = False + m_stCurrentTransaction = Nothing + m_bIsTransactionPending = False + m_alSavePoints = New ArrayList() + End Sub + + + ' /// + ' /// Purpose: Opens the connection object. + ' /// + ' /// True, if succeeded, otherwise an Exception exception is thrown. + Public Function OpenConnection() As Boolean + Try + If (m_scoDBConnection.State And ConnectionState.Open) > 0 Then + ' // It's already open. + Throw New Exception("OpenConnection::Connection is already open.") + End If + m_scoDBConnection.Open() + m_bIsTransactionPending = False + m_alSavePoints.Clear() + Return True + Catch ex As Exception + ' // bubble exception + Throw ex + End Try + End Function + + + ' /// + ' /// Purpose: Starts a new ADO.NET transaction using the open connection object of this class. + ' /// + ' /// Name of the transaction to start + ' /// True, if transaction is started correctly, otherwise an Exception exception is thrown + Public Function BeginTransaction(ByVal sTransactionName As String) As Boolean + Try + If m_bIsTransactionPending Then + ' // no nested transactions allowed. + Throw New Exception("BeginTransaction::Already transaction pending. Nesting not allowed") + End If + If (m_scoDBConnection.State And ConnectionState.Open) = 0 Then + ' // no open connection + Throw New Exception("BeginTransaction::Connection is not open.") + End If + ' // begin the transaction and store the transaction object. + m_stCurrentTransaction = m_scoDBConnection.BeginTransaction(IsolationLevel.ReadCommitted, sTransactionName) + m_bIsTransactionPending = True + Return True + Catch ex As Exception + ' // bubble exception + Throw ex + End Try + End Function + + + ' /// + ' /// Purpose: Commits a pending transaction on the open connection object of this class. + ' /// + ' /// True, if commit was succesful, or an Exception exception is thrown + Public Function CommitTransaction() As Boolean + Try + If Not m_bIsTransactionPending Then + ' // no transaction pending + Throw New Exception("CommitTransaction::No transaction pending.") + End If + If (m_scoDBConnection.State And ConnectionState.Open) = 0 Then + ' // no open connection + Throw New Exception("CommitTransaction::Connection is not open.") + End If + ' // commit the transaction + m_stCurrentTransaction.Commit() + m_bIsTransactionPending = False + m_stCurrentTransaction.Dispose() + m_stCurrentTransaction = Nothing + m_alSavePoints.Clear() + Return True + Catch ex As Exception + ' // bubble exception + Throw ex + End Try + End Function + + + ' /// + ' /// Purpose: Rolls back a pending transaction on the open connection object of this class, + ' /// or rolls back to the savepoint with the given name. Savepoints are created with SaveTransaction(). + ' /// + ' /// Name of transaction to roll back. Can be name of savepoint + ' /// True, if rollback was succesful, or an Exception exception is thrown + Public Function RollbackTransaction(ByVal sTransactionToRollback As String) As Boolean + Try + If Not m_bIsTransactionPending Then + ' // no transaction pending + Throw New Exception("RollbackTransaction::No transaction pending.") + End If + If (m_scoDBConnection.State And ConnectionState.Open) = 0 Then + ' // no open connection + Throw New Exception("RollbackTransaction::Connection is not open.") + End If + ' // rollback the transaction + m_stCurrentTransaction.Rollback(sTransactionToRollback) + ' // if this wasn't a savepoint, we've rolled back the complete transaction, so we + ' // can clean it up. + If Not m_alSavePoints.Contains(sTransactionToRollback) Then + ' // it's not a savepoint + m_bIsTransactionPending = False + m_stCurrentTransaction.Dispose() + m_stCurrentTransaction = Nothing + m_alSavePoints.Clear() + End If + Return True + Catch ex As Exception + ' // bubble exception + Throw ex + End Try + End Function + + + ' /// + ' /// Purpose: Saves a pending transaction on the open connection object of this class to a 'savepoint' + ' /// with the given name. + ' /// When a rollback is issued, the caller can rollback to this savepoint or roll back the complete transaction. + ' /// + ' /// Name of the savepoint to store the current transaction under. + ' /// True, if save was succesful, or an Exception exception is thrown + Public Function SaveTransaction(ByVal sSavePointName As String) As Boolean + Try + If Not m_bIsTransactionPending Then + ' // no transaction pending + Throw New Exception("SaveTransaction::No transaction pending.") + End If + If (m_scoDBConnection.State And ConnectionState.Open) = 0 Then + ' // no open connection + Throw New Exception("SaveTransaction::Connection is not open.") + End If + ' // save the transaction + m_stCurrentTransaction.Save(sSavePointName) + ' // Store the savepoint in the list. + m_alSavePoints.Add(sSavePointName) + Return True + Catch ex As Exception + ' // bubble exception + Throw ex + End Try + End Function + + + ' /// + ' /// Purpose: Closes the open connection. Depending on bCommitPendingTransactions, a pending + ' /// transaction is commited, or aborted. + ' /// + ' /// Flag for what to do when a transaction is still pending. True + ' /// will commit the current transaction, False will abort (rollback) the complete current transaction. + ' /// True, if close was succesful, False if connection was already closed, or an Exception exception is thrown when + ' /// an error occurs + Public Function CloseConnection(ByVal bCommitPendingTransaction As Boolean) As Boolean + Try + If (m_scoDBConnection.State And ConnectionState.Open) = 0 Then + ' // No open connection + Return False + End If + If m_bIsTransactionPending Then + If bCommitPendingTransaction Then + ' // Commit the pending transaction + m_stCurrentTransaction.Commit() + Else + ' // Rollback the pending transaction + m_stCurrentTransaction.Rollback() + End If + m_bIsTransactionPending = False + m_stCurrentTransaction.Dispose() + m_stCurrentTransaction = Nothing + m_alSavePoints.Clear() + End If + ' // close the connection + m_scoDBConnection.Close() + Return True + Catch ex As Exception + ' // bubble exception + Throw ex + End Try + End Function + + +#Region " Class Property Declarations " + + Public ReadOnly Property stCurrentTransaction() As SqlTransaction + Get + Return m_stCurrentTransaction + End Get + End Property + + + Public ReadOnly Property bIsTransactionPending() As Boolean + Get + Return m_bIsTransactionPending + End Get + End Property + + + Public ReadOnly Property scoDBConnection() As SqlConnection + Get + Return m_scoDBConnection + End Get + End Property + Public WriteOnly Property sConnectionString() As String + Set(ByVal Value As String) + m_scoDBConnection.ConnectionString = Value + End Set + End Property + +#End Region + + End Class +End Namespace diff --git a/EDKB04OP/db_connection.vb b/EDKB04OP/db_connection.vb new file mode 100644 index 0000000..7469854 --- /dev/null +++ b/EDKB04OP/db_connection.vb @@ -0,0 +1,36 @@ +Imports System.ComponentModel +Imports Microsoft.VisualBasic + +Public Class DB_Connection + Shared Sub New() + Try + 'Edoka + oread = IO.File.OpenText(appPath + "edokaconn.cfg") + sConnectionString_edoka = oread.ReadLine + Globals.sConnectionString_edoka = sConnectionString_edoka + oread.Close() + + 'Journale + oread = IO.File.OpenText(appPath + "journaleconn.cfg") + sConnectionString_journale = oread.ReadLine + Globals.sConnectionString_journale = sConnectionString_journale + oread.Close() + + ''tgdata + 'oread = IO.File.OpenText(appPath + "tgdataconn.cfg") + 'sConnectionString_tgdata = oread.ReadLine + 'Globals.sConnectionString_tgdata = sConnectionString_tgdata + 'oread.Close() + + Globals.conn_edoka.sConnectionString = sConnectionString_edoka + Globals.conn_journale.sConnectionString = sConnectionString_journale + 'Globals.conn_tgdata.sConnectionString = sConnectionString_tgdata + m_log.Log("EDKB04: DB-Connection OK", Common.Common.JournalEntryType.Information) + Catch ex As Exception + m_log.Log(ex.Message, Common.Common.JournalEntryType.Error) + End Try + + End Sub + +End Class + diff --git a/EDKB04OP/demopartner.xml b/EDKB04OP/demopartner.xml new file mode 100644 index 0000000..2cf3fdf --- /dev/null +++ b/EDKB04OP/demopartner.xml @@ -0,0 +1,49 @@ + + + Parter Stammdaten + + tgkb + avaloq + D + 123 + + + + 2 + BP + NAT + 29794711 + 1234 + Muster + Muster, Max + Max + Max Muster, irgendwo + 19680716 + CH + + D + M + 29748721 + + + + + + 8101 + 02 + 06 + N + CH + N + + + + + + + + + Verheiratet + + + diff --git a/EDKB04OP/dlls/BMS.dll b/EDKB04OP/dlls/BMS.dll new file mode 100644 index 0000000..b8da491 Binary files /dev/null and b/EDKB04OP/dlls/BMS.dll differ diff --git a/EDKB04OP/dlls/Common.dll b/EDKB04OP/dlls/Common.dll new file mode 100644 index 0000000..1cb73a8 Binary files /dev/null and b/EDKB04OP/dlls/Common.dll differ diff --git a/EDKB04OP/dlls/DataAccess.dll b/EDKB04OP/dlls/DataAccess.dll new file mode 100644 index 0000000..ae5ea94 Binary files /dev/null and b/EDKB04OP/dlls/DataAccess.dll differ diff --git a/EDKB04OP/dlls/amqmdnet.dll b/EDKB04OP/dlls/amqmdnet.dll new file mode 100644 index 0000000..97cebeb Binary files /dev/null and b/EDKB04OP/dlls/amqmdnet.dll differ diff --git a/EDKB04OP/edokaconn.cfg b/EDKB04OP/edokaconn.cfg new file mode 100644 index 0000000..bbe7ecd --- /dev/null +++ b/EDKB04OP/edokaconn.cfg @@ -0,0 +1 @@ +Data Source=shu01\shu00;Initial Catalog=edoka_dms;Persist Security Info=True;User ID=sa;Password=*shu29; diff --git a/EDKB04OP/journaleconn.cfg b/EDKB04OP/journaleconn.cfg new file mode 100644 index 0000000..1454125 --- /dev/null +++ b/EDKB04OP/journaleconn.cfg @@ -0,0 +1 @@ +Data Source=shu01\shu00;Initial Catalog=edoka_journale;Persist Security Info=True;User ID=sa;Password=*shu29 \ No newline at end of file diff --git a/EDKB04OP/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/EDKB04OP/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..942f5bd Binary files /dev/null and b/EDKB04OP/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/EDKB04OP/obj/Debug/EDKB04.ProjectInstaller.resources b/EDKB04OP/obj/Debug/EDKB04.ProjectInstaller.resources new file mode 100644 index 0000000..8b1a44e Binary files /dev/null and b/EDKB04OP/obj/Debug/EDKB04.ProjectInstaller.resources differ diff --git a/EDKB04OP/obj/Debug/EDKB04.Resources.resources b/EDKB04OP/obj/Debug/EDKB04.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/EDKB04OP/obj/Debug/EDKB04.Resources.resources differ diff --git a/EDKB04OP/obj/Debug/EDKB04.exe b/EDKB04OP/obj/Debug/EDKB04.exe new file mode 100644 index 0000000..0217993 Binary files /dev/null and b/EDKB04OP/obj/Debug/EDKB04.exe differ diff --git a/EDKB04OP/obj/Debug/EDKB04.pdb b/EDKB04OP/obj/Debug/EDKB04.pdb new file mode 100644 index 0000000..150018a Binary files /dev/null and b/EDKB04OP/obj/Debug/EDKB04.pdb differ diff --git a/EDKB04OP/obj/Debug/EDKB04.xml b/EDKB04OP/obj/Debug/EDKB04.xml new file mode 100644 index 0000000..e5ba6f1 --- /dev/null +++ b/EDKB04OP/obj/Debug/EDKB04.xml @@ -0,0 +1,489 @@ + + + + +EDKB04 + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Connection String für die EDOKA Datenbank + + + + + + Zum Suchen von LSV-BEs eines Partners mit Hilfe von zusäztlichen Kriterein (Selektoren). + Grundlage für die Klasse bildet die Tatsache, dass man mit einem SELECT Statement wie + select d.dokumentid, diw.inhalt from dbo.dokument d + inner join dbo.dokumentinfo_wert diw on d.dokumentid = diw.dokumentid + where d.dokumenttypnr = 1176 + and d.nrpar00= 1339632 + and diw.inhalt in ( 'IBAN;CH4400784013396322002', 'Paginatornummer;02180305004720', 'BE_LSV-ID_gueltig_ab;20180305', 'LSV-ID;SCW1W', 'Referenz1;60211909') + schon sehr gut eine LSV-BE finden kann und auch sieht, ob alle Suchkriterien aus dbo.dokumentinfo_wert mitberücksichtigt wurden. + + + + + Tag Id des Selektors in der XML Message von Avaloq + + + + + + Id (das ist der Teil vor dem ;) von dbo.dokumentinfo_wert.inhalt + + + + + + Wert des XML Tags aus der Message von Avaloq + + + + + + True: Der Selektor wurde in die DataTable abgefüllt + False: Der Selektor fehlt in der DataTable + + + + + + Adapter für Edoka Datenbank auf dem SQL Server + + + + + gemäss Stackoverflow https://stackoverflow.com/a/10373384 + + + + + + + + Hebt die LSV BEs gemäss Contract auf. + Dazu wird der ConnectionString benötigt + + True, wenn ein einziges Dokument identifiziert und aufgehoben werden konnte. Sonst False + + + + Füllt Items mit passenden Dokumenten. Zuerst wird nur mit Partner- und Paginatornummer gesucht. + Die restlichen Suchkriterien werden erst angewendet, wenn mit Partner- und Paginatornummer + keine passenden Dokumente gefunden werden können. + + Always true + + + + Fügt die TGNummer des Erstellers und die XML-Datei in die Datenbank (edk_data) ein. + + + + + + + Teil von Update_Partner() + Aktualisiert alle berechtigte Email Adressen eines Parnters + Die Daten (siehe Parameter) kommen alle aus der XML Message + + aus XML Message + + + + + + True: Alles OK, False: nicht alles OK + + + + Gibt den InnerText eines Tags zurück. Falls eine Ausnahme auftritt, wird diese abgefangen und + ein Leerstring ("") zurückgegeben. + + + + + + + + + Erstellt aus einer Serie von XML Objekten eine DataTable. + Haben die XML Objekte gleichnamige Subnodes, so wird der Spaltenname in der Tabelle mit einer + angehängten Indexnummer eindeutig gemacht. + Falls eine Ausnahme Auftritt, wird eine leere DataTable mit einer Spalte "Dummy" zurückgegeben. + + + + + + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if node is found and value is retrieved successfully. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + s + Converts a list of Xml nodes to a DataTable. + + List of Xml nodes + DataTable + + This method convert + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a list of Xml nodes to a DataTable and sets one of the columns as a primary key. + + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Updates the child nodes of "parentNode" by using the fields from a datatable. + + + + + + The child nodes that will be updated must have attribute fields that correspond to + the DataTable. The "keyField" will be used to identify the attribute that serves as + an identifier of the rows. The datatable can have less fields than the nodes so + you have the chance to update smaller subsets. + Make sure that you did not call "AcceptChanges" before passing the datatable or this + function will not find any change. + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Returns contents of an XmlNode in a string. + + The XmlNode whose contents will be read into a string. + Xml formatted string with contents of "node" parameter. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Convert a XmlNodeList to string + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Method to convert a XmlDocument to string. + + XmlDocument that will be converted to string. + A xml formatted string. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a string array to XmlNodes and appends all those nodes to a root node. + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + + + + + + + + ----------------------------------------------------------------------------- + + + + Inserts an empty record at the bottom of the hierarchy, creating the + tree as required. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The XmlNode inserted into the hierarchy. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts an record with a multiple fields at the bottom of the hierarchy. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The attribute names that will be created for the node inserted. + The corresponding value of each field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with a single field at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The field to add to the record. + The value assigned to the field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Insert a record with multiple fields at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The array of fields as field/value pairs. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + The columns names of the DataRow will become the attribute names and + the row values of the DataRow will be the attribute values. + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields from a DataTable at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + + + Inserts a record with multiple values at bottom of hierarchy. This is analogous to inserting + a column of data. + + + The xml XPath query to get to the bottom node. + Name of the attribute to be created at node inserted. + Values that will be inserted that correspond to the field name. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Update a single field in all records in the specified path. + + The XmlDocument whose node will be udpated. + The xml path. + The field name to update. + The new value. + The number of records affected. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to update an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Deletes all records of the specified path. + + The xml XPath query to get to the bottom node. + The number of records deleted. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Deletes a field from all records on the specified path. + + The xml path. + The field to delete. + The number of records affected. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Return a single string representing the value of the specified field + for the first record encountered. + + The xml path. + The desired field. + A string with the field's value or null. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns a DataTable for all rows on the path. + + The xml path. + The DataTable with the returned rows. + The row count will be 0 if no rows returned. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns an array of values for the specified field for all rows on + the path. + + The xml path. + The desired field. + The array of string values for each row qualified by the path. + A null is returned if the query results in 0 rows. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Inserts a node at the specified segment if it doesn't exist, otherwise + traverses the node. + + The current node. + The path segment list. + The current segment. + + + + + Creates columns given an XmlNode. + + The target DataTable. + The source XmlNode. + + + diff --git a/EDKB04OP/obj/Debug/EDKB04OP.vbproj.AssemblyReference.cache b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.AssemblyReference.cache new file mode 100644 index 0000000..3fc8ec7 Binary files /dev/null and b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.AssemblyReference.cache differ diff --git a/EDKB04OP/obj/Debug/EDKB04OP.vbproj.CoreCompileInputs.cache b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.CoreCompileInputs.cache new file mode 100644 index 0000000..7fc1c12 --- /dev/null +++ b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +8e71177d433b87085749bd8b060a3b51284e68e88e453de6e00601b342cdfee0 diff --git a/EDKB04OP/obj/Debug/EDKB04OP.vbproj.FileListAbsolute.txt b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.FileListAbsolute.txt new file mode 100644 index 0000000..12982c4 --- /dev/null +++ b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.FileListAbsolute.txt @@ -0,0 +1,22 @@ +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\bms_settings.xml +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\bms_conn.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\edokaconn.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\journaleconn.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\parameter.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\EDKB04.exe.config +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\EDKB04.exe +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\EDKB04.pdb +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\EDKB04.xml +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\amqmdnet.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\BMS.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\Common.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Debug\DataAccess.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04OP.vbproj.AssemblyReference.cache +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04.Resources.resources +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04.ProjectInstaller.resources +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04OP.vbproj.GenerateResource.cache +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04OP.vbproj.CoreCompileInputs.cache +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04OP.vbproj.Up2Date +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04.exe +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04.xml +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Debug\EDKB04.pdb diff --git a/EDKB04OP/obj/Debug/EDKB04OP.vbproj.GenerateResource.cache b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.GenerateResource.cache new file mode 100644 index 0000000..af703f3 Binary files /dev/null and b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.GenerateResource.cache differ diff --git a/EDKB04OP/obj/Debug/EDKB04OP.vbproj.Up2Date b/EDKB04OP/obj/Debug/EDKB04OP.vbproj.Up2Date new file mode 100644 index 0000000..e69de29 diff --git a/EDKB04OP/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/EDKB04OP/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..224c5ad Binary files /dev/null and b/EDKB04OP/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/EDKB04OP/obj/Release/EDKB04.ProjectInstaller.resources b/EDKB04OP/obj/Release/EDKB04.ProjectInstaller.resources new file mode 100644 index 0000000..8b1a44e Binary files /dev/null and b/EDKB04OP/obj/Release/EDKB04.ProjectInstaller.resources differ diff --git a/EDKB04OP/obj/Release/EDKB04.Resources.resources b/EDKB04OP/obj/Release/EDKB04.Resources.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/EDKB04OP/obj/Release/EDKB04.Resources.resources differ diff --git a/EDKB04OP/obj/Release/EDKB04.exe b/EDKB04OP/obj/Release/EDKB04.exe new file mode 100644 index 0000000..0fbacb2 Binary files /dev/null and b/EDKB04OP/obj/Release/EDKB04.exe differ diff --git a/EDKB04OP/obj/Release/EDKB04.pdb b/EDKB04OP/obj/Release/EDKB04.pdb new file mode 100644 index 0000000..4b42bb3 Binary files /dev/null and b/EDKB04OP/obj/Release/EDKB04.pdb differ diff --git a/EDKB04OP/obj/Release/EDKB04.xml b/EDKB04OP/obj/Release/EDKB04.xml new file mode 100644 index 0000000..e5ba6f1 --- /dev/null +++ b/EDKB04OP/obj/Release/EDKB04.xml @@ -0,0 +1,489 @@ + + + + +EDKB04 + + + + + + Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + + + + + Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + + + + + Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + + + + + Connection String für die EDOKA Datenbank + + + + + + Zum Suchen von LSV-BEs eines Partners mit Hilfe von zusäztlichen Kriterein (Selektoren). + Grundlage für die Klasse bildet die Tatsache, dass man mit einem SELECT Statement wie + select d.dokumentid, diw.inhalt from dbo.dokument d + inner join dbo.dokumentinfo_wert diw on d.dokumentid = diw.dokumentid + where d.dokumenttypnr = 1176 + and d.nrpar00= 1339632 + and diw.inhalt in ( 'IBAN;CH4400784013396322002', 'Paginatornummer;02180305004720', 'BE_LSV-ID_gueltig_ab;20180305', 'LSV-ID;SCW1W', 'Referenz1;60211909') + schon sehr gut eine LSV-BE finden kann und auch sieht, ob alle Suchkriterien aus dbo.dokumentinfo_wert mitberücksichtigt wurden. + + + + + Tag Id des Selektors in der XML Message von Avaloq + + + + + + Id (das ist der Teil vor dem ;) von dbo.dokumentinfo_wert.inhalt + + + + + + Wert des XML Tags aus der Message von Avaloq + + + + + + True: Der Selektor wurde in die DataTable abgefüllt + False: Der Selektor fehlt in der DataTable + + + + + + Adapter für Edoka Datenbank auf dem SQL Server + + + + + gemäss Stackoverflow https://stackoverflow.com/a/10373384 + + + + + + + + Hebt die LSV BEs gemäss Contract auf. + Dazu wird der ConnectionString benötigt + + True, wenn ein einziges Dokument identifiziert und aufgehoben werden konnte. Sonst False + + + + Füllt Items mit passenden Dokumenten. Zuerst wird nur mit Partner- und Paginatornummer gesucht. + Die restlichen Suchkriterien werden erst angewendet, wenn mit Partner- und Paginatornummer + keine passenden Dokumente gefunden werden können. + + Always true + + + + Fügt die TGNummer des Erstellers und die XML-Datei in die Datenbank (edk_data) ein. + + + + + + + Teil von Update_Partner() + Aktualisiert alle berechtigte Email Adressen eines Parnters + Die Daten (siehe Parameter) kommen alle aus der XML Message + + aus XML Message + + + + + + True: Alles OK, False: nicht alles OK + + + + Gibt den InnerText eines Tags zurück. Falls eine Ausnahme auftritt, wird diese abgefangen und + ein Leerstring ("") zurückgegeben. + + + + + + + + + Erstellt aus einer Serie von XML Objekten eine DataTable. + Haben die XML Objekte gleichnamige Subnodes, so wird der Spaltenname in der Tabelle mit einer + angehängten Indexnummer eindeutig gemacht. + Falls eine Ausnahme Auftritt, wird eine leere DataTable mit einer Spalte "Dummy" zurückgegeben. + + + + + + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if node is found and value is retrieved successfully. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Gets the value from an attribute at the specified node. + + The XmlNode from which this method will get the value of an attribute. + Name of the attribute that will be read. + Attribute value read by this method + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Sets the value of an attribute for a given XmlNode. + + XmlNode whose attribute will be set. + Name of the attribute to set. + Value to be set + True if success. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + s + Converts a list of Xml nodes to a DataTable. + + List of Xml nodes + DataTable + + This method convert + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a list of Xml nodes to a DataTable and sets one of the columns as a primary key. + + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Updates the child nodes of "parentNode" by using the fields from a datatable. + + + + + + The child nodes that will be updated must have attribute fields that correspond to + the DataTable. The "keyField" will be used to identify the attribute that serves as + an identifier of the rows. The datatable can have less fields than the nodes so + you have the chance to update smaller subsets. + Make sure that you did not call "AcceptChanges" before passing the datatable or this + function will not find any change. + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Returns contents of an XmlNode in a string. + + The XmlNode whose contents will be read into a string. + Xml formatted string with contents of "node" parameter. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Convert a XmlNodeList to string + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Method to convert a XmlDocument to string. + + XmlDocument that will be converted to string. + A xml formatted string. + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + Converts a string array to XmlNodes and appends all those nodes to a root node. + + + + + + + ----------------------------------------------------------------------------- + + + ----------------------------------------------------------------------------- + + + + + + + + + ----------------------------------------------------------------------------- + + + + Inserts an empty record at the bottom of the hierarchy, creating the + tree as required. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The XmlNode inserted into the hierarchy. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts an record with a multiple fields at the bottom of the hierarchy. + + The XmlDocument to which the node will be inserted. + The xml XPath query to get to the bottom node. + The attribute names that will be created for the node inserted. + The corresponding value of each field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with a single field at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The field to add to the record. + The value assigned to the field. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Insert a record with multiple fields at the bottom of the hierarchy. + + The xml XPath query to get to the bottom node. + The array of fields as field/value pairs. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + The columns names of the DataRow will become the attribute names and + the row values of the DataRow will be the attribute values. + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Inserts a record with multiple fields from a DataTable at bottom of the hierarchy. + + + The xml XPath query to get to the bottom node. + The DataRow values that will be added as attributes. + + + + Inserts a record with multiple values at bottom of hierarchy. This is analogous to inserting + a column of data. + + + The xml XPath query to get to the bottom node. + Name of the attribute to be created at node inserted. + Values that will be inserted that correspond to the field name. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to insert an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Update a single field in all records in the specified path. + + The XmlDocument whose node will be udpated. + The xml path. + The field name to update. + The new value. + The number of records affected. + Thrown when an argument is null. + + The "doc" variable must have a root node. The path should not contain the root node. + The path can contain only the node names or it can contain attributes in XPath query form. + For example to update an "Address" node at the bottom, the following is a valid xpath query + xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + + + + + Deletes all records of the specified path. + + The xml XPath query to get to the bottom node. + The number of records deleted. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Deletes a field from all records on the specified path. + + The xml path. + The field to delete. + The number of records affected. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Return a single string representing the value of the specified field + for the first record encountered. + + The xml path. + The desired field. + A string with the field's value or null. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns a DataTable for all rows on the path. + + The xml path. + The DataTable with the returned rows. + The row count will be 0 if no rows returned. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Returns an array of values for the specified field for all rows on + the path. + + The xml path. + The desired field. + The array of string values for each row qualified by the path. + A null is returned if the query results in 0 rows. + Thrown when an argument is null. + Additional exceptions may be thrown by the XmlDocument class. + + + + Inserts a node at the specified segment if it doesn't exist, otherwise + traverses the node. + + The current node. + The path segment list. + The current segment. + + + + + Creates columns given an XmlNode. + + The target DataTable. + The source XmlNode. + + + diff --git a/EDKB04OP/obj/Release/EDKB04OP.vbproj.AssemblyReference.cache b/EDKB04OP/obj/Release/EDKB04OP.vbproj.AssemblyReference.cache new file mode 100644 index 0000000..c412224 Binary files /dev/null and b/EDKB04OP/obj/Release/EDKB04OP.vbproj.AssemblyReference.cache differ diff --git a/EDKB04OP/obj/Release/EDKB04OP.vbproj.CoreCompileInputs.cache b/EDKB04OP/obj/Release/EDKB04OP.vbproj.CoreCompileInputs.cache new file mode 100644 index 0000000..7fc1c12 --- /dev/null +++ b/EDKB04OP/obj/Release/EDKB04OP.vbproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +8e71177d433b87085749bd8b060a3b51284e68e88e453de6e00601b342cdfee0 diff --git a/EDKB04OP/obj/Release/EDKB04OP.vbproj.FileListAbsolute.txt b/EDKB04OP/obj/Release/EDKB04OP.vbproj.FileListAbsolute.txt new file mode 100644 index 0000000..3bfa8cb --- /dev/null +++ b/EDKB04OP/obj/Release/EDKB04OP.vbproj.FileListAbsolute.txt @@ -0,0 +1,22 @@ +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\bms_settings.xml +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\bms_conn.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\edokaconn.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\journaleconn.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\parameter.cfg +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\EDKB04.exe.config +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\EDKB04.exe +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\EDKB04.pdb +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\EDKB04.xml +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\amqmdnet.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\BMS.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\Common.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\bin\Release\DataAccess.dll +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04OP.vbproj.AssemblyReference.cache +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04.Resources.resources +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04.ProjectInstaller.resources +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04OP.vbproj.GenerateResource.cache +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04OP.vbproj.CoreCompileInputs.cache +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04OP.vbproj.Up2Date +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04.exe +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04.xml +E:\Software-Projekte\EDOKA\batch\EDKB04OP\EDKB04OP\EDKB04OP\obj\Release\EDKB04.pdb diff --git a/EDKB04OP/obj/Release/EDKB04OP.vbproj.GenerateResource.cache b/EDKB04OP/obj/Release/EDKB04OP.vbproj.GenerateResource.cache new file mode 100644 index 0000000..af703f3 Binary files /dev/null and b/EDKB04OP/obj/Release/EDKB04OP.vbproj.GenerateResource.cache differ diff --git a/EDKB04OP/obj/Release/EDKB04OP.vbproj.Up2Date b/EDKB04OP/obj/Release/EDKB04OP.vbproj.Up2Date new file mode 100644 index 0000000..e69de29 diff --git a/EDKB04OP/obj/Release/TempPE/My Project.Resources.Designer.vb.dll b/EDKB04OP/obj/Release/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..90f02b0 Binary files /dev/null and b/EDKB04OP/obj/Release/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/EDKB04OP/parameter.cfg b/EDKB04OP/parameter.cfg new file mode 100644 index 0000000..33b92ff --- /dev/null +++ b/EDKB04OP/parameter.cfg @@ -0,0 +1,18 @@ +MQHostname =vb0049d +MQPort =1416 +MQChannel =TGKB.D16.EDOKA.CL +MQQueueName =test +SqlTimeOut =500000 +CDMUTER =EDKB04 +MuterNr =9996 +WatchDir =k:\edoka\00_EDK_Files\EDKB04 +TimerIntervall =0 +Loop =false +Debugmode =true +DebugDir =k:\edoka\00_EDK_Files\EDKB04\Archiv +DefaultBetreuerID =1166755 +nb_Errors =10 +nb_seconds =10 +len_TXADZ =35 +WaitForBrake =0 +WriteUnsplittedFile =1 diff --git a/EDKB04OP/xmlHandling.vb b/EDKB04OP/xmlHandling.vb new file mode 100644 index 0000000..7994c2c --- /dev/null +++ b/EDKB04OP/xmlHandling.vb @@ -0,0 +1,1442 @@ +Imports System.IO +Imports System.Xml +Imports System.Xml.Schema +Imports System.Data.SqlClient +Imports System.Data.SqlTypes + +Public Class xmlHandling + +#Region "Properties" + Dim m_result As Boolean + Property Result As Boolean + Get + Return m_result + End Get + Set(value As Boolean) + m_result = value + End Set + End Property +#End Region + +#Region "Deklarationen" + Dim Partner_Typ As String + Dim Partner_Art As String + Dim Resultvalue As String + Dim PersonBeziehung As New DataTable + Dim AddrBeziehung As New DataTable + Dim sAction As String = "" + Dim doc As New XmlDocument + Dim partnernr As Integer + Dim vvr As New DataTable + Dim pnr As Integer = 0 + Dim Angestelltenart As String = "" + Dim vipCode As String = "" + Dim OriginalXml As String = "" + +#End Region + + Sub New(ByVal strdata As String) + Try + Me.Result = True + Me.OriginalXml = strdata + Dim ds As New DataSet + If Result Then + doc.LoadXml(strdata) + Dim XMLType As String = XmlHelper.GetItemValueByTagName(doc, "resultName") + Select Case XMLType + Case "Partner Stammdaten" + Partner_Typ = XmlHelper.GetItemValueByTagName(doc, "typ") + Partner_Art = XmlHelper.GetItemValueByTagName(doc, "art") + PersonBeziehung = XmlHelper.ConvertXmlNodeListToDataTable(doc, "personbeziehung") + AddrBeziehung = XmlHelper.ConvertXmlNodeListToDataTable(doc, "adresse") + Angestelltenart = XmlHelper.GetItemValueByTagName(doc, "angestelltenArt") + vipCode = XmlHelper.GetItemValueByTagName(doc, "vipCode") + Result = Update_Partner() + If Result Then + Result = Update_Angestelltenart(Angestelltenart) + If Result Then + Result = Update_VIP(vipCode) + End If + End If + + Case "Adresse Stammdaten" + Dim Adresstype As String + ' Version mit E-Mail-Adressen + Adresstype = XmlHelper.GetItemValueByTagName(doc, "medium") + If Adresstype = "email" Then + Update_Email() + Else + Result = update_Adresse() + End If + + + Case "Container Stammdaten" + AddrBeziehung = XmlHelper.ConvertXmlNodeListToDataTable(doc, "adresse") + Result = update_vv() + Case "Document Stammdaten" + If XmlHelper.GetItemValueByTagName(doc, "partnerNummer") <> "" Then + Result = update_vv() + End If + Case "Konto Stammdaten" + AddrBeziehung = XmlHelper.ConvertXmlNodeListToDataTable(doc, "adresse") + Result = update_vv() + Case "Loan Stammdaten" + AddrBeziehung = XmlHelper.ConvertXmlNodeListToDataTable(doc, "adresse") + Result = update_vv() + Case "Mitarbeiter Stammdaten" + Case "Verfuegungsrechte" + vvr = XmlHelper.ConvertXmlNodeListToDataTable(doc, "Verfuegungsrecht") + pnr = XmlHelper.GetItemValueByTagName(doc, "BpKey") + Result = Update_Verfuegungsrechte() + Case "Schrankfach Stammdaten" + AddrBeziehung = XmlHelper.ConvertXmlNodeListToDataTable(doc, "adresse") + Result = update_vv() + Case "EDK-Dokument Referenz" + Dim dokumentid As String = XmlHelper.GetItemValueByTagName(doc, "objektRef") + Dim Ref1 As String = XmlHelper.GetItemValueByTagName(doc, "externeNr") + Dim Ref2 As String = XmlHelper.GetItemValueByTagName(doc, "formatierteNr") + Result = Update_Dokumentreferenz(dokumentid, Ref1, Ref2) + Case "LSV Stammdaten" + Result = update_lsv() + Case Else + m_log.log("EDKB04: Error bei XML->Obj: xmltype:" & XMLType, Common.Common.JournalEntryType.Error) + Result = False + End Select + + End If + Catch ex As Exception + m_log.log("EDKB04: Fehler beim Einlesen des XML", Common.Common.JournalEntryType.Error) + Result = False + End Try + End Sub + +#Region "LSV" + Private Function update_lsv() As Boolean + Dim ret As Boolean = True + Dim canceledDocuments As LsvBe.CanceledDocuments = New LsvBe.CanceledDocuments() + canceledDocuments.ConnectionString = Globals.sConnectionString_edoka + canceledDocuments.Contract = doc + ret = canceledDocuments.Render() + + For Each result As Result In canceledDocuments.Results + m_log.log(String.Format("EDKB04: {0}", result.Text), result.Type) + Next + + If Not ret Then + LsvSendMail() + End If + + Return ret + End Function + + Sub LsvSendMail() + Dim edokaSqlDb As New EdokaSqlDb(Globals.sConnectionString_edoka) + + edokaSqlDb.SendMail( + "TGGZVInlandAusland@tkb.ch", + "Zur Abklärung: Für die aufgehobene LSV-Belastungsermächtigung wurde im Archiv kein zutreffendes Dokument für die Aufhebung gefunden.", + Me.OriginalXml) + End Sub + +#End Region + + +#Region "Partner" + +#Region "PartnerUpdate" + + Private Sub UpdateStringRow(ByVal XmlElement As String, ByRef DbRow As DataRow, ByVal ColumnName As String) + Dim xmlValue As String + xmlValue = XmlHelper.GetItemValueByTagName(doc, XmlElement) + If xmlValue <> "" Then + DbRow(ColumnName) = xmlValue + Else + DbRow(ColumnName) = DBNull.Value + End If + End Sub + + Private Sub UpdateIntRow(ByVal XmlElement As String, ByRef DbRow As DataRow, ByVal ColumnName As String) + Dim xmlValue As String + xmlValue = XmlHelper.GetItemValueByTagName(doc, XmlElement) + If xmlValue <> "" Then + DbRow(ColumnName) = Convert.ToInt32(xmlValue) + Else + DbRow(ColumnName) = DBNull.Value + End If + End Sub + + Private Sub UpdateDateRow(ByVal XmlElement As String, ByRef DbRow As DataRow, ByVal ColumnName As String) + Dim xmlValue As String + xmlValue = XmlHelper.GetItemValueByTagName(doc, XmlElement) + If xmlValue <> "" Then + Dim d As Date = DateTime.ParseExact(xmlValue, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture) + DbRow(ColumnName) = d + Else + DbRow(ColumnName) = DBNull.Value + End If + End Sub + + Private Sub UpdatePartnerBoersenkotiert(ByRef DbRow As DataRow) + Const columnName = "boersenkotiert" + Const xmlElement = "is_boeko" + Dim xmlValue As String + xmlValue = XmlHelper.GetItemValueByTagName(doc, xmlElement) + If xmlValue.ToUpper() = "Y" Then + DbRow(columnName) = 1 + Else + DbRow(columnName) = 0 + End If + End Sub + + + + ''' + ''' Teil von Update_Partner() + ''' Aktualisiert alle berechtigte Email Adressen eines Parnters + ''' Die Daten (siehe Parameter) kommen alle aus der XML Message + ''' + ''' aus XML Message + Private Sub UpdatePartnerBerechtigteEmail(partnerNr As Integer) + ' Das Try/Catch Konstrukt braucht es nur für Debug Zwecke + Try + ' cn = ColumnName + Const cnId = "id" + Const cnPartnerNr = "partner_nr" + Const cnEmailAdresse = "email_adresse" + ' so = Size of + Const soEmailAdresse = 100 + Const tableName = "partner_berechtigte_email_adresse" + + ' select id, partner_nr, email_adresse from dbo.partner_berechtigte_email_adresse + Dim selectCmdText As String = String.Format("select {0}, {1}, {2} from dbo.{3}", cnId, cnPartnerNr, cnEmailAdresse, + tableName) + + ' select id, partner_nr, email_adresse from dbo.partner_berechtigte_email_adresse where partner_nr = @partner_nr + Dim selectByPartnerCmdText As String = String.Format("{0} where {1} = @{1}", selectCmdText, cnPartnerNr) + + ' select id, partner_nr, email_adresse from dbo.partner_berechtigte_email_adresse where id = scope_identity() + Dim selectByScopeIdentityCmdText As String = String.Format("{0} where {1} = scope_identity()", selectCmdText, cnId) + + ' insert into dbo.partner_berechtigte_email_adresse (partner_nr, email_adresse) values (@partner_nr, @email_adresse) + Dim insertCmdText As String = String.Format("insert into dbo.{0} ({1}, {2}) values (@{1}, @{2})", + tableName, cnPartnerNr, cnEmailAdresse, cnPartnerNr, cnEmailAdresse) + + ' insert into dbo.partner_berechtigte_email_adresse (partner_nr, email_adresse) values (@partner_nr, @email_adresse); + ' Select Case id, partner_nr, email_adresse from dbo.partner_berechtigte_email_adresse where id = scope_identity(); + Dim insertBatchText As String = String.Format("{0}; {1};", insertCmdText, selectByScopeIdentityCmdText) + + ' delete partner_berechtigte_email_adresse where id = @id + Dim deleteByIdCmdText As String = String.Format("delete {0} where {1} = @{1}", tableName, cnId) + + Dim connectionString As String = Globals.sConnectionString_edoka + + Const xmlElement = "berechtigteEmailAdressen" + Dim berechtigteEmailAdressen As String + berechtigteEmailAdressen = XmlHelper.GetItemValueByTagName(doc, xmlElement) + + Dim emailsFromXml As Dictionary(Of String, String) = New Dictionary(Of String, String) + Dim rowsToDeleteInDatabase As List(Of DataRow) = New List(Of DataRow) + Dim emails As [String]() = "".Split("") + + ' Emails aus berechtigteEmailAdressen in emailsFromXml speichern + If Not String.IsNullOrEmpty(berechtigteEmailAdressen) Then + emails = berechtigteEmailAdressen.Split(";") + End If + For Each email As String In emails + Dim trimmedEmail = email.Trim() + Dim emailKey = email.ToLower() + If trimmedEmail.Length > 0 Then + Dim dummy As String = "" + If Not emailsFromXml.TryGetValue(emailKey, dummy) Then + emailsFromXml(emailKey) = trimmedEmail + End If + End If + Next + + ' DB Adapter aufbauen (bis und mit Zeile 223) + Using connection As New SqlConnection(connectionString), + dtEmail As New DataTable, + daEmail As New SqlDataAdapter(selectByPartnerCmdText, connection), + insertCommand As New SqlCommand(insertBatchText, connection), + deleteCommand As New SqlCommand(deleteByIdCmdText, connection) + + daEmail.SelectCommand.Parameters.Add(New SqlParameter("@" + cnPartnerNr, partnerNr)) + daEmail.InsertCommand = insertCommand + daEmail.InsertCommand.Parameters.Add(New SqlParameter("@" + cnPartnerNr, SqlDbType.Int, 4, cnPartnerNr)) + daEmail.InsertCommand.Parameters.Add(New SqlParameter("@" + cnEmailAdresse, SqlDbType.NVarChar, soEmailAdresse, cnEmailAdresse)) + daEmail.DeleteCommand = deleteCommand + daEmail.DeleteCommand.Parameters.Add(New SqlParameter("@" + cnId, SqlDbType.Int, 4, cnId)) + + ' Mit DB Adapter Email Adressen des Partners aktualisieren + daEmail.MissingSchemaAction = MissingSchemaAction.AddWithKey + daEmail.Fill(dtEmail) + For Each row As DataRow In dtEmail.Rows + Dim dummy As String = "" + Dim emailFromDb As String = row(cnEmailAdresse) + Dim emailFromDbKey As String = emailFromDb.ToLower() + If emailsFromXml.TryGetValue(emailFromDbKey, dummy) Then + emailsFromXml.Remove(emailFromDbKey) + Else + rowsToDeleteInDatabase.Add(row) + End If + Next + For Each row As DataRow In rowsToDeleteInDatabase + row.Delete() + Next + For Each email As String In emailsFromXml.Values + Dim dataRow As DataRow = dtEmail.NewRow() + dataRow(cnEmailAdresse) = email + dataRow(cnPartnerNr) = partnerNr + + ' HINWEIS: Add eröffnet eine Transaction + dtEmail.Rows.Add(dataRow) + Next + + ' HINWEIS: Mit Update wird die Transaktion beendet + daEmail.Update(dtEmail) + End Using + + + Catch ex As Exception + Dim message As String = ex.Message + Throw ex + End Try + End Sub + + Private Function Update_Partner() As Boolean + Try + Dim dbRow As DataRow + partnernr = XmlHelper.GetItemValueByTagName(doc, "avqObjKey") + Dim dsPartner As New DataSet + Dim daPartner As New SqlDataAdapter("select * from partner where nrpar00 = " & partnernr.ToString, Globals.sConnectionString_edoka) + daPartner.SelectCommand.CommandTimeout = Params.SqlTimeout + + 'Saldierung: Status = 7 oder Ablaufdatum <=now + If hlp_Check_Saldierung(XmlHelper.GetItemValueByTagName(doc, "ablaufDatum"), XmlHelper.GetItemValueByTagName(doc, "status")) = True Then + Try + '------------------------------------------------------------------------------- + '- Saldierung + '------------------------------------------------------------------------------- + Dim scpartsald As New SqlCommand + Dim copartsald As New SqlConnection + scpartsald.CommandText = "dbo.sp_saldierter_partner" + scpartsald.CommandTimeout = Params.SqlTimeout + scpartsald.Parameters.Add(New SqlParameter("@nrpar00", SqlDbType.Int, 36, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, partnernr)) + scpartsald.CommandType = CommandType.StoredProcedure + copartsald.ConnectionString = Globals.sConnectionString_edoka + copartsald.Open() + scpartsald.Connection = copartsald + scpartsald.ExecuteNonQuery() + copartsald.Close() + scpartsald.Dispose() + copartsald.Dispose() + sAction = " Saldierung" + m_log.log("EDKB04: Partner : " & partnernr.ToString & sAction & " erfolgreich", Common.Common.JournalEntryType.Information) + Catch ex As Exception + m_log.log("EDKB04: Partner-Saldierung error (sp_saldierter_partner): PNR=" & partnernr.ToString & ", Msg:" & Err.Description, Common.Common.JournalEntryType.Error) + Return False + End Try + Return True + End If + + '------------------------------------------------------------------------------- + '- Partner insert / update + '------------------------------------------------------------------------------- + Dim neuer_partner As Boolean + + daPartner.Fill(dsPartner, "partner") + Dim dtPartner As DataTable = dsPartner.Tables(0) + + If dsPartner.Tables(0).Rows.Count < 1 Then + neuer_partner = True + sAction = " insert" + dbRow = dtPartner.NewRow() + Else + neuer_partner = False + sAction = " update" + dbRow = dsPartner.Tables(0).Rows(0) + End If + + If XmlHelper.GetItemValueByTagName(doc, "kundenSegment") = "WEBP" Then + dbRow("IDMSG00") = XmlHelper.GetItemValueByTagName(doc, "kundenSegment") + dbRow("bkpar00") = XmlHelper.GetItemValueByTagName(doc, "vorname") + " " + XmlHelper.GetItemValueByTagName(doc, "name") + End If + dbRow("nrpar00") = partnernr + dbRow("validto") = System.DBNull.Value + If XmlHelper.GetItemValueByTagName(doc, "ablaufDatum") <> "" Then + dbRow("validto") = hlp_Transformdate(XmlHelper.GetItemValueByTagName(doc, "ablaufDatum")) + End If + dbRow("saldiert") = hlp_Check_Saldierung(XmlHelper.GetItemValueByTagName(doc, "ablaufDatum"), XmlHelper.GetItemValueByTagName(doc, "status")) + dbRow("cdvsa00") = 0 + dbRow("azepl00") = 1 + dbRow("nrparad") = "00" & partnernr.ToString + dbRow("TXADZ012") = "" + dbRow("TXADZ022") = "" + dbRow("TXADZ032") = "" + dbRow("TXADZ042") = "" + dbRow("TXADZ052") = "" + dbRow("TXADZ062") = "" + dbRow("TXADZ072") = "" + dbRow("TXADZ011") = "" + dbRow("TXADZ021") = "" + dbRow("TXADZ031") = "" + dbRow("TXADZ041") = "" + dbRow("TXADZ051") = "" + dbRow("TXADZ061") = "" + dbRow("TXADZ071") = "" + dbRow("TSMUT00") = hlp_MutDatum("1") + dbRow("VDMUTER") = Params.CDMuter + If XmlHelper.GetItemValueByTagName(doc, "betreuerId") <> "" Then + dbRow("nrbeu01") = XmlHelper.GetItemValueByTagName(doc, "betreuerId") + Else + If Not IsNumeric(dbRow("nrbeu01")) Then + dbRow("nrbeu01") = Params.DefaultBetreuerID + End If + End If + + Dim kn As String = XmlHelper.GetItemValueByTagName(doc, "kurzName") + '20140921 - gem. DRO + 'Kurzname ist ggf. ein Alias und wird nicht berücksichtigt + kn = "" + Select Case Partner_Art + Case "NAT" + dbRow("cdpaw00") = "N" + dbRow("nrnat01") = hlp_TransformLand(XmlHelper.GetItemValueByTagName(doc, "nationalitaet")) + dbRow("nrdom00") = hlp_TransformLand(XmlHelper.GetItemValueByTagName(doc, "domizilCode")) + Dim s As String = hlp_Transformdate(XmlHelper.GetItemValueByTagName(doc, "geburtsDatum")) + If s <> "" Then dbRow("GebGruendDat") = s + If kn <> "" Then + dbRow("bkpar00") = kn + dbRow("Kurzname_Stamm") = XmlHelper.GetItemValueByTagName(doc, "name") + Else + dbRow("bkpar00") = XmlHelper.GetItemValueByTagName(doc, "vorname") + " " + XmlHelper.GetItemValueByTagName(doc, "name") + dbRow("kurzname_stamm") = dbRow("bkpar00") + End If + Case "JUR" + dbRow("cdpaw00") = "J" + dbRow("nrnat01") = hlp_TransformLand(XmlHelper.GetItemValueByTagName(doc, "domizilCode")) + If kn <> "" Then + dbRow("bkpar00") = kn + dbRow("Kurzname_Stamm") = XmlHelper.GetItemValueByTagName(doc, "name") + Else + dbRow("bkpar00") = XmlHelper.GetItemValueByTagName(doc, "vorname") + " " + XmlHelper.GetItemValueByTagName(doc, "name") + dbRow("kurzname_stamm") = dbRow("bkpar00") + End If + + Case Else + dbRow("cdpaw00") = "U" + dbRow("nrnat01") = hlp_TransformLand(XmlHelper.GetItemValueByTagName(doc, "domizilCode")) + If kn <> "" Then + dbRow("bkpar00") = kn + dbRow("Kurzname_Stamm") = XmlHelper.GetItemValueByTagName(doc, "name") + Else + dbRow("bkpar00") = XmlHelper.GetItemValueByTagName(doc, "vorname") + " " + XmlHelper.GetItemValueByTagName(doc, "name") + dbRow("kurzname_stamm") = dbRow("bkpar00") + End If + End Select + + UpdateStringRow("nameFormatiert", dbRow, "name_formated") + '20240916 + UpdateStringRow("steuerIdentAHV", dbRow, "steuerIdentAHV") + UpdateStringRow("zivilstand", dbRow, "zivilstand") + 'ende 20240916 + UpdateIntRow("sectorId", dbRow, "sector_id") + UpdateIntRow("rechtsFormId", dbRow, "legal_form_id") + UpdateIntRow("personRatingId", dbRow, "rate_intl_id") + UpdateDateRow("creditRatingDatum", dbRow, "rate_intl_date") + + 'Wird noch nicht gebraucht + 'Const nationalitaet_2ff = "nationalitaet_2ff" + 'UpdateStringRow(nationalitaet_2ff, dbRow, nationalitaet_2ff) + 'Const uid = "uid" + 'UpdateStringRow(uid, dbRow, uid) + + UpdatePartnerBoersenkotiert(dbRow) + UpdatePartnerBerechtigteEmail(partnernr) + + + + If neuer_partner Then + dtPartner.Rows.Add(dbRow) + End If + Dim cb As New SqlCommandBuilder(daPartner) + daPartner.Update(dsPartner, "partner") + kn = "" + + + kn = Update_BKPAR00(dbRow("Nrpar00")) + If kn <> "" Then + dbRow("BKPAR00") = Trim(dbRow("BKPAR00")) + ", " + kn + dbRow("kurzname_stamm") = dbRow("BKPAR00") + daPartner.Update(dsPartner, "partner") + End If + + daPartner.Dispose() + dsPartner.Clear() + + Update_Adressbeziehungen() + Update_PersonBeziehung() + + 'MsgBox(partnernr) + m_log.log("EDKB04: Partner : " & partnernr.ToString & sAction & " erfolgreich", Common.Common.JournalEntryType.Information) + Return True + Catch ex As Exception + m_log.log("EDKB04: DBHandling.Partner, Tabelle partner: " & partnernr.ToString & ex.Message, Common.Common.JournalEntryType.Error) + Return False + End Try + End Function + + Private Function Update_BKPAR00(ByVal pnr As Integer) As String + Dim dsAddr As New DataSet + Dim tempkn As String = "" + Try + Dim sql As String = "SELECT dbo.PartnerAdresse.Partnernr, dbo.Partner_Adresse.ORT FROM dbo.Partner_Adresse INNER JOIN " + sql = sql + "dbo.PartnerAdresse ON dbo.Partner_Adresse.ADDR_OBJ_ID = dbo.PartnerAdresse.ADDR_OBJ_ID " + sql = sql + "WHERE (dbo.PartnerAdresse.Partnernr = " + pnr.ToString + ")" + sql = sql + " and (dbo.PartnerAdresse.aktiv = 1) order by adresstype" + Dim daAddr As New SqlDataAdapter(sql, Globals.sConnectionString_edoka) + daAddr.SelectCommand.CommandTimeout = Params.SqlTimeout + daAddr.Fill(dsAddr, "Adressen") + If dsAddr.Tables(0).Rows.Count > 0 Then + tempkn = dsAddr.Tables(0).Rows(0).Item("Ort").ToString + End If + Return tempkn + Catch + Return "" + Finally + dsAddr.Dispose() + + End Try + + End Function + + Private Function Update_Angestelltenart(ByVal aart As String) As Boolean + Dim dsaart As New DataSet + Dim daaart As New SqlDataAdapter("select * from edoka_etmia0_data where nrpar00=" + partnernr.ToString, Globals.sConnectionString_edoka) + Try + daaart.SelectCommand.CommandTimeout = Params.SqlTimeout + daaart.Fill(dsaart, "Mitarbeiter") + If aart = "" And dsaart.Tables(0).Rows.Count > 0 Then + For Each dbrow As DataRow In dsaart.Tables(0).Rows + If dbrow("sarec00") = 2 Then + dbrow("sarec00") = 7 + dbrow("tsmut00") = Now() + End If + Next + sAction = " Update " + Else + If dsaart.Tables(0).Rows.Count > 0 Then + dsaart.Tables(0).Rows(0).Item("sarec00") = 2 + dsaart.Tables(0).Rows(0).Item("tsmut00") = Now + sAction = " Update " + + Else + If aart <> "" Then + Dim dbRow As DataRow + dbRow = dsaart.Tables(0).NewRow + dbRow("NRPAR00") = partnernr + dbRow("NRVRN00") = 9999 + dbRow("CDIDF00") = "EDKB04" + dbRow("NRSPA00") = 1 + dbRow("BKMIA00") = "EDKB04" + dbRow("NRBTI00") = 0 + dbRow("NRTEL00") = "" + dbRow("NRTFX00") = "" + dbRow("SABEU00") = "N" + dbRow("BEEML00") = "" + dbRow("CDMUTER") = 1 + dbRow("TSMUT00") = Now + dbRow("DMERF00") = Now + dbRow("SAREC00") = "2" + dsaart.Tables(0).Rows.Add(dbRow) + sAction = " Insert " + End If + End If + End If + Dim cb As New SqlCommandBuilder(daaart) + daaart.Update(dsaart, "Mitarbeiter") + m_log.log("EDKB04: Mitarbeiter : " & partnernr.ToString & sAction & " erfolgreich", Common.Common.JournalEntryType.Information) + Return True + Catch ex As Exception + m_log.log("EDKB04: DBHandling.Mitarbeiter, Tabelle etmia0_data: " & partnernr.ToString & ex.Message, Common.Common.JournalEntryType.Error) + Return False + Finally + dsaart.Dispose() + daaart.Dispose() + End Try + End Function + + + Private Function Update_VIP(ByVal VIPCode As String) As Boolean + Dim dsaart As New DataSet + Dim daaart As New SqlDataAdapter("select * from edoka_ETVIP0_data where nrpar00=" + partnernr.ToString, Globals.sConnectionString_edoka) + Try + daaart.SelectCommand.CommandTimeout = Params.SqlTimeout + daaart.Fill(dsaart, "VIP") + If VIPCode = "N" And dsaart.Tables(0).Rows.Count > 0 Then + For Each dbrow As DataRow In dsaart.Tables(0).Rows + If dbrow("sarec00") = 2 Then + dbrow("sarec00") = 7 + dbrow("tsmut00") = Now() + End If + Next + sAction = " update " + Else + If dsaart.Tables(0).Rows.Count > 0 Then + dsaart.Tables(0).Rows(0).Item("sarec00") = 2 + dsaart.Tables(0).Rows(0).Item("tsmut00") = Now + sAction = " update " + Else + If VIPCode <> "N" Then + Dim dbRow As DataRow + dbRow = dsaart.Tables(0).NewRow + dbRow("NRPAR00") = partnernr + dbRow("NRVRN00") = 9999 + dbRow("NRVIP00") = 1 + dbRow("DSMUT00") = Now + dbRow("SAREC00") = "2" + dsaart.Tables(0).Rows.Add(dbRow) + sAction = " Insert " + End If + End If + End If + Dim cb As New SqlCommandBuilder(daaart) + daaart.Update(dsaart, "VIP") + m_log.log("EDKB04: VIP : " & partnernr.ToString & sAction & " erfolgreich", Common.Common.JournalEntryType.Information) + Return True + Catch ex As Exception + m_log.log("EDKB04: DBHandling.Mitarbeiter, Tabelle etvip0_data: " & partnernr.ToString & ex.Message, Common.Common.JournalEntryType.Error) + Return False + Finally + dsaart.Dispose() + daaart.Dispose() + End Try + End Function + + +#End Region + + +#Region "Adressbeziehungen" + Function Update_Adressbeziehungen() + Dim Domiziladresse_fuer_Kurznamenupdate As Integer = 0 + Dim ts As DateTime = Now + Dim found As Boolean = False + Dim dsAddr As New DataSet + Dim daAddr As New SqlDataAdapter("select * from partneradresse where aktiv=1 and partnernr=" + partnernr.ToString, Globals.sConnectionString_edoka) + daAddr.SelectCommand.CommandTimeout = Params.SqlTimeout + daAddr.Fill(dsAddr, "Adressen") + For Each r As DataRow In AddrBeziehung.Rows + For Each r1 As DataRow In dsAddr.Tables(0).Rows + found = False + If r1("ADDR_Obj_ID") = r("avqObjId") Then + If r1("Adresstype") = 1 And r("Typ") = "D" Then + Domiziladresse_fuer_Kurznamenupdate = r1("Addr_obj_id") + r1("mutiert_am") = ts + found = True + Exit For + End If + If r1("Adresstype") = 2 And r("Typ") = "H" Then + r1("mutiert_am") = ts + found = True + Exit For + End If + If r1("Adresstype") = 9 And r("Typ") = "A" Then + r1("mutiert_am") = ts + found = True + Exit For + End If + End If + + Next + '-- Neue Adressbeziehung einfügen + If found = False Then + Dim rn As DataRow = dsAddr.Tables(0).NewRow + rn("Partnernr") = partnernr + 'rn("Adressnr") = "" + rn("Addr_obj_id") = r("avqobjid") + Select Case r("Typ") + Case "D" + rn("Adresstype") = 1 + Domiziladresse_fuer_Kurznamenupdate = rn("Addr_obj_id") + Case "H" + rn("Adresstype") = 2 + Case Else + rn("Adresstype") = 9 + End Select + rn("erstellt_am") = ts + rn("mutiert_am") = ts + rn("aktiv") = 1 + rn("mutierer") = 1 + dsAddr.Tables(0).Rows.Add(rn) + End If + + Next + For Each r As DataRow In dsAddr.Tables(0).Rows + If r("mutiert_am") <> ts Then + r("aktiv") = 0 + r("mutiert_am") = ts + r("mutierer") = 1 + End If + + Next + Dim cb As New SqlCommandBuilder(daAddr) + daAddr.Update(dsAddr, "Adressen") + daAddr.Dispose() + dsAddr.Dispose() + If Domiziladresse_fuer_Kurznamenupdate <> 0 Then Update_Kurzname(Domiziladresse_fuer_Kurznamenupdate) + End Function + + + +#End Region + +#Region "E-Mail" + Function Update_Email() + Dim AddrObjID As Integer + Try + Dim sql As String + Dim neue_Adrese As Boolean + Dim dbrow As DataRow + AddrObjID = XmlHelper.GetItemValueByTagName(doc, "AvqObjId") + sql = "SELECT * FROM Partneremail_data where Addr_Obj_ID = " + AddrObjID.ToString + Dim dsAddr As New DataSet + Dim daAddr As New SqlDataAdapter(sql, Globals.sConnectionString_edoka) + daAddr.SelectCommand.CommandTimeout = Params.SqlTimeout + daAddr.Fill(dsAddr, "Addr") + + + If dsAddr.Tables(0).Rows.Count < 1 Then + neue_Adrese = True + sAction = " insert" + dbrow = dsAddr.Tables(0).NewRow() + dbrow("Addr_obj_id") = AddrObjID + Else + neue_Adrese = False + sAction = " update" + dbrow = dsAddr.Tables(0).Rows(0) + End If + dbrow("email") = XmlHelper.GetItemValueByTagName(doc, "zeile1") + dbrow("erstellt_am") = Now + dbrow("erstellt_von") = 1 + dbrow("mutiert_am") = Now + dbrow("mutiert_von") = 1 + dbrow("aktiv") = 1 + 'dbrow("aktiv") = 1 + dbrow("ablaufdatum") = "" + If XmlHelper.GetItemValueByTagName(doc, "ablaufDatumAdresse") <> "" Then + Dim s As String = XmlHelper.GetItemValueByTagName(doc, "ablaufDatumAdresse") + dbrow("ablaufdatum") = hlp_Convert_Date(s, 1) + 'If dbrow("ablaufdatum") < Now Then dbrow("aktiv") = 0 + End If + If neue_Adrese Then + dsAddr.Tables(0).Rows.Add(dbrow) + End If + Dim cb As New SqlCommandBuilder(daAddr) + daAddr.Update(dsAddr, "Addr") + daAddr.Dispose() + dsAddr.Clear() + 'Update_Kurzname(AddrObjID) + m_log.log("EDKB04: E-Mail Adresse Addr_Obj_IDr: " & AddrObjID.ToString & sAction & " erfolgreich", Common.Common.JournalEntryType.Information) + Return True + Catch ex As Exception + m_log.log("EDKB04: E-Mail DBHandling.Adresse" + AddrObjID.ToString + " : " & ex.Message, Common.Common.JournalEntryType.Error) + Return False + End Try + + End Function +#End Region + +#Region "Personbeziehungen" + Function Update_PersonBeziehung() + Dim sql As String + If Partner_Typ = "BP" Then + sql = "Select * from partner_rel where aktiv=1 and bp_nr=" + partnernr.ToString + Else + sql = "Select * from partner_rel where aktiv=1 and person_nummer=" + partnernr.ToString + End If + + Dim ts As DateTime = Now + Dim found As Boolean = False + Dim dsPBez As New DataSet + Dim daPBez As New SqlDataAdapter(sql, Globals.sConnectionString_edoka) + daPBez.SelectCommand.CommandTimeout = Params.SqlTimeout + daPBez.Fill(dsPBez, "Beziehung") + + If Partner_Typ = "BP" Then + For Each r As DataRow In PersonBeziehung.Rows + For Each r1 As DataRow In dsPBez.Tables(0).Rows + found = False + If r1("Person_Nummer").ToString = r("key_to").ToString Then + If r("reltyp") = "reg_owner" And r1("BP_Person_Rel_Typ") = 2 Then + r1("mutiert_am") = ts + found = True + Exit For + End If + + If r("reltyp") = "acc_owner_lim" And r1("BP_Person_Rel_Typ") = 6 Then + r1("mutiert_am") = ts + found = True + Exit For + End If + End If + Next + If Not found And (r("reltyp") = "reg_owner" Or r("reltyp") = "acc_owner_lim") Then + Dim rn As DataRow = dsPBez.Tables(0).NewRow + rn("Person_Nummer") = r("key_to") + rn("Person_Obj_ID") = 0 + If r("reltyp") = "reg_owner" Then rn("BP_Person_Rel_Typ") = 6 + If r("reltyp") = "acc_owner_lim" Then rn("BP_Person_Rel_Typ") = 2 + If r("reltyp") = "acc_owner" Then rn("BP_Person_Rel_Typ") = 1 + rn("bp_nr") = partnernr + rn("erstellt_am") = ts + rn("mutiert_am") = ts + rn("Mutierer") = 1 + rn("Gueltig_bis") = hlp_Convert_Date(r("end_date"), 1) + If rn("gueltig_bis") < Now Then rn("Aktiv") = 0 Else rn("aktiv") = 1 + dsPBez.Tables(0).Rows.Add(rn) + End If + Next + For Each r As DataRow In dsPBez.Tables(0).Rows + If r("mutiert_am") <> ts Then + r("aktiv") = 0 + r("mutiert_am") = ts + r("mutierer") = 1 + End If + Next + Dim cb As New SqlCommandBuilder(daPBez) + daPBez.Update(dsPBez, "Beziehung") + daPBez.Dispose() + daPBez.Dispose() + Else + For Each r As DataRow In PersonBeziehung.Rows + For Each r1 As DataRow In dsPBez.Tables(0).Rows + found = False + If r1("BP_Nr").ToString = r("key_to").ToString Then + If r("reltyp") = "reg_owner" And r1("BP_Person_Rel_Typ") = 2 Then + r1("mutiert_am") = ts + found = True + Exit For + End If + + If r("reltyp") = "acc_owner_lim" And r1("BP_Person_Rel_Typ") = 6 Then + found = True + r1("mutiert_am") = ts + Exit For + End If + End If + Next + If Not found And (r("reltyp") = "reg_owner" Or r("reltyp") = "acc_owner_lim") Then + Dim rn As DataRow = dsPBez.Tables(0).NewRow + rn("Person_Nummer") = partnernr + rn("Person_Obj_ID") = 0 + If r("reltyp") = "reg_owner" Then rn("BP_Person_Rel_Typ") = 6 + If r("reltyp") = "acc_owner_lim" Then rn("BP_Person_Rel_Typ") = 2 + If r("reltyp") = "acc_owner" Then rn("BP_Person_Rel_Typ") = 1 + rn("bp_nr") = r("key_to") + rn("erstellt_am") = ts + rn("mutiert_am") = ts + rn("Mutierer") = 1 + rn("Gueltig_bis") = hlp_Convert_Date(r("end_date"), 1) + If rn("gueltig_bis") < Now Then rn("Aktiv") = 0 Else rn("aktiv") = 1 + dsPBez.Tables(0).Rows.Add(rn) + End If + Next + For Each r As DataRow In dsPBez.Tables(0).Rows + If r("mutiert_am") <> ts Then + r("aktiv") = 0 + r("mutiert_am") = ts + r("mutierer") = 1 + End If + Next + Dim cb As New SqlCommandBuilder(daPBez) + daPBez.Update(dsPBez, "Beziehung") + daPBez.Dispose() + daPBez.Dispose() + End If + + End Function + + + +#End Region + + +#End Region + +#Region "Adresse" + Public Function update_Adresse() + Dim AddrObjID As Integer + Try + Dim sql As String + Dim neue_Adrese As Boolean + Dim dbrow As DataRow + AddrObjID = XmlHelper.GetItemValueByTagName(doc, "AvqObjId") + sql = "SELECT * FROM Partner_Adresse where Addr_Obj_ID = " + AddrObjID.ToString + Dim dsAddr As New DataSet + Dim daAddr As New SqlDataAdapter(sql, Globals.sConnectionString_edoka) + daAddr.SelectCommand.CommandTimeout = Params.SqlTimeout + daAddr.Fill(dsAddr, "Addr") + + + If dsAddr.Tables(0).Rows.Count < 1 Then + neue_Adrese = True + sAction = " insert" + dbrow = dsAddr.Tables(0).NewRow() + dbrow("Addr_obj_id") = AddrObjID + Else + neue_Adrese = False + sAction = " update" + dbrow = dsAddr.Tables(0).Rows(0) + End If + dbrow("Zeile1") = XmlHelper.GetItemValueByTagName(doc, "zeile1") + dbrow("Zeile2") = XmlHelper.GetItemValueByTagName(doc, "zeile2") + dbrow("Zeile3") = XmlHelper.GetItemValueByTagName(doc, "zeile3") + dbrow("Zeile4") = XmlHelper.GetItemValueByTagName(doc, "zeile4") + dbrow("Zeile5") = XmlHelper.GetItemValueByTagName(doc, "zeile5") + dbrow("Zeile6") = XmlHelper.GetItemValueByTagName(doc, "zeile6") + dbrow("Zeile7") = XmlHelper.GetItemValueByTagName(doc, "zeile7") + dbrow("Titel_Vorgestellt") = XmlHelper.GetItemValueByTagName(doc, "titelVorgestellt") + dbrow("Vorname_1") = XmlHelper.GetItemValueByTagName(doc, "vorname1") + dbrow("Vorname_2") = XmlHelper.GetItemValueByTagName(doc, "vorname2") + dbrow("Vorname_3") = XmlHelper.GetItemValueByTagName(doc, "vorname3") + dbrow("Vorname_4") = XmlHelper.GetItemValueByTagName(doc, "vorname4") + dbrow("Nachname") = XmlHelper.GetItemValueByTagName(doc, "nachname") + dbrow("Firma") = XmlHelper.GetItemValueByTagName(doc, "firma") + dbrow("namenzusatz") = XmlHelper.GetItemValueByTagName(doc, "namenZusatz") + dbrow("ortzusatz") = XmlHelper.GetItemValueByTagName(doc, "ortZusatz") + + Const co = "co" + UpdateStringRow(co, dbrow, co) + + dbrow("Weiler") = XmlHelper.GetItemValueByTagName(doc, "weiler") + dbrow("strasse") = XmlHelper.GetItemValueByTagName(doc, "strasse") + dbrow("hausnr") = XmlHelper.GetItemValueByTagName(doc, "hausNr") + dbrow("briefanrede1code") = "" + dbrow("briefanrede1") = XmlHelper.GetItemValueByTagName(doc, "briefanrede1") + dbrow("briefanrede2zeile1") = XmlHelper.GetItemValueByTagName(doc, "briefanrede2Zeile1") + dbrow("briefanrede2zeile2") = XmlHelper.GetItemValueByTagName(doc, "briefanrede2Zeile2") + dbrow("plz") = XmlHelper.GetItemValueByTagName(doc, "plz") + dbrow("Ort") = XmlHelper.GetItemValueByTagName(doc, "ort") + dbrow("Land") = hlp_TransformLand(XmlHelper.GetItemValueByTagName(doc, "land")) + dbrow("Laendercode") = hlp_TransformLand(XmlHelper.GetItemValueByTagName(doc, "laenderCode")) + dbrow("banklagernd") = XmlHelper.GetItemValueByTagName(doc, "banklagernd") + dbrow("versandart") = XmlHelper.GetItemValueByTagName(doc, "versandart") + dbrow("beban01") = hlp_transform_Briefanrede(XmlHelper.GetItemValueByTagName(doc, "briefanrede2Zeile1")) + dbrow("beban02") = XmlHelper.GetItemValueByTagName(doc, "briefanrede2Zeile2") + 'dbrow("aktiv") = 1 + dbrow("ablaufdatum") = "" + If XmlHelper.GetItemValueByTagName(doc, "ablaufDatumAdresse") <> "" Then + Dim s As String = XmlHelper.GetItemValueByTagName(doc, "ablaufDatumAdresse") + dbrow("ablaufdatum") = hlp_Convert_Date(s, 1) + 'If dbrow("ablaufdatum") < Now Then dbrow("aktiv") = 0 + End If + If neue_Adrese Then + dsAddr.Tables(0).Rows.Add(dbrow) + End If + Dim cb As New SqlCommandBuilder(daAddr) + daAddr.Update(dsAddr, "Addr") + daAddr.Dispose() + dsAddr.Clear() + Update_Kurzname(AddrObjID) + m_log.log("EDKB04: Adresse Addr_Obj_IDr: " & AddrObjID.ToString & sAction & " erfolgreich", Common.Common.JournalEntryType.Information) + Return True + Catch ex As Exception + m_log.log("EDKB04: DBHandling.Adresse" + AddrObjID.ToString + " : " & ex.Message, Common.Common.JournalEntryType.Error) + Return False + End Try + End Function + + Private Sub Update_Kurzname(ByVal addrobjid As Integer) + + Dim scmCmdToExecute As SqlCommand = New SqlCommand() + Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute) + + scmCmdToExecute.CommandText = "dbo.sp_edkb04_update_kurzname" + scmCmdToExecute.CommandType = CommandType.StoredProcedure + scmCmdToExecute.Connection = conn_edoka.scoDBConnection + scmCmdToExecute.Parameters.Add(New SqlParameter("@addrobjid", SqlDbType.VarChar, 16, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, addrobjid)) + + Try + conn_edoka.OpenConnection() + scmCmdToExecute.ExecuteNonQuery() + Catch exi As Exception + m_log.log("EDKB04: Update Kurzname " & exi.Message & " - Addrobjid: " & addrobjid.ToString, Common.Common.JournalEntryType.Error) + Finally + conn_edoka.CloseConnection(True) + scmCmdToExecute.Dispose() + sdaAdapter.Dispose() + End Try + End Sub + +#End Region + +#Region "VV" + Public Function update_vv() + Try + Dim sql As String + Dim vv As String + Dim neue_vv As Boolean + Dim nrvvg00 As Integer + Dim dbrow As DataRow + Dim s As String + + If XmlHelper.GetItemValueByTagName(doc, "externeNr") <> "" Then + sql = "SELECT * FROM vv WHERE NEVVG00 = '" + hlp_vv_format("NEVVG00", XmlHelper.GetItemValueByTagName(doc, "externeNr")) + "'" + Else + sql = "SELECT * FROM vv WHERE NAVVG00 = '" + XmlHelper.GetItemValueByTagName(doc, "formatierteNr") + "'" + End If + Dim dsVV As New DataSet + Dim daVV As New SqlDataAdapter(sql, Globals.sConnectionString_edoka) + daVV.SelectCommand.CommandTimeout = Params.SqlTimeout + daVV.Fill(dsVV, "VV") + + If dsVV.Tables(0).Rows.Count < 1 Then + neue_vv = True + sAction = " insert" + dbrow = dsVV.Tables(0).NewRow() + dbrow("nrvvg00") = hlp_GetNewKey_vv() + Else + neue_vv = False + sAction = " update" + dbrow = dsVV.Tables(0).Rows(0) + End If + + dbrow("validto") = System.DBNull.Value + If XmlHelper.GetItemValueByTagName(doc, "ablaufDatum") <> "" Then + dbrow("validto") = hlp_Convert_Date(XmlHelper.GetItemValueByTagName(doc, "ablaufDatum"), 1) + End If + + dbrow("NAVVG00") = hlp_vv_format("NAVVG00", XmlHelper.GetItemValueByTagName(doc, "formatierteNr")) + 'dbrow("NAVVG00") = XmlHelper.GetItemValueByTagName(doc, "formatierteNr") + vv = dbrow("NAVVG00") + + If XmlHelper.GetItemValueByTagName(doc, "externeNr") = "" Then + s = hlp_TransformVVExtern(dbrow("NAVVG00")) + dbrow("NEVVG00") = hlp_vv_format("NEVVG00", s) + Else + dbrow("NEVVG00") = hlp_vv_format("NEVVG00", XmlHelper.GetItemValueByTagName(doc, "externeNr")) + End If + 'dbrow("NEVVG00") = XmlHelper.GetItemValueByTagName(doc, "externeNr") + 'If dbrow("NEVVG00") = "" Then dbrow("NEVVG00") = hlp_TransformVVExtern(dbrow("NAVVG00")) + 'dbrow("NAVVG00") = XmlHelper.GetItemValueByTagName(doc, "formatierteNr") + + If IsNumeric(XmlHelper.GetItemValueByTagName(doc, "produkt")) Then + dbrow("NRPRD00") = XmlHelper.GetItemValueByTagName(doc, "produkt") + Else + dbrow("NRPRD00") = 0 + End If + + dbrow("BEPRDLG") = XmlHelper.GetItemValueByTagName(doc, "kontoBezeichnung") + + dbrow("SAREC00") = XmlHelper.GetItemValueByTagName(doc, "status") + If XmlHelper.GetItemValueByTagName(doc, "ablaufDatum") <> "" Then + If dbrow("validto") < Now Then + dbrow("SAREC00") = 7 + End If + End If + dbrow("TXRBK00") = hlp_vv_format("TXRBK00", XmlHelper.GetItemValueByTagName(doc, "rubrik")) 'von "text" auf "rubrik" abgeändert + dbrow("NRPAR00") = XmlHelper.GetItemValueByTagName(doc, "partnerNummer") + If neue_vv Then + dsVV.Tables(0).Rows.Add(dbrow) + End If + nrvvg00 = dbrow("nrvvg00") + Dim cb As New SqlCommandBuilder(daVV) + daVV.Update(dsVV, "VV") + daVV.Dispose() + dsVV.Clear() + Update_VVAdressbeziehungen(nrvvg00) + m_log.Log("EDKB04: VV : " & vv.ToString & sAction & " erfolgreich", Common.Common.JournalEntryType.Information) + Return True + Catch ex As Exception + m_log.Log("EDKB04: DBHandling.VV, Tabelle VV: " & ex.Message, Common.Common.JournalEntryType.Error) + Return False + End Try + End Function + + Function hlp_vv_format(ByVal typ As String, ByVal istring As String) As String + Dim s As String + s = istring + Select Case typ + Case "NAVVG00" + If Len(s) > 16 Then s = Left(s, 16) + Case "NEVVG00" + If Len(s) > 16 Then s = Left(s, 16) + If Not (InStr(s, "EBANK.", CompareMethod.Text)) Then + Do While Len(s) < 12 + s = "0" & s + Loop + End If + Case "BEPRDLG" + If Len(s) > 35 Then s = Left(s, 35) + Case "TXRBK00" + If Len(s) > 255 Then s = Left(s, 255) + End Select + Return s + End Function + + +#Region "Adressbeziehungen" + Function Update_VVAdressbeziehungen(ByVal nrvvg00 As Integer) + Dim ts As DateTime = Now + Dim found As Boolean = False + Dim dsAddr As New DataSet + Dim daAddr As New SqlDataAdapter("select * from vvadresse where aktiv=1 and nrvvg00=" + nrvvg00.ToString, Globals.sConnectionString_edoka) + daAddr.SelectCommand.CommandTimeout = Params.SqlTimeout + daAddr.Fill(dsAddr, "Adressen") + For Each r As DataRow In AddrBeziehung.Rows + For Each r1 As DataRow In dsAddr.Tables(0).Rows + found = False + If r1("ADDR_Obj_ID") = r("avqObjId") Then + If r1("Adresstype") = 4 And r("Typ") = "A" Then + r1("mutiert_am") = ts + found = True + Exit For + End If + If r1("Adresstype") = 2 And r("Typ") = "H" Then + r1("mutiert_am") = ts + found = True + Exit For + End If + If r1("Adresstype") = 1 And r("Typ") = "D" Then + r1("mutiert_am") = ts + found = True + Exit For + End If + End If + + Next + '-- Neue Adressbeziehung einfügen + If found = False Then + Dim rn As DataRow = dsAddr.Tables(0).NewRow + rn("nrvvg00") = nrvvg00 + 'rn("Adressnr") = "" + rn("Addr_obj_id") = r("avqobjid") + Select Case r("Typ") + Case "D" + rn("Adresstype") = 1 + Case "H" + rn("Adresstype") = 2 + Case Else + rn("Adresstype") = 4 + + End Select + rn("erstellt_am") = ts + rn("mutiert_am") = ts + rn("aktiv") = 1 + rn("mutierer") = 1 + dsAddr.Tables(0).Rows.Add(rn) + End If + + Next + For Each r As DataRow In dsAddr.Tables(0).Rows + If r("mutiert_am") <> ts Then + r("aktiv") = 0 + r("mutiert_am") = ts + r("mutierer") = 1 + End If + + Next + Dim cb As New SqlCommandBuilder(daAddr) + daAddr.Update(dsAddr, "Adressen") + daAddr.Dispose() + dsAddr.Dispose() + End Function + + + +#End Region + + +#End Region + +#Region "Verfuegungsrechte" + ''' + ''' + ''' + ''' True: Alles OK, False: nicht alles OK + Public Function Update_Verfuegungsrechte() As Boolean + Dim ret As Boolean = True 'bei einer Exception wird ret einfach auf False gesetzt + Try + Dim ts As DateTime = Now + Dim found As Boolean = False + Dim dtToReturn As DataTable = New DataTable() + + + Try + Dim scmCmdToExecute As SqlCommand = New SqlCommand() + + Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute) + scmCmdToExecute.CommandText = "dbo.sp_get_verfuegungsrechte_pro_partner" + scmCmdToExecute.CommandType = CommandType.StoredProcedure + scmCmdToExecute.Connection = conn_edoka.scoDBConnection + + scmCmdToExecute.Parameters.Add(New SqlParameter("@nrpar00", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, pnr)) + sdaAdapter.Fill(dtToReturn) + Catch + ret = False + End Try + + If ret Then + For Each r As DataRow In vvr.Rows + For Each rr As DataRow In dtToReturn.Rows + found = False + If r.Item("avq_auth_extl_ref") = rr.Item("avq_auth_extl_ref") Then + found = True + Dim scmCmdToExecute As SqlCommand = New SqlCommand() + scmCmdToExecute.CommandText = "dbo.sp_update_verfuegungsrecht" + scmCmdToExecute.CommandType = CommandType.StoredProcedure + scmCmdToExecute.Connection = conn_edoka.scoDBConnection + conn_edoka.OpenConnection() + Try + scmCmdToExecute.Parameters.Add(New SqlParameter("@avq_auth_extl_ref", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, rr.Item("avq_auth_extl_ref"))) + scmCmdToExecute.Parameters.Add(New SqlParameter("@Gueltigbis", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, r.Item("end_date"))) + scmCmdToExecute.Parameters.Add(New SqlParameter("@fnkt", SqlDbType.Int, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, 0)) + scmCmdToExecute.ExecuteNonQuery() + m_log.log("EDKB04: DBHandling.Verfuegungsrecht aktualisiert" + rr.Item(1).ToString + " erfolgreich ", Common.Common.JournalEntryType.Information) + Catch ex As Exception + ret = False + m_log.log("EDKB04: DBHandling.Verfuegungsrecht aktualisiert" + rr.Item(1).ToString + " nicht erfolgreich : " + ex.Message, Common.Common.JournalEntryType.Error) + Finally + scmCmdToExecute.Dispose() + conn_edoka.CloseConnection(True) + End Try + Exit For + + End If + Next + If Not found Then + Dim scmCmdToExecute As SqlCommand = New SqlCommand() + scmCmdToExecute.CommandText = "dbo.sp_update_verfuegungsrecht" + scmCmdToExecute.CommandType = CommandType.StoredProcedure + scmCmdToExecute.Connection = conn_edoka.scoDBConnection + conn_edoka.OpenConnection() + Try + scmCmdToExecute.Parameters.Add(New SqlParameter("@avq_auth_extl_ref", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, r.Item("avq_auth_extl_ref"))) + scmCmdToExecute.Parameters.Add(New SqlParameter("@Gueltigbis", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Now.ToShortDateString)) + scmCmdToExecute.Parameters.Add(New SqlParameter("@fnkt", SqlDbType.Int, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, 1)) + scmCmdToExecute.ExecuteNonQuery() + m_log.log("EDKB04: DBHandling.Verfuegungsrecht Delete" + r.Item(1).ToString + " erfolgreich ", Common.Common.JournalEntryType.Information) + Catch ex As Exception + ret = False + m_log.log("EDKB04: DBHandling.Verfuegungsrecht Delete" + r.Item(1).ToString + " nicht erfolgreich : " + ex.Message, Common.Common.JournalEntryType.Error) + Finally + scmCmdToExecute.Dispose() + conn_edoka.CloseConnection(True) + End Try + End If + Next + End If + Catch ex As Exception + ret = False + End Try + Return ret + End Function + + Public Function Update_Dokumentreferenz(Docid As String, Ref1 As String, Ref2 As String) + Try + Dim scmCmdToExecute As SqlCommand = New SqlCommand() + scmCmdToExecute.CommandText = "dbo.sp_update_verfuegungsrecht_dokumentid" + scmCmdToExecute.CommandType = CommandType.StoredProcedure + scmCmdToExecute.Connection = conn_edoka.scoDBConnection + conn_edoka.OpenConnection() + Try + scmCmdToExecute.Parameters.Add(New SqlParameter("@Dokumentid", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Docid)) + scmCmdToExecute.Parameters.Add(New SqlParameter("@avq_auth_extl_ref", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Ref1)) + scmCmdToExecute.Parameters.Add(New SqlParameter("@avq_auth_extl_ref1", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Ref2)) + scmCmdToExecute.ExecuteNonQuery() + m_log.log("EDKB04: DBHandling.Verfuegungsrecht Update EDOKA-Dokument" + Docid + " " + Ref1 + " " + Ref2 + " erfolgreich ", Common.Common.JournalEntryType.Information) + Catch ex As Exception + m_log.log("EDKB04: DBHandling.Verfuegungsrecht Update EDOKA-Dokument" + Docid + " " + Ref1 + " " + Ref2 + " nicht erfolgreich : " + ex.Message, Common.Common.JournalEntryType.Error) + Finally + scmCmdToExecute.Dispose() + conn_edoka.CloseConnection(True) + End Try + + Catch ex As Exception + + End Try + End Function + + +#End Region + +#Region "Helper" + + Private Function hlp_GetNewKey_vv() As Integer + hlp_GetNewKey_vv = 0 + Dim ssql As String + ssql = "SELECT TOP 1 NRVVG00 + 1 AS NewRow FROM vv Order By NRVVG00 DESC" + + Dim connection As New SqlConnection() + Dim daTemp As New SqlDataAdapter(ssql, connection) + Dim dsTemp As New DataSet() + Try + connection.ConnectionString = Globals.sConnectionString_edoka + connection.Open() + daTemp.Fill(dsTemp) + hlp_GetNewKey_vv = dsTemp.Tables(0).Rows(0).Item(0) + + Catch ex As Exception + Return False + Finally + dsTemp = Nothing + daTemp = Nothing + connection.Close() + connection = Nothing + End Try + End Function + + Function hlp_Convert_Date(ByVal iDatum As String, fnkt As Integer) As String + Try + If iDatum = "" Then Return "2712-12-31" + Select Case fnkt + Case 1 + Return iDatum.Substring(0, 4) + "-" + iDatum.Substring(4, 2) + "-" + iDatum.Substring(6, 2) + End Select + Catch ex As Exception + Return "" + End Try + End Function + + Private Function hlp_Check_Saldierung(ByVal instr As String, ByVal Status As String) As Boolean + 'Kein Validto-Datum und Status=7 Saldierung durchfüren + If Len(instr) = 0 Then + If Status = "7" Then Return True + End If + 'Validto Datum vorhandên und kleiner oder gleich heute, dann Saldierung druchführen + If Len(instr) <> 0 Then + Dim d As String = hlp_Transformdate(instr) + If IsDate(d) And CDate(d) <= Now And Status = "7" Then Return True + If IsDate(d) And CDate(d) > Now And Status = "7" Then Return False + End If + Return False + End Function + + Private Function hlp_MutDatum(ByVal sformat As String) As String + Dim result As String = "" + Dim sMonth As String = Month(Now()) + If Len(sMonth) = 1 Then sMonth = "0" + sMonth + Dim sDay As String = Day(Now()) + If Len(sDay) = 1 Then sDay = "0" & sDay + Dim sHour As String = Hour(Now()) + If Len(sHour) = 1 Then sHour = "0" & sHour + Dim sMinute As String = Minute(Now()) + If Len(sMinute) = 1 Then sMinute = "0" & sMinute + Dim sSecond As String = Second(Now()) + If Len(sSecond) = 1 Then sSecond = "0" & sSecond + Select Case sformat + Case "1" + 'Partner.tsmut00 + result = Year(Now()) & "-" & sMonth & "-" & sDay & "-" & sHour & "." & sMinute & "." & sSecond & ".000000" + Case "2" + 'etparn.TSMUT00 + result = sDay & "." & sMonth & "." & Year(Now()) & " " & sHour & ":" & sMinute & ":" & sSecond + Case "3" + 'etparn.DMERF00 + result = sDay & "." & sMonth & "." & Year(Now()) + End Select + Return result + End Function + + Function hlp_TransformLand(ByVal inland As String) As String + Dim result As String = "756" + 'MNK 24.08.2009 Version 1.7 - Anpassung Landaufbereitung + Dim scmCmdToExecute As SqlCommand = New SqlCommand() + Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute) + + scmCmdToExecute.CommandText = "dbo.sp_edkb04_get_nationalitaet" + scmCmdToExecute.CommandType = CommandType.StoredProcedure + scmCmdToExecute.Connection = conn_edoka.scoDBConnection + scmCmdToExecute.Parameters.Add(New SqlParameter("@code", SqlDbType.VarChar, 16, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, inland)) + scmCmdToExecute.Parameters.Add(New SqlParameter("@land", SqlDbType.VarChar, 16, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0)) + + Try + conn_edoka.OpenConnection() + scmCmdToExecute.ExecuteNonQuery() + result = scmCmdToExecute.Parameters("@land").Value + Return result + Catch exi As Exception + m_log.log("EDKB04: Fehler TransformLand " & exi.Message & " - Code: " & inland, Common.Common.JournalEntryType.Error) + Return "756" + Finally + conn_edoka.CloseConnection(True) + scmCmdToExecute.Dispose() + sdaAdapter.Dispose() + End Try + End Function + + Function hlp_Transformdate(ByVal Datum As String) As String + Try + + Dim s As String + s = Datum.Substring(0, 4) + "-" + Datum.Substring(4, 2) + "-" + Datum.Substring(6, 2) + Try + Dim dd As DateTime + dd = s + Catch ex As Exception + s = System.DBNull.Value.ToString + End Try + Return s + Catch ex As Exception + Return "" + End Try + End Function + + Private Function hlp_GetBetreuerID_Substitute(ByVal strPnr As String) As String + Dim result As String = Params.DefaultBetreuerID + 'Prüfen ob bereit ein Betreuer eingetragen ist + Dim ssql As String + ssql = "SELECT TOP 1 NRBEU01 FROM edoka_etbez0 WHERE nrpar00 = " & strPnr + Dim connection As New SqlConnection() + Dim daTemp As New SqlDataAdapter(ssql, connection) + Dim dsTemp As New DataSet() + Try + connection.ConnectionString = Globals.sConnectionString_edoka + connection.Open() + daTemp.Fill(dsTemp) + If dsTemp.Tables(0).Rows.Count > 0 Then + If CStr(dsTemp.Tables(0).Rows(0).Item(0)) <> "0" Then + result = CStr(dsTemp.Tables(0).Rows(0).Item(0)) + m_log.log("EDKB04: Fehler in Partner, keine BetreuerID es wird der vorhandene Betreuer weiterverwendet, PartnerNr: " & strPnr, Common.Common.JournalEntryType.Error) + Else + m_log.log("EDKB04: Fehler in Partner, keine BetreuerID es wurde der Defaultbetreuer eingesetzt, PartnerNr: " & strPnr, Common.Common.JournalEntryType.Error) + End If + Else + m_log.log("EDKB04: Fehler in Partner, keine BetreuerID es wurde der Defaultbetreuer eingesetzt, PartnerNr: " & strPnr, Common.Common.JournalEntryType.Error) + End If + Catch ex As Exception + m_log.log("EDKB04: Fehler in hlp_GetBetreuerID_Substitute, PartnerNr: " & strPnr & ", Error" & ex.Message, Common.Common.JournalEntryType.Error) + Finally + dsTemp = Nothing + daTemp = Nothing + connection.Close() + connection = Nothing + End Try + Return result + End Function + + Private Function hlp_TransformVVExtern(ByVal instr As String) As String + Dim result As String = "" + Dim i As Integer = 1 + Do While i <= Len(instr) + If Char.IsDigit(Mid(instr, i, 1).Chars(0)) Then + result = result + Mid(instr, i, 1) + End If + i = i + 1 + Loop + Return result + End Function + + Private Function hlp_transform_Briefanrede(ByVal Anrede As String) As String + Dim s As String + s = Anrede + s = s.Replace("Sehr geehrter ", "") + s = s.Replace("Sehr geehrte ", "") + Return s + End Function + + + +#End Region +End Class diff --git a/EDKB04OP/xmlhelper.vb b/EDKB04OP/xmlhelper.vb new file mode 100644 index 0000000..3a50c4e --- /dev/null +++ b/EDKB04OP/xmlhelper.vb @@ -0,0 +1,1187 @@ + +Imports System.Xml +Imports System.Collections.Specialized +Public Class XmlHelper + + +#Region "GetItemValue (xmldocTagname,value)" + ''' + ''' Gibt den InnerText eines Tags zurück. Falls eine Ausnahme auftritt, wird diese abgefangen und + ''' ein Leerstring ("") zurückgegeben. + ''' + ''' + ''' + ''' + ''' + Shared Function GetItemValueByTagName(ByRef doc As XmlDocument, ByVal TagName As String) As String + Dim ret As String = "" + Try + Dim nlist As XmlNodeList + nlist = doc.GetElementsByTagName(TagName) + If nlist.Count > 0 Then ret = nlist(0).InnerText + Catch ex As Exception + End Try + Return ret + End Function +#End Region + +#Region "GetDataTableFromTagname" + + ''' + ''' Erstellt aus einer Serie von XML Objekten eine DataTable. + ''' Haben die XML Objekte gleichnamige Subnodes, so wird der Spaltenname in der Tabelle mit einer + ''' angehängten Indexnummer eindeutig gemacht. + ''' Falls eine Ausnahme Auftritt, wird eine leere DataTable mit einer Spalte "Dummy" zurückgegeben. + ''' + ''' + ''' + ''' + ''' + Public Shared Function ConvertXmlNodeListToDataTable(ByRef doc As XmlDocument, ByVal Tagname As String) As DataTable + Try + Dim xnl As XmlNodeList + xnl = doc.GetElementsByTagName(Tagname) + Dim dt As New DataTable() + Dim TempColumn As Integer = 0 + For Each node As XmlNode In xnl.Item(0).ChildNodes + TempColumn += 1 + Dim dc As New DataColumn(node.Name, System.Type.[GetType]("System.String")) + If dt.Columns.Contains(node.Name) Then + dt.Columns.Add(dc.ColumnName + TempColumn.ToString()) + Else + dt.Columns.Add(dc) + End If + Next + Dim ColumnsCount As Integer = dt.Columns.Count + For i As Integer = 0 To xnl.Count - 1 + Dim dr As DataRow = dt.NewRow() + For j As Integer = 0 To ColumnsCount - 1 + dr(j) = xnl.Item(i).ChildNodes(j).InnerText + Next + dt.Rows.Add(dr) + Next + Return dt + Catch ex As Exception + Dim dt As New DataTable + dt.Columns.Add("Dummy") + Return dt + + End Try + End Function + + +#End Region + + +#Region "GetItemValue(node, name, value)" + 'Get string value from a node. + Shared Function GetItemValue(ByRef node As XmlNode, ByVal itemName As String, ByRef value As String) As Boolean + Dim success As Boolean = False + If Not node Is Nothing Then + If Not node.Item(itemName) Is Nothing Then + value = node.Item(itemName).InnerText + success = True + End If + End If + Return success + End Function + + 'Get Int32 value from a node. + Shared Function GetItemValue(ByRef node As XmlNode, ByVal itemName As String, ByRef value As Int32) As Boolean + Dim success As Boolean = False + If Not node Is Nothing Then + If Not node.Item(itemName) Is Nothing Then + value = Int32.Parse(node.Item(itemName).InnerText) + success = True + End If + End If + Return success + End Function + + 'Get UInt32 value from a node. + Shared Function GetItemValue(ByRef node As XmlNode, ByVal itemName As String, ByRef value As UInt32) As Boolean + Dim success As Boolean = False + If Not node Is Nothing Then + If Not node.Item(itemName) Is Nothing Then + value = UInt32.Parse(node.Item(itemName).InnerText) + success = True + End If + End If + Return success + End Function +#End Region + + + +#Region "SetItemValue(node, name, value)" + 'Set string value in a node + Shared Function SetItemValue(ByRef node As XmlNode, ByVal itemName As String, ByVal value As String) As Boolean + Dim success As Boolean = False + If Not node Is Nothing Then + If Not node.Item(itemName) Is Nothing Then + node.Item(itemName).InnerText = value + success = True + End If + End If + Return success + End Function + + 'Set int32 value in a node + Shared Function SetItemValue(ByRef node As XmlNode, ByVal itemName As String, ByVal value As Int32) As Boolean + Dim success As Boolean = False + If Not node Is Nothing Then + If Not node.Item(itemName) Is Nothing Then + node.Item(itemName).InnerText = value.ToString + success = True + End If + End If + Return success + End Function + + 'Set uint32 value in a node + Shared Function SetItemValue(ByRef node As XmlNode, ByVal itemName As String, ByVal value As UInt32) As Boolean + Dim success As Boolean = False + If Not node Is Nothing Then + If Not node.Item(itemName) Is Nothing Then + node.Item(itemName).InnerText = value.ToString + success = True + End If + End If + Return success + End Function +#End Region + +#Region "GetAttributeValue(node, name, value)" + ''' ----------------------------------------------------------------------------- + ''' + ''' Gets the value from an attribute at the specified node. + ''' + ''' The XmlNode from which this method will get the value of an attribute. + ''' Name of the attribute that will be read. + ''' Attribute value read by this method + ''' True if node is found and value is retrieved successfully. + ''' ----------------------------------------------------------------------------- + Shared Function GetAttributeValue(ByRef node As XmlNode, ByVal attributeName As String, ByRef value As String) As Boolean + Dim success = False + If Not node Is Nothing Then + Dim attribute As XmlAttribute = node.Attributes.ItemOf(attributeName) + If Not attribute Is Nothing Then + value = attribute.Value + success = True + End If + End If + Return success + End Function + ''' ----------------------------------------------------------------------------- + ''' + ''' Gets the value from an attribute at the specified node. + ''' + ''' The XmlNode from which this method will get the value of an attribute. + ''' Name of the attribute that will be read. + ''' Attribute value read by this method + ''' True if success. + ''' ----------------------------------------------------------------------------- + Shared Function GetAttributeValue(ByRef node As XmlNode, ByVal attributeName As String, ByRef value As Integer) As Boolean + Dim success = False + If Not node Is Nothing Then + Dim attribute As XmlAttribute = node.Attributes.ItemOf(attributeName) + If Not attribute Is Nothing Then + Dim strValue = attribute.Value + value = Integer.Parse(strValue) + success = True + End If + End If + Return success + End Function + ''' ----------------------------------------------------------------------------- + ''' + ''' Gets the value from an attribute at the specified node. + ''' + ''' The XmlNode from which this method will get the value of an attribute. + ''' Name of the attribute that will be read. + ''' Attribute value read by this method + ''' True if success. + ''' ----------------------------------------------------------------------------- + Shared Function GetAttributeValue(ByRef node As XmlNode, ByVal attributeName As String, ByRef value As UInt32) As Boolean + Dim success = False + If Not node Is Nothing Then + Dim attribute As XmlAttribute = node.Attributes.ItemOf(attributeName) + If Not attribute Is Nothing Then + Dim strValue = attribute.Value + value = UInt32.Parse(strValue) + success = True + End If + End If + Return success + End Function + + Shared Function GetAttributeValue(ByRef node As XmlNode, ByVal attributeName As String) As String + Dim value As String = Nothing + If Not node Is Nothing Then + Dim attribute As XmlAttribute = node.Attributes.ItemOf(attributeName) + If Not attribute Is Nothing Then + value = attribute.Value + End If + End If + Return value + End Function + +#End Region + +#Region "SetAttributeValue(node, name, value)" + ''' ----------------------------------------------------------------------------- + ''' + ''' Sets the value of an attribute for a given XmlNode. + ''' + ''' XmlNode whose attribute will be set. + ''' Name of the attribute to set. + ''' Value to be set + ''' True if success. + ''' ----------------------------------------------------------------------------- + Shared Function SetAttributeValue(ByRef node As XmlNode, ByVal attributeName As String, ByVal value As String) As Boolean + Dim success = False + If Not node Is Nothing Then + Dim attrNode As XmlNode = node.Attributes.GetNamedItem(attributeName) + If Not attrNode Is Nothing Then + attrNode.Value = value + success = True + End If + End If + Return success + End Function + ''' ----------------------------------------------------------------------------- + ''' + ''' Sets the value of an attribute for a given XmlNode. + ''' + ''' XmlNode whose attribute will be set. + ''' Name of the attribute to set. + ''' Value to be set + ''' True if success. + ''' ----------------------------------------------------------------------------- + Shared Function SetAttributeValue(ByRef node As XmlNode, ByVal attributeName As String, ByVal value As Integer) As Boolean + Dim success = False + If Not node Is Nothing Then + Dim attrNode As XmlNode = node.Attributes.GetNamedItem(attributeName) + If Not attrNode Is Nothing Then + attrNode.Value = value.ToString + success = True + End If + End If + Return success + End Function + ''' ----------------------------------------------------------------------------- + ''' + ''' Sets the value of an attribute for a given XmlNode. + ''' + ''' XmlNode whose attribute will be set. + ''' Name of the attribute to set. + ''' Value to be set + ''' True if success. + ''' ----------------------------------------------------------------------------- + Shared Function SetAttributeValue(ByRef node As XmlNode, ByVal attributeName As String, ByVal value As UInt32) As Boolean + Dim success = False + If Not node Is Nothing Then + Dim attrNode As XmlNode = node.Attributes.GetNamedItem(attributeName) + If Not attrNode Is Nothing Then + attrNode.Value = value.ToString + success = True + End If + End If + Return success + End Function +#End Region + +#Region "More Attribute Methods" + Shared Function CopyAttribute(ByRef fromNode As XmlNode, ByRef toNode As XmlNode, ByVal attributeName As String) As Boolean + Dim success As Boolean = False + Dim doc As XmlDocument = toNode.OwnerDocument + Dim val As String = "" + If GetAttributeValue(fromNode, attributeName, val) Then + If toNode.Attributes(attributeName) Is Nothing Then CreateAttribute(toNode, attributeName, val) + success = SetAttributeValue(toNode, attributeName, val) + End If + Return success + End Function + + Shared Function CreateAttribute(ByRef node As XmlNode, ByVal attributeName As String, ByVal value As String) As XmlAttribute + Dim doc As XmlDocument = node.OwnerDocument + Dim newNode As XmlNode + + Dim attr As XmlAttribute + 'create new attribute + attr = doc.CreateAttribute(attributeName) + attr.Value = value + 'link attribute to node + node.Attributes.SetNamedItem(attr) + Return attr + End Function +#End Region + +#Region "DataTable manipulation" + + ''' ----------------------------------------------------------------------------- + ''' s + ''' Converts a list of Xml nodes to a DataTable. + ''' + ''' List of Xml nodes + ''' DataTable + ''' + ''' This method convert + ''' + ''' ----------------------------------------------------------------------------- + Shared Function GetDataTable(ByRef nodelist As XmlNodeList) As DataTable + Dim table As DataTable + Dim node As XmlNode + If nodelist Is Nothing Then Return Nothing + + 'get parameter names + node = nodelist.Item(0) + If node Is Nothing Then Return Nothing + + Dim attrCollection As XmlAttributeCollection = node.Attributes + If attrCollection Is Nothing Then Return Nothing + If attrCollection.Count = 0 Then Return Nothing + + 'create data table + table = New DataTable + For Each attr As XmlAttribute In attrCollection + table.Columns.Add(attr.Name) + Next + + 'add rows + Dim row As DataRow + For Each node In nodelist + row = table.NewRow() + For Each attr As XmlAttribute In node.Attributes + row(attr.Name) = attr.Value + Next + table.Rows.Add(row) + Next + + table.AcceptChanges() + Return table + End Function + + ''' ----------------------------------------------------------------------------- + ''' + ''' Converts a list of Xml nodes to a DataTable and sets one of the columns as a primary key. + ''' + ''' + ''' + ''' + ''' + ''' + ''' + ''' ----------------------------------------------------------------------------- + Public Shared Function GetDataTable(ByVal nodelist As XmlNodeList, ByVal primaryKeyColumn As String, ByVal autoIncrement As Boolean) As DataTable + Dim table As DataTable = Nothing + Dim node As XmlNode = Nothing + If nodelist Is Nothing Then + Return Nothing + End If + node = nodelist.Item(0) + If node Is Nothing Then + Return Nothing + End If + Dim attrCollection As XmlAttributeCollection = node.Attributes + If attrCollection Is Nothing Then + Return Nothing + End If + If attrCollection.Count = 0 Then + Return Nothing + End If + table = New DataTable + Dim primaryKeyFieldFound As Boolean = False + For Each attr As XmlAttribute In attrCollection + If attr.Name = primaryKeyColumn Then + primaryKeyFieldFound = True + End If + table.Columns.Add(attr.Name) + Next + If Not primaryKeyFieldFound Then + Throw New Exception("Unable to set primary key in datatable because field '" + primaryKeyColumn + "'was not found.") + End If + table.PrimaryKey = New DataColumn() {table.Columns(primaryKeyColumn)} + If autoIncrement Then + table.Columns(primaryKeyColumn).AutoIncrement = True + table.Columns(primaryKeyColumn).AutoIncrementStep = 1 + End If + Dim row As DataRow = Nothing + For Each n As XmlNode In nodelist + row = table.NewRow + For Each a As XmlAttribute In n.Attributes + row(a.Name) = a.Value + Next + table.Rows.Add(row) + Next + table.AcceptChanges() + Return table + End Function + + ''' ----------------------------------------------------------------------------- + ''' + ''' Updates the child nodes of "parentNode" by using the fields from a datatable. + ''' + ''' + ''' + ''' + ''' + ''' The child nodes that will be updated must have attribute fields that correspond to + ''' the DataTable. The "keyField" will be used to identify the attribute that serves as + ''' an identifier of the rows. The datatable can have less fields than the nodes so + ''' you have the chance to update smaller subsets. + ''' Make sure that you did not call "AcceptChanges" before passing the datatable or this + ''' function will not find any change. + ''' + ''' ----------------------------------------------------------------------------- + Public Shared Sub UpdateChildNodesWithDataTable(ByVal parentNode As XmlNode, ByVal table As DataTable, ByVal keyField As String) + If parentNode Is Nothing Then + Throw New ArgumentNullException("Unable to update child nodes because parentNode is null") + End If + If parentNode.HasChildNodes Then + ' + ' Verify that the fields of first child node match the fields in the data table + ' note that it's ok if the datatable has fewer fields than the nodes. + + Dim firstNode As XmlNode = parentNode.ChildNodes(0) + Dim missingFields As String = "" + Dim columnNames As StringCollection = New StringCollection + For Each col As DataColumn In table.Columns + If firstNode.Attributes(col.ColumnName) Is Nothing Then + If missingFields.Length = 0 Then + missingFields = col.ColumnName + Else + missingFields += ", " + col.ColumnName + End If + Else + columnNames.Add(col.ColumnName) + End If + Next + If missingFields.Length > 0 Then + Throw New Exception("Unable to update nodes with datatable because the nodes are missing the fields: " + missingFields) + End If + Dim currTable As DataTable = table.GetChanges(DataRowState.Deleted) + If Not (currTable Is Nothing) Then + Dim nodeToDelete As XmlNode + Trace.WriteLine("Rows Deleted:") + For Each row As DataRow In table.Rows + Dim keyValue As String = row(keyField).ToString + nodeToDelete = SelectNode(parentNode, keyField, keyValue) + Trace.WriteLine(keyValue) + If Not (nodeToDelete Is Nothing) Then + parentNode.RemoveChild(nodeToDelete) + End If + Next + End If + currTable = table.GetChanges(DataRowState.Modified) + If Not (currTable Is Nothing) Then + Dim nodeToUpdate As XmlNode + Trace.WriteLine("Rows Changed:") + For Each row As DataRow In currTable.Rows + Dim keyValue As String = row(keyField).ToString + Trace.WriteLine(keyValue) + nodeToUpdate = SelectNode(parentNode, keyField, keyValue) + If nodeToUpdate Is Nothing Then + Throw New Exception("Unable to update node with '" + keyField + "=" + keyValue + "' because it doesn't exist") + End If + Dim valueToSet As String + For Each colName As String In columnNames + If colName = keyField Then + ' continue + End If + valueToSet = row(colName).ToString + SetAttributeValue(nodeToUpdate, colName, valueToSet) + Next + Next + End If + currTable = table.GetChanges(DataRowState.Added) + If Not (currTable Is Nothing) Then + Dim newNode As XmlNode + Dim keyValue As String + Dim doc As XmlDocument = parentNode.OwnerDocument + Trace.WriteLine("Rows Added:") + For Each row As DataRow In currTable.Rows + keyValue = row(keyField).ToString + Trace.WriteLine(keyValue) + If SelectNode(parentNode, keyField, keyValue) Is Nothing Then + newNode = doc.CreateElement(firstNode.Name) + CopyAttributes(row, newNode) + parentNode.AppendChild(newNode) + Else + + End If + Next + End If + table.AcceptChanges() + End If + End Sub + + Public Shared Sub UpdateChildNodesWithDataTable(ByVal parentNode As XmlNode, ByVal table As DataTable) + Dim primaryKeyColumns As DataColumn() = table.PrimaryKey + If primaryKeyColumns Is Nothing Then + Throw New Exception("Can not update Child nodes with Table because the table doesn't have a primary key column") + Else + UpdateChildNodesWithDataTable(parentNode, table, primaryKeyColumns(0).ColumnName) + End If + End Sub + + Public Shared Sub CopyAttributes(ByVal fromRow As DataRow, ByVal toNode As XmlNode) + For Each col As DataColumn In fromRow.Table.Columns + CreateAttribute(toNode, col.ColumnName, fromRow(col.ColumnName).ToString) + Next + End Sub + +#End Region + +#Region "Misc" + Public Shared Function SelectNode(ByVal parentNode As XmlNode, ByVal attributeName As String, ByVal attributeValue As String) As XmlNode + Dim node As XmlNode = Nothing + If parentNode.HasChildNodes Then + Dim nodeName As String = parentNode.ChildNodes(0).Name + Dim path As String = nodeName + "[@" + attributeName + "='" + attributeValue + "']" + node = parentNode.SelectSingleNode(path) + End If + Return node + End Function +#End Region + +#Region "Conversion to Array" + Shared Function GetAttributeArray(ByRef nodeList As XmlNodeList, ByVal attributeName As String) As String() + Dim arrayOfValues() As String + If nodeList.Count > 0 Then + ReDim arrayOfValues(nodeList.Count - 1) + Dim index As Integer = 0 + For Each node As XmlNode In nodeList + arrayOfValues(index) = GetAttributeValue(node, attributeName) + index += 1 + Next + End If + Return arrayOfValues + End Function + + 'Gets only the values of the nodes passed in nodelist + Shared Function GetArray(ByRef nodeList As XmlNodeList) As String() + Dim arrayOfValues() As String + If nodeList.Count > 0 Then + ReDim arrayOfValues(nodeList.Count - 1) + Dim index As Integer = 0 + For Each node As XmlNode In nodeList + arrayOfValues(index) = node.InnerText + index += 1 + Next + End If + Return arrayOfValues + End Function + + 'This method gets the name value pair based on the first two attributes of every node + Shared Function GetNameValuePair(ByRef nodeList As XmlNodeList) As NameValueCollection + Dim nameVal As New NameValueCollection + If nodeList Is Nothing Then Return Nothing + + 'get parameter names + Dim node As XmlNode = nodeList.Item(0) + If node Is Nothing Then Return Nothing + + Dim attrCollection As XmlAttributeCollection = node.Attributes + If attrCollection Is Nothing Then Return Nothing + If attrCollection.Count < 2 Then Return Nothing + + Dim attrName1, attrName2 As String + 'read all nodes in nodelist and extract first two attributes + For Each node In nodeList + attrName1 = node.Attributes(0).Value + attrName2 = node.Attributes(1).Value + nameVal.Add(attrName1, attrName2) + Next + Return nameVal + End Function +#End Region + +#Region "Conversions to string" + + ''' ----------------------------------------------------------------------------- + ''' + ''' Returns contents of an XmlNode in a string. + ''' + ''' The XmlNode whose contents will be read into a string. + ''' Xml formatted string with contents of "node" parameter. + ''' ----------------------------------------------------------------------------- + Shared Function NodeToString(ByRef node As XmlNode) As String + Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder("") + Dim sw As System.IO.StringWriter = New System.IO.StringWriter(sb) + Dim writer As XmlTextWriter = New XmlTextWriter(sw) + writer.Formatting = Formatting.Indented + If node Is Nothing Then + writer.WriteStartElement("Node_Empty") + Else + writer.WriteStartElement(node.Name) + + ' Write any attributes + Dim a As XmlAttribute + For Each a In node.Attributes + writer.WriteAttributeString(a.Name, a.Value) + Next + + ' Write child nodes + Dim nodes As XmlNodeList = node.SelectNodes("child::*") + Dim nav As New NodeNavigator + If Not nodes Is Nothing Then + For Each n As XmlNode In nodes + nav.LoopThroughChildren(writer, n) + Next + End If + End If + + writer.WriteEndElement() + writer.Close() + + Return sw.ToString() + End Function + + ''' ----------------------------------------------------------------------------- + ''' + ''' Convert a XmlNodeList to string + ''' + ''' + ''' + ''' + ''' + ''' ----------------------------------------------------------------------------- + Public Shared Function NodeListToString(ByVal nodeList As XmlNodeList) As String + If Not (nodeList Is Nothing) Then + Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder + For Each node As XmlNode In nodeList + If sb.Length = 0 Then + sb.Append(NodeToString(node)) + Else + sb.Append(vbCrLf + NodeToString(node)) + End If + Next + Return sb.ToString + End If + Return "nodeList is null" + End Function + + ''' ----------------------------------------------------------------------------- + ''' + ''' Method to convert a XmlDocument to string. + ''' + ''' XmlDocument that will be converted to string. + ''' A xml formatted string. + ''' ----------------------------------------------------------------------------- + Shared Function DocumentToString(ByRef xmlDoc As XmlDocument) As String + Dim sb As New System.Text.StringBuilder("") + Dim sw As New System.IO.StringWriter(sb) + xmlDoc.Save(sw) + Return sw.ToString() + End Function + +#End Region + +#Region "Creation of Multiple child nodes" + ''' ----------------------------------------------------------------------------- + ''' + ''' Converts a string array to XmlNodes and appends all those nodes to a root node. + ''' + ''' + ''' + ''' + ''' + ''' + ''' ----------------------------------------------------------------------------- + Shared Sub CreateChildNodes(ByRef rootNode As XmlNode, ByVal names() As String) + Dim doc As XmlDocument = rootNode.OwnerDocument + Dim newNode As XmlNode + For Each name As String In names + newNode = doc.CreateElement(name) + rootNode.AppendChild(newNode) + Next + End Sub + + ''' ----------------------------------------------------------------------------- + ''' + ''' + ''' + ''' + ''' + ''' + ''' + ''' + ''' ----------------------------------------------------------------------------- + Shared Sub CreateChildNodes(ByRef rootNode As XmlNode, ByVal nodeName As String, _ + ByVal attributeName As String, ByVal attributeValues() As String) + Dim doc As XmlDocument = rootNode.OwnerDocument + Dim newNode As XmlNode + Dim attr As XmlAttribute + For Each value As String In attributeValues + newNode = doc.CreateElement(nodeName) + CreateAttribute(newNode, attributeName, value) + rootNode.AppendChild(newNode) + Next + End Sub +#End Region + +#Region "© Copyright 2005, Marc Clifton, All Rights Reserved - XmlDatase methods" + '(c) 2005, Marc Clifton + 'All Rights Reserved + + 'Redistribution and use in source and binary forms, with or without modification, + 'are permitted provided that the following conditions are met: + + 'Redistributions of source code must retain the above copyright notice, this list + 'of conditions and the following disclaimer. + + 'Redistributions in binary form must reproduce the above copyright notice, this + 'list of conditions and the following disclaimer in the documentation and/or other + 'materials provided with the distribution. + + 'Neither the name of the Marc Clifton nor the names of its contributors may be + 'used to endorse or promote products derived from this software without specific + 'prior written permission. + + 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + 'ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + 'WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + 'IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + 'INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + 'BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + 'DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + 'LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + 'OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + 'ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#Region "Disclosure" + 'With Marc Clifton's permission, the methods in this section were copied and + 'modified to be used in XmlHelper. The original source code is located at: + 'http://www.codeproject.com/dotnet/XmlDb.asp +#End Region + +#Region "Insert" + ''' + ''' Inserts an empty record at the bottom of the hierarchy, creating the + ''' tree as required. + ''' + ''' The XmlDocument to which the node will be inserted. + ''' The xml XPath query to get to the bottom node. + ''' The XmlNode inserted into the hierarchy. + ''' Thrown when an argument is null. + ''' + ''' The "doc" variable must have a root node. The path should not contain the root node. + ''' The path can contain only the node names or it can contain attributes in XPath query form. + ''' For example to insert an "Address" node at the bottom, the following is a valid xpath query + ''' xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + ''' + Public Shared Function Insert(ByVal doc As XmlDocument, ByVal xpath As String) As XmlNode + VerifyParameters(doc, xpath) + Dim path2 As String = xpath.Trim("/") 'get rid of slashes in front and back + Dim segments As String() = path2.Split("/") + Dim firstNode As XmlNode = doc.LastChild + Dim nodeIndex As Integer = 0 + If segments.Length > 1 Then + ''' + ''' Check if we can access the last node. This comes in handy in cases when the path + ''' contains attributes. For example: "University[@Name='UT']/Student[@Id=12222]/Address" + ''' In example above we would want to get access to last node directly + ''' + Dim pos As Integer = path2.LastIndexOf("/") + Dim path3 As String = path2.Substring(0, pos) + Dim parentNode As XmlNode = doc.LastChild.SelectSingleNode(path3) + If Not (parentNode Is Nothing) Then + firstNode = parentNode + nodeIndex = segments.Length - 1 + End If + End If + Dim lastNode As XmlNode = InsertNode(firstNode, segments, nodeIndex) + Return lastNode + End Function + + ''' + ''' Inserts an record with a multiple fields at the bottom of the hierarchy. + ''' + ''' The XmlDocument to which the node will be inserted. + ''' The xml XPath query to get to the bottom node. + ''' The attribute names that will be created for the node inserted. + ''' The corresponding value of each field. + ''' Thrown when an argument is null. + ''' + ''' The "doc" variable must have a root node. The path should not contain the root node. + ''' The path can contain only the node names or it can contain attributes in XPath query form. + ''' For example to insert an "Address" node at the bottom, the following is a valid xpath query + ''' xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + ''' + Public Shared Sub Insert(ByVal doc As XmlDocument, ByVal xpath As String, ByVal fields As String(), ByVal values As String()) + VerifyParameters(doc, xpath) + If fields Is Nothing Then + Throw (New ArgumentNullException("field cannot be null.")) + End If + If values Is Nothing Then + Throw (New ArgumentNullException("val cannot be null.")) + End If + Dim node As XmlNode = Insert(doc, xpath) + For i As Integer = 0 To fields.Length - 1 + CreateAttribute(node, fields(i), values(i)) + Next + End Sub + + ''' + ''' Inserts a record with a single field at the bottom of the hierarchy. + ''' + ''' The xml XPath query to get to the bottom node. + ''' The field to add to the record. + ''' The value assigned to the field. + ''' Thrown when an argument is null. + ''' + ''' The "doc" variable must have a root node. The path should not contain the root node. + ''' The path can contain only the node names or it can contain attributes in XPath query form. + ''' For example to insert an "Address" node at the bottom, the following is a valid xpath query + ''' xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + ''' + Public Shared Sub Insert(ByVal doc As XmlDocument, ByVal xpath As String, ByVal field As String, ByVal val As String) + VerifyParameters(doc, xpath) + If field Is Nothing Then + Throw (New ArgumentNullException("field cannot be null.")) + End If + If val Is Nothing Then + Throw (New ArgumentNullException("val cannot be null.")) + End If + Dim node As XmlNode = Insert(doc, xpath) + CreateAttribute(node, field, val) + End Sub + + ''' + ''' Insert a record with multiple fields at the bottom of the hierarchy. + ''' + ''' The xml XPath query to get to the bottom node. + ''' The array of fields as field/value pairs. + ''' Thrown when an argument is null. + ''' + ''' The "doc" variable must have a root node. The path should not contain the root node. + ''' The path can contain only the node names or it can contain attributes in XPath query form. + ''' For example to insert an "Address" node at the bottom, the following is a valid xpath query + ''' xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + ''' + Public Shared Sub Insert(ByVal doc As XmlDocument, ByVal xpath As String, ByVal nameValuePairs As NameValueCollection) + VerifyParameters(doc, xpath) + If nameValuePairs Is Nothing Then + Throw (New ArgumentNullException("fields cannot be null.")) + End If + Dim node As XmlNode = Insert(doc, xpath) + Dim iterator As System.Collections.IEnumerator = nameValuePairs.GetEnumerator + Dim field As String + Dim val As String + While iterator.MoveNext + field = iterator.Current.ToString + val = nameValuePairs(field) + CreateAttribute(node, field, val) + End While + End Sub + + ''' + ''' Inserts a record with multiple fields at bottom of the hierarchy. + ''' + ''' + ''' The xml XPath query to get to the bottom node. + ''' The DataRow values that will be added as attributes. + ''' + ''' The columns names of the DataRow will become the attribute names and + ''' the row values of the DataRow will be the attribute values. + ''' The "doc" variable must have a root node. The path should not contain the root node. + ''' The path can contain only the node names or it can contain attributes in XPath query form. + ''' For example to insert an "Address" node at the bottom, the following is a valid xpath query + ''' xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + ''' + Public Shared Sub Insert(ByVal doc As XmlDocument, ByVal xpath As String, ByVal rowValues As DataRow) + VerifyParameters(doc, xpath) + If rowValues Is Nothing Then + Throw (New ArgumentNullException("val cannot be null.")) + End If + Dim node As XmlNode = Insert(doc, xpath) + For Each col As DataColumn In rowValues.Table.Columns + CreateAttribute(node, col.ColumnName, rowValues(col.ColumnName).ToString) + Next + End Sub + + ''' + ''' Inserts a record with multiple fields from a DataTable at bottom of the hierarchy. + ''' + ''' + ''' The xml XPath query to get to the bottom node. + ''' The DataRow values that will be added as attributes. + Public Shared Sub Insert(ByVal doc As XmlDocument, ByVal xpath As String, ByVal table As DataTable) + VerifyParameters(doc, xpath) + If table Is Nothing Then + Throw (New ArgumentNullException("table cannot be null.")) + End If + + For Each row As DataRow In table.Rows + Insert(doc, xpath, row) + Next + End Sub + + ''' + ''' Inserts a record with multiple values at bottom of hierarchy. This is analogous to inserting + ''' a column of data. + ''' + ''' + ''' The xml XPath query to get to the bottom node. + ''' Name of the attribute to be created at node inserted. + ''' Values that will be inserted that correspond to the field name. + ''' + ''' The "doc" variable must have a root node. The path should not contain the root node. + ''' The path can contain only the node names or it can contain attributes in XPath query form. + ''' For example to insert an "Address" node at the bottom, the following is a valid xpath query + ''' xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + ''' + Public Shared Sub Insert(ByVal doc As XmlDocument, ByVal xpath As String, ByVal field As String, ByVal values As String()) + VerifyParameters(doc, xpath) + Dim node As XmlNode + For Each val As String In values + node = Insert(doc, xpath) + CreateAttribute(node, field, val) + Next + End Sub + +#End Region + +#Region "Update" + ''' + ''' Update a single field in all records in the specified path. + ''' + ''' The XmlDocument whose node will be udpated. + ''' The xml path. + ''' The field name to update. + ''' The new value. + ''' The number of records affected. + ''' Thrown when an argument is null. + ''' + ''' The "doc" variable must have a root node. The path should not contain the root node. + ''' The path can contain only the node names or it can contain attributes in XPath query form. + ''' For example to update an "Address" node at the bottom, the following is a valid xpath query + ''' xpath = "University[@Name='UT']/Student[@Id=12222]/Address" + ''' + Public Shared Function Update(ByVal doc As XmlDocument, ByVal xpath As String, ByVal field As String, ByVal val As String) As Integer + VerifyParameters(doc, xpath) + If field Is Nothing Then + Throw (New ArgumentNullException("field cannot be null.")) + End If + If val Is Nothing Then + Throw (New ArgumentNullException("val cannot be null.")) + End If + Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder + Dim nodeList As XmlNodeList = doc.LastChild.SelectNodes(xpath) + For Each node As XmlNode In nodeList + If Not SetAttributeValue(node, field, val) Then + sb.Append(field + " is not an attribute of: " + NodeToString(node) + vbCrLf) + End If + Next + If sb.Length > 0 Then + Throw New Exception("Failed to add nodes because:" + vbCrLf + sb.ToString) + End If + Return nodeList.Count + End Function + +#End Region + +#Region "Delete" + ''' + ''' Deletes all records of the specified path. + ''' + ''' The xml XPath query to get to the bottom node. + ''' The number of records deleted. + ''' Thrown when an argument is null. + ''' Additional exceptions may be thrown by the XmlDocument class. + Public Shared Function Delete(ByVal doc As XmlDocument, ByVal xpath As String) As Integer + VerifyParameters(doc, xpath) + Dim nodeList As XmlNodeList = doc.LastChild.SelectNodes(xpath) + For Each node As XmlNode In nodeList + node.ParentNode.RemoveChild(node) + Next + Return nodeList.Count + End Function + + ''' + ''' Deletes a field from all records on the specified path. + ''' + ''' The xml path. + ''' The field to delete. + ''' The number of records affected. + ''' Thrown when an argument is null. + ''' Additional exceptions may be thrown by the XmlDocument class. + Public Shared Function Delete(ByVal doc As XmlDocument, ByVal xpath As String, ByVal field As String) As Integer + VerifyParameters(doc, xpath) + If field Is Nothing Then + Throw (New ArgumentNullException("field cannot be null.")) + End If + Dim nodeList As XmlNodeList = doc.SelectNodes(xpath) + For Each node As XmlNode In nodeList + Dim attrib As XmlAttribute = node.Attributes(field) + node.Attributes.Remove(attrib) + Next + Return nodeList.Count + End Function +#End Region + +#Region "Query" + ''' + ''' Return a single string representing the value of the specified field + ''' for the first record encountered. + ''' + ''' The xml path. + ''' The desired field. + ''' A string with the field's value or null. + ''' Thrown when an argument is null. + ''' Additional exceptions may be thrown by the XmlDocument class. + Public Shared Function QueryScalar(ByVal doc As XmlDocument, ByVal xpath As String, ByVal field As String) As String + VerifyParameters(doc, xpath) + If field Is Nothing Then + Throw (New ArgumentNullException("field cannot be null.")) + End If + Dim ret As String = Nothing + Dim node As XmlNode = doc.LastChild.SelectSingleNode(xpath) + If Not (node Is Nothing) Then + ret = GetAttributeValue(node, field) + End If + Return ret + End Function + + ''' + ''' Returns a DataTable for all rows on the path. + ''' + ''' The xml path. + ''' The DataTable with the returned rows. + ''' The row count will be 0 if no rows returned. + ''' Thrown when an argument is null. + ''' Additional exceptions may be thrown by the XmlDocument class. + Public Shared Function Query(ByVal doc As XmlDocument, ByVal xpath As String) As DataTable + VerifyParameters(doc, xpath) + Dim dt As DataTable = New DataTable + Dim nodeList As XmlNodeList = doc.LastChild.SelectNodes(xpath) + If Not (nodeList.Count = 0) Then + CreateColumns(dt, nodeList(0)) + End If + For Each node As XmlNode In nodeList + Dim dr As DataRow = dt.NewRow + For Each attr As XmlAttribute In node.Attributes + dr(attr.Name) = attr.Value + Next + dt.Rows.Add(dr) + Next + Return dt + End Function + + ''' + ''' Returns an array of values for the specified field for all rows on + ''' the path. + ''' + ''' The xml path. + ''' The desired field. + ''' The array of string values for each row qualified by the path. + ''' A null is returned if the query results in 0 rows. + ''' Thrown when an argument is null. + ''' Additional exceptions may be thrown by the XmlDocument class. + Public Shared Function QueryField(ByVal doc As XmlDocument, ByVal xpath As String, ByVal field As String) As String() + VerifyParameters(doc, xpath) + If field Is Nothing Then + Throw (New ArgumentNullException("field cannot be null.")) + End If + Dim nodeList As XmlNodeList = doc.LastChild.SelectNodes(xpath) + Dim s As String() = Nothing + If Not (nodeList.Count = 0) Then + s = New String(nodeList.Count - 1) {} + Dim i As Integer = 0 + For Each node As XmlNode In nodeList + s(i) = node.Attributes(field).Value + i += 1 + Next + End If + Return s + End Function +#End Region + +#End Region + +#Region "NodeNavigator Class" + Private Class NodeNavigator + ' Recursively loop over a node subtree + Friend Sub LoopThroughChildren(ByVal writer As XmlTextWriter, ByVal rootNode As XmlNode) + ' Write the start tag + If rootNode.NodeType = XmlNodeType.Element Then + writer.WriteStartElement(rootNode.Name) + + ' Write any attributes + Dim a As XmlAttribute + For Each a In rootNode.Attributes + writer.WriteAttributeString(a.Name, a.Value) + Next + + ' Write any child nodes + Dim n As XmlNode + For Each n In rootNode.ChildNodes + LoopThroughChildren(writer, n) + Next + + ' Write the end tag + writer.WriteEndElement() + Else + ' Write any text + If rootNode.NodeType = XmlNodeType.Text Then + writer.WriteString(rootNode.Value) + End If + End If + End Sub + End Class +#End Region + +#Region "Helpers" + ''' + ''' Inserts a node at the specified segment if it doesn't exist, otherwise + ''' traverses the node. + ''' + ''' The current node. + ''' The path segment list. + ''' The current segment. + ''' + Protected Shared Function InsertNode(ByVal node As XmlNode, ByVal segments As String(), ByVal idx As Integer) As XmlNode + Dim newNode As XmlNode = Nothing + If idx = segments.Length Then + Return node + End If + If idx + 1 < segments.Length Then + For Each child As XmlNode In node.ChildNodes + If child.Name = segments(idx) Then + newNode = InsertNode(child, segments, idx + 1) + Return newNode + End If + Next + End If + Dim doc As XmlDocument = node.OwnerDocument + newNode = doc.CreateElement(segments(idx)) + node.AppendChild(newNode) + Dim nextNode As XmlNode = InsertNode(newNode, segments, idx + 1) + Return nextNode + End Function + + ''' + ''' Creates columns given an XmlNode. + ''' + ''' The target DataTable. + ''' The source XmlNode. + Protected Shared Sub CreateColumns(ByVal dt As DataTable, ByVal node As XmlNode) + For Each attr As XmlAttribute In node.Attributes + dt.Columns.Add(New DataColumn(attr.Name)) + Next + End Sub + + Protected Shared Sub VerifyParameters(ByVal doc As XmlDocument, ByVal xpath As String) + If doc Is Nothing Then + Throw New Exception("doc cannot be null.") + End If + If doc.LastChild.GetType Is GetType(System.Xml.XmlDeclaration) Then + Throw New Exception("XmlDocument requires at least the a root node") + End If + If xpath Is Nothing Then + Throw (New ArgumentNullException("path cannot be null.")) + End If + End Sub +#End Region +End Class diff --git a/Git_Create.bat b/Git_Create.bat new file mode 100644 index 0000000..df3fd5b --- /dev/null +++ b/Git_Create.bat @@ -0,0 +1,13 @@ +git remote add origin https://gitea.shubweb.ch/shu/edkb04.git +git push -u origin main +pause +rem touch .gitignore +rem pause +rem touch README.md +git init +git checkout -b main +git add README.md +git commit -m "first commit" +git remote add origin http://192.168.111.81:3000/shu/EDKB04.git +git push -u origin main +pause \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29