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

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

            Logger.Track(EvolveLoggerKeys.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   = "CWITC Data Synced",
                        Message = "You now have the latest conference data, however to sync your favorites and feedback you must sign in.",
                        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;
            }
        }
Exemplo n.º 2
0
        async Task ExecuteSyncCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }

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

            Logger.Track(EvolveLoggerKeys.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);
            }
            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;
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        async Task ExecuteLogoutCommand()
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                MessagingUtils.SendOfflineMessage();
                return;
            }


            if (IsBusy)
            {
                return;
            }

            Logger.Track(EvolveLoggerKeys.Logout);

            try
            {
                var ssoClient = DependencyService.Get <ISSOClient>();
                if (ssoClient != null)
                {
                    await ssoClient.LogoutAsync();
                }

                // clear Log In data first!
                Settings.ClearUserData();

                MessagingService.Current.SendMessage(MessageKeys.LoggedOut);
            }
            catch (Exception ex)
            {
                ex.Data["method"] = "ExecuteLoginCommandAsync";
                //TODO validate here.
                Logger.Report(ex);
            }
        }