VERSION 5.12.11

- Se agrego coddigo para habilitar la geocerca, se descarga la bandera desde cat_rutas y se guarda en cat_variables (GEOCERCA)
This commit is contained in:
2025-12-30 13:50:30 -06:00
parent be8647261e
commit 5f23ece03f
10 changed files with 291 additions and 441 deletions

View File

@@ -18,6 +18,9 @@ Version=9.85
'###################### PUSH TORTOISE GIT #########################################################
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=TortoiseGitProc&Args=/command:commit&Args=/path:"./../../"&Args=/closeonend:2
'###########################################################################################################
'###################### PUSH TORTOISE GIT CON TAG ##################################################
'Ctrl + clic para Git: ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=-ExecutionPolicy&Args=Bypass&Args=-File&Args=..\_git_tag.ps1&Args=%22%PROJECT%%22&Args=%22%PROJECT_NAME%%22
'###########################################################################################################
#End Region
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=github&Args=..\..\

View File

@@ -15,7 +15,6 @@ Sub Class_Globals
Dim reqManager As DBRequestManager
Dim cmd As DBCommand
Dim ime As IME
Dim g As GPS
Dim ruta As String
Dim skmt As SQL
@@ -34,8 +33,6 @@ Sub Class_Globals
Dim BLANCO As String
Dim cuenta As String
Dim tipo_venta As String = "PREVENTA"
Dim c As Cursor
Dim s As Cursor
Dim DD As Cursor
@@ -54,13 +51,10 @@ Sub Class_Globals
Dim gest As Button
Dim la_saldotot As Label
Dim la_saldooper As Label
Dim Tels As Button
Dim Label10 As Label
Dim Label11 As Label
Dim Tar As Button
Dim la_comm As Label
Dim la_actdte As Label
Dim la_usuario As Label
@@ -72,8 +66,7 @@ Sub Class_Globals
Dim DATOS As Button
Dim Guardar As Button
Dim NUEVO As Button
' Dim lat_gps, lon_gps As String
' Dim lat_gps, lon_gps As String
Dim l_total As Label
Dim c2 As Cursor
Dim S2 As Cursor
@@ -88,7 +81,6 @@ Sub Class_Globals
Private BT_QR As Button
'Private qr As QRCode
Dim CODIGO As String
Private b_mapa As Button
Dim CUANTOS As String
Private B_IMP As Button
@@ -110,22 +102,18 @@ Sub Class_Globals
Private HR_RES3 As String
Private EXISTE As String
Private TELEFONO As String
Private RB1 As RadioButton
Private RB2 As RadioButton
Private RB3 As RadioButton
Private RB4 As RadioButton
Private RB5 As RadioButton
Private stay_hh As String
Private stay_mi As String
Private stay_ss As String
Private LA_GEO As Label
Dim result As Int
Private cercavalor As String
Private LA_RUTA As String
Private b_like As Button
Private B_GPS As Button
' Dim sc As JhsIceZxing1
@@ -152,7 +140,6 @@ Sub Class_Globals
Dim cuest As C_Cuestionario
Private b_ventaabordo As Button
Private l_factura As Label
Dim Printer1 As EscPosPrinter
Dim impresoraConectada As Boolean = False
Dim MAC_IMPRESORA As String
@@ -197,7 +184,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
Else
b_cxc.Visible = True
End If
p_telefono.Top = 0 : p_telefono.Left = 0
s.Position=0
If c.RowCount>0 Then
c.Position=0
@@ -252,6 +239,7 @@ End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
CallSubDelayed(Tracker, "StartFLPSmall")
p_pedidoExistente.Visible = False
reqManager.Initialize(Me, Starter.DBReqServer)
b_pedidoExistente.Visible = False
@@ -267,7 +255,7 @@ Sub B4XPage_Appear
p_abono.Visible = False
Subs.centraPanel(p_abono, Root.Width)
skmt.Initialize(ruta,"kmt.db", True)
c=B4XPages.MainPage.skmt.ExecQuery("select 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,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa) UNION ALL select 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,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO from kmt_info2 where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
c=B4XPages.MainPage.skmt.ExecQuery("select 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,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa) UNION ALL select 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,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO from kmt_info2 where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
s=B4XPages.MainPage.skmt.ExecQuery("Select ifnull(SUM(PE_COSTO_TOT), 0) As TOTAL_CLIE, SUM(PE_CANT) As CANT_CLIE, PC_FACTURA FROM PEDIDO_CLIENTE INNER JOIN PEDIDO ON PEDIDO_CLIENTE.PC_CLIENTE = PEDIDO.PE_CLIENTE WHERE (PE_CLIENTE IN (Select cuenta from cuentaa))")
b = B4XPages.MainPage.skmt.ExecQuery("select COUNT(*) AS CLIENTE FROM ABONOSP WHERE CLIENTE IN (Select CUENTA from cuentaa)")
b.Position = 0
@@ -304,16 +292,16 @@ Sub B4XPage_Appear
If m_lon.Length < 5 Then m_lon = "0"
LA_RUTA = c.GetString("CAT_CL_RUTA")
' ESTO ES PARA FORZAR A PEDIR LA FOTO Y EL GPS
If c.GetString("CAT_CL_NUM_SERIEFISICO") = "0" Then
L_QR.TEXT = "SIN CODIGO"
L_QR.TextColor = Colors.Red
gest.VISIBLE = False
BT_QR.Visible = True
Else
L_QR.TEXT = c.GetString("CAT_CL_NUM_SERIEFISICO")
L_QR.TextColor = Colors.Blue
BT_QR.Visible = False
End If
' If c.GetString("CAT_CL_NUM_SERIEFISICO") = "0" Then
' L_QR.TEXT = "SIN CODIGO"
' L_QR.TextColor = Colors.Red
' gest.VISIBLE = False
' BT_QR.Visible = True
' Else
' L_QR.TEXT = c.GetString("CAT_CL_NUM_SERIEFISICO")
' L_QR.TextColor = Colors.Blue
' BT_QR.Visible = False
' End If
End If
c.Close
s.Close
@@ -374,17 +362,9 @@ Sub B4XPage_Appear
Tels.Visible = True
gest.Visible = True
End If
CallSubDelayed(Tracker, "Track")
CallSubDelayed(Tracker, "StartFLPSmall")
If Tracker.FLP.IsInitialized And Tracker.FLP.GetLastKnownLocation.IsInitialized Then 'Si tenemos "UltimaUbicaccionConocida" la usamos.
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
' Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
End If
Tels.Visible = True
gest.Visible = True
' h = B4XPages.MainPage.skmt.ExecQuery("SELECT CUENTA from CUENTAA")
' h.Position = 0
' Log(h.GetString("CUENTA"))
@@ -399,33 +379,20 @@ Sub B4XPage_Appear
' h.Close
' j.Close
If la_cuenta.Text = "0" Then
p_cbFactura.Visible = False
l_factura.Visible = False
b_ventaabordo.Visible = False
Else
p_cbFactura.Visible = True
l_factura.Visible = True
b_ventaabordo.Visible = True
End If
c = skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MACIMP"))
If c.RowCount > 0 Then
c.Position = 0
Starter.MAC_IMPRESORA = c.GetString("CAT_VA_VALOR")
End If
If Starter.MAC_IMPRESORA = "" Then Starter.MAC_IMPRESORA = "0"
' Log("|" & Starter.MAC_IMPRESORA & "|")
Printer1.Initialize(Me, "Printer1")
If Printer1.IsConnected = False Then
' Printer1.Connect
' Log("1")
Else
Printer1.DisConnect
Printer1.Connect
Log("2")
End If
If Subs.hayPedido And Starter.utimaPagina <> "Productos" And Starter.utimaPagina <> "Cliente" Then
' Log()
Private p As ResultSet = Starter.skmt.ExecQuery($"select * from pedido where pe_cliente = '${Subs.traeCliente}'"$)
lv_pedidoExistente.Clear
Private label1 As Label = lv_pedidoExistente.TwoLinesLayout.Label
@@ -433,7 +400,7 @@ Sub B4XPage_Appear
label1.TextSize = 13
Private label2 As Label = lv_pedidoExistente.TwoLinesLayout.SecondLabel
label2.TextSize = 13
Private cs As CSBuilder
Do While p.NextRow
cs.Initialize
@@ -443,11 +410,31 @@ Sub B4XPage_Appear
End If
lv_pedidoExistente.AddTwoLines(cs.Color(textColor).append(p.GetString("PE_PRONOMBRE")).pop, $"Cant: ${p.GetString("PE_CANT")} - $${NumberFormat2(p.GetString("PE_COSTO_TOT"),1,2,2,True)}, ${p.GetString("PE_FOLIO")}"$)
Loop
p_pedidoExistente.Visible = True
p_pedidoExistente.BringToFront
b_pedidoExistente.Visible = True
End If
If la_cuenta.Text = "0" Then
p_cbFactura.Visible = False
l_factura.Visible = False
b_ventaabordo.Visible = False
Else
p_cbFactura.Visible = True
l_factura.Visible = True
b_ventaabordo.Visible = True
End If
'Revisamos si la geocerca debe de activarse y de ser necesario, ocultamos los botones de venta y no venta.
If Subs.traeGeocerca Then ocultamosBotonesPorGeocerca
If Tracker.FLP.IsInitialized And Tracker.FLP.GetLastKnownLocation.IsInitialized Then 'Si tenemos "UltimaUbicaccionConocida" la usamos.
Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
End If
End Sub
Sub B4XPage_disappear
@@ -457,35 +444,41 @@ End Sub
Sub GPS_LocationChanged (Location1 As Location)
' LogColor($"Entrando a Cliente.GPS_LocationChanged"$, Colors.red)
If Tracker.FLP.GetLastKnownLocation.IsInitialized And Tracker.FLP.GetLastKnownLocation.Latitude <> 0 Then
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
' Log("Coords set to: " & B4XPages.MainPage.lat_gps & " and " & B4XPages.MainPage.lon_gps)
End If
Dim l1, l2 As Location
l1.Initialize2(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps)
' If Tracker.FLP.GetLastKnownLocation.IsInitialized And Tracker.FLP.GetLastKnownLocation.Latitude <> 0 Then
' B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
' B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
'' Log("Coords set to: " & B4XPages.MainPage.lat_gps & " and " & B4XPages.MainPage.lon_gps)
' End If
B4XPages.MainPage.lat_gps = Location1.Latitude
B4XPages.MainPage.lon_gps = Location1.Longitude
Dim locTienda As Location
locTienda.Initialize2(m_lat, m_lon)
' Log($"Coordenadas de la tienda - lat:${m_lat}, lon:${m_lon}"$)
l2.Initialize2(m_lat, m_lon)
BT_QR.Enabled = True
LA_GPS.TextColor = Colors.Blue
LA_GPS.Text = "CON UBICACION GPS"
' B_GPS.Enabled = True
'now we need the distance between our location and the target location
distance = l1.DistanceTo(l2) 'the result is in meter
gest.Visible = True
' If distance < 100 Then
LA_GEO.TextColor = Colors.Blue
Tels.Visible = True
distance = Location1.DistanceTo(locTienda) 'Distancia de la ubicacion actual a coords de la tienda.
Log("Distancia a tienda: " & distance)
If distance < 50 Then
gest.Visible = True
' Else
' LA_GEO.TextColor = Colors.Red
' End If
Tels.Visible = True
If la_cuenta.Text = "0" Then
b_ventaabordo.Visible = False
Else
b_ventaabordo.Visible = True
End If
Else
LA_GEO.TextColor = Colors.Red
If Subs.traeGeocerca Then
ocultamosBotonesPorGeocerca
End If
End If
LA_GEO.Text= $"$1.2{distance/1000} kms"$
B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
CallSubDelayed(Tracker, "CreateLocationRequest")
' CallSubDelayed(Tracker, "CreateLocationRequest")
End Sub
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
@@ -510,7 +503,6 @@ Sub gest_Click
' Return False
' End If
Private x As Cursor = B4XPages.MainPage.skmt.ExecQuery($"select tienda_id from COORDENADAS_GPS where tienda_id = '${la_cuenta.text}'"$)
' Log("+++++++++++++ " & x.RowCount)
If la_cuenta.Text<> "0" And distance > 50 And x.RowCount = 0 Then
Private res As String = Msgbox2("¿Estas en la tienda, para guardar la nueva ubicación?", "AVISO", "Si","" ,"No", Null) 'ignore
If res = DialogResponse.POSITIVE Then
@@ -527,8 +519,6 @@ Sub gest_Click
reqManager.ExecuteCommand(cmd , "ins_coords_nuevas")
End If
End If
'Si hay mapa de productos es que hay venta en proceso, entonces borramos la actual para meter la nueva.
' If B4XPages.MainPage.productos.prodsMap.IsInitialized And B4XPages.MainPage.productos.prodsMap.Size > 0 Then Subs.borraPedidoClienteActual
B4XPages.ShowPage("productos")
End Sub
@@ -539,7 +529,6 @@ End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
' BACK key pressed
' Return True To close, False To cancel
' Log($"venimosDeTicketsDia=${venimosDeTicketsDia}"$)
If la_cuenta.Text <> "0" Then
cuest.encuestaIniciada = False
cuest.ocultPanelPregunta
@@ -570,10 +559,6 @@ Sub Tar_Click
B4XPages.ShowPage("Nota")
End Sub
'Sub Tar_LongClick
' p_abono.Visible = True
'End Sub
Sub DATOS_Click
B4XPages.ShowPage("telefonos")
End Sub
@@ -592,7 +577,6 @@ Sub Guardar_Click
c.Close
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, COUNT(*) AS CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
c.Position=0
' Log("xxxxxxxxxxxxxxx " & c.GetString("CUANTOS"))
If c.GetString("CUANTOS") > 0 Then ' Si hay pedido, entonces ...
Log("HAY PEDIDO")
Private cbFactura As Int = 0
@@ -632,7 +616,7 @@ Sub Guardar_Click
' LogColor($"actualizamos "${la_cuenta.text}, hora_final=${DateTime.now}"$,Colors.Red)
Subs.actualizaTET(la_cuenta.text)
DateTime.TimeFormat = "HH:mm:ss"
mandaPendientes 'LO COMENTAMOS PARA PRUEBAS, ACTIVAR AL FINAL!!! solo envia clientes nuenos, no comentar lo que yo descomente --- javier (por que Guerra lo comento)
mandaPendientes 'LO COMENTAMOS PARA PRUEBAS, ACTIVAR AL FINAL!!! - Solo envia clientes nuevos, no comentar lo que yo descomente --- javier (por que Guerra lo comento) ... ¿Que descomentaste?? --- Guerra
mandapiezas
B4XPages.MainPage.productos.reiniciarlistaProds = True
B4XPages.MainPage.productos.prodsMap.Initialize
@@ -1743,4 +1727,11 @@ Private Sub Label16_LongClick
p_telefono.Height = Root.Height
p_telefono.Width = Root.Width
p_telefono.Visible = True
End Sub
' Ocultamos por geocerca (Venta, Preventa y No venta)
Sub ocultamosBotonesPorGeocerca
gest.Visible = False
b_ventaabordo.Visible = False
Tels.Visible = False
End Sub

View File

@@ -871,7 +871,7 @@ Sub cargar_Click
Subs.panelVisible(P1, 0, 0)
Subs.centraPanel(P1, Root.Width)
Subs.centraPanelV(P1, Root.Height)
' trabajar.Visible = False
' trabajar.Visible = False
NUEVO.Visible =False
BUSCA.Visible=False
connecta.Visible=False
@@ -936,7 +936,7 @@ Sub cargar_Click
sTime=DateTime.Time(DateTime.Now)
Dim P As PhoneId
' imei = P.GetDeviceId
' imei = P.GetDeviceId
imei = "xxxx"
cmd.Initialize
cmd.Name ="insert_drop_INTMEX_3"
@@ -953,10 +953,10 @@ Sub cargar_Click
cmd.Parameters = Array As Object(ALMACEN,e_ruta.Text)
reqManager.ExecuteQuery(cmd , 0, "gunaprod2")
' cmd.Initialize
' cmd.Name = "select_resum_apk_INTMEX" ''' va el nombre de archivo de config
' cmd.Parameters = Array As Object(ALMACEN)
' reqManager.ExecuteQuery(cmd , 0, "resum_apk") ''' donde regresa la info ver job_done
' cmd.Initialize
' cmd.Name = "select_resum_apk_INTMEX" ''' va el nombre de archivo de config
' cmd.Parameters = Array As Object(ALMACEN)
' reqManager.ExecuteQuery(cmd , 0, "resum_apk") ''' donde regresa la info ver job_done
cmd.Initialize
cmd.Name = "select_cat_paquetes_INTMEX4"
@@ -1026,41 +1026,43 @@ Sub cargar_Click
cmd.Name = "select_tipoRuta_Intmex"
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
reqManager.ExecuteQuery(cmd , 0, "tipoRuta")
' cmd.Initialize
' cmd.Name = "select_HIST_MARCAS_CUOTAS_INTMEX"
' cmd.Parameters = Array As Object( ALMACEN, e_ruta.text)
' reqManager.ExecuteQuery(cmd , 0, "HIST_MARCAS_CUOTAS")
' cmd.Initialize
' cmd.Name = "select_HIST_MARCAS_CUOTAS_INTMEX"
' cmd.Parameters = Array As Object( ALMACEN, e_ruta.text)
' reqManager.ExecuteQuery(cmd , 0, "HIST_MARCAS_CUOTAS")
cmd.Name = "select_geocerca_intmex"
cmd.Parameters = Array As Object(ALMACEN, e_ruta.text)
Log($"traeGeocerca: almacen: ${ALMACEN}, ruta: ${e_ruta.text}"$)
reqManager.ExecuteQuery(cmd , 0, "traeGeocerca")
If E_RUTA2.text <> "" Then
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_SUPLENCIA(RS_RUTA) VALUES(?)",Array As String(E_RUTA2.Text))
E_RUTA2.Visible = False
ImageView9.Visible = False
cmd.Initialize
cmd.Name = "select_cat_clientes3_INTMEX"
cmd.Parameters = Array As Object(E_RUTA2.text,E_RUTA2.text, ALMACEN,E_RUTA2.text,E_RUTA2.text)
reqManager.ExecuteQuery(cmd , 0, "kmt_datos")
cmd.Initialize
cmd.Name = "select_cat_clientes_todos_INTMEX"
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
reqManager.ExecuteQuery(cmd , 0, "kmt_datos_todos")
cmd.Initialize
cmd.Name = "select_hist_datos_INTMEX"
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
reqManager.ExecuteQuery(cmd , 0, "hist_datos")
cmd.Initialize
cmd.Name = "select_hist_promos_INTMEX"
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
reqManager.ExecuteQuery(cmd , 0, "hist_promos")
cmd.Initialize
cmd.Name = "select_hist_cliente_promos_INTMEX"
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
@@ -1076,12 +1078,12 @@ Sub cargar_Click
' cmd.Name = "select_verificacion_INTMEX"
' cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
' reqManager.ExecuteQuery(cmd , 0, "cat_verificacion")
cmd.Initialize
cmd.Name = "select_fecha"
' cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
reqManager.ExecuteQuery(cmd , 0, "fecha")
cmd.Initialize
cmd.Name = "select_folio_INTMEX"
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
@@ -1102,19 +1104,19 @@ Sub cargar_Click
cmd.Parameters = Array As Object(usuario)
reqManager.ExecuteQuery(cmd , 0, "marcas")
' cmd.Initialize
' cmd.Name = "select_CUEST_INTMEX"
' cmd.Parameters = Array As Object(ALMACEN)
' reqManager.ExecuteQuery(cmd , 0, "CUESTIONARIO")
' cmd.Initialize
' cmd.Name = "select_HIST_CUOTAS_INTMEX"
' cmd.Parameters = Array As Object( ALMACEN,e_ruta.text )
' reqManager.ExecuteQuery(cmd , 0, "CUOTAS")
' cmd.Initialize
' cmd.Name = "select_CUEST_INTMEX"
' cmd.Parameters = Array As Object(ALMACEN)
' reqManager.ExecuteQuery(cmd , 0, "CUESTIONARIO")
'
' cmd.Initialize
' cmd.Name = "select_HIST_CUOTAS_INTMEX"
' cmd.Parameters = Array As Object( ALMACEN,e_ruta.text )
' reqManager.ExecuteQuery(cmd , 0, "CUOTAS")
cmd.Initialize
cmd.Name = "select_comis_cedex_INTMEX"
cmd.Parameters = Array As Object( ALMACEN, e_ruta.text )
cmd.Parameters = Array As Object(ALMACEN, e_ruta.text)
reqManager.ExecuteQuery(cmd , 0, "COMISIONES")
cmd.Initialize
@@ -2006,7 +2008,7 @@ Sub JobDone(Job As HttpJob)
Dim avance As String = records(RESULT.Columns.Get("HIST_AM_AVANCE"))
Dim objetivo As String = records(RESULT.Columns.Get("HIST_AM_OBJETIVO"))
Dim porcentaje1 As String = records(RESULT.Columns.Get("HIST_AM_PORCENTAJE"))
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_AVANCE(HA_MARCA, HA_AVANCE, HA_OBJETIVO, HA_PORCENTAJE) VALUES (?,?,?,?)", Array As Object (MARCA2, avance, objetivo, porcentaje1))
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_AVANCE(HA_MARCA, HA_AVANCE, HA_OBJETIVO, HA_PORCENTAJE) VALUES (?,?,?,?)", Array As Object (marca2, avance, objetivo, porcentaje1))
Next
End If
End If
@@ -2048,29 +2050,39 @@ Sub JobDone(Job As HttpJob)
End If
End If
If Job.JobName = "DBRequest" Then
Dim RESULT As DBResult = reqManager.HandleJob(Job)
If RESULT.Tag = "ins_cuestionario" Then 'query tag
Subs.logJobDoneResultados(RESULT)
End If
If Job.JobName = "DBRequest" Then
Dim RESULT As DBResult = reqManager.HandleJob(Job)
If RESULT.Tag = "ins_cuestionario" Then 'query tag
Subs.logJobDoneResultados(RESULT)
End If
Dim RESULT As DBResult = reqManager.HandleJob(Job)
If RESULT.Tag = "test" Then 'query tag
Log(">>>>>>>>>>>>> TEST")
Subs.logJobDoneResultados(RESULT)
End If
Dim RESULT As DBResult = reqManager.HandleJob(Job)
If RESULT.Tag = "test" Then 'query tag
Log(">>>>>>>>>>>>> TEST")
Subs.logJobDoneResultados(RESULT)
End If
Dim RESULT As DBResult = reqManager.HandleJob(Job)
If RESULT.Tag = "clientes_cuestionario" Then
Log("Entramos a clientes_cuestionario - Regs:" & RESULT.Rows.Size)
Starter.skmt.ExecNonQuery("delete from HIST_CUESTIONARIO")
For Each records() As Object In RESULT.Rows
Dim idCliente As String = records(RESULT.Columns.Get("HC_CLIENTE"))
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_CUESTIONARIO(HC_CLIENTE) VALUES (?)", Array As Object (idCliente))
Next
End If
If RESULT.Tag = "traeGeocerca" Then
For Each records() As Object In RESULT.Rows
Dim geocerca As String = records(RESULT.Columns.Get("CAT_RU_GEOCERCA"))
Log("-- geo: " & geocerca)
B4XPages.MainPage.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("GEOCERCA"))
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("GEOCERCA", geocerca))
Next
End If
Dim RESULT As DBResult = reqManager.HandleJob(Job)
If RESULT.Tag = "clientes_cuestionario" Then
Log("Entramos a clientes_cuestionario - Regs:" & RESULT.Rows.Size)
Starter.skmt.ExecNonQuery("delete from HIST_CUESTIONARIO")
For Each records() As Object In RESULT.Rows
Dim idCliente As String = records(RESULT.Columns.Get("HC_CLIENTE"))
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_CUESTIONARIO(HC_CLIENTE) VALUES (?)", Array As Object (idCliente))
Next
End If
End If
End If
Job.Release
End Sub

