示例#1
0
        async private void SaveItinerary()
        {
            UserTripDataManager userTripManager = new UserTripDataManager();
            iOSLoginManager     loginManager    = iOSLoginManager.Instance;

            string origin       = Criteria.GetStartLocationString();
            string destination  = Criteria.GetEndLocationString();
            string prioritycode = "1";
            bool   isWheelchair = false;
            bool   isBike       = false;

            int  travelerId = loginManager.GetTravelerId();
            bool didSave    = await userTripManager.SaveTripForUser(travelerId, ItineraryToShow, origin, destination, prioritycode, isWheelchair, isBike);

            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "save trip", "save trip", didSave).Build());

            if (didSave)
            {
                this.NavigationController.PopToRootViewController(false);
            }
            else
            {
                UIAlertView alert = new UIAlertView("Not Saved", "Error saving trip.  Please try again.", null, "OK", null);
                alert.Show();
            }
        }
示例#2
0
        async private void sendLocation(CLLocation loc)
        {
            int taskId = -1;

            taskId = UIApplication.SharedApplication.BeginBackgroundTask(() => {
                UIApplication.SharedApplication.EndBackgroundTask(taskId);
            });
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            string userId     = loginManager.GetUserId();
            int    travelerId = loginManager.GetTravelerId();

            TravelerLocation travelerLoc = new TravelerLocation();

            travelerLoc.Latitude  = loc.Coordinate.Latitude;
            travelerLoc.Longitude = loc.Coordinate.Longitude;
            travelerLoc.TimeStamp = DateTime.UtcNow;
            //DateTime.SpecifyKind(loc.Timestamp, DateTimeKind.Utc);
            travelerLoc.UserId     = userId;
            travelerLoc.TravelerId = travelerId;

            TripManager tripManager = new TripManager();
            await tripManager.PostTravelerLocation(travelerLoc);

            UIApplication.SharedApplication.EndBackgroundTask(taskId);
        }
示例#3
0
        public void TermsDismissed(bool isAccepted)
        {
            this.DismissViewController(true, async() => {
                if (!isAccepted)
                {
                    NavigationController.PopViewControllerAnimated(true);
                }
                else
                {
                    AccountManager acm = new AccountManager();

                    iOSLoginManager loginManager = iOSLoginManager.Instance;

                    TravelerModel traveler       = await acm.GetTravelerByEmail(loginManager.GetUsername());
                    traveler.InformedConsent     = true;
                    traveler.InformedConsentDate = DateTime.UtcNow;

                    traveler = await acm.UpdateTraveler(traveler);

                    NavigationController.PopViewControllerAnimated(true);

                    if (LoginEvent != null)
                    {
                        LoginEvent();
                    }
                }
            });
        }
示例#4
0
        async public override void ViewWillAppear(bool animated)
        {
            showLoading();
            mACM = new AccountManager();
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            mUsername = loginManager.GetUsername();

            mTraveler = await mACM.GetTravelerByEmail(mUsername);

            if (!String.IsNullOrEmpty(mTraveler.PromoCode))
            {
                txtPromoCode.Text      = mTraveler.PromoCode;
                btnSetPromoCode.Hidden = true;
            }
            else
            {
                btnSetPromoCode.Hidden = false;
            }

            lblUsername.Text = mUsername;

                        #if DEBUG
            string versionTag = " debug";
                        #else
            string versionTag = "";
                        #endif
            lblVersion.Text = NSBundle.MainBundle.InfoDictionary [new NSString("CFBundleVersion")].ToString() + versionTag;
            dismissLoading();
        }
示例#5
0
        partial void LogoutAction(MonoTouch.Foundation.NSObject sender)
        {
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            loginManager.Logout();

            if (LogoutEvent != null)
            {
                LogoutEvent();
            }
        }
示例#6
0
        async private Task UpdateTripDisplays()
        {
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            int id = loginManager.GetTravelerId();

            int  maxRecords = 1;
            bool retina     = (UIScreen.MainScreen.Scale > 1.0);

            if (retina)
            {
                if (UIScreen.MainScreen.Bounds.Size.Height > 480.0f)
                {
                    maxRecords = 3;
                }
            }

            int upcomingTripCount = await mUserTripManager.GetUpcomingTripCount(id);

            if (upcomingTripCount > maxRecords)
            {
                btnMoreTrips.Hidden = false;
            }
            else
            {
                btnMoreTrips.Hidden = true;
            }

            mNextTrip = await mHomeDataManager.GetNextTrip(id);

            updateNextTripDisplay(mNextTrip);

            List <Trip> trips = await mUserTripManager.GetUpcomingTripsAfterNext(id, maxRecords);

            UpcomingTripsTableSource tableSource = new UpcomingTripsTableSource(trips, new TripTableCellHomeScreen(""));

            tableSource.TripSelected += (Trip trip) => {
                mTripSelected = trip;
                PerformSegue("TripDetailsSegue", this);
            };


            tableUpcomingTrips.Source = tableSource;
            tableUpcomingTrips.ReloadData();
            dismissLoading();
        }
