EDMIService: clean up edmiservice
This commit is contained in:
parent
8530005b6b
commit
6fc4541567
@ -519,54 +519,61 @@ Public Class EDMIService
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End Try
|
||||
End Function
|
||||
Public Function New_FileStore_Object(IDB_OBJ_ID As Long, pStoreType As String, pDate As String, pExtension As String, pKeepExtension As Boolean) As String Implements IEDMIService.New_FileStore_Object
|
||||
|
||||
Public Function NewObjectId(Data As NewObjectIdRequest) As NewObjectIdResponse Implements IEDMIService.NewObjectId
|
||||
Try
|
||||
Dim oSQL As String = $"DECLARE @NEW_IDB_OBJ_ID BIGINT
|
||||
EXEC PRIDB_NEW_OBJECT '{Data.KindType}','{Data.Who}','{Data.BusinessEntity}',0, @IDB_OBJ_ID = @NEW_IDB_OBJ_ID OUTPUT;
|
||||
SELECT @NEW_IDB_OBJ_ID"
|
||||
Dim oObjectId = MSSQL_IDB.GetScalarValue(oSQL)
|
||||
Return New NewObjectIdResponse With {.ObjectId = oObjectId}
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return New NewObjectIdResponse With {.ObjectId = 0}
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function NewFileObject(Data As NewFileObjectRequest) As NewFileObjectResponse Implements IEDMIService.NewFileObject
|
||||
Try
|
||||
Dim oRelpath As String
|
||||
If pStoreType = String.Empty Then
|
||||
pStoreType = ClassConstants.FileStoreWork
|
||||
Dim oStoreType As String = Data.StoreType
|
||||
|
||||
If oStoreType = String.Empty Then
|
||||
oStoreType = ClassConstants.FileStoreWork
|
||||
End If
|
||||
oRelpath = GetFileStorePraefix(pStoreType)
|
||||
If pDate = String.Empty Then
|
||||
|
||||
oRelpath = GetFileStorePraefix(oStoreType)
|
||||
|
||||
If IsNothing(Data.DateImported) Then
|
||||
oRelpath = GetFolderToday(oRelpath)
|
||||
Else
|
||||
Try
|
||||
Dim odate = CDate(pDate)
|
||||
oRelpath = GetFolderDate(oRelpath, odate)
|
||||
Dim oDate = CDate(Data.DateImported)
|
||||
oRelpath = GetFolderDate(oRelpath, oDate)
|
||||
Catch ex As Exception
|
||||
Return ""
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
End Try
|
||||
End If
|
||||
Dim oIDB_FileObject As String
|
||||
If oRelpath = String.Empty Then
|
||||
Return "ERROR"
|
||||
Else
|
||||
_Logger.Debug($"oRelpath is [{oRelpath}]")
|
||||
|
||||
oIDB_FileObject = Path.Combine(oRelpath, GetDigitalDataFileObject(IDB_OBJ_ID, pExtension, pKeepExtension))
|
||||
End If
|
||||
_Logger.Debug($"oRelpath is [{oRelpath}]")
|
||||
Dim oFileObjectPath As String = Path.Combine(oRelpath, GetFileObjectFileName(Data.ObjectId, Data.Extension, Data.KeepExtension))
|
||||
Return New NewFileObjectResponse With {.FileObjectPath = oFileObjectPath}
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Return oIDB_FileObject
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return ""
|
||||
Dim oDetails As New UnexpectedErrorFault(ex)
|
||||
Throw New FaultException(Of UnexpectedErrorFault)(oDetails, oDetails.ErrorMessage)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function NewIDB_Object(pKindType As String, pWho As String, pBusinessEntity As String) As String Implements IEDMIService.New_IDB_OBJECT
|
||||
Try
|
||||
Dim oSQL As String = $"DECLARE @NEW_IDB_OBJ_ID BIGINT
|
||||
EXEC PRIDB_NEW_OBJECT '{pKindType}','{pWho}','{pBusinessEntity}',0, @IDB_OBJ_ID = @NEW_IDB_OBJ_ID OUTPUT;
|
||||
SELECT @NEW_IDB_OBJ_ID"
|
||||
Dim oObjectId = MSSQL_IDB.GetScalarValue(oSQL)
|
||||
Return oObjectId
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return 0
|
||||
End Try
|
||||
End Function
|
||||
Public Function ImportFileIDBFO(Data As DocumentImportIDBFORequest) As DocumentImportIDBFOResponse Implements IEDMIService.ImportNewIDBFO
|
||||
Public Function ImportFileIntoFileObject(Data As ImportFileIntoFileObjectRequest) As ImportFileIntoFileObjectResponse Implements IEDMIService.ImportFileIntoFileObject
|
||||
Dim oObjectStore = GlobalState.ObjectStores.First()
|
||||
Dim EDMIPath = New EDMI.File.Path(LogConfig, oObjectStore.Path)
|
||||
Dim oEDMIPath = New EDMI.File.Path(LogConfig, oObjectStore.Path)
|
||||
|
||||
Try
|
||||
Using oStream = New FileStream(Data.pIDBFilePath, FileMode.Create, FileAccess.Write)
|
||||
@ -580,10 +587,9 @@ Public Class EDMIService
|
||||
|
||||
' insert into db
|
||||
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{Data.pIDBFilePath}','{Data.pWho}','{Data.pIDB_OBJ_ID}',{Data.pObjectStoreID}"
|
||||
|
||||
Dim oResult As Boolean = MSSQL_IDB.ExecuteNonQuery(oSQL)
|
||||
|
||||
Return New DocumentImportIDBFOResponse() With {.Result = oResult}
|
||||
Return New ImportFileIntoFileObjectResponse() With {.Result = oResult}
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
@ -596,34 +602,33 @@ Public Class EDMIService
|
||||
|
||||
End Try
|
||||
End Function
|
||||
Private Function GetDigitalDataFileObject(IDB_OBJ_ID As Long, pExtension As String, pKeepExtension As Boolean) As String
|
||||
#End Region
|
||||
|
||||
Private Function GetFileObjectFileName(IDB_OBJ_ID As Long, pExtension As String, pKeepExtension As Boolean) As String
|
||||
If pKeepExtension Then
|
||||
Return $"{IDB_OBJ_ID}.{pExtension}"
|
||||
Else
|
||||
Return $"{IDB_OBJ_ID}.ddfo"
|
||||
End If
|
||||
|
||||
End Function
|
||||
Private Function GetFileStorePraefix(pStoreType As String) As String
|
||||
Dim oObjectStore
|
||||
Dim EDMIPath As String
|
||||
If pStoreType = ClassConstants.FileStoreArchive Then
|
||||
oObjectStore = GlobalState.ObjectStores.Item(0)
|
||||
Else pStoreType = ClassConstants.FileStoreWork
|
||||
Else 'pStoreType = ClassConstants.FileStoreWork
|
||||
oObjectStore = GlobalState.ObjectStores.Item(1)
|
||||
End If
|
||||
_Logger.Debug($"oObjectStore is [{oObjectStore.Path}]")
|
||||
Return oObjectStore.Path
|
||||
|
||||
End Function
|
||||
Private Function GetFolderToday(pRelationalPath As String) As String
|
||||
Dim oDateSubDirectoryName As String = Now.ToString("yyyy-MM-dd")
|
||||
Dim oDateSubDirectoryName As String = GetDateSubDirectory(Now)
|
||||
Dim oFolderToday As String = Path.Combine(pRelationalPath, oDateSubDirectoryName)
|
||||
' Create the destination directory if it does not exist
|
||||
If Not Directory.Exists(oFolderToday) Then
|
||||
Try
|
||||
Directory.CreateDirectory(oFolderToday)
|
||||
_Logger.Debug($"created NEW todayFolder [{oFolderToday}]")
|
||||
_Logger.Debug($"Created NEW todayFolder [{oFolderToday}]")
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return ""
|
||||
@ -632,13 +637,13 @@ Public Class EDMIService
|
||||
Return oFolderToday
|
||||
End Function
|
||||
Private Function GetFolderDate(pRelationalPath As String, pDate As Date) As String
|
||||
Dim oDateSubDirectoryName As String = pDate.ToString("yyyy-MM-dd")
|
||||
Dim oDateSubDirectoryName As String = GetDateSubDirectory(pDate)
|
||||
Dim oFolderDateSepecial As String = Path.Combine(pRelationalPath, oDateSubDirectoryName)
|
||||
' Create the destination directory if it does not exist
|
||||
If Not Directory.Exists(oFolderDateSepecial) Then
|
||||
Try
|
||||
Directory.CreateDirectory(oFolderDateSepecial)
|
||||
_Logger.Debug($"created NEW DateSpecialFolder [{oFolderDateSepecial}]")
|
||||
_Logger.Debug($"Created NEW DateSpecialFolder [{oFolderDateSepecial}]")
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return ""
|
||||
@ -646,8 +651,9 @@ Public Class EDMIService
|
||||
End If
|
||||
Return oFolderDateSepecial
|
||||
End Function
|
||||
Private Function GetDateSubDirectory([Date] As Date) As String
|
||||
Return [Date].ToString("yyyy-MM-dd")
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
End Class
|
||||
@ -26,9 +26,9 @@ Namespace Messages
|
||||
Public ObjectId As Long
|
||||
End Class
|
||||
#End Region
|
||||
#Region "DocumentImportIDBFO"
|
||||
#Region "FileImport 2021"
|
||||
<MessageContract>
|
||||
Public Class DocumentImportIDBFORequest
|
||||
Public Class ImportFileIntoFileObjectRequest
|
||||
<MessageBodyMember>
|
||||
Public Contents() As Byte
|
||||
<MessageBodyMember>
|
||||
@ -42,10 +42,47 @@ Namespace Messages
|
||||
End Class
|
||||
|
||||
<MessageContract>
|
||||
Public Class DocumentImportIDBFOResponse
|
||||
Public Class ImportFileIntoFileObjectResponse
|
||||
<MessageBodyMember>
|
||||
Public Result As Boolean
|
||||
End Class
|
||||
|
||||
<MessageContract>
|
||||
Public Class NewObjectIdRequest
|
||||
<MessageBodyMember>
|
||||
Public KindType As String
|
||||
<MessageBodyMember>
|
||||
Public Who As String
|
||||
<MessageBodyMember>
|
||||
Public BusinessEntity As String
|
||||
End Class
|
||||
|
||||
<MessageContract>
|
||||
Public Class NewObjectIdResponse
|
||||
<MessageBodyMember>
|
||||
Public ObjectId As Long
|
||||
End Class
|
||||
|
||||
<MessageContract>
|
||||
Public Class NewFileObjectRequest
|
||||
<MessageBodyMember>
|
||||
Public ObjectId As Long
|
||||
<MessageBodyMember>
|
||||
Public StoreType As String
|
||||
<MessageBodyMember>
|
||||
Public DateImported As Date
|
||||
<MessageBodyMember>
|
||||
Public Extension As String
|
||||
<MessageBodyMember>
|
||||
Public KeepExtension As Boolean
|
||||
End Class
|
||||
|
||||
<MessageContract>
|
||||
Public Class NewFileObjectResponse
|
||||
<MessageBodyMember>
|
||||
Public FileObjectPath As String
|
||||
End Class
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "DocumentStream"
|
||||
|
||||
@ -81,14 +81,15 @@ Interface IEDMIService
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function New_FileStore_Object(IDB_OBJ_ID As Long, pStoreType As String, pDate As String, pExtension As String, pKeepExtension As Boolean) As String
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function New_IDB_OBJECT(KindType As String, pWho As String, pBusinessEntity As String) As String
|
||||
Function NewObjectId(Data As NewObjectIdRequest) As NewObjectIdResponse
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ImportNewIDBFO(Data As DocumentImportIDBFORequest) As DocumentImportIDBFOResponse
|
||||
Function NewFileObject(Data As NewFileObjectRequest) As NewFileObjectResponse
|
||||
|
||||
<OperationContract>
|
||||
<FaultContract(GetType(UnexpectedErrorFault))>
|
||||
Function ImportFileIntoFileObject(Data As ImportFileIntoFileObjectRequest) As ImportFileIntoFileObjectResponse
|
||||
#End Region
|
||||
|
||||
End Interface
|
||||
Loading…
x
Reference in New Issue
Block a user