Fix overlap when sync is still running, fix directory guid not changing

This commit is contained in:
Jonathan Jenne 2023-09-22 11:50:49 +02:00
parent 16dba7bdcd
commit 134a4642b2
4 changed files with 36 additions and 6 deletions

View File

@ -29,7 +29,7 @@ Public MustInherit Class BaseModule
Public Event OnFileProcessed As EventHandler(Of String) Implements ISync.OnFileProcessed Public Event OnFileProcessed As EventHandler(Of String) Implements ISync.OnFileProcessed
Public Event OnFileError As EventHandler(Of String) Implements ISync.OnFileError Public Event OnFileError As EventHandler(Of String) Implements ISync.OnFileError
Private ReadOnly DirectoryGuid As String = Guid.NewGuid.ToString() Private DirectoryGuid As String = Guid.NewGuid.ToString()
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pConfig As Config) Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pConfig As Config)
MyBase.New(pLogConfig) MyBase.New(pLogConfig)
@ -38,6 +38,10 @@ Public MustInherit Class BaseModule
Config = pConfig Config = pConfig
End Sub End Sub
Friend Sub RefreshDirectoryGuid()
DirectoryGuid = Guid.NewGuid.ToString()
End Sub
Friend Async Function FetchDocIds() As Task(Of List(Of String)) Friend Async Function FetchDocIds() As Task(Of List(Of String))
If Config.SQLQueryFetch = "" Then If Config.SQLQueryFetch = "" Then
Logger.Warn("Fetch Query is not configured. Exiting.") Logger.Warn("Fetch Query is not configured. Exiting.")

View File

@ -20,6 +20,7 @@ Namespace Sharepoint
AddDivider() AddDivider()
EnsureOutputDirectoryExists() EnsureOutputDirectoryExists()
RefreshDirectoryGuid()
Dim oExtDocIds = Await FetchDocIds() Dim oExtDocIds = Await FetchDocIds()
If oExtDocIds Is Nothing Then If oExtDocIds Is Nothing Then

View File

@ -32,6 +32,7 @@ Namespace slt
AddDivider() AddDivider()
EnsureOutputDirectoryExists() EnsureOutputDirectoryExists()
RefreshDirectoryGuid()
Dim oExtDocIds = Await FetchDocIds() Dim oExtDocIds = Await FetchDocIds()
If oExtDocIds Is Nothing Then If oExtDocIds Is Nothing Then

View File

@ -1,5 +1,6 @@
Imports System.ComponentModel Imports System.ComponentModel
Imports System.Runtime.Remoting.Messaging Imports System.Runtime.Remoting.Messaging
Imports System.Threading.Tasks
Imports Connectors.Common Imports Connectors.Common
Imports DevExpress.XtraEditors.ViewInfo Imports DevExpress.XtraEditors.ViewInfo
Imports DigitalData.Modules.Config Imports DigitalData.Modules.Config
@ -15,6 +16,7 @@ Partial Public Class frmMain
Private FilesProcessed As Integer = 0 Private FilesProcessed As Integer = 0
Private ErrorsOccurred As Integer = 0 Private ErrorsOccurred As Integer = 0
Private SyncRunning As Boolean = False
Public Enum LogLevel Public Enum LogLevel
Info Info
@ -48,7 +50,7 @@ Partial Public Class frmMain
AddDivider() AddDivider()
If ConfigManager.Config.ActiveModule = "NONE" Then If ConfigManager.Config.ActiveModule = "NONE" Then
AddWarnEntry("No ActiveModule selected, check your configuration!", ConfigManager.Config.ActiveModule) AddWarnEntry("No ActiveModule selected, check your configuration!")
Exit Sub Exit Sub
End If End If
@ -69,11 +71,16 @@ Partial Public Class frmMain
Exit Sub Exit Sub
End If End If
If Sync.TestConfigIsComplete() Then
AddWarnEntry("Configuration is incomplete, check your configuration!")
Exit Sub
End If
btnForceSync.Enabled = True btnForceSync.Enabled = True
If ConfigManager.Config.Autostart And Sync.TestConfigIsComplete() Then If ConfigManager.Config.Autostart Then
btnForceSync.Enabled = False btnForceSync.Enabled = False
Await Sync.Run() Await RunSync()
btnForceSync.Enabled = True btnForceSync.Enabled = True
End If End If
@ -165,9 +172,26 @@ Partial Public Class frmMain
SyncTimer.Enabled = False SyncTimer.Enabled = False
End Sub End Sub
Private Async Function RunSync() As Task
If SyncRunning = True Then
Logger.Debug("Sync still running. Skipping.")
Exit Function
End If
Try
SyncRunning = True
Await Sync.Run()
SyncRunning = False
Catch ex As Exception
SyncRunning = False
Logger.Warn("Error while running sync!")
Logger.Error(ex)
End Try
End Function
Private Async Function Timer_Elapsed(sender As Object, e As System.EventArgs) As Threading.Tasks.Task Handles SyncTimer.Tick Private Async Function Timer_Elapsed(sender As Object, e As System.EventArgs) As Threading.Tasks.Task Handles SyncTimer.Tick
btnForceSync.Enabled = False btnForceSync.Enabled = False
Await Sync.Run() Await RunSync()
btnForceSync.Enabled = True btnForceSync.Enabled = True
End Function End Function
@ -253,7 +277,7 @@ Partial Public Class frmMain
Private Async Sub btnForceSync_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnForceSync.ItemClick Private Async Sub btnForceSync_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnForceSync.ItemClick
btnForceSync.Enabled = False btnForceSync.Enabled = False
Await Sync.Run() Await RunSync()
btnForceSync.Enabled = True btnForceSync.Enabled = True
End Sub End Sub