Binary file not shown.

View File

@@ -164,7 +164,7 @@ Version=12.8
#Region Project Attributes
#ApplicationLabel: Intmex
#VersionCode: 1
#VersionName: 5.12.10
#VersionName: 5.12.11
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False

View File

@@ -85,12 +85,12 @@ ModuleClosedNodes28=
ModuleClosedNodes29=
ModuleClosedNodes3=
ModuleClosedNodes30=
ModuleClosedNodes4=
ModuleClosedNodes4=4
ModuleClosedNodes5=3
ModuleClosedNodes6=
ModuleClosedNodes7=
ModuleClosedNodes8=
ModuleClosedNodes9=
NavigationStack=DBRequestManager,HandleJob,197,0,C_Cliente,B4XPage_Appear,298,0,Diseñador Visual,principal.bal,-100,6,C_Principal,B_OK_PAS_Click,2327,0,C_Principal,checaPedido,2834,0,C_Principal,nvo_cliente_Click,2597,0,B4XMainPage,B4XPage_Created,195,3,C_Principal,cargar_Click,955,6,C_Principal,resdia_Click,2565,0,C_Principal,JobDone,1688,6,C_Principal,hacer_ped_Click,2592,6
NavigationStack=C_Principal,JobDone,2070,6,C_Principal,cargar_Click,1016,6,Tracker,StartFLPSmall,399,0,Tracker,CreateLocationRequestSmallD,134,0,C_Cliente,GPS_LocationChanged,475,6,C_Cliente,ListView1_ItemLongClick,478,0,C_Cliente,gest_Click,515,0,C_Cliente,B4XPage_CloseRequest,543,0,C_Cliente,Tar_Click,554,0,C_Cliente,Guardar_Click,619,6,C_Cliente,mandaPendientes,1291,0
SelectedBuild=0
VisibleModules=28,2,13,20,14,29,15,4,11,21
VisibleModules=28,2,13,20,14,29,15,4,11,21,30

