Italian Rdc2 su Systray

Xfood

Expert
Licensed User
Sto lavorando con rdc per gestire un db sqlite via rete locale,
Volevo chiedere, come posso inserite all'interno
Del sistema rdc, visto che e' sempre attivo in esecuzione, come se fosse un servizio, una verìfica di un file senza aggiungere un timer,
Cioe' dovrebbe verificare se esiste questo file nella cartella c:\tmp\file.zip , in tal caso poi tramite shell lo copio dove mi serve e lo cancello, e poi se qualche altra procedura ( non mia) copia nuovamente il file.zip nella cartella tmp, il " mio " rdc dovrebbe scatenare l'evento .
Qualche idea?.



P.s. per la parte amministrativa, come suggerito da @DonManfred sto utilizzando una procedura B4J Ui, che manda dei comandi al mio rdc, prendendo spunto dal grande amico e fratello @sfsameer detto Saif.
Invece qualche idea per il mio quesito..?
 

LucaMs

Expert
Licensed User
Longtime User
Coza ezzere RDC? Remote DATABASE controller.

Se, per qualche strano motivo (!) devi "spostare" file .zip, dovrai usare un (tuo) sw differente.

(Dovrei rileggere per tentare di capire cosa devi fare esattamente, ma mi sono già stancato troppo (e "sbilanciato") scrivendo questo post 😄)
 

Xfood

Expert
Licensed User
grazie al suggerimento di @LucaMs sono a buon punto,
sto provando questo metodo che se passo una sola cartella per analizzare eventuali cambiamenti funziona,
se passo piu cartelle separate dall "," purtroppo mi va in errore.
come posso passare i parametri corretti a questa semplice classe...

Grazie


B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Dim cfw As CustomFileWatcher
End Sub

Sub AppStart (Args() As String)
    cfw.Initialize("C:/syspc/dbcasse", Me, "CustomFileWatcherEvent")    ' OK'


                   ' questo mi da errore '
''    cfw.Initialize("C:/syspc/dbcasse,c:/pippo", Me, "CustomFileWatcherEvent")
    StartMessageLoop
End Sub

Sub CustomFileWatcherEvent_CreationDetected(PathToWatch As String, Filename As String)
    Log("New file/folder created: " & PathToWatch & "/" & Filename)
End Sub

  
Sub CustomFileWatcherEvent_ModificationDetected(PathToWatch As String, Filename As String)
    Log("Modifica File : " & PathToWatch & "/" & Filename)
End Sub

Sub CustomFileWatcherEvent_DeletionDetected(PathToWatch As String, Filename As String)
    Log("Cancellazione File : " & PathToWatch & "/" & Filename)
End Sub

la classe:
B4X:
#Event: CreationDetected(PathToWatch As String, Filename As String)
#Event: DeletionDetected(PathToWatch As String, Filename As String)
#Event: ModificationDetected(PathToWatch As String, Filename As String)
Sub Class_Globals
    Private FWatcher As FileWatcher
    Private mEventName As String
    Private mCallbackModule As Object
    Private mPathToWatch As String
    
End Sub

'Initialze the object
'Pass the path you want to watch, the module you want to be called, the event you want to be called
Public Sub Initialize(PathToWatch As Object, CallbackModule As Object, EventName As String)
    mEventName = EventName
    mCallbackModule = CallbackModule
    mPathToWatch=PathToWatch
    FWatcher.Initialize("fwEvent")
    FWatcher.SetWatchList(Array As String(mPathToWatch))
    FWatcher.StartWatching
End Sub

Public Sub FermaAvviaVerifica( FermaAvvia As Boolean)
    If FermaAvvia=False Then FWatcher.StopWatching Else FWatcher.StartWatching
End Sub
Public Sub PathControllo(mPath As Object)
    mPathToWatch=mPath
    FWatcher.StopWatching
    FWatcher.SetWatchList(Array As String(mPathToWatch))
    FWatcher.StartWatching
End Sub

Private Sub fwEvent_CreationDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_CreationDetected", mPathToWatch, FileName)
    Log("classe Creazione file")
End Sub

Private Sub fwEvent_DeletionDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_DeletionDetected", mPathToWatch, FileName)
    Log("classe Cancella file")
