This commit is contained in:
Jonathan Jenne 2017-08-15 12:37:22 +02:00
parent 1872606a5c
commit 273218d124
4 changed files with 23 additions and 46 deletions

View File

@ -1,5 +1,4 @@
Imports System.Configuration Imports System.Configuration
Imports System
Public Class AppConfig Public Class AppConfig
@ -10,21 +9,21 @@ Public Class AppConfig
Dim appsettings As AppSettingsSection = appconfig.AppSettings Dim appsettings As AppSettingsSection = appconfig.AppSettings
Dim settings As KeyValueConfigurationCollection = appsettings.Settings Dim settings As KeyValueConfigurationCollection = appsettings.Settings
Dim values As New ConfigValues() Dim values As New ConfigValues() With {
.username = settings.Item("dpma_username").Value,
values.username = settings.Item("dpma_username").Value .password = settings.Item("dpma_password").Value,
values.password = settings.Item("dpma_password").Value .query = settings.Item("dpma_query").Value,
values.query = settings.Item("dpma_query").Value .queryIgnore = settings.Item("dpma_query_ignore").Value,
values.queryIgnore = settings.Item("dpma_query_ignore").Value .connstring = settings.Item("sql_connstring").Value,
values.connstring = settings.Item("sql_connstring").Value .database = settings.Item("sql_database").Value,
values.database = settings.Item("sql_database").Value .searchType = settings.Item("search_type").Value
values.searchType = settings.Item("search_type").Value }
Return values Return values
End Function End Function
Public Shared Function GetVersion() Public Shared Function GetVersion()
Dim assembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly() Dim assembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
Dim fvi As FileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location) Dim fvi As FileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location)
Dim version As String = fvi.FileVersion Dim version As String = fvi.FileVersion
Return version Return version
@ -40,7 +39,4 @@ Public Class ConfigValues
Public connstring As String Public connstring As String
Public database As String Public database As String
Public searchType As String Public searchType As String
Public Sub New()
End Sub
End Class End Class

View File