View File

@@ -1545,4 +1545,15 @@ Sub traeTicketConsecutivo(idCliente As String) As Int
sigTicket = c.GetInt("pe_ticket")
Loop
Return sigTicket + 1
End Sub
' Regresa la geocerca desde CAT_VARIABLES, default = TRUE
Sub traeGeocerca As Boolean
Private usarGeo As Boolean = True
Private c As Cursor = Starter.skmt.ExecQuery("select * from cat_variables where cat_va_descripcion ='GEOCERCA'")
If c.RowCount> 0 Then
c.Position = 0
If c.GetInt("CAT_VA_VALOR") = 0 Then usarGeo = False
End If
Return usarGeo
End Sub

View File

@@ -4,300 +4,6 @@ ModulesStructureVersion=1
Type=Service
Version=10.2
@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 B4XPage_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 = 51042
' 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
'End Sub
'
'Sub Service_Create
' Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
' 'Para FusedLocationProvider (2 lineas)
' FLP.Initialize("flp")
' FLP.Connect
' lock.PartialLock
' StartFLP
'End Sub
'
'Sub flp_ConnectionSuccess
'' Log("Connected to location provider")
' 'FLP.GetLastKnownLocation
'End Sub
'
'Sub flp_ConnectionFailed(ConnectionResult1 As Int)
' Log("Failed to connect to location provider")
'End Sub
'
'Sub Service_Start (StartingIntent As Intent)
' 'Para FusedLocationProvider (1 linea)
' Service.StopAutomaticForeground
' Service.StartForeground(nid, CreateNotification("..."))
' Track
' StartServiceAt(Me, DateTime.Now + 5 * DateTime.TicksPerMinute, True)
' FLP.GetLastKnownLocation.Initialize
'End Sub
'
'Public Sub Track
'' Log("Inicia Track - Tracking : "&Tracking)
' If Not(FLP.IsInitialized) Then FLP.Initialize("flp")
' If Not(FLP.IsConnected) Then FLP.Connect
' If Tracking And actualLR.IsInitialized 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
' Log("No permission")
' Return
' End If
' StartFLP 'Iniciamos FusedLocationProvider
' Tracking = True
'End Sub
'
'Public Sub StartFLP
'' Log("StartFLP - flpStarted="&flpStarted)
' Do While FLP.IsConnected = False
' Sleep(500)
'' Log("sleeping")
' Loop
'' If flpStarted = False Then
'' Log("RequestLocationUpdates")
' FLP.RequestLocationUpdates(CreateLocationRequest) 'Buscamos ubicacion
'' Log("Buscamos ubicacion")
'' Log(actualLR.GetSmallestDisplacement)
' flpStarted = True
'' End If
'End Sub
'
'Public Sub StartFLPSmall
'' Log("StartFLPSmall - flpStarted="&flpStarted)
' Do While FLP.IsConnected = False
' Sleep(500)
' Log("sleeping")
' Loop
' dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
' FLP.RequestLocationUpdates(CreateLocationRequestSmallD) 'Buscamos ubicacion 2 peticiones
'' Log("Buscamos ubicacion Small displacement")
'' Log("GPSSmallestDisplacement = " & actualLR.GetSmallestDisplacement)
'End Sub
'
'Private Sub CreateLocationRequest As LocationRequest
'' 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(50) '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 CreateLocationRequestSmallD As LocationRequest
'' Log("Iniciamos CreateLocationRequestSmallD")
' 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 Main.logger Then Log("Mandamos UUC : "&formatoFecha(FLP.GetLastKnownLocation.Time))
' If Starter.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)
'' ToastMessageShow("Loc changed", False)
'' Log($"Loc changed:${Location1.Longitude},${Location1.Latitude}"$)
' B4XPages.MainPage.lat_gps = Location1.Latitude
' B4XPages.MainPage.lon_gps = Location1.Longitude
' UUGCoords = Location1
'' Log("SmallestDisplacement="&actualLR.GetSmallestDisplacement)
'' If DateTime.Now > LastUpdateTime + 10 * DateTime.TicksPerSecond Then
'' Dim n As Notification = CreateNotification($"$2.5{Location1.Latitude} / $2.5{Location1.Longitude}"$)
'' n.Notify(nid)
'' LastUpdateTime = DateTime.Now
'' End If
' '/////// para la ultima localización FL
' Dim sDate,sTime As String
' DateTime.DateFormat = "MM/dd/yyyy"
' sDate=DateTime.Date(DateTime.Now)
' sTime=DateTime.Time(DateTime.Now)
' If Not(B4XPages.MainPage.skmt.IsInitialized) Then B4XPages.MainPage.skmt.Initialize(Starter.ruta,"kmt.db", True)
' Try
' B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
' B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
' Catch
' LogColor(LastException, Colors.Red)
' End Try
' '///////
' Dim coords As String = Location1.Latitude&","&Location1.Longitude&","&formatoFecha(Location1.Time)
'' Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&B4XPages.MainPage.usuario&"|")
'' Log("Mandamos Ubicacion")
'' Log(FirebaseMessaging.locRequest)
' ' Solo mandamos la ubicacion si la precision es menor a XX mts
' If Location1.Accuracy < 100 Then
'' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
' End If
'
' CallSub2(Starter, "GPS_LocationChanged", Location1)
'' CallSub2(gestion, "GPS_LocationChanged", Location1)
'' CallSub2(B4XPages.GetPage("Cliente"), "GPS_LocationChanged", Location1)
'' CallSub2(nuevocliente, "GPS_LocationChanged", Location1)
'End Sub
'
'Sub CreateNotification (Body As String) As Notification
' Dim notification As Notification
' notification.Initialize2(notification.IMPORTANCE_LOW)
' notification.Icon = "icon"
' notification.SetInfo("INTMEX", 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 '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
'
''Revisamos que el FLP (FusedLocationProvider) este inicializado y activo
'Sub revisaFLP 'ignore
' LogColor("**** **** Revisamos FLP **** ****", Colors.RGB(78,0,227))
' Private todoBienFLP As Boolean = True
' Try
' If Not(FLP.IsInitialized) Then
' Subs.log2DB("revisaFLP: No esta inicializado ... 'Reinicializando FLP'")
' FLP.Initialize("flp")
' todoBienFLP = False
' End If
' Catch
' LogColor("If Not(Tracker.FLP.IsInitialized) --> "&LastException, Colors.Red)
' End Try
' Try
' If FLP.IsInitialized Then
' Try
' If Not(FLP.IsConnected) Then
' Subs.log2DB("revisaFLP: No esta conectado ... 'Reconectando FLP'")
' ' Tracker.FLP.Connect
' StartFLP
' todoBienFLP = False
' End If
' Catch
' LogColor("If Not(Tracker.FLP.IsConnected) --> "&LastException, Colors.Red)
' End Try
' Try
' If FLP.IsConnected And _
' FLP.GetLastKnownLocation.IsInitialized And _
' FLP.GetLastKnownLocation.DistanceTo(UUGCoords) > 500 Then
' Subs.log2DB("revisaFLP: 'No se esta actualizando, lo reiniciamos ...'")
' StartService(Me)
' todoBienFLP = False
' End If
' Catch
' LogColor("If FLP.IsConnectctd and FLP.getLKL.IsInitialized --> "&LastException, Colors.Red)
' End Try
' End If
' If todoBienFLP Then LogColor(" +++ +++ Sin errores en FLP", Colors.Green)
' Catch
' LogColor("If Tracker.FLP.IsInitialized --> "&LastException, Colors.Red)
' End Try
' ' revisar hora de lastKnownlocation y si es mayor de 10 minutos llamar StartFLP
'End Sub
'
''Compara la UUG (Ultima Ubicacion Guardada) con FLP.LastKnowLocation y si
''cumple con los requisitos de distancia y precision la guardamos en la BD.
'Sub revisaUUG 'ignore
' Try
'' revisaFLP
' If FLP.IsInitialized And FLP.IsConnected Then
' Try
' If FLP.GetLastKnownLocation.IsInitialized Then
'' Dim x As Location = FLP.GetLastKnownLocation
' Dim daa As Int = UUGCoords.DistanceTo(FLP.GetLastKnownLocation) 'Distancia de la UUG a la actual de Tracker.FLP.GetLastKnownLocation
' If Starter.Logger Then LogColor($"**** UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
' If daa > 40 And FLP.GetLastKnownLocation.Accuracy < 35 Then 'Si la distancia de la ubicacion anterior es mayor de XX y la precision es menor de XX, la guardamos ...
' B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)", Array As Object (Subs.fechaKMT(FLP.GetLastKnownLocation.Time),FLP.GetLastKnownLocation.Latitude,FLP.GetLastKnownLocation.Longitude))
' If Starter.Logger Then Log("++++ Distancia a anterior="&daa&"|"&"Precision="&FLP.GetLastKnownLocation.Accuracy)
' End If
' UUGCoords = FLP.GetLastKnownLocation
' End If
' Catch
' LogColor("FLP.GetLastKnownLocation.IsInitialized --> "&LastException, Colors.Red)
' End Try
' Else
' Log("StartFLP")
' StartFLP
' End If
' Catch
' LogColor("If FLP.IsInitialized --> "&LastException, Colors.Red)
' End Try
'End Sub
#Region Service Attributes
#StartAtBoot: True
#End Region
@@ -403,7 +109,6 @@ Public Sub StartFLPSmall
Sleep(500)
Log("sleeping")
Loop
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
FLP.RequestLocationUpdates(CreateLocationRequestSmallD) 'Buscamos ubicacion 2 peticiones
' Log("Buscamos ubicacion Small displacement")
' Log("GPSSmallestDisplacement = " & actualLR.GetSmallestDisplacement)
@@ -434,16 +139,6 @@ Private Sub CreateLocationRequestSmallD As LocationRequest
Return lr
End Sub
Sub dameUltimaUbicacionConocida
If FLP.GetLastKnownLocation.IsInitialized Then 'Mandamos ultima ubicacion guardada
' If Main.logger Then Log("Mandamos UUC : "&formatoFecha(FLP.GetLastKnownLocation.Time))
If Starter.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

