Common: First working version of watcher with confirmation
This commit is contained in:
@@ -237,20 +237,42 @@ Public Class frmDocumentResultList
|
||||
|
||||
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
|
||||
})
|
||||
Dim oFileInfo = New FileInfo(e.File.FilePath)
|
||||
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."
|
||||
Dim oResult As DialogResult = MsgBox(oMessage, MsgBoxStyle.YesNoCancel Or MsgBoxStyle.Question, "Datei verändert")
|
||||
|
||||
' 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
|
||||
Logger.Error(ex)
|
||||
Show_CriticalError(ex)
|
||||
|
||||
Finally
|
||||
' Signal to the watcher that the file is no longer in use
|
||||
Watcher.FileSaved(e.File)
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Reference in New Issue
Block a user