diff --git a/GUIs.Common/DocumentResultList/Watcher.vb b/GUIs.Common/DocumentResultList/Watcher.vb
index 63c01204..834ba40d 100644
--- a/GUIs.Common/DocumentResultList/Watcher.vb
+++ b/GUIs.Common/DocumentResultList/Watcher.vb
@@ -21,6 +21,11 @@ Namespace DocumentResultList
'''
Private ReadOnly OpenFiles As New List(Of OpenFile)
+ '''
+ ''' List of files that changed and are processed by the client, ie. updated
+ '''
+ Private ReadOnly ProcessedFiles As New List(Of OpenFile)
+
Public Event FileChanged As EventHandler(Of FileChangedArgs)
Public Class OpenFile
@@ -39,15 +44,15 @@ Namespace DocumentResultList
FileEx = New Modules.Filesystem.File(pLogConfig)
End Sub
- Public Function OpenDocument(pDocument As Document) As Boolean
+ Public Async Function OpenDocument(pDocument As Document) As Task(Of Boolean)
Dim oResult As Tuple(Of Process, String) = Nothing
- If pDocument.FullPath IsNot Nothing OrElse pDocument.FullPath.Trim <> String.Empty Then
+ If pDocument.FullPath IsNot Nothing AndAlso pDocument.FullPath.Trim <> String.Empty Then
' TODO: DONT put into openfiles
oResult = OpenFileFromPath(pDocument)
ElseIf pDocument.Extension IsNot Nothing AndAlso pDocument.Contents IsNot Nothing Then
- oResult = OpenFileFromByteArray(pDocument)
+ oResult = Await OpenFileFromByteArray(pDocument)
End If
@@ -67,14 +72,21 @@ Namespace DocumentResultList
.ProcessId = oProcess.Id
})
+
+ If FileOpenTimer.Enabled = False Then
+ FileOpenTimer.Interval = 10000
+ FileOpenTimer.Start()
+ End If
+
Return True
End Function
Public Sub FileSaved(pOpenFile As OpenFile)
- pOpenFile.CurrentlyProcessing = False
+ OpenFiles.Remove(pOpenFile)
+ ProcessedFiles.Remove(pOpenFile)
End Sub
- Private Function OpenFileFromByteArray(pDocument As Document) As Tuple(Of Process, String)
+ Private Async Function OpenFileFromByteArray(pDocument As Document) As Task(Of Tuple(Of Process, String))
Try
Dim oTempPath = Path.Combine(Path.GetTempPath(), Constants.TEMP_PATH_SUBFOLDER)
Dim oDirectory = Directory.CreateDirectory(oTempPath)
@@ -82,8 +94,8 @@ Namespace DocumentResultList
Dim oFilePath = Path.Combine(oTempPath, oFileName)
Using oMemoryStream As New MemoryStream(pDocument.Contents)
- Using oStreamWriter As New StreamWriter(oFilePath, append:=False, Encoding.UTF8)
- oMemoryStream.CopyTo(oMemoryStream)
+ Using oFileStream As New FileStream(oFilePath, FileMode.Create, FileAccess.Write)
+ Await oMemoryStream.CopyToAsync(oFileStream)
End Using
End Using
@@ -119,14 +131,20 @@ Namespace DocumentResultList
Private Sub FileOpenTimer_Elapsed() Handles FileOpenTimer.Elapsed
Try
For Each oOpenFile In OpenFiles
+
' All files that are currently processe/updated on the outside,
' will not be checked again.
- If oOpenFile.CurrentlyProcessing = False Then
+ Dim oFileIsProcessed = ProcessedFiles.Contains(oOpenFile)
+ Debug.WriteLine($"File is processed: [{oFileIsProcessed}]")
+
+ If oFileIsProcessed = True Then
Continue For
End If
' Check if the file is currently in use, and skip if it is.
Dim oIsLocked = FileEx.TestFileIsLocked(oOpenFile.FilePath)
+ Debug.WriteLine($"File is locked: [{oIsLocked}]")
+
If oIsLocked Then
Continue For
End If
@@ -134,53 +152,37 @@ Namespace DocumentResultList
' If this point is reached, we assume the file was closed again after opening it.
' ------
+ Debug.WriteLine($"File Closed")
+
' Compute the current hash of the file and compare it with the one
' in the database.
Dim oOldHash = oOpenFile.Document.FileHash
Dim oNewHash = FileEx.GetChecksum(oOpenFile.FilePath)
+ Debug.WriteLine($"Old Hash: [{oOldHash}]")
+ Debug.WriteLine($"New Hash: [{oNewHash}]")
+
' If the the file did not change, remove it from the watch list
If oNewHash.Equals(oOldHash) Then
+ ProcessedFiles.Remove(oOpenFile)
OpenFiles.Remove(oOpenFile)
Continue For
End If
+ ' If this point is reached, we assume the file changed.
+ ' ------
+
+ Debug.WriteLine($"File Changed")
+
' The File changed, so mark the file as being processed/updated
- ' and notify any listeners of the FileChanged event
- oOpenFile.CurrentlyProcessing = True
+ ' and notify any listeners of the FileChanged event
+ ProcessedFiles.Add(oOpenFile)
+
RaiseEvent FileChanged(Me, New FileChangedArgs() With {.File = oOpenFile})
Next
Catch ex As Exception
Logger.Error(ex)
End Try
-
- 'Try
- ' Dim oIds = Process.GetProcesses().
- ' Select(Function(process) process.Id).
- ' ToList()
-
- ' Dim oNewFileOpenList As New Dictionary(Of Integer, Document)
- ' For Each oOpenFile In OpenFiles
- ' If oIds.Contains(oOpenFile.Key) Then
- ' oNewFileOpenList.Add(oOpenFile.Key, oOpenFile.Value)
- ' End If
- ' Next
-
- ' If oNewFileOpenList.Count < OpenFiles.Count Then
- ' Dim oClosedFiles = OpenFiles.
- ' Except(oNewFileOpenList).
- ' ToList()
-
- ' If oClosedFiles.Count = 1 Then
- ' Dim oOpenFile = oClosedFiles.First()
- ' RaiseEvent ProcessEnded(Me, oOpenFile.Value)
- ' End If
-
- ' OpenFiles = oNewFileOpenList
- ' End If
- 'Catch ex As Exception
- ' Logger.Error(ex)
- 'End Try
End Sub
End Class
diff --git a/GUIs.Common/frmDocumentResultList.vb b/GUIs.Common/frmDocumentResultList.vb
index 9e85bd97..06ba148b 100644
--- a/GUIs.Common/frmDocumentResultList.vb
+++ b/GUIs.Common/frmDocumentResultList.vb
@@ -229,19 +229,28 @@ Public Class frmDocumentResultList
End If
Catch ex As Exception
Logger.Error(ex)
- Show_CriticalError(ex.Message)
+ Show_CriticalError(ex)
Finally
Cursor = Cursors.Default
End Try
End Sub
- Public Sub Watcher_FileChanged(sender As Object, e As DocumentResultList.Watcher.FileChangedArgs) Handles Watcher.FileChanged
+ Public Async Sub Watcher_FileChanged(sender As Object, e As DocumentResultList.Watcher.FileChangedArgs) Handles Watcher.FileChanged
Try
+ Await _IDBClient.UpdateFileAsync(e.File.Document.Id, e.File.FilePath, New Options.UpdateFileOptions With {
+ .CreateNewFileVersion = False,
+ .Language = Environment.User.Language,
+ .Username = Environment.User.UserName
+ })
+
+
Catch ex As Exception
-
+ Logger.Error(ex)
+ Show_CriticalError(ex)
Finally
- e.File.CurrentlyProcessing = False
+ ' Signal to the watcher that the file is no longer in use
+ Watcher.FileSaved(e.File)
End Try
End Sub
@@ -565,11 +574,12 @@ Public Class frmDocumentResultList
Close()
End Sub
- Private Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick
+ Private Async Sub GridControl_DoubleClick(sender As Object, e As EventArgs) Handles GridControl1.DoubleClick, GridControl2.DoubleClick, GridControl3.DoubleClick
If _CurrentDocument IsNot Nothing AndAlso _CurrentDocument.AccessRight > Rights.AccessRight.VIEW_ONLY Then
- Process.Start(New ProcessStartInfo With {
- .FileName = _CurrentDocument.FullPath
- })
+ 'Process.Start(New ProcessStartInfo With {
+ ' .FileName = _CurrentDocument.FullPath
+ '})
+ Await Watcher.OpenDocument(_CurrentDocument)
End If
End Sub
@@ -578,6 +588,11 @@ Public Class frmDocumentResultList
labelCriticalError.Caption = Message
End Sub
+ Public Sub Show_CriticalError(pException As Exception)
+ labelCriticalError.Visibility = BarItemVisibility.Always
+ labelCriticalError.Caption = pException.Message
+ End Sub
+
Public Sub Show_Warning(Message As String)
labelWarning.Visibility = BarItemVisibility.Always
labelWarning.Caption = Message
@@ -701,15 +716,17 @@ Public Class frmDocumentResultList
oPropertyDialog.Show()
End Sub
- Private Sub MenuItemFileOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFileOpen.ItemClick
+ Private Async Sub MenuItemFileOpen_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemFileOpen.ItemClick
If TestPathExists(OPEN_FILE) = False Then
Exit Sub
End If
Try
- Process.Start(New ProcessStartInfo With {
- .FileName = _CurrentDocument.FullPath
- })
+ Await Watcher.OpenDocument(_CurrentDocument)
+
+ 'Process.Start(New ProcessStartInfo With {
+ ' .FileName = _CurrentDocument.FullPath
+ '})
Catch ex As Exception
Logger.Error(ex)
End Try
diff --git a/GUIs.ZooFlow/ApplicationEvents.vb b/GUIs.ZooFlow/ApplicationEvents.vb
index fc281a7a..cb6d4709 100644
--- a/GUIs.ZooFlow/ApplicationEvents.vb
+++ b/GUIs.ZooFlow/ApplicationEvents.vb
@@ -2,6 +2,7 @@
Imports DigitalData.Modules.EDMI.API
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Logging.LogConfig
+Imports Microsoft.VisualBasic.ApplicationServices
Namespace My
' Für MyApplication sind folgende Ereignisse verfügbar:
@@ -18,6 +19,8 @@ Namespace My
Private CommonAppDataPath As String = Windows.Forms.Application.CommonAppDataPath
Private StartupPath As String = Windows.Forms.Application.StartupPath
+
+
Public Sub App_Startup() Handles Me.Startup
Dim oLogConfig As New LogConfig(LogPath:=PathType.AppData, CompanyName:="Digital Data", ProductName:="ZooFlow", FileKeepRangeInDays:=30) With {.Debug = True}
@@ -68,6 +71,13 @@ Namespace My
Public Sub App_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown
_Logger.Debug("Shutting down Client Suite..")
+ Application.Sidebar.UnregisterSidebar()
+ End Sub
+
+ Private Sub MyApplication_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs) Handles Me.UnhandledException
+ Application.Sidebar.UnregisterSidebar()
+ _Logger.Warn("Unhandled exception occurred: [{0}]", e.Exception.Message)
+ _Logger.Error(e.Exception)
End Sub
End Class
-End Namespace
+End Namespace
\ No newline at end of file
diff --git a/GUIs.ZooFlow/MyApplication.vb b/GUIs.ZooFlow/MyApplication.vb
index 0f49db01..492f74fd 100644
--- a/GUIs.ZooFlow/MyApplication.vb
+++ b/GUIs.ZooFlow/MyApplication.vb
@@ -55,6 +55,7 @@ Namespace My
Public Property IDB_ConnectionString As String
Public Property Globix As New Globix.State
Public Property Search As New Search.State
+ Public Property Sidebar As Sidebar
Public CommandLineFunction As String
Public CommandLineArguments As New Dictionary(Of String, String)
diff --git a/GUIs.ZooFlow/Sidebar.vb b/GUIs.ZooFlow/Sidebar.vb
new file mode 100644
index 00000000..0a8e939e
--- /dev/null
+++ b/GUIs.ZooFlow/Sidebar.vb
@@ -0,0 +1,94 @@
+Public Class Sidebar
+#Region "Sidebar Declarations"
+ Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
+ Public Declare Auto Function MoveWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal X As Int32, ByVal Y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean
+ Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As Integer
+ Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cX As Integer, ByVal cY As Integer, ByVal wFlags As Integer) As Integer
+
+ Structure APPBARDATA
+ Dim cbSize As Integer
+ Dim hwnd As Integer
+ Dim uCallbackMessage As [Delegate]
+ Dim uEdge As Integer
+ Dim rc As RECT
+ Dim lParam As Integer ' message specific
+ End Structure
+
+ Structure RECT
+ Dim Left As Integer
+ Dim Top As Integer
+ Dim Right As Integer
+ Dim Bottom As Integer
+ End Structure
+
+ Const ABE_LEFT As Integer = 0
+ Const ABE_TOP As Integer = &H1
+ Const ABE_RIGHT As Integer = 2
+ Const ABE_BOTTOM As Integer = 3
+
+ Const ABM_NEW As Integer = 0
+ Const ABM_REMOVE As Integer = 1
+ Const ABM_QUERYPOS As Integer = 2
+ Const ABM_SETPOS As Integer = &H3
+ Const ABM_GETSTATE As Integer = 4
+ Const ABM_GETTASKBARPOS As Integer = 5
+ Const ABM_ACTIVATE As Integer = 6
+ Const ABM_GETAUTOHIDEBAR As Integer = 7
+ Const ABM_SETAUTOHIDEBAR As Integer = 8
+ Const ABM_WINDOWPOSCHANGED As Integer = 9
+
+ Const ABS_AUTOHIDE As Integer = 1
+ Const ABS_ALWAYSONTOP As Integer = 2
+
+ Const HWND_NOTTOPMOST As Integer = -2
+ Const HWND_TOPMOST As Integer = -1
+ Const HWND_TOP As Integer = 0
+ Const SHOWNORMAL As Integer = 5
+
+ Const SWP_NOSIZE As Integer = &H1
+ Const SWP_NOMOVE As Short = &H2
+ Const SWP_NOZORDER As Integer = 4
+ Const SWP_NOACTIVATE As Integer = &H10
+ Const SWP_DRAWFRAME As Integer = &H20
+ Const SWP_SHOWWINDOW As Integer = &H40
+#End Region
+
+ Private Sidebar As APPBARDATA
+ Private Handle As IntPtr
+
+ Public Sub New(pHandle As IntPtr)
+ Handle = pHandle
+ End Sub
+
+ Public Sub RegisterSidebar(pScreenName As String)
+ Sidebar.hwnd = Handle.ToInt32
+ Sidebar.cbSize = Len(Sidebar)
+
+ Dim oSelectedScreen = System.Windows.Forms.Screen.PrimaryScreen
+
+ ' TODO: Make Sidebar Screen configurable
+ 'If pScreenName <> "" Then
+ ' Dim oScreens = System.Windows.Forms.Screen.AllScreens
+ ' For Each oScreen In oScreens
+ ' If oScreen.DeviceName = pScreenName Then
+ ' oSelectedScreen = oScreen
+ ' End If
+ ' Next
+ 'End If
+
+ With Sidebar
+ .uEdge = ABE_RIGHT
+ .rc.Top = oSelectedScreen.WorkingArea.Top '0
+ .rc.Right = oSelectedScreen.WorkingArea.Right ' right
+ .rc.Left = oSelectedScreen.WorkingArea.Right - 200 ' width of our appbar
+ .rc.Bottom = oSelectedScreen.WorkingArea.Height ' bottom
+ SHAppBarMessage(ABM_NEW, Sidebar)
+ SetWindowPos(Sidebar.hwnd, HWND_TOP, .rc.Left, .rc.Top, .rc.Right - .rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE)
+ SHAppBarMessage(ABM_SETPOS, Sidebar)
+ End With
+ End Sub
+
+ Public Sub UnregisterSidebar()
+ SHAppBarMessage(ABM_REMOVE, Sidebar)
+ End Sub
+End Class
diff --git a/GUIs.ZooFlow/ZooFlow.vbproj b/GUIs.ZooFlow/ZooFlow.vbproj
index acc1f51b..5affd08c 100644
--- a/GUIs.ZooFlow/ZooFlow.vbproj
+++ b/GUIs.ZooFlow/ZooFlow.vbproj
@@ -98,6 +98,9 @@
..\Controls.SnapPanel\obj\Debug\DigitalData.Controls.SnapPanel.dll
+
+ ..\Modules.Base\Base\bin\Debug\DigitalData.Modules.Base.dll
+
P:\Visual Studio Projekte\Bibliotheken\MSG .NET\Bin\22_11_19\Independentsoft.Msg.dll
@@ -405,6 +408,7 @@
+
frmAdmin_ClipboardWatcher.vb
diff --git a/GUIs.ZooFlow/frmFlowForm.vb b/GUIs.ZooFlow/frmFlowForm.vb
index c730fa16..6da0d0a5 100644
--- a/GUIs.ZooFlow/frmFlowForm.vb
+++ b/GUIs.ZooFlow/frmFlowForm.vb
@@ -13,59 +13,7 @@ Imports DigitalData.Modules.Messaging
Imports DigitalData.Modules.Windows
Public Class frmFlowForm
-#Region "Sidebar Declarations"
- Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
- Public Declare Auto Function MoveWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal X As Int32, ByVal Y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean
- Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" (ByVal dwMessage As Integer, ByRef pData As APPBARDATA) As Integer
- Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cX As Integer, ByVal cY As Integer, ByVal wFlags As Integer) As Integer
- Structure APPBARDATA
- Dim cbSize As Integer
- Dim hwnd As Integer
- Dim uCallbackMessage As [Delegate]
- Dim uEdge As Integer
- Dim rc As RECT
- Dim lParam As Integer ' message specific
- End Structure
-
- Structure RECT
- Dim Left As Integer
- Dim Top As Integer
- Dim Right As Integer
- Dim Bottom As Integer
- End Structure
-
- Const ABE_LEFT As Integer = 0
- Const ABE_TOP As Integer = &H1
- Const ABE_RIGHT As Integer = 2
- Const ABE_BOTTOM As Integer = 3
-
- Const ABM_NEW As Integer = 0
- Const ABM_REMOVE As Integer = 1
- Const ABM_QUERYPOS As Integer = 2
- Const ABM_SETPOS As Integer = &H3
- Const ABM_GETSTATE As Integer = 4
- Const ABM_GETTASKBARPOS As Integer = 5
- Const ABM_ACTIVATE As Integer = 6
- Const ABM_GETAUTOHIDEBAR As Integer = 7
- Const ABM_SETAUTOHIDEBAR As Integer = 8
- Const ABM_WINDOWPOSCHANGED As Integer = 9
-
- Const ABS_AUTOHIDE As Integer = 1
- Const ABS_ALWAYSONTOP As Integer = 2
-
- Const HWND_NOTTOPMOST As Integer = -2
- Const HWND_TOPMOST As Integer = -1
- Const HWND_TOP As Integer = 0
- Const SHOWNORMAL As Integer = 5
-
- Const SWP_NOSIZE As Integer = &H1
- Const SWP_NOMOVE As Short = &H2
- Const SWP_NOZORDER As Integer = 4
- Const SWP_NOACTIVATE As Integer = &H10
- Const SWP_DRAWFRAME As Integer = &H20
- Const SWP_SHOWWINDOW As Integer = &H40
-#End Region
' Constants
Private Const OPACITY_INITIAL = 0
@@ -101,7 +49,7 @@ Public Class frmFlowForm
Private ESCHitCount As Integer = 0
Private IndexForm As frmGlobix_Index
Private AdminForm As frmAdmin_Start
- Private Sidebar As APPBARDATA
+
' Events
Public Event ClipboardChanged As EventHandler(Of IDataObject)
@@ -128,8 +76,8 @@ Public Class frmFlowForm
Init.InitializeApplication()
' Register Form as Sidebar
- Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
- RegisterSidebar(My.UIConfig.SidebarScreen)
+ My.Application.Sidebar = New Sidebar(Handle)
+ My.Application.Sidebar.RegisterSidebar(My.UIConfig.SidebarScreen)
End Sub
Private Sub Init_Completed(sender As Object, e As EventArgs)
@@ -938,42 +886,6 @@ Public Class frmFlowForm
frmSearchNeu.Show()
End Sub
- Private Sub frmFlowForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
- UnregisterSidebar()
- End Sub
-
- Private Sub RegisterSidebar(pScreenName As String)
- Sidebar.hwnd = Me.Handle.ToInt32
- Sidebar.cbSize = Len(Sidebar)
-
- Dim oSelectedScreen = System.Windows.Forms.Screen.PrimaryScreen
-
- ' TODO: Make Sidebar Screen configurable
- 'If pScreenName <> "" Then
- ' Dim oScreens = System.Windows.Forms.Screen.AllScreens
- ' For Each oScreen In oScreens
- ' If oScreen.DeviceName = pScreenName Then
- ' oSelectedScreen = oScreen
- ' End If
- ' Next
- 'End If
-
- With Sidebar
- .uEdge = ABE_RIGHT
- .rc.Top = oSelectedScreen.WorkingArea.Top '0
- .rc.Right = oSelectedScreen.WorkingArea.Right ' right
- .rc.Left = oSelectedScreen.WorkingArea.Right - 200 ' width of our appbar
- .rc.Bottom = oSelectedScreen.WorkingArea.Height ' bottom
- SHAppBarMessage(ABM_NEW, Sidebar)
- SetWindowPos(Sidebar.hwnd, HWND_TOP, .rc.Left, .rc.Top, .rc.Right - .rc.Left, .rc.Bottom, SWP_SHOWWINDOW Or SWP_NOACTIVATE)
- SHAppBarMessage(ABM_SETPOS, Sidebar)
- End With
- End Sub
-
- Private Sub UnregisterSidebar()
- SHAppBarMessage(ABM_REMOVE, Sidebar)
- End Sub
-
Private Sub BasisKonfigurationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BasisKonfigurationToolStripMenuItem.Click
frmConfigBasic.ShowDialog()
End Sub
diff --git a/GUIs.ZooFlow/frmtest.vb b/GUIs.ZooFlow/frmtest.vb
index 3c5e6a84..393feef3 100644
--- a/GUIs.ZooFlow/frmtest.vb
+++ b/GUIs.ZooFlow/frmtest.vb
@@ -1,10 +1,5 @@
-
-Imports DigitalData.Modules.Logging
-Imports DigitalData.Modules.EDMI.API
-Imports System.IO
-Imports System.Text
-Imports DigitalData.Modules.EDMI.API.Client
-Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
+Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
+Imports DigitalData.Modules.Base.IDB.FileStore
Public Class frmtest
@@ -27,7 +22,7 @@ Public Class frmtest
"DEFAULT"
)
- If oObjectId <> INVALID_OBEJCT_ID Then
+ If oObjectId <> FILE_STORE_INVALID_OBEJCT_ID Then
MsgBox("File Imported!", MsgBoxStyle.Information, Text)
Else
MsgBox("File was not imported. Check the server logs!")
@@ -35,7 +30,6 @@ Public Class frmtest
txtIDB_OBJ_ID.Text = oObjectId
End Sub
-
Private Async Sub btnImportFile_Click_(sender As Object, e As EventArgs) Handles btnImportFile.Click
Dim oResponse As ImportFileResponse = Await My.Application.Service.Client.Globix_ImportFileAsync(
txtFile2Import.Text,
diff --git a/Modules.Base/Base/Base.vbproj b/Modules.Base/Base/Base.vbproj
index 52e79389..96bcd49c 100644
--- a/Modules.Base/Base/Base.vbproj
+++ b/Modules.Base/Base/Base.vbproj
@@ -66,8 +66,8 @@
-
+
True
diff --git a/Modules.Base/Base/BaseClass.vb b/Modules.Base/Base/BaseClass.vb
index e71ef5c2..e12a99c1 100644
--- a/Modules.Base/Base/BaseClass.vb
+++ b/Modules.Base/Base/BaseClass.vb
@@ -1,5 +1,8 @@
Imports DigitalData.Modules.Logging
+'''
+''' BaseClass that sets up a Logger.
+'''
Public Class BaseClass
Protected LogConfig As LogConfig
Protected Logger As Logger
diff --git a/Modules.Base/Base/Database/Enums.vb b/Modules.Base/Base/Database/Enums.vb
deleted file mode 100644
index 3e0cbe6b..00000000
--- a/Modules.Base/Base/Database/Enums.vb
+++ /dev/null
@@ -1,8 +0,0 @@
-Namespace Database
- Module Enums
- Public Enum NamedDatabase
- ECM
- IDB
- End Enum
- End Module
-End Namespace
diff --git a/Modules.Base/Base/IDB/Database.vb b/Modules.Base/Base/IDB/Database.vb
index f86b7186..7d585336 100644
--- a/Modules.Base/Base/IDB/Database.vb
+++ b/Modules.Base/Base/IDB/Database.vb
@@ -1,15 +1,18 @@
Namespace IDB
- '''
- ''' This module is intended for often used constants and datastructures
- ''' Therefor it is important that this module does not have any dependencies on other modules!!
- '''
- Module Constants
+ Public Class Database
Public Const OBJECT_STATE_FILE_ADDED = "File added"
Public Const OBJECT_STATE_FILE_VERSIONED = "File versioned"
Public Const OBJECT_STATE_FILE_CHANGED = "File changed"
Public Const OBJECT_STATE_FILE_DELETED = "File deleted"
Public Const OBJECT_STATE_METADATA_CHANGED = "Metadata changed"
Public Const OBJECT_STATE_ATTRIBUTEVALUE_DELETED = "Attributevalue deleted"
- End Module
+
+ Public Enum NamedDatabase
+ ECM
+ IDB
+ End Enum
+ End Class
+
End Namespace
+
diff --git a/Modules.Base/Base/IDB/FileStore.vb b/Modules.Base/Base/IDB/FileStore.vb
new file mode 100644
index 00000000..15b2c05b
--- /dev/null
+++ b/Modules.Base/Base/IDB/FileStore.vb
@@ -0,0 +1,6 @@
+Namespace IDB
+ Public Class FileStore
+ Public Const FILE_STORE_INVALID_OBEJCT_ID = 0
+ End Class
+
+End Namespace
\ No newline at end of file
diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb
index 8f9e8ffd..c5ec8046 100644
--- a/Modules.EDMIAPI/Client.vb
+++ b/Modules.EDMIAPI/Client.vb
@@ -196,6 +196,16 @@ Public Class Client
End Try
End Function
+ Public Async Function UpdateFileAsync(pObjectId As Long, pFilePath As String, Optional pImportOptions As Options.UpdateFileOptions = Nothing) As Task(Of Long)
+ Try
+ Dim oUpdateFile As New Modules.IDB.UpdateFile(LogConfig, Channel)
+ Return Await oUpdateFile.RunAsync(pFilePath, pObjectId, pImportOptions)
+ Catch ex As Exception
+ Logger.Error(ex)
+ Return Nothing
+ End Try
+ End Function
+
Public Async Function Globix_ImportFileAsync(
pFilePath As String,
pProfileId As Integer,
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.EDMI.API.EDMIServiceReference.UpdateFileResponse.datasource b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.EDMI.API.EDMIServiceReference.UpdateFileResponse.datasource
new file mode 100644
index 00000000..e22df5f3
--- /dev/null
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Modules.EDMI.API.EDMIServiceReference.UpdateFileResponse.datasource
@@ -0,0 +1,10 @@
+
+
+
+ DigitalData.Modules.EDMI.API.EDMIServiceReference.UpdateFileResponse, Connected Services.EDMIServiceReference.Reference.vb.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+
\ No newline at end of file
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.IDB.GetFileObject.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.IDB.GetFileObject.xsd
index 8d71cf3d..cfdf11f8 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.IDB.GetFileObject.xsd
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.IDB.GetFileObject.xsd
@@ -24,6 +24,7 @@
+
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.IDB.UpdateFile.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.IDB.UpdateFile.xsd
new file mode 100644
index 00000000..df44e7f6
--- /dev/null
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.Methods.IDB.UpdateFile.xsd
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl
index a5ca1cd7..6704c25c 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.wsdl
@@ -19,6 +19,7 @@
+
@@ -161,6 +162,12 @@
+
+
+
+
+
+
@@ -299,6 +306,10 @@
+
+
+
+
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd
index 1439c329..3235b93d 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/DigitalData.Services.EDMIService.xsd
@@ -7,6 +7,7 @@
+
@@ -246,45 +247,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -298,7 +313,7 @@
-
+
@@ -314,7 +329,7 @@
-
+
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap
index 515a521a..c01950b4 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.svcmap
@@ -41,6 +41,7 @@
+
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
index b1702f42..7896d60c 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
@@ -28,6 +28,7 @@ Namespace EDMIServiceReference
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.GetScalarValueResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ExecuteNonQueryResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.NewFileResponse)), _
+ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UpdateFileResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ImportFileResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.GetFileObjectResponse)), _
@@ -165,6 +166,8 @@ Namespace EDMIServiceReference
System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileInfo)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileSystemInfo)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UserState)), _
+ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UpdateFileRequest)), _
+ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UpdateFileResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueRequest)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ImportFileRequest)), _
@@ -260,6 +263,8 @@ Namespace EDMIServiceReference
System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileInfo)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(System.IO.FileSystemInfo)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UserState)), _
+ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UpdateFileRequest)), _
+ System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.UpdateFileResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueRequest)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.SetAttributeValueResponse)), _
System.Runtime.Serialization.KnownTypeAttribute(GetType(EDMIServiceReference.ImportFileRequest)), _
@@ -338,6 +343,31 @@ Namespace EDMIServiceReference
End Property
End Class
+ _
+ Partial Public Class UpdateFileResponse
+ Inherits EDMIServiceReference.BaseResponse
+
+ _
+ Private ObjectIdField As Long
+
+ _
+ Public Property ObjectId() As Long
+ Get
+ Return Me.ObjectIdField
+ End Get
+ Set
+ If (Me.ObjectIdField.Equals(value) <> true) Then
+ Me.ObjectIdField = value
+ Me.RaisePropertyChanged("ObjectId")
+ End If
+ End Set
+ End Property
+ End Class
+
_
+ Partial Public Class UpdateFileRequest
+ Inherits Object
+ Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
+
+ _
+ Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
+
+ _
+ Private CreateNewVersionField As Boolean
+
+ _
+ Private FileField As EDMIServiceReference.FileProperties
+
+ _
+ Private ObjectIdField As Long
+
+ _
+ Private UserField As EDMIServiceReference.UserState
+
+ _
+ Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
+ Get
+ Return Me.extensionDataField
+ End Get
+ Set
+ Me.extensionDataField = value
+ End Set
+ End Property
+
+ _
+ Public Property CreateNewVersion() As Boolean
+ Get
+ Return Me.CreateNewVersionField
+ End Get
+ Set
+ If (Me.CreateNewVersionField.Equals(value) <> true) Then
+ Me.CreateNewVersionField = value
+ Me.RaisePropertyChanged("CreateNewVersion")
+ End If
+ End Set
+ End Property
+
+ _
+ Public Property File() As EDMIServiceReference.FileProperties
+ Get
+ Return Me.FileField
+ End Get
+ Set
+ If (Object.ReferenceEquals(Me.FileField, value) <> true) Then
+ Me.FileField = value
+ Me.RaisePropertyChanged("File")
+ End If
+ End Set
+ End Property
+
+ _
+ Public Property ObjectId() As Long
+ Get
+ Return Me.ObjectIdField
+ End Get
+ Set
+ If (Me.ObjectIdField.Equals(value) <> true) Then
+ Me.ObjectIdField = value
+ Me.RaisePropertyChanged("ObjectId")
+ End If
+ End Set
+ End Property
+
+ _
+ Public Property User() As EDMIServiceReference.UserState
+ Get
+ Return Me.UserField
+ End Get
+ Set
+ If (Object.ReferenceEquals(Me.UserField, value) <> true) Then
+ Me.UserField = value
+ Me.RaisePropertyChanged("User")
+ End If
+ End Set
+ End Property
+
+ Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
+
+ Protected Sub RaisePropertyChanged(ByVal propertyName As String)
+ Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent
+ If (Not (propertyChanged) Is Nothing) Then
+ propertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
+ End If
+ End Sub
+ End Class
+
_
+ Public Property _FilePath() As String
+ Get
+ Return Me._FilePathField
+ End Get
+ Set
+ If (Object.ReferenceEquals(Me._FilePathField, value) <> true) Then
+ Me._FilePathField = value
+ Me.RaisePropertyChanged("_FilePath")
+ End If
+ End Set
+ End Property
+
_
Public Property _FileSize() As Long
Get
@@ -2103,6 +2244,12 @@ Namespace EDMIServiceReference
_
Function NewFileAsync(ByVal Data As EDMIServiceReference.NewFileRequest) As System.Threading.Tasks.Task(Of EDMIServiceReference.NewFileResponse)
+ _
+ Function UpdateFile(ByVal Data As EDMIServiceReference.UpdateFileRequest) As EDMIServiceReference.UpdateFileResponse
+
+ _
+ Function UpdateFileAsync(ByVal Data As EDMIServiceReference.UpdateFileRequest) As System.Threading.Tasks.Task(Of EDMIServiceReference.UpdateFileResponse)
+
_
Function SetAttributeValue(ByVal Data As EDMIServiceReference.SetAttributeValueRequest) As EDMIServiceReference.SetAttributeValueResponse
@@ -2494,6 +2641,14 @@ Namespace EDMIServiceReference
Return MyBase.Channel.NewFileAsync(Data)
End Function
+ Public Function UpdateFile(ByVal Data As EDMIServiceReference.UpdateFileRequest) As EDMIServiceReference.UpdateFileResponse Implements EDMIServiceReference.IEDMIService.UpdateFile
+ Return MyBase.Channel.UpdateFile(Data)
+ End Function
+
+ Public Function UpdateFileAsync(ByVal Data As EDMIServiceReference.UpdateFileRequest) As System.Threading.Tasks.Task(Of EDMIServiceReference.UpdateFileResponse) Implements EDMIServiceReference.IEDMIService.UpdateFileAsync
+ Return MyBase.Channel.UpdateFileAsync(Data)
+ End Function
+
Public Function SetAttributeValue(ByVal Data As EDMIServiceReference.SetAttributeValueRequest) As EDMIServiceReference.SetAttributeValueResponse Implements EDMIServiceReference.IEDMIService.SetAttributeValue
Return MyBase.Channel.SetAttributeValue(Data)
End Function
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl
index 8ea21e10..370573f4 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/service.wsdl
@@ -227,6 +227,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/Modules.EDMIAPI/EDMI.API.vbproj b/Modules.EDMIAPI/EDMI.API.vbproj
index 04daf047..a13ed06c 100644
--- a/Modules.EDMIAPI/EDMI.API.vbproj
+++ b/Modules.EDMIAPI/EDMI.API.vbproj
@@ -167,6 +167,9 @@
Reference.svcmap
+
+ Reference.svcmap
+
Designer
@@ -206,6 +209,9 @@
Designer
+
+ Designer
+
Designer
diff --git a/Modules.EDMIAPI/Modules/IDB/UpdateFile.vb b/Modules.EDMIAPI/Modules/IDB/UpdateFile.vb
index 8ec2f014..182578c1 100644
--- a/Modules.EDMIAPI/Modules/IDB/UpdateFile.vb
+++ b/Modules.EDMIAPI/Modules/IDB/UpdateFile.vb
@@ -10,29 +10,43 @@ Namespace Modules.IDB
MyBase.New(pLogConfig, pChannel)
End Sub
- Public Async Function RunAsync(pFilePath As String, pObjectId As Long, Optional pOptions As UpdateFileOptions = Nothing) As Task
- ' Set default options
- If pOptions Is Nothing Then
- pOptions = New UpdateFileOptions()
- End If
+ Public Async Function RunAsync(pFilePath As String, pObjectId As Long, Optional pOptions As UpdateFileOptions = Nothing) As Task(Of Long)
+ Try
+ ' Set default options
+ If pOptions Is Nothing Then
+ pOptions = New UpdateFileOptions()
+ End If
- ' Check if file exists
- If IO.File.Exists(pFilePath) = False Then
- Throw New IO.FileNotFoundException("Path does not exist")
- End If
+ ' Check if file exists
+ If IO.File.Exists(pFilePath) = False Then
+ Throw New IO.FileNotFoundException("Path does not exist")
+ End If
- ' Importing the file now
- Dim oFileProperties = Helpers.GetFileProperties(pFilePath, Date.Now)
- 'Dim oFileImportResponse = Await Channel.(New NewFileRequest With {
- ' .BusinessEntity = pBusinessEntity,
- ' .File = oFileProperties,
- ' .KindType = pObjectKind,
- ' .StoreName = pObjectStoreName,
- ' .User = New UserState With {
- ' .Language = pOptions.Language,
- ' .UserName = pOptions.Username
- ' }
- '})
+ ' Importing the file now
+ Dim oFileProperties = Helpers.GetFileProperties(pFilePath, Date.Now)
+
+
+ Dim oUpdateFileResponse = Await Channel.UpdateFileAsync(New UpdateFileRequest With {
+ .File = oFileProperties,
+ .ObjectId = pObjectId,
+ .CreateNewVersion = pOptions.CreateNewFileVersion,
+ .User = New UserState With {
+ .Language = pOptions.Language,
+ .UserName = pOptions.Username
+ }
+ })
+
+ If oUpdateFileResponse.OK = False Then
+ Throw New ApplicationException("Could not Import File Contents!")
+ End If
+
+ Return oUpdateFileResponse.ObjectId
+
+ Catch ex As Exception
+ Logger.Error(ex)
+ Return Constants.INVALID_OBEJCT_ID
+
+ End Try
End Function
End Class
diff --git a/Modules.Filesystem/File.vb b/Modules.Filesystem/File.vb
index 1c109f8f..9a1eb6b9 100644
--- a/Modules.Filesystem/File.vb
+++ b/Modules.Filesystem/File.vb
@@ -352,11 +352,13 @@ Public Class File
'''
Public Function TestFileIsLocked(pFilePath As String) As Boolean
Try
- Using stream As FileStream = IO.File.Open(FileMode.Open, FileAccess.Read, FileShare.None)
+ Using stream As FileStream = IO.File.Open(pFilePath, FileMode.Open, FileAccess.Read, FileShare.None)
stream.Close()
End Using
Catch ex As Exception When ((ex.HResult And &HFFFF) = 32)
Return True
+ Catch ex As Exception
+ Return True
End Try
Return False
@@ -409,4 +411,13 @@ Public Class File
Return $"{pBaseString}-{pSuffix}.{pExtension}"
End Function
+ Public Function GetFilenameWithPrefix(pFilePath As String, pPrefix As String)
+ Dim oFileInfo = New IO.FileInfo(pFilePath)
+ Return GetFilenameWithSuffix(IO.Path.GetFileNameWithoutExtension(pFilePath), pPrefix, oFileInfo.Extension.Substring(1))
+ End Function
+
+ Public Function GetFilenameWithPrefix(pBaseString As String, pPrefix As String, pExtension As String)
+ Return $"{pPrefix}-{pBaseString}.{pExtension}"
+ End Function
+
End Class
diff --git a/Service.EDMIService/IDB/Helpers.vb b/Service.EDMIService/IDB/Helpers.vb
index 9b150509..9fdff60a 100644
--- a/Service.EDMIService/IDB/Helpers.vb
+++ b/Service.EDMIService/IDB/Helpers.vb
@@ -72,35 +72,35 @@ Namespace IDB
End Try
End Function
- Public Function GetAttributesForObject(pObjectId As Long, pLanguage As String) As List(Of ObjectAttribute)
- Dim oAttributes As New List(Of ObjectAttribute)
+ 'Public Function GetAttributesForObject(pObjectId As Long, pLanguage As String) As List(Of ObjectAttribute)
+ ' Dim oAttributes As New List(Of ObjectAttribute)
- Try
- Dim oTable As DataTable = Database.GetDatatable($"EXEC [PRIDB_GET_VALUE_DT] {pObjectId}, '{pLanguage}'")
- If oTable Is Nothing OrElse oTable.Rows.Count = 0 Then
- Return Nothing
- End If
+ ' Try
+ ' Dim oTable As DataTable = Database.GetDatatable($"EXEC [PRIDB_GET_VALUE_DT] {pObjectId}, '{pLanguage}'")
+ ' If oTable Is Nothing OrElse oTable.Rows.Count = 0 Then
+ ' Return Nothing
+ ' End If
- For Each oRow As DataRow In oTable.Rows
- Dim oAttribute As New ObjectAttribute With {
- .Id = oRow.Item("AttributeId"),
- .Title = oRow.Item("AttributeTitle"),
- .Type = oRow.Item("AttributeType"),
- .ValueBigInt = Utils.NotNull(oRow.Item("ValueBigInt"), Nothing),
- .ValueDate = Utils.NotNull(oRow.Item("ValueDate"), Nothing),
- .ValueDecimal = Utils.NotNull(oRow.Item("ValueDecimal"), Nothing),
- .ValueText = Utils.NotNull(oRow.Item("ValueText"), Nothing)
- }
+ ' For Each oRow As DataRow In oTable.Rows
+ ' Dim oAttribute As New ObjectAttribute With {
+ ' .Id = oRow.Item("AttributeId"),
+ ' .Title = oRow.Item("AttributeTitle"),
+ ' .Type = oRow.Item("AttributeType"),
+ ' .ValueBigInt = Utils.NotNull(oRow.Item("ValueBigInt"), Nothing),
+ ' .ValueDate = Utils.NotNull(oRow.Item("ValueDate"), Nothing),
+ ' .ValueDecimal = Utils.NotNull(oRow.Item("ValueDecimal"), Nothing),
+ ' .ValueText = Utils.NotNull(oRow.Item("ValueText"), Nothing)
+ ' }
- oAttributes.Add(oAttribute)
- Next
+ ' oAttributes.Add(oAttribute)
+ ' Next
- Return oAttributes
- Catch ex As Exception
- Logger.Error(ex)
- Return Nothing
- End Try
- End Function
+ ' Return oAttributes
+ ' Catch ex As Exception
+ ' Logger.Error(ex)
+ ' Return Nothing
+ ' End Try
+ 'End Function
Public Function SetAttributeValue(pConnection As SqlConnection, pTransaction As SqlTransaction, pObjectId As Long, pAttributeName As String, pValue As String, pLanguage As String, pWho As String) As Boolean
Dim oSql = $"
diff --git a/Service.EDMIService/Methods/IDB/GetFileObject/FileObject.vb b/Service.EDMIService/Methods/IDB/GetFileObject/FileObject.vb
index 3a315e91..0448d2cb 100644
--- a/Service.EDMIService/Methods/IDB/GetFileObject/FileObject.vb
+++ b/Service.EDMIService/Methods/IDB/GetFileObject/FileObject.vb
@@ -15,6 +15,9 @@ Namespace Methods.IDB.GetFileObject
Public Property FileSize As Long
Public Property FileContents As Byte()
+
+ ' Internal Properties, these will not be given to the client
+ Public Property FilePath As String
End Class
End Namespace
\ No newline at end of file
diff --git a/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb b/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb
index 674131fb..9b735d52 100644
--- a/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb
+++ b/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb
@@ -28,19 +28,19 @@ Namespace Methods.IDB.GetFileObject
Dim oFileHash As String = oRow.ItemEx("FILE_HASH", "")
Dim oFileSize As Long = oRow.ItemEx(Of Long)("FILE_SIZE", 0)
Dim oFileExtension As String = oRow.ItemEx(Of String)("EXTENSION")
+ Dim oFilePath = oRow.ItemEx("RELPATH", "")
+ Dim oFileName = oRow.ItemEx("Filename", "")
+ Dim oFullFileName = Path.Combine(oFilePath, oFileName)
Dim oFileObject As New FileObject With {
.ObjectId = pData.ObjectId,
.FileHash = oFileHash,
.FileSize = oFileSize,
- .FileExtension = oFileExtension
+ .FileExtension = oFileExtension,
+ .FilePath = oFullFileName
}
If pData.LoadFileContents = True Then
- Dim oFilePath = oRow.ItemEx("RELPATH", "")
- Dim oFileName = oRow.ItemEx("Filename", "")
- Dim oFullFileName = Path.Combine(oFilePath, oFileName)
-
If File.Exists(oFullFileName) = False Then
Throw New FileNotFoundException("FileObject not Found!", oFullFileName)
End If
diff --git a/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb b/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb
index 9f07e7cc..88240d8e 100644
--- a/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb
+++ b/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb
@@ -125,10 +125,10 @@ Namespace Methods.IDB.NewFile
'TODO: File dates in try catch
Dim oSystemAttributes As New Dictionary(Of String, Object) From {
- {"OriginFileName", pData.File.FileName},
- {"OriginCreationDatetime", pData.File.FileCreatedAt},
- {"OriginChangedDatetime", pData.File.FileChangedAt}
- }
+ {"OriginFileName", pData.File.FileName},
+ {"OriginCreationDatetime", pData.File.FileCreatedAt},
+ {"OriginChangedDatetime", pData.File.FileChangedAt}
+ }
For Each oAttribute As KeyValuePair(Of String, Object) In oSystemAttributes
Try
diff --git a/Service.EDMIService/Methods/IDB/UpdateFile/UpdateFileMethod.vb b/Service.EDMIService/Methods/IDB/UpdateFile/UpdateFileMethod.vb
index d06584fc..d5e27f24 100644
--- a/Service.EDMIService/Methods/IDB/UpdateFile/UpdateFileMethod.vb
+++ b/Service.EDMIService/Methods/IDB/UpdateFile/UpdateFileMethod.vb
@@ -21,25 +21,56 @@ Namespace Methods.IDB.UpdateFile
Public Function Run(pData As UpdateFileRequest) As UpdateFileResponse
- ' TODO: Update file object
- If Helpers.TestObjectIdExists(pData.ObjectId) = False Then
- LogAndThrow("ObjectId does not exist!")
- End If
+ Try
+ ' TODO: Update file object
+ If Helpers.TestObjectIdExists(pData.ObjectId) = False Then
+ LogAndThrow("ObjectId does not exist!")
+ End If
- 'TODO: Create a view that collects all information about an idb object
+ 'TODO: Create a view that collects all information about an idb object
- If pData.CreateNewVersion = False Then
+ If pData.CreateNewVersion = False Then
+ Dim oGetFileObject As New GetFileObject.GetFileObjectMethod(LogConfig, DatabaseIDB, DatabaseECM, GlobalState)
+ Dim oArgs = New GetFileObject.GetFileObjectRequest With {
+ .ObjectId = pData.ObjectId,
+ .LoadFileContents = False
+ }
+ Dim oFileObjectResponse As GetFileObject.GetFileObjectResponse = oGetFileObject.Run(oArgs)
+
+ If oFileObjectResponse.OK = False Then
+ LogAndThrow(oFileObjectResponse.ErrorMessage)
+ End If
+
+ Dim oFileObjectSize As Long = pData.File.FileContents.Length
+ Dim oFileObject As GetFileObject.FileObject = oFileObjectResponse.FileObject
+ Dim oFilePath As String = oFileObject.FilePath
+
+ Try
+ Using oStream = New IO.FileStream(oFilePath, IO.FileMode.Create, IO.FileAccess.Write)
+ Logger.Info("Saving file to path [{0}]", oFilePath)
+ oStream.Write(pData.File.FileContents, 0, oFileObjectSize)
+ oStream.Flush(True)
+ oStream.Close()
+ End Using
+ Catch ex As Exception
+ LogAndThrow(ex, $"Could not write file [{oFilePath}] to disk!")
+ End Try
+
+ Return New UpdateFileResponse(pData.ObjectId)
+
+ Else
+ Throw New ApplicationException("Not implemented!!")
- Else
+ End If
- End If
+ Catch ex As Exception
+ Return New UpdateFileResponse(ex)
+
+ End Try
-
- Return New UpdateFileResponse(pData.ObjectId)
-
'Dim oFilePath As String = Nothing
'
'Dim oExistingObjectId = TestFileChecksumExists(pData.File.FileChecksum)