File Container, Prepare Import for Marvman

This commit is contained in:
Jonathan Jenne 2019-03-01 15:52:00 +01:00
parent cfbcd8a8f2
commit 6f0164d010
24 changed files with 496 additions and 306 deletions

View File

@ -61,7 +61,7 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ClientSuite", "EDMI_ClientS
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDEDMService", "SERVICES\DDEDM_NetworkService\DDEDMService.vbproj", "{A8C3F298-76AB-4359-AB3C-986E313B4336}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EDMIFileOps", "EDMI_FILE_OPs\EDMIFileOps.vbproj", "{5B1171DC-FFFE-4813-A20D-786AAE47B320}"
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EDMIAPI", "EDMI_FILE_OPs\EDMIAPI.vbproj", "{5B1171DC-FFFE-4813-A20D-786AAE47B320}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DDEDMLicenseService", "DDLicenseService\DDEDMLicenseService.vbproj", "{CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C}"
EndProject

View File

@ -368,9 +368,9 @@
<Project>{44982F9B-6116-44E2-85D0-F39650B1EF99}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\EDMI_FILE_OPs\EDMIFileOps.vbproj">
<ProjectReference Include="..\EDMI_FILE_OPs\EDMIAPI.vbproj">
<Project>{5b1171dc-fffe-4813-a20d-786aae47b320}</Project>
<Name>EDMIFileOps</Name>
<Name>EDMIAPI</Name>
</ProjectReference>
<ProjectReference Include="..\Filesystem\Filesystem.vbproj">
<Project>{991d0231-4623-496d-8bd0-9ca906029cbc}</Project>

View File

@ -1,8 +1,10 @@
Imports DigitalData.Modules.EDMIFileOps
Imports System.IO
Imports DigitalData.Modules.EDMIFileOps
Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Logging
Public Class frmFileTest
Private _fileOp As FileOp
Private _fileOp As Document
Private _Logger As Logger
Public Sub New()
@ -13,7 +15,7 @@ Public Class frmFileTest
Private Sub frmFileTest_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
_fileOp = New FileOp(My.LogConfig, My.Settings.EDM_NetworkService_Adress)
_fileOp = New Document(My.LogConfig, My.Settings.EDM_NetworkService_Adress)
Catch ex As Exception
_Logger.Warn($"Unexpected error in frmFileTest_Load: {ex.Message}")
@ -27,9 +29,19 @@ Public Class frmFileTest
If oResult <> DialogResult.OK Then
Exit Sub
End If
Dim oFileID = Await _fileOp.New_EDMI_File(oDialog.FileName, Environment.UserName)
MsgBox(oFileID)
ListBox1.Items.Add(oFileID)
Try
Dim oDocObject = Await _fileOp.ImportFileAsync(oDialog.FileName)
If oDocObject.OK = False Then
MsgBox(oDocObject.ErrorMessage)
Exit Sub
End If
ListBox1.Items.Add(oDocObject)
Catch ex As Exception
MsgBox(ex.Message)
_Logger.Error(ex)
End Try
End Sub
End Class

3
EDMI_FILE_OPs/Channel.vb Normal file
View File

@ -0,0 +1,3 @@
Public Class Channel
End Class

View File

@ -5,6 +5,6 @@
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="ContainerResult" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>DigitalData.Modules.EDMIFileOps.EDMIServiceReference.ContainerResult, Connected Services.EDMIServiceReference.Reference.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
<GenericObjectDataSource DisplayName="DocumentResult" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>DigitalData.Modules.EDMIFileOps.EDMIServiceReference.DocumentResult, Connected Services.EDMIServiceReference.Reference.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

View File

@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="FileContainerInner">
<xs:complexType name="DocumentObject">
<xs:sequence>
<xs:element name="Contents" nillable="true" type="xs:base64Binary" />
<xs:element name="CreatedAt" type="xs:dateTime" />
<xs:element name="Extension" nillable="true" type="xs:string" />
<xs:element name="FileId" nillable="true" type="xs:string" />
<xs:element name="UpdatedAt" type="xs:dateTime" />
<xs:element name="_ContainerId" nillable="true" type="xs:string" />
<xs:element name="_DocumentId" type="xs:long" />
<xs:element name="_FileName" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="FileContainerInner" nillable="true" type="tns:FileContainerInner" />
<xs:element name="DocumentObject" nillable="true" type="tns:DocumentObject" />
</xs:schema>

View File

