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=git&Args=pull '########################################################################################################### '###################### PUSH ############################################################# 'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\ '########################################################################################################### '###################### 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 '########################################################################################################### #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 Dim principal As C_principal Dim datos As c_datos Private b_iniciar As Button Private Contraseña As EditText Private Usuario As EditText Dim user As String Dim db As SQL Dim reqManager As DBRequestManager Public updateAvailable As C_UpdateAvailable Private p_configuracion As Panel Private p_adorno As Panel Private et_server As EditText Private lv_server As ListView Dim Logger As Boolean Private b_guarda_server As Button Public Provider As FileProvider Private l_version As Label 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") principal.Initialize B4XPages.AddPage("principal",principal) datos.Initialize B4XPages.AddPage("datos",datos) updateAvailable.Initialize B4XPages.AddPage("updateAvailable", updateAvailable) reqManager.Initialize(Me, Starter.DBReqServer) db.Initialize(Starter.rutaBD,"kmt.db",True) Provider.Initialize l_version.Text = Application.VersionName Subs.guardaAppInfo(db) End Sub Sub B4XPage_Appear If Starter.muestraProgreso = 1 Then muestraProgreso("Descargando actualización") Starter.muestraProgreso = 0 End If p_configuracion.Width = Root.Width p_configuracion.Height = Root.Height p_configuracion.Visible = False p_adorno.Width = Root.Width * 0.85 p_adorno.Height = Root.Height * 0.80 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) 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) ' Log(Location1.Latitude) End Sub 'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage. Private Sub b_iniciar_Click ' If Usuario.Text <> "" Then ' ' Dim cmd As DBCommand ' cmd.Initialize ' cmd.Name = "select_usuario_AREstrategicas" ' cmd.Parameters = Array As Object(Usuario.Text, Contraseña.Text) ' reqManager.ExecuteQuery(cmd , 0, "usuario") ' user = Usuario.Text ' Else ' MsgboxAsync("Llena los datos de acceso","Atención") '' B4XPages.ShowPage ("principal") ' End If B4XPages.ShowPage ("principal") Log(Starter.latitud & Starter.longitud) 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) 'Mod por CHV - 211110 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")) 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 Private Sub B4XPage_CloseRequest As ResumableSub If p_configuracion.Visible = True Then p_configuracion.Visible = False Else B4XPages.ShowPage("Mainpage") End If ' Return True Return False End Sub Private Sub ImageView5_Click p_configuracion.Visible = True lv_server.Clear lv_server.AddSingleLine("http://keymon.lat:1788") If Usuario.Text = "KMTS1" Then lv_server.AddSingleLine("http://11.0.0.196:1782") ' l_server.Text = Starter.server et_server.Text = Starter.DBReqServer l_version.Visible = False End Sub Private Sub p_configuracion_Click End Sub Private Sub lv_server_ItemClick (Position As Int, Value As Object) Starter.DBReqServer = Value ' l_server.Text = Value et_server.Text = Value Starter.reqManager.Initialize(Me, Value) Log(Value) ToastMessageShow("Servidor modificado", False) End Sub Private Sub b_guarda_server_Click Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("SERVER")) Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("SERVER",et_server.text)) Starter.DBReqServer = et_server.text Log("Inicializamos reqManager con " & Starter.DBReqServer) reqManager.Initialize(Me, Starter.DBReqServer) CallSubDelayed(Starter, "reinicializaReqManager") p_configuracion.Visible= False l_version.Visible = True End Sub Private Sub b_regresa_Click p_configuracion.Visible = False l_version.Visible = True End Sub Private Sub b_enviarbd_Click ' copiaDB ' Sleep(1000) Dim FileName As String = "kmt.db" 'copy the shared file to the shared folder Log("xxxxxx:"&Provider.SharedFolder) Sleep(1000) File.Copy(File.DirInternal, FileName, Provider.SharedFolder, FileName) Dim email As Email email.To.Add("soporte@keymonsoft.com") email.Subject = "Envio Base de dados Bagon" email.Attachments.Add(Provider.GetFileUri(FileName)) ' email.Attachments.Add(Provider.GetFileUri(FileName)) 'second attachment Dim in As Intent = email.GetIntent in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION StartActivity(in) End Sub Private Sub b_actualizar_app_Click StartService(appUpdater) End Sub ' appUpdater - Mostramos el anuncio de que se esta descargando el nuevo apk Sub muestraProgreso(mensaje As String) ProgressDialogShow(mensaje) End Sub ' ' appUpdater - Ocultamos el anuncio de que se esta descargando el nuevo apk Sub ocultaProgreso ProgressDialogHide End Sub