I have One List which contains a certain number of matricules to test that i call LeftList and 2 timers since am testing same list.The scenario is that i must use this list to do the operation : With first index of list i will test all other indicies to verify if there is a duplicate and so on until the list is finish.The problem is that with this method is time consuming since i retest all the time already tested matricules.I want to be able to exclude already tested matricule from next tests in order to reduce testing time.What are the best practicies i tried List.RemoveAt(Index) but i always get idex out of bounds This is what i've done so far that works.
B4X:
Sub Tim_Tick
Log("Here Tim1")
'IndexToTest = IndexToTest3
If IndexToTest >= SizeToTest Then
Log("Here off Tim1")
Tim.Enabled = False
Encours = False
Else
Log("Here On Tim1")
Encours = True
AffcherAvecMatricule1(LeftList.Get(IndexToTest),PourQuix2)
CheckDuplicates(LeftList.Get(IndexToTest2),LeftList.Get(IndexToTest),PourQuix2)
IndexToTest = IndexToTest + 1
If IndexToTest = SizeToTest Then
IndexToTest = 0
IndexToTest2 = IndexToTest2 + 1
Tim2.Enabled = True
Tim.Enabled = False
End If
End If
End Sub
Sub Tim2_Tick
Log("Here Tim2")
ProgressBar1.Progress = (IndexToTest2/LeftList.Size) * 100
lblPercentage.Text = ProgressBar1.Progress & " % "
If IndexToTest2 = SizeToTest Then
Log("Here off Tim2")
Tim2.Enabled = False
Encours = False
Else
Log("Here On Tim2")
Encours = True
AffcherAvecMatricule2(LeftList.Get(IndexToTest2),PourQuix2)
MediaPlayer1.Play
ActionBar.SubTitle = "Checking Duplicates For Matricule " & txtCode1.Text
Tim.Enabled = True
Tim2.Enabled = False
End If
End Sub
Sub btnGo_Click
Try
AffcherAvecMatricule2(LeftList.Get(0),PourQuix2)
MediaPlayer1.Play
ActionBar.SubTitle = "Checking Duplicates For Matricule " & txtCode1.Text
lblPercentage.Text = "0 %"
ProgressBar1.Progress = 0
IndexToTest = 0
IndexToTest2 = 0
Tim.Enabled = True
'Delete_LocalRows(PourQuix)
Catch
Log(LastException)
End Try
End Sub
Sub Delete_LocalRows(TableName As String)
Try
Dim Query As String = "DELETE FROM '"& TableName &"'"
Starter.SQL1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
End Sub
Sub CheckDuplicates(WithMatriculeA As String,WithMatriculeB As String,TableName As String)
Log(" IndexFirst "& WithMatriculeA & " IndexSecond "& WithMatriculeB)
Dim PathToFile1Left As String
Dim PathToFile1Right As String
Dim PathToFileLeft As String
Dim PathToFileRight As String
Dim Matriculos As String
Dim EmpreintosL() As Byte
Dim EmpreintosR() As Byte
Dim RSA As ResultSet = Starter.SQL1.ExecQuery("SELECT idetudiantetablissement,matriculeetudiantharmonise, empreinteetudiantgauche,empreinteetudiantdroite, imageempreintegauche, imageempreintedroite, photoetudiant, dateenrolementetudiant, handicapetudiantok, langueorigineetudiant, typeclavierprefere, signatureelectroniqueetudianteta, observationdoublons,confirmationidentification, confirmationreception, dateconfirmationetudiant FROM '"&TableName &"' WHERE matriculeetudiantharmonise = '"& WithMatriculeA &"'")
Do While RSA.NextRow
Matriculos = RSA.GetString("matriculeetudiantharmonise")
EmpreintosL = Su.DecodeBase64(RSA.GetString("empreinteetudiantgauche"))
PathToFile1Left = MCL.saveFPToFile(File.DirDefaultExternal&"/HESIProjectFolder",EmpreintosL,Matriculos&".iso-fmr")
EmpreintosR = Su.DecodeBase64(RSA.GetString("empreinteetudiantdroite"))
PathToFile1Right = MCL.saveFPToFile(File.DirDefaultExternal&"/HESIProjectFolder",EmpreintosR,Matriculos&".iso-fmr")
Log(" Index First Valid = "& MCL.isValidTemplate(MCL.pathToByte(PathToFile1Left)) & " Index Second Is Valid "& MCL.isValidTemplate(MCL.pathToByte(PathToFile1Right)))
Loop
RSA.Close
Dim RSB As ResultSet = Starter.SQL1.ExecQuery("SELECT idetudiantetablissement,matriculeetudiantharmonise, empreinteetudiantgauche,empreinteetudiantdroite, imageempreintegauche, imageempreintedroite, photoetudiant, dateenrolementetudiant, handicapetudiantok, langueorigineetudiant, typeclavierprefere, signatureelectroniqueetudianteta, observationdoublons,confirmationidentification, confirmationreception, dateconfirmationetudiant FROM '"& TableName &"' WHERE matriculeetudiantharmonise = '"& WithMatriculeB &"'")
Do While RSB.NextRow
Matriculos = RSB.GetString("matriculeetudiantharmonise")
EmpreintosL = Su.DecodeBase64(RSB.GetString("empreinteetudiantgauche"))
PathToFileLeft = MCL.saveFPToFile(File.DirDefaultExternal&"/HESIProjectFolder",EmpreintosL,Matriculos&".iso-fmr")
EmpreintosR = Su.DecodeBase64(RSB.GetString("empreinteetudiantdroite"))
PathToFileRight = MCL.saveFPToFile(File.DirDefaultExternal&"/HESIProjectFolder",EmpreintosR,Matriculos&".iso-fmr")
Log(" Index First Valid = " & MCL.isValidTemplate(MCL.pathToByte(PathToFileLeft)) & " Index Second Is Valid "& MCL.isValidTemplate(MCL.pathToByte(PathToFileRight)))
Loop
RSB.Close
Dim NumDou As String
If MCL.verifyMatch(PathToFile1Left,PathToFileLeft) = "VERIFICATION MATCHED" Or MCL.verifyMatch(PathToFile1Left,PathToFileRight) = "VERIFICATION MATCHED" Then
Update_ViewCallFromThere(imgCheck1,True)
If MCL.verifyMatch(PathToFile1Left,PathToFileLeft) = "VERIFICATION MATCHED" Then
NumDou = Count_Doublons(PourQuix,PourQui)
If WithMatriculeA <> WithMatriculeB Then
Insert_Doublons(NumDou,WithMatriculeA,WithMatriculeB,"Empreinte Gauche En Doublon Avec Empreinte Gauche",PourQuix)
End If
End If
If MCL.verifyMatch(PathToFile1Left,PathToFileRight) = "VERIFICATION MATCHED" Then
NumDou = Count_Doublons(PourQuix,PourQui)
If WithMatriculeA <> WithMatriculeB Then
Insert_Doublons(NumDou,WithMatriculeA,WithMatriculeB,"Empreinte Gauche En Doublon Avec Empreinte Droite",PourQuix)
End If
End If
End If
If MCL.verifyMatch(PathToFile1Left,PathToFileLeft) = "VERIFICATION FAILED" And MCL.verifyMatch(PathToFile1Left,PathToFileRight) = "VERIFICATION FAILED" Then
Update_ViewCallFromThere(imgCheck1,False)
End If
If MCL.verifyMatch(PathToFile1Right,PathToFileRight) = "VERIFICATION MATCHED" Or MCL.verifyMatch(PathToFile1Right,PathToFileLeft) = "VERIFICATION MATCHED" Then
Update_ViewCallFromThere(imgCheck2,True)
If MCL.verifyMatch(PathToFile1Right,PathToFileRight) = "VERIFICATION MATCHED" Then
NumDou = Count_Doublons(PourQuix,PourQui)
If WithMatriculeA <> WithMatriculeB Then
Insert_Doublons(NumDou,WithMatriculeA,WithMatriculeB,"Empreinte Droite En Doublon Avec Empreinte Droite",PourQuix)
End If
End If
If MCL.verifyMatch(PathToFile1Right,PathToFileLeft) = "VERIFICATION MATCHED" Then
NumDou = Count_Doublons(PourQuix,PourQui)
If WithMatriculeA <> WithMatriculeB Then
Insert_Doublons(NumDou,WithMatriculeA,WithMatriculeB,"Empreinte Droite En Doublon Avec Empreinte Gauche",PourQuix)
End If
End If
End If
If MCL.verifyMatch(PathToFile1Right,PathToFileRight) = "VERIFICATION FAILED" And MCL.verifyMatch(PathToFile1Right,PathToFileLeft) = "VERIFICATION FAILED" Then
Update_ViewCallFromThere(imgCheck2,False)
End If
End Sub
Sub Insert_Doublons(Numero As String,MatriculeSource As String,MatriculeCible As String,Observations As String,TableName As String)
Try
Dim Query As String
If PourQui = "Etablissement" Then
Query = "INSERT INTO '"& TableName &"' (iddoublonsetablissement,matriculesource,matriculecible,observation) VALUES (?,?,?,?)"
Else If PourQui = "University" Then
Query = "INSERT INTO '"& TableName &"' (iddoublonsuniversite,matriculesource,matriculecible,observation) VALUES (?,?,?,?)"
Else If PourQui = "Ministry" Then
Query = "INSERT INTO '"& TableName &"' (iddoublonsministere,matriculesource,matriculecible,observation) VALUES (?,?,?,?)"
End If
Starter.SQL1.ExecNonQuery2(Query,Array As Object(Numero,MatriculeSource,MatriculeCible,Observations))
Catch
Log(LastException)
End Try
End Sub