summaryrefslogtreecommitdiff
path: root/sqlite.go
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-11-02 13:03:42 +0100
committerNikolaus Gotsche <n@softwarefools.com>2018-11-02 13:03:42 +0100
commit38cd567117fb2248a175f23cb8a736a988e3691c (patch)
treed9bba5d41b9c6126c5fa249b9175d1486d8d4ddd /sqlite.go
parent2a50cbb5ffd3f4fbc088bd18598980e0f142d7b7 (diff)
Full working import/export with TARing of the files
Diffstat (limited to 'sqlite.go')
-rw-r--r--sqlite.go35
1 files changed, 20 insertions, 15 deletions
diff --git a/sqlite.go b/sqlite.go
index cb772a0..e749a6b 100644
--- a/sqlite.go
+++ b/sqlite.go
@@ -472,7 +472,7 @@ func SaveTask(in Task) {
checkErr(err)
}
-// Loop through Array of []Projects and call SaveProject
+// Loop through Array of []Customers, []Projects and []Tasks, update new db ids and call their respected SaveFunctions
func SaveImportsToDB(cus []Customer, prs []Project, tsk []Task) {
boldGreen := color.New(color.FgGreen, color.Bold).SprintFunc()
var cusids, prids []IdMap
@@ -482,20 +482,25 @@ func SaveImportsToDB(cus []Customer, prs []Project, tsk []Task) {
fmt.Println(nli," Projects:",len(prs))
fmt.Println(nli," Tasks:",len(tsk))
fmt.Println(sub(""))
- for _,c := range cus {
- id := SaveCustomer(c)
- cusids=append(cusids,IdMap{c.Id,id})
- }
- fmt.Println(cusids)
- prs = ChangeCustomerIds(cusids,prs)
- for _,p := range prs {
- id := SaveProject(p)
- prids=append(prids,IdMap{p.Id,id})
- }
- fmt.Println(prids)
- tsk = ChangeProjectIds(prids,tsk)
- for _,t := range tsk {
- SaveTask(t)
+ if isInterSure(nli+" Are You sure to Import them all?") {
+ for _,c := range cus {
+ id := SaveCustomer(c)
+ cusids=append(cusids,IdMap{c.Id,id})
+ }
+ fmt.Println(cusids)
+ prs = ChangeCustomerIds(cusids,prs)
+ for _,p := range prs {
+ id := SaveProject(p)
+ prids=append(prids,IdMap{p.Id,id})
+ }
+ fmt.Println(prids)
+ tsk = ChangeProjectIds(prids,tsk)
+ for _,t := range tsk {
+ SaveTask(t)
+ }
+ fmt.Println(frame(posR(),false))
+ }else{
+ fmt.Println(frame(negR(),false))
}
}