EDMI: Fix DoctypeId Parameter

This commit is contained in:
Jonathan Jenne
2022-03-29 13:35:20 +02:00
parent 665a23d8a7
commit 615666f040
17 changed files with 178 additions and 187 deletions

View File

@@ -7,7 +7,7 @@
<xs:sequence>
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMIService.Methods.IDB" minOccurs="0" name="AttributeValues" nillable="true" type="q1:ArrayOfUserAttributeValue" />
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMIService.Methods.IDB" minOccurs="0" name="File" nillable="true" type="q2:FileProperties" />
<xs:element minOccurs="0" name="IDBDoctypeId" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="IDBDoctypeId" type="xs:long" />
<xs:element minOccurs="0" name="KindType" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="ProfileId" type="xs:int" />
<xs:element minOccurs="0" name="StoreName" nillable="true" type="xs:string" />

View File

@@ -7,7 +7,7 @@
<xs:sequence>
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMIService.Methods.IDB" minOccurs="0" name="AttributeValues" nillable="true" type="q1:ArrayOfUserAttributeValue" />
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMIService.Methods.IDB" minOccurs="0" name="File" nillable="true" type="q2:FileProperties" />
<xs:element minOccurs="0" name="IDBDoctypeId" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="IDBDoctypeId" type="xs:long" />
<xs:element minOccurs="0" name="KindType" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="ProfileId" type="xs:int" />
<xs:element minOccurs="0" name="StoreName" nillable="true" type="xs:string" />

View File

@@ -2372,7 +2372,7 @@ Namespace EDMIServiceReference
Private FileField As EDMIServiceReference.FileProperties
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private IDBDoctypeIdField As String
Private IDBDoctypeIdField As Long
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private KindTypeField As String
@@ -2423,12 +2423,12 @@ Namespace EDMIServiceReference
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property IDBDoctypeId() As String
Public Property IDBDoctypeId() As Long
Get
Return Me.IDBDoctypeIdField
End Get
Set
If (Object.ReferenceEquals(Me.IDBDoctypeIdField, value) <> true) Then
If (Me.IDBDoctypeIdField.Equals(value) <> true) Then
Me.IDBDoctypeIdField = value
Me.RaisePropertyChanged("IDBDoctypeId")
End If
@@ -2516,7 +2516,7 @@ Namespace EDMIServiceReference
Private FileField As EDMIServiceReference.FileProperties
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private IDBDoctypeIdField As String
Private IDBDoctypeIdField As Long
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private KindTypeField As String
@@ -2567,12 +2567,12 @@ Namespace EDMIServiceReference
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property IDBDoctypeId() As String
Public Property IDBDoctypeId() As Long
Get
Return Me.IDBDoctypeIdField
End Get
Set
If (Object.ReferenceEquals(Me.IDBDoctypeIdField, value) <> true) Then
If (Me.IDBDoctypeIdField.Equals(value) <> true) Then
Me.IDBDoctypeIdField = value
Me.RaisePropertyChanged("IDBDoctypeId")
End If

View File