@ -70,6 +70,12 @@
<wsdl:message name="IEDMService_DeleteFile_OutputMessage">
<wsdl:part name="parameters" element="tns:DeleteFileResponse" />
</wsdl:message>
<wsdl:message name="IEDMService_SetFileIndex_InputMessage">
<wsdl:part name="parameters" element="tns:SetFileIndex" />
</wsdl:message>
<wsdl:message name="IEDMService_SetFileIndex_OutputMessage">
<wsdl:part name="parameters" element="tns:SetFileIndexResponse" />
</wsdl:message>
<wsdl:portType name="IEDMService">
<wsdl:operation name="Heartbeat">
<wsdl:input wsaw:Action="http://DigitalData.Services.EDMService/IEDMService/Heartbeat" message="tns:IEDMService_Heartbeat_InputMessage" />
@ -111,5 +117,9 @@
<wsdl:input wsaw:Action="http://DigitalData.Services.EDMService/IEDMService/DeleteFile" message="tns:IEDMService_DeleteFile_InputMessage" />
<wsdl:output wsaw:Action="http://DigitalData.Services.EDMService/IEDMService/DeleteFileResponse" message="tns:IEDMService_DeleteFile_OutputMessage" />
</wsdl:operation>
<wsdl:operation name="SetFileIndex">
<wsdl:input wsaw:Action="http://DigitalData.Services.EDMService/IEDMService/SetFileIndex" message="tns:IEDMService_SetFileIndex_InputMessage" />
<wsdl:output wsaw:Action="http://DigitalData.Services.EDMService/IEDMService/SetFileIndexResponse" message="tns:IEDMService_SetFileIndex_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://DigitalData.Services.EDMService" elementFormDefault="qualified" targetNamespace="http://DigitalData.Services.EDMService" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMService" />
<xs:import namespace="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" />
<xs:element name="Heartbeat">
<xs:complexType>
<xs:sequence />
@ -83,22 +84,22 @@
<xs:element name="CreateFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="FileName" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="Contents" nillable="true" type="xs:base64Binary" />
<xs:element minOccurs="0" name="Extension" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CreateFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="CreateFileResult" nillable="true" type="xs:string" />
<xs:element xmlns:q4="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMService" minOccurs="0" name="CreateFileResult" nillable="true" type="q4:DocumentResult" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="UpdateFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ContainerId" nillable="true" type="xs:string" />
<xs:element xmlns:q5="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" minOccurs="0" name="DocObject" nillable="true" type="q5:DocumentObject" />
<xs:element minOccurs="0" name="Contents" nillable="true" type="xs:base64Binary" />
</xs:sequence>
</xs:complexType>
@ -106,28 +107,28 @@
<xs:element name="UpdateFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="UpdateFileResult" nillable="true" type="xs:string" />
<xs:element xmlns:q6="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMService" minOccurs="0" name="UpdateFileResult" nillable="true" type="q6:DocumentResult" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ContainerId" nillable="true" type="xs:string" />
<xs:element xmlns:q7="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" minOccurs="0" name="DocObject" nillable="true" type="q7:DocumentObject" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q4="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMService" minOccurs="0" name="GetFileResult" nillable="true" type="q4:ContainerResult" />
<xs:element xmlns:q8="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMService" minOccurs="0" name="GetFileResult" nillable="true" type="q8:DocumentResult" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DeleteFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ContainerId" nillable="true" type="xs:string" />
<xs:element xmlns:q9="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" minOccurs="0" name="DocObject" nillable="true" type="q9:DocumentObject" />
</xs:sequence>
</xs:complexType>
</xs:element>
@ -138,4 +139,20 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SetFileIndex">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q10="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" minOccurs="0" name="DocObject" nillable="true" type="q10:DocumentObject" />
<xs:element minOccurs="0" name="Syskey" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="Value" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="SetFileIndexResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="SetFileIndexResult" nillable="true" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -37,12 +37,14 @@
</xs:sequence>
</xs:complexType>
<xs:element name="NonQueryResult" nillable="true" type="tns:NonQueryResult" />
<xs:complexType name="ContainerResult">
<xs:complexType name="DocumentResult">
<xs:sequence>
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" name="Container" nillable="true" type="q1:FileContainerInner" />
<xs:element name="Contents" nillable="true" type="xs:base64Binary" />
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem" name="Document" nillable="true" type="q1:DocumentObject" />
<xs:element name="ErrorMessage" nillable="true" type="xs:string" />
<xs:element name="HasContents" type="xs:boolean" />
<xs:element name="OK" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
<xs:element name="ContainerResult" nillable="true" type="tns:ContainerResult" />
<xs:element name="DocumentResult" nillable="true" type="tns:DocumentResult" />
</xs:schema>

View File

