mirror of
https://github.com/KeymonSoft/Guna_Reparto_Imp.git
synced 2026-04-20 06:09:19 +00:00
v. 5.08.31
This commit is contained in:
58
B4A/Subs.bas
58
B4A/Subs.bas
@@ -19,6 +19,8 @@ Sub Process_Globals
|
||||
Dim rutaMaxPoints As Int = 3000
|
||||
Dim rutaHrsAtras As Int = 48
|
||||
' Dim rutaInicioHoy As String = ""
|
||||
Dim in As Intent
|
||||
Dim intentUsado As Boolean = False
|
||||
End Sub
|
||||
|
||||
'Pone el valor de phn.Model en la variable global "devModel"
|
||||
@@ -41,6 +43,62 @@ Sub getPhnId As String 'ignore
|
||||
Return devModel
|
||||
End Sub
|
||||
|
||||
' Se revisa si hay una intención (intent) de abrir una base de datos y si es así, entonces se importa esa base de datos.
|
||||
Sub importaBDDesdeWhatsApp
|
||||
' Private tmpBDWA As Boolean = traeUsarIntentBDWA
|
||||
Log("Revisamos intent de importar desde whatsapp")
|
||||
Log(B4XPages.MainPage.intentUsado)
|
||||
Log(in)
|
||||
If Not(in.IsInitialized) Then in = B4XPages.GetNativeParent(B4XPages.MainPage).GetStartingIntent ' Si se usa esta funcion en Mainpage, se pone "Me" en lugar de B4XPages.MainPage.
|
||||
If Not(B4XPages.MainPage.intentUsado) And in <> Null Then
|
||||
' Log(in)
|
||||
LogColor("Importamos base de datos desde Whatsapp.", Colors.blue)
|
||||
B4XPages.MainPage.intentUsado = True
|
||||
' Log(in.As(String))
|
||||
If in.GetData <> Null Then
|
||||
Dim XmlData As String
|
||||
XmlData = in.GetData
|
||||
Try
|
||||
Dim OutStr As OutputStream = File.OpenOutput(File.DirInternal,"kmt.db",False)
|
||||
Dim InStr As InputStream = File.OpenInput("ContentDir",XmlData)
|
||||
File.Copy2(InStr,OutStr)
|
||||
LogColor("BD copiada a interna.", Colors.Blue)
|
||||
OutStr.Close
|
||||
If in.As(String).Contains("whatsapp") Then ToastMessageShow("BD cargada desde Whatsapp", False)
|
||||
Catch
|
||||
Log(LastException)
|
||||
End Try
|
||||
' ExitApplication
|
||||
' Starter.skmt.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'")
|
||||
' Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('IMPORTAR_BD_WA', '${tmpBDWA}')"$)
|
||||
Private a As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'APP_NAME'"$)
|
||||
If a.RowCount > 0 Then
|
||||
a.Position = 0
|
||||
ToastMessageShow($"BD de "${a.GetString("CAT_VA_VALOR")}" cargada."$, True)
|
||||
End If
|
||||
a = Starter.skmt.ExecQuery($"select * from usuarioa"$)
|
||||
If a.RowCount > 0 Then
|
||||
a.Position = 0
|
||||
B4XPages.MainPage.user.Text = a.GetString("USUARIO")
|
||||
B4XPages.MainPage.pass.Text = a.GetString("PASS")
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Regresa si se debe de usar el intent de importar la base d datos desde Whatsapp.
|
||||
Sub traeUsarIntentBDWA As Boolean 'ignore
|
||||
Private BDWA As Boolean = False
|
||||
Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'"$)
|
||||
If x.RowCount > 0 Then
|
||||
x.Position = 0
|
||||
If x.GetString("CAT_VA_VALOR") = "true" Then BDWA = True
|
||||
End If
|
||||
' Log($"cb_importarBDWA = ${BDWA}"$)
|
||||
Return BDWA
|
||||
End Sub
|
||||
|
||||
|
||||
'Comprime y regresa un texto (str) en base64
|
||||
Sub compress(str As String) As String 'ignore
|
||||
'Requiere la libreria "CompressStrings"
|
||||
|
||||
Reference in New Issue
Block a user