mirror of
https://github.com/KeymonSoft/DBCheck.git
synced 2026-04-17 19:37:09 +00:00
...
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,3 @@
|
||||
**/Objects
|
||||
**/AutoBackups
|
||||
**/Objects/
|
||||
**/AutoBackups/
|
||||
*.meta
|
||||
@@ -3,19 +3,22 @@ File1=MainPage.bal
|
||||
FileGroup1=Default Group
|
||||
Group=Default Group
|
||||
Library1=b4xpages
|
||||
Library2=core
|
||||
Library3=okhttputils2
|
||||
Library4=randomaccessfile
|
||||
Library5=sql
|
||||
Library6=byteconverter
|
||||
Library2=byteconverter
|
||||
Library3=contentresolver
|
||||
Library4=core
|
||||
Library5=okhttputils2
|
||||
Library6=randomaccessfile
|
||||
Library7=sql
|
||||
Library8=appupdating
|
||||
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="31"/>~\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~'End of default text.~\n~~\n~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~AddPermission(android.permission.INTERNET)~\n~AddPermission(android.permission.READ_EXTERNAL_STORAGE)~\n~AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)~\n~SetApplicationAttribute(android:allowBackup, "false")~\n~~\n~AddActivityText(main,~\n~<intent-filter>~\n~<action android:name="android.intent.action.VIEW" />~\n~<category android:name="android.intent.category.DEFAULT" />~\n~<data android:mimeType="application/octet-stream" />~\n~</intent-filter>)
|
||||
Module1=|relative|..\B4XMainPage
|
||||
Module2=DBRequestManager
|
||||
Module3=Starter
|
||||
Module4=Subs
|
||||
Module3=FileHandler
|
||||
Module4=Starter
|
||||
Module5=Subs
|
||||
NumberOfFiles=1
|
||||
NumberOfLibraries=6
|
||||
NumberOfModules=4
|
||||
NumberOfLibraries=8
|
||||
NumberOfModules=5
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
|
||||
@@ -3,16 +3,19 @@ ModuleBookmarks1=
|
||||
ModuleBookmarks2=
|
||||
ModuleBookmarks3=
|
||||
ModuleBookmarks4=
|
||||
ModuleBookmarks5=
|
||||
ModuleBreakpoints0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleBreakpoints2=
|
||||
ModuleBreakpoints3=
|
||||
ModuleBreakpoints4=
|
||||
ModuleBreakpoints5=
|
||||
ModuleClosedNodes0=2,6
|
||||
ModuleClosedNodes1=
|
||||
ModuleClosedNodes1=2
|
||||
ModuleClosedNodes2=
|
||||
ModuleClosedNodes3=1
|
||||
ModuleClosedNodes4=
|
||||
NavigationStack=B4XMainPage,l_ruta2_LongClick,377,6,B4XMainPage,B4XPage_CloseRequest,375,0,B4XMainPage,b_guardaRuta_Click,392,5,B4XMainPage,JobDone,368,0,B4XMainPage,b_enviar_Click,125,0,Visual Designer,MainPage.bal,-100,6,B4XMainPage,B4XPage_Appear,109,0,Subs,panelOculto,91,0,B4XMainPage,Class_Globals,13,0,Subs,dameDiaSemana,139,0
|
||||
ModuleClosedNodes3=
|
||||
ModuleClosedNodes4=1
|
||||
ModuleClosedNodes5=
|
||||
NavigationStack=B4XMainPage,b_enviar_Click,158,0,B4XMainPage,JobDone,368,0,Subs,panelOculto,91,0,Subs,dameDiaSemana,139,0,B4XMainPage,B4XPage_CloseRequest,375,0,B4XMainPage,B4XPage_Created,51,6,Visual Designer,MainPage.bal,-100,6,B4XMainPage,Class_Globals,7,5,B4XMainPage,B4XPage_Appear,95,6,B4XMainPage,b_cargarBD_Click,398,2
|
||||
SelectedBuild=0
|
||||
VisibleModules=1,4
|
||||
VisibleModules=1,5,3
|
||||
|
||||
163
B4A/FileHandler.bas
Normal file
163
B4A/FileHandler.bas
Normal file
@@ -0,0 +1,163 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11
|
||||
@EndOfDesignText@
|
||||
'Requiere la librería "ContentResolver" y "AppUpdating"
|
||||
'
|
||||
'Copiar este codigo al boton_Click que se quiere que importe la base de datos.
|
||||
'
|
||||
' Private Sub b_importarBD_Click
|
||||
' Private FH As FileHandler
|
||||
' FH.Initialize
|
||||
' Wait For (FH.Load) Complete (Result As LoadResult) 'Abre un fileManager para seleccionar la base de datos a importar.
|
||||
' File.Copy(Result.Dir, Result.FileName, File.DirInternal, "kmt.db") 'Copia la base de datos seleccionada al directorio interno.
|
||||
' Starter.skmt.Initialize(Starter.ruta,"kmt.db", True) 'Reiniciliza la base de datos con la recien importada.
|
||||
' ToastMessageShow("¡BD importada!", False)
|
||||
' End Sub
|
||||
|
||||
Sub Class_Globals
|
||||
#if B4A
|
||||
Private ion As Object
|
||||
Private OldIntent As Intent
|
||||
#end if
|
||||
Type LoadResult (Success As Boolean, Dir As String, FileName As String, RealName As String, Size As Long, Modified As Long, MimeType As String)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize
|
||||
|
||||
End Sub
|
||||
|
||||
#if B4A
|
||||
Public Sub SaveAs (Source As InputStream, MimeType As String, Title As String) As ResumableSub
|
||||
Dim intent As Intent
|
||||
intent.Initialize("android.intent.action.CREATE_DOCUMENT", "")
|
||||
intent.AddCategory("android.intent.category.OPENABLE")
|
||||
intent.PutExtra("android.intent.extra.TITLE", Title)
|
||||
intent.SetType(MimeType)
|
||||
StartActivityForResult(intent)
|
||||
Wait For ion_Event (MethodName As String, Args() As Object)
|
||||
If -1 = Args(0) Then 'resultCode = RESULT_OK
|
||||
Dim result As Intent = Args(1)
|
||||
Dim jo As JavaObject = result
|
||||
Dim ctxt As JavaObject
|
||||
Dim out As OutputStream = ctxt.InitializeContext.RunMethodJO("getContentResolver", Null).RunMethod("openOutputStream", Array(jo.RunMethod("getData", Null)))
|
||||
File.Copy2(Source, out)
|
||||
out.Close
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Public Sub Load As ResumableSub
|
||||
Dim cc As ContentChooser
|
||||
cc.Initialize("cc")
|
||||
cc.Show("application/octet-stream", "Choose text file")
|
||||
Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
|
||||
Log($"***************************${CRLF}${Dir}${CRLF} ${FileName}"$)
|
||||
Dim res As LoadResult = CreateLoadResult(Success, Dir, FileName)
|
||||
Log($"***************************${CRLF}${res.FileName}${CRLF} ${res}"$)
|
||||
If res.Success Then ExtractInformationFromURI(res.FileName, res)
|
||||
Return res
|
||||
End Sub
|
||||
|
||||
Private Sub StartActivityForResult(i As Intent)
|
||||
Dim jo As JavaObject = GetBA
|
||||
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
|
||||
jo.RunMethod("startActivityForResult", Array(ion, i))
|
||||
End Sub
|
||||
|
||||
Private Sub GetBA As Object
|
||||
Return Me.As(JavaObject).RunMethod("getBA", Null)
|
||||
End Sub
|
||||
|
||||
Private Sub ExtractInformationFromURI (Uri As String, res As LoadResult)
|
||||
Try
|
||||
|
||||
Dim resolver As ContentResolver
|
||||
resolver.Initialize("")
|
||||
Dim u As Uri
|
||||
u.Parse(Uri)
|
||||
Dim rs As ResultSet = resolver.Query(u, Null, "", Null, "")
|
||||
If rs.NextRow Then
|
||||
Dim columns As B4XSet = B4XCollections.CreateSet
|
||||
For i = 0 To rs.ColumnCount - 1
|
||||
columns.Add(rs.GetColumnName(i))
|
||||
Next
|
||||
If columns.Contains("_display_name") Then res.RealName = rs.GetString("_display_name")
|
||||
If columns.Contains("_size") Then res.Size = rs.GetLong("_size")
|
||||
If columns.Contains("last_modified") Then res.Modified = rs.GetLong("last_modified")
|
||||
If columns.Contains("mime_type") Then res.MimeType = rs.GetString("mime_type")
|
||||
End If
|
||||
rs.Close
|
||||
|
||||
Catch
|
||||
Log("error extracting information from file provider")
|
||||
Log(LastException)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub CheckForReceivedFiles As LoadResult
|
||||
Dim Activity As Activity = B4XPages.GetNativeParent(B4XPages.MainPage)
|
||||
If IsRelevantIntent(Activity.GetStartingIntent) Then
|
||||
Dim in As Intent = Activity.GetStartingIntent
|
||||
Dim uri As String
|
||||
If in.HasExtra("android.intent.extra.STREAM") Then
|
||||
uri = in.As(JavaObject).RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM"))
|
||||
Else
|
||||
uri = in.GetData
|
||||
End If
|
||||
Dim res As LoadResult = CreateLoadResult(True, "ContentDir", uri)
|
||||
ExtractInformationFromURI(res.FileName, res)
|
||||
Return res
|
||||
End If
|
||||
Return CreateLoadResult(False, "", "")
|
||||
End Sub
|
||||
|
||||
Private Sub IsRelevantIntent(in As Intent) As Boolean
|
||||
If in.IsInitialized And in <> OldIntent And in.Action = in.ACTION_VIEW Then
|
||||
OldIntent = in
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
#else if B4i
|
||||
Public Sub SaveAs(ParentPage As Object, AnchorView As Object, Text As String) As ResumableSub
|
||||
Dim avc As ActivityViewController
|
||||
avc.Initialize("avc", Array(Text))
|
||||
avc.Show(B4XPages.GetNativeParent(ParentPage), AnchorView)
|
||||
Wait For avc_Complete (Success As Boolean, ActivityType As String)
|
||||
Return Success
|
||||
End Sub
|
||||
|
||||
Public Sub Load (ParentPage As Object, AnchorView As Object) As ResumableSub
|
||||
Dim DocumentPicker As DocumentPickerViewController
|
||||
DocumentPicker.InitializeImport("picker", Array("public.text"))
|
||||
DocumentPicker.Show(B4XPages.GetNativeParent(ParentPage), AnchorView)
|
||||
Wait For Picker_Complete (Success As Boolean, URLs As List)
|
||||
If Success And URLs.Size > 0 Then
|
||||
Return UrlToLoadResult(URLs.Get(0))
|
||||
End If
|
||||
Return CreateLoadResult(False, "", "")
|
||||
End Sub
|
||||
|
||||
Public Sub UrlToLoadResult(url As String) As LoadResult
|
||||
Dim res As LoadResult = CreateLoadResult(IIf(File.Exists(url, ""), True, False), url, "")
|
||||
res.RealName = res.Dir.SubString(res.Dir.LastIndexOf("/") + 1)
|
||||
res.Size = File.Size(res.Dir, "")
|
||||
Return res
|
||||
End Sub
|
||||
#end if
|
||||
|
||||
Private Sub CreateLoadResult (Success As Boolean, Dir As String, FileName As String) As LoadResult
|
||||
Dim t1 As LoadResult
|
||||
t1.Initialize
|
||||
t1.Success = Success
|
||||
t1.Dir = Dir
|
||||
t1.FileName = FileName
|
||||
Return t1
|
||||
End Sub
|
||||
|
||||
Binary file not shown.
@@ -56,5 +56,13 @@
|
||||
android:name=".httputils2service$httputils2service_BR"
|
||||
android:exported="true">
|
||||
</receiver>
|
||||
<service
|
||||
android:name=".newinst2"
|
||||
android:exported="true">
|
||||
</service>
|
||||
<receiver
|
||||
android:name=".newinst2$newinst2_BR"
|
||||
android:exported="true">
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -7,11 +7,10 @@ Version=9.85
|
||||
#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
|
||||
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
|
||||
'Ctrl + click to sync files con Github Desktop 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
|
||||
@@ -39,6 +38,11 @@ Sub Class_Globals
|
||||
Private l_progressDialog As Label
|
||||
Private p_editaRuta As Panel
|
||||
Private p_editaAlmacen As Panel
|
||||
Private b_cargarBD As Button
|
||||
Private p_datos As Panel
|
||||
Private p_principal As Panel
|
||||
Private l_appInfo As Label
|
||||
Dim empresa, appVersion As String
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize
|
||||
@@ -49,8 +53,11 @@ End Sub
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
Root.LoadLayout("MainPage")
|
||||
p_principal.Width = Root.Width
|
||||
p_principal.Height = Root.Height
|
||||
Subs.centraPanel(p_datos, Root.Width)
|
||||
reqManager.Initialize(Me, "http://187.189.244.154:1782")
|
||||
B4XPages.SetTitle(Me, "Mariana revisión de BD")
|
||||
B4XPages.SetTitle(Me, "Revisión de BD")
|
||||
Subs.centraPanel(p_progressDialog, Root.Width)
|
||||
Subs.centraPanel(p_editaRuta, Root.Width)
|
||||
Subs.centraPanel(p_editaAlmacen, Root.Width)
|
||||
@@ -86,14 +93,25 @@ Sub B4XPage_Appear
|
||||
Log($"Existe BD: ${File.Exists(File.DirInternal, "kmt.db") }"$)
|
||||
If File.Exists(File.DirInternal, "kmt.db") Then
|
||||
If Not(skmt.IsInitialized) Then skmt.Initialize(File.DirInternal,"kmt.db", True)
|
||||
Dim ai As Cursor = skmt.ExecQuery($"select CAT_VA_DESCRIPCION, CAT_VA_VALOR from cat_variables where CAT_VA_DESCRIPCION = 'EMPRESA' or CAT_VA_DESCRIPCION = 'APP_VERSION'"$)
|
||||
If ai.RowCount > 1 Then
|
||||
For i = 0 To ai.RowCount -1
|
||||
ai.Position = i
|
||||
If ai.GetString("CAT_VA_DESCRIPCION") = "EMPRESA" Then empresa = ai.GetString("CAT_VA_VALOR")
|
||||
If ai.GetString("CAT_VA_DESCRIPCION") = "APP_VERSION" Then appVersion = ai.GetString("CAT_VA_VALOR")
|
||||
Next
|
||||
l_appInfo.Text = $"${empresa} ${appVersion}"$
|
||||
End If
|
||||
Dim c As Cursor = skmt.ExecQuery($"select count(distinct pe_cliente) as pedidos, group_concat(distinct substr(pe_fecha, 4,2)) as diasVenta, sum(pe_costo_tot) as total, (select PE_CANT from pedido where PE_CANT = 0) as cantsEnCero, (select count(PE_CLIENTE) from pedido where printf("%d", PE_CLIENTE) <> PE_CLIENTE ) as clienteNoNumerico from pedido"$)
|
||||
Log(c.RowCount)
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
l_pedidos2.Text = c.GetString("pedidos")
|
||||
l_diasVenta.Text = c.GetString("diasVenta")
|
||||
l_totalVenta.Text = "$" & NumberFormat2(c.GetString("total"), 1, 2, 2, True)
|
||||
l_cantsEnCero.Text = c.GetString("cantsEnCero")
|
||||
l_diasVenta.Text = "N/A"
|
||||
If c.GetString("diasVenta") <> Null Then l_diasVenta.Text = c.GetString("diasVenta")
|
||||
If c.GetString("total") <> Null Then l_totalVenta.Text = "$" & NumberFormat2(c.GetString("total"), 1, 2, 2, True) Else l_totalVenta.Text = "0"
|
||||
l_cantsEnCero.Text = "0"
|
||||
If c.GetString("cantsEnCero") <> Null Then l_cantsEnCero.Text = c.GetString("cantsEnCero")
|
||||
l_clienteNoNumerico.Text = c.GetString("clienteNoNumerico")
|
||||
End If
|
||||
Dim c As Cursor = skmt.ExecQuery("select pe_ruta from pedido")
|
||||
@@ -380,6 +398,15 @@ Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Private Sub b_cargarBD_Click
|
||||
Private FH As FileHandler
|
||||
FH.Initialize
|
||||
Wait For (FH.Load) Complete (Result As LoadResult) 'Abre un fileManager para seleccionar la base de datos a importar.
|
||||
File.Copy(Result.Dir, Result.FileName, File.DirInternal, "kmt.db") 'Copia la base de datos seleccionada al directorio interno.
|
||||
skmt.Initialize(File.DirInternal,"kmt.db", True) 'Reiniciliza la base de datos con la recien importada.
|
||||
ToastMessageShow("¡BD importada!", False)
|
||||
End Sub
|
||||
|
||||
Private Sub l_ruta2_LongClick
|
||||
p_editaRuta.Top = l_ruta2.top
|
||||
p_editaRuta.Visible = True
|
||||
|
||||
Reference in New Issue
Block a user