End Sub

Private Sub fwEvent_ModificationDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_ModificationDetected", mPathToWatch, FileName)
    Log("classe Modifica file")
End Sub

chi mi corregge questa classe...
grazie


Error: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
java.nio.file.InvalidPathException: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at butt.droid.FileWatcher$WatcherThread.run(FileWatcher.java:355)
 

Star-Dust

Expert
Licensed User
Longtime User
grazie al suggerimento di @LucaMs sono a buon punto,
sto provando questo metodo che se passo una sola cartella per analizzare eventuali cambiamenti funziona,
se passo piu cartelle separate dall "," purtroppo mi va in errore.
come posso passare i parametri corretti a questa semplice classe...

Grazie


B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Dim cfw As CustomFileWatcher
End Sub

Sub AppStart (Args() As String)
    cfw.Initialize("C:/syspc/dbcasse", Me, "CustomFileWatcherEvent")    ' OK'


                   ' questo mi da errore '
''    cfw.Initialize("C:/syspc/dbcasse,c:/pippo", Me, "CustomFileWatcherEvent")
    StartMessageLoop
End Sub

Sub CustomFileWatcherEvent_CreationDetected(PathToWatch As String, Filename As String)
    Log("New file/folder created: " & PathToWatch & "/" & Filename)
End Sub

 
Sub CustomFileWatcherEvent_ModificationDetected(PathToWatch As String, Filename As String)
    Log("Modifica File : " & PathToWatch & "/" & Filename)
End Sub

Sub CustomFileWatcherEvent_DeletionDetected(PathToWatch As String, Filename As String)
    Log("Cancellazione File : " & PathToWatch & "/" & Filename)
End Sub

la classe:
B4X:
#Event: CreationDetected(PathToWatch As String, Filename As String)
#Event: DeletionDetected(PathToWatch As String, Filename As String)
#Event: ModificationDetected(PathToWatch As String, Filename As String)
Sub Class_Globals
    Private FWatcher As FileWatcher
    Private mEventName As String
    Private mCallbackModule As Object
    Private mPathToWatch As String
   
End Sub

'Initialze the object
'Pass the path you want to watch, the module you want to be called, the event you want to be called
Public Sub Initialize(PathToWatch As Object, CallbackModule As Object, EventName As String)
    mEventName = EventName
    mCallbackModule = CallbackModule
    mPathToWatch=PathToWatch
    FWatcher.Initialize("fwEvent")
    FWatcher.SetWatchList(Array As String(mPathToWatch))
    FWatcher.StartWatching
End Sub

Public Sub FermaAvviaVerifica( FermaAvvia As Boolean)
    If FermaAvvia=False Then FWatcher.StopWatching Else FWatcher.StartWatching
End Sub
Public Sub PathControllo(mPath As Object)
    mPathToWatch=mPath
    FWatcher.StopWatching
    FWatcher.SetWatchList(Array As String(mPathToWatch))
    FWatcher.StartWatching
End Sub

Private Sub fwEvent_CreationDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_CreationDetected", mPathToWatch, FileName)
    Log("classe Creazione file")
End Sub

Private Sub fwEvent_DeletionDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_DeletionDetected", mPathToWatch, FileName)
    Log("classe Cancella file")
End Sub

Private Sub fwEvent_ModificationDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_ModificationDetected", mPathToWatch, FileName)
    Log("classe Modifica file")
End Sub

chi mi corregge questa classe...
grazie


Error: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
java.nio.file.InvalidPathException: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at butt.droid.FileWatcher$WatcherThread.run(FileWatcher.java:355)
Poi ci passi i sorgenti.


Sorgenti!! Sorgenti!! Sorgenti!! Sorgenti!! Sorgenti!! Sorgenti!!
 

Xfood

Expert
Licensed User
grazie al suggerimento di @LucaMs sono a buon punto,
sto provando questo metodo che se passo una sola cartella per analizzare eventuali cambiamenti funziona,
se passo piu cartelle separate dall "," purtroppo mi va in errore.
come posso passare i parametri corretti a questa semplice classe...

Grazie


B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Dim cfw As CustomFileWatcher
End Sub

