This commit is contained in:
shoopea 2019-06-11 09:59:20 +08:00
parent 381e5f0345
commit a39b212a7b
4 changed files with 55 additions and 2 deletions

4
def.go
View File

@ -347,8 +347,8 @@ const (
objSubTypeJobSetJobDone = 607
objSubTypeJobMsgClient = 608
objSubTypeJobMsgRefresh = 609
objSubTypeJobExportBackup = 610
objSubTypeJobImportBackup = 611
objSubTypeJobBackupExport = 610
objSubTypeJobBackupImport = 611
objSubTypeItemResource = 701
objSubTypeItemAlch = 702
objSubTypeItemMisc = 703

46
job.go
View File

@ -412,3 +412,49 @@ func jobMsgClient(j Job) {
logOnError(err, "joMsgClient : setJobDone")
return
}
func jobBackupExport(j Job) {
var p JobPayloadBackupExport
err := setJobStart(j.ID64)
logOnError(err, "jobBackupExport : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobBackupExport : Unmarshal payload")
if err == nil {
m := TGCommand{
Type: commandReplyMsg,
Text: "Backup exported.",
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
}
TGCmdQueue <- m
}
err = setJobDone(j.ID64)
logOnError(err, "jobBackupExport : setJobDone")
return
}
func jobBackupImport(j Job) {
var p JobPayloadBackupImport
err := setJobStart(j.ID64)
logOnError(err, "jobBackupImport : setJobStart")
err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobBackupImport : Unmarshal payload")
if err == nil {
m := TGCommand{
Type: commandReplyMsg,
Text: "Backup imported.",
FromMsgID64: p.MsgID64,
FromChatID64: p.ChatID64,
}
TGCmdQueue <- m
}
err = setJobDone(j.ID64)
logOnError(err, "jobBackupImport : setJobDone")
return
}

2
sql.go
View File

@ -424,6 +424,8 @@ func initDB() {
,(` + strconv.Itoa(objSubTypeJobSetJobDone) + `, "job_set_done", "Set job as done job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobMsgClient) + `, "job_msg_client", "Send message via client", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobMsgRefresh) + `, "job_msg_refresh", "Refresh message from client", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobBackupExport) + `, "job_backup_export", "Export Backup", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobBackupImport) + `, "job_backup_import", "Import Backup", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeItemResource) + `, "item_res", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemAlch) + `, "item_alch", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemMisc) + `, "item_misc", "Time", ` + strconv.Itoa(objTypeItem) + `)

View File

@ -237,6 +237,11 @@ func JobWorker(id int, jobs <-chan Job) {
jobMsgClient(j)
case objSubTypeJobMsgRefresh:
jobMsgRefresh(j)
case objSubTypeJobBackupExport:
jobBackupExport(j)
case objSubTypeJobBackupImport:
jobBackupImport(j)
default:
log.Printf("jobWorker["+strconv.Itoa(id)+"] : No handler for job type #%d.\n", j.JobTypeID)
}