| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- Option Compare Database
- Option Explicit
- Public Sub ImportAll()
- Dim db As DAO.Database
- Dim FSO As Object
- logger "ImportAll", "INFO", "Begin 'Import all sources'"
-
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set db = CurrentDb
- If Not FSO.FolderExists(source_dir()) Then
- logger "ImportAll", "CRITICAL", "No source found at:" & source_dir
- End If
- ' close any opened form or report, except OpenAccess's form
- Call CloseFormsReports
- ' import database properties
- Call ImportProperties(CurrentDb, joinpaths(source_dir, "database.properties"))
- Call ImportAllQueries
-
- Call ImportAllTblDefs
- Call ImportAllTableDatas
- Call ImportAllDataMacros
-
- Call ImportAllDocs(acForm)
-
- Call ImportAllDocs(acReport)
- Call ImportAllPrintVars
-
- Call ImportAllDocs(acMacro)
-
- Call ImportReferences
- Call ImportAllDocs(acModule)
-
- Call ImportAllRelations
- SaveProject
-
- logger "ImportAll", "INFO", "Import done"
- End Sub
- Public Sub ImportAllQueries()
- Dim dirpath, obj_name As String
- Dim filename As Variant
- Dim count, total As Integer
-
- dirpath = joinpaths(source_dir(), "queries\")
-
- logger "ImportAllQueries", "INFO", "Import queries"
- logger "ImportAllQueries", "DEBUG", "> import from: " & dirpath
- count = 0
- total = 0
-
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.bas")
- total = UBound(Split(to_import, "|")) + 1
-
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
-
- obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1)
- obj_name = to_accessname(obj_name)
-
- ImportDocument acQuery, obj_name, joinpaths(dirpath, filename)
-
- count = count + 1
- Call SysCmd(acSysCmdSetStatus, "Import query: " & count & " on " & total)
-
- filename = dir$()
- Next filename
-
- logger "ImportAllQueries", "INFO", "> " & count & " queries imported"
-
- Else
- logger "ImportAllQueries", "INFO", "> No query to import"
- End If
-
- Call SysCmd(acSysCmdClearStatus)
-
- End Sub
- Public Sub ImportAllTblDefs()
- Dim dirpath, obj_name As String
- Dim filename As Variant
- Dim count, total As Integer
-
- dirpath = joinpaths(source_dir(), "tbldefs\")
-
- logger "ImportAllTblDefs", "INFO", "Import table defs"
- logger "ImportAllTblDefs", "DEBUG", "> import from: " & dirpath
-
- count = 0
- total = 0
-
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.sql")
- total = UBound(Split(to_import, "|")) + 1
-
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
-
- obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1)
- obj_name = to_accessname(obj_name)
-
- ImportTableDef CStr(obj_name), dirpath
-
- count = count + 1
- Call SysCmd(acSysCmdSetStatus, "Import tabledef: " & count & " on " & total)
-
- Next filename
-
- logger "ImportAllTblDefs", "INFO", "> " & count & " TblDefs imported"
- Else
- logger "ImportAllTblDefs", "INFO", "> No tabledef to import"
- End If
-
- Call SysCmd(acSysCmdClearStatus)
-
- End Sub
- Public Sub ImportAllLinkedTables()
- Dim dirpath, obj_name As String
- Dim filename As Variant
- Dim count, total As Integer
-
- dirpath = joinpaths(source_dir(), "tbldef\")
-
- logger "ImportAllLinkedTables", "INFO", "Import linked tables"
- logger "ImportAllLinkedTables", "DEBUG", "> import from: " & dirpath
-
- count = 0
- total = 0
-
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.LNKD")
- total = UBound(Split(to_import, "|")) + 1
-
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
-
- obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1)
- obj_name = to_accessname(obj_name)
-
- ImportLinkedTable CStr(obj_name), dirpath
-
- count = count + 1
- Call SysCmd(acSysCmdSetStatus, "Import linked table: " & count & " on " & total)
-
- Next filename
-
- logger "ImportAllLinkedTables", "INFO", "> " & count & " Linked TblDefs imported"
- Else
- logger "ImportAllLinkedTables", "INFO", "> No linked table to import"
- End If
- Call SysCmd(acSysCmdClearStatus)
-
- End Sub
- Public Sub ImportAllTableDatas()
- Dim dirpath, obj_name As String
- Dim filename As Variant
- Dim count, total As Integer
-
- dirpath = joinpaths(source_dir(), "tables\")
-
- logger "ImportAllTableDatas", "INFO", "Import table datas"
- logger "ImportAllTableDatas", "DEBUG", "> import from: " & dirpath
-
- count = 0
- total = 0
-
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.txt")
- total = UBound(Split(to_import, "|")) + 1
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
-
- obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1)
- obj_name = to_accessname(obj_name)
-
- ImportTableData CStr(obj_name), dirpath
-
- count = count + 1
- Call SysCmd(acSysCmdSetStatus, "Import table data: " & count & " on " & total)
-
- Next filename
-
- logger "ImportAllTableDatas", "INFO", "> " & count & " table's data imported"
- Else
- logger "ImportAllTableDatas", "INFO", "> " & count & " table's data imported"
- End If
- Call SysCmd(acSysCmdClearStatus)
- End Sub
- Public Sub ImportAllDataMacros()
- Dim dirpath, obj_name As String
- Dim filename As Variant
- Dim count, total As Integer
-
- dirpath = joinpaths(source_dir(), "tbldef\")
-
- logger "ImportAllDataMacros", "INFO", "Import DataMacros"
- logger "ImportAllDataMacros", "DEBUG", "> import from: " & dirpath
-
- count = 0
- total = 0
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.xml")
- total = UBound(Split(to_import, "|")) + 1
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
-
- obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1)
- obj_name = to_accessname(obj_name)
- ImportDataMacros obj_name, dirpath
- Call SysCmd(acSysCmdSetStatus, "Import DataMacro: " & count & " on " & total)
-
- count = count + 1
-
- Next filename
-
- logger "ImportAllDataMacros", "INFO", "> " & count & " DataMacros imported"
- Else
- logger "ImportAllDataMacros", "INFO", "> " & count & " DataMacros imported"
- End If
- Call SysCmd(acSysCmdClearStatus)
-
- End Sub
- Public Sub ImportAllDocs(ByVal acType As Integer, Optional ByVal encoding = "utf-8")
- Dim doc_label As String
- Dim dirpath, obj_name As String
- Dim filename As Variant
- Dim count, total As Integer
-
- 'get the document's container's name from it's type
- doc_label = get_container_name(acType)
- If Len(doc_label) = 0 Then
- logger "ImportAllDocs", "CRITICAL", "acType " & acType & " is not recognized!"
- Exit Sub
- End If
-
- dirpath = joinpaths(source_dir(), doc_label & "\")
- logger "ImportAllDocs", "INFO", "# Import " & doc_label
- logger "ImportAllDocs", "DEBUG", "> import from: " & dirpath
- count = 0
- total = 0
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.bas")
- total = UBound(Split(to_import, "|")) + 1
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
-
- obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1)
- obj_name = to_accessname(obj_name)
-
- If IsNotVCS(obj_name) Then
-
- ImportDocument acType, obj_name, joinpaths(dirpath, filename)
- Else
- logger "ImportAllDocs", "WARNING", "Module " & obj_name & " could not be updated while running. Ensure latest version is included!"
- End If
-
- count = count + 1
- Call SysCmd(acSysCmdSetStatus, "Import " & doc_label & ": " & count & " on " & total)
-
- Next filename
-
- logger "ImportAllDocs", "INFO", "> " & count & " " & doc_label & " imported"
- Else
- logger "ImportAllDocs", "INFO", "> No " & doc_label & " to import"
- End If
- Call SysCmd(acSysCmdClearStatus)
- End Sub
- Public Sub ImportAllPrintVars()
- Dim dirpath, obj_name As String
- Dim filename As Variant
- Dim count, total As Integer
-
- dirpath = joinpaths(source_dir(), "reports\")
-
- logger "ImportAllPrintVars", "INFO", "Import Print Vars"
- logger "ImportAllPrintVars", "DEBUG", "> import from: " & dirpath
-
- count = 0
- total = 0
-
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.pv")
- total = UBound(Split(to_import, "|")) + 1
-
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
- obj_name = Mid$(filename, 1, InStrRev(filename, ".") - 1)
- obj_name = to_accessname(obj_name)
-
- ImportPrintVars obj_name, joinpaths(dirpath, filename)
-
- count = count + 1
- Call SysCmd(acSysCmdSetStatus, "Import Print Vars: " & count & " on " & total)
-
- Next filename
- logger "ImportAllPrintVars", "INFO", "> " & count & " Print Vars imported"
- Else
- logger "ImportAllPrintVars", "INFO", "> No Print Vars to import"
- End If
- Call SysCmd(acSysCmdClearStatus)
- End Sub
- Public Sub ImportAllRelations()
- Dim dirpath As String
- Dim filename As Variant
- Dim count, total As Integer
-
-
- dirpath = joinpaths(source_dir(), "relations\")
-
- logger "ImportAllRelations", "INFO", "Import Relations"
- logger "ImportAllRelations", "DEBUG", "> import from: " & dirpath
-
- count = 0
- total = 0
-
- Dim to_import As String
- to_import = list_files_in(dirpath, "*.txt")
- total = UBound(Split(to_import, "|")) + 1
-
- If Len(to_import) > 0 Then
- For Each filename In Split(to_import, "|")
-
- ImportRelation joinpaths(dirpath, filename)
-
- count = count + 1
- Call SysCmd(acSysCmdSetStatus, "Import relation: " & count & " on " & total)
-
- Next filename
-
- logger "ImportAllRelations", "INFO", "> " & count & " Relations imported"
- Else
- logger "ImportAllRelations", "INFO", "> No relation to import"
- End If
- Call SysCmd(acSysCmdClearStatus)
- End Sub
|