110
B4A/_git_tag.ps1 Normal file
View File

@@ -0,0 +1,110 @@
# --- SCRIPT DE AUTODESCUBRIMIENTO CON GUI MEJORADA ---
# Cargar librería visual
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# 1. AUTODESCUBRIMIENTO
$projectPath = $PSScriptRoot
Write-Host "Ruta: $projectPath"
$b4aFileItem = Get-ChildItem -Path $projectPath -Filter "*.b4a" | Select-Object -First 1
if (-Not $b4aFileItem) {
[System.Windows.Forms.MessageBox]::Show("No hay archivo .b4a en esta carpeta.", "Error", "OK", "Error")
return
}
$b4aFile = $b4aFileItem.FullName
$projectName = $b4aFileItem.BaseName
Write-Host "Proyecto: $projectName"
# 2. LIMPIEZA
# $objectsPath = Join-Path $projectPath "Objects"
# if (Test-Path $objectsPath) {
# Write-Host "Limpiando Objects..."
# Remove-Item -Path "$objectsPath\*" -Recurse -Force -ErrorAction SilentlyContinue
# }
# 3. LEER VERSIÓN
$versionLine = Get-Content $b4aFile | Select-String "#VersionName:"
if (-Not $versionLine) { Write-Error "Falta #VersionName"; return }
$version = ($versionLine -split ":")[1].Trim()
$tagName = "v$version"
Set-Location $projectPath
# 4. COMMIT
$oldCommit = git rev-parse HEAD
Write-Host "----------------------------------------"
Write-Host "Versión: $version"
Write-Host "Abriendo TortoiseGit..."
# Argumentos limpios
$pathArg = '/path:"{0}"' -f $projectPath
$msgArg = '/logmsg:"VERSION {0}"' -f $version
$cmdArg = "/command:commit"
$process = Start-Process "TortoiseGitProc.exe" -ArgumentList $cmdArg, $pathArg, $msgArg -Wait -PassThru
$newCommit = git rev-parse HEAD
# 5. VALIDACIÓN
if ($oldCommit -eq $newCommit) {
Write-Warning "Commit cancelado."
git tag -d $tagName 2>$null # Borra tag local previo si existe para actualizarlo al nuevo commit
return
}
Write-Host ">> Commit detectado."
# 6. GESTIÓN DE TAGS (VISUAL TOPMOST)
Write-Host "git ls-remote --tags origin $tagName"
$remoteTagInfo = git ls-remote --tags origin $tagName
if ($remoteTagInfo) {
# --- TRUCO PARA QUE LA VENTANA SALGA AL FRENTE ---
# Creamos un formulario invisible que esté "Siempre Visible" (TopMost)
Write-Host "Recibimos remoteTagInfo"
$topForm = New-Object System.Windows.Forms.Form
$topForm.TopMost = $true
$topForm.Opacity = 0 # Invisible
$topForm.ShowInTaskbar = $false
$topForm.StartPosition = "CenterScreen"
$topForm.Show()
$topForm.Activate()
[System.Console]::Beep(1000, 200)
[System.Console]::Beep(1000, 200)
$msgBody = "El tag '$tagName' YA EXISTE en GitHub.`n`nDeseas SOBRESCRIBIRLO?`n`nSi = Borrar anterior y actualizar (Force Push).`nNo = Subir solo codigo (mantener tag viejo)."
$msgTitle = "⚠️ Conflicto de Versiones - $projectName"
# El mensaje ahora es "hijo" del formulario invisible, heredando su propiedad TopMost
Write-Host "Preguntamos que hacer con el tag"
$respuesta = [System.Windows.Forms.MessageBox]::Show($topForm, $msgBody, $msgTitle, "YesNo", "Warning")
$topForm.Dispose() # Limpiamos el formulario invisible
if ($respuesta -eq "Yes") {
Write-Host "Sobrescribiendo..."
git tag -d $tagName 2>$null
git tag -a $tagName -m "Release version $version (Updated)"
git push origin
git push origin $tagName --force
Write-Host ">> Tag actualizado (Force Push)."
} else {
Write-Host "Conservando tag anterior..."
git push origin
Write-Host ">> Código subido."
}
} else {
# Tag Nuevo
git tag -a $tagName -m "Release version $version"
git push origin --follow-tags
Write-Host ">> Versión publicada."
}
Write-Host "----------------------------------------"

