diff --git a/EDMI.File/Path.vb b/EDMI.File/Path.vb
index e8b904b0..8da28dcb 100644
--- a/EDMI.File/Path.vb
+++ b/EDMI.File/Path.vb
@@ -17,14 +17,21 @@ Public Class Path
End Sub
Public Function GetActivePath(DocumentType As String)
- Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ACTIVE, DocumentType}
- oPathParts.AddRange(GetDatePath())
+ Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ACTIVE}
+ oPathParts.AddRange(GetRelativePath(DocumentType))
Return IO.Path.Combine(oPathParts.ToArray())
End Function
Public Function GetArchivePath(DocumentType As String)
- Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ARCHIVE, DocumentType}
+ Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ARCHIVE}
+ oPathParts.AddRange(GetRelativePath(DocumentType))
+
+ Return IO.Path.Combine(oPathParts.ToArray())
+ End Function
+
+ Public Function GetRelativePath(DocumentType As String)
+ Dim oPathParts As New List(Of String) From {DocumentType}
oPathParts.AddRange(GetDatePath())
Return IO.Path.Combine(oPathParts.ToArray())
diff --git a/GUIs.Test.EDMIBenchmark/Form1.vb b/GUIs.Test.EDMIBenchmark/Form1.vb
index 1080747a..f6df2a78 100644
--- a/GUIs.Test.EDMIBenchmark/Form1.vb
+++ b/GUIs.Test.EDMIBenchmark/Form1.vb
@@ -50,9 +50,9 @@ Public Class Form1
Await oStream.ReadAsync(oContents, 0, oFileInfo.Length)
End Using
- Dim oResult As EDMIServiceReference.DocumentResult2 = Await _Channel.ImportFileAsync(oFileInfo, oContents, False, 0)
+ Dim oResult As EDMIServiceReference.DocumentResult2 = Await _Channel.ImportFileAsync(oFileInfo.Name, oContents, Environment.UserName)
If oResult.OK Then
- listboxLog.Items.Add($"File {oFileInfo.Name} imported!")
+ listboxLog.Items.Add($"File [{oFileInfo.Name}] with Id [{oResult.Document.FileId}] imported!")
listboxFileids.Items.Add(oResult.Document.FileId)
Else
listboxLog.Items.Add($"Import Error: {oResult.ErrorMessage}")
diff --git a/Modules.Database/Database.vbproj b/Modules.Database/Database.vbproj
index 01a2e276..46730ac9 100644
--- a/Modules.Database/Database.vbproj
+++ b/Modules.Database/Database.vbproj
@@ -93,6 +93,7 @@
+
diff --git a/Modules.Database/IDatabase.vb b/Modules.Database/IDatabase.vb
new file mode 100644
index 00000000..b9c5420f
--- /dev/null
+++ b/Modules.Database/IDatabase.vb
@@ -0,0 +1,12 @@
+Imports System.Data.Common
+
+Public Interface IDatabase
+ Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable
+ Function GetDatatable(SqlCommand As String) As DataTable
+
+ Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean
+ Function ExecuteNonQuery(SQLCommand As String) As Boolean
+
+ Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object
+ Function GetScalarValue(SQLQuery As String) As Object
+End Interface
diff --git a/Modules.Database/MSSQLServer.vb b/Modules.Database/MSSQLServer.vb
index 6a9a8ae9..d335ce07 100644
--- a/Modules.Database/MSSQLServer.vb
+++ b/Modules.Database/MSSQLServer.vb
@@ -1,7 +1,10 @@
-Imports System.Data.SqlClient
+Imports System.Data.Common
+Imports System.Data.SqlClient
Imports DigitalData.Modules.Logging
Public Class MSSQLServer
+ Implements IDatabase
+
Public DBInitialized As Boolean = False
Public CurrentSQLConnectionString As String = ""
@@ -40,7 +43,7 @@ Public Class MSSQLServer
Dim oConnectionStringBuilder As New SqlConnectionStringBuilder() With {
.DataSource = Server,
.InitialCatalog = Database,
- .UserId = UserId,
+ .UserID = UserId,
.Password = Password
}
@@ -89,7 +92,7 @@ Public Class MSSQLServer
'''
''' sqlcommand for datatable (select XYZ from TableORView)
''' Returns a datatable
- Public Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable
+ Public Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable Implements IDatabase.GetDatatable
Try
If TestCanConnect() = False Then
Return Nothing
@@ -113,7 +116,7 @@ Public Class MSSQLServer
End Try
End Function
- Public Function GetDatatable(SqlCommand As String) As DataTable
+ Public Function GetDatatable(SqlCommand As String) As DataTable Implements IDatabase.GetDatatable
Return GetDatatable(SqlCommand, _Timeout)
End Function
@@ -128,7 +131,7 @@ Public Class MSSQLServer
Return ExecuteNonQuery(executeStatement)
End Function
- Public Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean
+ Public Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean Implements IDatabase.ExecuteNonQuery
Try
If TestCanConnect() = False Then
Return Nothing
@@ -149,7 +152,7 @@ Public Class MSSQLServer
End Try
End Function
- Public Function ExecuteNonQuery(SQLCommand As String) As Boolean
+ Public Function ExecuteNonQuery(SQLCommand As String) As Boolean Implements IDatabase.ExecuteNonQuery
Return ExecuteNonQuery(SQLCommand, _Timeout)
End Function
@@ -163,7 +166,7 @@ Public Class MSSQLServer
Return GetScalarValue(ScalarSQL)
End Function
- Public Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object
+ Public Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object Implements IDatabase.GetScalarValue
Try
If TestCanConnect() = False Then
Return Nothing
@@ -184,10 +187,43 @@ Public Class MSSQLServer
End Try
End Function
- Public Function GetScalarValue(SQLQuery As String) As Object
+ Public Function GetScalarValue(SQLQuery As String) As Object Implements IDatabase.GetScalarValue
Return GetScalarValue(SQLQuery, _Timeout)
End Function
+ Public Function GetScalarValue(SQLCommand As SqlCommand, OutputParameter As String, Timeout As Integer) As Object
+ Try
+ If TestCanConnect() = False Then
+ Return Nothing
+ End If
+
+ If SQLCommand.CommandText.Contains(" ") Then
+ SQLCommand.CommandType = CommandType.Text
+ Else
+ SQLCommand.CommandType = CommandType.StoredProcedure
+ End If
+
+ Using oConnection As SqlConnection = GetSQLConnection()
+
+ SQLCommand.Connection = oConnection
+ SQLCommand.Parameters(OutputParameter).Direction = ParameterDirection.Output
+ SQLCommand.CommandTimeout = Timeout
+ SQLCommand.ExecuteNonQuery()
+ oConnection.Close()
+
+ Return SQLCommand.Parameters(OutputParameter).Value
+ End Using
+ Catch ex As Exception
+ _Logger.Error(ex)
+ _Logger.Warn("SQLQuery: " & SQLCommand.CommandText)
+ Return Nothing
+ End Try
+ End Function
+
+ Public Function GetScalarValue(SQLCommand As SqlCommand, OutputParameter As String) As Object
+ Return GetScalarValue(SQLCommand, OutputParameter, _Timeout)
+ End Function
+
'''
''' Executes the passed sql-statement in asyncmode
'''
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl
index 4c17fb89..60584846 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl
@@ -8,7 +8,6 @@
-
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd
index 51c95fc6..a6517bc3 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd
@@ -2,7 +2,6 @@
-
@@ -171,24 +170,23 @@
-
+
-
-
+
-
+
-
+
@@ -198,7 +196,7 @@
-
+
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap
index 93c22c81..3b8b7529 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap
@@ -30,7 +30,6 @@
-
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
index 08fa4b87..9fea810d 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
@@ -97,9 +97,7 @@ Namespace EDMIServiceReference
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.DocumentResult2.DocumentObject)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.IndexResult)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(System.DBNull)), _
- System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.DocumentObject)), _
- System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileInfo)), _
- System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileSystemInfo))> _
+ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.DocumentObject))> _
Partial Public Class ScalarResult
Inherits EDMIServiceReference.BaseResult
@@ -504,10 +502,10 @@ Namespace EDMIServiceReference
Function GetDocumentByContainerIdAsync(ByVal ContainerId As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult)
_
- Function ImportFile(ByVal FileInfo As System.IO.FileInfo, ByVal Contents() As Byte, ByVal [ReadOnly] As Boolean, ByVal RetentionTime As Integer) As EDMIServiceReference.DocumentResult2
+ Function ImportFile(ByVal FileName As String, ByVal Contents() As Byte, ByVal AddedWho As String) As EDMIServiceReference.DocumentResult2
_
- Function ImportFileAsync(ByVal FileInfo As System.IO.FileInfo, ByVal Contents() As Byte, ByVal [ReadOnly] As Boolean, ByVal RetentionTime As Integer) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult2)
+ Function ImportFileAsync(ByVal FileName As String, ByVal Contents() As Byte, ByVal AddedWho As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult2)
_
Function NewFileIndex(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal LanguageCode As String, ByVal Value As String) As EDMIServiceReference.IndexResult
@@ -643,12 +641,12 @@ Namespace EDMIServiceReference
Return MyBase.Channel.GetDocumentByContainerIdAsync(ContainerId)
End Function
- Public Function ImportFile(ByVal FileInfo As System.IO.FileInfo, ByVal Contents() As Byte, ByVal [ReadOnly] As Boolean, ByVal RetentionTime As Integer) As EDMIServiceReference.DocumentResult2 Implements EDMIServiceReference.IEDMIService.ImportFile
- Return MyBase.Channel.ImportFile(FileInfo, Contents, [ReadOnly], RetentionTime)
+ Public Function ImportFile(ByVal FileName As String, ByVal Contents() As Byte, ByVal AddedWho As String) As EDMIServiceReference.DocumentResult2 Implements EDMIServiceReference.IEDMIService.ImportFile
+ Return MyBase.Channel.ImportFile(FileName, Contents, AddedWho)
End Function
- Public Function ImportFileAsync(ByVal FileInfo As System.IO.FileInfo, ByVal Contents() As Byte, ByVal [ReadOnly] As Boolean, ByVal RetentionTime As Integer) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult2) Implements EDMIServiceReference.IEDMIService.ImportFileAsync
- Return MyBase.Channel.ImportFileAsync(FileInfo, Contents, [ReadOnly], RetentionTime)
+ Public Function ImportFileAsync(ByVal FileName As String, ByVal Contents() As Byte, ByVal AddedWho As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult2) Implements EDMIServiceReference.IEDMIService.ImportFileAsync
+ Return MyBase.Channel.ImportFileAsync(FileName, Contents, AddedWho)
End Function
Public Function NewFileIndex(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal LanguageCode As String, ByVal Value As String) As EDMIServiceReference.IndexResult Implements EDMIServiceReference.IEDMIService.NewFileIndex
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/System.IO.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/System.IO.xsd
deleted file mode 100644
index 68a2b9b7..00000000
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/System.IO.xsd
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Modules.EDMIAPI/Document.vb b/Modules.EDMIAPI/Document.vb
index 21121216..1330bf99 100644
--- a/Modules.EDMIAPI/Document.vb
+++ b/Modules.EDMIAPI/Document.vb
@@ -55,12 +55,10 @@ Public Class Document
''' A document object
Public Async Function ImportFileAsync(FilePath As String, Optional [ReadOnly] As Boolean = False, Optional RetentionPeriod As Integer = 0) As Task(Of DocumentResult2)
Try
- Dim oInfo As New FileInfo(FilePath)
-
Using oStream As New FileStream(FilePath, FileMode.Open)
Dim oContents As Byte() = {}
Dim oBytesRead = Await oStream.ReadAsync(oContents, 0, oStream.Length)
- Dim oResult = Await _channel.ImportFileAsync(oInfo, oContents, [ReadOnly], RetentionPeriod)
+ Dim oResult = Await _channel.ImportFileAsync(FilePath, oContents, Environment.UserName)
Return oResult
End Using
@@ -75,11 +73,11 @@ Public Class Document
'''
''' The filename to import
''' A document object
- Public Function ImportFile(FilePath As String, Optional [ReadOnly] As Boolean = False, Optional RetentionPeriod As Integer = 0) As DocumentResult2
+ Public Function ImportFile(FilePath As String) As DocumentResult2
Try
Dim oContents As Byte() = File.ReadAllBytes(FilePath)
Dim oInfo As New FileInfo(FilePath)
- Dim oDocObject = _channel.ImportFile(oInfo, oContents, [ReadOnly], RetentionPeriod)
+ Dim oDocObject = _channel.ImportFile(FilePath, oContents, Environment.UserName)
Return oDocObject
Catch ex As Exception
_logger.Error(ex)
diff --git a/Modules.EDMIAPI/EDMI.API.vbproj b/Modules.EDMIAPI/EDMI.API.vbproj
index c390ee95..0f340797 100644
--- a/Modules.EDMIAPI/EDMI.API.vbproj
+++ b/Modules.EDMIAPI/EDMI.API.vbproj
@@ -141,9 +141,6 @@
Designer
-
- Designer
-
Designer
diff --git a/Service.EDMIService/App.config b/Service.EDMIService/App.config
index 23db2755..85cbdc9f 100644
--- a/Service.EDMIService/App.config
+++ b/Service.EDMIService/App.config
@@ -7,6 +7,10 @@
+
+
+
+
diff --git a/Service.EDMIService/AppConfig.vb b/Service.EDMIService/AppConfig.vb
index 3172d5d1..e1212b52 100644
--- a/Service.EDMIService/AppConfig.vb
+++ b/Service.EDMIService/AppConfig.vb
@@ -8,6 +8,7 @@ Public Class AppConfig
Public Shared ContainerPath As String
Public Shared ContainerPassword As String
Public Shared DatastorePath As String
+ Public Shared MSSQLConnectionString As String
Public Shared Sub Load()
With ConfigurationManager.AppSettings
@@ -15,9 +16,22 @@ Public Class AppConfig
FirebirdDatabase = .Item("FIREBIRD_DATABASE_NAME")
FirebirdUser = .Item("FIREBIRD_DATABASE_USER")
FirebirdPassword = .Item("FIREBIRD_DATABASE_PASS")
+
+ MSSQLConnectionString = .Item("MSSQL_CONNECTION_STRING")
+
ContainerPath = .Item("CONTAINER_PATH")
ContainerPassword = .Item("CONTAINER_PASSWORD")
+
DatastorePath = .Item("DATASTORE_PATH")
End With
End Sub
+
+ Public Shared Function IsFirebirdConfigured() As Boolean
+ Dim oProps As New List(Of String) From {FirebirdDataSource, FirebirdDatabase, FirebirdUser, FirebirdPassword}
+ Return Not oProps.Any(Function(Prop) String.IsNullOrWhiteSpace(Prop))
+ End Function
+
+ Public Shared Function IsMSSQLConfigured() As Boolean
+ Return Not String.IsNullOrWhiteSpace(MSSQLConnectionString)
+ End Function
End Class
diff --git a/Service.EDMIService/Database/IDatabase.vb b/Service.EDMIService/Database/IDatabase.vb
new file mode 100644
index 00000000..0b370d22
--- /dev/null
+++ b/Service.EDMIService/Database/IDatabase.vb
@@ -0,0 +1,3 @@
+Public Interface IDatabase
+ Function NewDocument(RelativePath As String, AddedWho As String, ObjectStoreId As Int64, ReferenceId As Int64) As Int64
+End Interface
diff --git a/Service.EDMIService/Database/MSSQL.vb b/Service.EDMIService/Database/MSSQL.vb
new file mode 100644
index 00000000..3d4153b1
--- /dev/null
+++ b/Service.EDMIService/Database/MSSQL.vb
@@ -0,0 +1,20 @@
+Imports DigitalData.Modules.Database
+Imports DigitalData.Modules.Logging
+
+Public Class MSSQL
+ Implements IDatabase
+
+ Private ReadOnly LogConfig As LogConfig
+ Private ReadOnly Database As MSSQLServer
+ Private ReadOnly Logger As Logger
+
+ Public Sub New(LogConfig As LogConfig, Database As MSSQLServer)
+ Me.LogConfig = LogConfig
+ Me.Database = Database
+ Me.Logger = LogConfig.GetLogger()
+ End Sub
+
+ Public Function NewDocument(RelativePath As String, AddedWho As String, ObjectStoreId As Long, ReferenceId As Long) As Long Implements IDatabase.NewDocument
+
+ End Function
+End Class
diff --git a/Service.EDMIService/EDMIService.vb b/Service.EDMIService/EDMIService.vb
index d5c9979e..2a36814f 100644
--- a/Service.EDMIService/EDMIService.vb
+++ b/Service.EDMIService/EDMIService.vb
@@ -6,13 +6,15 @@ Imports DigitalData.Modules
Imports System.IO
Imports System.ServiceModel.Description
Imports System.ServiceModel.Channels
+Imports System.Data.SqlClient
Public Class EDMIService
Implements IEDMIService
Public Shared LogConfig As LogConfig
- Public Shared Database As Firebird
+ Public Shared MSSQL As MSSQLServer
+ Public Shared Firebird As Firebird
Public Shared AppConfig As AppConfig
Public Shared Filesystem As Filesystem.File
Public Shared EDMIPath As EDMI.File.Path
@@ -54,7 +56,7 @@ Public Class EDMIService
#End Region
#Region "Request"
Public Sub CreateRequest(Name As String, Optional Debug As Boolean = False)
- _request = New Request(Name, _username, Database, Debug)
+ _request = New Request(Name, _username, Firebird, Debug)
_debug = Debug
_logger.Info("Creating request {0}/{1}", _request.Name, _request.RequestId)
@@ -91,7 +93,7 @@ Public Class EDMIService
_logger.Info($"ReturnDatatable, SQL: {SQL}")
_request.LogDebug($"ReturnDatatable, SQL: {SQL}")
- Dim oResult As DataTable = Database.GetDatatableWithConnection(SQL, _request.Connection)
+ Dim oResult As DataTable = Firebird.GetDatatableWithConnection(SQL, _request.Connection)
Return New TableResult(oResult)
Catch ex As Exception
_logger.Error(ex)
@@ -107,7 +109,7 @@ Public Class EDMIService
_logger.Info($"ReturnScalar, SQL: {SQL}")
_request.LogDebug($"ReturnScalar, SQL: {SQL}")
- Dim oResult As Object = Database.GetScalarValueWithConnection(SQL, _request.Connection)
+ Dim oResult As Object = Firebird.GetScalarValueWithConnection(SQL, _request.Connection)
Return New ScalarResult(oResult)
Catch ex As Exception
_logger.Error(ex)
@@ -123,7 +125,7 @@ Public Class EDMIService
_logger.Info($"ExecuteNonQuery, SQL: {SQL}")
_request.LogDebug($"ExecuteNonQuery, SQL: {SQL}")
- Dim oResult As Boolean = Database.ExecuteNonQueryWithConnection(SQL, _request.Connection)
+ Dim oResult As Boolean = Firebird.ExecuteNonQueryWithConnection(SQL, _request.Connection)
Return New NonQueryResult()
Catch ex As Exception
_logger.Error(ex)
@@ -152,7 +154,7 @@ Public Class EDMIService
_logger.Debug("File extension of file {0} is {1}", FileName, oExtension)
Dim oSQL = $"SELECT FNICM_NEW_DOC('010', '{oContainerId}', '{GetContainerName(oContainerId)}', '{FileName}', '{oExtension}', '{_username}') FROM RDB$DATABASE;"
- Dim oDocId As Int64 = Database.GetScalarValue(oSQL)
+ Dim oDocId As Int64 = Firebird.GetScalarValue(oSQL)
If oDocId = -1 Then
_logger.Warn("Database returned -1 while creating Document Entry. File was not saved!")
@@ -244,7 +246,7 @@ Public Class EDMIService
Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResult Implements IEDMIService.GetDocumentByDocumentId
Try
Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE GUID = {DocumentId}"
- Dim oTable = Database.GetDatatable(oSQL)
+ Dim oTable = Firebird.GetDatatable(oSQL)
If oTable.Rows.Count = 0 Then
Return New DocumentResult("Document not found")
@@ -272,7 +274,7 @@ Public Class EDMIService
Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult Implements IEDMIService.GetDocumentByContainerId
Try
Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE CONTAINER_ID = '{ContainerId}'"
- Dim oTable = Database.GetDatatable(oSQL)
+ Dim oTable = Firebird.GetDatatable(oSQL)
If oTable.Rows.Count = 0 Then
Return New DocumentResult("Document not found")
@@ -299,11 +301,12 @@ Public Class EDMIService
#End Region
#Region "Document"
- Public Function ImportFile(FileInfo As FileInfo, Contents() As Byte, [Readonly] As Boolean, RetentionPeriod As Integer) As DocumentResult2 Implements IEDMIService.ImportFile
+ Public Function ImportFile(FileName As String, Contents() As Byte, AddedWho As String) As DocumentResult2 Implements IEDMIService.ImportFile
Dim oDocumentType As String = "DummyDocumentType"
Dim oDirectoryPath = EDMIPath.GetActivePath(oDocumentType)
- Dim oFilePath = Path.Combine(oDirectoryPath, FileInfo.Name)
- Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name, .FileId = Guid.NewGuid.ToString}
+ Dim oAbsPath = Path.Combine(oDirectoryPath, FileName)
+ Dim oRelativePath = EDMIPath.GetRelativePath(oDocumentType)
+ Dim oDocument = New DocumentResult2.DocumentObject With {.FileName = FileName}
Try
Directory.CreateDirectory(oDirectoryPath)
@@ -313,16 +316,26 @@ Public Class EDMIService
End Try
Try
- Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oFilePath)
+ Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oAbsPath)
- _logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oVersionedFileName)
+ _logger.Info("Saving file [{0}] to path [{1}]", FileName, oVersionedFileName)
Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew)
oStream.Write(Contents, 0, Contents.Length)
oStream.Flush(True)
oStream.Close()
End Using
- EDMIArchive.SetRetention(oVersionedFileName, RetentionPeriod, [Readonly])
+ ' insert into db
+ Dim oCommand As New SqlCommand("PRIDB_NEW_DOCUMENT")
+ oCommand.Parameters.AddWithValue("@OBJ_ST_ID", 1)
+ oCommand.Parameters.AddWithValue("@REL_PATH", oDirectoryPath)
+ oCommand.Parameters.AddWithValue("@WHO", AddedWho)
+ oCommand.Parameters.AddWithValue("@REF_DOCID", 0)
+ oCommand.Parameters.Add(New SqlParameter("@IDB_OBJ_ID", SqlDbType.BigInt))
+
+ Dim oObjectId = MSSQL.GetScalarValue(oCommand, "@IDB_OBJ_ID")
+
+ oDocument.FileId = oObjectId
Return New DocumentResult2(oDocument)
Catch ex As Exception
@@ -330,13 +343,14 @@ Public Class EDMIService
Return New DocumentResult2(ex.Message)
End Try
End Function
+
#End Region
#Region "Index"
Public Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult Implements IEDMIService.NewFileIndex
Try
Dim oSQL = $"SELECT FNIDB_NEW_DOC_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;"
- Dim oIndexId As Int64 = Database.GetScalarValue(oSQL)
+ Dim oIndexId As Int64 = Firebird.GetScalarValue(oSQL)
Return New IndexResult(oIndexId)
Catch ex As Exception
diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj
index db351beb..77d5cb22 100644
--- a/Service.EDMIService/EDMIService.vbproj
+++ b/Service.EDMIService/EDMIService.vbproj
@@ -101,6 +101,8 @@
+
+
diff --git a/Service.EDMIService/IEDMIService.vb b/Service.EDMIService/IEDMIService.vb
index 0acc56b9..6a2d43d3 100644
--- a/Service.EDMIService/IEDMIService.vb
+++ b/Service.EDMIService/IEDMIService.vb
@@ -49,7 +49,7 @@ Interface IEDMIService
#Region "Document (New)"
- Function ImportFile(FileInfo As FileInfo, Contents As Byte(), [ReadOnly] As Boolean, RetentionTime As Integer) As DocumentResult2
+ Function ImportFile(FileName As String, Contents As Byte(), AddedWho As String) As DocumentResult2
#End Region
#Region "Index"
diff --git a/Service.EDMIService/WindowsService.vb b/Service.EDMIService/WindowsService.vb
index 60ef89a2..067b315e 100644
--- a/Service.EDMIService/WindowsService.vb
+++ b/Service.EDMIService/WindowsService.vb
@@ -13,8 +13,10 @@ Public Class WindowsService
Private _logConfig As LogConfig
Private _logger As Logger
- Private _db As Firebird
- Private _clientsConnected As Integer = 0
+
+ Private _firebird As Firebird
+ Private _mssql As MSSQLServer
+
Private _config As AppConfig
Private _Path As EDMI.File.Path
Private _Archive As EDMI.File.Archive
@@ -39,17 +41,28 @@ Public Class WindowsService
_logger = _logConfig.GetLogger()
_logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME)
- _logger.Debug("Connecting to database...")
- _db = New Firebird(
- _logConfig,
- AppConfig.FirebirdDataSource,
- AppConfig.FirebirdDatabase,
- AppConfig.FirebirdUser,
- AppConfig.FirebirdPassword
- )
+ If AppConfig.IsFirebirdConfigured() Then
+ _logger.Debug("Connecting to Firebird...")
+ _firebird = New Firebird(
+ _logConfig,
+ AppConfig.FirebirdDataSource,
+ AppConfig.FirebirdDatabase,
+ AppConfig.FirebirdUser,
+ AppConfig.FirebirdPassword
+ )
+ _logger.Info("Database connection established.")
+ Else
+ _logger.Info("Firebird is not configured, will not be used!")
+ End If
- _logger.Info("Database connection established.")
+ If AppConfig.IsMSSQLConfigured() Then
+ _logger.Debug("Connecting to MSSQL...")
+ _mssql = New MSSQLServer(_logConfig, AppConfig.MSSQLConnectionString)
+ _logger.Info("Database connection established.")
+ Else
+ _logger.Info("MSSQL is not configured, will not be used!")
+ End If
_logger.Debug("Initializing EDMI Functions")
@@ -57,9 +70,10 @@ Public Class WindowsService
_Archive = New EDMI.File.Archive(_logConfig)
_filesystem = New Filesystem.File(_logConfig)
- _logger.Debug("EDMI Functions initialized.")
+ _logger.Info("EDMI Functions initialized.")
- EDMIService.Database = _db
+ EDMIService.MSSQL = _mssql
+ EDMIService.Firebird = _firebird
EDMIService.LogConfig = _logConfig
EDMIService.AppConfig = _config
EDMIService.EDMIArchive = _Archive
@@ -71,7 +85,7 @@ Public Class WindowsService
_serviceHost = New ServiceHost(GetType(EDMIService))
_serviceHost.Open()
- _logger.Debug("WCF ServiceHost started.")
+ _logger.Info("WCF ServiceHost started.")
_logger.Info("Service {0} successfully started.", SERVICE_DISPLAY_NAME)
Catch ex As Exception