Beispiel #1
0
 protected virtual void RunInBackground(BackgroundOperationType operationType)
 {
     if (_Worker != null && !_Worker.IsBusy)
     {
         BackgroundOperationArgs args = new BackgroundOperationArgs(operationType);
         RunInBackground(args);
     }
 }
Beispiel #2
0
        protected virtual void RunInBackground <T>(BackgroundOperationType operationType, T args)
        {
            if (_Worker != null && !_Worker.IsBusy)
            {
                BackgroundOperationArgs <T> opArgs = new BackgroundOperationArgs <T>(args, operationType);

                _Worker.RunWorkerAsync(opArgs);
            }
        }
Beispiel #3
0
        private void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundOperationType backgroundOperationType = (BackgroundOperationType)e.Argument;

            try
            {
                if (backgroundOperationType == BackgroundOperationType.CheckNewVersionAvailable)
                {
                    _newVersionAvailable = PassportPDFApplicationUpdateUtilities.IsNewVersionAvailable(_appId, _appVersion, out string latestVersion);
                    _latestVersionNumber = latestVersion;
                }
                else if (backgroundOperationType == BackgroundOperationType.CheckCurrentAppVersionIsSupported)
                {
                    _currentAppVersionIsSupported = PassportPDFApplicationUpdateUtilities.IsCurrentApplicationVersionSupported(_appId, _appVersion);
                }
                else if (backgroundOperationType == BackgroundOperationType.FetchPassportInfo)
                {
                    PassportPDFPassport passportPdfPassport = PassportPDFRequestsUtilities.GetPassportInfo(_passportToBeFetchedId);
                    if (passportPdfPassport != null)
                    {
                        _fetchedPassportInfo = new PassportInfo
                        {
                            PassportNumber   = passportPdfPassport.PassportId,
                            IsActive         = passportPdfPassport.IsActive,
                            SubscriptionDate = passportPdfPassport.SubscriptionDate ?? default,
                            TokensUsed       = passportPdfPassport.CurrentTokensUsed,
                            RemainingTokens  = passportPdfPassport.RemainingTokens,
                        };
                    }
                }
                else if (backgroundOperationType == BackgroundOperationType.FetchConfiguration)
                {
                    FrameworkGlobals.FetchPassportPDFConfigurationEx(_appId);
                }
                else if (backgroundOperationType == BackgroundOperationType.FetchOCRSupportedLanguages)
                {
                    _getAvailableOCRLanguagesResponse = PassportPDFRequestsUtilities.GetAvailableOCRLanguages();
                }
            }
            catch (Exception exception)
            {
                _apiCallException = exception;
            }
        }
 public BackgroundOperationArgs(BackgroundOperationType type)
 {
     Type = type;
 }
Beispiel #5
0
 public BackgroundOperationResult(bool success, BackgroundOperationType type, string message = "")
 {
     Success = success;
     Type    = type;
     Message = message;
 }