#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#CommandLineArgs:
#AdditionalJar: sqlite-jdbc-3.7.2
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Button_close As Button
Private Button_open As Button
Private TableView_list As TableView
Private sqlite As class_sqlite
Private ProgressBar1 As ProgressBar
Private Thread1 As Thread
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
sqlite.Initialize
Thread1.Initialise("Thread1")
resize_column_tableview
End Sub
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Button_open_Click
If Thread1.Start(Me, "AsyncSetMap", Null) = True Then
ProgressBar1.Progress = -1
End If
End Sub
Sub Thread1_Ended(endedOK As Boolean, error As String)
Log(error)
ProgressBar1.Progress = 0
AsyncSetMap(Null)
End Sub
Private Sub AsyncSetMap(obj As Object)
Dim FC As FileChooser
FC.Initialize
FileChooserUtils.AddExtensionFilters4(FC,Array As String("CSV","Text FIles"),Array As String("*.csv","*.txt"),True,"Output Files",True)
FC.Title = "Open file CSV"
Dim FileName As String = FC.ShowOpen(MainForm)
Dim DirParent As String = FC.InitialDirectory
FileName = FileName.Replace(DirParent & "\","")' C:\Users\ivanomonti\Desktop\ExportSelfAgent.csv
Dim myTextReader As TextReader
myTextReader.Initialize(File.OpenInput(DirParent,FileName))
Dim values As String = myTextReader.ReadAll
myTextReader.Close
Dim list As List
list.Initialize
list = Regex.Split(Chr(10),values)
Dim count, error As Int
count = 0
error = 0
TableView_list.Items.Clear
Dim listexport As String
For i=1 To list.Size-1
Try
count = count + 1
values = list.Get(i)
Dim m() As String = Regex.Split(";",values.Replace("""","").Replace("=","").Replace(Chr(10),""))
Dim mp As Map
mp.Initialize
mp.Put("Name",m(4))
mp.Put("Surname","")
mp.Put("Phone",m(0))
mp.Put("Status",m(14))
If sqlite.client_add(mp) = True Then
Dim Row() As Object = Array ( m(4).ToUpperCase, m(0).ToUpperCase, m(5).ToLowerCase & " " & m(6).ToLowerCase, m(14).ToLowerCase,m(15).ToLowerCase)
End If
TableView_list.Items.Add(Row)
Catch
count = count-1
error = error+1
listexport = listexport & Chr(10) & i & " " & values
End Try
Next
File.WriteString(DirParent,"Report.txt",listexport)
fx.Msgbox(MainForm,"The file " & FileName & " was successfully imported, we found errors (" & error & ") found in the saved report","Alert")
fx.ShowExternalDocument(File.GetUri(DirParent,"Report.txt"))
End Sub
Sub Button_save_Click
End Sub
Sub resize_column_tableview
TableView_list.SetColumnWidth(0, TableView_list.PrefWidth*25/100)
TableView_list.SetColumnWidth(1, TableView_list.PrefWidth*5/100)
TableView_list.SetColumnWidth(2, TableView_list.PrefWidth*15/100)
TableView_list.SetColumnWidth(3, TableView_list.PrefWidth*15/100)
TableView_list.SetColumnWidth(4, TableView_list.PrefWidth*40/100)
End Sub
Sub Button_close_Click
ExitApplication
End Sub
Sub TableView_list_Resize (Width As Double, Height As Double)
resize_column_tableview
End Sub