@ -19,17 +19,17 @@ Public Class DB
End Sub End Sub
#Region "=== HELPERS ===" #Region "=== HELPERS ==="
Public Function formatTable(table As String) As String Public Function FormatTable(table As String) As String
Return String.Format("[{0}].[dbo].[{1}]", _db, table) Return String.Format("[{0}].[dbo].[{1}]", _db, table)
End Function End Function
Public Function GetFormIdFor(entityName As String) As Integer Public Function GetFormIdFor(entityName As String) As Integer
Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}'", Me.formatTable("TBPMO_FORM"), entityName) Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}'", Me.FormatTable("TBPMO_FORM"), entityName)
Return Me.Scalar(sql) Return Me.Scalar(sql)
End Function End Function
Public Function GetControlId(formId As Integer, Optional name As String = "ApplicationNumber") As Integer Public Function GetControlId(formId As Integer, Optional name As String = "ApplicationNumber") As Integer
Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}' AND FORM_ID = {2}", Me.formatTable("TBPMO_CONTROL"), name, formId) Dim sql = String.Format("SELECT GUID FROM {0} WHERE NAME = '{1}' AND FORM_ID = {2}", Me.FormatTable("TBPMO_CONTROL"), name, formId)
Return Me.Scalar(sql) Return Me.Scalar(sql)
End Function End Function
@ -54,7 +54,7 @@ Public Class DB
End Function End Function
Public Function IsEqual(controlId As Integer, recordId As Integer, valueToCompare As Object) Public Function IsEqual(controlId As Integer, recordId As Integer, valueToCompare As Object)
Dim table = Me.formatTable("TBPMO_CONTROL_VALUE") Dim table = Me.FormatTable("TBPMO_CONTROL_VALUE")
Dim sql = String.Format("SELECT VALUE FROM {0} WHERE CONTROL_ID = {1} AND RECORD_ID = {2}", table, controlId, recordId) Dim sql = String.Format("SELECT VALUE FROM {0} WHERE CONTROL_ID = {1} AND RECORD_ID = {2}", table, controlId, recordId)
Dim value = Me.Scalar(sql) Dim value = Me.Scalar(sql)
@ -68,12 +68,12 @@ Public Class DB
#Region "=== RECORD ID ===" #Region "=== RECORD ID ==="
Public Function GetRecordId(controlId As Integer, applicationNumber As String) As Integer Public Function GetRecordId(controlId As Integer, applicationNumber As String) As Integer
Dim sql = String.Format("SELECT RECORD_ID FROM {0} WHERE CONTROL_ID = {1} AND VALUE = '{2}'", Me.formatTable("TBPMO_CONTROL_VALUE"), controlId, applicationNumber) Dim sql = String.Format("SELECT RECORD_ID FROM {0} WHERE CONTROL_ID = {1} AND VALUE = '{2}'", Me.FormatTable("TBPMO_CONTROL_VALUE"), controlId, applicationNumber)
Return Me.Scalar(sql) Return Me.Scalar(sql)
End Function End Function
Public Function InsertRecord(formId As Integer) Public Function InsertRecord(formId As Integer)
Dim sql = String.Format("INSERT INTO {0} (FORM_ID, ADDED_WHO, RECORD_ENTITY_ID, PARENT_RECORD) VALUES ({1}, '{2}', {1}, 0)", Me.formatTable("TBPMO_RECORD"), formId, Username) Dim sql = String.Format("INSERT INTO {0} (FORM_ID, ADDED_WHO, RECORD_ENTITY_ID, PARENT_RECORD) VALUES ({1}, '{2}', {1}, 0)", Me.FormatTable("TBPMO_RECORD"), formId, Username)
Me.NonQuery(sql) Me.NonQuery(sql)
Return Me.Scalar("SELECT MAX(GUID) FROM TBPMO_RECORD") Return Me.Scalar("SELECT MAX(GUID) FROM TBPMO_RECORD")
End Function End Function
@ -81,14 +81,14 @@ Public Class DB
#Region "=== VALUES ===" #Region "=== VALUES ==="
Public Function InsertValue(controlId As Integer, recordId As Integer, value As Object) Public Function InsertValue(controlId As Integer, recordId As Integer, value As Object)
Dim table = Me.formatTable("TBPMO_CONTROL_VALUE") Dim table = Me.FormatTable("TBPMO_CONTROL_VALUE")
Dim sql = String.Format("INSERT INTO {0} (CONTROL_ID, RECORD_ID, VALUE, ADDED_WHO) VALUES ({1}, {2}, '{3}', '{4}')", table, controlId, recordId, value, Username) Dim sql = String.Format("INSERT INTO {0} (CONTROL_ID, RECORD_ID, VALUE, ADDED_WHO) VALUES ({1}, {2}, '{3}', '{4}')", table, controlId, recordId, value, Username)
Me.NonQuery(sql) Me.NonQuery(sql)
Return Me.Scalar(String.Format("SELECT MAX(GUID) FROM {0} WHERE CONTROL_ID = {1}", table, controlId)) Return Me.Scalar(String.Format("SELECT MAX(GUID) FROM {0} WHERE CONTROL_ID = {1}", table, controlId))
End Function End Function
Public Sub UpdateValue(controlId As Integer, recordId As Integer, value As Object) Public Sub UpdateValue(controlId As Integer, recordId As Integer, value As Object)
Dim table = Me.formatTable("TBPMO_CONTROL_VALUE") Dim table = Me.FormatTable("TBPMO_CONTROL_VALUE")
Dim sql = String.Format("UPDATE {0} SET VALUE = '{1}', CHANGED_WHO = '{4}' WHERE CONTROL_ID = {2} AND RECORD_ID = {3} ", table, value, controlId, recordId, Username) Dim sql = String.Format("UPDATE {0} SET VALUE = '{1}', CHANGED_WHO = '{4}' WHERE CONTROL_ID = {2} AND RECORD_ID = {3} ", table, value, controlId, recordId, Username)
Me.NonQuery(sql) Me.NonQuery(sql)
End Sub End Sub
@ -152,7 +152,7 @@ Public Class DB
#Region "=== IMAGES ===" #Region "=== IMAGES ==="
Public Sub InsertImage(bimage As Byte(), ControlId As Integer, RecordId As Integer) Public Sub InsertImage(bimage As Byte(), ControlId As Integer, RecordId As Integer)
Dim table = Me.formatTable("TBPMO_CONTROL_IMAGE") Dim table = Me.FormatTable("TBPMO_CONTROL_IMAGE")
Dim sql = String.Format("INSERT INTO {0} (CONTROL_ID, RECORD_ID, IMG) VALUES (@CONTROL_ID, @RECORD_ID, @IMG)", table) Dim sql = String.Format("INSERT INTO {0} (CONTROL_ID, RECORD_ID, IMG) VALUES (@CONTROL_ID, @RECORD_ID, @IMG)", table)
Dim conn As New SqlClient.SqlConnection(_connstring) Dim conn As New SqlClient.SqlConnection(_connstring)
Dim cmd As New SqlClient.SqlCommand(sql, conn) Dim cmd As New SqlClient.SqlCommand(sql, conn)
@ -167,7 +167,7 @@ Public Class DB
End Sub End Sub
Public Sub UpdateImage(bimage As Byte(), ControlId As Integer, RecordId As Integer) Public Sub UpdateImage(bimage As Byte(), ControlId As Integer, RecordId As Integer)
Dim table = Me.formatTable("TBPMO_CONTROL_IMAGE") Dim table = Me.FormatTable("TBPMO_CONTROL_IMAGE")
Dim sql = String.Format("UPDATE {0} SET IMG = @IMG WHERE CONTROL_ID = @CONTROL_ID AND RECORD_ID = @RECORD_ID", table) Dim sql = String.Format("UPDATE {0} SET IMG = @IMG WHERE CONTROL_ID = @CONTROL_ID AND RECORD_ID = @RECORD_ID", table)
Dim conn As New SqlClient.SqlConnection(_connstring) Dim conn As New SqlClient.SqlConnection(_connstring)
Dim cmd As New SqlClient.SqlCommand(sql, conn) Dim cmd As New SqlClient.SqlCommand(sql, conn)

View File

@ -17,25 +17,6 @@ Public Class DPMAConnectPatents
_service.Open() _service.Open()
End Sub End Sub
Public Function SearchPatents(query As String) As XmlDocument
Dim doc As New XmlDocument()
Dim xmlstring As String
Try
xmlstring = _service.search(_user, _pass, query)
doc.LoadXml(xmlstring)
Dim ErrorMessage = doc.SelectSingleNode("Hitlist/ErrorMessage")
If Not IsNothing(ErrorMessage) Then
Throw New Exception(ErrorMessage.InnerText)
End If
Catch ex As Exception
Throw ex
End Try
Return doc
End Function
Public Function Search(query As String) As XmlDocument Public Function Search(query As String) As XmlDocument
Dim doc As New XmlDocument() Dim doc As New XmlDocument()
Dim xmlstring As String Dim xmlstring As String

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.3.1")> <Assembly: AssemblyVersion("1.3.1.0")>
<Assembly: AssemblyFileVersion("1.1.2.0")> <Assembly: AssemblyFileVersion("1.1.2.0")>