Sub AppStart (Args() As String)
    cfw.Initialize("C:/syspc/dbcasse", Me, "CustomFileWatcherEvent")    ' OK'


                   ' questo mi da errore '
''    cfw.Initialize("C:/syspc/dbcasse,c:/pippo", Me, "CustomFileWatcherEvent")
    StartMessageLoop
End Sub

Sub CustomFileWatcherEvent_CreationDetected(PathToWatch As String, Filename As String)
    Log("New file/folder created: " & PathToWatch & "/" & Filename)
End Sub

  
Sub CustomFileWatcherEvent_ModificationDetected(PathToWatch As String, Filename As String)
    Log("Modifica File : " & PathToWatch & "/" & Filename)
End Sub

Sub CustomFileWatcherEvent_DeletionDetected(PathToWatch As String, Filename As String)
    Log("Cancellazione File : " & PathToWatch & "/" & Filename)
End Sub

la classe:
B4X:
#Event: CreationDetected(PathToWatch As String, Filename As String)
#Event: DeletionDetected(PathToWatch As String, Filename As String)
#Event: ModificationDetected(PathToWatch As String, Filename As String)
Sub Class_Globals
    Private FWatcher As FileWatcher
    Private mEventName As String
    Private mCallbackModule As Object
    Private mPathToWatch As String
    
End Sub

'Initialze the object
'Pass the path you want to watch, the module you want to be called, the event you want to be called
Public Sub Initialize(PathToWatch As Object, CallbackModule As Object, EventName As String)
    mEventName = EventName
    mCallbackModule = CallbackModule
    mPathToWatch=PathToWatch
    FWatcher.Initialize("fwEvent")
    FWatcher.SetWatchList(Array As String(mPathToWatch))
    FWatcher.StartWatching
End Sub

Public Sub FermaAvviaVerifica( FermaAvvia As Boolean)
    If FermaAvvia=False Then FWatcher.StopWatching Else FWatcher.StartWatching
End Sub
Public Sub PathControllo(mPath As Object)
    mPathToWatch=mPath
    FWatcher.StopWatching
    FWatcher.SetWatchList(Array As String(mPathToWatch))
    FWatcher.StartWatching
End Sub

Private Sub fwEvent_CreationDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_CreationDetected", mPathToWatch, FileName)
    Log("classe Creazione file")
End Sub

Private Sub fwEvent_DeletionDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_DeletionDetected", mPathToWatch, FileName)
    Log("classe Cancella file")
End Sub

Private Sub fwEvent_ModificationDetected(FileName As String)
    CallSub3(mCallbackModule, mEventName & "_ModificationDetected", mPathToWatch, FileName)
    Log("classe Modifica file")
End Sub

chi mi corregge questa classe...
grazie


Error: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
java.nio.file.InvalidPathException: Illegal char <:> at index 18: C:/syspc/dbcasse,c:/pippo
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at butt.droid.FileWatcher$WatcherThread.run(FileWatcher.java:355)
Help. Help. Help.
 

Star-Dust

Expert
Licensed User
Longtime User
Help. Help. Help.
Questa libreria è particolare. Usa FileWarcher in questo modo


B4X:
fw.Initialize("fw")
fw.SetWatchList(ListPathWatch) 'ListPathWatch As List of String
fw.StartWatching

Metti tutte le cartelle che vuoi controllare nella lista e si solleverà l'evento ad ogni variazione
B4X:
Sub fw_CreationDetected(FileName As String)
    Log("CreationDetected: " & FileName)    'Logs the creation of a new file or folder
End Sub

Sub fw_DeletionDetected(FileName As String)
    Log("DeletionDetected: " & FileName)   'Logs the deletion of a file or folder
End Sub

Sub fw_ModificationDetected(FileName As String)
    Log("ModificationDetected: " & FileName)   'Logs the modification of a file or folder
End Sub

Non ti esce il percorso purtroppo, quindi se ti interessa il percorso meglio avere un FileWatch per ogni percorso specifico con un evento separato
 

Xfood

Expert
Licensed User
Il mio problema e' passare il parametro come stringa, tipo:
Pasametro ="c:/cartella1" & "," & "c:/cartella2"
Mi da errore, se pasdo solo una cartella funziona.
 

Xfood

