Common: First working version of watcher with confirmation
This commit is contained in:
parent
dbe755bc94
commit
66599efcbf
@ -15,6 +15,7 @@ Namespace DocumentResultList
|
|||||||
' TODO: Hashes for checking if the opened file was modified externally
|
' TODO: Hashes for checking if the opened file was modified externally
|
||||||
Private HashOriginalFile As String = Nothing
|
Private HashOriginalFile As String = Nothing
|
||||||
Private HashOpenedFile As String = Nothing
|
Private HashOpenedFile As String = Nothing
|
||||||
|
Private Const FILE_OPEN_HANDLE_INTERVAL = 2000
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' List of opened files containing the filepath that was opened and the document id
|
''' List of opened files containing the filepath that was opened and the document id
|
||||||
@ -74,7 +75,7 @@ Namespace DocumentResultList
|
|||||||
|
|
||||||
|
|
||||||
If FileOpenTimer.Enabled = False Then
|
If FileOpenTimer.Enabled = False Then
|
||||||
FileOpenTimer.Interval = 10000
|
FileOpenTimer.Interval = FILE_OPEN_HANDLE_INTERVAL
|
||||||
FileOpenTimer.Start()
|
FileOpenTimer.Start()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|||||||
@ -237,20 +237,42 @@ Public Class frmDocumentResultList
|
|||||||
|
|
||||||
Public Async 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
|
Try
|
||||||
Await _IDBClient.UpdateFileAsync(e.File.Document.Id, e.File.FilePath, New Options.UpdateFileOptions With {
|
Dim oFileInfo = New FileInfo(e.File.FilePath)
|
||||||
.CreateNewFileVersion = False,
|
Dim oMessage = $"Die Datei '{oFileInfo.Name}' wurde außerhalb des Systems verändert. Wollen Sie diese Änderung als neue Version in das System übernehmen? 'Nein' überschreibt die ursprüngliche Datei."
|
||||||
.Language = Environment.User.Language,
|
Dim oResult As DialogResult = MsgBox(oMessage, MsgBoxStyle.YesNoCancel Or MsgBoxStyle.Question, "Datei verändert")
|
||||||
.Username = Environment.User.UserName
|
|
||||||
})
|
|
||||||
|
|
||||||
|
' Three possibilities:
|
||||||
|
'
|
||||||
|
' - Yes: Version file
|
||||||
|
' - No: Overwrite file
|
||||||
|
' - Cancel: Abort update
|
||||||
|
Select Case oResult
|
||||||
|
Case DialogResult.Cancel
|
||||||
|
MsgBox("Abbruch!")
|
||||||
|
|
||||||
|
Case Else
|
||||||
|
Dim oCreateNewFileVersion = IIf(oResult = DialogResult.Yes, True, False)
|
||||||
|
Dim oObjectId = Await _IDBClient.UpdateFileAsync(e.File.Document.Id, e.File.FilePath, New Options.UpdateFileOptions With {
|
||||||
|
.CreateNewFileVersion = oCreateNewFileVersion,
|
||||||
|
.Language = Environment.User.Language,
|
||||||
|
.Username = Environment.User.UserName
|
||||||
|
})
|
||||||
|
|
||||||
|
If IsNothing(oObjectId) Then
|
||||||
|
MsgBox($"Beim Speichern der Datei '{oFileInfo.Name}' Fehler ist ein Fehler aufgetreten!", MsgBoxStyle.Critical, Text)
|
||||||
|
Else
|
||||||
|
MsgBox($"Die Datei '{oFileInfo.Name}' wurde erfolgreich gespeichert!", MsgBoxStyle.Information, Text)
|
||||||
|
End If
|
||||||
|
End Select
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Logger.Error(ex)
|
Logger.Error(ex)
|
||||||
Show_CriticalError(ex)
|
Show_CriticalError(ex)
|
||||||
|
|
||||||
Finally
|
Finally
|
||||||
' Signal to the watcher that the file is no longer in use
|
' Signal to the watcher that the file is no longer in use
|
||||||
Watcher.FileSaved(e.File)
|
Watcher.FileSaved(e.File)
|
||||||
|
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user