Exemplo n.º 1
0
        private async Task ProcessAsync(IFileSystemSmugglerSource source, IFileSystemSmugglerDestination destination, FileSystemSmugglerOperationState state, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(source.DisplayName) == false)
            {
                Notifications.ShowProgress("Processing source: {0}", source.DisplayName);
            }

            var maxEtags = await source
                           .FetchCurrentMaxEtagsAsync()
                           .ConfigureAwait(false);

            foreach (var type in source.GetItemsToSmuggle())
            {
                switch (type)
                {
                case SmuggleType.None:
                    return;

                case SmuggleType.File:
                    await new FileSmuggler(source, destination, options, Notifications, maxEtags.LastFileEtag).SmuggleAsync(state, cancellationToken).ConfigureAwait(false);
                    continue;

                case SmuggleType.Configuration:
                    await new ConfigurationSmuggler(source, destination, options, Notifications).SmuggleAsync(state, cancellationToken).ConfigureAwait(false);
                    continue;

                default:
                    throw new NotSupportedException(type.ToString());
                }
            }
        }
Exemplo n.º 2
0
 protected SmugglerBase(IFileSystemSmugglerSource source, IFileSystemSmugglerDestination destination, FileSystemSmugglerOptions options, FileSystemSmugglerNotifications notifications)
 {
     Notifications = notifications;
     Source        = source;
     Destination   = destination;
     Options       = options;
 }
Exemplo n.º 3
0
        public async Task <FileSystemSmugglerOperationState> ExecuteAsync(IFileSystemSmugglerSource source, IFileSystemSmugglerDestination destination, CancellationToken cancellationToken = default(CancellationToken))
        {
            using (source) // TODO arek
                using (destination)
                {
                    FileSystemSmugglerOperationState state = null;

                    try
                    {
                        await source
                        .InitializeAsync(options, cancellationToken)
                        .ConfigureAwait(false);

                        await destination
                        .InitializeAsync(options, Notifications, cancellationToken)
                        .ConfigureAwait(false);

                        state = new FileSystemSmugglerOperationState
                        {
                            LastFileEtag        = options.StartFilesEtag,
                            LastDeletedFileEtag = options.StartFilesDeletionEtag,
                        };

                        Debug.Assert(state.LastFileEtag != null); //TODO arek - for refactoring purposes
                        Debug.Assert(state.LastDeletedFileEtag != null);

                        await ProcessAsync(source, destination, state, cancellationToken).ConfigureAwait(false);

                        await destination.AfterExecuteAsync(state).ConfigureAwait(false);

                        return(state);
                    }
                    catch (SmugglerException e)
                    {
                        // TODO arek
                        //source.OnException(e);
                        destination.OnException(e);

                        throw;
                    }
                }
        }
Exemplo n.º 4
0
 public FileSmuggler(IFileSystemSmugglerSource source, IFileSystemSmugglerDestination destination, FileSystemSmugglerOptions options, FileSystemSmugglerNotifications notifications, Etag maxEtag)
     : base(source, destination, options, notifications)
 {
     this.maxEtag = maxEtag;
 }
Exemplo n.º 5
0
 public FileSystemSmugglerOperationState Execute(IFileSystemSmugglerSource source, IFileSystemSmugglerDestination destination)
 {
     return(AsyncHelpers.RunSync(() => ExecuteAsync(source, destination, CancellationToken.None)));
 }
Exemplo n.º 6
0
 public ConfigurationSmuggler(IFileSystemSmugglerSource source, IFileSystemSmugglerDestination destination, FileSystemSmugglerOptions options, FileSystemSmugglerNotifications notifications)
     : base(source, destination, options, notifications)
 {
 }