public void GetMemebers() { memberDatabase = new MemberDatabase(); var members = memberDatabase.GetMembers(); xlist.ItemsSource = members; }
public InfoUser() { InitializeComponent(); memberDatabase = new MemberDatabase(); var members = memberDatabase.GetMembers(); listMembers.ItemsSource = members; }
protected override void OnStart() { // Handle when your app starts //Sqli instance memberDatabase = new MemberDatabase(); var members = memberDatabase.GetMembers(); int RowCount = 0; int membcount = members.Count(); RowCount = Convert.ToInt32(membcount); if (RowCount > 0) { SendLocation(); } }
public FormsPage() { InitializeComponent(); memberDatabase = new MemberDatabase(); var members = memberDatabase.GetMembers(); /* if (members) * { * DisplayAlert("no","no members", "i accept"); * }*/ int RowCount = 0; int membcount = members.Count(); RowCount = Convert.ToInt32(membcount); if (RowCount > 0) { DisplayAlert("", "nohayusers", "oki"); } xlist.ItemsSource = members; }
protected async override void OnAppearing() { base.OnAppearing(); res_x.Text = ""; var mx = memberDatabase.GetMembers(); var mx_first = mx.FirstOrDefault(); var tok_ty = mx_first.Token_Type; var acc_tok = mx_first.Access_Token; var id = mx_first.ID; //try http GET var uri = "http://aige.sytes.net:81/ApiRestSAM/api/conapesca/Geolocalizacion?idusuario=" + id; var request = new HttpRequestMessage(); request.RequestUri = new Uri(uri); request.Method = HttpMethod.Get; var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(tok_ty, acc_tok); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.SendAsync(request); switch (response.StatusCode) { //200 case (System.Net.HttpStatusCode.OK): HttpContent content = response.Content; string xjson = await content.ReadAsStringAsync(); try { //List<Table_Loc> loc_list = JsonConvert.DeserializeObject<List<Table_Loc>>(xjson); Root myobject = JsonConvert.DeserializeObject <Root>(xjson); res_x.Text = "Exito en solicitar datos"; ListLoc.ItemsSource = myobject.tablas.Table1; // ListLoc } catch (Exception ex) { await DisplayAlert("", "" + ex.ToString(), "ok"); return; } break; //500 case (System.Net.HttpStatusCode.InternalServerError): await DisplayAlert("No existe registro de usuario", "Nuestros servidores estan en mantenimiento", "Continuar"); memberDatabase.DeleteMember(id); await Navigation.PushModalAsync(new AuthPage()); break; //404 case (System.Net.HttpStatusCode.Forbidden): try { await DisplayAlert("Su sesión ha caducado", "Reingrese sus datos", "ok"); memberDatabase.DeleteMember(id); await Navigation.PushModalAsync(new AuthPage()); } catch (Exception ex) { res_x.Text = ex.ToString(); } break; } //res_lbl //await DisplayAlert("","fack user "+id+" we R good 2 Go! yei :D / :3 ","ok"); }
public async Task RetriveLocation() { if (!CrossGeolocator.Current.IsGeolocationEnabled) { await DisplayAlert("Advertencia !", "Active su GPS para utilizar esta aplicación correctamente", "Continuar"); } else { testx.Text = ""; memberDatabase = new MemberDatabase(); var members = memberDatabase.GetMembers(); var member = members.FirstOrDefault(); var userName = member.UserName; var id = member.ID; var tok_ty = member.Token_Type; var acc_tok = member.Access_Token; string str_id = id.ToString(); waitActIndicator.IsRunning = true; var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 100; var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10000), null, true); txtLat.Text = "Latitude: " + position.Latitude.ToString(); txtLong.Text = "Longitude: " + position.Longitude.ToString(); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(tok_ty, acc_tok); client.DefaultRequestHeaders.Add("api-version", "1.0"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var values = new Dictionary <string, string> { { "Longitud", position.Longitude.ToString() }, { "Latitud", position.Latitude.ToString() }, { "IdUsuario", str_id }, { "opcion", "Insertar" } }; var content = new FormUrlEncodedContent(values); var response = await client.PostAsync("http://aige.sytes.net:81/ApiRestSAM/api/conapesca/Geolocalizacion", content); switch (response.StatusCode) { case (System.Net.HttpStatusCode.OK): testx.Text = "success"; break; case (System.Net.HttpStatusCode.BadRequest): testx.Text = "no good"; break; case (System.Net.HttpStatusCode.Forbidden): await DisplayAlert("Su sesión ha caducado", "Reingrese sus datos", "ok"); memberDatabase.DeleteMember(id); Application.Current.MainPage = new NavigationPage(new AuthPage()); break; } } waitActIndicator.IsRunning = false; }
protected override async void OnAppearing() { base.OnAppearing(); await splashImage.ScaleTo(1, 2000); //Time-consuming processes such as initialization await splashImage.ScaleTo(0.6, 1500, Easing.Linear); await splashImage.ScaleTo(150, 1200, Easing.Linear); //Application.Current.MainPage = new NavigationPage(new PageAuth()); //After loading MainPage it gets Navigated to our new Page InitializeComponent(); //conection instance CrossConnectivity.Current.ConnectivityChanged += Current_ConnectivityChanged; //Sqli instance memberDatabase = new MemberDatabase(); var members = memberDatabase.GetMembers(); if (!CrossConnectivity.Current.IsConnected) { await DisplayAlert("Advertencia !", "Esta aplicación requiere estar conectada a internet de lo contrario no funionará. Por favor active sus datos", "Continuar"); } if (!CrossGeolocator.Current.IsGeolocationEnabled) { await DisplayAlert("Advertencia !", "Active su GPS para utilizar esta aplicación correctamente", "Continuar"); } int RowCount = 0; int membcount = members.Count(); RowCount = Convert.ToInt32(membcount); if (RowCount > 0) { var mx = memberDatabase.GetMembers(); var mx_first = mx.FirstOrDefault(); var tok_ty = mx_first.Token_Type; var acc_tok = mx_first.Access_Token; var userName = mx_first.UserName; var pass = mx_first.Pass; var id = mx_first.ID; HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(tok_ty, acc_tok); client.DefaultRequestHeaders.Add("api-version", "1.0"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var values = new Dictionary <string, string> { { "usuario", userName }, { "contraseña", pass } }; var content = new FormUrlEncodedContent(values); var response = await client.PostAsync("http://aige.sytes.net:81/ApiRestSAM/api/conapesca/acceso", content); switch (response.StatusCode) { case (System.Net.HttpStatusCode.OK): Application.Current.MainPage = new NavigationPage(new PageNav()); break; case (System.Net.HttpStatusCode.BadRequest): testx.Text = "no good"; break; case (System.Net.HttpStatusCode.Forbidden): await DisplayAlert("Su sesión ha caducado", "Reingrese sus datos", "ok"); memberDatabase.DeleteMember(id); Application.Current.MainPage = new NavigationPage(new AuthPage()); break; //500 case (System.Net.HttpStatusCode.InternalServerError): string status = "Nuestros servidores estan en mantenimiento"; testx.Text = status; break; } //Application.Current.MainPage = new NavigationPage(new PageNav()); } else { await DisplayAlert("No existe registro de usuario", "Por favor acceda con su usuario y contraseña. Si no cuenta con ellos " + "pongase en contacto con su provedor", "Continuar"); Application.Current.MainPage = new NavigationPage(new AuthPage()); } }