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)
|
}
|
|
}
|