public static async Task <bool> UserLogin(string url) { bool result = false; var request = System.Net.WebRequest.Create(url) as HttpWebRequest; if (request != null) { request.Method = "GET"; request.ServicePoint.Expect100Continue = false; request.Timeout = 20000; request.ContentType = "application/json"; using (WebResponse response = await request.GetResponseAsync()) { using (Stream stream = response.GetResponseStream()) { string x = JsonObject.Load(stream).ToString(); JsonObject jObj = (JsonObject)JsonObject.Parse(x); JsonArray jArr = (JsonArray)jObj["result"]; foreach (var item in jArr) { tblUser user = new tblUser(); user.id = 1; user.user_id = Convert.ToString((Int32)item ["number"]); user.fname = Convert.ToString((string)item ["fname"]); user.lname = Convert.ToString((string)item ["lname"]); user.username = Convert.ToString((string)item ["user"]); user.password = Convert.ToString((string)item ["password"]); ConAddress.UpdateUser(user); } } } } return(result); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.LayAddress); var menuButton = FindViewById(Resource.Id.menuHdrButton); menuButton.Click += (sender, e) => { leftdrawer(); }; var MenuUserName = FindViewById <TextView>(Resource.Id.MenuUserName); MenuUserName.Text = " " + GlobalVariables.GlobalFname + " " + GlobalVariables.GlobalLname; var MenuInterviewer = FindViewById(Resource.Id.MenuInterviewer); MenuInterviewer.Click += (sender, e) => { leftdrawer(); }; var MenuLogout = FindViewById(Resource.Id.MenuLogout); MenuLogout.Click += (sender, e) => { tblUser user = new tblUser(); GlobalVariables.GlobalUserid = ""; user.id = 1; user.user_id = ""; user.username = ""; user.password = ""; user.fname = ""; user.lname = ""; ConAddress.UpdateUser(user); var intent = new Intent(); intent.SetClass(this, typeof(ActLogin)); StartActivity(intent); }; lvlist = FindViewById <ListView>(Resource.Id.lvlist); lvlist.ItemClick += new System.EventHandler <AdapterView.ItemClickEventArgs>(lvlist_ItemClicked); lvlist.ItemLongClick += new System.EventHandler <AdapterView.ItemLongClickEventArgs>(lvlist_ItemLongClick); txtsearch = FindViewById <EditText>(Resource.Id.txtsearch); txtsearch.AfterTextChanged += delegate { refreshItems(); }; btnSync = FindViewById <Button> (Resource.Id.btnSync); btnSync.Click += delegate { ApiRSTlist(); }; btnAddaddress = FindViewById <Button> (Resource.Id.btnAddaddress); btnAddaddress.Click += delegate { var intent = new Intent(); intent.SetClass(this, typeof(ActAddressAdd)); StartActivity(intent); }; refreshItems(); }