update service and api
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Services.IDBService
|
||||
Imports System.IO
|
||||
|
||||
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
|
||||
Public Class IDBService
|
||||
@@ -31,17 +31,16 @@ Public Class IDBService
|
||||
#Region "Auth"
|
||||
Private Function TestUserAuth() As Boolean
|
||||
Try
|
||||
Dim oSQL As String = $"SELECT FNIDB_AUTH_USER('{_username}') FROM RDB$DATABASE;"
|
||||
Dim oResult As Boolean = Database.GetScalarValue(oSQL)
|
||||
|
||||
Return oResult
|
||||
'Dim oSQL As String = $"SELECT FNIDB_AUTH_USER('{_username}') FROM RDB$DATABASE;"
|
||||
'Dim oResult As Boolean = Database.GetScalarValue(oSQL)
|
||||
'Return oResult
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Heartbeat"
|
||||
Public Function Heartbeat() As Boolean Implements IIDBService.Heartbeat
|
||||
Return True
|
||||
@@ -129,7 +128,7 @@ Public Class IDBService
|
||||
|
||||
|
||||
#End Region
|
||||
#Region "Document"
|
||||
#Region "Document (with FileContainer)"
|
||||
Public Function NewFile(FileName As String, Contents() As Byte) As DocumentResult Implements IIDBService.NewFile
|
||||
Try
|
||||
Dim oContainer As FileContainer
|
||||
@@ -237,6 +236,35 @@ Public Class IDBService
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "Document"
|
||||
Public Function ImportFile(FileInfo As FileInfo, Contents() As Byte) As DocumentResult2 Implements IIDBService.ImportFile
|
||||
Dim oFilePath = Path.Combine(AppConfig.ContainerPath, FileInfo.Name)
|
||||
Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name}
|
||||
|
||||
Try
|
||||
_logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oFilePath)
|
||||
Using oStream = New FileStream(oFilePath, FileMode.CreateNew)
|
||||
oStream.Write(Contents, 0, Contents.Length)
|
||||
oStream.Flush(True)
|
||||
oStream.Close()
|
||||
End Using
|
||||
|
||||
Dim oAttributes = IO.File.GetAttributes(oFilePath) Or FileAttributes.ReadOnly
|
||||
|
||||
_logger.Info("Setting LastAccessTime")
|
||||
IO.File.SetLastAccessTime(oFilePath, Date.Now.AddYears(30))
|
||||
|
||||
_logger.Info("Setting ReadOnly Attribute")
|
||||
IO.File.SetAttributes(oFilePath, oAttributes)
|
||||
|
||||
Return New DocumentResult2(oDocument)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult2(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Utils"
|
||||
Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResult Implements IIDBService.GetDocumentByDocumentId
|
||||
Try
|
||||
|
||||
Reference in New Issue
Block a user