If FirstTime Then
Manager.Initialize(keyDBX, secretDBX, "Manager")
Manager.LinkAccount 'must link to account
End If
Manager.AutoSync =True 'per new Erel lib 1.25
DBFilePath = File.DirRootExternal & "/HHE" 'subfolder called HHE
TenderID="DG1"
MyListtwo.Initialize
End Sub
Sub Activity_Resume
Manager.LinkAccount
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Manager_AccountReady (Success As Boolean)
MyListtwo.Initialize
Log("Account Ready: " & Success)
If Success =True Then
'Export is a Dropbox subfolder where all 6 files are downloaded from Dropbox
'The 6 files are all text files ranging from 1 kB to 300 KB max each.
'The 6 File names: DG1_Base_Comments.tab, DG1_Base_Consumables.tab, DG1_Base_Settings.tab,
'DG1_Base_Goals.tab, DG1_Base_Wells.tab, DG1_Daily.csv
For Each FileInfo As DbxFileInfo In Manager.ListFiles("/Export")
If FileInfo.Name.StartsWith(TenderID) OR FileInfo.Name.StartsWith("Base_") Then
MyFile=FileInfo.Name
MyListtwo.Add(MyFile)
End If
Next
End If
If Success=True Then
CallSub(Me,"Download") 'start downloadt
Dim p As Period 'for testing service run every few minutes
p.Minutes = 3
Dim NextSchedule As Long = DateUtils.AddPeriod(DateTime.Now, p)
StartServiceAt(svcDownload,NextSchedule,True)
Activity.Finish
End If
End Sub
Sub Manager_DownloadCompleted (Success As Boolean, LocalDir As String, LocalFileName As String)
Log("Download Completed: " & Success)
End Sub
Sub Download
For i=0 To MyListtwo.Size-1
MyFile=MyListtwo.Get(i)
GetFile
Next
End Sub
Sub GetFile
Manager.DownloadFile("/Export", MyFile, DBFilePath, MyFile)
Log(MyFile)
ToastMessageShow(MyFile,False)
End Sub