Example #1
0
        //void saveFile(List<Producto> jsonObject) {
        //	//Serializando Objeto
        //	//var toJson = JsonConv

        //	var fileSaving = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

        //}


        //METODO PARA RECIBIR JSON FILE Y GUARDARLO EN MyDocuments iOS
        //public void seveJsonFile() {
        //Obteniendo Desde Service JSONFILE

        //Guardando JsonDile en folder iOS

        //}

        async void ButtonLogin_TouchUpInside(object sender, EventArgs e)
        {
            Console.WriteLine("Iniciando sesion...");
            Service.Service servicio = new Service.Service();
            string          uuid     = labelUIDevice.Text;

            Console.WriteLine("Unique ID " + uuid);

            var uniqueID = UIKit.UIDevice.CurrentDevice.IdentifierForVendor.AsString(); //Obteniendo UuniqueID de iPhone

            uniqueID = uniqueID.Substring(0, 8);                                        //Cortando el uniqueID a 8 digitos

            labelUIDevice.Text = uniqueID;
            labelUIDevice.Text = "F0:27:65:E8:19:69";

            //uuid = "F0:27:65:E8:19:69"; //Pruebas



            try {
                var sesion = await servicio.LoginAsync(uuid);

                if (CurrentSession.id_mac == uuid)
                {
                    Console.WriteLine("Session Iniciada Exitosamente!");
                    statusLogin.Text = "Sesión Iniciada Correctamente!";

                    //var productosViewController = (ProductosViewController)Storyboard.InstantiateViewController("ProductosViewController");
                    //this.NavigationController.PushViewController(productosViewController, true);
                    //var TabBar = (TabBarViewController)Storyboard.InstantiateViewController("TabBarViewController");
                    //this.NavigationController.PushViewController(TabBar, true);


                    var appDelegate        = UIApplication.SharedApplication.Delegate as AppDelegate;
                    var rootViewController = new RootViewController();
                    var productsView       = (TabBarViewController)Storyboard.InstantiateViewController("TabBarViewController");

                    appDelegate.SetRootViewController(productsView, true);
                }
                else
                {
                    if (CurrentSession.id_mac != uuid || CurrentSession.id_mac == null || CurrentSession.id_mac == "")
                    {
                        var sessioErrorAlert = UIAlertController.Create("Error de Sesión", "Verifique ID de dispositivo con Admnistrador", UIAlertControllerStyle.Alert);


                        sessioErrorAlert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                        // Present Alert
                        PresentViewController(sessioErrorAlert, true, null);
                        statusLogin.BackgroundColor = UIColor.Red;
                        statusLogin.Text            = "Problemas al iniciar sesión";
                    }
                }
            }
            catch {
            }
        }
Example #2
0
        //Sets the RootViewController of the Apps main window with an option for animation.
        public void SetRootViewController(UIViewController rootViewController, bool animate)
        {
            Console.WriteLine("SetRootViewController: " + rootViewController);
            if (animate)
            {
                var transitionType = UIViewAnimationOptions.TransitionFlipFromLeft;

                Window.RootViewController = rootViewController;
                UIView.Transition(Window, 0.8, transitionType,
                                  () => Window.RootViewController = rootViewController,
                                  null);
            }
            else
            {
                var rRootViewController = new RootViewController();

                Console.WriteLine("Primera vista: " + rootViewController.ToString());
                //Primera Vista
                Window.RootViewController = rootViewController;

                //Window.RootViewController = rRootViewController;//Vista de RootViewController
            }
        }