Пример #1
0
        private static async Task Upload(
            ITransferClient client,
            TransferContext context,
            IList <TransferPath> localSourcePaths,
            string uploadTargetPath,
            SampleRunner sampleRunner,
            CancellationToken token)
        {
            // Create a job-based upload transfer request.
            Console2.WriteStartHeader("Transfer - Upload");
            TransferRequest uploadJobRequest = TransferRequest.ForUploadJob(uploadTargetPath, context);

            uploadJobRequest.Application = "Github Sample";
            uploadJobRequest.Name        = "Upload Sample";

            // Create a transfer job to upload the local sample dataset to the target remote path.
            using (ITransferJob job = await client.CreateJobAsync(uploadJobRequest, token).ConfigureAwait(false))
            {
                Console2.WriteLine("Upload started.");

                // Paths added to the async job are transferred immediately.
                await job.AddPathsAsync(localSourcePaths, token).ConfigureAwait(false);

                // Await completion of the job.
                ITransferResult result = await job.CompleteAsync(token).ConfigureAwait(false);

                Console2.WriteLine("Upload completed.");
                sampleRunner.DisplayTransferResult(result);
                Console2.WriteEndHeader();
            }
        }
 public RemittanceClient(
     RemittanceConfig remittanceConfig,
     ITokenClient tokenClient,
     IAccountBalanceClient accountBalanceClient,
     IAccountHolderClient accountHolderClient,
     ITransferClient transferClient)
 {
     this.remittanceConfig     = remittanceConfig;
     this.tokenClient          = tokenClient;
     this.accountBalanceClient = accountBalanceClient;
     this.accountHolderClient  = accountHolderClient;
     this.transferClient       = transferClient;
 }
 public DisbursementsClient(
     DisbursementsConfig disbursementConfig,
     ITokenClient tokenClient,
     IAccountBalanceClient accountBalanceClient,
     IAccountHolderClient accountHolderClient,
     ITransferClient transferClient)
 {
     this.disbursementConfig   = disbursementConfig;
     this.tokenClient          = tokenClient;
     this.accountBalanceClient = accountBalanceClient;
     this.accountHolderClient  = accountHolderClient;
     this.transferClient       = transferClient;
 }
Пример #4
0
            private async Task <IList <TransferPath> > SearchLocalSourcePathsAsync(ITransferClient transferClient, string uploadTargetPath, CancellationToken cancellationToken)
            {
                Console2.WriteTapiStartHeader("Search Paths");
                string                searchLocalPath       = GetLocalDocumentsFolderPath();
                const bool            local                 = true;
                PathEnumeratorContext pathEnumeratorContext = new PathEnumeratorContext(transferClient.Configuration, new[] { searchLocalPath }, uploadTargetPath)
                {
                    PreserveFolders = false
                };
                IPathEnumerator       pathEnumerator = transferClient.CreatePathEnumerator(local);
                EnumeratedPathsResult result         = await pathEnumerator.EnumerateAsync(pathEnumeratorContext, cancellationToken).ConfigureAwait(false);

                Console2.WriteDebugLine("Local Paths: {0}", result.LocalPaths);
                Console2.WriteDebugLine("Elapsed time: {0:hh\\:mm\\:ss}", result.Elapsed);
                Console2.WriteDebugLine("Total files: {0:n0}", result.TotalFileCount);
                Console2.WriteDebugLine("Total bytes: {0:n0}", result.TotalByteCount);
                Console2.WriteTapiEndHeader();
                return(result.Paths.ToList());
            }
Пример #5
0
        private static async Task Download(
            ITransferClient client,
            AutoDeleteDirectory directory,
            TransferContext context,
            IList <TransferPath> localSourcePaths,
            string uploadTargetPath,
            SampleRunner sampleRunner,
            CancellationToken token)
        {
            // Create a job-based download transfer request.
            Console2.WriteStartHeader("Transfer - Download");
            string          downloadTargetPath = directory.Path;
            TransferRequest downloadJobRequest = TransferRequest.ForDownloadJob(downloadTargetPath, context);

            downloadJobRequest.Application = "Github Sample";
            downloadJobRequest.Name        = "Download Sample";
            Console2.WriteLine("Download started.");

            // Create a transfer job to download the sample dataset to the target local path.
            using (ITransferJob job = await client.CreateJobAsync(downloadJobRequest, token).ConfigureAwait(false))
            {
                IEnumerable <TransferPath> remotePaths = localSourcePaths.Select(
                    localPath => new TransferPath
                {
                    SourcePath     = uploadTargetPath + "\\" + Path.GetFileName(localPath.SourcePath),
                    PathAttributes = TransferPathAttributes.File,
                    TargetPath     = downloadTargetPath
                });

                await job.AddPathsAsync(remotePaths, token).ConfigureAwait(false);

                await sampleRunner.ChangeDataRateAsync(job, token).ConfigureAwait(false);

                // Await completion of the job.
                ITransferResult result = await job.CompleteAsync(token).ConfigureAwait(false);

                Console2.WriteLine("Download completed.");
                sampleRunner.DisplayTransferResult(result);
                Console2.WriteEndHeader();
            }
        }
