var DetailsofU = [];
//Type your code here
/*********************
Module name : UserLogin
Function name :validate
Description :Common validation
Author :Abdulkareem
Date :16-10-2018
***************************/
function validate(response){
if(response === null || response === "" || response === undefined || response === " "){
return true;
}else{
return false;
}
}
// /*********************
// Module name : UserLogin
// Function name :UserloginIn
// Description :userlogin Service call in here
// Author :Abdulkareem
// Date :16-10-2018
// ***************************/
// function UserloginIn(){
// if(validate(frmLogin2.txtUsername.text)){
// alert("Please enter valid Username");
// frmLogin2.txtUsername.setFocus(true);
// return false;
// }
// if(validate(frmLogin2.txtPw.text)){
// alert("Please enter password");
// frmLogin2.txtPw.setFocus(true);
// return false;
// }
// var cName = frmLogin2.txtUsername.text;
// var cPw = frmLogin2.txtPw.text;
// var serviceName = "devUserLogin";
// var integrationObj = KNYMobileFabric.getIntegrationService(serviceName);
// var operationName = "UserLogin";
// var data= {"username": cName,"password": cPw};
// var headers= {};
// //integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);
// integrationObj.invokeOperation(operationName, headers, data, operationSuccesslogin, operationFailurelogin);
// }
// /*********************
// Module name : UserLogin
// Function name :operationSuccesslogin
// Description :operation name of userlogin success
// Author :Abdulkareem
// Date :16-10-2018
// ***************************/
// function operationSuccesslogin(res){
// try{
// alert("response" + JSON.stringify(res));
// if(res.opstatus === 0){
// if(res.status === "Success"){
// frmUserD.lbl1.text =res.response[0].address;
// frmUserD.lbl2.text =res.response[0].name;
// frmUserD.lbl3.text =res.response[0].id;
// frmUserD.lbl4.text =res.response[0].phoneno;
// frmUserD.lbl5.text =res.response[0].username;
// } else{
// alert(res.Message);
// }
// }
// // }
// frmLogin2.destroy();
// frmUserD.show();
// }catch(error){
// alert("Exception succussful of operationSuccess" + error);
// }
// //code for success call back
// }
// /*********************
// Module name : UserLogin
// Function name :operationFailurelogin
// Description :operation name of userlogin failure
// Author :Abdulkareem
// Date :16-10-2018
// ***************************/
// function operationFailurelogin(res){
// try{
// alert("response" + JSON.stringify(res));
// }catch(error){
// alert("Exception succussful of operationFailure" + error);
// }
// //code for failure call back
// }
/*********************
Module name : shoWinfo
Function name :GetUserdetailService
Description :Userdetail Service call in here
Author :Abdulkareem
Date :16-10-2018
***************************/
function GetUserdetailService(){
loader();
var serviceName = "devUserLogin";
var integrationObj = KNYMobileFabric.getIntegrationService(serviceName);
var operationName = "getDetails";
var data= {};
var headers= {};
integrationObj.invokeOperation(operationName, headers, data, operationSuccessUDetail, operationFailureUDetail);
}
/*********************
Module name : shoWinfo
Function name :operationSuccessUDetail
Description :Operation name of GetUserdetail Success
Author :Abdulkareem
Date :16-10-2018
***************************/
function operationSuccessUDetail(res){
try{
kony.application.dismissLoadingScreen();
var Userlist =[];
Userlist = res.response;
var DataU =[];
if(Userlist !== null){
for(var i=0; i < Userlist.length;i++){
var Obj={"flximagseg":{isVisible:true},"lbl1": Userlist[i].name,"lbl2": Userlist[i].phoneno,"lbl3": Userlist[i].address,"lbl4": Userlist[i].id};
DataU.push(Obj);
}
}
frmActionarea.segD.setData(DataU);
//frmLogin2.destroy();
frmActionarea.show();
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//return false;
//code for failure call back
}
/*********************
Module name : shoWinfo
Function name :operationFailure
Description :Operation name of GetUserdetail Failure
Author :Abdulkareem
Date :16-10-2018
***************************/
function operationFailureUDetail(res){
try{
alert("response" + res);
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : shoWinfo
Function name :loaddataB
Description :Load user details in segment
Author :Abdulkareem
Date :16-10-2018
***************************/
function loaddataB(){
if(DetailsofU !== null){
frmshoWinfo.segD.setData(DetailsofU);
}
}
/*********************
Module name : shoWinfo
Function name :GetUserdetailGET
Description :Userdetail Service call in here
Author :Abdulkareem
Date :16-10-2018
***************************/
// function GetUserdetailGET(){
// var serviceName = "DbUserdetails";
// var integrationObj = KNYMobileFabric.getIntegrationService(serviceName);
// var operationName = "mflearn_tbl_register_get";
// var data= {};
// var headers= {};
// integrationObj.invokeOperation(operationName, headers, data, operationSuccessUserdetailGET, operationFailureUserdetailGET);
// }
function GetUserdetailGET(){
loader();
var serviceName = "NewuserDetailOBJ";
var serviceType = "online";
var objSvc = kony.sdk.getCurrentInstance().getObjectService(serviceName, {"access": serviceType});
var objectName = "UserDetailDMobj";
var dataObject = new kony.sdk.dto.DataObject(objectName);
var options = {"dataObject":dataObject};
objSvc.fetch(options, operationSuccessUserdetailGET, operationFailureUserdetailGET);
}
/*********************
Module name : shoWinfo
Function name :operationSuccessUDetail
Description :Operation name of GetUserdetail Success
Author :Abdulkareem
Date :16-10-2018
***************************/
function operationSuccessUserdetailGET(res){
try{
kony.application.dismissLoadingScreen();
var Userlist =[];
Userlist = res.records;
var DataU =[];
if(Userlist !== null){
for(var i=0; i < Userlist.length;i++){
var Obj={"flximagseg":{isVisible:true}, "lbl1": Userlist[i].iname,"lbl2": Userlist[i].iphone,"lbl3": Userlist[i].iaddress,"lbl4": Userlist[i].ids};
DataU.push(Obj);
}
}
frmshoWinfo.segD.setData(DataU);
frmLogin2.destroy();
frmshoWinfo.show();
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : shoWinfo
Function name :operationFailure
Description :Operation name of GetUserdetail Failure
Author :Abdulkareem
Date :16-10-2018
***************************/
function operationFailureUserdetailGET(res){
try{
alert("response" + res);
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : shoWinfo
Function name :operationFailure
Description :Operation name of GetUserdetail Failure
Author :Abdulkareem
Date :16-10-2018
***************************/
function DBobjGetuserD(){
// var serviceName = "DBNanAccess";
// var serviceType = "online";
// var objSvc = kony.sdk.getCurrentInstance().getObjectService(serviceName, {"access": serviceType});
// //Code to invoke parent object service should be present to use below code.
// var objectName = "newDetailsObj";
// var dataObject = new kony.sdk.dto.DataObject(objectName);
// //ex: dataObject.odataUrl = "$filter=ORDER_NUM eq 10001,$expand=ORDER_ITEM";
// //dataObject.odataUrl = "$select=<place-holder>,$filter=<place-holder>,$orderby=<place-holder>,$top=<place-holder>,$skip=<place-holder>,$expand=<place-holder>";
// var options = {"dataObject":dataObject};
// //'objSvc' is the instance of the parent object service.
// objSvc.fetch(options, onSuccessGetuserD, onFailureGetuserD);
}
function onSuccessGetuserD(res) {
try{
var Urget =[];
if(res.opstatus === 0 || res.opstatus === "0"){
var Userlist = [];
Userlist = res.newDetailsObj;
var DataU =[];
if(Userlist !== null){
for(var i=0; i < Userlist.length;i++){
var Obj={"lbl1": Userlist[i].namess,"lbl2": Userlist[i].PhoneNumber,"lbl3": Userlist[i].Addressss,"lbl4": Userlist[i].id};
DataU.push(Obj);
}
}
frmActionarea.segD.setData(DataU);
}
frmActionarea.show();
}catch(error){
alert("error-->" + error);
}
//Success handler
}
function onFailureGetuserD(res) {
alert("error failure obj-->" + error);
//Failure handler
}
/*********************
Module name : UserLogin
Function name :UserloginIn
Description :userlogin Service call in here
Author :Abdulkareem
Date :16-10-2018
***************************/
function UserloginInPost(){
if(validate(frmEntryform.txtName.text)){
alert("Please enter Name");
frmEntryform.txtName.setFocus(true);
return false;
}
if(validate(frmEntryform.txtUsername.text)){
alert("Please enter UserName");
frmEntryform.txtUsername.setFocus(true);
return false;
}
if(validate(frmEntryform.txtPasswords.text)){
alert("Please enter Password");
frmEntryform.txtPasswords.setFocus(true);
return false;
}
if(validate(frmEntryform.txtAddress.text)){
alert("Please enter Address");
frmEntryform.txtAddress.setFocus(true);
return false;
}
if(validate(frmEntryform.txtPhone.text)){
alert("Please enter Phone");
frmEntryform.txtPhone.setFocus(true);
return false;
}
var cName = frmEntryform.txtName.text;
var cUserName = frmEntryform.txtUsername.text;
var cPasswords = frmEntryform.txtPasswords.text;
var cAddress = frmEntryform.txtAddress.text;
var cPhone= frmEntryform.txtPhone.text;
loader();
var serviceName = "NewuserDetailOBJ";
var serviceType = "online";
var objSvc = kony.sdk.getCurrentInstance().getObjectService(serviceName, {"access": serviceType});
var objectName = "UserDetailDMobj";
var dataObject = new kony.sdk.dto.DataObject(objectName);
dataObject.addField("iname", cName);
dataObject.addField("iusername", cUserName);
dataObject.addField("ipassword", cPasswords);
dataObject.addField("iaddress", cAddress);
dataObject.addField("iphone", cPhone);
var options = {"dataObject":dataObject};
//'objSvc' is the instance of the parent object service.
objSvc.create(options, onSuccessUsr, onFailureUsr);
}
function onSuccessUsr(res) {
try{
kony.application.dismissLoadingScreen();
alert("Register successfully");
frmEntryform.destroy();
frmLogin2.destroy();
frmLogin2.show();
}catch(err){
alert("error"+ err);
}
//Success handler
}
function onFailureUsr(res) {
//Failure handler
alert("error Registor-->" + res);
}
/*********************
Module name : UserLogin2
Function name :UserloginIn
Description :userlogin Service call in here
Author :Abdulkareem
Date :16-10-2018
***************************/
function UserloginIn2(){
if(validate(frmLogin2.txtUsername.text)){
alert("Please enter valid Username");
frmLogin2.txtUsername.setFocus(true);
return false;
}
if(validate(frmLogin2.txtPW.text)){
alert("Please enter password");
frmLogin2.txtPW.setFocus(true);
return false;
}
var cName = frmLogin2.txtUsername.text;
var cPw = frmLogin2.txtPW.text;
loader();
var serviceName = "devUserLogin";
var integrationObj = KNYMobileFabric.getIntegrationService(serviceName);
var operationName = "UserLogin";
var data= {"username": cName,"password": cPw};
var headers= {};
//integrationObj.invokeOperation(operationName, headers, data, operationSuccess, operationFailure);
integrationObj.invokeOperation(operationName, headers, data, operationSuccesslogin2, operationFailurelogin2);
}
/*********************
Module name : UserLogin2
Function name :operationSuccesslogin
Description :operation name of userlogin success
Author :Abdulkareem
Date :16-10-2018
***************************/
function operationSuccesslogin2(res){
try{
kony.application.dismissLoadingScreen();
if(res.opstatus === 0){
if(res.status === "Success"){
frmUserD.lbl1.text =res.response[0].address;
frmUserD.lbl2.text =res.response[0].name;
frmUserD.lbl3.text =res.response[0].id;
frmUserD.lbl4.text =res.response[0].phoneno;
frmUserD.lbl5.text =res.response[0].username;
frmLogin2.destroy();
frmHome.show();
} else{
alert(res.Message);
}
}
// frmUserD.show();
}
catch(error){
alert("Exception succussful of operationSuccess" + error);
}
}
//code for success call back
/*********************
Module name : UserLogin2
Function name :operationFailurelogin
Description :operation name of userlogin failure
Author :Abdulkareem
Date :16-10-2018
***************************/
function operationFailurelogin2(res){
try{
alert("response" + JSON.stringify(res));
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : Gatewayscreen
Function name :BtnLoginOnclick
Description :userlogin form call with destroy
Author :Abdulkareem
Date :23-10-2018
***************************/
function BtnLoginOnclick(){
try{
frmLogin2.destroy(true);
frmLogin2.show();
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : Gatewayscreen
Function name :BtnLoginBackOnclick
Description :userlogin form call with destroy
Author :Abdulkareem
Date :23-10-2018
***************************/
function BtnLoginBackOnclick(){
try{
frmLogin2.destroy(true);
frmGateway.show();
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : Register
Function name :BtnBackGWOnclick
Description :call back Gateway screen
Author :Abdulkareem
Date :23-10-2018
***************************/
function BtnBackGWOnclick(){
try{
frmEntryform.destroy(true);
frmGateway.show();
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : Gatewayscreen
Function name :BtnRegistorOnclick
Description :Registor form call with destroy
Author :Abdulkareem
Date :23-10-2018
***************************/
function BtnRegistorOnclick(){
try{
frmEntryform.destroy(true);
frmEntryform.show();
}catch(error){
alert("Exception succussful of operationFailure" + error);
}
//code for failure call back
}
/*********************
Module name : Register
Function name :BtnRegistorDoROnclick
Description :Registor form reset
Author :Abdulkareem
Date :23-10-2018
***************************/
function BtnRegistorDoROnclick(){
try{
frmEntryform.txtName.text ="";
frmEntryform.txtUsername.text ="";
frmEntryform.txtPasswords.text ="";
frmEntryform.txtAddress.text ="";
frmEntryform.txtPhone.text ="";
frmEntryform.txtName.setFocus(true);
}catch(error){
alert("Register Doreset" + error);
}
//code for failure call back
}
/*********************
Module name : NFIscreen
Function name :NFIfunctionCall
Description :call option
Author :Abdulkareem
Date :24-10-2018
***************************/
function NFIfunctionCall(){
try{
var Intent = java.import("android.content.Intent");
var KonyMain = java.import("com.konylabs.android.KonyMain");
var uri = java.import("android.net.Uri");
// var launchIntent = getPackageManager().getLaunchIntentForPackage("com.orgname.firstLogin");
var intent = new Intent(Intent.ACTION_CALL);
intent.setData(uri.parse("tel:" + 9677403105));//change the number
KonyMain.getAppContext().startActivity(intent);
}catch(err){
}
}
/*********************
Module name : NFIscreen
Function name :GetCurrentmillisecond
Description :get Currentmillisecond
Author :Abdulkareem
Date :24-10-2018
***************************/
function GetCurrentmillisecond(){
var System = java.import("java.lang.System");
var CurrentTime = System.currentTimeMillis();
return CurrentTime;
}
/*********************
Module name : NFIscreen
Function name :Callbacktap
Description :Call back func
Author :Abdulkareem
Date :24-10-2018
***************************/
// function Callbacktap(restap){
// alert(JSON.stringify(restap));
// }
/*********************
Module name : NFIscreen
Function name :NFIFunctionInt
Description :get start activity
Author :Abdulkareem
Date :24-10-2018
***************************/
function NFIFunctionInt(){
try{
var intent = java.import("android.content.Intent");
var KonyMain = java.import("com.konylabs.android.KonyMain");
intent = KonyMain.getAppContext().getPackageManager().getLaunchIntentForPackage("com.truetech.nativeffi");
KonyMain.getAppContext().startActivity(intent);
}catch(err){
alert("Error "+JSON.stringify(err));
}
}
/*********************
Module name : NFIscreen
Function name :NFIFunctionIntSmsOpt
Description :send sms
Author :Abdulkareem
Date :24-10-2018
***************************/
function NFIFunctionIntSmsOpt(){
try{
var Intent = java.import("android.content.Intent");
var KonyMain = java.import("com.konylabs.android.KonyMain");
var uri = java.import("android.net.Uri");
var intents = new Intent(Intent.ACTION_VIEW);
intents.setData(uri.parse("sms:" + 9659675924));
KonyMain.getAppContext().startActivity(intents);
}catch(err){
alert("Error "+JSON.stringify(err));
}
}
/*********************
Module name : NFIscreen
Function name :NFIFunctionAutoSMS
Description :send sms
Author :Abdulkareem
Date :24-10-2018
***************************/
function autoSMSSending(){
try{
var SmsManager = java.import("android.telephony.SmsManager");
smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("9677089975", null, "welcome chandru", null, null);
}catch(err){
alert(JSON.stringify(err));
}
}
/*********************
Module name : FFIscreen
Function name :additionOne
Description :Add number by ffi java package
Author :Abdulkareem
Date :24-10-2018
***************************/
function additionOne(){
try{
var AddVal = additionExample.iaddition(200, 100);
alert("Value of addtion" + AddVal);
}catch(error){
alert("error of addval javapackage " + JSON.stringify(error));
}
}
/*********************
Module name : FFIscreen
Function name :additionToast
Description :Add number by ffi java package with Toast
Author :Abdulkareem
Date :24-10-2018
***************************/
function additionToast(){
additionExample.iaddtionT();
}
function additionWithoutStatic(){
try{
var AdditionNonStaticObject = new additionExample.WithoutStatic();
var returnedValue = AdditionNonStaticObject.NonStaticAdd(16, 30, 10);
alert("Non Static Addition value "+ returnedValue);
}catch(err){
alert("Error :" + err);
}
}
function additionCallback(){
try{
var AdditionNonStaticObject = new additionExample.WithoutStatic();
AdditionNonStaticObject.NonStaticCallBack( 18, 18, callBack);
}catch(err){
alert("Error :" + err);
}
}
function callBack(res){
alert(JSON.stringify(res));
}
function loader() {
kony.application.showLoadingScreen("sknlblload", "Loading...", constants.LOADING_SCREEN_POSITION_ONLY_CENTER, false, true, {
enableMenuKey: true,
enableBackKey: true,
progressIndicatorColor: "White"
});
}
Hi,
ReplyDeleteThank you for this. It has really helped me understand a-lot about the kony's storage service CRUD operation...