lizhanwei
2020-03-12 558c2b293637494eb3887a99b3e3d461210b0777
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package safeluck.drive.evaluation.DB.exam_status
 
import android.content.Context
import android.util.Log
import androidx.work.Data
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.anyun.exam.lib.AYSdk
import com.anyun.exam.lib.MyLog
import org.json.JSONException
import org.json.JSONObject
import safeluck.drive.evaluation.DB.Constant
import safeluck.drive.evaluation.DB.WorkRoomDataBase
 
class ExamStatusOutWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
    val TAG:String = "ExamStatusOutWorker"
    override fun doWork(): Result {
        val examType =WorkRoomDataBase.getWorkRoomDataBase(applicationContext).examStatusDao.startExamInt;
        MyLog.i("查到的考试type="+examType)
        val data = Data.Builder().putInt(Constant.EXAM_STATUS_TYPE,examType).build()
        if (examType != safeluck.drive.evaluation.Constant.NONE_BEEN_START_EXAM) {
            try {
                val jsonObject = JSONObject()
                jsonObject.put("exam", 1)
                jsonObject.put("type", examType)
                val examJson = jsonObject.toString()
                AYSdk.getInstance().sendCmd(safeluck.drive.evaluation.Constant.EXAM_STATUS, examJson)
            } catch (e: JSONException) {
                e.printStackTrace()
            }
        }
        return Result.success(data)
    }
 
}