@@ -3,17 +3,18 @@ Imports DigitalData.Modules.Logging
Public Class Helpers
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private ReadOnly FileEx As Filesystem.File
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private ReadOnly FileEx As Filesystem.File
Public Sub New(pLogConfig As LogConfig)
LogConfig = pLogConfig
Logger = pLogConfig.GetLogger()
FileEx = New Filesystem.File(pLogConfig)
End Sub
Public Sub New(pLogConfig As LogConfig)
LogConfig = pLogConfig
Logger = pLogConfig.GetLogger()
FileEx = New Filesystem.File(pLogConfig)
End Sub
Public Function GetFileProperties(pFilePath As String, pDateImportedAt As Date) As FileProperties
Public Function GetFileProperties(pFilePath As String, pDateImportedAt As Date) As FileProperties
Try
Using oFileStream As New IO.FileStream(pFilePath, IO.FileMode.Open, IO.FileAccess.Read)
Using oMemoryStream As New IO.MemoryStream()
oFileStream.CopyTo(oMemoryStream)
@@ -27,16 +28,21 @@ Public Class Helpers
Dim oFileModifiedAt As Date = oFileInfo?.LastWriteTime
Dim oFileHash As String = FileEx.GetChecksum(oFileInfo.FullName)
Return New FileProperties With {
.FileName = oFileInfo.Name,
.FileCreatedAt = oFileCreatedAt,
.FileChangedAt = oFileModifiedAt,
.FileContents = oContents,
.FileImportedAt = pDateImportedAt,
.FileChecksum = oFileHash,
.FileInfoRaw = oFileInfo
Return New FileProperties With {
.FileName = oFileInfo.Name,
.FileCreatedAt = oFileCreatedAt,
.FileChangedAt = oFileModifiedAt,
.FileContents = oContents,
.FileImportedAt = pDateImportedAt,
.FileChecksum = oFileHash,
.FileInfoRaw = oFileInfo
}
End Using
End Using
End Using
End Function
End Class
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
End Class

View File

@@ -28,47 +28,32 @@ Namespace Modules.Globix
Throw New FileNotFoundException("Path does not exist")
End If
Dim oFileInfo As New FileInfo(pFilePath)
Dim oExtension As String = oFileInfo.Extension
Dim oFileName As String = oFileInfo.Name
Dim oFileCreatedAt As Date = oFileInfo?.CreationTime
Dim oFileModifiedAt As Date = oFileInfo?.LastWriteTime
Dim oFileHash As String = FileEx.GetChecksum(oFileInfo.FullName)
' Try to load file properties
Dim oFileProperties = Helpers.GetFileProperties(pFilePath, pImportOptions.DateImported)
If oFileProperties Is Nothing Then
Throw New IOException("File could not be read!")
End If
' Importing the file now
Using oFileStream As New FileStream(pFilePath, FileMode.Open, FileAccess.Read)
Using oMemoryStream As New MemoryStream()
oFileStream.CopyTo(oMemoryStream)
Dim oContents = oMemoryStream.ToArray()
Dim oFileImportResponse = Await Channel.Globix_ImportFileAsync(New Globix_ImportFileRequest With {
.IDBDoctypeId = pIDBDoctypeId,
.File = oFileProperties,
.KindType = pObjectKind,
.StoreName = pObjectStoreName,
.User = New UserState() With {
.UserName = pImportOptions.Username,
.Language = pImportOptions.Language
},
.ProfileId = pProfileId,
.AttributeValues = pAttributeValues.ToArray
})
Dim oFileImportResponse = Await Channel.Globix_ImportFileAsync(New Globix_ImportFileRequest With {
.IDBDoctypeId = pIDBDoctypeId,
.File = New FileProperties With {
.FileName = oFileInfo.Name,
.FileCreatedAt = oFileCreatedAt,
.FileChangedAt = oFileModifiedAt,
.FileContents = oContents,
.FileImportedAt = pImportOptions.DateImported,
.FileChecksum = oFileHash,
.FileInfoRaw = oFileInfo
},
.KindType = pObjectKind,
.StoreName = pObjectStoreName,
.User = New UserState() With {
.UserName = pImportOptions.Username,
.Language = pImportOptions.Language
},
.ProfileId = pProfileId,
.AttributeValues = pAttributeValues.ToArray
})
Return oFileImportResponse
Return oFileImportResponse
End Using
End Using
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
End Class

View File

@@ -27,47 +27,32 @@ Namespace Modules.IDB
Throw New FileNotFoundException("Path does not exist")
End If
Dim oFileInfo As New FileInfo(pFilePath)
Dim oExtension As String = oFileInfo.Extension
Dim oFileName As String = oFileInfo.Name
Dim oFileCreatedAt As Date = oFileInfo?.CreationTime
Dim oFileModifiedAt As Date = oFileInfo?.LastWriteTime
Dim oFileHash As String = FileEx.GetChecksum(oFileInfo.FullName)
' Try to load file properties
Dim oFileProperties = Helpers.GetFileProperties(pFilePath, pImportOptions.DateImported)
If oFileProperties Is Nothing Then
Throw New IOException("File could not be read!")
End If
' Importing the file now
Using oFileStream As New FileStream(pFilePath, FileMode.Open, FileAccess.Read)
Using oMemoryStream As New MemoryStream()
oFileStream.CopyTo(oMemoryStream)
Dim oContents = oMemoryStream.ToArray()
Dim oFileImportResponse = Await Channel.ImportFileAsync(New ImportFileRequest With {
.IDBDoctypeId = pIDBDoctypeId,
.File = oFileProperties,
.KindType = pObjectKind,
.StoreName = pObjectStoreName,
.User = New UserState() With {
.UserName = pImportOptions.Username,
.Language = pImportOptions.Language
},
.ProfileId = -1,
.AttributeValues = pAttributeValues.ToArray
})
Dim oFileImportResponse = Await Channel.ImportFileAsync(New ImportFileRequest With {
.IDBDoctypeId = pIDBDoctypeId,
.File = New FileProperties With {
.FileName = oFileInfo.Name,
.FileCreatedAt = oFileCreatedAt,
.FileChangedAt = oFileModifiedAt,
.FileContents = oContents,
.FileImportedAt = pImportOptions.DateImported,
.FileChecksum = oFileHash,
.FileInfoRaw = oFileInfo
},
.KindType = pObjectKind,
.StoreName = pObjectStoreName,
.User = New UserState() With {
.UserName = pImportOptions.Username,
.Language = pImportOptions.Language
},
.ProfileId = -1,
.AttributeValues = pAttributeValues.ToArray
})
Return oFileImportResponse
Return oFileImportResponse
End Using
End Using
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
End Class