Common/DocumentResultList: Catch errors better
This commit is contained in:
parent
38608e353a
commit
b1af861810
@ -20,6 +20,7 @@
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>DigitalData.GUIs.Common.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
||||
@ -4,6 +4,7 @@ Imports DigitalData.Modules.EDMI.API.Client
|
||||
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow.Constants
|
||||
Imports DigitalData.Modules.ZooFlow.State
|
||||
|
||||
Public Class DocumentLoader
|
||||
Inherits Modules.ZooFlow.Base.BaseClass
|
||||
@ -27,7 +28,6 @@ Public Class DocumentLoader
|
||||
Case OperationMode.WithAppServer
|
||||
Return Load_FromIDB(pObjectId)
|
||||
|
||||
|
||||
Case OperationMode.ZooFlow
|
||||
Return Load_FromZooflow(pObjectId)
|
||||
|
||||
@ -49,20 +49,30 @@ Public Class DocumentLoader
|
||||
End Function
|
||||
|
||||
Private Function Load_FromIDB(pObjectId As Long) As DocumentResultInfo
|
||||
Dim oDocumentInfo As DocumentInfo = Client.GetDocumentInfo(User.UserId, pObjectId)
|
||||
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
|
||||
Dim oResultDocumentInfo As New DocumentResultInfo(pObjectId) With {
|
||||
.Contents = Load_FromDisk(oDocumentInfo.FullPath),
|
||||
.AccessRight = oDocumentInfo.AccessRight,
|
||||
.FullPath = oDocumentInfo.FullPath,
|
||||
.Extension = oFileInfo.Extension.Substring(1)
|
||||
}
|
||||
Try
|
||||
Dim oDocumentInfo As DocumentInfo = Client.GetDocumentInfo(User.UserId, pObjectId)
|
||||
Dim oFileInfo As New FileInfo(oDocumentInfo.FullPath)
|
||||
Dim oResultDocumentInfo As New DocumentResultInfo(pObjectId) With {
|
||||
.Contents = Load_FromDisk(oDocumentInfo.FullPath),
|
||||
.AccessRight = oDocumentInfo.AccessRight,
|
||||
.FullPath = oDocumentInfo.FullPath,
|
||||
.Extension = oFileInfo.Extension.Substring(1)
|
||||
}
|
||||
|
||||
Return oResultDocumentInfo
|
||||
Return oResultDocumentInfo
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function Load_FromZooflow(pObjectId As Long) As DocumentResultInfo
|
||||
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 {
|
||||
.Contents = oFileObject._FileContents,
|
||||
.Extension = oFileObject._FileExtension,
|
||||
|
||||
@ -210,12 +210,6 @@ Public Class frmDocumentResultList
|
||||
DocumentViewer1.CloseDocument()
|
||||
|
||||
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
|
||||
If IsNothing(oDocumentInfo) Then
|
||||
@ -223,6 +217,13 @@ Public Class frmDocumentResultList
|
||||
Exit Sub
|
||||
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
|
||||
DocumentViewer1.SetViewOnly(True)
|
||||
RibbonPageGroup_Export.Visible = False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user