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