@ -101,9 +101,9 @@ Namespace EDMIServiceReference
System.SerializableAttribute(), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.TableResult)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.NonQueryResult)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ContainerResult)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.DocumentResult)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(System.DBNull)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.FileContainerInner))> _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.DocumentObject))> _
Partial Public Class ScalarResult
Inherits Object
Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
@ -244,19 +244,23 @@ Namespace EDMIServiceReference
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.DataContractAttribute(Name:="ContainerResult", [Namespace]:="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMService"), _
System.Runtime.Serialization.DataContractAttribute(Name:="DocumentResult", [Namespace]:="http://schemas.datacontract.org/2004/07/DigitalData.Services.EDMService"), _
System.SerializableAttribute()> _
Partial Public Class ContainerResult
Partial Public Class DocumentResult
Inherits Object
Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
<System.NonSerializedAttribute()> _
Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
Private ContainerField As EDMIServiceReference.FileContainerInner
Private ContentsField() As Byte
Private DocumentField As EDMIServiceReference.DocumentObject
Private ErrorMessageField As String
Private HasContentsField As Boolean
Private OKField As Boolean
<Global.System.ComponentModel.BrowsableAttribute(false)> _
@ -270,14 +274,27 @@ Namespace EDMIServiceReference
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property Container() As EDMIServiceReference.FileContainerInner
Public Property Contents() As Byte()
Get
Return Me.ContainerField
Return Me.ContentsField
End Get
Set
If (Object.ReferenceEquals(Me.ContainerField, value) <> true) Then
Me.ContainerField = value
Me.RaisePropertyChanged("Container")
If (Object.ReferenceEquals(Me.ContentsField, value) <> true) Then
Me.ContentsField = value
Me.RaisePropertyChanged("Contents")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property Document() As EDMIServiceReference.DocumentObject
Get
Return Me.DocumentField
End Get
Set
If (Object.ReferenceEquals(Me.DocumentField, value) <> true) Then
Me.DocumentField = value
Me.RaisePropertyChanged("Document")
End If
End Set
End Property
@ -295,6 +312,19 @@ Namespace EDMIServiceReference
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property HasContents() As Boolean
Get
Return Me.HasContentsField
End Get
Set
If (Me.HasContentsField.Equals(value) <> true) Then
Me.HasContentsField = value
Me.RaisePropertyChanged("HasContents")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property OK() As Boolean
Get
@ -320,24 +350,20 @@ Namespace EDMIServiceReference
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.DataContractAttribute(Name:="FileContainerInner", [Namespace]:="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem"), _
System.Runtime.Serialization.DataContractAttribute(Name:="DocumentObject", [Namespace]:="http://schemas.datacontract.org/2004/07/DigitalData.Modules.Filesystem"), _
System.SerializableAttribute()> _
Partial Public Class FileContainerInner
Partial Public Class DocumentObject
Inherits Object
Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
<System.NonSerializedAttribute()> _
Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
Private ContentsField() As Byte
Private _ContainerIdField As String
Private CreatedAtField As Date
Private _DocumentIdField As Long
Private ExtensionField As String
Private FileIdField As String
Private UpdatedAtField As Date
Private _FileNameField As String
<Global.System.ComponentModel.BrowsableAttribute(false)> _
Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
@ -350,66 +376,40 @@ Namespace EDMIServiceReference
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property Contents() As Byte()
Public Property _ContainerId() As String
Get
Return Me.ContentsField
Return Me._ContainerIdField
End Get
Set
If (Object.ReferenceEquals(Me.ContentsField, value) <> true) Then
Me.ContentsField = value
Me.RaisePropertyChanged("Contents")
If (Object.ReferenceEquals(Me._ContainerIdField, value) <> true) Then
Me._ContainerIdField = value
Me.RaisePropertyChanged("_ContainerId")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property CreatedAt() As Date
Public Property _DocumentId() As Long
Get
Return Me.CreatedAtField
Return Me._DocumentIdField
End Get
Set
If (Me.CreatedAtField.Equals(value) <> true) Then
Me.CreatedAtField = value
Me.RaisePropertyChanged("CreatedAt")
If (Me._DocumentIdField.Equals(value) <> true) Then
Me._DocumentIdField = value
Me.RaisePropertyChanged("_DocumentId")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property Extension() As String
Public Property _FileName() As String
Get
Return Me.ExtensionField
Return Me._FileNameField
End Get
Set
If (Object.ReferenceEquals(Me.ExtensionField, value) <> true) Then
Me.ExtensionField = value
Me.RaisePropertyChanged("Extension")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property FileId() As String
Get
Return Me.FileIdField
End Get
Set
If (Object.ReferenceEquals(Me.FileIdField, value) <> true) Then
Me.FileIdField = value
Me.RaisePropertyChanged("FileId")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property UpdatedAt() As Date
Get
Return Me.UpdatedAtField
End Get
Set
If (Me.UpdatedAtField.Equals(value) <> true) Then
Me.UpdatedAtField = value
Me.RaisePropertyChanged("UpdatedAt")
If (Object.ReferenceEquals(Me._FileNameField, value) <> true) Then
Me._FileNameField = value
Me.RaisePropertyChanged("_FileName")
End If
End Set
End Property
@ -465,28 +465,40 @@ Namespace EDMIServiceReference
Function ExecuteNonQueryAsync(ByVal SQL As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.NonQueryResult)
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/CreateFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/CreateFileResponse")> _
Function CreateFile(ByVal Contents() As Byte, ByVal Extension As String) As String
Function CreateFile(ByVal FileName As String, ByVal Contents() As Byte) As EDMIServiceReference.DocumentResult
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/CreateFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/CreateFileResponse")> _
Function CreateFileAsync(ByVal Contents() As Byte, ByVal Extension As String) As System.Threading.Tasks.Task(Of String)
Function CreateFileAsync(ByVal FileName As String, ByVal Contents() As Byte) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult)
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/UpdateFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/UpdateFileResponse")> _
Function UpdateFile(ByVal ContainerId As String, ByVal Contents() As Byte) As String
Function UpdateFile(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Contents() As Byte) As EDMIServiceReference.DocumentResult
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/UpdateFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/UpdateFileResponse")> _
Function UpdateFileAsync(ByVal ContainerId As String, ByVal Contents() As Byte) As System.Threading.Tasks.Task(Of String)
Function UpdateFileAsync(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Contents() As Byte) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult)
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/GetFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/GetFileResponse")> _
Function GetFile(ByVal ContainerId As String) As EDMIServiceReference.ContainerResult
Function GetFile(ByVal DocObject As EDMIServiceReference.DocumentObject) As EDMIServiceReference.DocumentResult
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/GetFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/GetFileResponse")> _
Function GetFileAsync(ByVal ContainerId As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.ContainerResult)
Function GetFileAsync(ByVal DocObject As EDMIServiceReference.DocumentObject) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult)
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/DeleteFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/DeleteFileResponse")> _
Function DeleteFile(ByVal ContainerId As String) As Boolean
Function DeleteFile(ByVal DocObject As EDMIServiceReference.DocumentObject) As Boolean
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/DeleteFile", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/DeleteFileResponse")> _
Function DeleteFileAsync(ByVal ContainerId As String) As System.Threading.Tasks.Task(Of Boolean)
Function DeleteFileAsync(ByVal DocObject As EDMIServiceReference.DocumentObject) As System.Threading.Tasks.Task(Of Boolean)
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/SetFileIndex", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/SetFileIndexResponse"), _
System.ServiceModel.ServiceKnownTypeAttribute(GetType(EDMIServiceReference.TableResult)), _
System.ServiceModel.ServiceKnownTypeAttribute(GetType(EDMIServiceReference.ScalarResult)), _
System.ServiceModel.ServiceKnownTypeAttribute(GetType(EDMIServiceReference.NonQueryResult)), _
System.ServiceModel.ServiceKnownTypeAttribute(GetType(EDMIServiceReference.DocumentResult)), _
System.ServiceModel.ServiceKnownTypeAttribute(GetType(System.DBNull)), _
System.ServiceModel.ServiceKnownTypeAttribute(GetType(EDMIServiceReference.DocumentObject))> _
Function SetFileIndex(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal Value As String) As Object
<System.ServiceModel.OperationContractAttribute(Action:="http://DigitalData.Services.EDMService/IEDMService/SetFileIndex", ReplyAction:="http://DigitalData.Services.EDMService/IEDMService/SetFileIndexResponse")> _
Function SetFileIndexAsync(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal Value As String) As System.Threading.Tasks.Task(Of Object)
End Interface
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> _
@ -568,36 +580,44 @@ Namespace EDMIServiceReference
Return MyBase.Channel.ExecuteNonQueryAsync(SQL)
End Function
Public Function CreateFile(ByVal Contents() As Byte, ByVal Extension As String) As String Implements EDMIServiceReference.IEDMService.CreateFile
Return MyBase.Channel.CreateFile(Contents, Extension)
Public Function CreateFile(ByVal FileName As String, ByVal Contents() As Byte) As EDMIServiceReference.DocumentResult Implements EDMIServiceReference.IEDMService.CreateFile
Return MyBase.Channel.CreateFile(FileName, Contents)
End Function
Public Function CreateFileAsync(ByVal Contents() As Byte, ByVal Extension As String) As System.Threading.Tasks.Task(Of String) Implements EDMIServiceReference.IEDMService.CreateFileAsync
Return MyBase.Channel.CreateFileAsync(Contents, Extension)
Public Function CreateFileAsync(ByVal FileName As String, ByVal Contents() As Byte) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult) Implements EDMIServiceReference.IEDMService.CreateFileAsync
Return MyBase.Channel.CreateFileAsync(FileName, Contents)
End Function
Public Function UpdateFile(ByVal ContainerId As String, ByVal Contents() As Byte) As String Implements EDMIServiceReference.IEDMService.UpdateFile
Return MyBase.Channel.UpdateFile(ContainerId, Contents)
Public Function UpdateFile(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Contents() As Byte) As EDMIServiceReference.DocumentResult Implements EDMIServiceReference.IEDMService.UpdateFile
Return MyBase.Channel.UpdateFile(DocObject, Contents)
End Function
Public Function UpdateFileAsync(ByVal ContainerId As String, ByVal Contents() As Byte) As System.Threading.Tasks.Task(Of String) Implements EDMIServiceReference.IEDMService.UpdateFileAsync
Return MyBase.Channel.UpdateFileAsync(ContainerId, Contents)
Public Function UpdateFileAsync(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Contents() As Byte) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult) Implements EDMIServiceReference.IEDMService.UpdateFileAsync
Return MyBase.Channel.UpdateFileAsync(DocObject, Contents)
End Function
Public Function GetFile(ByVal ContainerId As String) As EDMIServiceReference.ContainerResult Implements EDMIServiceReference.IEDMService.GetFile
Return MyBase.Channel.GetFile(ContainerId)
Public Function GetFile(ByVal DocObject As EDMIServiceReference.DocumentObject) As EDMIServiceReference.DocumentResult Implements EDMIServiceReference.IEDMService.GetFile
Return MyBase.Channel.GetFile(DocObject)
End Function
Public Function GetFileAsync(ByVal ContainerId As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.ContainerResult) Implements EDMIServiceReference.IEDMService.GetFileAsync
Return MyBase.Channel.GetFileAsync(ContainerId)
Public Function GetFileAsync(ByVal DocObject As EDMIServiceReference.DocumentObject) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult) Implements EDMIServiceReference.IEDMService.GetFileAsync
Return MyBase.Channel.GetFileAsync(DocObject)
End Function
Public Function DeleteFile(ByVal ContainerId As String) As Boolean Implements EDMIServiceReference.IEDMService.DeleteFile
Return MyBase.Channel.DeleteFile(ContainerId)
Public Function DeleteFile(ByVal DocObject As EDMIServiceReference.DocumentObject) As Boolean Implements EDMIServiceReference.IEDMService.DeleteFile
Return MyBase.Channel.DeleteFile(DocObject)
End Function
Public Function DeleteFileAsync(ByVal ContainerId As String) As System.Threading.Tasks.Task(Of Boolean) Implements EDMIServiceReference.IEDMService.DeleteFileAsync
Return MyBase.Channel.DeleteFileAsync(ContainerId)
Public Function DeleteFileAsync(ByVal DocObject As EDMIServiceReference.DocumentObject) As System.Threading.Tasks.Task(Of Boolean) Implements EDMIServiceReference.IEDMService.DeleteFileAsync
Return MyBase.Channel.DeleteFileAsync(DocObject)
End Function
Public Function SetFileIndex(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal Value As String) As Object Implements EDMIServiceReference.IEDMService.SetFileIndex
Return MyBase.Channel.SetFileIndex(DocObject, Syskey, Value)
End Function
Public Function SetFileIndexAsync(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal Value As String) As System.Threading.Tasks.Task(Of Object) Implements EDMIServiceReference.IEDMService.SetFileIndexAsync
Return MyBase.Channel.SetFileIndexAsync(DocObject, Syskey, Value)
End Function
End Class
End Namespace

