Example #1
0
        public override async void OnDialogOpened(IDialogParameters parameters)
        {
            await SetBusyAsync(async() =>
            {
                await Task.Delay(1000);

                //加载本地的缓存信息
                DisplayText = LocalTranslationHelper.Localize("Initializing");

                accessTokenManager.AuthenticateResult = dataStorageService.RetrieveAuthenticateResult();
                applicationContext.Load(dataStorageService.RetrieveTenantInfo(), dataStorageService.RetrieveLoginInfo());

                //加载系统资源
                DisplayText = LocalTranslationHelper.Localize("LoadResource");
                await UserConfigurationManager.GetIfNeedsAsync();

                //如果本地授权存在,直接进入系统首页
                if (accessTokenManager.IsUserLoggedIn)
                {
                    OnDialogClosed();
                }
                else
                {
                    OnDialogClosed(ButtonResult.No);
                }
            });
        }
Example #2
0
        private static async Task HandleFlurlHttpException <TResult>(FlurlHttpException httpException,
                                                                     Func <Task <TResult> > func,
                                                                     Func <TResult, Task> successCallback,
                                                                     Func <System.Exception, Task> failCallback)
        {
            if (await new ExceptionHandler(dialogService).HandleIfAbpResponseAsync(httpException))
            {
                await failCallback(httpException);

                return;
            }

            var httpExceptionMessage = LocalTranslationHelper.Localize("HttpException");

#if DEBUG
            httpExceptionMessage += Environment.NewLine + httpException.Message;
#endif

            var accepted = dialogService.Question(
                LocalTranslationHelper.Localize("MessageTitle"),
                httpExceptionMessage);

            if (accepted)
            {
                await Execute(func, successCallback, failCallback);
            }
            else
            {
                await failCallback(httpException);
            }
        }
Example #3
0
        private static async Task HandleAbpValidationException(AbpValidationException abpValidationException,
                                                               Func <System.Exception, Task> failCallback)
        {
            dialogService.ShowMessage(
                LocalTranslationHelper.Localize("MessageTitle"),
                abpValidationException.GetConsolidatedMessage());

            await failCallback(abpValidationException);
        }
Example #4
0
        private static async Task HandleDefaultException <TResult>(System.Exception exception,
                                                                   Func <Task <TResult> > func,
                                                                   Func <TResult, Task> successCallback,
                                                                   Func <System.Exception, Task> failCallback)
        {
            var accepted = dialogService.Question(
                LocalTranslationHelper.Localize("MessageTitle"),
                LocalTranslationHelper.Localize("UnhandledWebRequestException"));

            if (accepted)
            {
                await Execute(func, successCallback, failCallback);
            }
            else
            {
                await failCallback(exception);
            }
        }
Example #5
0
        private static async Task HandleFlurlHttpTimeoutException(FlurlHttpTimeoutException httpTimeoutException,
                                                                  Func <Task> func,
                                                                  Func <Task> successCallback,
                                                                  Func <System.Exception, Task> failCallback)
        {
            var accepted = dialogService.Question(
                LocalTranslationHelper.Localize("MessageTitle"),
                LocalTranslationHelper.Localize("RequestTimedOut"));

            if (accepted)
            {
                await Execute(func, successCallback, failCallback);
            }
            else
            {
                await failCallback(httpTimeoutException);
            }
        }
        private static string Localize(string localizationKeyOrMessage,
                                       LocalizationSource localizationSource = LocalizationSource.LocalTranslation)
        {
            switch (localizationSource)
            {
            case LocalizationSource.RemoteTranslation:
                return(L.Localize(localizationKeyOrMessage));

            case LocalizationSource.LocalTranslation:
                return(LocalTranslationHelper.Localize(localizationKeyOrMessage));

            case LocalizationSource.NoTranslation:
                return(localizationKeyOrMessage);

            default:
                return(localizationKeyOrMessage);
            }
        }