示例#7
0
        async partial void SubmitRegistration(MonoTouch.Foundation.NSObject sender)
        {
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            String username       = txtEmailAddress.Text;
            String password       = txtPassword.Text;
            String verifyPassword = txtVerifyPassword.Text;
            String firstName      = txtFirstName.Text;
            String lastName       = txtLastName.Text;



            if (String.IsNullOrEmpty(firstName) || String.IsNullOrEmpty(lastName) ||
                String.IsNullOrEmpty(verifyPassword) || String.IsNullOrEmpty(password) || String.IsNullOrEmpty(username))
            {
                UIAlertView alert = new UIAlertView("Error", "All fields are required", null, "OK", null);
                alert.Show();
            }
            else if (password != verifyPassword)
            {
                UIAlertView alert = new UIAlertView("Error", "Passwords don't match", null, "OK", null);
                alert.Show();
            }
            else
            {
                RegistrationApplicant regApp = new RegistrationApplicant(username, password, verifyPassword, firstName, lastName);

                LoginResult loginResult = await regApp.Register(loginManager);                 //await loginManager.Register(username, password, firstName, lastName);

                GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "register user", "register result", loginResult.Success).Build());

                if (loginResult.Success)
                {
                    if (RegisteredEvent != null)
                    {
                        RegisteredEvent();
                    }
                }
                else
                {
                    UIAlertView alert = new UIAlertView("Error", loginResult.ErrorString, null, "OK", null);
                    alert.Show();
                }
            }
        }
示例#8
0
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            // NOTE: Don't call the base implementation on a Model class
            // see http://docs.xamarin.com/guides/ios/application_fundamentals/delegates,_protocols,_and_events

            Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath);
            this.DeviceToken = deviceToken;

            try{
                Hub.UnregisterAllAsync(deviceToken, (error) => {
                    if (error != null)
                    {
                        Console.WriteLine("Error calling Unregister: {0}", error.ToString());
                        return;
                    }


                    iOSLoginManager loginManager = iOSLoginManager.Instance;

                    string username   = loginManager.GetUsername();
                    string travelerId = loginManager.GetTravelerId().ToString();

                    string[] tagsArray = new string[2];
                    tagsArray[0]       = username;
                    tagsArray[1]       = travelerId;

                    NSSet tags = new NSSet(tagsArray);

                    Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => {
                        if (errorCallback != null)
                        {
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "notifications registration error", null).Build());
                            Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
                        }
                        else
                        {
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications launched", "notifications registration complete", null).Build());
                        }
                    });
                });
            }catch (Exception ex) {
                Console.WriteLine("Error" + ex.ToString());
            }
        }
        async private Task loadData()
        {
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            int travelerId = loginManager.GetTravelerId();

            List <Trip> trips = await mUserTripManager.GetUpcomingTrips(travelerId, 25);

            UpcomingTripsTableSource tableSource = new UpcomingTripsTableSource(trips, new TripTableCell(""));

            tableSource.TripSelected += (Trip trip) => {
                mTripSelected = trip;
                PerformSegue("TripDetailsSegue", this);
            };


            tableViewUpcomingTrips.Source = tableSource;
            tableViewUpcomingTrips.ReloadData();
        }
示例#10
0
        async partial void SubmitLogin(NSObject sender)
        {
            showLoading();


            iOSLoginManager loginManager = iOSLoginManager.Instance;

            String username = txtEmailAddress.Text;
            String password = txtPassword.Text;

            LoginResult loginResult = await loginManager.Login(username, password);

            dismissLoading();


            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "user login", "login result", Convert.ToInt32(loginResult.Success)).Build());

            if (loginResult.Success)
            {
                //check for terms acceptance
                AccountManager acm = new AccountManager();

                TravelerModel traveler = await acm.GetTravelerByEmail(username);

                if (!traveler.InformedConsent)
                {
                    PerformSegue("LoginTermsSegue", this);
                }
                else
                {
                    if (LoginEvent != null)
                    {
                        LoginEvent();
                    }
                }
            }
            else
            {
                UIAlertView alert = new UIAlertView("Error", loginResult.ErrorString, null, "OK", null);
                alert.Show();
            }
        }
示例#11
0
        async private void CancelTrip()
        {
            UserTripDataManager userTripManager = new UserTripDataManager();
            iOSLoginManager     loginManager    = iOSLoginManager.Instance;

            int  travelerId = loginManager.GetTravelerId();
            bool didSave    = await userTripManager.CancelTripForUser(travelerId, TripToShow);

            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("ui_action", "cancel trip", "cancel trip", didSave).Build());

            if (didSave)
            {
                UIAlertView alert = new UIAlertView("Canceled", "Trip Canceled", null, "OK", null);
                alert.Show();
                btnSaveCancel.Hidden = true;
            }
            else
            {
                UIAlertView alert = new UIAlertView("Not Canceled", "Error canceling trip.  Please try again.", null, "OK", null);
                alert.Show();
            }
        }
示例#12
0
        private async Task checkLogin()
        {
            iOSLoginManager loginManager = iOSLoginManager.Instance;
            bool            shouldLogout = NSUserDefaults.StandardUserDefaults.BoolForKey("logout_preference");

            if (shouldLogout)
            {
                loginManager.Logout();
                NSUserDefaults.StandardUserDefaults.SetBool(false, "logout_preference");
            }

            AccountManager acm      = new AccountManager();
            TravelerModel  traveler = await acm.GetTravelerByEmail(loginManager.GetUsername());

            if (traveler != null && !traveler.InformedConsent)
            {
                loginManager.Logout();
            }


            if (!await loginManager.IsLoggedIn())
            {
                PerformSegue("LoginSegue", this);
            }
            else
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert |
                                                             UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);

                if (CLLocationManager.LocationServicesEnabled)
                {
                    mLocationManager.StartUpdatingLocation();
                }

                await UpdateTripDisplays();
            }
        }