예제 #1
0
        /// <summary>
        /// Refresh access token
        /// </summary>
        private async void RefreshToken()
        {
            try
            {
                //var nis = SimpleIoc.Default.GetInstance<INetworkInformationService>();
                if (ObjectSyncDispatcher.HasInternetConnection())
                {
                    await ObjectSyncDispatcher.Instance.RefreshToken();

                    //_logger.LogTrace("AppBootstrapper-RefreshToken| Trying to refresh token");
                    //await AuthenticationService.RefreshToken();
                    Debug.WriteLine("App RefreshToken");
                }
            }
            catch (OAuthException oae)
            {
                //_logger.LogException("AppBootstrapper-RefreshToken|", oae);
                Debug.WriteLine(oae);
            }
            catch (Exception ex)
            {
                //_logger.LogException("AppBootstrapper-RefreshToken|", ex);
                Debug.WriteLine(ex);
            }
        }
예제 #2
0
        private static async void OnHtmlPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            if (ObjectSyncDispatcher.HasInternetConnection())
            {
                return;
            }

            var msgDialog = new MessageDialog("Connection Not Available");
            await msgDialog.ShowAsync();
        }
예제 #3
0
        private void NetworkInformation_NetworkStatusChanged(object sender)
        {
            var hasInternetAccess = ObjectSyncDispatcher.HasInternetConnection();

            if (HasInternetConnection != hasInternetAccess)
            {
                Messenger.Default.Send(new NetworkStatusChangedMessage(hasInternetAccess));
            }
            HasInternetConnection = hasInternetAccess;
        }
예제 #4
0
        private async void SyncUpLogs()
        {
            try
            {
                if (!ObjectSyncDispatcher.HasInternetConnection())
                {
                    return;
                }

                await ObjectSyncDispatcher.Instance.SyncUpDsaSyncLogs((text) => Debug.WriteLine(text));
            }
            catch (Exception e)
            {
                PlatformAdapter.SendToCustomLogger(e, LoggingLevel.Error);
                Debug.WriteLine("SyncUpLogs exception");
            }
        }
예제 #5
0
        public async void SyncUpSearchTerms()
        {
            try
            {
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                if (!ObjectSyncDispatcher.HasInternetConnection() || !SfdcConfig.CollectSearchTerms)
                {
                    return;
                }

                await ObjectSyncDispatcher.Instance.SyncUpSearchTerms((text) => Debug.WriteLine(text));
            }
            catch (Exception e)
            {
                PlatformAdapter.SendToCustomLogger(e, LoggingLevel.Error);
                Debug.WriteLine("SyncUpSearchTerms exception");
            }
        }
예제 #6
0
        protected override async Task OnAfterLogin()
        {
            var firstLogin = await ObjectSyncDispatcher.Instance.IsUserFirstLogIn();

            if (firstLogin)
            {
                if (ControlBarViewModel.ShowInitialynchronizationPopup.CanExecute(this))
                {
                    ControlBarViewModel.ShowInitialynchronizationPopup.Execute(this);
                }
            }
            else
            {
                if (ObjectSyncDispatcher.HasInternetConnection())
                {
                    if (ControlBarViewModel.ShowDeltaSynchronizationPopup.CanExecute(this))
                    {
                        ControlBarViewModel.ShowDeltaSynchronizationPopup.Execute(this);
                    }
                }
            }
        }
예제 #7
0
        private async Task <bool> SyncUpNewPlaylist(bool syncPlaylistContent = false)
        {
            try
            {
                if (!ObjectSyncDispatcher.HasInternetConnection())
                {
                    return(false);
                }

                await ObjectSyncDispatcher.Instance.SyncUpFeaturedPlaylists((text) => Debug.WriteLine(text));

                if (syncPlaylistContent)
                {
                    await ObjectSyncDispatcher.Instance.SyncUpPlaylistContent((text) => Debug.WriteLine(text));
                }
                return(true);
            }
            catch (Exception e)
            {
                PlatformAdapter.SendToCustomLogger(e, LoggingLevel.Error);
                Debug.WriteLine("SyncUpNewPlaylist exception");
            }
            return(false);
        }
        private void ShowErrorMessageBoxIfNeeded(AggregateException exception)
        {
            var messagesToDisplay = exception.InnerExceptions.Where(e => e != null).Select(e => e.Message).ToList();

            if (messagesToDisplay.Any() == false)
            {
                return;
            }

            var message = string.Join(Environment.NewLine, messagesToDisplay);

            if (exception.InnerExceptions.Any(e => e is ErrorResponseException))
            {
                var messageHeader = $"You do not have correct permission set for DSA app, report the problem to email address {SfdcConfig.SynchronizationFailedSupportEmail}";
                message = messageHeader + Environment.NewLine + Environment.NewLine + message;
            }

            if (!ObjectSyncDispatcher.HasInternetConnection())
            {
                message = ObjectSyncDispatcher.NoInternetConnectionMessage;
            }

            DispatcherHelper.CheckBeginInvokeOnUI(() => { _dialogService.ShowMessage(message, "Synchronization failed"); });
        }
예제 #9
0
 public NetworkInformationService()
 {
     HasInternetConnection = ObjectSyncDispatcher.HasInternetConnection();
     NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;
 }