EDMIService: Small fixes and exception handling
This commit is contained in:
@@ -8,6 +8,7 @@ Imports System.Data.SqlClient
|
||||
Imports System.ServiceModel.Description
|
||||
Imports DigitalData.Services.EDMIService.Messages
|
||||
Imports DigitalData.Modules.EDMI.API.Rights
|
||||
Imports DigitalData.Services.EDMIService.Exceptions
|
||||
|
||||
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
|
||||
Public Class EDMIService
|
||||
@@ -23,6 +24,9 @@ Public Class EDMIService
|
||||
Public Shared GlobalState As GlobalState
|
||||
Public Shared Scheduler As Scheduler
|
||||
|
||||
Public Const TBIDB_DOC_INFO = "TBIDB_DOC_INFO"
|
||||
Public Const TBIDB_ACCESSRIGHT = "TBIDB_ACCESSRIGHT"
|
||||
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _Debug As Boolean = False
|
||||
Private ReadOnly _Username As String
|
||||
@@ -100,11 +104,20 @@ Public Class EDMIService
|
||||
|
||||
Return New TableResult(oFilteredTable)
|
||||
Else
|
||||
Throw New ApplicationException($"DataTable {Name} does not exist")
|
||||
_Logger.Warn($"Datatable {Name} does not exist")
|
||||
Dim oDetails As New DataTableDoesNotExistFault(Name)
|
||||
Throw New FaultException(Of DataTableDoesNotExistFault)(oDetails)
|
||||
End If
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw New FaultException(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
@@ -115,9 +128,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ReturnDatatable_MSSQL_IDB, SQL: {SQL}")
|
||||
Dim oResult As DataTable = MSSQL_IDB.GetDatatable(SQL)
|
||||
Return New TableResult(oResult)
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New TableResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -126,9 +146,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ReturnScalar_MSSQL_IDB, SQL: {SQL}")
|
||||
Dim oResult As Object = MSSQL_IDB.GetScalarValue(SQL)
|
||||
Return New ScalarResult(oResult)
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New ScalarResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -137,9 +164,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ExecuteNonQuery_MSSQL_IDB, SQL: {SQL}")
|
||||
Dim oResult As Boolean = MSSQL_IDB.ExecuteNonQuery(SQL)
|
||||
Return New NonQueryResult()
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New NonQueryResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
@@ -150,9 +184,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ReturnDatatable_MSSQL_ECM, SQL: {SQL}")
|
||||
Dim oResult As DataTable = MSSQL_ECM.GetDatatable(SQL)
|
||||
Return New TableResult(oResult)
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New TableResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -161,9 +202,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ReturnScalar_MSSQL_ECM, SQL: {SQL}")
|
||||
Dim oResult As Object = MSSQL_ECM.GetScalarValue(SQL)
|
||||
Return New ScalarResult(oResult)
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New ScalarResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -172,9 +220,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ExecuteNonQuery_MSSQL_ECM, SQL: {SQL}")
|
||||
Dim oResult As Boolean = MSSQL_ECM.ExecuteNonQuery(SQL)
|
||||
Return New NonQueryResult()
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New NonQueryResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
@@ -185,9 +240,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ReturnDatatable, SQL: {SQL}")
|
||||
Dim oResult As DataTable = Firebird.GetDatatable(SQL)
|
||||
Return New TableResult(oResult)
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New TableResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -196,9 +258,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ReturnScalar, SQL: {SQL}")
|
||||
Dim oResult As Object = Firebird.GetScalarValue(SQL)
|
||||
Return New ScalarResult(oResult)
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New ScalarResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -207,9 +276,16 @@ Public Class EDMIService
|
||||
_Logger.Info($"ExecuteNonQuery, SQL: {SQL}")
|
||||
Dim oResult As Boolean = Firebird.ExecuteNonQuery(SQL)
|
||||
Return New NonQueryResult()
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New NonQueryResult(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
@@ -220,14 +296,7 @@ Public Class EDMIService
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Function ImportFile(Data As DocumentImportRequest) As DocumentImportResponse Implements IEDMIService.ImportFile
|
||||
Dim oObjectStore = GlobalState.ObjectStores.
|
||||
Where(Function(s) s.Id = Data.ObjectStoreId).
|
||||
FirstOrDefault()
|
||||
|
||||
If oObjectStore Is Nothing Then
|
||||
Throw New FaultException($"Object Store with Id [{Data.ObjectStoreId}] does not exist!")
|
||||
End If
|
||||
|
||||
Dim oObjectStore = GlobalState.ObjectStores.First()
|
||||
Dim EDMIPath = New EDMI.File.Path(LogConfig, oObjectStore.Path)
|
||||
|
||||
' TODO:
|
||||
@@ -244,12 +313,7 @@ Public Class EDMIService
|
||||
|
||||
Try
|
||||
Directory.CreateDirectory(oDirectoryPath)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw New FaultException(ex.Message)
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oAbsolutePath)
|
||||
|
||||
_Logger.Info("ImportFile: Saving file [{0}] to path [{1}]", Data.FileName, oVersionedFileName)
|
||||
@@ -270,37 +334,37 @@ Public Class EDMIService
|
||||
Dim oObjectId = MSSQL_IDB.GetScalarValue(oCommand, "@IDB_OBJ_ID")
|
||||
|
||||
Return New DocumentImportResponse() With {.ObjectId = oObjectId}
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw New FaultException(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFileByObjectId(Data As DocumentStreamRequest) As DocumentStreamResponse Implements IEDMIService.GetFileByObjectId
|
||||
Try
|
||||
Dim oSQL As String = $"SELECT ObjectStoreId FROM VWIDB_DOC_DATA WHERE IDB_OBJ_ID = {Data.ObjectId}"
|
||||
Dim oObjectStoreId = MSSQL_IDB.GetScalarValue(oSQL)
|
||||
Dim oFullPath = GetFullPathForObjectId(Data.ObjectId)
|
||||
|
||||
Dim oObjectStore = GlobalState.ObjectStores.
|
||||
Where(Function(s) s.Id = oObjectStoreId).
|
||||
FirstOrDefault()
|
||||
|
||||
Dim oSQL2 As String = $"SELECT DocRelativePath FROM VWIDB_DOC_DATA WHERE IDB_OBJ_ID = {Data.ObjectId}"
|
||||
Dim oPath As String = MSSQL_IDB.GetScalarValue(oSQL2)
|
||||
|
||||
If IsNothing(oPath) Then
|
||||
Throw New FaultException($"Object [{Data.ObjectId}] does not exist in database!")
|
||||
If oFullPath = String.Empty Then
|
||||
Dim oDetails As New ObjectDoesNotExistFault(Data.ObjectId)
|
||||
_Logger.Warn("GetFileByObjectId: " & oDetails.ErrorMessage)
|
||||
Throw New FaultException(Of ObjectDoesNotExistFault)(oDetails, oDetails.ErrorMessage)
|
||||
End If
|
||||
|
||||
Dim EDMIPath As New EDMI.File.Path(LogConfig, oObjectStore.Path)
|
||||
Dim oFullPath = EDMIPath.GetFullPathFromRelativePath(oPath)
|
||||
|
||||
_Logger.Debug("GetFileByObjectId: Loading file [{0}]", oFullPath)
|
||||
|
||||
Dim oFileInfo As New FileInfo(oFullPath)
|
||||
|
||||
If Not oFileInfo.Exists Then
|
||||
Throw New FaultException($"Object [{Data.ObjectId}] does not exist on filesystem!")
|
||||
Dim oDetails As New ObjectDoesNotExistFault(Data.ObjectId)
|
||||
_Logger.Warn("GetFileByObjectId: " & oDetails.ErrorMessage)
|
||||
Throw New FaultException(Of ObjectDoesNotExistFault)(oDetails, oDetails.ErrorMessage)
|
||||
End If
|
||||
|
||||
Dim oDestination As New MemoryStream()
|
||||
@@ -309,109 +373,145 @@ Public Class EDMIService
|
||||
End Using
|
||||
oDestination.Seek(0, SeekOrigin.Begin)
|
||||
|
||||
Dim oMessage As New Messages.DocumentStreamResponse() With {
|
||||
Dim oMessage As New DocumentStreamResponse() With {
|
||||
.FileName = oFileInfo.Name,
|
||||
.FileContents = oDestination
|
||||
}
|
||||
|
||||
Return oMessage
|
||||
|
||||
Catch ex As IOException
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw New FaultException($"Object [{Data.ObjectId}] could not be streamed!")
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw New FaultException(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ListFilesForUser() As DocumentListResponse Implements IEDMIService.ListFilesForUser
|
||||
Try
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_DOC_DATA"
|
||||
Dim oDatatable As DataTable = MSSQL_IDB.GetDatatable(oSQL)
|
||||
oDatatable.TableName = "DocumentList"
|
||||
Dim oDatatable = GetFileList()
|
||||
|
||||
Return New DocumentListResponse() With {
|
||||
.Datatable = oDatatable
|
||||
}
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw New FaultException(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFileInfoByObjectId(Data As DocumentInfoRequest) As DocumentInfoResponse Implements IEDMIService.GetFileInfoByObjectId
|
||||
Try
|
||||
Dim oAccessRight = GetAccessRight(Data.UserId, Data.ObjectId)
|
||||
Dim oFullPath = GetFullPath(Data.ObjectId)
|
||||
Dim oAccessRight = GetAccessRightForObjectId(Data.UserId, Data.ObjectId)
|
||||
Dim oFullPath = GetFullPathForObjectId(Data.ObjectId)
|
||||
|
||||
If oFullPath = String.Empty Then
|
||||
Dim oDetails As New ObjectDoesNotExistFault(Data.ObjectId)
|
||||
Throw New FaultException(Of ObjectDoesNotExistFault)(oDetails)
|
||||
End If
|
||||
|
||||
Return New DocumentInfoResponse With {
|
||||
.FileRight = oAccessRight,
|
||||
.FullPath = oFullPath
|
||||
}
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw New FaultException(ex.Message)
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetFullPath(ObjectId As Long) As String
|
||||
Dim oTableName As String = "TBIDB_DOC_INFO"
|
||||
|
||||
If Not GlobalState.TableStore.Tables.Contains(oTableName) Then
|
||||
_Logger.Warn("GetFullPath: Document info table does not exist!")
|
||||
Return String.Empty
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(oTableName)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId}").ToList()
|
||||
|
||||
Dim oFullPath As String
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetFullPath: Full path does not exist for on object [{1}]", ObjectId)
|
||||
oFullPath = String.Empty
|
||||
Else
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
oFullPath = oRow.Item("FULL_PATH")
|
||||
End If
|
||||
|
||||
Return oFullPath
|
||||
End Function
|
||||
|
||||
Private Function GetAccessRight(UserId As Long, ObjectId As Long) As AccessRight
|
||||
Dim oTableName As String = "TBIDB_ACCESSRIGHT"
|
||||
|
||||
If Not GlobalState.TableStore.Tables.Contains(oTableName) Then
|
||||
_Logger.Warn("GetAccessRight: Access right table does not exist!")
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(oTableName)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId} AND USR_ID = {UserId}").ToList()
|
||||
Dim oRight As AccessRight = AccessRight.VIEW_ONLY
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetAccessRight: Access right assignment does not exist for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
Else
|
||||
If oRows.Count > 1 Then
|
||||
_Logger.Warn("GetAccessRight: More than one access right assignment found for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
Public Function GetFileList() As DataTable
|
||||
Try
|
||||
If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then
|
||||
_Logger.Warn("GetFileList: Document info table does not exist!")
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
Dim oRightAsInt = oRow.Item("ACCESSRIGHT")
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_DOC_INFO)
|
||||
Return oTable
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetFileList: Unexpected Error while getting file list.")
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Private Function GetFullPathForObjectId(ObjectId As Long) As String
|
||||
Try
|
||||
If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then
|
||||
_Logger.Warn("GetFullPathForObjectId: Document info table does not exist!")
|
||||
Return String.Empty
|
||||
End If
|
||||
|
||||
oRight = Utils.ToEnum(Of AccessRight)(oRightAsInt)
|
||||
End If
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_DOC_INFO)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId}").ToList()
|
||||
|
||||
Return oRight
|
||||
Dim oFullPath As String
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetFullPathForObjectId: Full path does not exist for on object [{1}]", ObjectId)
|
||||
oFullPath = String.Empty
|
||||
Else
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
oFullPath = oRow.Item("FULL_PATH")
|
||||
End If
|
||||
|
||||
Return oFullPath
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetFullPathForObjectId: Unexpected Error while getting full path for object [{0}].", ObjectId)
|
||||
_Logger.Error(ex)
|
||||
Return String.Empty
|
||||
End Try
|
||||
End Function
|
||||
Private Function GetAccessRightForObjectId(UserId As Long, ObjectId As Long) As AccessRight
|
||||
Try
|
||||
If Not GlobalState.TableStore.Tables.Contains(TBIDB_ACCESSRIGHT) Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: Access right table does not exist!")
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_ACCESSRIGHT)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId} AND USR_ID = {UserId}").ToList()
|
||||
Dim oRight As AccessRight
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: Access right assignment does not exist for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
Else
|
||||
If oRows.Count > 1 Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: More than one access right assignment found for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
Dim oRightAsInt = oRow.Item("ACCESSRIGHT")
|
||||
|
||||
oRight = Utils.ToEnum(Of AccessRight)(oRightAsInt)
|
||||
End If
|
||||
|
||||
Return oRight
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetAccessRightForObjectId: Unexpected Error while getting access right for object [{0}].", ObjectId)
|
||||
_Logger.Error(ex)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
End Class
|
||||
@@ -126,14 +126,13 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Config.vb" />
|
||||
<Compile Include="GlobalState.vb" />
|
||||
<Compile Include="Results.vb" />
|
||||
<Compile Include="Results\AccessRightResult.vb" />
|
||||
<Compile Include="Results\Messages.vb" />
|
||||
<Compile Include="Results\BaseResult.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Results\DatabaseResult.vb" />
|
||||
<Compile Include="Helpers\AccessRightResult.vb" />
|
||||
<Compile Include="Helpers\Messages.vb" />
|
||||
<Compile Include="Helpers\BaseResult.vb" />
|
||||
<Compile Include="Helpers\Exceptions.vb" />
|
||||
<Compile Include="Helpers\DatabaseResult.vb" />
|
||||
<Compile Include="EDMIService.vb" />
|
||||
<Compile Include="Scheduler.vb" />
|
||||
<Compile Include="Scheduler\Scheduler.vb" />
|
||||
<Compile Include="Scheduler\DatatableJob.vb" />
|
||||
<Compile Include="Scheduler\JobListener.vb" />
|
||||
<Compile Include="Scheduler\JobResult.vb" />
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
Imports System.ServiceModel
|
||||
|
||||
Public Class Exceptions
|
||||
|
||||
Public Class BaseException
|
||||
Inherits FaultException
|
||||
End Class
|
||||
|
||||
Public Class NoRequestException
|
||||
Inherits BaseException
|
||||
End Class
|
||||
|
||||
End Class
|
||||
71
Service.EDMIService/Helpers/Exceptions.vb
Normal file
71
Service.EDMIService/Helpers/Exceptions.vb
Normal file
@@ -0,0 +1,71 @@
|
||||
Imports System.Runtime.Serialization
|
||||
Imports System.ServiceModel
|
||||
|
||||
Namespace Exceptions
|
||||
|
||||
|
||||
Public Class UnexpectedErrorException(Of UnexpectedErrorFault)
|
||||
Inherits FaultException
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<DataContract>
|
||||
Public Class BaseFault
|
||||
''' <summary>
|
||||
''' The human readable error message
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property ErrorMessage As String
|
||||
|
||||
<DataMember>
|
||||
Public Property InnerException As Exception
|
||||
|
||||
<DataMember>
|
||||
Public Property IsRecoverable As Boolean = True
|
||||
End Class
|
||||
|
||||
<DataContract>
|
||||
Public Class UnexpectedErrorFault
|
||||
Inherits BaseFault
|
||||
|
||||
Public Sub New(Exception As Exception)
|
||||
MyBase.New()
|
||||
ErrorMessage = "Unexpected Error"
|
||||
IsRecoverable = True
|
||||
InnerException = Exception
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
<DataContract>
|
||||
Public Class DataTableDoesNotExistFault
|
||||
Inherits BaseFault
|
||||
|
||||
Public Sub New(Name As String)
|
||||
MyBase.New()
|
||||
ErrorMessage = $"Datatable {Name} does not exist"
|
||||
IsRecoverable = True
|
||||
InnerException = Nothing
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
<DataContract>
|
||||
Public Class ObjectDoesNotExistFault
|
||||
Inherits BaseFault
|
||||
|
||||
Public Sub New(ObjectId As Long)
|
||||
MyBase.New()
|
||||
ErrorMessage = $"Object with Id {ObjectId} does not exist"
|
||||
IsRecoverable = True
|
||||
InnerException = Nothing
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -1,8 +1,8 @@
|
||||
Imports System.IO
|
||||
Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Services.EDMIService.Exceptions
|
||||
Imports DigitalData.Services.EDMIService.Messages
|
||||
Imports DigitalData.Services.EDMIService.Results
|
||||
|
||||
<ServiceContract(Name:="IEDMIService", [Namespace]:="http://DigitalData.Services.EDMIService")>
|
||||
Interface IEDMIService
|
||||
@@ -14,53 +14,69 @@ Interface IEDMIService
|
||||
|
||||
#Region "Database"
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
<FaultContract(GetType(DataTableDoesNotExistFault))>
|
||||
Function ReturnDatatableFromCache(Name As String, FilterExpression As String, SortByColumn As String) As TableResult
|
||||
#End Region
|
||||
|
||||
#Region "Database (Firebird)"
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ReturnDatatable_Firebird(SQL As String) As TableResult
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ReturnScalar_Firebird(SQL As String) As ScalarResult
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ExecuteNonQuery_Firebird(SQL As String) As NonQueryResult
|
||||
#End Region
|
||||
|
||||
#Region "Database (MSSQL IDB)"
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ReturnDatatable_MSSQL_IDB(SQL As String) As TableResult
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ReturnScalar_MSSQL_IDB(SQL As String) As ScalarResult
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ExecuteNonQuery_MSSQL_IDB(SQL As String) As NonQueryResult
|
||||
#End Region
|
||||
|
||||
#Region "Database (MSSQL ECM)"
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ReturnDatatable_MSSQL_ECM(SQL As String) As TableResult
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ReturnScalar_MSSQL_ECM(SQL As String) As ScalarResult
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ExecuteNonQuery_MSSQL_ECM(SQL As String) As NonQueryResult
|
||||
#End Region
|
||||
|
||||
#Region "Document (New)"
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ImportFile(Data As DocumentImportRequest) As DocumentImportResponse
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(ObjectDoesNotExistFault))>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function GetFileByObjectId(Data As DocumentStreamRequest) As DocumentStreamResponse
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function GetFileInfoByObjectId(Data As DocumentInfoRequest) As DocumentInfoResponse
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ListFilesForUser() As DocumentListResponse
|
||||
#End Region
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Friend Class Results
|
||||
End Class
|
||||
@@ -64,7 +64,7 @@ Public Class DatatableJob
|
||||
oResultTable.TableRelationColumn = oParentColumn
|
||||
End If
|
||||
|
||||
oLogger.Info("Fetched Datatable [{0}]", oDatatableName)
|
||||
oLogger.Debug("Fetched Datatable [{0}]", oDatatableName)
|
||||
oResult.Tables.Add(oResultTable)
|
||||
Catch ex As Exception
|
||||
oLogger.Warn("Execute: Error while saving Table: [{0}]", oDatatableName)
|
||||
@@ -72,6 +72,8 @@ Public Class DatatableJob
|
||||
End Try
|
||||
Next
|
||||
|
||||
oLogger.Info("Fetched [{0}] Datatables", oResult.Tables.Count)
|
||||
|
||||
' Das Ergebnis speichern
|
||||
context.Result = oResult
|
||||
|
||||
@@ -81,60 +83,5 @@ Public Class DatatableJob
|
||||
End Try
|
||||
|
||||
Return Task.FromResult(True)
|
||||
|
||||
#Region "OLD"
|
||||
'Dim oJobData = context.MergedJobDataMap
|
||||
'Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
|
||||
'Dim oLogger As Logger = oLogConfig.GetLogger()
|
||||
'Dim oDetailRow As DataRow = oJobData.Item("CronJobDetails")
|
||||
'Dim oDatatableName As String = NotNull(oDetailRow.Item("DT_NAME"), String.Empty)
|
||||
|
||||
'Try
|
||||
' Dim oCronJobTitle As String = oJobData.Item("CronJobTitle")
|
||||
' Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL")
|
||||
|
||||
' Dim oConnectionId As Integer = NotNull(oDetailRow.Item("CON_ID"), String.Empty)
|
||||
' Dim oTitle As String = NotNull(oDetailRow.Item("TITLE"), String.Empty)
|
||||
' Dim oSQL As String = NotNull(oDetailRow.Item("COMMAND"), String.Empty)
|
||||
|
||||
' oLogger.Debug("Running Command-Job [{0}]", oTitle)
|
||||
' oLogger.Debug("Datatable Name: {0}", oDatatableName)
|
||||
' oLogger.Debug("Connection Id: {0}", oConnectionId)
|
||||
|
||||
' Dim oConnectionString = oMSSQL.Get_ConnectionStringforID(oConnectionId)
|
||||
|
||||
' Dim oTable = oMSSQL.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
' oTable.TableName = oDatatableName
|
||||
' oLogger.Debug("Result Datatable [{0}] contains [{1}] rows", oTable.TableName, oTable.Rows.Count)
|
||||
|
||||
' Dim oResult = New JobResult() With {
|
||||
' .Table = oTable
|
||||
' }
|
||||
|
||||
' Dim oChildTableNAme As String = NotNull(oDetailRow.Item("CHILD_DT_NAME"), String.Empty)
|
||||
|
||||
' If oChildTableNAme <> String.Empty Then
|
||||
' Dim oParentColumn As String = NotNull(oDetailRow.Item("DT_COLUMN"), String.Empty)
|
||||
' Dim oChildColumn As String = NotNull(oDetailRow.Item("CHILD_DT_COLUMN"), String.Empty)
|
||||
' oLogger.Debug("Child Datatable [{0}] defined, Relation: Parent [{1}] -> Child [{2}]", oChildTableName, oParentColumn, oChildColumn)
|
||||
|
||||
' Dim oChildTable As DataTable = oMSSQL.GetDatatableWithConnection($"SELECT * FROM {oChildTableName}", oConnectionString)
|
||||
' oChildTable.TableName = oChildTableName
|
||||
' oLogger.Debug("Child Datatable [{0}] contains [{1}] rows", oChildTable.TableName, oChildTable.Rows.Count)
|
||||
|
||||
' oResult.ChildTable = oChildTable
|
||||
' oResult.ChildRelationColumn = oChildColumn
|
||||
' oResult.TableRelationColumn = oParentColumn
|
||||
' End If
|
||||
|
||||
' ' Das Ergebnis speichern
|
||||
' context.Result = oResult
|
||||
'Catch ex As Exception
|
||||
' oLogger.Error(ex)
|
||||
' oLogger.Warn("Unhandled exception while executing SQL for Datatable {0}", oDatatableName)
|
||||
'End Try
|
||||
|
||||
'Return Task.FromResult(True)
|
||||
#End Region
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@@ -167,8 +167,8 @@ Public Class JobListener
|
||||
Dim oDatatableNameTemp As String = oName & "-TEMP"
|
||||
|
||||
' Used for debugging relations and constraints
|
||||
_Logger.Debug("Dataset BEFORE saving datatables")
|
||||
ListTables(Dataset)
|
||||
'_Logger.Debug("Dataset BEFORE saving datatables")
|
||||
'ListTables(Dataset)
|
||||
|
||||
If Dataset.Tables.Contains(oName) Then
|
||||
' Replace existing table
|
||||
@@ -193,14 +193,9 @@ Public Class JobListener
|
||||
_Logger.Debug(oDataTable.TableName)
|
||||
Next
|
||||
|
||||
_Logger.Debug("Listing Relations in Dataset")
|
||||
For Each oRelation As DataRelation In Dataset.Relations
|
||||
_Logger.Debug(oRelation.RelationName)
|
||||
Next
|
||||
|
||||
' Used for debugging relations and constraints
|
||||
_Logger.Debug("Dataset AFTER saving datatables")
|
||||
ListTables(Dataset)
|
||||
'_Logger.Debug("Dataset AFTER saving datatables")
|
||||
'ListTables(Dataset)
|
||||
|
||||
_MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})")
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user