예제 #1
0
        async Task ExecuteSyncCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }

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

            Logger.Track(SealegsLoggerKeys.ManualSync);

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

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

                Settings.HasSyncedData = true;
                Settings.LastSync      = DateTime.UtcNow;
                RaisePropertyChanged();

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

                if (!Settings.Current.IsLoggedIn)
                {
                    MessagingService.Current.SendMessage <MessagingServiceAlert>(MessageKeys.Message, new MessagingServiceAlert
                    {
                        Title   = "Evolve Data Synced",
                        Message = "You now have the latest conference data, however to sync your favorites and feedback you must sign in with your Sealegs 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;
            }
        }
예제 #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 feed" +
                               "" +
                               "back 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);
        }