View File

@ -129,6 +129,15 @@
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SetFileIndex">
<soap12:operation soapAction="http://DigitalData.Services.EDMService/IEDMService/SetFileIndex" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EDMService">
<wsdl:port name="tcpBinding" binding="tns:tcpBinding">

144
EDMI_FILE_OPs/Document.vb Normal file
View File

@ -0,0 +1,144 @@
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.EDMIFileOps.EDMIServiceReference
Imports System.ServiceModel
Imports System.IO
Public Class Document
Private _logger As Logger
Private _logConfig As LogConfig
Private _channelFactory As ChannelFactory(Of IEDMServiceChannel)
Private _channel As IEDMServiceChannel
Public Sub New(LogConfig As LogConfig, EDMI_ServiceAdress As String)
_logger = LogConfig.GetLogger()
_logConfig = LogConfig
Try
Dim binding As New NetTcpBinding()
binding.Security.Mode = SecurityMode.Transport
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows
binding.MaxReceivedMessageSize = 2147483647
binding.MaxBufferSize = 2147483647
binding.MaxBufferPoolSize = 2147483647
binding.MaxConnections = 10000
binding.ReaderQuotas.MaxArrayLength = 2147483647
binding.ReaderQuotas.MaxStringContentLength = 2147483647
Dim endpointAddress = New EndpointAddress(EDMI_ServiceAdress)
_channelFactory = New ChannelFactory(Of IEDMServiceChannel)(binding, endpointAddress)
Connect2NetService()
Catch ex As Exception
_logger.Error(ex)
End Try
End Sub
Private Function Connect2NetService()
Try
_channel = Nothing
_channel = _channelFactory.CreateChannel()
_logger.Info("Successfully connected to EDM_Network Service")
AddHandler _channel.Faulted, AddressOf Reconnect
_channel.Open()
Return True
Catch ex As Exception
_logger.Error(ex)
Return True
End Try
End Function
Private Sub Reconnect()
_channel.Abort()
Connect2NetService()
End Sub
''' <summary>
''' Imports a file by filename
''' </summary>
''' <param name="FilePath">The filename to import</param>
''' <returns>A document object</returns>
Public Async Function ImportFileAsync(FilePath As String) As Task(Of DocumentResult)
Try
Return Await CreateDocument(FilePath)
Catch ex As Exception
_logger.Error(ex)
Throw ex
End Try
End Function
Public Async Function SetFileIndex(DocObject As DocumentObject, Syskey As String, Value As String) As Task
Try
Dim oResult As DocumentResult = _channel
Catch ex As Exception
_logger.Error(ex)
Throw ex
End Try
End Function
Private Async Function CreateDocument(FilePath As String) As Task(Of DocumentResult)
Try
Dim oContents As Byte() = File.ReadAllBytes(FilePath)
Dim oInfo As New FileInfo(FilePath)
Dim oName As String = oInfo.Name
Dim oExtension As String = oInfo.Extension.Substring(1)
Dim oDocObject = Await _channel.CreateFileAsync(oName, oContents)
Return oDocObject
Catch ex As Exception
_logger.Error(ex)
Throw ex
End Try
End Function
'Public Async Function New_EDMI_File(oFILENAME As String, oUserName As String) As Task(Of String)
' Try
' Dim oFileGUID As DocumentResult = Await CreateDocument(oFILENAME)
' Dim oFileRecordID = Nothing
' If Not IsNothing(oFileGUID) Then
' Dim oSQL = $"SELECT FNEDMI_SET_RECORD(""TBEDMI_ADRESSE"",""{oUserName}"",FALSE,NULL,"""",'{oFileGUID._ContainerId}') FROM rdb$database;"
' oFileRecordID = Await New_EDMIFile_CreateDB_Record(oSQL)
' End If
' Return oFileRecordID
' Catch ex As Exception
' _logger.Error(ex)
' Return Nothing
' End Try
'End Function
'Private Async Function New_EDMIFile_CreateDB_Record(FBCommand As String) As Task(Of String)
' Try
' Dim oTimeTotal As TimeSpan
' Dim oStopwatch As New Stopwatch()
' oStopwatch.Start()
' Dim oRecord_ID As String
' Dim oRequestName = Await _channel.CreateDatabaseRequestAsync("CreateEDMFileRecord", True)
' Dim oResult = Await _channel.ReturnScalarAsync(FBCommand)
' oTimeTotal = oStopwatch.Elapsed
' oStopwatch.Reset()
' Await _channel.CloseDatabaseRequestAsync()
' If Not oResult.OK Then
' _logger.Warn($"Unexpected error while executing command: {oResult.ErrorMessage}")
' Else
' oRecord_ID = oResult.Scalar
' _logger.Debug($"SCALAR (SERVICE) {FBCommand} - TIME: {(oTimeTotal.ToString)}")
' End If
' Return oRecord_ID
' Catch ex As Exception
' _logger.Error(ex)
' Return Nothing
' End Try
'End Function
Public Async Function Load_EDMIFile_2TempPath(oEDMIFile_GUID As String) As Task(Of String)
'Try
' Dim oResult As EDMIServiceReference.ContainerResult = Await _channel.GetFileAsync(oEDMIFile_GUID)
' Dim oTempPath = Path.Combine(Path.GetTempPath(), "EDMI_FileContainer")
' Directory.CreateDirectory(oTempPath)
' Dim oFilePath = Path.Combine(oTempPath, $"{oResult.Container.FileId}.{oResult.Container.Extension}")
' File.WriteAllBytes(oFilePath, oResult.Container.Contents)
' ' Process.Start(oTempPath)
' Return oTempPath
'Catch ex As Exception
' _logger.Error(ex)
' Return Nothing
'End Try
End Function
End Class

View File

@ -72,12 +72,13 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="Channel.vb" />
<Compile Include="Connected Services\EDMIServiceReference\Reference.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Reference.svcmap</DependentUpon>
</Compile>
<Compile Include="FileOp.vb" />
<Compile Include="Document.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
@ -104,7 +105,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Connected Services\EDMIServiceReference\DigitalData.Modules.EDMIFileOps.EDMIServiceReference.ContainerResult.datasource">
<None Include="Connected Services\EDMIServiceReference\DigitalData.Modules.EDMIFileOps.EDMIServiceReference.DocumentResult.datasource">
<DependentUpon>Reference.svcmap</DependentUpon>
</None>
<None Include="Connected Services\EDMIServiceReference\DigitalData.Modules.EDMIFileOps.EDMIServiceReference.NonQueryResult.datasource">

View File

@ -1,120 +0,0 @@
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.EDMIFileOps.EDMIServiceReference
Imports System.ServiceModel
Imports System.IO
Public Class FileOp
Private _logger As Logger
Private _logConfig As LogConfig
Private _channelFactory As ChannelFactory(Of IEDMServiceChannel)
Private _channel As IEDMServiceChannel
Public Sub New(LogConfig As LogConfig, EDMI_ServiceAdress As String)
_logger = LogConfig.GetLogger()
_logConfig = LogConfig
Try
Dim binding As New NetTcpBinding()
binding.Security.Mode = SecurityMode.Transport
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows
binding.MaxReceivedMessageSize = 2147483647
binding.MaxBufferSize = 2147483647
binding.MaxBufferPoolSize = 2147483647
binding.MaxConnections = 10000
binding.ReaderQuotas.MaxArrayLength = 2147483647
binding.ReaderQuotas.MaxStringContentLength = 2147483647
Dim endpointAddress = New EndpointAddress(EDMI_ServiceAdress)
_channelFactory = New ChannelFactory(Of IEDMServiceChannel)(binding, endpointAddress)
Connect2NetService()
Catch ex As Exception
_logger.Error(ex)
End Try
End Sub
Private Function Connect2NetService()
Try
_channel = Nothing
_channel = _channelFactory.CreateChannel()
_logger.Info("Successfully connected to EDM_Network Service")
AddHandler _channel.Faulted, AddressOf Reconnect
_channel.Open()
Return True
Catch ex As Exception
_logger.Error(ex)
Return True
End Try
End Function
Private Sub Reconnect()
_channel.Abort()
Connect2NetService()
End Sub
Public Async Function New_EDMI_File(oFILENAME As String, oUserName As String) As Task(Of String)
Try
Dim oFileGUID = Await New_EDMIFile_CreateContainer(oFILENAME)
Dim oFileRecordID = Nothing
If Not IsNothing(oFileGUID) Then
Dim oSQL = $"SELECT FNEDMI_SET_RECORD(""TBEDMI_ADRESSE"",""{oUserName}"",FALSE,NULL,"""",'{oFileGUID}') FROM rdb$database;"
oFileRecordID = Await New_EDMIFile_CreateDB_Record(oSQL)
End If
Return oFileRecordID
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Private Async Function New_EDMIFile_CreateContainer(oFILENAME As String) As Task(Of String)
Try
Dim sw As New Stopwatch()
sw.Start()
Dim oFileContents = File.ReadAllBytes(oFILENAME)
Dim oExtension As String = New FileInfo(oFILENAME).Extension.Substring(1)
Dim oFileGUID = Await _channel.CreateFileAsync(oFileContents, oExtension)
sw.Stop()
_logger.Info($"File successfully transferred - stopwatch: {sw.Elapsed.ToString}")
Return oFileGUID
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Private Async Function New_EDMIFile_CreateDB_Record(FBCommand As String) As Task(Of String)
Try
Dim oTimeTotal As TimeSpan
Dim oStopwatch As New Stopwatch()
oStopwatch.Start()
Dim oRecord_ID As String
Dim oRequestName = Await _channel.CreateDatabaseRequestAsync("CreateEDMFileRecord", True)
Dim oResult = Await _channel.ReturnScalarAsync(FBCommand)
oTimeTotal = oStopwatch.Elapsed
oStopwatch.Reset()
Await _channel.CloseDatabaseRequestAsync()
If Not oResult.OK Then
_logger.Warn($"Unexpected error while executing command: {oResult.ErrorMessage}")
Else
oRecord_ID = oResult.Scalar
_logger.Debug($"SCALAR (SERVICE) {FBCommand} - TIME: {(oTimeTotal.ToString)}")
End If
Return oRecord_ID
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Public Async Function Load_EDMIFile_2TempPath(oEDMIFile_GUID As String) As Task(Of String)
Try
Dim oResult As EDMIServiceReference.ContainerResult = Await _channel.GetFileAsync(oEDMIFile_GUID)
Dim oTempPath = Path.Combine(Path.GetTempPath(), "EDMI_FileContainer")
Directory.CreateDirectory(oTempPath)
Dim oFilePath = Path.Combine(oTempPath, $"{oResult.Container.FileId}.{oResult.Container.Extension}")
File.WriteAllBytes(oFilePath, oResult.Container.Contents)
' Process.Start(oTempPath)
Return oTempPath
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
End Class

View File

@ -0,0 +1,12 @@
<Serializable>
Public Class DocumentObject
Public ReadOnly Property FileName As String
Public ReadOnly Property ContainerId As String
Public ReadOnly Property DocumentId As Int64
Public Sub New(ContainerId As String, DocumentId As Int64, FileName As String)
_ContainerId = ContainerId
_DocumentId = DocumentId
_FileName = FileName
End Sub
End Class

View File

@ -43,7 +43,6 @@ Imports ProtoBuf
Public Class FileContainer
Private _crypto As Encryption
Private _compression As Compression
Private _containerId As Guid
Private _inner As FileContainerInner
Private _logger As Logger
Private _logConfig As LogConfig
@ -57,15 +56,7 @@ Public Class FileContainer
_inner.Contents = value
End Set
End Property
Public Property Extension As String
Get
Return _inner.Extension
End Get
Set(value As String)
_inner.Extension = value
End Set
End Property
Public ReadOnly Property FileId As String
Public ReadOnly Property ContainerId As String
Get
Return _inner.FileId
End Get
@ -92,14 +83,6 @@ Public Class FileContainer
Return oContainer
End Function
Public Sub New(LogConfig As LogConfig, Password As String, Path As String)
_logger = LogConfig.GetLogger()
_crypto = New Encryption(LogConfig, Password)
_compression = New Compression(LogConfig)
_inner = New FileContainerInner()
_path = Path
End Sub
Public Sub New(LogConfig As LogConfig, Password As String)
_logger = LogConfig.GetLogger()
_crypto = New Encryption(LogConfig, Password)
@ -107,9 +90,15 @@ Public Class FileContainer
_inner = New FileContainerInner()
End Sub
Public Sub SetFile(Contents As Byte(), Extension As String)
Public Sub New(LogConfig As LogConfig, Password As String, Path As String)
MyClass.New(LogConfig, Password)
_path = Path
End Sub
Public Sub SetFile(Contents As Byte(), FileName As String)
_inner.Contents = Contents
_inner.Extension = Extension
_inner.UpdatedAt = Date.Now
_inner.FileName = FileName
End Sub
Public Function GetFile() As FileContainerInner

View File

@ -12,11 +12,12 @@ Public Class FileContainerInner
<ProtoMember(4)>
Public UpdatedAt As DateTime
<ProtoMember(5)>
Public Extension As String
Public FileName As String
Public Sub New()
FileId = Guid.NewGuid.ToString
FileId = Guid.NewGuid().ToString
CreatedAt = Date.Now
UpdatedAt = Date.Now
End Sub
End Class

View File

@ -76,6 +76,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Compression.vb" />
<Compile Include="DocumentObject.vb" />
<Compile Include="FileContainer.vb" />
<Compile Include="Encryption.vb" />
<Compile Include="File.vb" />

View File

@ -186,6 +186,7 @@ Public Class Firebird
_logger.Debug("Executing Non-Query: {0}", SqlCommand)
If Connection Is Nothing Then
_Logger.Warn("Connection is nothing!")
Return Nothing
End If
@ -236,6 +237,7 @@ Public Class Firebird
_logger.Debug("Fetching Scalar-Value: {0}", SqlQuery)
If Connection Is Nothing Then
_Logger.Warn("Connection is nothing!")
Return Nothing
End If
@ -282,6 +284,7 @@ Public Class Firebird
_logger.Debug("Fetching Datatable: {0}", SqlQuery)
If Connection Is Nothing Then
_Logger.Warn("Connection is nothing!")
Return Nothing
End If

View File

@ -85,6 +85,7 @@
<ItemGroup>
<Compile Include="AppConfig.vb" />
<Compile Include="ContainerResult.vb" />
<Compile Include="DocumentResult.vb" />
<Compile Include="Exceptions.vb" />
<Compile Include="DatabaseResult.vb" />
<Compile Include="EDMService.vb" />

View File

@ -0,0 +1,20 @@
Imports DigitalData.Modules.Filesystem
<Serializable>
Public Class DocumentResult
Public ReadOnly OK As Boolean
Public ReadOnly ErrorMessage As String
Public Document As DocumentObject
Public HasContents As Boolean
Public Contents As Byte()
Public Sub New()
OK = True
ErrorMessage = Nothing
End Sub
Public Sub New(ErrorMessage As String)
OK = False
Me.ErrorMessage = ErrorMessage
End Sub
End Class

View File

@ -3,7 +3,6 @@ Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Filesystem
Imports System.IO
Imports DigitalData.Services.EDMService
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
Public Class EDMService
@ -28,17 +27,35 @@ Public Class EDMService
_logger = LogConfig.GetLogger()
End Sub
#Region "Auth"
Private Function TestUserAuth() As Boolean
Try
Dim oSQL As String = $"SELECT FNICM_AUTH_USER('{_username}') FROM RDB$DATABASE;"
Dim oResult As Boolean = Database.GetScalarValue(oSQL)
Return oResult
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
#End Region
#Region "Heartbeat"
Public Function Heartbeat() As Boolean Implements IEDMService.Heartbeat
Return True
End Function
#End Region
#Region "Request"
Public Function CreateDatabaseRequest(Name As String, Optional Debug As Boolean = False) As String Implements IEDMService.CreateDatabaseRequest
Public Sub CreateRequest(Name As String, Optional Debug As Boolean = False)
_request = New Request(Name, _username, Database, Debug)
_debug = Debug
_logger.Info("Creating request {0}/{1}", _request.Name, _request.RequestId)
End Sub
Public Function CreateDatabaseRequest(Name As String, Optional Debug As Boolean = False) As String Implements IEDMService.CreateDatabaseRequest
CreateRequest(Name, Debug)
Return _request.Name
End Function
@ -111,80 +128,123 @@ Public Class EDMService
#End Region
#Region "FileContainer"
Private Function GetFilePath(ContainerId As String) As String
Return Path.Combine(AppConfig.ContainerPath, ContainerId & ".enc")
End Function
Private Sub TestFileExists(ContainerId)
Dim oContainerPath = GetFilePath(ContainerId)
If Not IO.File.Exists(oContainerPath) Then
Throw New FileNotFoundException("Container existiert nicht", oContainerPath)
End If
End Sub
Public Function GetFile(ContainerId As String) As ContainerResult Implements IEDMService.GetFile
#Region "Document"
Public Function CreateFile(FileName As String, Contents() As Byte) As DocumentResult Implements IEDMService.CreateFile
Try
TestFileExists(ContainerId)
Dim oContainer As FileContainer
Dim oContainerId As String
Dim oContainerPath = GetFilePath(ContainerId)
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
If Not TestUserAuth() Then
Throw New Exception("User not authorized")
End If
Dim oResult As New ContainerResult With {
.Container = oContainer.GetFile()
oContainer = FileContainer.Create(LogConfig, AppConfig.ContainerPassword)
oContainerId = oContainer.ContainerId
_logger.Debug("Container created with id {0}", oContainerId)
Dim oExtension As String = Path.GetExtension(FileName).Substring(1)
_logger.Debug("File extension of file {0} is {1}", FileName, oExtension)
Dim oSQL = $"SELECT FNICM_NEW_DOC('{FileName}','{oExtension}','{oContainerId}','{GetContainerName(oContainerId)}','{_username}') FROM RDB$DATABASE;"
Dim oDocId As Int64 = Database.GetScalarValue(oSQL)
If oDocId = -1 Then
_logger.Warn("Database returned -1 while creating Document Entry. File was not saved!")
Return Nothing
End If
_logger.Debug("Database Entry created with DocId {0}", oDocId)
oContainer.SetFile(Contents, FileName)
oContainer.SaveAs(GetContainerPath(oContainerId))
_logger.Debug("File saved in Container!", FileName)
Return New DocumentResult() With {
.Document = New DocumentObject(oContainerId, oDocId, FileName)
}
Return oResult
Catch ex As Exception
_logger.Error(ex)
Return New ContainerResult(ex.Message)
Return New DocumentResult(ex.Message)
End Try
End Function
Public Function CreateFile(Contents() As Byte, Extension As String) As String Implements IEDMService.CreateFile
Public Function UpdateFile(DocObject As DocumentObject, Contents() As Byte) As DocumentResult Implements IEDMService.UpdateFile
Try
Dim oContainer As FileContainer = FileContainer.Create(LogConfig, AppConfig.ContainerPassword)
Dim oContainerId As String = oContainer.FileId
TestFileExists(DocObject.ContainerId)
oContainer.SetFile(Contents, Extension)
oContainer.SaveAs(GetFilePath(oContainerId))
' TODO: update db
Return oContainerId
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Public Function UpdateFile(FileId As String, Contents() As Byte) As String Implements IEDMService.UpdateFile
Try
TestFileExists(FileId)
Dim oFilePath = GetFilePath(FileId)
Dim oFilePath = GetContainerPath(DocObject.ContainerId)
Dim oFileContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oFilePath)
oFileContainer.SetFile(Contents, oFileContainer.Extension)
oFileContainer.SetFile(Contents, oFileContainer.GetFile.FileName)
oFileContainer.Save()
Return oFileContainer.FileId
Return New DocumentResult() With {
.Document = DocObject
}
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Public Function DeleteFile(FileId As String) As Boolean Implements IEDMService.DeleteFile
Public Function GetFile(DocObject As DocumentObject) As DocumentResult Implements IEDMService.GetFile
Try
TestFileExists(FileId)
TestFileExists(DocObject.ContainerId)
Dim oFilePath = GetFilePath(FileId)
Dim oContainerPath = GetContainerPath(DocObject.ContainerId)
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
Dim oContents As Byte() = oContainer.GetFile().Contents
Return New DocumentResult With {
.Document = DocObject,
.Contents = oContents
}
Catch ex As Exception
_logger.Error(ex)
Return New DocumentResult(ex.Message)
End Try
End Function
Public Function DeleteFile(DocObject As DocumentObject) As Boolean Implements IEDMService.DeleteFile
Try
TestFileExists(DocObject.ContainerId)
Dim oFilePath = GetContainerPath(DocObject.ContainerId)
IO.File.Delete(oFilePath)
'TODO: Delete doc from db
Return True
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
Private Function GetContainerPath(ContainerId As String) As String
Return Path.Combine(AppConfig.ContainerPath, GetContainerName(ContainerId))
End Function
Private Function GetContainerName(ContainerId As String) As String
Return ContainerId & ".enc"
End Function
Private Sub TestFileExists(ContainerId)
Dim oContainerPath = GetContainerPath(ContainerId)
If Not IO.File.Exists(oContainerPath) Then
Throw New FileNotFoundException("Container existiert nicht", oContainerPath)
End If
End Sub
#End Region
#Region "Index"
Public Function SetFileIndex(DocObject As DocumentObject, Syskey As String, Value As String) As Object Implements IEDMService.SetFileIndex
Throw New NotImplementedException()
End Function
#End Region
End Class

View File

@ -26,18 +26,23 @@ Interface IEDMService
Function ExecuteNonQuery(SQL As String) As NonQueryResult
#End Region
#Region "FileContainer"
#Region "Document"
<OperationContract>
Function CreateFile(Contents As Byte(), Extension As String) As String
Function CreateFile(FileName As String, Contents As Byte()) As DocumentResult
<OperationContract>
Function UpdateFile(ContainerId As String, Contents As Byte()) As String
Function UpdateFile(DocObject As DocumentObject, Contents As Byte()) As DocumentResult
<OperationContract>
Function GetFile(ContainerId As String) As ContainerResult
Function GetFile(DocObject As DocumentObject) As DocumentResult
<OperationContract>
Function DeleteFile(ContainerId As String) As Boolean
Function DeleteFile(DocObject As DocumentObject) As Boolean
#End Region
#Region "Index"
<OperationContract>
Function SetFileIndex(DocObject As DocumentObject, Syskey As String, Value As String)
#End Region
End Interface

View File

@ -4,6 +4,8 @@ Imports System.Configuration
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Database.Exceptions
Imports System.ServiceModel.Channels
Imports System.ServiceModel.Dispatcher
Public Class WindowsService
Inherits ServiceBase