Common/DocumentResultList: Catch errors better

This commit is contained in:
Jonathan Jenne 2021-12-23 10:29:37 +01:00
parent 38608e353a
commit b1af861810
3 changed files with 28 additions and 16 deletions

View File

@ -20,6 +20,7 @@
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>DigitalData.GUIs.Common.xml</DocumentationFile> <DocumentationFile>DigitalData.GUIs.Common.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>

View File

@ -4,6 +4,7 @@ Imports DigitalData.Modules.EDMI.API.Client
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.ZooFlow.Constants Imports DigitalData.Modules.ZooFlow.Constants
Imports DigitalData.Modules.ZooFlow.State
Public Class DocumentLoader Public Class DocumentLoader
Inherits Modules.ZooFlow.Base.BaseClass Inherits Modules.ZooFlow.Base.BaseClass
@ -27,7 +28,6 @@ Public Class DocumentLoader
Case OperationMode.WithAppServer Case OperationMode.WithAppServer
Return Load_FromIDB(pObjectId) Return Load_FromIDB(pObjectId)
Case OperationMode.ZooFlow Case OperationMode.ZooFlow
Return Load_FromZooflow(pObjectId) Return Load_FromZooflow(pObjectId)
@ -49,6 +49,7 @@ Public Class DocumentLoader
End Function End Function
Private Function Load_FromIDB(pObjectId As Long) As DocumentResultInfo Private Function Load_FromIDB(pObjectId As Long) As DocumentResultInfo
Try
Dim oDocumentInfo As DocumentInfo = Client.GetDocumentInfo(User.UserId, pObjectId) Dim oDocumentInfo As DocumentInfo = Client.GetDocumentInfo(User.UserId, pObjectId)
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath) Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
Dim oResultDocumentInfo As New DocumentResultInfo(pObjectId) With { Dim oResultDocumentInfo As New DocumentResultInfo(pObjectId) With {
@ -59,10 +60,19 @@ Public Class DocumentLoader
} }
Return oResultDocumentInfo Return oResultDocumentInfo
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function End Function
Private Function Load_FromZooflow(pObjectId As Long) As DocumentResultInfo Private Function Load_FromZooflow(pObjectId As Long) As DocumentResultInfo
Dim oFileObject As FileObject = Client.GetFileObject(pObjectId, pLoadFileContents:=True) Dim oFileObject As FileObject = Client.GetFileObject(pObjectId, pLoadFileContents:=True)
If oFileObject Is Nothing Then
Return Nothing
End If
Dim oResultDocumentInfo As New DocumentResultInfo(pObjectId) With { Dim oResultDocumentInfo As New DocumentResultInfo(pObjectId) With {
.Contents = oFileObject._FileContents, .Contents = oFileObject._FileContents,
.Extension = oFileObject._FileExtension, .Extension = oFileObject._FileExtension,

View File

@ -210,12 +210,6 @@ Public Class frmDocumentResultList
DocumentViewer1.CloseDocument() DocumentViewer1.CloseDocument()
oDocumentInfo = _documentloader.Load(oObjectId, oFullPath) oDocumentInfo = _documentloader.Load(oObjectId, oFullPath)
Dim oFileName = $"{oObjectId}.{oDocumentInfo.Extension}"
DocumentViewer1.LoadFile(oFileName, New MemoryStream(oDocumentInfo.Contents))
' Save reference to current
_CurrentDocument = oDocumentInfo
' Check DocumentInfo ' Check DocumentInfo
If IsNothing(oDocumentInfo) Then If IsNothing(oDocumentInfo) Then
@ -223,6 +217,13 @@ Public Class frmDocumentResultList
Exit Sub Exit Sub
End If End If
Dim oFileName = $"{oObjectId}.{oDocumentInfo.Extension}"
DocumentViewer1.LoadFile(oFileName, New MemoryStream(oDocumentInfo.Contents))
' Save reference to current
_CurrentDocument = oDocumentInfo
If oDocumentInfo.AccessRight = Rights.AccessRight.VIEW_ONLY Then If oDocumentInfo.AccessRight = Rights.AccessRight.VIEW_ONLY Then
DocumentViewer1.SetViewOnly(True) DocumentViewer1.SetViewOnly(True)
RibbonPageGroup_Export.Visible = False RibbonPageGroup_Export.Visible = False