Created
April 15, 2020 20:17
-
-
Save bubnenkoff/fb201803460c6e2c430fe94b5ba2c5b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Recursive-Read: func [ | |
| "Recursively read Directory." | |
| Directory [file! url!] "The Directory to read." | |
| /local Files Subdirectory | |
| ] [ | |
| if exists? Directory [ | |
| Files: read Directory | |
| if block? Files [ | |
| foreach File Files [ | |
| if #"/" = last File [ | |
| Subdirectory: File | |
| foreach File read Directory/:Subdirectory [ | |
| append Files Directory/:Subdirectory/:File | |
| ] | |
| ] | |
| ] | |
| ] | |
| list-of-rules: collect [foreach f Files [if equal? suffix? f ".xml" [keep f ]]] | |
| foreach f list-of-rules [ | |
| if not find f "/" [ ; add full path for root folder files | |
| insert f Directory | |
| ] | |
| ] | |
| list-of-rules | |
| ] | |
| ] | |
| SQLite/do [ | |
| db1: open %test.db | |
| ] | |
| f-fields: [] | |
| append f-fields collect [loop 15 [keep [f-path: field 400x25 hint "path" f-type: field 150x25 hint "doc-type" f-status: field hint "status" return] ]] | |
| append f-fields [button "preview" button "next"] | |
| controls: [ | |
| button "Load from DB" | |
| f-dir-for-scan: field 400x25 hint "path" | |
| button "Load To DB" [ | |
| either not none? f-dir-for-scan/text | |
| [ | |
| either exists? normalize-dir to-red-file f-dir-for-scan/text | |
| [ | |
| xml-files: Recursive-Read normalize-dir to-red-file f-dir-for-scan/text | |
| either (length? xml-files) > 0 | |
| [ | |
| total-xml-count: length? xml-files | |
| processed-count: 0 | |
| foreach xml-file xml-files [ | |
| SQLite/do compose [ | |
| exec (rejoin [{INSERT INTO "xml_files" ("file_name" ) VALUES('} xml-file {');}]) | |
| ] | |
| processed-count: processed-count + 1 | |
| p/data: round to-percent processed-count * 100% / total-xml-count | |
| ] | |
| ] | |
| [ | |
| t/text: "No XML Files" | |
| ] | |
| ] | |
| [ | |
| t/text: "Dir not exists" | |
| ] | |
| ] | |
| [ | |
| t/text: "Specify dir" | |
| ] | |
| ] | |
| t: text | |
| return | |
| p: progress 700x10 | |
| ] | |
| view [ panel controls return panel f-fields ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment