Catrobat.IDE.Core.Services.Common.ProgramExportService.ExportToPocketCodeOrgWithNotifications C# (CSharp) Метод

ExportToPocketCodeOrgWithNotifications() публичный Метод

public ExportToPocketCodeOrgWithNotifications ( string programName, string currentUserName, string currentToken ) : Task
programName string
currentUserName string
currentToken string
Результат Task
        public async Task ExportToPocketCodeOrgWithNotifications(string programName, string currentUserName, string currentToken)
        {
            _cancellationTokenSource = new CancellationTokenSource();
            JSONStatusResponse statusResponse = await Task.Run(() => 
                ServiceLocator.WebCommunicationService.UploadProgramAsync(
                programName, currentUserName, currentToken, _cancellationTokenSource.Token,
                ServiceLocator.CultureService.GetCulture().TwoLetterISOLanguageName), _cancellationTokenSource.Token);

            if (_cancellationTokenSource.Token.IsCancellationRequested == true)
            {
                ServiceLocator.NotifictionService.ShowToastNotification(
                        AppResourcesHelper.Get("Export_CanceledText"),
                        AppResourcesHelper.Get("Export_CanceledText"),
                        ToastDisplayDuration.Long);
                return;
            }
            switch (statusResponse.statusCode)
            {
                case StatusCodes.ServerResponseOk:
                    break;

                case StatusCodes.HTTPRequestFailed:
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramErrorCaption"),
                            AppResourcesHelper.Get("Main_NoInternetConnection"), UploadErrorCallback, MessageBoxOptions.Ok);
                    break;

                default:
                    string messageString = string.IsNullOrEmpty(statusResponse.answer) ? string.Format(AppResourcesHelper.Get("Main_UploadProgramUndefinedError"), statusResponse.statusCode.ToString()) :
                                           string.Format(AppResourcesHelper.Get("Main_UploadProgramError"), statusResponse.answer);
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Main_UploadProgramErrorCaption"),
                                messageString, UploadErrorCallback, MessageBoxOptions.Ok);
                    break;
            }

            if (ServiceLocator.WebCommunicationService.NoUploadsPending())
            {
                ServiceLocator.NotifictionService.ShowToastNotification(null,
                    AppResourcesHelper.Get("Main_NoUploadsPending"), ToastDisplayDuration.Short);
            }
        }