public virtual async Task HandleNotificationAsync(SessionNotification notification)
 {
     await New <IProgressBackground>().WorkAsync($"{nameof(HandleNotificationAsync)} {notification.NotificationType}",
                                                 async(IProgressContext progress) =>
     {
         progress.NotifyLevelStart();
         try
         {
             await HandleNotificationInternalAsync(notification, progress).Free();
         }
         catch (AxCryptException acex)
         {
             return(new FileOperationContext(acex.DisplayContext, acex.Messages(), ErrorStatus.Exception));
         }
         catch (Exception ex)
         {
             return(new FileOperationContext(string.Empty, ex.Messages(), ErrorStatus.Exception));
         }
         finally
         {
             progress.NotifyLevelFinished();
         }
         return(new FileOperationContext(String.Empty, ErrorStatus.Success));
     },
                                                 async(FileOperationContext status) =>
     {
         if (status.ErrorStatus == ErrorStatus.Success)
         {
             return;
         }
         _statusChecker.CheckStatusAndShowMessage(status.ErrorStatus, status.FullName, $"{status.InternalMessage} ({notification.NotificationType})");
     },
                                                 new ProgressContext()).Free();
 }
Ejemplo n.º 2
0
 public virtual async Task DecryptFilesInsideFolderUniqueWithWipeOfOriginalAsync(IDataContainer sourceContainer, LogOnIdentity logOnIdentity, IStatusChecker statusChecker, IProgressContext progress)
 {
     IEnumerable <IDataStore> files = sourceContainer.ListEncrypted(Resolve.FileSystemState.WatchedFolders.Select(cn => New <IDataContainer>(cn.Path)), New <UserSettings>().FolderOperationMode.Policy());
     await Resolve.ParallelFileOperation.DoFilesAsync(files, (file, context) =>
     {
         return(DecryptFileUniqueWithWipeOfOriginalAsync(file, logOnIdentity, context));
     },
                                                      async (status) =>
     {
         await Resolve.SessionNotify.NotifyAsync(new SessionNotification(SessionNotificationType.UpdateActiveFiles));
         statusChecker.CheckStatusAndShowMessage(status.ErrorStatus, status.FullName, status.InternalMessage);
     }).Free();
 }