Ejemplo n.º 1
0
        async Task ExecuteSyncCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }

            if (!CrossConnectivity.Current.IsConnected)
            {
                MessagingUtils.SendOfflineMessage();
                return;
            }

            Logger.Track(ConferenceLoggerKeys.ManualSync);

            SyncText = "Syncing...";
            IsBusy   = true;

            try
            {
                #if DEBUG
                await Task.Delay(1000);
                #endif

                Settings.HasSyncedData = true;
                Settings.LastSync      = DateTime.UtcNow;
                OnPropertyChanged("LastSyncDisplay");

                await StoreManager.SyncAllAsync(Settings.Current.IsLoggedIn);

                if (!Settings.Current.IsLoggedIn)
                {
                    MessagingService.Current.SendMessage <MessagingServiceAlert>(MessageKeys.Message, new MessagingServiceAlert
                    {
                        Title   = "Conference Data Synced",
                        Message = "You now have the latest conference data, however to sync your favorites and feedback you must sign in with your Xamarin account.",
                        Cancel  = "OK"
                    });
                }
            }
            catch (Exception ex)
            {
                ex.Data["method"] = "ExecuteSyncCommandAsync";
                MessagingUtils.SendAlert("Unable to sync", "Uh oh, something went wrong with the sync, please try again. \n\n Debug:" + ex.Message);
                Logger.Report(ex);
            }
            finally
            {
                SyncText = "Sync Now";
                IsBusy   = false;
            }
        }
Ejemplo n.º 2
0
        void ExecuteLoginCommand()
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                MessagingUtils.SendOfflineMessage();
                return;
            }


            if (IsBusy)
            {
                return;
            }


            if (Settings.IsLoggedIn)
            {
                MessagingService.Current.SendMessage <MessagingServiceQuestion>(MessageKeys.Question, new MessagingServiceQuestion
                {
                    Title       = "Logout?",
                    Question    = "Are you sure you want to logout? You can only save favorites and leave feedback when logged in.",
                    Positive    = "Yes, Logout",
                    Negative    = "Cancel",
                    OnCompleted = async(result) =>
                    {
                        if (!result)
                        {
                            return;
                        }

                        await Logout();
                    }
                });

                return;
            }

            Logger.TrackPage(AppPage.Login.ToString(), "Settings");
            MessagingService.Current.SendMessage(MessageKeys.NavigateLogin);
        }