Exemple #1
0
        public void GetMemebers()
        {
            memberDatabase = new MemberDatabase();
            var members = memberDatabase.GetMembers();

            xlist.ItemsSource = members;
        }
Exemple #2
0
        public InfoUser()
        {
            InitializeComponent();
            memberDatabase = new MemberDatabase();
            var members = memberDatabase.GetMembers();

            listMembers.ItemsSource = members;
        }
Exemple #3
0
        public void InsertMember(object o, EventArgs e)
        {
            try
            {
                member          = new Member();
                memberDatabase  = new MemberDatabase();
                member.UserName = memberName.Text;
                member.Pass     = memberAge.Text;

                memberDatabase.AddMember(member);
                GetMemebers();
            }
            catch (Exception ex)
            {
                DisplayAlert("", ex.ToString(), "");
            }
        }
Exemple #4
0
        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();
            }
        }
Exemple #5
0
        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;
        }
Exemple #6
0
        public async void Login_Api(string userName, string pass, string tok_ty, string acc_tok)
        {
            // await Navigation.PushAsync(new PageNav());


            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):
                res_Label_api.Text = "good";

                var responseString = await response.Content.ReadAsStringAsync();



                // var xjson = JsonConvert.DeserializeObject(responseString);
                var xjson = JsonConvert.DeserializeObject <RootObject>(responseString);

                //int xid = Convert.ToInt32(xjson.DatosEnvio.IdUsuario);


                try
                {
                    member              = new Member();
                    memberdatabase      = new MemberDatabase();
                    member.UserName     = userName;
                    member.Pass         = pass;
                    member.Token_Type   = tok_ty;
                    member.Access_Token = acc_tok;
                    member.ID           = xjson.DatosEnvio.IdUsuario;

                    memberdatabase.AddMember(member);

                    await Navigation.PushAsync(new PageNav());
                }
                catch (Exception ex)
                {
                    res_Label.Text     = "Hubo un problema como los datos de acceso";
                    res_Label_api.Text = ex.ToString();
                }



                //Application.Current.MainPage = new NavigationPage(new PageNav());

                break;

            case (System.Net.HttpStatusCode.BadRequest):
                res_Label_api.Text = "no good";
                break;

            case (System.Net.HttpStatusCode.Forbidden):
                res_Label_api.Text = "no good, Forbidden";
                break;

            //500
            case (System.Net.HttpStatusCode.InternalServerError):
                string status = "Nuestros servidores estan en mantenimiento";
                res_Label_api.Text = status;
                break;
            }


            waitActIndicator.IsRunning = false;
            btnAuth.IsEnabled          = true;
            return;
        }
Exemple #7
0
        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;
        }
Exemple #8
0
        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());
            }
        }