use strings for dates

This commit is contained in:
JenneJ 2015-10-13 14:12:51 +02:00
parent 2a25617572
commit d238d7fadc
5 changed files with 83 additions and 36 deletions

View File

@ -12,6 +12,21 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<MyType>Console</MyType> <MyType>Console</MyType>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -117,7 +132,7 @@
<CustomToolNamespace>My</CustomToolNamespace> <CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput> <LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None> </None>
<None Include="App.config"> <None Include="BrainpoolXmlParser.exe.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>
@ -174,6 +189,23 @@
<LastGenOutput>Reference.vb</LastGenOutput> <LastGenOutput>Reference.vb</LastGenOutput>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -4,6 +4,7 @@ Imports System
Public Class AppConfig Public Class AppConfig
Public Shared Function GetConfiguration() As ConfigValues Public Shared Function GetConfiguration() As ConfigValues
Dim appfile As String = My.Application.Info.DirectoryPath & "\" & My.Application.Info.Title & ".exe" Dim appfile As String = My.Application.Info.DirectoryPath & "\" & My.Application.Info.Title & ".exe"
Dim appconfig As Configuration = ConfigurationManager.OpenExeConfiguration(appfile) Dim appconfig As Configuration = ConfigurationManager.OpenExeConfiguration(appfile)
Dim appsettings As AppSettingsSection = appconfig.AppSettings Dim appsettings As AppSettingsSection = appconfig.AppSettings

View File

