diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb index 3bdc2db6..828edb15 100644 --- a/Modules.EDMIAPI/Client.vb +++ b/Modules.EDMIAPI/Client.vb @@ -160,7 +160,9 @@ Public Class Client }, .KindType = pObjectKind, .StoreName = pObjectStoreName, - .Who = pImportOptions.Username + .User = New UserState With { + .UserName = pImportOptions.Username + } }) If oFileImportResponse.OK = False Then @@ -176,58 +178,61 @@ Public Class Client End Try End Function - 'Public Function ImportFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pImportOptions As NewFileOptions = Nothing) - ' Try - ' ' Set default options - ' If pImportOptions Is Nothing Then - ' pImportOptions = New NewFileOptions() - ' End If + Public Async Function ImportFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pImportOptions As NewFileOptions = Nothing) As Task(Of Long) + Try + ' Set default options + If pImportOptions Is Nothing Then + pImportOptions = New NewFileOptions() + End If - ' ' Check if file exists - ' If File.Exists(pFilePath) = False Then - ' Throw New FileNotFoundException("Path does not exist") - ' End If + ' Check if file exists + If File.Exists(pFilePath) = False Then + Throw New FileNotFoundException("Path does not exist") + End If - ' Dim oFileInfo As New FileInfo(pFilePath) - ' Dim oExtension As String = oFileInfo.Extension + 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) + 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) - ' ' 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() + ' 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.NewFIleAsync (New NewFileRequest With { - ' .BusinessEntity = pBusinessEntity, - ' .File = New FileProperties With { - ' .FileName = oFileInfo.Name, - ' .FileCreatedAt = oFileCreatedAt, - ' .FileChangedAt = oFileModifiedAt, - ' .FileContents = oContents, - ' .FileImportedAt = pImportOptions.DateImported, - ' .FileChecksum = oFileHash - ' }, - ' .KindType = pObjectKind, - ' .StoreName = pObjectStoreName, - ' .Who = pImportOptions.Username - ' }) - ' If oFileImportResponse.OK = False Then - ' Throw New ApplicationException("Could not Import File Contents!") - ' End If + Dim oFileImportResponse = Await _channel.ImportFileAsync(New ImportFileRequest With { + .BusinessEntity = pBusinessEntity, + .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 + } + }) + If oFileImportResponse.OK = False Then + Throw New ApplicationException("Could not Import File Contents!") + End If - ' Return oFileImportResponse.ObjectId - ' End Using - ' End Using - ' Catch ex As Exception - ' _logger.Error(ex) - ' Return INVALID_OBEJCT_ID - ' End Try - 'End Function + Return oFileImportResponse.ObjectId + End Using + End Using + Catch ex As Exception + _logger.Error(ex) + Return INVALID_OBEJCT_ID + End Try + End Function ''' ''' Sets a value to an attribute diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Arrays.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Arrays.xsd new file mode 100644 index 00000000..c7a5d70f --- /dev/null +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Arrays.xsd @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.EDMI.API.EDMIServiceReference.ImportFileResponse.datasource b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.EDMI.API.EDMIServiceReference.ImportFileResponse.datasource new file mode 100644 index 00000000..d3e7710e --- /dev/null +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.EDMI.API.EDMIServiceReference.ImportFileResponse.datasource @@ -0,0 +1,10 @@ + + + + DigitalData.Modules.EDMI.API.EDMIServiceReference.ImportFileResponse, Connected Services.EDMIServiceReference.Reference.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.ZooFlow.State.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.ZooFlow.State.xsd new file mode 100644 index 00000000..631e9bfc --- /dev/null +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.ZooFlow.State.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.GlobalIndexer.ImportFile.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.GlobalIndexer.ImportFile.xsd new file mode 100644 index 00000000..dfacd76d --- /dev/null +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.GlobalIndexer.ImportFile.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.NewFile.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.NewFile.xsd index 2aa3f71d..9bbf4d86 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.NewFile.xsd +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.NewFile.xsd @@ -1,21 +1,21 @@  + - - + - + diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.xsd index 0a3fdbd6..df472490 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.xsd +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.xsd @@ -1,5 +1,7 @@  + + @@ -7,8 +9,24 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl index e5817814..b5182607 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl @@ -10,7 +10,11 @@ + + + + @@ -126,6 +130,12 @@ + + + + + + @@ -230,6 +240,10 @@ + + + + diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd index aa80c7b0..84c580cb 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd @@ -3,6 +3,7 @@ + @@ -187,6 +188,20 @@ + + + + + + + + + + + + + + @@ -197,7 +212,7 @@ - + @@ -213,7 +228,7 @@ - + diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap index 60e088a1..08a1ba92 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap @@ -32,7 +32,11 @@ + + + + diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb index 7a74f601..f7595dbe 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb @@ -25,6 +25,7 @@ Namespace EDMIServiceReference System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.NonQueryResult)), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.NewFileResponse)), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueResponse)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ImportFileResponse)), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.TableResult))> _ Partial Public Class BaseResponse Inherits Object @@ -118,8 +119,16 @@ Namespace EDMIServiceReference System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.NewFileRequest)), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.NewFileResponse)), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.FileProperties)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UserAttributeValue())), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UserAttributeValue)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileInfo)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileSystemInfo)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UserState)), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueRequest)), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueResponse)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ImportFileRequest)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ImportFileResponse)), _ + System.Runtime.Serialization.KnownTypeAttribute(GetType(String())), _ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.RightsAccessRight))> _ Partial Public Class ScalarResult Inherits EDMIServiceReference.BaseResponse @@ -200,6 +209,31 @@ Namespace EDMIServiceReference End Property End Class + _ + Partial Public Class ImportFileResponse + Inherits EDMIServiceReference.BaseResponse + + _ + Private ObjectIdField As Long + + _ + Public Property ObjectId() As Long + Get + Return Me.ObjectIdField + End Get + Set + If (Me.ObjectIdField.Equals(value) <> true) Then + Me.ObjectIdField = value + Me.RaisePropertyChanged("ObjectId") + End If + End Set + End Property + End Class + _ Private KindTypeField As String - _ - Private LanguageField As String - _ Private StoreNameField As String _ - Private WhoField As String + Private UserField As EDMIServiceReference.UserState _ Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData @@ -414,19 +445,6 @@ Namespace EDMIServiceReference End Set End Property - _ - Public Property Language() As String - Get - Return Me.LanguageField - End Get - Set - If (Object.ReferenceEquals(Me.LanguageField, value) <> true) Then - Me.LanguageField = value - Me.RaisePropertyChanged("Language") - End If - End Set - End Property - _ Public Property StoreName() As String Get @@ -441,14 +459,14 @@ Namespace EDMIServiceReference End Property _ - Public Property Who() As String + Public Property User() As EDMIServiceReference.UserState Get - Return Me.WhoField + Return Me.UserField End Get Set - If (Object.ReferenceEquals(Me.WhoField, value) <> true) Then - Me.WhoField = value - Me.RaisePropertyChanged("Who") + If (Object.ReferenceEquals(Me.UserField, value) <> true) Then + Me.UserField = value + Me.RaisePropertyChanged("User") End If End Set End Property @@ -489,6 +507,9 @@ Namespace EDMIServiceReference _ Private FileImportedAtField As Date + _ + Private FileInfoRawField As System.IO.FileInfo + _ Private FileNameField As String @@ -567,6 +588,19 @@ Namespace EDMIServiceReference End Set End Property + _ + Public Property FileInfoRaw() As System.IO.FileInfo + Get + Return Me.FileInfoRawField + End Get + Set + If (Object.ReferenceEquals(Me.FileInfoRawField, value) <> true) Then + Me.FileInfoRawField = value + Me.RaisePropertyChanged("FileInfoRaw") + End If + End Set + End Property + _ Public Property FileName() As String Get @@ -590,6 +624,324 @@ Namespace EDMIServiceReference End Sub End Class + _ + Partial Public Class UserAttributeValue + Inherits Object + Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged + + _ + Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject + + _ + Private AttributeIdField As Integer + + _ + Private AttributeNameField As String + + _ + Private AttributeValuesField() As String + + _ + Private ControlNameField As String + + _ + Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData + Get + Return Me.extensionDataField + End Get + Set + Me.extensionDataField = value + End Set + End Property + + _ + Public Property AttributeId() As Integer + Get + Return Me.AttributeIdField + End Get + Set + If (Me.AttributeIdField.Equals(value) <> true) Then + Me.AttributeIdField = value + Me.RaisePropertyChanged("AttributeId") + End If + End Set + End Property + + _ + Public Property AttributeName() As String + Get + Return Me.AttributeNameField + End Get + Set + If (Object.ReferenceEquals(Me.AttributeNameField, value) <> true) Then + Me.AttributeNameField = value + Me.RaisePropertyChanged("AttributeName") + End If + End Set + End Property + + _ + Public Property AttributeValues() As String() + Get + Return Me.AttributeValuesField + End Get + Set + If (Object.ReferenceEquals(Me.AttributeValuesField, value) <> true) Then + Me.AttributeValuesField = value + Me.RaisePropertyChanged("AttributeValues") + End If + End Set + End Property + + _ + Public Property ControlName() As String + Get + Return Me.ControlNameField + End Get + Set + If (Object.ReferenceEquals(Me.ControlNameField, value) <> true) Then + Me.ControlNameField = value + Me.RaisePropertyChanged("ControlName") + End If + End Set + End Property + + Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Sub RaisePropertyChanged(ByVal propertyName As String) + Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent + If (Not (propertyChanged) Is Nothing) Then + propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName)) + End If + End Sub + End Class + + _ + Partial Public Class UserState + Inherits Object + Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged + + _ + Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject + + _ + Private DateFormatField As String + + _ + Private EmailField As String + + _ + Private GivenNameField As String + + _ + Private HideBasicConfigField As Boolean + + _ + Private IsAdminField As Boolean + + _ + Private LanguageField As String + + _ + Private LanguageIdField As Integer + + _ + Private MachineNameField As String + + _ + Private ShortNameField As String + + _ + Private SurnameField As String + + _ + Private UserIdField As Integer + + _ + Private UserNameField As String + + _ + Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData + Get + Return Me.extensionDataField + End Get + Set + Me.extensionDataField = value + End Set + End Property + + _ + Public Property DateFormat() As String + Get + Return Me.DateFormatField + End Get + Set + If (Object.ReferenceEquals(Me.DateFormatField, value) <> true) Then + Me.DateFormatField = value + Me.RaisePropertyChanged("DateFormat") + End If + End Set + End Property + + _ + Public Property Email() As String + Get + Return Me.EmailField + End Get + Set + If (Object.ReferenceEquals(Me.EmailField, value) <> true) Then + Me.EmailField = value + Me.RaisePropertyChanged("Email") + End If + End Set + End Property + + _ + Public Property GivenName() As String + Get + Return Me.GivenNameField + End Get + Set + If (Object.ReferenceEquals(Me.GivenNameField, value) <> true) Then + Me.GivenNameField = value + Me.RaisePropertyChanged("GivenName") + End If + End Set + End Property + + _ + Public Property HideBasicConfig() As Boolean + Get + Return Me.HideBasicConfigField + End Get + Set + If (Me.HideBasicConfigField.Equals(value) <> true) Then + Me.HideBasicConfigField = value + Me.RaisePropertyChanged("HideBasicConfig") + End If + End Set + End Property + + _ + Public Property IsAdmin() As Boolean + Get + Return Me.IsAdminField + End Get + Set + If (Me.IsAdminField.Equals(value) <> true) Then + Me.IsAdminField = value + Me.RaisePropertyChanged("IsAdmin") + End If + End Set + End Property + + _ + Public Property Language() As String + Get + Return Me.LanguageField + End Get + Set + If (Object.ReferenceEquals(Me.LanguageField, value) <> true) Then + Me.LanguageField = value + Me.RaisePropertyChanged("Language") + End If + End Set + End Property + + _ + Public Property LanguageId() As Integer + Get + Return Me.LanguageIdField + End Get + Set + If (Me.LanguageIdField.Equals(value) <> true) Then + Me.LanguageIdField = value + Me.RaisePropertyChanged("LanguageId") + End If + End Set + End Property + + _ + Public Property MachineName() As String + Get + Return Me.MachineNameField + End Get + Set + If (Object.ReferenceEquals(Me.MachineNameField, value) <> true) Then + Me.MachineNameField = value + Me.RaisePropertyChanged("MachineName") + End If + End Set + End Property + + _ + Public Property ShortName() As String + Get + Return Me.ShortNameField + End Get + Set + If (Object.ReferenceEquals(Me.ShortNameField, value) <> true) Then + Me.ShortNameField = value + Me.RaisePropertyChanged("ShortName") + End If + End Set + End Property + + _ + Public Property Surname() As String + Get + Return Me.SurnameField + End Get + Set + If (Object.ReferenceEquals(Me.SurnameField, value) <> true) Then + Me.SurnameField = value + Me.RaisePropertyChanged("Surname") + End If + End Set + End Property + + _ + Public Property UserId() As Integer + Get + Return Me.UserIdField + End Get + Set + If (Me.UserIdField.Equals(value) <> true) Then + Me.UserIdField = value + Me.RaisePropertyChanged("UserId") + End If + End Set + End Property + + _ + Public Property UserName() As String + Get + Return Me.UserNameField + End Get + Set + If (Object.ReferenceEquals(Me.UserNameField, value) <> true) Then + Me.UserNameField = value + Me.RaisePropertyChanged("UserName") + End If + End Set + End Property + + Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Sub RaisePropertyChanged(ByVal propertyName As String) + Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent + If (Not (propertyChanged) Is Nothing) Then + propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName)) + End If + End Sub + End Class + _ + Partial Public Class ImportFileRequest + Inherits Object + Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged + + _ + Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject + + _ + Private AttributeValuesField() As EDMIServiceReference.UserAttributeValue + + _ + Private BusinessEntityField As String + + _ + Private FileField As EDMIServiceReference.FileProperties + + _ + Private KindTypeField As String + + _ + Private ProfileIdField As Integer + + _ + Private StoreNameField As String + + _ + Private UserField As EDMIServiceReference.UserState + + _ + Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData + Get + Return Me.extensionDataField + End Get + Set + Me.extensionDataField = value + End Set + End Property + + _ + Public Property AttributeValues() As EDMIServiceReference.UserAttributeValue() + Get + Return Me.AttributeValuesField + End Get + Set + If (Object.ReferenceEquals(Me.AttributeValuesField, value) <> true) Then + Me.AttributeValuesField = value + Me.RaisePropertyChanged("AttributeValues") + End If + End Set + End Property + + _ + Public Property BusinessEntity() As String + Get + Return Me.BusinessEntityField + End Get + Set + If (Object.ReferenceEquals(Me.BusinessEntityField, value) <> true) Then + Me.BusinessEntityField = value + Me.RaisePropertyChanged("BusinessEntity") + End If + End Set + End Property + + _ + Public Property File() As EDMIServiceReference.FileProperties + Get + Return Me.FileField + End Get + Set + If (Object.ReferenceEquals(Me.FileField, value) <> true) Then + Me.FileField = value + Me.RaisePropertyChanged("File") + End If + End Set + End Property + + _ + Public Property KindType() As String + Get + Return Me.KindTypeField + End Get + Set + If (Object.ReferenceEquals(Me.KindTypeField, value) <> true) Then + Me.KindTypeField = value + Me.RaisePropertyChanged("KindType") + End If + End Set + End Property + + _ + Public Property ProfileId() As Integer + Get + Return Me.ProfileIdField + End Get + Set + If (Me.ProfileIdField.Equals(value) <> true) Then + Me.ProfileIdField = value + Me.RaisePropertyChanged("ProfileId") + End If + End Set + End Property + + _ + Public Property StoreName() As String + Get + Return Me.StoreNameField + End Get + Set + If (Object.ReferenceEquals(Me.StoreNameField, value) <> true) Then + Me.StoreNameField = value + Me.RaisePropertyChanged("StoreName") + End If + End Set + End Property + + _ + Public Property User() As EDMIServiceReference.UserState + Get + Return Me.UserField + End Get + Set + If (Object.ReferenceEquals(Me.UserField, value) <> true) Then + Me.UserField = value + Me.RaisePropertyChanged("User") + End If + End Set + End Property + + Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged + + Protected Sub RaisePropertyChanged(ByVal propertyName As String) + Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent + If (Not (propertyChanged) Is Nothing) Then + propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName)) + End If + End Sub + End Class + _ Public Enum RightsAccessRight As Integer @@ -851,6 +1347,12 @@ Namespace EDMIServiceReference _ Function SetAttributeValueAsync(ByVal Data As EDMIServiceReference.SetAttributeValueRequest) As System.Threading.Tasks.Task(Of EDMIServiceReference.SetAttributeValueResponse) + _ + Function ImportFile(ByVal Data As EDMIServiceReference.ImportFileRequest) As EDMIServiceReference.ImportFileResponse + + _ + Function ImportFileAsync(ByVal Data As EDMIServiceReference.ImportFileRequest) As System.Threading.Tasks.Task(Of EDMIServiceReference.ImportFileResponse) + 'CODEGEN: Der Nachrichtenvertrag wird generiert, da der Wrappername (DocumentStreamRequest) von Nachricht "DocumentStreamRequest" nicht mit dem Standardwert (GetFileByObjectId) übereinstimmt. _ Function EDMIServiceReference_IEDMIService_GetFileByObjectId(ByVal request As EDMIServiceReference.DocumentStreamRequest) As EDMIServiceReference.DocumentStreamResponse Implements EDMIServiceReference.IEDMIService.GetFileByObjectId Return MyBase.Channel.GetFileByObjectId(request) diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/System.IO.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/System.IO.xsd new file mode 100644 index 00000000..68a2b9b7 --- /dev/null +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/System.IO.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl index 1ea6a324..28c3fba3 100644 --- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl +++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl @@ -191,6 +191,15 @@ + + + + + + + + + diff --git a/Modules.EDMIAPI/EDMI.API.vbproj b/Modules.EDMIAPI/EDMI.API.vbproj index 47af114d..5fad9be9 100644 --- a/Modules.EDMIAPI/EDMI.API.vbproj +++ b/Modules.EDMIAPI/EDMI.API.vbproj @@ -109,6 +109,9 @@ + + Designer + Reference.svcmap @@ -118,6 +121,9 @@ Reference.svcmap + + Reference.svcmap + Reference.svcmap @@ -142,12 +148,18 @@ Designer + + Designer + Designer Designer + + Designer + Designer @@ -171,6 +183,9 @@ Designer + + Designer + Designer diff --git a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index ec77830a..d4e91d3d 100644 --- a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -410,9 +410,7 @@ Public Class ImportZUGFeRDFiles AddRejectedState(oMessageId, "NoFerdsException", " Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction) Catch ex As NoFerdsAlternateException - ' TODO - ' Maybe dont even log this 'error', since it's not really an error - ' and it might happen *A LOT* + ' TODO: Maybe dont even log this 'error', since it's not really an error and it might happen *A LOT* _logger.Error(ex) oMoveDirectory = oArgs.NonZugferdDirectory diff --git a/Modules.Patterns/Modules/FileInformation.vb b/Modules.Patterns/Modules/FileInformation.vb new file mode 100644 index 00000000..b0e8bf5e --- /dev/null +++ b/Modules.Patterns/Modules/FileInformation.vb @@ -0,0 +1,67 @@ +Imports System.IO +Imports DigitalData.Modules.Logging + +Namespace Modules + Public Class FileInformation + Inherits BaseModule + Implements IModule + + Public Const FILE_VALUE_FILEINFO = "FILEINFO" + Public Const FILE_VALUE_FILENAME = "FILENAME" + Public Const FILE_VALUE_EXTENSION = "EXTENSION" + Public Const FILE_VALUE_FILENAME_EXT = "FILENAME_EXT" + Public Const FILE_VALUE_DATE_CREATED = "DATE_CREATED" + Public Const FILE_VALUE_DATE_MODIFIED = "DATE_MODIFIED" + + Public Property PatternIdentifier As String = "FILE" Implements IModule.PatternIdentifier + Public Property IsComplex As Boolean = False Implements IModule.IsComplex + + Public Sub New(pLogConfig As LogConfig) + MyBase.New(pLogConfig) + End Sub + + Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace + Dim oResult = pInput + Dim oCounter = 0 + Dim oFileInfo As FileInfo = pReplaceMap.Item(FILE_VALUE_FILEINFO) + + ' Replace Filename without extension + While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME) + Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(oFileInfo.Name) + oResult = ReplacePattern(oResult, PatternIdentifier, oFilenameWithoutExtension) + IncrementCounterOrThrow(oCounter) + End While + + ' Replace Filename with extension + While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME_EXT) + Dim oFilename As String = oFileInfo.Name + oResult = ReplacePattern(oResult, PatternIdentifier, oFilename) + IncrementCounterOrThrow(oCounter) + End While + + ' Replace Extension + While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME_EXT) + Dim oExtension As String = oFileInfo.Extension.Substring(1) + oResult = ReplacePattern(oResult, PatternIdentifier, oExtension) + IncrementCounterOrThrow(oCounter) + End While + + ' Replace creation date + While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_DATE_CREATED) + Dim oDateCreated = oFileInfo.CreationTime.ToString("yyyy-MM-dd") + oResult = ReplacePattern(oResult, PatternIdentifier, oDateCreated) + IncrementCounterOrThrow(oCounter) + End While + + ' Replace last modification date + While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_DATE_CREATED) + Dim oDateModified = oFileInfo.LastWriteTime.ToString("yyyy-MM-dd") + oResult = ReplacePattern(oResult, PatternIdentifier, oDateModified) + IncrementCounterOrThrow(oCounter) + End While + + Return oResult + End Function + End Class + +End Namespace \ No newline at end of file diff --git a/Modules.Patterns/Modules/Internal.vb b/Modules.Patterns/Modules/Internal.vb index 205cfc50..5394746a 100644 --- a/Modules.Patterns/Modules/Internal.vb +++ b/Modules.Patterns/Modules/Internal.vb @@ -12,6 +12,9 @@ Namespace Modules Public Const INT_VALUE_MACHINE = "MACHINE" Public Const INT_VALUE_DOMAIN = "DOMAIN" Public Const INT_VALUE_DATE = "DATE" + Public Const INT_VALUE_DATE_YYYY = "DATE_YYYY" + Public Const INT_VALUE_DATE_MM = "DATE_MM" + Public Const INT_VALUE_DATE_DD = "DATE_DD" Public Property PatternIdentifier As String = "INT" Implements IModule.PatternIdentifier Public Property IsComplex As Boolean = False Implements IModule.IsComplex @@ -23,30 +26,29 @@ Namespace Modules Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace Dim oResult = pInput Dim oCounter = 0 - - ' Replace Username(s) - While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_USERNAME) - oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(INT_VALUE_USERNAME)) - IncrementCounterOrThrow(oCounter) - End While - - ' Replace Machinename(s) - While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_MACHINE) - oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(INT_VALUE_MACHINE)) - IncrementCounterOrThrow(oCounter) - End While - - - ' Replace Domainname(s) - While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DOMAIN) - oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(INT_VALUE_DOMAIN)) - IncrementCounterOrThrow(oCounter) - End While - + Dim oNow As Date = Now ' Replace CurrentDate(s) While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE) - oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(INT_VALUE_DATE)) + oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy-MM-dd")) + IncrementCounterOrThrow(oCounter) + End While + + ' Replace Year(s) + While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_YYYY) + oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy")) + IncrementCounterOrThrow(oCounter) + End While + + ' Replace Month(s) + While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_MM) + oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("MM")) + IncrementCounterOrThrow(oCounter) + End While + + ' Replace Day(s) + While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_DD) + oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("dd")) IncrementCounterOrThrow(oCounter) End While diff --git a/Modules.Patterns/Patterns.vbproj b/Modules.Patterns/Patterns.vbproj index 201ccb22..8fc6b49b 100644 --- a/Modules.Patterns/Patterns.vbproj +++ b/Modules.Patterns/Patterns.vbproj @@ -81,6 +81,7 @@ + diff --git a/Modules.Patterns/Patterns2.vb b/Modules.Patterns/Patterns2.vb index 8b7d114f..8278c8de 100644 --- a/Modules.Patterns/Patterns2.vb +++ b/Modules.Patterns/Patterns2.vb @@ -1,4 +1,5 @@ -Imports System.Text.RegularExpressions +Imports System.IO +Imports System.Text.RegularExpressions Imports System.Windows.Forms Imports DigitalData.Controls.LookupGrid Imports DigitalData.Modules.Logging @@ -65,7 +66,8 @@ Public Class Patterns2 New Modules.Internal(LogConfig), New Modules.Clipboard(LogConfig), New Modules.Controls(LogConfig), - New Modules.User(LogConfig) + New Modules.User(LogConfig), + New Modules.FileInformation(LogConfig) }) End Sub @@ -75,12 +77,12 @@ Public Class Patterns2 IDBActive = pIDBActive End Sub - Public Function ReplaceAllValues(pInput As String, pPanel As Panel, pUser As State.UserState) As String + Public Function ReplaceAllValues(pInput As String, pPanel As Panel, pUser As State.UserState, pFIleinfo As FileInfo) As String Dim oResult = pInput For Each oModule In Modules Try - Dim oArgs = GetReplaceMapForModule(oModule, pPanel, pUser) + Dim oArgs = GetReplaceMapForModule(oModule, pPanel:=pPanel, pUser:=pUser, pFileInfo:=pFIleinfo) oResult = oModule.Replace(oResult, oArgs) Catch ex As Exception Logger.Warn("Placeholders for String [{0}] could not be replaced completely in Module [{1}]. Skipping.", pInput, oModule.GetType.Name) @@ -101,6 +103,16 @@ Public Class Patterns2 Return oResult End Function + Public Function ReplaceFileValues(pInput As String, pFileInfo As FileInfo) As String + Dim oResult = pInput + + Dim oModule = GetModule(Of Modules.User)() + Dim oArgs = GetReplaceMapForModule(oModule, pFileInfo:=pFileInfo) + oResult = DoReplaceForModule(oResult, oModule, oArgs) + + Return oResult + End Function + Public Function ReplaceControlValues(pInput As String, pPanel As Panel) As String Dim oResult = pInput @@ -135,16 +147,18 @@ Public Class Patterns2 Return oResult End Function - Public Function ReplaceGlobixValues(pInput As String) As String + Public Function ReplaceGlobixValues(pInput As String, pGlobixIndexes As Dictionary(Of String, List(Of String))) As String Dim oResult = pInput Dim oGlobixModule = GetModule(Of Modules.Globix)() - Dim oGlobixArgs = GetReplaceMapForModule(oGlobixModule) + Dim oGlobixArgs = GetReplaceMapForModule(oGlobixModule, pGlobixIndexes:=pGlobixIndexes) oResult = DoReplaceForModule(oResult, oGlobixModule, oGlobixArgs) Return oResult End Function + + Private Function DoReplaceForModule(pInput As String, pModule As IModule, pArgs As Dictionary(Of String, Object)) As String Try pInput = pModule.Replace(pInput, pArgs) @@ -166,7 +180,8 @@ Public Class Patterns2 Optional pPanel As Panel = Nothing, Optional pUser As State.UserState = Nothing, Optional pWMObject As WMObject = Nothing, - Optional pGlobixIndexes As Dictionary(Of String, List(Of String)) = Nothing + Optional pGlobixIndexes As Dictionary(Of String, List(Of String)) = Nothing, + Optional pFileInfo As FileInfo = Nothing ) As Dictionary(Of String, Object) Dim oArgs As New Dictionary(Of String, Object) @@ -177,12 +192,9 @@ Public Class Patterns2 Logger.Error(ex) End Try - ElseIf TypeOf pModule Is Modules.Internal Then + ElseIf TypeOf pModule Is Modules.FileInformation Then Try - oArgs.Add(Patterns.Modules.Internal.INT_VALUE_USERNAME, System.Environment.UserName) - oArgs.Add(Patterns.Modules.Internal.INT_VALUE_MACHINE, System.Environment.MachineName) - oArgs.Add(Patterns.Modules.Internal.INT_VALUE_DOMAIN, System.Environment.UserDomainName) - oArgs.Add(Patterns.Modules.Internal.INT_VALUE_DATE, Now.ToShortDateString) + oArgs.Add(Patterns.Modules.FileInformation.FILE_VALUE_FILEINFO, pFileInfo) Catch ex As Exception Logger.Error(ex) End Try diff --git a/Modules.ZooFlow/State/UserState.vb b/Modules.ZooFlow/State/UserState.vb index 728d5965..f2305ae9 100644 --- a/Modules.ZooFlow/State/UserState.vb +++ b/Modules.ZooFlow/State/UserState.vb @@ -32,12 +32,11 @@ Namespace State End Sub ''' - ''' Initialize user object with user id. Mandatory for sending user data between systems. + ''' Initialize user object with user name. Mandatory for sending user data between systems. ''' - ''' - Public Sub New(pUserId As Integer) + Public Sub New(pUserName As String) MyBase.New() - UserId = pUserId + UserName = pUserName End Sub End Class End Namespace diff --git a/Service.EDMIService/BaseClass.vb b/Service.EDMIService/BaseClass.vb index 92377d5e..b574765e 100644 --- a/Service.EDMIService/BaseClass.vb +++ b/Service.EDMIService/BaseClass.vb @@ -8,4 +8,14 @@ Public Class BaseClass LogConfig = pLogConfig Logger = pLogConfig.GetLogger() End Sub + + Public Sub LogAndThrow(pMessage As String) + Logger.Warn(pMessage) + Throw New ApplicationException(pMessage) + End Sub + + Public Sub LogAndThrow(pException As Exception, pMessage As String) + Logger.Error(pException) + Throw New ApplicationException(pMessage, pException) + End Sub End Class diff --git a/Service.EDMIService/BaseMethod.vb b/Service.EDMIService/BaseMethod.vb index e09a29c4..f6ea8ad3 100644 --- a/Service.EDMIService/BaseMethod.vb +++ b/Service.EDMIService/BaseMethod.vb @@ -15,14 +15,4 @@ Public MustInherit Class BaseMethod Helpers = New Helpers(pLogConfig, pMSSQLServer) GlobalState = pGlobalState End Sub - - Public Sub LogAndThrow(pMessage As String) - Logger.Warn(pMessage) - Throw New ApplicationException(pMessage) - End Sub - - Public Sub LogAndThrow(pException As Exception, pMessage As String) - Logger.Error(pException) - Throw New ApplicationException(pMessage, pException) - End Sub End Class diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj index 3d39f8f4..67fa652f 100644 --- a/Service.EDMIService/EDMIService.vbproj +++ b/Service.EDMIService/EDMIService.vbproj @@ -138,9 +138,14 @@ + + + + + @@ -245,6 +250,10 @@ {7c3b0c7e-59fe-4e1a-a655-27ae119f9444} Patterns + + {81cac44f-3711-4c8f-ae98-e02a7448782a} + ZooFlow + diff --git a/Service.EDMIService/GlobalState.vb b/Service.EDMIService/GlobalState.vb index fdab4321..8897fc96 100644 --- a/Service.EDMIService/GlobalState.vb +++ b/Service.EDMIService/GlobalState.vb @@ -1,4 +1,6 @@ -Imports DigitalData.Modules.Database +Imports System.Data.SqlClient +Imports DigitalData.Modules.Database +Imports DigitalData.Modules.Language Imports DigitalData.Modules.Logging Public Class GlobalState @@ -8,6 +10,7 @@ Public Class GlobalState Private ReadOnly _MSSQL_ECM As MSSQLServer Public Property ObjectStores As New List(Of ObjectStore) + Public Property Connections As New List(Of DatabaseConnection) Public Property TableStore As New DataSet @@ -18,8 +21,33 @@ Public Class GlobalState _MSSQL_ECM = MSSQL_ECM End Sub + Public Function GetObjectStore(pName As String) As ObjectStore + Return ObjectStores. + Where(Function(store) store.Title.ToUpper = pName.ToUpper). + FirstOrDefault() + End Function + + Public Function GetConnection(pConnectionId As Long) As DatabaseConnection + Return Connections. + Where(Function(conn) conn.Id = pConnectionId). + FirstOrDefault() + End Function + + Public Function GetConnectionString(pConnectionId As Long) As String + Dim oConnection = GetConnection(pConnectionId) + Dim oBuilder As New SqlConnectionStringBuilder With { + .DataSource = oConnection.Server, + .InitialCatalog = oConnection.Database, + .UserID = oConnection.Username, + .Password = MSSQLServer.DecryptConnectionString(oConnection.Password) + } + + Return oBuilder.ToString + End Function + + Public Sub LoadObjectStores() - _Logger.Debug("Loading Object Stores") + _Logger.Info("Loading Object Stores") Try Dim oSQL As String = "SELECT * FROM VWIDB_OBJECTSTORE" Dim oDatatable As DataTable = _MSSQL_IDB.GetDatatable(oSQL) @@ -43,11 +71,34 @@ Public Class GlobalState End Try End Sub - Public Function GetObjectStore(Name As String) As ObjectStore - Return ObjectStores. - Where(Function(o) o.Title.ToUpper = Name.ToUpper). - FirstOrDefault() - End Function + Public Sub LoadConnections() + _Logger.Info("Loading Database Connections") + Try + Dim oSQL As String = "SELECT * FROM TBDD_CONNECTION" + Dim oDatatable As DataTable = _MSSQL_ECM.GetDatatable(oSQL) + + Connections.Clear() + + _Logger.Info("Found [{0}] Connections", oDatatable.Rows.Count) + + For Each oRow As DataRow In oDatatable.Rows + Dim oConnection As New DatabaseConnection() With { + .Id = oRow.ItemEx(Of Integer)("GUID"), + .Active = oRow.ItemEx(Of Boolean)("AKTIV"), + .Database = oRow.ItemEx(Of String)("DATENBANK"), + .Title = oRow.ItemEx(Of String)("BEZEICHNUNG"), + .Password = oRow.ItemEx(Of String)("PASSWORD"), + .Provider = oRow.ItemEx(Of String)("SQL_PROVIDER"), + .Server = oRow.ItemEx(Of String)("SERVER"), + .Username = oRow.ItemEx(Of String)("USERNAME") + } + _Logger.Info("New Connection [{0}]", oConnection.Title) + Connections.Add(oConnection) + Next + Catch ex As Exception + _Logger.Error(ex) + End Try + End Sub Class ObjectStore Public Id As Long @@ -55,4 +106,15 @@ Public Class GlobalState Public IsArchive As Boolean Public Path As String End Class + + Class DatabaseConnection + Public Id As Long + Public Title As String + Public Provider As String + Public Server As String + Public Database As String + Public Username As String + Public Password As String + Public Active As Boolean + End Class End Class diff --git a/Service.EDMIService/Methods/FileProperties.vb b/Service.EDMIService/Methods/FileProperties.vb index 4ea8a239..6682d748 100644 --- a/Service.EDMIService/Methods/FileProperties.vb +++ b/Service.EDMIService/Methods/FileProperties.vb @@ -37,6 +37,12 @@ Namespace Methods ''' Public Property FileChecksum As String + + ''' + ''' The Raw FileInfo Object + ''' + + Public Property FileInfoRaw As IO.FileInfo End Class End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/GlobalIndexer/AutomaticIndex.vb b/Service.EDMIService/Methods/GlobalIndexer/AutomaticIndex.vb new file mode 100644 index 00000000..b9fe5c42 --- /dev/null +++ b/Service.EDMIService/Methods/GlobalIndexer/AutomaticIndex.vb @@ -0,0 +1,8 @@ +Namespace Methods.GlobalIndexer + Public Class AutomaticIndex + Inherits BaseIndex + + Public Value As String + End Class + +End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/GlobalIndexer/BaseIndex.vb b/Service.EDMIService/Methods/GlobalIndexer/BaseIndex.vb new file mode 100644 index 00000000..f9195271 --- /dev/null +++ b/Service.EDMIService/Methods/GlobalIndexer/BaseIndex.vb @@ -0,0 +1,21 @@ +Namespace Methods.GlobalIndexer + Public MustInherit Class BaseIndex + Public Id As Integer + Public Name As String + Public ProfileId As Integer + + Public SQLCommand As String + Public SQLConnectionId As Integer + + Public Sequence As Integer = 0 + + Public Function HasSqlCommand() As Boolean + Return Not ( + SQLCommand Is Nothing OrElse + SQLCommand = String.Empty OrElse + SQLConnectionId < 0 + ) + End Function + End Class + +End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb index c05449b2..1d6e98b0 100644 --- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb @@ -12,8 +12,8 @@ Namespace Methods.GlobalIndexer.ImportFile Private ReadOnly GetDatatable As GetDatatableFromCacheMethod Private Profile As DataRow - Private ManualIndexes As DataTable - Private AutomaticIndexes As DataTable + Private ManualIndexes As List(Of ManualIndex) + Private AutomaticIndexes As List(Of AutomaticIndex) Private ManualIndexesPostProcessing As DataTable Private Const VIEW_PROFILE = "VWGI_DOCTYPE_IDB" @@ -21,10 +21,6 @@ Namespace Methods.GlobalIndexer.ImportFile Private Const VIEW_INDEX_AUTOMATIC = "VWDDINDEX_AUTOM" Private Const TABLE_POST_PROCESSING = "TBDD_INDEX_MAN_POSTPROCESSING" - Private Const TYPE_VBSPLIT = "VBSPLIT" - Private Const TYPE_VBREPLACE = "VBREPLACE" - Private Const TYPE_REGEXPRESSION = "REG. EXPRESSION" - Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer, pGlobalState As GlobalState) MyBase.New(pLogConfig, pMSSQLServer, pGlobalState) @@ -42,17 +38,25 @@ Namespace Methods.GlobalIndexer.ImportFile ''' Public Function Run(pData As ImportFileRequest) Try + ' TODO: Add missing user properties in UserState from TBDD_USER + 'pData.User = ResolveUserFromUserName(pData.User.UserName) + LoadIndexes(pData.ProfileId) LoadProfile(pData.ProfileId) + Dim oFinalAttributes = pData.AttributeValues Dim oFileName As String = GetFilenameByNameconvention(pData.File.FileName, Profile.Item("NAMENKONVENTION")) - ' apply the post processing - oFinalAttributes = ApplyManualPostprocessing(oFinalAttributes, ManualIndexesPostProcessing) + ' Apply post processing + Dim oPostProcessing = New Steps.PostProcessing(LogConfig, ManualIndexesPostProcessing) + oFinalAttributes = oPostProcessing.ApplyManualPostprocessing(oFinalAttributes) - ' TODO: apply the manual attributes - oFinalAttributes = ApplyAutomaticeAttributes(oFinalAttributes) + ' Apply automatic attributes + Dim oAutomaticIndexing = New Steps.AutomaticIndexing(LogConfig, Database, AutomaticIndexes, GlobalState) + + + oFinalAttributes = oAutomaticIndexing.ApplyAutomaticeAttributes(oFinalAttributes, pData.File.FileInfoRaw, pData.User) ' Import the file Dim oNewFile As New NewFileMethod(LogConfig, Database, GlobalState) @@ -60,9 +64,8 @@ Namespace Methods.GlobalIndexer.ImportFile .File = pData.File, .BusinessEntity = pData.BusinessEntity, .KindType = pData.KindType, - .Language = pData.Language, - .Who = pData.Who, - .StoreName = pData.StoreName + .StoreName = pData.StoreName, + .User = pData.User }) If oResponse.OK Then @@ -76,95 +79,12 @@ Namespace Methods.GlobalIndexer.ImportFile End Try End Function - Private Function ApplyManualPostprocessing(pManualAttributes As List(Of UserAttributeValue), pPostprocessingSteps As DataTable) As List(Of UserAttributeValue) - Logger.Debug("Start of Method [ApplyManualPostprocessing]") - Dim oAttributes = pManualAttributes - For Each oProcessingRow As DataRow In pPostprocessingSteps.Rows - - Dim oIndexId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID") - Dim oIndexRow As DataRow = ManualIndexes.Select($"GUID = {oIndexId}").FirstOrDefault() - Dim oIndex As UserAttributeValue = pManualAttributes. - Where(Function(attr) attr.AttributeId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")). - FirstOrDefault() - - Dim oValue = GetPostprocessingValue(oIndex.AttributeValues, oIndexRow) - - oAttributes.Add(New UserAttributeValue With { - .AttributeId = oIndexId, - .AttributeName = oIndex.AttributeName, - .AttributeValues = oIndex.AttributeValues, - .ControlName = oIndex.ControlName - }) - Next - - Return oAttributes - End Function - - Private Function ApplyAutomaticeAttributes(pManualAttributes As List(Of UserAttributeValue)) As List(Of UserAttributeValue) - Logger.Debug("Start of Method [ApplyAutomaticeAttributes]") - - Return pManualAttributes - End Function - - Private Function GetPostprocessingValue(pValues As List(Of String), pRow As DataRow) - Logger.Debug("Start of Method [GetPostprocessingValue]") - - Dim oType = pRow.Item("TYPE") - Dim oResult As New List(Of String) - - Logger.Debug("Type of Postprocessing is [{0}]", oType) - - Select Case oType - Case TYPE_VBREPLACE - Dim oFindString = pRow.Item("TEXT1") - Dim oReplaceString = pRow.Item("TEXT2") - - Logger.Debug("Replacing [{0}] with [{1}]", oFindString, oReplaceString) - - For Each oIndexValue In pValues - Dim oReplaceResult = oIndexValue.Replace(oFindString, oReplaceString) - If oReplaceResult.Equals(oIndexValue) Then - Logger.Debug("Replace did not succeed, ReplaceString was not found.") - Else - Logger.Debug("Replace successful for [{0}].", oIndexValue) - End If - - oResult.Add(oReplaceResult) - Next - - Case TYPE_VBSPLIT - Dim oSeparator As String = pRow.Item("TEXT1") - Dim oSplitIndex As Integer = 0 - Integer.TryParse(pRow.Item("TEXT2"), oSplitIndex) - - Logger.Debug("Splitting String at Separator [{0}] and Index [{1}]", oSeparator, oSplitIndex) - - For Each oIndexValue In pValues - Dim oSplitted As List(Of String) = oIndexValue.Split(oSeparator).ToList() - Logger.Debug("Split succeeded, resulting list has [{0}] items.", oSplitted.Count) - - If oSplitIndex < oSplitted.Count Then - Dim oValue = oSplitted.Item(oSplitIndex) - Logger.Debug("Saving value [{0}] from Index [{1}]", oValue, oSplitIndex) - oResult.Add(oValue) - Else - Logger.Debug("SplitIndex(TEXT2) was out of array bounds. Skipping.") - End If - - Next - - Case Else - LogAndThrow($"Postprocessing type [{oType}] is not supported!") - End Select - - Return oResult - End Function - - Private Function GetFilenameByNameconvention(pFileName As String, pNameconvention As String) As String + Private Function GetFilenameByNameconvention(pFileName As String, pNameconvention As String) As String + Return pFileName End Function Private Sub LoadIndexes(pProfileId As Integer) @@ -213,7 +133,21 @@ Namespace Methods.GlobalIndexer.ImportFile LogAndThrow(oAutomaticIndexes.ErrorMessage) End If - AutomaticIndexes = oAutomaticIndexes.Table + Dim oIndexes As New List(Of AutomaticIndex) + + For Each oRow As DataRow In oAutomaticIndexes.Table.Rows + Dim oAutomaticIndex As New AutomaticIndex With { + .Id = oRow.ItemEx(Of Integer)("GUID"), + .Name = oRow.ItemEx(Of String)("INDEXNAME"), + .ProfileId = oRow.ItemEx(Of Integer)("DOCTYPE_ID"), + .SQLCommand = oRow.ItemEx(Of String)("SQL_RESULT"), + .SQLConnectionId = oRow.ItemEx(Of Integer)("CONNECTION_ID"), + .Sequence = oRow.ItemEx(Of String)("SEQUENCE"), + .Value = oRow.ItemEx(Of String)("VALUE") + } + Next + + AutomaticIndexes = oIndexes Catch ex As Exception LogAndThrow(ex, "Error while automatic loading indexes!") End Try @@ -234,7 +168,23 @@ Namespace Methods.GlobalIndexer.ImportFile LogAndThrow(oManualIndexes.ErrorMessage) End If - ManualIndexes = oManualIndexes.Table + Dim oIndexes As New List(Of ManualIndex) + + For Each oRow As DataRow In oManualIndexes.Table.Rows + Dim oManualIndex As New ManualIndex With { + .Id = oRow.ItemEx(Of Integer)("GUID"), + .Name = oRow.ItemEx(Of String)("INDEXNAME"), + .ProfileId = oRow.ItemEx(Of Integer)("DOCTYPE_ID"), + .IsOptional = oRow.ItemEx(Of Boolean)("OPTIONAL"), + .IsMultiselect = oRow.ItemEx(Of String)("MULTISELECT"), + .SQLCommand = oRow.ItemEx(Of String)("SQL_RESULT"), + .SQLConnectionId = oRow.ItemEx(Of Integer)("CONNECTION_ID"), + .DefaultValue = oRow.ItemEx(Of String)("DEFAULT_VALUE"), + .DataType = oRow.ItemEx(Of String)("DATA_TYPE") + } + Next + + ManualIndexes = oIndexes Catch ex As Exception LogAndThrow(ex, "Error while loading indexes!") @@ -246,10 +196,7 @@ Namespace Methods.GlobalIndexer.ImportFile Try ' Generate a string containing all index ids joined into a string - Dim oIndexIdList As New List(Of Integer) - For Each oRow As DataRow In ManualIndexes.Rows - oIndexIdList.Add(oRow.ItemEx(Of Integer)("GUID")) - Next + Dim oIndexIdList As List(Of Integer) = ManualIndexes.Select(Function(index) index.Id).ToList() Dim oIndexIds As String = String.Join(",", oIndexIdList) ' Load all relevant postprocessing steps diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb index 6c17c4ab..1dac0f51 100644 --- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb @@ -1,4 +1,5 @@ Imports System.Runtime.Serialization +Imports DigitalData.Modules.ZooFlow.State Namespace Methods.GlobalIndexer.ImportFile @@ -13,6 +14,7 @@ Namespace Methods.GlobalIndexer.ImportFile ''' ''' The ProfileId the file will be imported with ''' + Public Property ProfileId As Integer ''' @@ -37,18 +39,14 @@ Namespace Methods.GlobalIndexer.ImportFile ''' The attribute values given by the user in the form of ''' Attribute Name/Attribute Value/ControlName ''' + Public Property AttributeValues As List(Of UserAttributeValue) ''' - ''' The name of the user importing the file, ex. JenneJ + ''' User Importing the file ''' + ''' - Public Property Who As String - - ''' - ''' The language of the user, ex. de-DE - ''' - - Public Property Language As String + Public Property User As UserState End Class End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb new file mode 100644 index 00000000..44358440 --- /dev/null +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb @@ -0,0 +1,85 @@ +Imports System.IO +Imports DigitalData.Modules.Database +Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.Patterns +Imports DigitalData.Modules.ZooFlow.State +Imports DigitalData.Services.EDMIService.GlobalState + +Namespace Methods.GlobalIndexer.ImportFile.Steps + Public Class AutomaticIndexing + Inherits BaseClass + + Private ReadOnly GlobalState As GlobalState + Private ReadOnly AutomaticIndexes As List(Of AutomaticIndex) + Private ReadOnly Patterns As Patterns2 + Private ReadOnly Database As MSSQLServer + + Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pAutomaticIndexes As List(Of AutomaticIndex), pGlobalState As GlobalState) + MyBase.New(pLogConfig) + Database = pDatabase + GlobalState = pGlobalState + AutomaticIndexes = pAutomaticIndexes + Patterns = New Patterns2(pLogConfig) + End Sub + + Public Function ApplyAutomaticeAttributes(pManualAttributes As List(Of UserAttributeValue), pFileInfo As FileInfo, pUserState As UserState) As List(Of UserAttributeValue) + Logger.Debug("Start of Method [ApplyAutomaticeAttributes]") + Dim oAttributes = pManualAttributes + + For Each oAutomaticIndex In AutomaticIndexes + ' We add oAttributes from the previous run into the current run so it is in theory possible to reference + ' automatic attributes which have been set just before. + Dim oAttribute = ApplyAutomaticIndex(oAutomaticIndex, pFileInfo, pUserState, oAttributes) + oAttributes.Add(oAttribute) + Next + + Return oAttributes + End Function + + + Private Function ApplyAutomaticIndex(pAutomaticIndex As AutomaticIndex, pFileInfo As FileInfo, pUserState As UserState, pAttributes As List(Of UserAttributeValue)) As UserAttributeValue + Dim oAttributeDict = pAttributes.ToDictionary( + Function(attr) attr.AttributeName, + Function(attr) attr.AttributeValues) + + ' If there is no SQL command, we use the Value property and replace all placeholders in it. + If pAutomaticIndex.HasSqlCommand = False Then + Dim oResult As String = GetPlaceholderValue(pAutomaticIndex.Value, pFileInfo, pUserState, oAttributeDict) + + Return New UserAttributeValue With { + .AttributeValues = New List(Of String) From {oResult}, + .AttributeName = pAutomaticIndex.Name, + .AttributeId = pAutomaticIndex.Id + } + End If + + ' Otherwise we will replace placeholders in the SQL command and then execute it + Dim oConnectionString As String = GlobalState.GetConnectionString(pAutomaticIndex.SQLConnectionId) + Dim oFinalSQLCommand = pAutomaticIndex.SQLCommand + oFinalSQLCommand = GetPlaceholderValue(oFinalSQLCommand, pFileInfo, pUserState, oAttributeDict) + + ' Now we have a SQL command which only contains vector placeholders + ' Next, we execute the command to get our result + Dim oValue = Database.GetScalarValueWithConnection(oFinalSQLCommand, oConnectionString) + + ' TODO: Return multiple values + Return New UserAttributeValue With { + .AttributeValues = New List(Of String) From {oValue}, + .AttributeName = pAutomaticIndex.Name, + .AttributeId = pAutomaticIndex.Id + } + End Function + + Private Function GetPlaceholderValue(pValue As String, pFileInfo As FileInfo, pUserState As UserState, pAttributes As Dictionary(Of String, List(Of String))) As String + Dim oResult As String = pValue + + oResult = Patterns.ReplaceInternalValues(oResult) + oResult = Patterns.ReplaceFileValues(oResult, pFileInfo) + oResult = Patterns.ReplaceUserValues(oResult, pUserState) + oResult = Patterns.ReplaceGlobixValues(oResult, pAttributes) + + Return oResult + End Function + End Class + +End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/PostProcessing.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/PostProcessing.vb new file mode 100644 index 00000000..86930694 --- /dev/null +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/PostProcessing.vb @@ -0,0 +1,98 @@ +Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.Language + +Namespace Methods.GlobalIndexer.ImportFile.Steps + Public Class PostProcessing + Inherits BaseClass + + Public Const TYPE_VBSPLIT = "VBSPLIT" + Public Const TYPE_VBREPLACE = "VBREPLACE" + Public Const TYPE_REGEXPRESSION = "REG. EXPRESSION" + + Private PostprocessingSteps As DataTable + + Public Sub New(pLogConfig As LogConfig, pPostProcessingSteps As DataTable) + MyBase.New(pLogConfig) + PostprocessingSteps = pPostProcessingSteps + End Sub + + Public Function ApplyManualPostprocessing(pManualAttributes As List(Of UserAttributeValue)) As List(Of UserAttributeValue) + Logger.Debug("Start of Method [ApplyManualPostprocessing]") + Dim oAttributes = pManualAttributes + + For Each oProcessingRow As DataRow In PostprocessingSteps.Rows + + Dim oIndexId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID") + Dim oIndex As UserAttributeValue = pManualAttributes. + Where(Function(attr) attr.AttributeId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")). + FirstOrDefault() + + Dim oValue = GetPostprocessingValue(oIndex.AttributeValues, oProcessingRow) + + oAttributes.Add(New UserAttributeValue With { + .AttributeId = oIndexId, + .AttributeName = oIndex.AttributeName, + .AttributeValues = oIndex.AttributeValues, + .ControlName = oIndex.ControlName + }) + Next + + Return oAttributes + End Function + + Public Function GetPostprocessingValue(pValues As List(Of String), pRow As DataRow) + Logger.Debug("Start of Method [GetPostprocessingValue]") + + Dim oType = pRow.Item("TYPE") + Dim oResult As New List(Of String) + + Logger.Debug("Type of Postprocessing is [{0}]", oType) + + Select Case oType + Case TYPE_VBREPLACE + Dim oFindString = pRow.Item("TEXT1") + Dim oReplaceString = pRow.Item("TEXT2") + + Logger.Debug("Replacing [{0}] with [{1}]", oFindString, oReplaceString) + + For Each oIndexValue In pValues + Dim oReplaceResult = oIndexValue.Replace(oFindString, oReplaceString) + If oReplaceResult.Equals(oIndexValue) Then + Logger.Debug("Replace did not succeed, ReplaceString was not found.") + Else + Logger.Debug("Replace successful for [{0}].", oIndexValue) + End If + + oResult.Add(oReplaceResult) + Next + + Case TYPE_VBSPLIT + Dim oSeparator As String = pRow.Item("TEXT1") + Dim oSplitIndex As Integer = 0 + Integer.TryParse(pRow.Item("TEXT2"), oSplitIndex) + + Logger.Debug("Splitting String at Separator [{0}] and Index [{1}]", oSeparator, oSplitIndex) + + For Each oIndexValue In pValues + Dim oSplitted As List(Of String) = oIndexValue.Split(oSeparator).ToList() + Logger.Debug("Split succeeded, resulting list has [{0}] items.", oSplitted.Count) + + If oSplitIndex < oSplitted.Count Then + Dim oValue = oSplitted.Item(oSplitIndex) + Logger.Debug("Saving value [{0}] from Index [{1}]", oValue, oSplitIndex) + oResult.Add(oValue) + Else + Logger.Debug("SplitIndex(TEXT2) was out of array bounds. Skipping.") + End If + + Next + + Case Else + LogAndThrow($"Postprocessing type [{oType}] is not supported!") + End Select + + Return oResult + End Function + End Class + +End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/GlobalIndexer/ManualIndex.vb b/Service.EDMIService/Methods/GlobalIndexer/ManualIndex.vb new file mode 100644 index 00000000..a2976d05 --- /dev/null +++ b/Service.EDMIService/Methods/GlobalIndexer/ManualIndex.vb @@ -0,0 +1,12 @@ +Namespace Methods.GlobalIndexer + Public Class ManualIndex + Inherits BaseIndex + + Public DataType As String + + Public IsOptional As Boolean + Public IsMultiselect As Boolean + + Public DefaultValue As String + End Class +End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/NewFile/NewFileMethod.vb b/Service.EDMIService/Methods/NewFile/NewFileMethod.vb index 327072e9..00324f53 100644 --- a/Service.EDMIService/Methods/NewFile/NewFileMethod.vb +++ b/Service.EDMIService/Methods/NewFile/NewFileMethod.vb @@ -28,7 +28,7 @@ Public Class NewFileMethod Try - Dim oObjectId = NewObjectId(pData.KindType, pData.BusinessEntity, pData.Who) + Dim oObjectId = NewObjectId(pData.KindType, pData.BusinessEntity, pData.User.UserName) If oObjectId = 0 Then LogAndThrow("Could not create new ObjectId!") End If @@ -107,7 +107,16 @@ Public Class NewFileMethod Logger.Info("Creating IDB FileObject for ObjectId [{0}].", oObjectId) ' Insert into DB - Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{oFinalPath}', '{oFileObjectName}', '{oFileObjectExtension}',{oFileObjectSize},'{pData.File.FileChecksum}' ,'{pData.Who}','{oObjectId}',{oStore.Id}" + Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO + '{oFinalPath}', + '{oFileObjectName}', + '{oFileObjectExtension}', + {oFileObjectSize}, + '{pData.File.FileChecksum}' , + '{pData.User.UserName}', + '{oObjectId}', + {oStore.Id}" + Dim oResult As Boolean = Database.ExecuteNonQueryWithConnectionObject(oSQL, Connection, ExternalTransaction, Transaction) If oResult = False Then @@ -131,7 +140,7 @@ Public Class NewFileMethod Continue For End If - Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, oObjectId, oAttribute.Key, oAttribute.Value, "de-DE", pData.Who) + Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, oObjectId, oAttribute.Key, oAttribute.Value, pData.User.Language, pData.User.UserName) If oSuccess Then Logger.Debug("Default Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value) Else diff --git a/Service.EDMIService/Methods/NewFile/NewFileRequest.vb b/Service.EDMIService/Methods/NewFile/NewFileRequest.vb index 27fd1bb3..8e35ca9d 100644 --- a/Service.EDMIService/Methods/NewFile/NewFileRequest.vb +++ b/Service.EDMIService/Methods/NewFile/NewFileRequest.vb @@ -1,4 +1,5 @@ Imports System.Runtime.Serialization +Imports DigitalData.Modules.ZooFlow.State Namespace Methods.NewFile @@ -26,17 +27,11 @@ Namespace Methods.NewFile Public Property KindType As String ''' - ''' The name of the user importing the file, ex. JenneJ - ''' - - Public Property Who As String - - ''' - ''' The language of the user + ''' User Importing the file ''' ''' - Public Property Language As String + Public Property User As UserState End Class End Namespace diff --git a/Service.EDMIService/WindowsService.vb b/Service.EDMIService/WindowsService.vb index b7d000d9..47b0cf36 100644 --- a/Service.EDMIService/WindowsService.vb +++ b/Service.EDMIService/WindowsService.vb @@ -73,8 +73,9 @@ Public Class WindowsService _Global = New GlobalState(_LogConfig, _MSSQL_IDB, _MSSQL_ECM) _Scheduler = New Scheduler(_LogConfig, _MSSQL_ECM, _Global.TableStore) - _Logger.Debug("Loading Objectstores") + _Logger.Debug("Loading Global Data") _Global.LoadObjectStores() + _Global.LoadConnections() _Logger.Debug("Starting Scheduler") _Scheduler.Start()