void refreshTable(Object sender, EventArgs e)
        {
            List <FlightCards> cards2 = new List <FlightCards>();

            if (Reachability.IsHostReachable("http://www.google.com"))
            {
                db.QueryUpdateTables();
                db.updateLocalFromRemote();
                db.updateLeaseFromRemote();
                db.updatePilotFromRemote();
                db.updatePlaneFromRemote();
                cards2 = db.LoadArray(startRange);
            }
            else
            {
                cards2 = db.LoadArray(startRange);
                Reachability.InternetConnectionStatus();
                Reachability.LocalWifiConnectionStatus();
                Reachability.RemoteHostStatus();
                try{
                    Reachability.ReachabilityChanged += delegate {
                        if (Reachability.IsHostReachable("http://www.google.com"))
                        {
                            db.QueryUpdateTables();

                            db.updateLocalFromRemote();
                            db.updateLeaseFromRemote();
                            db.updatePilotFromRemote();
                            db.updatePlaneFromRemote();
                            cards2 = db.LoadArray(startRange);
                        }
                    };
                }catch (Exception ex) {
                    Console.Out.WriteLine(ex.ToString());
                }
            }

            ToastIOS.Toast.MakeText("Refreshing");
            FlightTableView.Source             = new FlightTVS(cards2, this);
            FlightTableView.RowHeight          = 150f;
            FlightTableView.EstimatedRowHeight = 150f;
            refreshControl.EndRefreshing();
            FlightTableView.ReloadData();
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            RefServiceTSE.Service1 proxy = new RefServiceTSE.Service1();

            RefServiceTSE.Flight[] flightsF = proxy.getFlightArrivals(DateTime.Today, true);


            RefServiceTSE.Flight flightF = new RefServiceTSE.Flight();

            Flight flight;

            foreach (var item in flightsF)
            {
                flight = new Flight();
                flight.FlightNumber   = item.FlightNumber;
                flight.ScheduledTime  = item.ScheduledTime;
                flight.FlightUniqueID = item.FlightUniqueID;
                flights.Add(flight);
            }


            //XmlElement root = proxy.GetFlights("d2ad08e1-8e92-46e5-9788-1e4e56457c18", DateTime.Today, true, DateTime.Today.AddHours(5), true, "TSE", TSEService.AirportIdentifierType.IATACode, true);
            //XElement rootX = XmlElementToXelement(root);
            //Functional.getFlights(rootX);
            ////Functional.ArrivalFligts
            //oflight = Functional.ArrivalFligts;


            FlightTableView.Source = new FlightsTVS(flights);

            FlightTableView.Delegate = new FlightsDelegate();

            FlightTableView.RowHeight          = UITableView.AutomaticDimension;
            FlightTableView.EstimatedRowHeight = 90f;
            FlightTableView.ReloadData();
        }
        public override void ViewDidAppear(bool animated)

        {
            db = new DataManip();
            var cards = new List <FlightCards>();

            vc = this;

            var tapOutside = new UITapGestureRecognizer(() => View.EndEditing(true));

            tapOutside.CancelsTouchesInView = false;
            View.AddGestureRecognizer(tapOutside);

            Picker(StartRangeTextField);

            if (Reachability.IsHostReachable("http://www.google.com"))
            {
                db.QueryUpdateTables();
                db.updateLocalFromRemote();
                db.updatePilotFromRemote();
                db.updatePlaneFromRemote();
                db.updateLeaseFromRemote();
                cards = db.LoadArray(startRange);
            }
            else
            {
                cards = db.LoadArray(startRange);

                try
                {
                    Reachability.ReachabilityChanged += delegate
                    {
                        if (Reachability.IsHostReachable("https://www.google.com"))
                        {
                            db.QueryUpdateTables();
                            db.updateLocalFromRemote();
                            db.updatePilotFromRemote();
                            db.updatePlaneFromRemote();
                            db.updateLeaseFromRemote();
                            cards = db.LoadArray(startRange);
                            ToastIOS.Toast.MakeText("Host online, Syncing with remote database", ToastIOS.Toast.LENGTH_LONG).Show();
                        }
                    };
                }
                catch (Exception e)
                {
                    Console.Out.WriteLine(e.ToString());
                }
            }
            db = new DataManip();

            FlightTableView.Source             = new FlightTVS(cards, this);
            FlightTableView.RowHeight          = 150f;
            FlightTableView.EstimatedRowHeight = 150f;
            FlightTableView.ReloadData();

            refreshControl = new UIRefreshControl();

            FlightTableView.AddSubview(refreshControl);
            refreshControl.ValueChanged += refreshTable;
        }