Пример #6
0
        private static async Task DemoTransferAsync(IRelativityTransferHost host, CancellationToken token, SampleRunner sampleRunner)
        {
            // Search for the first logical file share.
            const int           LogicalFileShareNumber = 1;
            RelativityFileShare fileShare = await sampleRunner.GetFileShareAsync(host, LogicalFileShareNumber, token).ConfigureAwait(false);

            // Assigning the file share bypasses auto-configuration that will normally use the default workspace repository.
            sampleRunner.AssignFileshare(fileShare);

            // Prepare transfer setup common for upload and download.
            IList <TransferPath> localSourcePaths = await sampleRunner.SearchLocalSourcePathsAsync(token).ConfigureAwait(false);

            string          uploadTargetPath = sampleRunner.GetUniqueRemoteTargetPath(fileShare);
            TransferContext context          = sampleRunner.CreateTransferContext();

            using (ITransferClient client = await sampleRunner.CreateClientAsync(host, token).ConfigureAwait(false))
                using (AutoDeleteDirectory directory = new AutoDeleteDirectory())
                {
                    await Upload(client, context, localSourcePaths, uploadTargetPath, sampleRunner, token);

                    await Download(client, directory, context, localSourcePaths, uploadTargetPath, sampleRunner, token);
                }
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the FileHelper class.
        /// </summary>
        /// <param name="fileName">
        ///     The fully qualified name of the new file, or the relative file name.
        /// </param>
        public FileHelper(string fileName)
        {
            this.fileName = fileName;

            Uri uri = new Uri(fileName);

            if (uri.Scheme == Uri.UriSchemeFile)
            {
                fxClient = new TransferClientFile();

                try
                {
                    creationTime = fxClient.FileGetLastWriteTime(fileName);
                }
                catch { }
            }
            else if (uri.Scheme == Uri.UriSchemeFtp)
            {
                fxClient = new TransferClientFtp(loginLine);
            }
            else if (uri.Scheme == Uri.UriSchemeHttp)
            {
            }
        }
 public void Init()
 {
     _stripe = Substitute.For<IStripeClient>();
     _client = new TransferClient(_stripe);
 }
Пример #9
0
            private async Task UploadMultipleDocumentsAsync(IRelativityTransferHost relativityTransferHost, CancellationToken cancellationToken)
            {
                // Search for the first logical file share.
                const int           logicalFileShareNumber = 1;
                RelativityFileShare fileShare = await GetFileShareAsync(relativityTransferHost, logicalFileShareNumber, cancellationToken).ConfigureAwait(false);

                // Configure an Aspera specific transfer.
                AsperaClientConfiguration configuration = CreateAsperaClientConfiguration();

                // Assigning the file share bypasses auto-configuration that will normally use the default workspace repository.
                configuration.TargetFileShare = fileShare;
                using (ITransferClient client = await CreateClientAsync(relativityTransferHost, configuration, cancellationToken).ConfigureAwait(false))
                    using (AutoDeleteDirectory directory = new AutoDeleteDirectory())
                    {
                        // Create a job-based upload transfer request.
                        Console2.WriteTapiStartHeader("Advanced Transfer - Upload");
                        string uploadTargetPath = GetUniqueRemoteTargetPath(fileShare);
                        IList <TransferPath> localSourcePaths = await SearchLocalSourcePathsAsync(client, uploadTargetPath, cancellationToken).ConfigureAwait(false);

                        TransferContext context          = CreateTransferContext();
                        TransferRequest uploadJobRequest = TransferRequest.ForUploadJob(uploadTargetPath, context);
                        uploadJobRequest.Application = "Github Sample";
                        uploadJobRequest.Name        = "Advanced Upload Sample";

                        // Create a transfer job to upload the local sample data set to the target remote path.
                        using (ITransferJob job = await client.CreateJobAsync(uploadJobRequest, cancellationToken).ConfigureAwait(false))
                        {
                            Console2.WriteDebugLine("Advanced upload started.");

                            // Paths added to the async job are transferred immediately.
                            await job.AddPathsAsync(localSourcePaths, cancellationToken).ConfigureAwait(false);

                            // Await completion of the job.
                            ITransferResult result = await job.CompleteAsync(cancellationToken).ConfigureAwait(false);

                            Console2.WriteDebugLine("Advanced upload completed.");
                            DisplayTransferResult(result);
                            Console2.WriteTapiEndHeader();
                        }

                        // Create a job-based download transfer request.
                        Console2.WriteTapiStartHeader("Advanced Transfer - Download");
                        string          downloadTargetPath = directory.Path;
                        TransferRequest downloadJobRequest = TransferRequest.ForDownloadJob(downloadTargetPath, context);
                        downloadJobRequest.Application = "Github Sample";
                        downloadJobRequest.Name        = "Advanced Download Sample";
                        Console2.WriteDebugLine("Advanced download started.");

                        // Create a transfer job to download the sample data set to the target local path.
                        using (ITransferJob job = await client.CreateJobAsync(downloadJobRequest, cancellationToken).ConfigureAwait(false))
                        {
                            IEnumerable <TransferPath> remotePaths = localSourcePaths.Select(localPath => new TransferPath
                            {
                                SourcePath     = uploadTargetPath + "\\" + Path.GetFileName(localPath.SourcePath),
                                PathAttributes = TransferPathAttributes.File,
                                TargetPath     = downloadTargetPath
                            });

                            await job.AddPathsAsync(remotePaths, cancellationToken).ConfigureAwait(false);
                            await ChangeDataRateAsync(job, cancellationToken).ConfigureAwait(false);

                            // Await completion of the job.
                            ITransferResult result = await job.CompleteAsync(cancellationToken).ConfigureAwait(false);

                            Console2.WriteDebugLine("Advanced download completed.");
                            DisplayTransferResult(result);
                            Console2.WriteTapiEndHeader();
                        }
                    }
            }
Пример #10
0
 public void Init()
 {
     _stripe = Substitute.For <IStripeClient>();
     _client = new TransferClient(_stripe);
 }