Expert
Licensed User
Cosi Funziona
cfw.Initialize("C:/syspc/dbcasse", Me, "CustomFileWatcherEvent") ' OK'



Cosi no.

' questo mi da errore '
'' cfw.Initialize("C:/syspc/dbcasse,c:/pippo", Me, "CustomFileWatcherEvent")
StartMessageLoop
 

Xfood

Expert
Licensed User
Era per provare una classe..

Quindi se passo i dati come stringa funziona?
 

Star-Dust

Expert
Licensed User
Longtime User
La Classe CustomFileWatch usa FileWatch... io ti consiglio di usare direttamente file Watch

Oppure modifica la classe CustomFileWatch cosi:
B4X:
Public Sub Initialize(PathToWatch As String, CallbackModule As Object, EventName As String)
    mEventName = EventName
    mCallbackModule = CallbackModule
    mPathToWatch=PathToWatch
    FWatcher.Initialize("fwEvent")
    FWatcher.SetWatchList(Regex.Split(",",mPathToWatch))
    FWatcher.StartWatching
End Sub

questa modifica ti permetterebbe di dividere i percorsi da una virgola...
 

Star-Dust

Expert
Licensed User
Longtime User
Era per provare una classe..

Quindi se passo i dati come stringa funziona?
NOOOOOOOOOOOOO. Un array di stringhe. Leggili i parametri
 

Xfood

Expert
Licensed User
La Classe CustomFileWatch usa FileWatch... io ti consiglio di usare direttamente file Watch

Oppure modifica la classe CustomFileWatch cosi:
B4X:
Public Sub Initialize(PathToWatch As String, CallbackModule As Object, EventName As String)
    mEventName = EventName
    mCallbackModule = CallbackModule
    mPathToWatch=PathToWatch
    FWatcher.Initialize("fwEvent")
    FWatcher.SetWatchList(Regex.Split(",",mPathToWatch))
    FWatcher.StartWatching
End Sub

questa modifica ti permetterebbe di dividere i percorsi da una virgola...
Tra le varie prove mi sembra di averlo provato, provo dopo cena questa modifica.
Grazie
 

Star-Dust

Expert
Licensed User
Longtime User
La Classe CustomFileWatch usa FileWatch... io ti consiglio di usare direttamente file Watch

Oppure modifica la classe CustomFileWatch cosi:
B4X:
Public Sub Initialize(PathToWatch As String, CallbackModule As Object, EventName As String)
    mEventName = EventName
    mCallbackModule = CallbackModule
    mPathToWatch=PathToWatch
    FWatcher.Initialize("fwEvent")
    FWatcher.SetWatchList(Regex.Split(",",mPathToWatch))
    FWatcher.StartWatching
End Sub

questa modifica ti permetterebbe di dividere i percorsi da una virgola...
Con questa modifica puoi passare in percorsi come stringa unica divise da una virgola.

Comunque non ti serve la classe CustomFileWatch
 
Last edited:

Xfood

Expert
Licensed User
La Classe CustomFileWatch usa FileWatch... io ti consiglio di usare direttamente file Watch

Oppure modifica la classe CustomFileWatch cosi:
B4X:
Public Sub Initialize(PathToWatch As String, CallbackModule As Object, EventName As String)
    mEventName = EventName
    mCallbackModule = CallbackModule
    mPathToWatch=PathToWatch
    FWatcher.Initialize("fwEvent")
    FWatcher.SetWatchList(Regex.Split(",",mPathToWatch))
    FWatcher.StartWatching
End Sub

questa modifica ti permetterebbe di dividere i percorsi da una virgola...
Funziona... woww.. Grazie. Sei un grande @Star-Dust
 

LucaMs

Expert
Licensed User
Longtime User
Sei un grande @Star-Dust
Per quella robetta? Se guardassi bene qualche altro suo sorgente, che diresti, che è Dio? 😄

Spiego bene, non si sa mai venisse travisato...
Ciò che ha scritto @Star-Dust in questo thread sono inezie, come lui stesso sa, e le sue capacità vanno bel al di là!

[Mi sento stranamente buono, stasera 😄. Va beh, e come sempre sono sincero, tranne quando scherzo, ovvero... quasi sempre 😄]
 
Top