feat 2factor refs #7775
This commit is contained in:
parent
3cc2717a90
commit
cdc5ebcd57
|
@ -21,11 +21,12 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
|||
onSuccess(response)
|
||||
} else {
|
||||
try {
|
||||
val errorBodyString = response.errorBody()?.string()
|
||||
if (response.code() == 555) {
|
||||
var message = JSONObject(response.message()).getString("Message")
|
||||
onError(Error(message))
|
||||
} else if (response.code() == 401) {
|
||||
if (!(context as MobileApplication).isLoginRunning()){
|
||||
if (!(context as MobileApplication).isLoginRunning()) {
|
||||
val intent = Intent(context, LoginActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent)
|
||||
|
@ -34,9 +35,7 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
|||
onError(Error(response.message().toString()))
|
||||
}
|
||||
} else {
|
||||
|
||||
onError(Error(errorSalixMessage(response)))
|
||||
// onError(Error(response.message().toString()))
|
||||
onError(Error(errorSalixMessage(response, errorBodyString)))
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
defaultErrorHandler(t)
|
||||
|
@ -71,30 +70,18 @@ abstract class SalixCallback<T>(val context: Context) : Callback<T> {
|
|||
throw t
|
||||
}
|
||||
|
||||
/* fun isActivityRunning(context: Context, activityClass: Class<*>): Boolean {
|
||||
val packageName = context.packageName
|
||||
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
val runningActivities = activityManager.getRunningTasks(Int.MAX_VALUE)
|
||||
|
||||
for (taskInfo in runningActivities) {
|
||||
if (taskInfo.baseActivity?.className == activityClass.name && taskInfo.topActivity?.packageName == packageName) {
|
||||
return true
|
||||
}
|
||||
private fun errorSalixMessage(response: Response<T>, errorBody: String?): String {
|
||||
val myErrorCodeBody = errorBody?.let { errorBodyString
|
||||
->
|
||||
JSONObject(errorBodyString).getJSONObject("error").getString("code")
|
||||
}
|
||||
|
||||
return false
|
||||
}*/
|
||||
|
||||
private fun errorSalixMessage(response: Response<T>): String {
|
||||
|
||||
val messageResponse = response.errorBody()!!.string()
|
||||
return try {
|
||||
|
||||
val messageResponse = response.errorBody()!!.string()
|
||||
val jsonObject = Gson().fromJson(messageResponse, JsonObject::class.java)
|
||||
jsonObject?.getAsJsonObject("error")?.get("message")?.asString.toString()
|
||||
|
||||
var messageJson = jsonObject?.getAsJsonObject("error")?.get("message")?.asString
|
||||
messageJson ?: "${response.message()}.$myErrorCodeBody"
|
||||
} catch (ex: Exception) {
|
||||
response.message()
|
||||
response.message() + ".$myErrorCodeBody"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,6 +98,13 @@ interface SalixService {
|
|||
@Body params: LoginSalixVO
|
||||
): Call<LoginSalixVO>
|
||||
|
||||
@POST("VnUsers/validate-auth")
|
||||
fun validateAuth(
|
||||
@Query("user") user: Any,
|
||||
@Query("password") password: Any,
|
||||
@Query("code") code: Any
|
||||
): Call<LoginSalixVO>
|
||||
|
||||
@POST("Accounts/loginApp")
|
||||
fun loginApp(
|
||||
@Body params: LoginApp
|
||||
|
@ -201,7 +208,7 @@ interface SalixService {
|
|||
@Query("params") params: Any? = null
|
||||
): Call<Any>
|
||||
|
||||
@POST("Applications/itemShelvingSale_addBySectorCollection/execute-proc") // PERMISOS GRANT
|
||||
@POST("Applications/itemShelvingSale_addBySectorCollection/execute-proc")
|
||||
fun getReserveBySectorCollection(
|
||||
@Query("schema") schema: String = "vn",
|
||||
@Query("params") params: Any? = null
|
||||
|
@ -243,7 +250,7 @@ interface SalixService {
|
|||
@POST("TicketObservations/upsertWithWhere")
|
||||
fun updateNoteFromDropOff(
|
||||
@Query("where") where: Any? = null,
|
||||
@Body params: Any //description
|
||||
@Body params: Any
|
||||
): Call<Any>
|
||||
|
||||
@POST("TicketObservations/addDropOff")
|
||||
|
@ -331,7 +338,7 @@ interface SalixService {
|
|||
@Query("filter") filter: Any?,
|
||||
): Call<List<ItemExpeditionTruckSalix>>
|
||||
|
||||
@GET("Printers")//NO SALIX
|
||||
@GET("Printers")
|
||||
fun getprinters(
|
||||
@Query("filter") filter: Any?
|
||||
):
|
||||
|
@ -374,7 +381,7 @@ interface SalixService {
|
|||
):
|
||||
Call<Any>
|
||||
|
||||
@GET("Sales/getFromSectorCollection")//NO SALIX
|
||||
@GET("Sales/getFromSectorCollection")
|
||||
fun sectorCollectionGetSale(
|
||||
@Query("sectorFk") sectorFk: Int,
|
||||
@Query("sectorCollectionFk") sectorCollectionFk: Int,
|
||||
|
@ -465,7 +472,7 @@ interface SalixService {
|
|||
):
|
||||
Call<VersionApp>
|
||||
|
||||
@GET("Items/get")//NO SALIX
|
||||
@GET("Items/get")
|
||||
fun getCard(
|
||||
@Query("barcode") barcode: Number,
|
||||
@Query("warehouseFk") warehouseFk: Int
|
||||
|
@ -694,13 +701,6 @@ interface SalixService {
|
|||
@Query("params") params: Any,
|
||||
): Call<Any>
|
||||
|
||||
/* @POST("Applications/itemShelvingLog_get/execute-proc")
|
||||
fun itemShelvingLogGet(
|
||||
@Query("schema") schema: String = "vn",
|
||||
@Query("params") params: Any,
|
||||
): Call<List<ItemShelvingLog>>*/
|
||||
|
||||
//Tarea 7168
|
||||
@GET("ItemShelvingLogs")
|
||||
fun itemShelvingLogGet(
|
||||
@Query("filter") filter: String,
|
||||
|
@ -744,7 +744,7 @@ interface SalixService {
|
|||
Call<List<ItemDetails>>
|
||||
|
||||
@POST("Applications/expedition_getState/execute-proc")
|
||||
fun expedition_getState(
|
||||
fun expeditionGetState(
|
||||
@Query("schema") schema: String = "vn",
|
||||
@Query("params") params: Any,
|
||||
): Call<ArrayList<JsonObject>>
|
||||
|
@ -768,7 +768,7 @@ interface SalixService {
|
|||
): Call<Any>
|
||||
|
||||
@POST("Applications/buffer_setTypeByName/execute-proc")
|
||||
fun buffer_setTypeByName(
|
||||
fun bufferSetTypeByName(
|
||||
@Query("schema") schema: String = "srt",
|
||||
@Query("params") params: Any
|
||||
): Call<List<JsonObject>>
|
||||
|
@ -789,10 +789,6 @@ interface SalixService {
|
|||
@Body params: Any
|
||||
): Call<CollectionTicket>
|
||||
|
||||
@GET("collections/sectorCollection_get")
|
||||
fun sectorCollection_get(
|
||||
): Call<List<CollectionVO>>
|
||||
|
||||
@POST("collections/setSaleQuantity")
|
||||
fun collectionIncreaseQuantitySalix(
|
||||
@Body params: SalixSaleQuantity
|
||||
|
@ -837,9 +833,8 @@ interface SalixService {
|
|||
):
|
||||
Call<EntrySalix>
|
||||
|
||||
|
||||
@GET("Departments")
|
||||
fun department_getHasMistake(
|
||||
fun departmentGetHasMistake(
|
||||
@Query("filter") filter: String = """{"fields": {"id": true,"name": true},"where": {"hasToMistake": true}}"""
|
||||
): Call<List<DepartmentMistake>>
|
||||
|
||||
|
@ -859,16 +854,10 @@ interface SalixService {
|
|||
): Call<Any>
|
||||
|
||||
@GET("Workers/{idWorker}/sip")
|
||||
fun sip_getExtension(
|
||||
fun sipGetExtension(
|
||||
@Path("idWorker") idWorker: Int,
|
||||
): Call<Any>
|
||||
|
||||
@PATCH("Items/{itemFk}")
|
||||
fun update_ItemPackingType(
|
||||
@Path("itemFk") itemFk: String,
|
||||
@Body params: Any
|
||||
): Call<Any>
|
||||
|
||||
@PATCH("Items/{itemFk}")
|
||||
fun updateItem(
|
||||
@Path("itemFk") itemFk: Int,
|
||||
|
@ -903,7 +892,7 @@ interface SalixService {
|
|||
): Call<Any>
|
||||
|
||||
@GET("ItemPackingTypes")
|
||||
fun get_ItemPackingType(
|
||||
fun getItemPackingType(
|
||||
@Query("filter") filter: String = """{"where": {"isActive": true}}"""
|
||||
): Call<List<ItemPackingType>>
|
||||
|
||||
|
@ -941,7 +930,7 @@ interface SalixService {
|
|||
): Call<List<StopMapTruckPallet>>
|
||||
|
||||
@POST("PackingSiteAdvanceds")
|
||||
fun ticket_advancePackaging(
|
||||
fun ticketAdvancePackaging(
|
||||
@Body parms: PackingSiteSalix
|
||||
): Call<Unit>
|
||||
|
||||
|
@ -963,33 +952,10 @@ interface SalixService {
|
|||
|
||||
@GET("Suppliers")
|
||||
fun getSuppliers(
|
||||
//@Query("filter") filter:String="""{"fields":{"id":true,"name":true}}"""
|
||||
//@Body params:JSONObject=JSONObject("""filter"={"fields":{"id":true,"name":true},"include":[{"relation":"contacts","scope":{"fields":["email"],"order":"id DESC","limit":1,"where":{"email":{"neq":null}}}}]}""")
|
||||
@Query("filter") filter: String = """{"fields":{"id":true,"name":true},"order":"name ASC","where":{"isActive":1,"name":{"neq":null}}, "include":[{"relation":"contacts","scope":{"fields":["email"],"where":{"email":{"neq":null}}}}]}"""
|
||||
/* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
|
||||
"\"scope\":{" +
|
||||
"\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," +
|
||||
"\"where\":{ \"email\":{\"neq\":null } }}}]})"*/
|
||||
//@Query("filter") filter:String? = """""\"order\":\"name DESC\""""
|
||||
|
||||
): Call<List<Supplier>>
|
||||
|
||||
/* fun getEntries(
|
||||
//@Body params:JSONObject=JSONObject("""filter"={"fields":{"id":true,"name":true},"include":[{"relation":"contacts","scope":{"fields":["email"],"order":"id DESC","limit":1,"where":{"email":{"neq":null}}}}]}""")
|
||||
*//* @Query("filter") filter:String="{\"fields\":{\"id\":true,\"name\":true},\"include\":[{\"relation\":\"contacts\"," +
|
||||
"\"scope\":{" +
|
||||
"\"fields\":[\"email\"],\"order\":\"id DESC\",\"limit\":1," +
|
||||
"\"where\":{ \"email\":{\"neq\":null } }}}]})"*//*
|
||||
|
||||
):
|
||||
Call<List<EntrySalix>>*/
|
||||
|
||||
@PUT("Entries")
|
||||
fun Entries(
|
||||
@Body supplier: Any
|
||||
):
|
||||
Call<List<EntrySalix>>
|
||||
|
||||
@GET("Entries")
|
||||
fun getEntriesFromSupplier(
|
||||
@Query("filter") filter: String
|
||||
|
@ -997,20 +963,20 @@ interface SalixService {
|
|||
Call<List<EntrySalix>>
|
||||
|
||||
@GET("Entries")
|
||||
fun add_entry(
|
||||
fun addEntry(
|
||||
@Body entry: EntrySalix
|
||||
):
|
||||
Call<EntrySalix>
|
||||
|
||||
@PATCH("Entries/{entryId}")
|
||||
fun entry_updateObserv(
|
||||
fun entryUpdateObserv(
|
||||
@Path("entryId") entryId: Int,
|
||||
@Body entry: ObervationEntry
|
||||
):
|
||||
Call<EntrySalix>
|
||||
|
||||
@GET("Shelvings")
|
||||
fun Shelvings(
|
||||
fun shelvingsGet(
|
||||
@Query("filter") filter: String
|
||||
): Call<List<ShelvingLogSalix>>
|
||||
|
||||
|
@ -1052,13 +1018,13 @@ interface SalixService {
|
|||
): Call<Any>
|
||||
|
||||
@PATCH("Operators/{id}")
|
||||
fun update_operator(
|
||||
fun updateOperator(
|
||||
@Path("id") id: Number,
|
||||
@Body params: Any
|
||||
): Call<Unit>
|
||||
|
||||
@GET("Operators/{id}")
|
||||
fun operator_getData(
|
||||
fun operatorGetData(
|
||||
@Path("id") id: Number,
|
||||
@Query("filter") filter: String
|
||||
): Call<OperatorSalix>
|
||||
|
@ -1085,7 +1051,7 @@ interface SalixService {
|
|||
|
||||
@POST("TicketCollections/update")
|
||||
fun ticketCollectionUpdate(
|
||||
@Query("where") filter: Any,//revisar si con Any vale, update generalmente pongo json (ejemplo: itemShelvingReset)
|
||||
@Query("where") filter: Any,
|
||||
@Body params: Any
|
||||
): Call<Unit>
|
||||
|
||||
|
@ -1111,15 +1077,10 @@ interface SalixService {
|
|||
): Call<Any>
|
||||
|
||||
@POST("ItemShelvingSales/itemShelvingSale_addByCollection")
|
||||
fun itemShelvingSale_addByCollection(
|
||||
fun itemShelvingSaleAddByCollection(
|
||||
@Body params: Any,
|
||||
): Call<Any>
|
||||
|
||||
/* @POST("ItemShelvingSales/itemShelvingSale_addBySale")
|
||||
fun itemShelvingSale_addBySale(
|
||||
@Body params: Any,
|
||||
): Call<Any>*/
|
||||
|
||||
@POST("ItemShelvings/getInventory")
|
||||
fun getInventoryParking(
|
||||
@Query("parkingFrom") parkingFrom: String, @Query("parkingTo") parkingTo: String
|
||||
|
|
|
@ -32,6 +32,7 @@ import es.verdnatura.presentation.base.BaseFragment
|
|||
import es.verdnatura.presentation.common.OnTrashItemRowClickListener
|
||||
import es.verdnatura.presentation.common.OnWorkFormsItemRowClickListener
|
||||
import es.verdnatura.presentation.view.component.CustomDialog
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||
import es.verdnatura.presentation.view.component.CustomDialogInputThreeValues
|
||||
import es.verdnatura.presentation.view.component.CustomDialogList
|
||||
import es.verdnatura.presentation.view.feature.login.adapter.WorkFormAdapter
|
||||
|
@ -44,6 +45,7 @@ import kotlin.system.exitProcess
|
|||
class LoginFragment(private var imageUri: Uri?) :
|
||||
BaseFragment<FragmentLoginBinding, LoginViewModel>(LoginViewModel::class) {
|
||||
|
||||
private lateinit var customDialogInput: CustomDialogInput
|
||||
private lateinit var customDialog: CustomDialog
|
||||
private lateinit var customNewForm: CustomDialogInputThreeValues
|
||||
private var workFormAdapter: WorkFormAdapter? = null
|
||||
|
@ -60,6 +62,7 @@ class LoginFragment(private var imageUri: Uri?) :
|
|||
|
||||
customDialogList = CustomDialogList(requireContext())
|
||||
customDialog = CustomDialog(requireContext())
|
||||
customDialogInput = CustomDialogInput(requireContext())
|
||||
//createFolderSerial()
|
||||
saveIdentifiers()
|
||||
checkUser()
|
||||
|
@ -466,25 +469,24 @@ class LoginFragment(private var imageUri: Uri?) :
|
|||
|
||||
if (it.isError) {
|
||||
saveTokenPref("", 0)
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
if (it.errorMessage.contains("REQUIRES_2FA")) {
|
||||
showInputCode()
|
||||
} else {
|
||||
customDialog.setTitle(getString(R.string.error))
|
||||
|
||||
.setDescription(
|
||||
if (it.errorMessage.contains("Unauthorized")) {
|
||||
getString(R.string.messageUserError)
|
||||
} else {
|
||||
if (it.errorMessage.contains("Unable to resolve")) {
|
||||
getString(R.string.messageInternetError)
|
||||
} else {
|
||||
it.errorMessage
|
||||
.setDescription(
|
||||
when {
|
||||
it.errorMessage.contains("Unauthorized") -> getString(R.string.messageUserError)
|
||||
it.errorMessage.contains("Unable to resolve") -> getString(R.string.messageInternetError)
|
||||
else -> it.errorMessage
|
||||
}
|
||||
).setOkButton(
|
||||
getString(R.string.accept)
|
||||
) {
|
||||
customDialog.dismiss()
|
||||
|
||||
}
|
||||
).setOkButton(
|
||||
getString(R.string.accept)
|
||||
) {
|
||||
customDialog.dismiss()
|
||||
|
||||
}.show()
|
||||
}.show()
|
||||
}
|
||||
} else {
|
||||
saveTokenPref(it.token, it.ttl)
|
||||
app.userName = binding.edittextUsername.text.toString()
|
||||
|
@ -533,6 +535,23 @@ class LoginFragment(private var imageUri: Uri?) :
|
|||
super.observeViewModel()
|
||||
}
|
||||
|
||||
private fun showInputCode() {
|
||||
customDialogInput.setTitle(getString(R.string.messageTwoFactorTitle))
|
||||
|
||||
.setDescription(
|
||||
getString(R.string.messageTwoFactor)
|
||||
).setOkButton(
|
||||
getString(R.string.validate)
|
||||
) {
|
||||
customDialogInput.dismiss()
|
||||
viewModel.validateAuth(
|
||||
user = binding.edittextUsername.text.toString(),
|
||||
password = binding.edittextPassword.text.toString(),
|
||||
code = customDialogInput.getValue())
|
||||
|
||||
}.show()
|
||||
}
|
||||
|
||||
private fun setupFirebase(userName: String) {
|
||||
Firebase.crashlytics.setUserId(userName)
|
||||
}
|
||||
|
|
|
@ -80,37 +80,56 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
.enqueue(object : SalixCallback<LoginSalixVO>(context) {
|
||||
override fun onSuccess(response: Response<LoginSalixVO>) {
|
||||
|
||||
val loginSalixVO: LoginSalixVO?
|
||||
if (response.body() != null) {
|
||||
loginSalixVO = response.body()?.let {
|
||||
LoginSalixVO(
|
||||
user,
|
||||
password,
|
||||
it.token,
|
||||
it.created,
|
||||
it.ttl,
|
||||
isError = false,
|
||||
errorMessage = ""
|
||||
)
|
||||
}
|
||||
} else {
|
||||
|
||||
loginSalixVO = LoginSalixVO(
|
||||
_loginSalixItem.value = response.body()?.let {
|
||||
LoginSalixVO(
|
||||
user,
|
||||
password,
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), response.message()
|
||||
)
|
||||
it.token,
|
||||
it.created,
|
||||
it.ttl,
|
||||
isError = false,
|
||||
errorMessage = ""
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
_loginSalixItem.value = loginSalixVO
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
val loginSalixVO = LoginSalixVO(
|
||||
_loginSalixItem.value = LoginSalixVO(
|
||||
user,
|
||||
password,
|
||||
"",
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun validateAuth(user: String, password: String, code: String) {
|
||||
salix.validateAuth(user, password, code)
|
||||
.enqueue(object : SalixCallback<LoginSalixVO>(context) {
|
||||
override fun onSuccess(response: Response<LoginSalixVO>) {
|
||||
|
||||
_loginSalixItem.value = response.body()?.let {
|
||||
LoginSalixVO(
|
||||
user,
|
||||
password,
|
||||
it.token,
|
||||
it.created,
|
||||
it.ttl,
|
||||
isError = false,
|
||||
errorMessage = ""
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
_loginSalixItem.value = LoginSalixVO(
|
||||
user,
|
||||
password,
|
||||
"",
|
||||
|
@ -119,7 +138,6 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
_loginSalixItem.value = loginSalixVO
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -127,25 +145,23 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
fun loginApp(
|
||||
login: LoginApp,
|
||||
|
||||
) {
|
||||
salix.loginApp(login)
|
||||
.enqueue(object : SalixCallback<LoginAppData>(context) {
|
||||
) {
|
||||
salix.loginApp(login).enqueue(object : SalixCallback<LoginAppData>(context) {
|
||||
override fun onSuccess(response: Response<LoginAppData>) {
|
||||
|
||||
_loginApp.value = response.body()
|
||||
_loginApp.value = response.body()
|
||||
}
|
||||
|
||||
override fun onError(t: Throwable) {
|
||||
/* val loginSalixVO = LoginAppData(
|
||||
user,
|
||||
password,
|
||||
"",
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
_loginSalixItem.value = loginSalixVO*/
|
||||
override fun onError(t: Throwable) {/* val loginSalixVO = LoginAppData(
|
||||
user,
|
||||
password,
|
||||
"",
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
_loginSalixItem.value = loginSalixVO*/
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -181,16 +197,16 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
override fun onSuccess(response: Response<DataUserSalix>) {
|
||||
app.userName = response.body()?.nickname
|
||||
app.userId = response.body()?.id
|
||||
deviceLog_addSalix(
|
||||
deviceLogAddSalix(
|
||||
app = appName,
|
||||
versionApp = versionApp,
|
||||
android_id = androidId,
|
||||
androidId = androidId,
|
||||
userFk = app.userId!!,
|
||||
serialnumber = serialNumber
|
||||
)
|
||||
//Tarea 5870
|
||||
operator_add(app.userId)
|
||||
operator_getDataSalix(app.userId!!)
|
||||
operatorAdd(app.userId)
|
||||
operatorGetData(app.userId!!)
|
||||
deviceCheckLogin(app.userId!!, androidId)
|
||||
}
|
||||
})
|
||||
|
@ -209,14 +225,14 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
})
|
||||
}
|
||||
|
||||
fun deviceLog_addSalix(
|
||||
app: String, versionApp: String, android_id: String, userFk: Int, serialnumber: String?
|
||||
fun deviceLogAddSalix(
|
||||
app: String, versionApp: String, androidId: String, userFk: Int, serialnumber: String?
|
||||
) {
|
||||
|
||||
//Tarea 4815
|
||||
salix.deviceLogInsert(
|
||||
DeviceLogSalix(
|
||||
android_id = android_id,
|
||||
android_id = androidId,
|
||||
userFk = userFk,
|
||||
nameApp = app,
|
||||
versionApp = versionApp,
|
||||
|
@ -233,8 +249,7 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
|
||||
fun checkVersion(nameApp: String) {
|
||||
//Tarea 6276 Modificado back
|
||||
salix.getVersion(nameApp)
|
||||
.enqueue(object : SalixCallback<VersionApp>(context) {
|
||||
salix.getVersion(nameApp).enqueue(object : SalixCallback<VersionApp>(context) {
|
||||
override fun onSuccess(response: Response<VersionApp>) {
|
||||
|
||||
_versionappitem.value = response.body()?.let {
|
||||
|
@ -274,18 +289,16 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
return list
|
||||
}
|
||||
|
||||
fun operator_add(workerFk: Int? = null) {
|
||||
fun operatorAdd(workerFk: Int? = null) {
|
||||
//Tarea 6276
|
||||
salix.operatorAdd(OperatorAdd(workerFk!!,false))
|
||||
salix.operatorAdd(OperatorAdd(workerFk!!, false))
|
||||
.enqueue(object : SalixCallback<Any>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
|
||||
if (!(t.message!!.contains("ER_DUP_ENTRY")))
|
||||
_operatorAdd.value = ResponseItemVO(
|
||||
isError = true,
|
||||
errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this),
|
||||
t.message!!
|
||||
if (!(t.message!!.contains("ER_DUP_ENTRY"))) _operatorAdd.value =
|
||||
ResponseItemVO(
|
||||
isError = true, errorMessage = getMessageFromAllResponse(
|
||||
nameofFunction(this), t.message!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -297,12 +310,12 @@ class LoginViewModel(val context: Context) : BaseViewModel(context) {
|
|||
}
|
||||
|
||||
//Tarea 5870
|
||||
fun operator_getDataSalix(
|
||||
fun operatorGetData(
|
||||
workerId: Int
|
||||
) {
|
||||
val filter =
|
||||
"""{"fields":["itemPackingTypeFk","numberOfWagons","sectorFk","trainFk","labelerFk","isOnReservationMode"],"include":[{"relation":"sector","scope":{"fields":["description","warehouseFk"]}},{"relation":"printer","scope":{"fields":["name"]}},{"relation":"train","scope":{"fields":["name"]}}]}"""
|
||||
salix.operator_getData(id = workerId, filter)
|
||||
salix.operatorGetData(id = workerId, filter)
|
||||
.enqueue(object : SalixCallback<OperatorSalix>(context) {
|
||||
override fun onError(t: Throwable) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue