Commit inicial
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
**/Objects
|
||||||
|
**/AutoBackups
|
||||||
|
*.meta
|
||||||
717
B4A/C_cliente.bas
Normal file
@@ -0,0 +1,717 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=12.2
|
||||||
|
@EndOfDesignText@
|
||||||
|
Sub Class_Globals
|
||||||
|
Private Root As B4XView 'ignore
|
||||||
|
Private xui As XUI 'ignore
|
||||||
|
Private ScrollView1 As ScrollView
|
||||||
|
Private Panel1 As Panel
|
||||||
|
Dim IME As IME
|
||||||
|
Private p_cuestionario As Panel
|
||||||
|
Private paneltop As Panel
|
||||||
|
Private camEx2 As CameraExClass2
|
||||||
|
Dim frontCamera As Boolean = False
|
||||||
|
Private p_cam As Panel
|
||||||
|
Dim nombrefoto As String = "0"
|
||||||
|
Dim nombrefoto1 As String = "0"
|
||||||
|
Dim nombrefoto2 As String = "0"
|
||||||
|
Dim nombrefoto3 As String = "0"
|
||||||
|
Dim nombrefoto4 As String = "0"
|
||||||
|
Dim nombrefoto5 As String = "0"
|
||||||
|
Dim nombrefoto6 As String = "0"
|
||||||
|
Dim nombrefoto7 As String = "0"
|
||||||
|
Dim nombrefoto8 As String = "0"
|
||||||
|
Private p_camara As Panel
|
||||||
|
Private teclado As IME
|
||||||
|
Private ImageView1 As ImageView
|
||||||
|
Private ImageView2 As ImageView
|
||||||
|
Private ImageView3 As ImageView
|
||||||
|
Private ImageView4 As ImageView
|
||||||
|
Private ImageView5 As ImageView
|
||||||
|
Private ImageView6 As ImageView
|
||||||
|
Private ImageView7 As ImageView
|
||||||
|
Private ImageView8 As ImageView
|
||||||
|
Private ImageView9 As ImageView
|
||||||
|
Private RadioButton1 As RadioButton
|
||||||
|
Private RadioButton2 As RadioButton
|
||||||
|
Private RadioButton3 As RadioButton
|
||||||
|
Private RadioButton4 As RadioButton
|
||||||
|
Private RadioButton5 As RadioButton
|
||||||
|
Private RadioButton6 As RadioButton
|
||||||
|
Private RadioButton7 As RadioButton
|
||||||
|
Private RadioButton8 As RadioButton
|
||||||
|
Private RadioButton9 As RadioButton
|
||||||
|
Private RadioButton10 As RadioButton
|
||||||
|
Private RadioButton11 As RadioButton
|
||||||
|
Private RadioButton12 As RadioButton
|
||||||
|
Private RadioButton13 As RadioButton
|
||||||
|
Private RadioButton14 As RadioButton
|
||||||
|
Private RadioButton15 As RadioButton
|
||||||
|
Private RadioButton16 As RadioButton
|
||||||
|
Private RadioButton17 As RadioButton
|
||||||
|
Private RadioButton18 As RadioButton
|
||||||
|
Private EditText1 As EditText
|
||||||
|
Private EditText2 As EditText
|
||||||
|
Private EditText3 As EditText
|
||||||
|
Private EditText4 As EditText
|
||||||
|
Private EditText5 As EditText
|
||||||
|
Private EditText6 As EditText
|
||||||
|
Private EditText7 As EditText
|
||||||
|
Private EditText8 As EditText
|
||||||
|
Private EditText9 As EditText
|
||||||
|
Dim p1 As String
|
||||||
|
Dim p2 As String
|
||||||
|
Dim p3 As String
|
||||||
|
Dim p4 As String
|
||||||
|
Dim p5 As String
|
||||||
|
Dim p6 As String
|
||||||
|
Dim p7 As String
|
||||||
|
Dim p8 As String
|
||||||
|
Dim p9 As String
|
||||||
|
Private Label2 As Label
|
||||||
|
Private Label4 As Label
|
||||||
|
Private Label6 As Label
|
||||||
|
Private Label8 As Label
|
||||||
|
Private Label10 As Label
|
||||||
|
Private Label12 As Label
|
||||||
|
Private Label14 As Label
|
||||||
|
Private Label16 As Label
|
||||||
|
Private Label18 As Label
|
||||||
|
Dim c As Cursor
|
||||||
|
Dim d As Cursor
|
||||||
|
Dim e As Cursor
|
||||||
|
Dim fototomada As String
|
||||||
|
Dim timer As Timer
|
||||||
|
Dim timer2 As Timer
|
||||||
|
Dim reqManager As DBRequestManager
|
||||||
|
Private l_ubicacion As Label
|
||||||
|
Dim mlat As String
|
||||||
|
Dim mlon As String
|
||||||
|
Dim logger As Boolean = False
|
||||||
|
Dim laDist As Float
|
||||||
|
Private ubicacion As Location
|
||||||
|
Dim l1, l2 As Location
|
||||||
|
Dim distance As Long
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'You can add more parameters here.
|
||||||
|
Public Sub Initialize As Object
|
||||||
|
Return Me
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'This event will be called once, before the page becomes visible.
|
||||||
|
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||||
|
Root = Root1
|
||||||
|
Root.LoadLayout("cliente")
|
||||||
|
reqManager.Initialize(Me, Starter.DBReqServer)
|
||||||
|
IME.Initialize("IME")
|
||||||
|
IME.AddHeightChangedEvent
|
||||||
|
IME_HeightChanged(100%y, 0)
|
||||||
|
'load the layout to Root
|
||||||
|
ScrollView1.height = Root.Height - Panel1.Height
|
||||||
|
|
||||||
|
ScrollView1.Panel.LoadLayout("p_cuest")
|
||||||
|
ScrollView1.Panel.Height = p_cuestionario.Height
|
||||||
|
Log(Starter.latitud & " , " & Starter.longitud)
|
||||||
|
p_camara.Height = Root.Height
|
||||||
|
p_camara.Width = Root.Width
|
||||||
|
p_camara.Visible = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub B4XPage_Appear
|
||||||
|
Log(Starter.latitud & " , " & Starter.longitud)
|
||||||
|
c = Starter.skmt.ExecQuery("SELECT latitud, longitud FROM CUENTAA")
|
||||||
|
c.Position = 0
|
||||||
|
mlat=0
|
||||||
|
mlon=0
|
||||||
|
If c.GetString("latitud") <> "" Then
|
||||||
|
mlat = c.GetString("latitud")
|
||||||
|
mlon = c.GetString("longitud")
|
||||||
|
End If
|
||||||
|
c.Close
|
||||||
|
|
||||||
|
If Not(Starter.GPS.GPSEnabled) Then
|
||||||
|
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
||||||
|
StartActivity(Starter.GPS.LocationSettingsIntent)
|
||||||
|
Else
|
||||||
|
Starter.GPS.Start(0, 0)
|
||||||
|
If Starter.ubicacionActual.Latitude <> 0 Then GPS_LocationChanged(Starter.ubicacionActual)
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub GPS_LocationChanged (Location1 As Location)
|
||||||
|
|
||||||
|
' ubicacion.Initialize
|
||||||
|
' ubicacion.Latitude = mlat
|
||||||
|
' ubicacion.Longitude = mlon
|
||||||
|
' If logger Then Log($"${Location1.Latitude}, ${Location1.Longitude}, ${Location1.Accuracy}"$)
|
||||||
|
' laDist = Location1.DistanceTo(ubicacion)
|
||||||
|
' l_ubicacion.Text = $"Dist: $1.0{laDist} mts."$
|
||||||
|
|
||||||
|
l1.Initialize2(Starter.latitud,Starter.longitud)
|
||||||
|
l2.Initialize2(mlat, mlon)
|
||||||
|
distance = l1.DistanceTo(l2) ' resultado en metros
|
||||||
|
' Log (distance)
|
||||||
|
' Log(mlat & " , " & mlon)
|
||||||
|
' Log(Starter.latitud & " , " & Starter.longitud)
|
||||||
|
l_ubicacion.Text = $"Dist: $1.0{distance} mts."$
|
||||||
|
If laDist > 50 Then l_ubicacion.TextColor = Colors.Red Else l_ubicacion.TextColor = Colors.Blue
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'tomar foto
|
||||||
|
|
||||||
|
Private Sub InitializeCamera2
|
||||||
|
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
|
||||||
|
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
If Result Then
|
||||||
|
camEx2.Initialize(p_cam, frontCamera, Me, "Camera1")
|
||||||
|
frontCamera = camEx2.Front
|
||||||
|
Log("inicializamos Camara")
|
||||||
|
Else
|
||||||
|
ToastMessageShow("No permission!!!", True)
|
||||||
|
End If
|
||||||
|
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
|
||||||
|
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
If Result Then
|
||||||
|
Log("conpermisos para escritura")
|
||||||
|
Else
|
||||||
|
ToastMessageShow("No permission!!!", True)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
|
||||||
|
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
If Result Then
|
||||||
|
Log("conpermisos para escritura")
|
||||||
|
Else
|
||||||
|
ToastMessageShow("No permission!!!", True)
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Camera1_Ready (Success As Boolean)
|
||||||
|
Log("Camara ready")
|
||||||
|
If Success Then
|
||||||
|
camEx2.SetJpegQuality(90)
|
||||||
|
camEx2.SetContinuousAutoFocus
|
||||||
|
camEx2.CommitParameters
|
||||||
|
camEx2.StartPreview
|
||||||
|
Log(camEx2.GetPreviewSize)
|
||||||
|
Else
|
||||||
|
ToastMessageShow("Cannot open camera.", True)
|
||||||
|
Log("Cannot open camera")
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView1_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto = DateTime.Now & "_planograma.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView2_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto1 = DateTime.Now & "_catalogo.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto1
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView3_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto2 = DateTime.Now & "_presenciaanaqel.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto2
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView4_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto3 = DateTime.Now & "_exhibicion.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto3
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView5_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto4 = DateTime.Now & "_cabecera.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto4
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView6_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto5 = DateTime.Now & "_innovacion.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto5
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView7_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto6 = DateTime.Now & "_abasto.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto6
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView8_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto7 = DateTime.Now & "_foods.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto7
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ImageView9_Click
|
||||||
|
' foto = 2
|
||||||
|
DateTime.DateFormat="ddMMyyyyHHmmss"
|
||||||
|
InitializeCamera2
|
||||||
|
p_camara.Visible = True
|
||||||
|
nombrefoto8 = DateTime.Now & "_pc.jpg"
|
||||||
|
teclado.HideKeyboard
|
||||||
|
fototomada = nombrefoto8
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub p_camara_Click
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub b_foto_inci_Click
|
||||||
|
camEx2.TakePicture
|
||||||
|
p_camara.Visible = False
|
||||||
|
' StopCamera2
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Camera1_PictureTaken (Data()As Byte)
|
||||||
|
Log("tome foto")
|
||||||
|
Dim filename As String = fototomada
|
||||||
|
Dim Dirp As String = File.DirInternal
|
||||||
|
Dim Dir As String
|
||||||
|
Dim Dir2 As String
|
||||||
|
Try
|
||||||
|
File.MakeDir(Dirp,"/promotoriakmts")
|
||||||
|
Dir = "/promotoriakmts"
|
||||||
|
Log("creado en promotoria " & Dirp & Dir)
|
||||||
|
Catch
|
||||||
|
Dir = ""
|
||||||
|
Log("creado en raiz")
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Try
|
||||||
|
File.MakeDir(Dirp & Dir,"/reduccion")
|
||||||
|
Dir2 = "/reduccion"
|
||||||
|
Log("creado en promotoria " & Dirp & Dir & Dir2)
|
||||||
|
Catch
|
||||||
|
Dir = ""
|
||||||
|
Log("creado en raiz")
|
||||||
|
End Try
|
||||||
|
|
||||||
|
camEx2.SavePictureToFile(Data, Dirp&Dir, filename)
|
||||||
|
camEx2.StartPreview 'restart preview
|
||||||
|
ToastMessageShow("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename, True)
|
||||||
|
Log("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename)
|
||||||
|
p_camara.Visible = False
|
||||||
|
|
||||||
|
|
||||||
|
If nombrefoto <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView1.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto1 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView2.Bitmap = LoadBitmap(File.DirInternal & Dir& Dir2,nombrefoto1)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto2 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView3.Bitmap = LoadBitmap(File.DirInternal & Dir& Dir2,nombrefoto2)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto3 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView4.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto3)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto4 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView5.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto4)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto5 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView6.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto5)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto6 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView7.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto6)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto7 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView8.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto7)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If nombrefoto8 <> 0 Then
|
||||||
|
Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 300, 450, True)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
|
||||||
|
img.WriteToStream(out, 100, "PNG")
|
||||||
|
out.Close
|
||||||
|
ImageView9.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto8)
|
||||||
|
End If
|
||||||
|
StopCamera2
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub StopCamera2
|
||||||
|
' Capturing = False
|
||||||
|
If camEx2.IsInitialized Then
|
||||||
|
camEx2.Release
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub b_guardar_Click
|
||||||
|
If EditText1.Text <> "" And nombrefoto <> 0 And RadioButton1.Checked = True Or RadioButton2.Checked = True Then
|
||||||
|
If RadioButton1.Checked Then p1 = "Satisfactorio"
|
||||||
|
If RadioButton2.Checked Then p1 = "Incompleto"
|
||||||
|
' Log(nombrefoto)
|
||||||
|
|
||||||
|
If EditText2.Text <> "" And nombrefoto1 <> 0 And RadioButton3.Checked = True Or RadioButton4.Checked = True Then
|
||||||
|
If RadioButton3.Checked Then p2 = "Satisfactorio"
|
||||||
|
If RadioButton4.Checked Then p2 = "Incompleto"
|
||||||
|
|
||||||
|
If EditText3.Text <> "" And nombrefoto2 <> 0 And RadioButton5.Checked = True Or RadioButton6.Checked = True Then
|
||||||
|
If RadioButton5.Checked Then p3 = "Satisfactorio"
|
||||||
|
If RadioButton6.Checked Then p3 = "Incompleto"
|
||||||
|
|
||||||
|
If EditText4.Text <> "" And nombrefoto3 <> 0 And RadioButton7.Checked = True Or RadioButton8.Checked = True Then
|
||||||
|
If RadioButton7.Checked Then p4 = "Satisfactorio"
|
||||||
|
If RadioButton8.Checked Then p4 = "Incompleto"
|
||||||
|
|
||||||
|
If EditText5.Text <> "" And nombrefoto4 <> 0 And RadioButton9.Checked = True Or RadioButton10.Checked = True Then
|
||||||
|
If RadioButton9.Checked Then p5 = "Satisfactorio"
|
||||||
|
If RadioButton10.Checked Then p5 = "Incompleto"
|
||||||
|
|
||||||
|
If EditText6.Text <> "" And nombrefoto5 <> 0 And RadioButton11.Checked = True Or RadioButton12.Checked = True Then
|
||||||
|
If RadioButton11.Checked Then p6 = "Satisfactorio"
|
||||||
|
If RadioButton12.Checked Then p6 = "Incompleto"
|
||||||
|
|
||||||
|
If EditText7.Text <> "" And nombrefoto6 <> 0 And RadioButton13.Checked = True Or RadioButton14.Checked = True Then
|
||||||
|
If RadioButton13.Checked Then p7 = "Satisfactorio"
|
||||||
|
If RadioButton14.Checked Then p7 = "Incompleto"
|
||||||
|
|
||||||
|
If EditText8.Text <> "" And nombrefoto7 <> 0 And RadioButton15.Checked = True Or RadioButton16.Checked = True Then
|
||||||
|
If RadioButton15.Checked Then p8 = "Satisfactorio"
|
||||||
|
If RadioButton16.Checked Then p8 = "Incompleto"
|
||||||
|
|
||||||
|
If EditText9.Text <> "" And nombrefoto8 <> 0 And RadioButton17.Checked = True Or RadioButton18.Checked = True Then
|
||||||
|
If RadioButton17.Checked Then p9 = "Satisfactorio"
|
||||||
|
If RadioButton18.Checked Then p9 = "Incompleto"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
If distance > 50 Then
|
||||||
|
|
||||||
|
c = Starter.skmt.ExecQuery("SELECT cuenta FROM CUENTAA")
|
||||||
|
c.Position = 0
|
||||||
|
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label2.Text,p1,EditText1.Text,nombrefoto))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label4.Text,p2,EditText2.Text,nombrefoto1))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label6.Text,p3,EditText3.Text,nombrefoto2))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label8.Text,p4,EditText4.Text,nombrefoto3))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label10.Text,p5,EditText5.Text,nombrefoto4))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label12.Text,p6,EditText6.Text,nombrefoto5))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label14.Text,p7,EditText7.Text,nombrefoto6))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label16.Text,p8,EditText8.Text,nombrefoto7))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label18.Text,p9,EditText9.Text,nombrefoto8))
|
||||||
|
Starter.skmt.ExecNonQuery("UPDATE CUENTAA SET asignado = '0'")
|
||||||
|
Starter.skmt.ExecNonQuery2("UPDATE DATOS_CLIENTE SET ESTATUS = 1 WHERE CAT_CL_CODIGO = ?", Array As String(c.GetString("cuenta")))
|
||||||
|
MsgboxAsync("Datos guardados","Atención")
|
||||||
|
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
d = Starter.skmt.ExecQuery("SELECT CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO FROM HIST_PREGUNTAS")
|
||||||
|
e = Starter.skmt.ExecQuery("SELECT RUTA FROM CARGA")
|
||||||
|
e.Position = 0
|
||||||
|
Log("estoy aqui")
|
||||||
|
For i = 0 To d.RowCount - 1
|
||||||
|
d.Position = i
|
||||||
|
Log("estoy aqui 2")
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "delete_hist_promotoria_INTMEX"
|
||||||
|
cmd.Parameters = Array As Object(Starter.almacen, e.GetString("RUTA"),B4XPages.MainPage.user,d.GetString("CLIENTE"),d.GetString("CATEGORIA"))
|
||||||
|
B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "delete")
|
||||||
|
Next
|
||||||
|
|
||||||
|
c.Close
|
||||||
|
d.Close
|
||||||
|
e.Close
|
||||||
|
|
||||||
|
timer.Initialize("Timerconteo",20000)
|
||||||
|
timer.Enabled = True
|
||||||
|
|
||||||
|
Timerconteo_tick
|
||||||
|
guardado
|
||||||
|
B4XPages.ShowPage ("principal")
|
||||||
|
|
||||||
|
Else if distance < 50 Then
|
||||||
|
|
||||||
|
Dim result As Int
|
||||||
|
result = Msgbox2("Estas fuera de rango de check-in. ¿Deseas enviar la información?", "Atención","Si","","No",Null)
|
||||||
|
If result = DialogResponse.POSITIVE Then
|
||||||
|
|
||||||
|
c = Starter.skmt.ExecQuery("SELECT cuenta FROM CUENTAA")
|
||||||
|
c.Position = 0
|
||||||
|
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label2.Text,p1,EditText1.Text,nombrefoto))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label4.Text,p2,EditText2.Text,nombrefoto1))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label6.Text,p3,EditText3.Text,nombrefoto2))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label8.Text,p4,EditText4.Text,nombrefoto3))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label10.Text,p5,EditText5.Text,nombrefoto4))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label12.Text,p6,EditText6.Text,nombrefoto5))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label14.Text,p7,EditText7.Text,nombrefoto6))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label16.Text,p8,EditText8.Text,nombrefoto7))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_PREGUNTAS(CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO) VALUES(?,?,?,?,?)", Array As Object(c.GetString("cuenta"),Label18.Text,p9,EditText9.Text,nombrefoto8))
|
||||||
|
Starter.skmt.ExecNonQuery("UPDATE CUENTAA SET asignado = '0'")
|
||||||
|
Starter.skmt.ExecNonQuery2("UPDATE DATOS_CLIENTE SET ESTATUS = 1 WHERE CAT_CL_CODIGO = ?", Array As String(c.GetString("cuenta")))
|
||||||
|
MsgboxAsync("Datos guardados","Atención")
|
||||||
|
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
d = Starter.skmt.ExecQuery("SELECT CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO FROM HIST_PREGUNTAS")
|
||||||
|
e = Starter.skmt.ExecQuery("SELECT RUTA FROM CARGA")
|
||||||
|
e.Position = 0
|
||||||
|
Log("estoy aqui")
|
||||||
|
For i = 0 To d.RowCount - 1
|
||||||
|
d.Position = i
|
||||||
|
Log("estoy aqui 2")
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "delete_hist_promotoria_INTMEX"
|
||||||
|
cmd.Parameters = Array As Object(Starter.almacen, e.GetString("RUTA"),B4XPages.MainPage.user,d.GetString("CLIENTE"),d.GetString("CATEGORIA"))
|
||||||
|
B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "delete")
|
||||||
|
Next
|
||||||
|
|
||||||
|
c.Close
|
||||||
|
d.Close
|
||||||
|
e.Close
|
||||||
|
|
||||||
|
timer2.Initialize("Timerconteo",20000)
|
||||||
|
timer2.Enabled = True
|
||||||
|
|
||||||
|
Timerconteo2_tick
|
||||||
|
guardado
|
||||||
|
B4XPages.ShowPage ("principal")
|
||||||
|
|
||||||
|
Else If result = DialogResponse.NEGATIVE Then
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de la Categoria PC", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de la Categoria Foods", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de Abasto", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de Innovacion", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de Cabecera", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de Exhibicion adicional", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de Presencia Anaquel", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos de Catalogo", "Atención")
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgboxAsync("Completa todos los campos del Planograma", "Atención")
|
||||||
|
End If
|
||||||
|
teclado.HideKeyboard
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
|
||||||
|
paneltop.Top = NewHeight - paneltop.Height
|
||||||
|
ScrollView1.Height = paneltop.Top - ScrollView1.Top
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||||
|
|
||||||
|
If p_camara.Visible = True Then
|
||||||
|
p_camara.Visible = False
|
||||||
|
StopCamera2
|
||||||
|
Else
|
||||||
|
B4XPages.ShowPage("principal")
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Return True
|
||||||
|
Return False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub guardado
|
||||||
|
RadioButton1.Checked = False
|
||||||
|
RadioButton2.Checked = False
|
||||||
|
RadioButton3.Checked = False
|
||||||
|
RadioButton4.Checked = False
|
||||||
|
RadioButton5.Checked = False
|
||||||
|
RadioButton6.Checked = False
|
||||||
|
RadioButton7.Checked = False
|
||||||
|
RadioButton8.Checked = False
|
||||||
|
RadioButton9.Checked = False
|
||||||
|
RadioButton10.Checked = False
|
||||||
|
RadioButton11.Checked = False
|
||||||
|
RadioButton12.Checked = False
|
||||||
|
RadioButton13.Checked = False
|
||||||
|
RadioButton14.Checked = False
|
||||||
|
RadioButton15.Checked = False
|
||||||
|
RadioButton16.Checked = False
|
||||||
|
RadioButton17.Checked = False
|
||||||
|
RadioButton18.Checked = False
|
||||||
|
EditText1.Text = ""
|
||||||
|
EditText2.Text = ""
|
||||||
|
EditText3.Text = ""
|
||||||
|
EditText4.Text = ""
|
||||||
|
EditText5.Text = ""
|
||||||
|
EditText6.Text = ""
|
||||||
|
EditText7.Text = ""
|
||||||
|
EditText8.Text = ""
|
||||||
|
EditText9.Text = ""
|
||||||
|
ImageView1.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView2.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView3.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView4.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView5.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView6.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView7.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView8.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
ImageView9.Bitmap = LoadBitmap(File.DirAssets,"camara1.png")
|
||||||
|
nombrefoto = 0
|
||||||
|
nombrefoto1 = 0
|
||||||
|
nombrefoto2 = 0
|
||||||
|
nombrefoto3 = 0
|
||||||
|
nombrefoto4 = 0
|
||||||
|
nombrefoto5 = 0
|
||||||
|
nombrefoto6 = 0
|
||||||
|
nombrefoto7 = 0
|
||||||
|
nombrefoto8 = 0
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Timerconteo_tick
|
||||||
|
Dim fotox() As Byte
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
c = Starter.skmt.ExecQuery("SELECT cuenta, latitud, longitud FROM CUENTAA")
|
||||||
|
d = Starter.skmt.ExecQuery("SELECT CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO FROM HIST_PREGUNTAS")
|
||||||
|
e = Starter.skmt.ExecQuery("SELECT RUTA FROM CARGA")
|
||||||
|
c.Position = 0
|
||||||
|
e.Position = 0
|
||||||
|
Dim Dirp As String = File.DirInternal
|
||||||
|
Dim Dir As String
|
||||||
|
Dim Dir2 As String
|
||||||
|
Dir = "/promotoriakmts"
|
||||||
|
Dir2 = "/reduccion"
|
||||||
|
|
||||||
|
For i = 0 To d.RowCount - 1
|
||||||
|
d.Position = i
|
||||||
|
Log(File.Exists(Dirp&Dir&Dir2,d.GetString("NOMBRE_FOTO")))
|
||||||
|
fotox = Bit.InputStreamToBytes(File.OpenInput(Dirp&Dir&Dir2,d.GetString("NOMBRE_FOTO")))
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "insert_promotoria_INTMEX"
|
||||||
|
cmd.Parameters = Array As Object(Starter.almacen, e.GetString("RUTA"),B4XPages.MainPage.user,d.GetString("CLIENTE"),d.GetString("CATEGORIA"),d.GetString("PREGUNTA1"),d.GetString("COMENTARIOS"),fotox,c.GetString("latitud"),c.GetString("longitud"),c.GetString("lalitud"),c.GetString("longitud"))
|
||||||
|
B4XPages.MainPage.reqManager.ExecuteCommand(cmd, $"insert_promotoria_${d.GetString("CLIENTE")}_${d.GetString("CATEGORIA")}"$)
|
||||||
|
Next
|
||||||
|
|
||||||
|
c.Close
|
||||||
|
d.Close
|
||||||
|
e.Close
|
||||||
|
timer.Enabled = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Timerconteo2_tick
|
||||||
|
Dim fotox() As Byte
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
c = Starter.skmt.ExecQuery("SELECT cuenta, latitud, longitud FROM CUENTAA")
|
||||||
|
d = Starter.skmt.ExecQuery("SELECT CLIENTE, CATEGORIA, PREGUNTA1, COMENTARIOS, NOMBRE_FOTO FROM HIST_PREGUNTAS")
|
||||||
|
e = Starter.skmt.ExecQuery("SELECT RUTA FROM CARGA")
|
||||||
|
c.Position = 0
|
||||||
|
e.Position = 0
|
||||||
|
Dim Dirp As String = File.DirInternal
|
||||||
|
Dim Dir As String
|
||||||
|
Dim Dir2 As String
|
||||||
|
Dir = "/promotoriakmts"
|
||||||
|
Dir2 = "/reduccion"
|
||||||
|
|
||||||
|
For i = 0 To d.RowCount - 1
|
||||||
|
d.Position = i
|
||||||
|
Log(File.Exists(Dirp&Dir&Dir2,d.GetString("NOMBRE_FOTO")))
|
||||||
|
fotox = Bit.InputStreamToBytes(File.OpenInput(Dirp&Dir&Dir2,d.GetString("NOMBRE_FOTO")))
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "insert_promotoria_INTMEX"
|
||||||
|
cmd.Parameters = Array As Object(Starter.almacen, e.GetString("RUTA"),B4XPages.MainPage.user,d.GetString("CLIENTE"),d.GetString("CATEGORIA"),d.GetString("PREGUNTA1"),d.GetString("COMENTARIOS"),fotox,c.GetString("latitud"),c.GetString("longitud"), Starter.latitud, Starter.longitud)
|
||||||
|
B4XPages.MainPage.reqManager.ExecuteCommand(cmd, $"insert_promotoria_${d.GetString("CLIENTE")}_${d.GetString("CATEGORIA")}"$)
|
||||||
|
Next
|
||||||
|
|
||||||
|
c.Close
|
||||||
|
d.Close
|
||||||
|
e.Close
|
||||||
|
timer2.Enabled = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
190
B4A/C_principal.bas
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=12.2
|
||||||
|
@EndOfDesignText@
|
||||||
|
Sub Class_Globals
|
||||||
|
Private Root As B4XView 'ignore
|
||||||
|
Private xui As XUI 'ignore
|
||||||
|
Private CustomListView1 As CustomListView
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
Private teclado As IME
|
||||||
|
Private e_ruta As EditText
|
||||||
|
Dim ALMACEN As String
|
||||||
|
Dim reqManager As DBRequestManager
|
||||||
|
Dim trabajos = 0 As Int
|
||||||
|
Private l_ruta As Label
|
||||||
|
Private p_clientes As Panel
|
||||||
|
Private nombrecliente As Label
|
||||||
|
Private numerocliente As Label
|
||||||
|
Private direccion As Label
|
||||||
|
Private p_datosclie As Panel
|
||||||
|
Dim c As Cursor
|
||||||
|
Dim d As Cursor
|
||||||
|
Dim ruta As String
|
||||||
|
Dim e As Cursor
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'You can add more parameters here.
|
||||||
|
Public Sub Initialize As Object
|
||||||
|
Return Me
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'This event will be called once, before the page becomes visible.
|
||||||
|
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||||
|
Root = Root1
|
||||||
|
Root.LoadLayout("principal")
|
||||||
|
'load the layout to Root
|
||||||
|
ALMACEN = Starter.almacen
|
||||||
|
reqManager.Initialize(Me, Starter.DBReqServer)
|
||||||
|
p_clientes.Visible = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub B4XPage_Appear
|
||||||
|
e = Starter.skmt.ExecQuery("SELECT USUARIO, RUTA FROM CARGA WHERE CARGADO = 1")
|
||||||
|
e.Position = 0
|
||||||
|
If e.RowCount = 1 Then
|
||||||
|
l_ruta.Text = e.GetString("RUTA")
|
||||||
|
p_clientes.Visible = True
|
||||||
|
c=Starter.skmt.ExecQuery("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from DATOS_CLIENTE WHERE ESTATUS = '0' ORDER BY CAT_CL_CODIGO ")
|
||||||
|
CustomListView1.Clear
|
||||||
|
For i = 0 To c.RowCount - 1
|
||||||
|
c.Position = i
|
||||||
|
CustomListView1.Add(CreateListItem(c.GetString("CAT_CL_NOMBRE"),c.GetString("CAT_CL_CALLE"),c.GetString("CAT_CL_CODIGO")),i)
|
||||||
|
Next
|
||||||
|
c.Close
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
|
Private Sub b_carga_Click
|
||||||
|
trabajos = 0
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "select_cat_clientes_INTMEXP"
|
||||||
|
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "kmt_datos")
|
||||||
|
trabajos = trabajos + 1
|
||||||
|
ProgressDialogShow ("Cargando")
|
||||||
|
Log(Starter.latitud & " " & Starter.longitud)
|
||||||
|
teclado.HideKeyboard
|
||||||
|
ruta = e_ruta.Text
|
||||||
|
l_ruta.Text = ruta
|
||||||
|
e_ruta.Text = ""
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub CreateListItem(mostrar As String, mostrar1 As String, mostrar2 As String) As Panel
|
||||||
|
Dim p As B4XView = xui.CreatePanel("")
|
||||||
|
p.SetLayoutAnimated(0, 0, 0, 1, 220)
|
||||||
|
p.LoadLayout("datos_cliente")
|
||||||
|
p.Height= 60dip
|
||||||
|
' p.Width = clv_orden.GetBase.Width
|
||||||
|
nombrecliente.Text = mostrar
|
||||||
|
direccion.Text = mostrar1
|
||||||
|
numerocliente.Text = mostrar2
|
||||||
|
p_datosclie.Tag = mostrar2
|
||||||
|
' cxc.Text = mostrar3
|
||||||
|
' Log(p.Width)
|
||||||
|
Return p
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub JobDone(Job As HttpJob)
|
||||||
|
If Job.Success = False Then
|
||||||
|
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||||
|
Else
|
||||||
|
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green)
|
||||||
|
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||||
|
|
||||||
|
If result.Tag = "kmt_datos" Then 'query tag
|
||||||
|
trabajos = trabajos - 1
|
||||||
|
Starter.skmt.ExecNonQuery("delete from DATOS_CLIENTE")
|
||||||
|
Starter.skmt.ExecNonQuery("delete from HIST_PREGUNTAS")
|
||||||
|
' Starter.skmt.ExecNonQuery("delete from CARGA")
|
||||||
|
Starter.skmt.ExecNonQuery2("UPDATE CARGA SET CARGADO = '1' WHERE USUARIO = ?", Array As Object(B4XPages.MainPage.user))
|
||||||
|
Starter.skmt.ExecNonQuery2("UPDATE CARGA SET RUTA = ? WHERE USUARIO = ?", Array As Object(ruta, B4XPages.MainPage.user))
|
||||||
|
For Each records() As Object In result.Rows
|
||||||
|
Dim CAT_CL_CODIGO As String = records(result.Columns.Get("CAT_CL_CODIGO"))
|
||||||
|
Dim CAT_CL_RUTA As String = records(result.Columns.Get("CAT_CL_RUTA"))
|
||||||
|
Dim CAT_CL_NOMBRE As String = records(result.Columns.Get("CAT_CL_NOMBRE"))
|
||||||
|
Dim CAT_CL_ATIENDE1 As String = records(result.Columns.Get("CAT_CL_ATIENDE1"))
|
||||||
|
Dim CAT_CL_ATIENTE2 As String = records(result.Columns.Get("CAT_CL_ATIENTE2"))
|
||||||
|
Dim CAT_CL_TELEFONO As String = records(result.Columns.Get("CAT_CL_TELEFONO"))
|
||||||
|
Dim CAT_CL_EMAIL As String = records(result.Columns.Get("CAT_CL_EMAIL"))
|
||||||
|
Dim CAT_CL_CALLE As String = records(result.Columns.Get("CAT_CL_CALLE"))
|
||||||
|
Dim CAT_CL_NOEXT As String = records(result.Columns.Get("CAT_CL_NOEXT"))
|
||||||
|
Dim CAT_CL_NOINT As String = records(result.Columns.Get("CAT_CL_NOINT"))
|
||||||
|
Dim CAT_CL_CALLE1 As String = records(result.Columns.Get("CAT_CL_CALLE1"))
|
||||||
|
Dim CAT_CL_CALLE2 As String = records(result.Columns.Get("CAT_CL_CALLE2"))
|
||||||
|
Dim CAT_CL_COLONIA As String = records(result.Columns.Get("CAT_CL_COLONIA"))
|
||||||
|
Dim CAT_CL_MUNI As String = records(result.Columns.Get("CAT_CL_MUNI"))
|
||||||
|
Dim CAT_CL_EDO As String = records(result.Columns.Get("CAT_CL_EDO"))
|
||||||
|
Dim CAT_CL_CP As String = records(result.Columns.Get("CAT_CL_CP"))
|
||||||
|
Dim CAT_CL_LONG As String = records(result.Columns.Get("CAT_CL_LONG"))
|
||||||
|
Dim CAT_CL_LAT As String = records(result.Columns.Get("CAT_CL_LAT"))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO DATOS_CLIENTE(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT, ESTATUS) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object (CAT_CL_CODIGO, CAT_CL_RUTA, CAT_CL_NOMBRE, CAT_CL_ATIENDE1, CAT_CL_ATIENTE2, CAT_CL_TELEFONO, CAT_CL_EMAIL, CAT_CL_CALLE, CAT_CL_NOEXT, CAT_CL_NOINT, CAT_CL_CALLE1, CAT_CL_CALLE2, CAT_CL_COLONIA, CAT_CL_MUNI, CAT_CL_EDO, CAT_CL_CP, CAT_CL_LONG, CAT_CL_LAT,"0"))
|
||||||
|
Next
|
||||||
|
p_clientes.Visible = True
|
||||||
|
c=Starter.skmt.ExecQuery("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from DATOS_CLIENTE WHERE ESTATUS = '0' ORDER BY CAT_CL_CODIGO ")
|
||||||
|
CustomListView1.Clear
|
||||||
|
For i = 0 To c.RowCount - 1
|
||||||
|
c.Position = i
|
||||||
|
CustomListView1.Add(CreateListItem(c.GetString("CAT_CL_NOMBRE"),c.GetString("CAT_CL_CALLE"),c.GetString("CAT_CL_CODIGO")),i)
|
||||||
|
Next
|
||||||
|
c.Close
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
If trabajos = 0 Then
|
||||||
|
ProgressDialogHide
|
||||||
|
' l_ruta.Text = e_ruta.Text
|
||||||
|
' e_ruta.Text = ""
|
||||||
|
p_clientes.Visible = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub p_datosclie_Click
|
||||||
|
|
||||||
|
Dim index As Int = CustomListView1.GetItemFromView(Sender)
|
||||||
|
Dim pnl As B4XView = CustomListView1.GetPanel(index).GetView(0)
|
||||||
|
Private lb As Label = pnl.GetView(0)
|
||||||
|
Log(lb.Text)
|
||||||
|
|
||||||
|
c = Starter.skmt.ExecQuery2("SELECT cuenta FROM CUENTAA WHERE cuenta = ?", Array As String (lb.Text))
|
||||||
|
d = Starter.skmt.ExecQuery("SELECT asignado FROM CUENTAA")
|
||||||
|
c.Position = 0
|
||||||
|
d.position = 0
|
||||||
|
|
||||||
|
If d.rowcount = 0 Then
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?,?,?,?)", Array As Object(lb.Text,1,Starter.latitud,Starter.longitud))
|
||||||
|
B4XPages.ShowPage ("cliente")
|
||||||
|
Log(Starter.latitud & Starter.longitud)
|
||||||
|
Log("1")
|
||||||
|
Else if c.RowCount = 0 And d.GetString("asignado") = 0 Then
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CUENTAA")
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?,?,?,?)", Array As Object(lb.Text,1,Starter.latitud,Starter.longitud))
|
||||||
|
B4XPages.ShowPage ("cliente")
|
||||||
|
Log(Starter.latitud & Starter.longitud)
|
||||||
|
Log("2")
|
||||||
|
Else if c.RowCount = 0 And d.GetString("asignado") = "1" Then
|
||||||
|
MsgboxAsync("Tienes que hacer check out del cliente anterior","Atención")
|
||||||
|
Log("3")
|
||||||
|
Else if c.RowCount = 1 And d.GetString("asignado") = "1" Then
|
||||||
|
B4XPages.ShowPage ("cliente")
|
||||||
|
Log("4")
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
c.Close
|
||||||
|
d.Close
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
399
B4A/CameraExClass2.bas
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=6
|
||||||
|
@EndOfDesignText@
|
||||||
|
'Class module
|
||||||
|
'version 1.30
|
||||||
|
'See this page for the list of constants:
|
||||||
|
'http://developer.android.com/intl/fr/reference/android/hardware/Camera.Parameters.html
|
||||||
|
'Note that you should use the constant values instead of the names.
|
||||||
|
Sub Class_Globals
|
||||||
|
Private nativeCam As Object
|
||||||
|
Private cam As Camera
|
||||||
|
Private r As Reflector
|
||||||
|
Private target As Object
|
||||||
|
Private event As String
|
||||||
|
Public Front As Boolean
|
||||||
|
Private parameters As Object
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Initialize (Panel1 As Panel, FrontCamera As Boolean, TargetModule As Object, EventName As String)
|
||||||
|
target = TargetModule
|
||||||
|
event = EventName
|
||||||
|
Front = FrontCamera
|
||||||
|
Dim id As Int
|
||||||
|
id = FindCamera(Front).id
|
||||||
|
If id = -1 Then
|
||||||
|
Front = Not(Front) 'try different camera
|
||||||
|
id = FindCamera(Front).id
|
||||||
|
If id = -1 Then
|
||||||
|
ToastMessageShow("No camera found.", True)
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
cam.Initialize2(Panel1, "camera", id)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub FindCamera (frontCamera As Boolean) As CameraInfoAndId
|
||||||
|
Dim ci As CameraInfoAndId
|
||||||
|
Dim cameraInfo As Object
|
||||||
|
Dim cameraValue As Int
|
||||||
|
Log("findCamera")
|
||||||
|
If frontCamera Then cameraValue = 1 Else cameraValue = 0
|
||||||
|
cameraInfo = r.CreateObject("android.hardware.Camera$CameraInfo")
|
||||||
|
Dim numberOfCameras As Int = r.RunStaticMethod("android.hardware.Camera", "getNumberOfCameras", Null, Null)
|
||||||
|
Log(r.target)
|
||||||
|
Log(numberOfCameras)
|
||||||
|
For i = 0 To numberOfCameras - 1
|
||||||
|
r.RunStaticMethod("android.hardware.Camera", "getCameraInfo", Array As Object(i, cameraInfo), _
|
||||||
|
Array As String("java.lang.int", "android.hardware.Camera$CameraInfo"))
|
||||||
|
r.target = cameraInfo
|
||||||
|
Log("facing: " & r.GetField("facing") & ", " & cameraValue)
|
||||||
|
If r.GetField("facing") = cameraValue Then
|
||||||
|
ci.cameraInfo = r.target
|
||||||
|
ci.Id = i
|
||||||
|
Return ci
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
ci.id = -1
|
||||||
|
Return ci
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub SetDisplayOrientation
|
||||||
|
r.target = r.GetActivity
|
||||||
|
r.target = r.RunMethod("getWindowManager")
|
||||||
|
r.target = r.RunMethod("getDefaultDisplay")
|
||||||
|
r.target = r.RunMethod("getRotation")
|
||||||
|
Dim previewResult, result, degrees As Int = r.target * 90
|
||||||
|
Dim ci As CameraInfoAndId = FindCamera(Front)
|
||||||
|
r.target = ci.CameraInfo
|
||||||
|
Dim orientation As Int = r.GetField("orientation")
|
||||||
|
If Front Then
|
||||||
|
previewResult = (orientation + degrees) Mod 360
|
||||||
|
result = previewResult
|
||||||
|
previewResult = (360 - previewResult) Mod 360
|
||||||
|
Else
|
||||||
|
previewResult = (orientation - degrees + 360) Mod 360
|
||||||
|
result = previewResult
|
||||||
|
Log(previewResult)
|
||||||
|
End If
|
||||||
|
r.target = nativeCam
|
||||||
|
r.RunMethod2("setDisplayOrientation", previewResult, "java.lang.int")
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod2("setRotation", result, "java.lang.int")
|
||||||
|
CommitParameters
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Camera_Ready (Success As Boolean)
|
||||||
|
If Success Then
|
||||||
|
r.target = cam
|
||||||
|
nativeCam = r.GetField("camera")
|
||||||
|
r.target = nativeCam
|
||||||
|
parameters = r.RunMethod("getParameters")
|
||||||
|
SetDisplayOrientation
|
||||||
|
Else
|
||||||
|
Log("success = false, " & LastException)
|
||||||
|
End If
|
||||||
|
CallSub2(target, event & "_ready", Success)
|
||||||
|
End Sub
|
||||||
|
'Uncomment this sub if you need to handle the Preview event
|
||||||
|
'Sub Camera_Preview (Data() As Byte)
|
||||||
|
' If SubExists(target, event & "_preview") Then
|
||||||
|
' CallSub2(target, event & "_preview", Data)
|
||||||
|
' End If
|
||||||
|
'End Sub
|
||||||
|
|
||||||
|
Public Sub TakePicture
|
||||||
|
cam.TakePicture
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Camera_PictureTaken (Data() As Byte)
|
||||||
|
CallSub2(target, event & "_PictureTaken", Data)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub StartPreview
|
||||||
|
cam.StartPreview
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub StopPreview
|
||||||
|
cam.StopPreview
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Release
|
||||||
|
cam.Release
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Saves the data received from PictureTaken event
|
||||||
|
Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String)
|
||||||
|
Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)
|
||||||
|
out.WriteBytes(Data, 0, Data.Length)
|
||||||
|
out.Close
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetParameter(Key As String, Value As String)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod3("set", Key, "java.lang.String", Value, "java.lang.String")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetParameter(Key As String) As String
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod2("get", Key, "java.lang.String")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub CommitParameters
|
||||||
|
'Try
|
||||||
|
r.target = nativeCam
|
||||||
|
r.RunMethod4("setParameters", Array As Object(parameters), Array As String("android.hardware.Camera$Parameters"))
|
||||||
|
'Catch
|
||||||
|
' ToastMessageShow("Error setting parameters.", True)
|
||||||
|
' Log(LastException)
|
||||||
|
' End Try
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetColorEffect As String
|
||||||
|
Return GetParameter("effect")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetColorEffect(Effect As String)
|
||||||
|
SetParameter("effect", Effect)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetSupportedPreviewSizes As CameraSize()
|
||||||
|
r.target = parameters
|
||||||
|
Dim list1 As List = r.RunMethod("getSupportedPreviewSizes")
|
||||||
|
Dim cs(list1.Size) As CameraSize
|
||||||
|
For i = 0 To list1.Size - 1
|
||||||
|
r.target = list1.get(i)
|
||||||
|
cs(i).Width = r.GetField("width")
|
||||||
|
cs(i).Height = r.GetField("height")
|
||||||
|
Next
|
||||||
|
Return cs
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetPreviewSize(Width As Int, Height As Int)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod3("setPreviewSize", Width, "java.lang.int", Height, "java.lang.int")
|
||||||
|
End Sub
|
||||||
|
Public Sub GetSupportedPicturesSizes As CameraSize()
|
||||||
|
r.target = parameters
|
||||||
|
Dim list1 As List = r.RunMethod("getSupportedPictureSizes")
|
||||||
|
Dim cs(list1.Size) As CameraSize
|
||||||
|
For i = 0 To list1.Size - 1
|
||||||
|
r.target = list1.get(i)
|
||||||
|
cs(i).Width = r.GetField("width")
|
||||||
|
cs(i).Height = r.GetField("height")
|
||||||
|
Next
|
||||||
|
Return cs
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetPictureSize(Width As Int, Height As Int)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod3("setPictureSize", Width, "java.lang.int", Height, "java.lang.int")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetJpegQuality(Quality As Int)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod2("setJpegQuality", Quality, "java.lang.int")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetFlashMode(Mode As String)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod2("setFlashMode", Mode, "java.lang.String")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetFlashMode As String
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getFlashMode")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetSupportedFlashModes As List
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getSupportedFlashModes")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetSupportedColorEffects As List
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getSupportedColorEffects")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Returns a list with the supported preview fps. Each item in the list is an array of two ints (minimum value and maximum value).
|
||||||
|
Public Sub GetSupportedPreviewFpsRange As List
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getSupportedPreviewFpsRange")
|
||||||
|
End Sub
|
||||||
|
'Returns the current preview fps range.
|
||||||
|
'Range is a two elements array. The minimum value and maximum value will be stored in this array.
|
||||||
|
Public Sub GetPreviewFpsRange(Range() As Int)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod4("getPreviewFpsRange", Array As Object(Range), Array As String("[I"))
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetPreviewFpsRange(MinValue As Int, MaxValue As Int)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod4("setPreviewFpsRange", Array As Object(MinValue, MaxValue), _
|
||||||
|
Array As String("java.lang.int", "java.lang.int"))
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetPreviewSize As CameraSize
|
||||||
|
r.target = parameters
|
||||||
|
r.target = r.RunMethod("getPreviewSize")
|
||||||
|
Dim cs As CameraSize
|
||||||
|
cs.Width = r.GetField("width")
|
||||||
|
cs.Height = r.GetField("height")
|
||||||
|
Return cs
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetPictureSize As CameraSize
|
||||||
|
r.target = parameters
|
||||||
|
r.target = r.RunMethod("getPictureSize")
|
||||||
|
Dim cs As CameraSize
|
||||||
|
cs.Width = r.GetField("width")
|
||||||
|
cs.Height = r.GetField("height")
|
||||||
|
Return cs
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Converts a preview image formatted in YUV format to JPEG.
|
||||||
|
'Note that you should not save every preview image as it will slow down the whole process.
|
||||||
|
Public Sub PreviewImageToJpeg(data() As Byte, quality As Int) As Byte()
|
||||||
|
Dim size, previewFormat As Object
|
||||||
|
r.target = parameters
|
||||||
|
size = r.RunMethod("getPreviewSize")
|
||||||
|
previewFormat = r.RunMethod("getPreviewFormat")
|
||||||
|
r.target = size
|
||||||
|
Dim width = r.GetField("width"), height = r.GetField("height") As Int
|
||||||
|
Dim yuvImage As Object = r.CreateObject2("android.graphics.YuvImage", _
|
||||||
|
Array As Object(data, previewFormat, width, height, Null), _
|
||||||
|
Array As String("[B", "java.lang.int", "java.lang.int", "java.lang.int", "[I"))
|
||||||
|
r.target = yuvImage
|
||||||
|
Dim rect1 As Rect
|
||||||
|
rect1.Initialize(0, 0, r.RunMethod("getWidth"), r.RunMethod("getHeight"))
|
||||||
|
Dim out As OutputStream
|
||||||
|
out.InitializeToBytesArray(100)
|
||||||
|
r.RunMethod4("compressToJpeg", Array As Object(rect1, quality, out), _
|
||||||
|
Array As String("android.graphics.Rect", "java.lang.int", "java.io.OutputStream"))
|
||||||
|
Return out.ToBytesArray
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetSupportedFocusModes As List
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getSupportedFocusModes")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetContinuousAutoFocus
|
||||||
|
Dim modes As List = GetSupportedFocusModes
|
||||||
|
If modes.IndexOf("continuous-picture") > -1 Then
|
||||||
|
SetFocusMode("continuous-picture")
|
||||||
|
Else If modes.IndexOf("continuous-video") > -1 Then
|
||||||
|
SetFocusMode("continuous-video")
|
||||||
|
Else
|
||||||
|
Log("Continuous focus mode is not available")
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetFocusMode(Mode As String)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod2("setFocusMode", Mode, "java.lang.String")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetFocusDistances As Float()
|
||||||
|
Dim F(3) As Float
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod4("getFocusDistances", Array As Object(F), Array As String("[F"))
|
||||||
|
Return F
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetSupportedPictureFormats As List
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getSupportedPictureFormats")
|
||||||
|
End Sub
|
||||||
|
'This method should only be called if you need to immediately release the camera.
|
||||||
|
'For example if you need to start another application that depends on the camera.
|
||||||
|
Public Sub CloseNow
|
||||||
|
cam.Release
|
||||||
|
r.target = cam
|
||||||
|
r.RunMethod2("releaseCameras", True, "java.lang.boolean")
|
||||||
|
End Sub
|
||||||
|
'Calls AutoFocus and then takes the picture if focus was successfull.
|
||||||
|
Public Sub FocusAndTakePicture
|
||||||
|
cam.AutoFocus
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub Camera_FocusDone (Success As Boolean)
|
||||||
|
If Success Then
|
||||||
|
TakePicture
|
||||||
|
Else
|
||||||
|
Log("AutoFocus error.")
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub IsZoomSupported As Boolean
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("isZoomSupported")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub GetMaxZoom As Int
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getMaxZoom")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub getZoom() As Int
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getZoom")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub setZoom(ZoomValue As Int)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod2("setZoom", ZoomValue, "java.lang.int")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub getExposureCompensation As Int
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getExposureCompensation")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub setExposureCompensation(v As Int)
|
||||||
|
r.target = parameters
|
||||||
|
r.RunMethod2("setExposureCompensation", v, "java.lang.int")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub getMinExposureCompensation As Int
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getMinExposureCompensation")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub getMaxExposureCompensation As Int
|
||||||
|
r.target = parameters
|
||||||
|
Return r.RunMethod("getMaxExposureCompensation")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub SetFaceDetectionListener
|
||||||
|
Dim jo As JavaObject = nativeCam
|
||||||
|
Dim e As Object = jo.CreateEvent("android.hardware.Camera.FaceDetectionListener", "FaceDetection", Null)
|
||||||
|
jo.RunMethod("setFaceDetectionListener", Array(e))
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub FaceDetection_Event (MethodName As String, Args() As Object) As Object
|
||||||
|
Dim faces() As Object = Args(0)
|
||||||
|
For Each f As Object In faces
|
||||||
|
Dim jo As JavaObject = f
|
||||||
|
Dim faceRect As Rect = jo.GetField("rect")
|
||||||
|
Log(faceRect)
|
||||||
|
Next
|
||||||
|
Return Null
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Public Sub StartFaceDetection
|
||||||
|
Dim jo As JavaObject = nativeCam
|
||||||
|
jo.RunMethod("startFaceDetection", Null)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub StopFaceDetection
|
||||||
|
Dim jo As JavaObject = nativeCam
|
||||||
|
jo.RunMethod("stopFaceDetection", Null)
|
||||||
|
End Sub
|
||||||
|
|
||||||
272
B4A/DBRequestManager.bas
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=6.8
|
||||||
|
@EndOfDesignText@
|
||||||
|
''Class module
|
||||||
|
|
||||||
|
'' Requiere accesRandom File y requiere compressStrings, byte converter y okhhtputuils2
|
||||||
|
Sub Class_Globals
|
||||||
|
Private mTarget As Object
|
||||||
|
Type DBResult (Tag As Object, Columns As Map, Rows As List)
|
||||||
|
Type DBCommand (Name As String, Parameters() As Object)
|
||||||
|
Private link As String
|
||||||
|
Private bc As ByteConverter
|
||||||
|
Private T_NULL = 0, T_STRING = 1, T_SHORT = 2, T_INT = 3, T_LONG = 4, T_FLOAT = 5 _
|
||||||
|
,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
|
||||||
|
Private VERSION As Float = 0.9
|
||||||
|
Private tempArray(1) As Object
|
||||||
|
Dim jobTagAnterior As String = "" 'Mod por CHV - 211109
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Target - The module that handles JobDone (usually Me).
|
||||||
|
'ConnectorLink - URL of the Java server.
|
||||||
|
Public Sub Initialize (Target As Object, ConnectorLink As String)
|
||||||
|
mTarget = Target
|
||||||
|
link = ConnectorLink
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Sends a query request.
|
||||||
|
'Command - Query name and parameters.
|
||||||
|
'Limit - Maximum rows to return or 0 for no limit.
|
||||||
|
'Tag - An object that will be returned in the result.
|
||||||
|
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
|
||||||
|
Dim j As HttpJob
|
||||||
|
Dim ms As OutputStream
|
||||||
|
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||||
|
|
||||||
|
WriteObject(Command.Name, out2)
|
||||||
|
WriteInt(Limit, out2)
|
||||||
|
WriteList(Command.Parameters, out2)
|
||||||
|
out2.Close
|
||||||
|
j.PostBytes(link & "?method=query", ms.ToBytesArray)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Executes a batch of (non-select) commands.
|
||||||
|
'ListOfCommands - List of the commands that will be executes.
|
||||||
|
'Tag - An object that will be returned in the result.
|
||||||
|
Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
|
||||||
|
Dim j As HttpJob
|
||||||
|
Dim ms As OutputStream
|
||||||
|
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||||
|
WriteInt(ListOfCommands.Size, out2)
|
||||||
|
For Each Command As DBCommand In ListOfCommands
|
||||||
|
WriteObject(Command.Name, out2)
|
||||||
|
WriteList(Command.Parameters, out2)
|
||||||
|
Next
|
||||||
|
out2.Close
|
||||||
|
j.PostBytes(link & "?method=batch", ms.ToBytesArray)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Similar to ExecuteBatch. Sends a single command.
|
||||||
|
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
|
||||||
|
ExecuteBatch(Array As DBCommand(Command), Tag)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub StartJob(j As HttpJob, MemoryStream As OutputStream, Tag As Object) As OutputStream
|
||||||
|
j.Initialize("DBRequest", mTarget)
|
||||||
|
j.Tag = Tag
|
||||||
|
MemoryStream.InitializeToBytesArray(0)
|
||||||
|
Dim compress As CompressedStreams
|
||||||
|
Dim out As OutputStream = compress.WrapOutputStream(MemoryStream, "gzip")
|
||||||
|
WriteObject(VERSION, out)
|
||||||
|
Return out
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub WriteList(Parameters As List, out As OutputStream)
|
||||||
|
Dim data() As Byte
|
||||||
|
If Parameters = Null Or Parameters.IsInitialized = False Then
|
||||||
|
Dim Parameters As List
|
||||||
|
Parameters.Initialize
|
||||||
|
End If
|
||||||
|
data = bc.IntsToBytes(Array As Int(Parameters.Size))
|
||||||
|
out.WriteBytes(data, 0, data.Length)
|
||||||
|
For Each o As Object In Parameters
|
||||||
|
WriteObject(o, out)
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub WriteObject(o As Object, out As OutputStream)
|
||||||
|
Dim data() As Byte
|
||||||
|
tempArray(0) = o
|
||||||
|
If tempArray(0) = Null Then
|
||||||
|
out.WriteBytes(Array As Byte(T_NULL), 0, 1)
|
||||||
|
Else If tempArray(0) Is Short Then
|
||||||
|
out.WriteBytes(Array As Byte(T_SHORT), 0, 1)
|
||||||
|
data = bc.ShortsToBytes(Array As Short(o))
|
||||||
|
Else If tempArray(0) Is Int Then
|
||||||
|
out.WriteBytes(Array As Byte(T_INT), 0, 1)
|
||||||
|
data = bc.IntsToBytes(Array As Int(o))
|
||||||
|
Else If tempArray(0) Is Float Then
|
||||||
|
out.WriteBytes(Array As Byte(T_FLOAT), 0, 1)
|
||||||
|
data = bc.FloatsToBytes(Array As Float(o))
|
||||||
|
Else If tempArray(0) Is Double Then
|
||||||
|
out.WriteBytes(Array As Byte(T_DOUBLE), 0, 1)
|
||||||
|
data = bc.DoublesToBytes(Array As Double(o))
|
||||||
|
Else If tempArray(0) Is Long Then
|
||||||
|
out.WriteBytes(Array As Byte(T_LONG), 0, 1)
|
||||||
|
data = bc.LongsToBytes(Array As Long(o))
|
||||||
|
Else If tempArray(0) Is Boolean Then
|
||||||
|
out.WriteBytes(Array As Byte(T_BOOLEAN), 0, 1)
|
||||||
|
Dim b As Boolean = 0
|
||||||
|
Dim data(1) As Byte
|
||||||
|
If b Then data(0) = 1 Else data(0) = 0
|
||||||
|
Else If GetType(tempArray(0)) = "[B" Then
|
||||||
|
data = o
|
||||||
|
out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
|
||||||
|
WriteInt(data.Length, out)
|
||||||
|
Else 'If o Is String Then (treat all other values as string)
|
||||||
|
out.WriteBytes(Array As Byte(T_STRING), 0, 1)
|
||||||
|
data = bc.StringToBytes(o, "UTF8")
|
||||||
|
WriteInt(data.Length, out)
|
||||||
|
End If
|
||||||
|
If data.Length > 0 Then out.WriteBytes(data, 0, data.Length)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ReadObject(In As InputStream) As Object
|
||||||
|
Dim data(1) As Byte
|
||||||
|
In.ReadBytes(data, 0, 1)
|
||||||
|
Select data(0)
|
||||||
|
Case T_NULL
|
||||||
|
Return Null
|
||||||
|
Case T_SHORT
|
||||||
|
Dim data(2) As Byte
|
||||||
|
Return bc.ShortsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||||
|
Case T_INT
|
||||||
|
Dim data(4) As Byte
|
||||||
|
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||||
|
Case T_LONG
|
||||||
|
Dim data(8) As Byte
|
||||||
|
Return bc.LongsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||||
|
Case T_FLOAT
|
||||||
|
Dim data(4) As Byte
|
||||||
|
Return bc.FloatsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||||
|
Case T_DOUBLE
|
||||||
|
Dim data(8) As Byte
|
||||||
|
Return bc.DoublesFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||||
|
Case T_BOOLEAN
|
||||||
|
Dim b As Byte = ReadByte(In)
|
||||||
|
Return b = 1
|
||||||
|
Case T_BLOB
|
||||||
|
Dim len As Int = ReadInt(In)
|
||||||
|
Dim data(len) As Byte
|
||||||
|
Return ReadBytesFully(In, data, data.Length)
|
||||||
|
Case Else
|
||||||
|
Dim len As Int = ReadInt(In)
|
||||||
|
Dim data(len) As Byte
|
||||||
|
ReadBytesFully(In, data, data.Length)
|
||||||
|
Return BytesToString(data, 0, data.Length, "UTF8")
|
||||||
|
End Select
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ReadBytesFully(In As InputStream, Data() As Byte, Len As Int) As Byte()
|
||||||
|
Dim count = 0, read As Int
|
||||||
|
Do While count < Len And read > -1
|
||||||
|
read = In.ReadBytes(Data, count, Len - count)
|
||||||
|
count = count + read
|
||||||
|
Loop
|
||||||
|
Return Data
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub WriteInt(i As Int, out As OutputStream)
|
||||||
|
Dim data() As Byte
|
||||||
|
data = bc.IntsToBytes(Array As Int(i))
|
||||||
|
out.WriteBytes(data, 0, data.Length)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ReadInt(In As InputStream) As Int
|
||||||
|
Dim data(4) As Byte
|
||||||
|
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub ReadByte(In As InputStream) As Byte
|
||||||
|
Dim data(1) As Byte
|
||||||
|
In.ReadBytes(data, 0, 1)
|
||||||
|
Return data(0)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Handles the Job result and returns a DBResult.
|
||||||
|
Public Sub HandleJob(Job As HttpJob) As DBResult
|
||||||
|
Dim start As Long = DateTime.Now 'ignore
|
||||||
|
Dim In As InputStream = Job.GetInputStream
|
||||||
|
Dim cs As CompressedStreams
|
||||||
|
In = cs.WrapInputStream(In, "gzip")
|
||||||
|
Dim serverVersion As Float = ReadObject(In) 'ignore
|
||||||
|
Dim method As String = ReadObject(In)
|
||||||
|
Dim table As DBResult
|
||||||
|
table.Initialize
|
||||||
|
table.Columns.Initialize
|
||||||
|
table.rows.Initialize
|
||||||
|
table.Tag = Job.Tag
|
||||||
|
If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211109
|
||||||
|
jobTagAnterior = Job.Tag 'Mod por CHV - 211109
|
||||||
|
If method = "query" Then
|
||||||
|
Dim numberOfColumns As Int = ReadInt(In)
|
||||||
|
For i = 0 To numberOfColumns - 1
|
||||||
|
table.Columns.Put(ReadObject(In), i)
|
||||||
|
Next
|
||||||
|
Do While ReadByte(In) = 1
|
||||||
|
Dim rowObjects(numberOfColumns) As Object
|
||||||
|
table.rows.Add(rowObjects)
|
||||||
|
For col = 0 To numberOfColumns - 1
|
||||||
|
Dim o As Object = ReadObject(In)
|
||||||
|
rowObjects(col) = o
|
||||||
|
Next
|
||||||
|
Loop
|
||||||
|
Else If method = "batch" Then
|
||||||
|
table.Columns.Put("AffectedRows", 0)
|
||||||
|
Dim rows As Int = ReadInt(In)
|
||||||
|
For i = 0 To rows - 1
|
||||||
|
table.rows.Add(Array As Object(ReadInt(In)))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
In.Close
|
||||||
|
' Log("HandleJob: " & (DateTime.Now - start))'Comentado por CHV - 211112
|
||||||
|
Return table
|
||||||
|
End Sub
|
||||||
|
'Reads a file and returns the file as a bytes array.
|
||||||
|
Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
|
||||||
|
Dim out As OutputStream
|
||||||
|
out.InitializeToBytesArray(0)
|
||||||
|
Dim In As InputStream = File.OpenInput(Dir, FileName)
|
||||||
|
File.Copy2(In, out)
|
||||||
|
out.Close
|
||||||
|
Return out.ToBytesArray
|
||||||
|
End Sub
|
||||||
|
'Converts an image to a bytes array (for BLOB fields).
|
||||||
|
Public Sub ImageToBytes(Image As Bitmap) As Byte()
|
||||||
|
Dim out As OutputStream
|
||||||
|
out.InitializeToBytesArray(0)
|
||||||
|
Image.WriteToStream(out, 100, "JPEG")
|
||||||
|
out.Close
|
||||||
|
Return out.ToBytesArray
|
||||||
|
End Sub
|
||||||
|
'Converts a bytes array to an image (for BLOB fields).
|
||||||
|
Public Sub BytesToImage(bytes() As Byte) As Bitmap
|
||||||
|
Dim In As InputStream
|
||||||
|
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
|
||||||
|
Dim bmp As Bitmap
|
||||||
|
bmp.Initialize2(In)
|
||||||
|
Return bmp
|
||||||
|
End Sub
|
||||||
|
'Prints the table to the logs.
|
||||||
|
Public Sub PrintTable(Table As DBResult)
|
||||||
|
Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
|
||||||
|
Dim sb As StringBuilder
|
||||||
|
sb.Initialize
|
||||||
|
For Each col In Table.Columns.Keys
|
||||||
|
sb.Append(col).Append(TAB)
|
||||||
|
Next
|
||||||
|
Log(sb.ToString)
|
||||||
|
For Each row() As Object In Table.Rows
|
||||||
|
Dim sb As StringBuilder
|
||||||
|
sb.Initialize
|
||||||
|
For Each record As Object In row
|
||||||
|
sb.Append(record).Append(TAB)
|
||||||
|
Next
|
||||||
|
ToastMessageShow(sb.ToString, True)
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
338
B4A/Files/camara.ai
Normal file
BIN
B4A/Files/camara.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
B4A/Files/camara1.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
B4A/Files/candado.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
B4A/Files/cliente.bal
Normal file
BIN
B4A/Files/datos_cliente.bal
Normal file
BIN
B4A/Files/fondo.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
B4A/Files/icon_22-[convertido].png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
B4A/Files/kmt.db
Normal file
BIN
B4A/Files/logointmex.jpg
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
B4A/Files/mainpage.bal
Normal file
BIN
B4A/Files/p_cuest.bal
Normal file
BIN
B4A/Files/principal.bal
Normal file
BIN
B4A/Files/usuario.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
131
B4A/Intmex-Promotoria.b4a
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
Build1=Default,intmex_preenta.keymon
|
||||||
|
File1=camara.png
|
||||||
|
File10=p_cuest.bal
|
||||||
|
File11=principal.bal
|
||||||
|
File12=usuario.png
|
||||||
|
File2=camara1.png
|
||||||
|
File3=candado.png
|
||||||
|
File4=cliente.bal
|
||||||
|
File5=datos_cliente.bal
|
||||||
|
File6=fondo.png
|
||||||
|
File7=Icon_22-[Convertido].png
|
||||||
|
File8=logointmex.jpg
|
||||||
|
File9=MainPage.bal
|
||||||
|
FileGroup1=Default Group
|
||||||
|
FileGroup10=Default Group
|
||||||
|
FileGroup11=Default Group
|
||||||
|
FileGroup12=Default Group
|
||||||
|
FileGroup2=Default Group
|
||||||
|
FileGroup3=Default Group
|
||||||
|
FileGroup4=Default Group
|
||||||
|
FileGroup5=Default Group
|
||||||
|
FileGroup6=Default Group
|
||||||
|
FileGroup7=Default Group
|
||||||
|
FileGroup8=Default Group
|
||||||
|
FileGroup9=Default Group
|
||||||
|
Group=Default Group
|
||||||
|
Library1=accessibility
|
||||||
|
Library10=okhttputils2
|
||||||
|
Library11=phone
|
||||||
|
Library12=randomaccessfile
|
||||||
|
Library13=reflection
|
||||||
|
Library14=runtimepermissions
|
||||||
|
Library15=sql
|
||||||
|
Library16=stringutils
|
||||||
|
Library17=xcustomlistview
|
||||||
|
Library18=xui
|
||||||
|
Library19=xui views
|
||||||
|
Library2=b4xpages
|
||||||
|
Library20=fusedlocationprovider
|
||||||
|
Library3=bctoast
|
||||||
|
Library4=byteconverter
|
||||||
|
Library5=camera
|
||||||
|
Library6=compressstrings
|
||||||
|
Library7=core
|
||||||
|
Library8=gps
|
||||||
|
Library9=ime
|
||||||
|
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="33"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~SetServiceAttribute(Tracker, android:foregroundServiceType, "location")~\n~'SetServiceAttribute(android:requestLegacyExternalStorage, True)~\n~~\n~AddApplicationText(~\n~<meta-data~\n~ android:name="com.google.android.geo.API_KEY"~\n~ android:value="AIzaSyBlBnx3O-DncOSv3oFIp-12wgujOYYcl-U"/>~\n~ <meta-data android:name="com.google.android.gms.version"~\n~ android:value="@integer/google_play_services_version" />~\n~)~\n~~\n~AddManifestText(~\n~<uses-permission~\n~ android:name="android.permission.ACCESS_FINE_LOCATION"~\n~ android:maxSdkVersion="33" />~\n~)~\n~~\n~AddManifestText(~\n~<uses-permission ~\n~ android:name="android.permission.ACCESS_COARSE_LOCATION"~\n~ android:maxSdkVersion="33" />~\n~ )~\n~~\n~AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)~\n~~\n~AddPermission("android.permission.MANAGE_EXTERNAL_STORAGE")~\n~~\n~~\n~AddManifestText(<uses-permission~\n~android:name="android.permission.WRITE_EXTERNAL_STORAGE"~\n~android:maxSdkVersion="33" />~\n~)~\n~~\n~~\n~'End of default text.
|
||||||
|
Module1=|relative|..\B4XMainPage
|
||||||
|
Module2=C_cliente
|
||||||
|
Module3=C_principal
|
||||||
|
Module4=CameraExClass2
|
||||||
|
Module5=DBRequestManager
|
||||||
|
Module6=Starter
|
||||||
|
Module7=Subs
|
||||||
|
Module8=Tracker
|
||||||
|
NumberOfFiles=12
|
||||||
|
NumberOfLibraries=20
|
||||||
|
NumberOfModules=8
|
||||||
|
Version=11.5
|
||||||
|
@EndOfDesignText@
|
||||||
|
#Region Project Attributes
|
||||||
|
#AdditionalJar: com.android.support:support-v4
|
||||||
|
#AdditionalJar: com.google.android.gms:play-services-location
|
||||||
|
#ApplicationLabel: INTMEX Promotoria
|
||||||
|
#VersionCode: 1
|
||||||
|
#VersionName:
|
||||||
|
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||||
|
#SupportedOrientations: portrait
|
||||||
|
#CanInstallToExternalStorage: False
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
#Region Activity Attributes
|
||||||
|
#FullScreen: False
|
||||||
|
#IncludeTitle: False
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
'#BridgeLogger: True
|
||||||
|
|
||||||
|
Sub Process_Globals
|
||||||
|
Public ActionBarHomeClicked As Boolean
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Globals
|
||||||
|
Type CameraInfoAndId (CameraInfo As Object, Id As Int)
|
||||||
|
Type CameraSize (Width As Int, Height As Int)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_Create(FirstTime As Boolean)
|
||||||
|
Dim pm As B4XPagesManager
|
||||||
|
pm.Initialize(Activity)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Template version: B4A-1.01
|
||||||
|
#Region Delegates
|
||||||
|
|
||||||
|
Sub Activity_ActionBarHomeClick
|
||||||
|
ActionBarHomeClicked = True
|
||||||
|
B4XPages.Delegate.Activity_ActionBarHomeClick
|
||||||
|
ActionBarHomeClicked = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_KeyPress (KeyCode As Int) As Boolean
|
||||||
|
Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_Resume
|
||||||
|
B4XPages.Delegate.Activity_Resume
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_Pause (UserClosed As Boolean)
|
||||||
|
B4XPages.Delegate.Activity_Pause
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Create_Menu (Menu As Object)
|
||||||
|
B4XPages.Delegate.Create_Menu(Menu)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
#if Java
|
||||||
|
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
|
||||||
|
processBA.raiseEvent(null, "create_menu", menu);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
#End If
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
'Program code should go into B4XMainPage and other pages.
|
||||||
52
B4A/Starter.bas
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Service
|
||||||
|
Version=9.85
|
||||||
|
@EndOfDesignText@
|
||||||
|
#Region Service Attributes
|
||||||
|
#StartAtBoot: False
|
||||||
|
#ExcludeFromLibrary: True
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
Sub Process_Globals
|
||||||
|
'These global variables will be declared once when the application starts.
|
||||||
|
'These variables can be accessed from all modules.
|
||||||
|
Public rp As RuntimePermissions
|
||||||
|
Dim reqManager As DBRequestManager
|
||||||
|
Dim DBReqServer As String = "http://keymon.lat:1787" '"http://keymon.lat:1782" "http://10.0.0.205:1782" "http://keymon.lat:1783" "http://11.0.0.48:1783" ""' CAMBIAR HACIA AFUERA O DENTRO DE LA OFNA
|
||||||
|
' Dim server As String = "http://10.0.0.205:1782"
|
||||||
|
Dim rutaBD As String = File.DirInternal
|
||||||
|
Dim skmt As SQL
|
||||||
|
Dim almacen As String
|
||||||
|
Dim GPS As GPS
|
||||||
|
Public rp As RuntimePermissions
|
||||||
|
Public FLP As FusedLocationProvider
|
||||||
|
Private flpStarted As Boolean
|
||||||
|
Dim latitud As Double = 0
|
||||||
|
Dim longitud As Double = 0
|
||||||
|
Dim ubicacionActual As Location
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Create
|
||||||
|
'This is the program entry point.
|
||||||
|
'This is a good place to load resources that are not specific to a single activity.
|
||||||
|
GPS.Initialize("GPS")
|
||||||
|
ubicacionActual.Initialize
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Start (StartingIntent As Intent)
|
||||||
|
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||||
|
Subs.revisaBD
|
||||||
|
reqManager.Initialize(Me, DBReqServer)
|
||||||
|
If Not(skmt.IsInitialized) Then skmt.Initialize(rutaBD, "kmt.db", True)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_TaskRemoved
|
||||||
|
'This event will be raised when the user removes the app from the recent apps list.
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Destroy
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
26
B4A/Subs.bas
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=StaticCode
|
||||||
|
Version=11.5
|
||||||
|
@EndOfDesignText@
|
||||||
|
'Code module
|
||||||
|
'Subs in this code module will be accessible from all modules.
|
||||||
|
Sub Process_Globals
|
||||||
|
'These global variables will be declared once when the application starts.
|
||||||
|
'These variables can be accessed from all modules.
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Revisa que exista la BD y si es necesario crea algunas tablas dentro de ella
|
||||||
|
Sub revisaBD 'ignore
|
||||||
|
If Not(File.Exists(Starter.rutaBD, "kmt.db")) Then File.Copy(File.DirAssets, "kmt.db", Starter.rutaBD, "kmt.db")
|
||||||
|
If Not(Starter.skmt.IsInitialized) Then Starter.skmt.Initialize(Starter.rutaBD, "kmt.db", True)
|
||||||
|
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS DATOS_CLIENTE(CAT_CL_CODIGO TEXT, CAT_CL_RUTA TEXT, CAT_CL_NOMBRE TEXT, CAT_CL_ATIENDE1 TEXT, CAT_CL_ATIENTE2 TEXT, CAT_CL_TELEFONO TEXT, CAT_CL_EMAIL TEXT, CAT_CL_CALLE TEXT, CAT_CL_NOEXT TEXT, CAT_CL_NOINT TEXT, CAT_CL_CALLE1 TEXT, CAT_CL_CALLE2 TEXT, CAT_CL_COLONIA TEXT, CAT_CL_MUNI TEXT, CAT_CL_EDO TEXT, CAT_CL_CP TEXT, CAT_CL_LONG TEXT, CAT_CL_LAT TEXT, ESTATUS TEXT)")
|
||||||
|
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CUENTAA (cuenta text, asignado text, latitud text, longitud text)")
|
||||||
|
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_PREGUNTAS(CLIENTE TEXT, CATEGORIA TEXT, PREGUNTA1 TEXT, COMENTARIOS TEXT, NOMBRE_FOTO TEXT)")
|
||||||
|
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CARGA(USUARIO TEXT, CONTRASEÑA TEXT,RUTA TEXT, CARGADO TEXT)")
|
||||||
|
' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS DATOS_CLIENTE")
|
||||||
|
' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS CUENTAA")
|
||||||
|
' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS HIST_PREGUNTAS")
|
||||||
|
' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS CARGA")
|
||||||
|
End Sub
|
||||||
218
B4A/Tracker.bas
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Service
|
||||||
|
Version=11
|
||||||
|
@EndOfDesignText@
|
||||||
|
#Region Service Attributes
|
||||||
|
#StartAtBoot: True
|
||||||
|
#End Region
|
||||||
|
'******************************************************************************
|
||||||
|
'No olvidar agregar esta linea al editor de manifiesto:
|
||||||
|
' SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
|
||||||
|
'
|
||||||
|
'En Starter agregar estas lineas en Process_Globals
|
||||||
|
' Public rp As RuntimePermissions
|
||||||
|
' Public FLP As FusedLocationProvider
|
||||||
|
' Private flpStarted As Boolean
|
||||||
|
'
|
||||||
|
'En Main agregar estas lineas a Activity_Resume
|
||||||
|
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||||
|
' Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
' If Result Then
|
||||||
|
' StartService(Tracker)
|
||||||
|
' Log("Start Tracker")
|
||||||
|
' Else
|
||||||
|
' ToastMessageShow("No permission", True)
|
||||||
|
' End If
|
||||||
|
'
|
||||||
|
'Se necesitan las librerias FusedLocationProvider, GPS, Phone y RunTimePermissions
|
||||||
|
'
|
||||||
|
'Y en Main agregar estas dos lineas:
|
||||||
|
'#AdditionalJar: com.android.support:support-v4
|
||||||
|
'#AdditionalJar: com.google.android.gms:play-services-location
|
||||||
|
|
||||||
|
Sub Process_Globals
|
||||||
|
' Private nid As Int = 1
|
||||||
|
Private Tracking As Boolean
|
||||||
|
Private lock As PhoneWakeState
|
||||||
|
'Para FusedLocationProvider (2 lineas)
|
||||||
|
Public FLP As FusedLocationProvider
|
||||||
|
Dim actualLR As LocationRequest
|
||||||
|
Private flpStarted As Boolean
|
||||||
|
' Dim locRequest As String
|
||||||
|
Dim UUGCoords As Location 'Ultima Ubicacion Guardada
|
||||||
|
' Dim trackerActividad, pushServiceActividad As String
|
||||||
|
Dim logger As Boolean = true
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Create
|
||||||
|
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
|
||||||
|
UUGCoords.Initialize
|
||||||
|
logger = False
|
||||||
|
'Para FusedLocationProvider (2 lineas)
|
||||||
|
FLP.Initialize("flp")
|
||||||
|
FLP.Connect
|
||||||
|
lock.PartialLock
|
||||||
|
StartFLP
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub flp_ConnectionSuccess
|
||||||
|
' If logger Then Log("Connected to location provider")
|
||||||
|
'FLP.GetLastKnownLocation
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub flp_ConnectionFailed(ConnectionResult1 As Int)
|
||||||
|
If logger Then Log("Failed to connect to location provider")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub flp_ConnectionSuspended(ConnectionResult1 As Int)
|
||||||
|
If logger Then Log("FLP conection suspended")
|
||||||
|
StartFLP
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Start (StartingIntent As Intent)
|
||||||
|
LogColor("Iniciando Tracker ...", Colors.Green)
|
||||||
|
Service.StopAutomaticForeground
|
||||||
|
' Service.StartForeground(51042, Subs.notiLowReturn("Kelloggs", "Activo", 51042))
|
||||||
|
StartServiceAt(Me, DateTime.Now + 10 * DateTime.TicksPerMinute, True)
|
||||||
|
Track
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Track
|
||||||
|
If logger Then Log("Inicia Track - Tracking : "&Tracking)
|
||||||
|
If Tracking Then
|
||||||
|
' Log(actualLR.GetSmallestDisplacement)
|
||||||
|
Return 'Si ya estamos "rastreando" no hacemos nada (return)
|
||||||
|
End If
|
||||||
|
If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
|
||||||
|
If logger Then Log("Sin permisos de ublicación.")
|
||||||
|
Return
|
||||||
|
End If
|
||||||
|
StartFLP 'Iniciamos FusedLocationProvider
|
||||||
|
Tracking = True
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub StartFLP
|
||||||
|
If logger Then Log("StartFLP - flpStarted="&flpStarted)
|
||||||
|
Do While FLP.IsConnected = False
|
||||||
|
Sleep(500)
|
||||||
|
If logger Then Log("sleeping")
|
||||||
|
Loop
|
||||||
|
' If flpStarted = False Then
|
||||||
|
' If logger Then Log("RequestLocationUpdates")
|
||||||
|
FLP.RequestLocationUpdates(CreateLocationRequest) 'Buscamos ubicacion
|
||||||
|
If logger Then LogColor("Buscamos ubicacion (movimientoMinimo = "&actualLR.GetSmallestDisplacement&")", Colors.Magenta)
|
||||||
|
' If logger Then Log(actualLR.GetSmallestDisplacement)
|
||||||
|
flpStarted = True
|
||||||
|
' End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub StartFLP2
|
||||||
|
If logger Then Log("StartFLP2 - flpStarted="&flpStarted)
|
||||||
|
Do While FLP.IsConnected = False
|
||||||
|
Sleep(500)
|
||||||
|
If logger Then Log("sleeping")
|
||||||
|
Loop
|
||||||
|
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
|
||||||
|
FLP.RequestLocationUpdates(CreateLocationRequest2) 'Buscamos ubicacion 2 peticiones
|
||||||
|
If logger Then LogColor("Buscamos ubicacion (movimientoMinimo = "&actualLR.GetSmallestDisplacement&")", Colors.Magenta)
|
||||||
|
' If logger Then Log(actualLR.GetSmallestDisplacement)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub CreateLocationRequest As LocationRequest
|
||||||
|
' If logger Then Log("CreateLocationRequest")
|
||||||
|
Dim lr As LocationRequest
|
||||||
|
lr.Initialize
|
||||||
|
lr.SetInterval(10000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||||
|
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||||
|
lr.SetSmallestDisplacement(0) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||||
|
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||||
|
actualLR=lr
|
||||||
|
Return lr
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub CreateLocationRequest2 As LocationRequest
|
||||||
|
If logger Then Log("Iniciamos CreateLocationRequest2")
|
||||||
|
Dim lr As LocationRequest
|
||||||
|
lr.Initialize
|
||||||
|
lr.SetInterval(2000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||||
|
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||||
|
lr.setNumUpdates(2) 'Solicitamos solo 2 actualizaciones con estos parametros
|
||||||
|
lr.SetSmallestDisplacement(1) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||||
|
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||||
|
actualLR=lr
|
||||||
|
Return lr
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub dameUltimaUbicacionConocida
|
||||||
|
If FLP.GetLastKnownLocation.IsInitialized Then 'Mandamos ultima ubicacion guardada
|
||||||
|
' If logger Then LogColor($"Mandamos UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|Acc:$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|Spd:$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
|
||||||
|
' Dim coords As String = FLP.GetLastKnownLocation.Latitude&","&FLP.GetLastKnownLocation.Longitude&","&formatoFecha(FLP.GetLastKnownLocation.Time)
|
||||||
|
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||||
|
' Subs.mandamosLoc(coords)
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub StopFLP
|
||||||
|
'Log("StopFLP")
|
||||||
|
If flpStarted Then
|
||||||
|
FLP.RemoveLocationUpdates 'Eliminamos todas las solicitudes de ubicacion
|
||||||
|
flpStarted = False
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub flp_LocationChanged (Location1 As Location)
|
||||||
|
Starter.latitud = Location1.Latitude
|
||||||
|
Starter.longitud = Location1.Longitude
|
||||||
|
LogColor($"Location changed lat=${Location1.Latitude}, lon=${Location1.Longitude}, Acc=${Location1.Accuracy}, SD=$1.0{actualLR.GetSmallestDisplacement}"$, Colors.green)
|
||||||
|
UUGCoords = Location1
|
||||||
|
' If logger Then Log("SmallestDisplacement="&actualLR.GetSmallestDisplacement)
|
||||||
|
' CallSub2(Starter, "GPS_LocationChanged", Location1)
|
||||||
|
' CallSub2(gestion, "GPS_LocationChanged", Location1)
|
||||||
|
' Starter.ubicacionActual.Latitude = Starter.lat_gps
|
||||||
|
' Starter.ubicacionActual.Longitude = Starter.lon_gps
|
||||||
|
' Starter.ubicacionActual.Accuracy = Location1.Accuracy
|
||||||
|
|
||||||
|
'/////// para la ultima ubicacion FL
|
||||||
|
Dim sDate,sTime As String
|
||||||
|
DateTime.DateFormat = "MM/dd/yyyy"
|
||||||
|
sDate=DateTime.Date(DateTime.Now)
|
||||||
|
sTime=DateTime.Time(DateTime.Now)
|
||||||
|
' If Starter.lat_gps <> 0 And Starter.lat_gps <> Null Then
|
||||||
|
' Try
|
||||||
|
' Starter.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||||
|
' Starter.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, Starter.lat_gps, Starter.lon_gps))
|
||||||
|
' Catch
|
||||||
|
' If logger Then Log("Error al borrar o insertar nuevas coordendas en HIST_GPS")
|
||||||
|
' End Try
|
||||||
|
' End If
|
||||||
|
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub CreateNotification (Body As String) As Notification 'ignore
|
||||||
|
Dim notification As Notification
|
||||||
|
notification.Initialize2(notification.IMPORTANCE_LOW)
|
||||||
|
notification.Icon = "icon"
|
||||||
|
notification.SetInfo("This", Body, Main)
|
||||||
|
Return notification
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Destroy
|
||||||
|
If Tracking Then
|
||||||
|
StopFLP
|
||||||
|
End If
|
||||||
|
Tracking = False
|
||||||
|
lock.ReleasePartialLock
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub formatoFecha(fecha As String) As String 'ignore 'Convierte una fecha al formato yyMMddHHmmss
|
||||||
|
' Log(fecha)
|
||||||
|
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
|
||||||
|
DateTime.DateFormat="yyMMddHHmmss"
|
||||||
|
Dim lastUpdate As String=DateTime.Date(fecha)
|
||||||
|
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||||
|
' Log(lastUpdate)
|
||||||
|
Return lastUpdate
|
||||||
|
End Sub
|
||||||
142
B4XMainPage.bas
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=9.85
|
||||||
|
@EndOfDesignText@
|
||||||
|
#Region Shared Files
|
||||||
|
'#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
|
||||||
|
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
|
||||||
|
'###########################################################################################################
|
||||||
|
'###################### PULL #############################################################
|
||||||
|
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=..\..\gitpull.bat
|
||||||
|
'###########################################################################################################
|
||||||
|
'###################### PUSH #############################################################
|
||||||
|
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=github&Args=..\..\
|
||||||
|
'###########################################################################################################
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
|
||||||
|
|
||||||
|
Sub Class_Globals
|
||||||
|
Private Root As B4XView
|
||||||
|
Private xui As XUI
|
||||||
|
Private b_iniciar As Button
|
||||||
|
Private Usuario As EditText
|
||||||
|
Private Contraseña As EditText
|
||||||
|
Dim reqManager As DBRequestManager
|
||||||
|
Dim user As String
|
||||||
|
|
||||||
|
Dim principal As C_principal
|
||||||
|
Dim cliente As C_cliente
|
||||||
|
Dim user As String
|
||||||
|
Dim password As String
|
||||||
|
Dim e As Cursor
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Initialize
|
||||||
|
' B4XPages.GetManager.LogEvents = True
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'This event will be called once, before the page becomes visible.
|
||||||
|
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||||
|
Root = Root1
|
||||||
|
Root.LoadLayout("MainPage")
|
||||||
|
reqManager.Initialize(Me, Starter.DBReqServer)
|
||||||
|
principal.Initialize
|
||||||
|
B4XPages.AddPage("principal", principal)
|
||||||
|
cliente.Initialize
|
||||||
|
B4XPages.AddPage("cliente", cliente)
|
||||||
|
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||||
|
Wait For b4xpage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
If Result Then
|
||||||
|
StartService(Tracker)
|
||||||
|
Log("Start Tracker")
|
||||||
|
Else
|
||||||
|
ToastMessageShow("Sin permisos para GPS", True)
|
||||||
|
End If
|
||||||
|
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_COARSE_LOCATION)
|
||||||
|
Wait For b4xpage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
If Result Then
|
||||||
|
' StartService(Tracker)
|
||||||
|
' Log("Start Tracker")
|
||||||
|
Else
|
||||||
|
ToastMessageShow("Sin permisos para GPS", True)
|
||||||
|
End If
|
||||||
|
Log(Result)
|
||||||
|
|
||||||
|
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
|
||||||
|
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
' If Result Then
|
||||||
|
' Log("conpermisos para escritura")
|
||||||
|
' Else
|
||||||
|
' ToastMessageShow("No permission!!!", True)
|
||||||
|
' End If
|
||||||
|
'
|
||||||
|
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
|
||||||
|
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
' If Result Then
|
||||||
|
' Log("conpermisos para escritura")
|
||||||
|
' Else
|
||||||
|
' ToastMessageShow("No permission!!!", True)
|
||||||
|
' End If
|
||||||
|
|
||||||
|
Log("inicio1")
|
||||||
|
StartService(Tracker)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub B4XPage_Appear
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub b_iniciar_Click
|
||||||
|
|
||||||
|
If Usuario.Text <> "" Then
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "select_usuario_INTMEXP"
|
||||||
|
cmd.Parameters = Array As Object(Usuario.Text, Contraseña.Text)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "usuario")
|
||||||
|
user = Usuario.Text
|
||||||
|
End If
|
||||||
|
e = Starter.skmt.ExecQuery2("SELECT USUARIO FROM CARGA WHERE USUARIO = ?", Array As String(B4XPages.MainPage.user))
|
||||||
|
e.Position = 0
|
||||||
|
If e.RowCount = 0 Then
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO CARGA (USUARIO, CARGADO)VALUES(?, ?)",Array As String(B4XPages.MainPage.user,0))
|
||||||
|
End If
|
||||||
|
Log(Starter.latitud)
|
||||||
|
Log(Starter.longitud)
|
||||||
|
' B4XPages.ShowPage ("Principal")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub JobDone(Job As HttpJob)
|
||||||
|
If Job.Success = False Then
|
||||||
|
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||||
|
Else
|
||||||
|
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green)
|
||||||
|
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||||
|
If result.Tag = "usuario" Then 'query tag
|
||||||
|
For Each records() As Object In result.Rows
|
||||||
|
For Each k As String In result.Columns.Keys
|
||||||
|
Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
|
||||||
|
Next
|
||||||
|
If records(result.Columns.Get ("USUARIO")) = "OKActivo" Then
|
||||||
|
Starter.almacen = records(result.Columns.Get ("CAT_LO_AGENCIA"))
|
||||||
|
user = Usuario.Text
|
||||||
|
password = Contraseña.Text
|
||||||
|
B4XPages.ShowPage ("Principal")
|
||||||
|
Log(Starter.almacen)
|
||||||
|
Else
|
||||||
|
ToastMessageShow ("Datos incorrectos",True)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
If result.Rows.Size = 0 Then
|
||||||
|
ToastMessageShow ("Datos incorrectos",True)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
BIN
camara.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
1
gitpull.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
git pull
|
||||||
BIN
logointmex.jpg
Normal file
|
After Width: | Height: | Size: 81 KiB |