@ -4,30 +4,20 @@ Imports System.Xml
Imports NLog Imports NLog
Module Main Module Main
Public LOGPATH As String Private logger As Logger
' Config Variablen Private mainDoc As XmlDocument
'Dim username As String '= "TestBrainpool" Private markDoc As XmlDocument
'Dim password As String '= "09Test2015"
'Dim filename As String '= "BRAINPOOL_MARKEN.xml"
'Dim query As String '= "INH=""BRAINPOOL"""
'Dim connstring As String
'Dim database As String
Private logger As Logger = LogManager.GetLogger("Main") Private MainFile As String = "Importer-SearchData.xml"
Dim mainDoc As XmlDocument Private p As New Parser()
Dim markDoc As XmlDocument Private dpma As DPMAConnect
Private db As DB
Dim MainFile As String = "Importer-SearchData.xml" Private config As ConfigValues
Private marks As New List(Of Mark)
Dim p As New Parser() Private props = New List(Of String) From {
Dim dpma As DPMAConnect
Dim db As DB
Dim config As ConfigValues
Dim marks As New List(Of Mark)
Dim props = New List(Of String) From {
"RegistrationOfficeCode", "RegistrationOfficeCode",
"RegistrationDate", "RegistrationDate",
"RegistrationNumber", "RegistrationNumber",
@ -48,6 +38,7 @@ Module Main
Sub Main() Sub Main()
Try Try
logger = LogManager.GetLogger("Main")
config = AppConfig.GetConfiguration() config = AppConfig.GetConfiguration()
logger.Info("{0} started", My.Application.Info.Title) logger.Info("{0} started", My.Application.Info.Title)
@ -61,6 +52,8 @@ Module Main
' Ergebnis auslesen und Marken-Klassen erstellen ' Ergebnis auslesen und Marken-Klassen erstellen
marks = p.ReadMarkXMLFile(MainFile) marks = p.ReadMarkXMLFile(MainFile)
logger.Info("Importing Marks..")
For Each mark As Mark In marks For Each mark As Mark In marks
Dim akz As String = mark.ApplicationNumber Dim akz As String = mark.ApplicationNumber
Dim file As String = String.Format("Importer-RegisterData-{0}.xml", akz) Dim file As String = String.Format("Importer-RegisterData-{0}.xml", akz)
@ -71,7 +64,6 @@ Module Main
markDoc.Save(file) markDoc.Save(file)
p.ReadMarkRegisterInfoXMLFile(file, mark) p.ReadMarkRegisterInfoXMLFile(file, mark)
'p.ReadMarkRegisterInfoXML(markDoc, mark)
Next Next
logger.Info("{0} Marks imported", marks.Count) logger.Info("{0} Marks imported", marks.Count)
@ -81,6 +73,8 @@ Module Main
db = New DB(config.connstring, "DD_ECM") db = New DB(config.connstring, "DD_ECM")
Dim formId As Integer = db.GetFormId() Dim formId As Integer = db.GetFormId()
Dim changedMarks As Integer = 0
Dim addedMarks As Integer = 0
For Each m As Mark In marks For Each m As Mark In marks
@ -100,6 +94,7 @@ Module Main
logger.Info("New record created with GUID: " & recordId) logger.Info("New record created with GUID: " & recordId)
' Den Leit-Wert einfügen für mainControlId ' Den Leit-Wert einfügen für mainControlId
Dim valueId = db.InsertValue(mainControlId, recordId, m.ApplicationNumber) Dim valueId = db.InsertValue(mainControlId, recordId, m.ApplicationNumber)
addedMarks = addedMarks + 1
logger.Debug("Value inserted - Property: {0}, Value: {1}, ControlId: {2}", "ApplicationNumber", m.ApplicationNumber, mainControlId) logger.Debug("Value inserted - Property: {0}, Value: {1}, ControlId: {2}", "ApplicationNumber", m.ApplicationNumber, mainControlId)
' alle anderen properties zu dieser marke einfügen einfügen ' alle anderen properties zu dieser marke einfügen einfügen
@ -115,6 +110,7 @@ Module Main
Else Else
' Marke aktualisieren ' Marke aktualisieren
Dim recordId As Integer = markExists Dim recordId As Integer = markExists
Dim propsChanged = False
logger.Info("Existing Record updated with GUID: {0}", recordId) logger.Info("Existing Record updated with GUID: {0}", recordId)
@ -123,25 +119,44 @@ Module Main
Dim controlId = db.GetControlId(formId, prop) Dim controlId = db.GetControlId(formId, prop)
' Wert für die aktuelle property holen ' Wert für die aktuelle property holen
Dim value = db.GetProperty(m, prop) Dim value = db.GetProperty(m, prop)
' Wert aktualisieren
Dim hasChanged As Boolean = Not db.IsEqual(controlId, recordId, value) Dim hasChanged As Boolean = Not db.IsEqual(controlId, recordId, value)
logger.Debug("Value {0} for {1} has changed", value, recordId) logger.Debug("Value for {0} has changed", recordId)
If hasChanged Then If hasChanged Then
propsChanged = True
' Wert aktualisieren
db.UpdateValue(controlId, recordId, value) db.UpdateValue(controlId, recordId, value)
logger.Debug("Value updated - Property: {0}, NewValue: {1}, ControlId: {2}", prop, value, controlId) logger.Debug("Value updated - Property: {0}, ControlId: {1}", prop, controlId)
End If End If
Next Next
If propsChanged Then
changedMarks = changedMarks + 1
End If
End If End If
logger.Debug("=================== DATABASE END ===================")
Next Next
logger.Info("{0} Marks added, {1} updated", addedMarks, changedMarks)
logger.Debug("=================== DATABASE END ===================")
Catch ex As Exception Catch ex As Exception
logger.Error("An Error occurred: " & ex.Message) logger.Error("An Error occurred: {0}", GetExceptionInfo(ex))
logger.Error("{0}, {1}, {2}, {3}, {4}", config.username, config.password, config.query, config.connstring, config.database)
Environment.Exit(1) Environment.Exit(1)
End Try End Try
End Sub End Sub
Public Function GetExceptionInfo(ex As Exception) As String
Dim Result As String
Dim hr As Integer = Runtime.InteropServices.Marshal.GetHRForException(ex)
Result = ex.GetType.ToString & "(0x" & hr.ToString("X8") & "): " & ex.Message & Environment.NewLine & ex.StackTrace & Environment.NewLine
Dim st As StackTrace = New StackTrace(ex, True)
For Each sf As StackFrame In st.GetFrames
If sf.GetFileLineNumber() > 0 Then
Result &= "Line:" & sf.GetFileLineNumber() & " Filename: " & IO.Path.GetFileName(sf.GetFileName) & Environment.NewLine
End If
Next
Return Result
End Function
End Module End Module

View File

@ -1,22 +1,21 @@
Public Class Mark Public Class Mark
' Aus Search ' Aus Search
Public Property RegistrationOfficeCode As String 'Datenbestand Public Property RegistrationOfficeCode As String 'Datenbestand
Public Property RegistrationDate As Date 'Tag der Eintragung im Register Public Property RegistrationDate As String 'Tag der Eintragung im Register
Public Property RegistrationNumber As String 'Registernummer Public Property RegistrationNumber As String 'Registernummer
Public Property MarkCurrentStatusCode As String 'Aktenzustand Public Property MarkCurrentStatusCode As String 'Aktenzustand
Public Property MarkVerbalElementText As String 'Wiedergabe der Marke Public Property MarkVerbalElementText As String 'Wiedergabe der Marke
Public Property MarkFeature As String 'Markenform Public Property MarkFeature As String 'Markenform
Public Property ApplicationDate As Date 'Anmeldetag Public Property ApplicationDate As String 'Anmeldetag
Public Property ApplicationNumber As String 'Aktenzeichen Public Property ApplicationNumber As String 'Aktenzeichen
Public Property Applicant As String 'Inhaber Public Property Applicant As String 'Inhaber
Public Property Representative As String 'Vertreter Public Property Representative As String 'Vertreter
' Aus GetRegisterInfo ' Aus GetRegisterInfo
Public Property PublicationDate As Date Public Property PublicationDate As String ' Tag der Veröffentlichung
Public Property PropertyationDate As Date Public Property ExpiryDate As String 'Schutzendedatum
Public Property ExpiryDate As Date 'Schutzendedatum Public Property TerminationDate As String 'Wirkungsdatum Löschung
Public Property TerminationDate As Date 'Wirkungsdatum Löschung Public Property OppositionPeriodStartDate As String 'Beginn Widerspruchsfrist
Public Property OppositionPeriodStartDate As Date 'Beginn Widerspruchsfrist Public Property OppositionPeriodEndDate As String 'Ablauf Widerspruchsfrist
Public Property OppositionPeriodEndDate As Date 'Ablauf Widerspruchsfrist
Public Property MarkRecordDetails As New List(Of MarkRecordDetail) Public Property MarkRecordDetails As New List(Of MarkRecordDetail)
Public Property ClassificationKindCode As String Public Property ClassificationKindCode As String
Public Property ClassificationVersion As String Public Property ClassificationVersion As String
@ -61,7 +60,7 @@ Public Class MarkRecordDetail
Public RecordIdentifier As String Public RecordIdentifier As String
Public BasicRecordKind As String Public BasicRecordKind As String
Public RecordCurrentStatusCode As String Public RecordCurrentStatusCode As String
Public RecordCurrentStatusDate As Date Public RecordCurrentStatusDate As String
Public RecordProcedureIncomplete As Boolean = False Public RecordProcedureIncomplete As Boolean = False
Public Sub New() Public Sub New()