28
B4A/_juntaBas.ps1 Normal file
View File

@@ -0,0 +1,28 @@
# SCRIPT: _juntaBas.ps1 - Versión Saneada y Optimizada para LLM
$OutputFile="_CODIGO_COMPLETO_PARA_LLM.txt"
# Eliminar el archivo anterior si existe (IMPORTANTE)
Remove-Item -Path $OutputFile -ErrorAction SilentlyContinue
Write-Host "Iniciando fusion para LLM..."
# Itera sobre los archivos .bas, .b4a, .b4j
Get-ChildItem -Path ".\*" -Include @("*.bas", "*.b4a", "*.b4j") | ForEach-Object {
$currentFile = $_.Name
Write-Host "Procesando: $currentFile"
# --- ENCABEZADO ESTRUCTURADO Y COMENTADO EN B4X (Agregado al archivo) ---
Add-Content -Path $OutputFile -Value "`n'======================================================================================"
Add-Content -Path $OutputFile -Value $"// ARCHIVO_INICIO: ${currentFile}"
Add-Content -Path $OutputFile -Value "'======================================================================================`n"
# Vuelca el contenido del archivo
Get-Content -Encoding UTF8 -Path $_.FullName -Raw | Add-Content -Path $OutputFile
# --- DELIMITADOR DE FIN DE ARCHIVO (Agregado al archivo) ---
Add-Content -Path $OutputFile -Value "`n'======================================================================================"
Add-Content -Path $OutputFile -Value $"// ARCHIVO_FIN: ${currentFile}"
Add-Content -Path $OutputFile -Value "'======================================================================================`n"
}
Write-Host "`nProceso terminado. Se ha creado el archivo: $OutputFile"