protected async Task RunTransferJob(BlobTransferJob transferJob, DataMovementUserData userData)
        {
            this.SetRequestOptionsInTransferJob(transferJob);
            transferJob.OverwritePromptCallback = ConfirmOverwrite;

            try
            {
                await this.transferJobRunner.RunTransferJob(
                    transferJob,
                    (percent, speed) =>
                {
                    if (userData.Record != null)
                    {
                        userData.Record.PercentComplete   = (int)percent;
                        userData.Record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.FileTransmitStatus, (int)percent, Util.BytesToHumanReadableSize(speed));
                        this.OutputStream.WriteProgress(userData.Record);
                    }
                },
                    this.CmdletCancellationToken);

                if (userData.Record != null)
                {
                    userData.Record.PercentComplete   = 100;
                    userData.Record.StatusDescription = Resources.TransmitSuccessfully;
                    this.OutputStream.WriteProgress(userData.Record);
                }
            }
            catch (OperationCanceledException)
            {
                if (userData.Record != null)
                {
                    userData.Record.StatusDescription = Resources.TransmitCancelled;
                    this.OutputStream.WriteProgress(userData.Record);
                }
            }
            catch (Exception e)
            {
                if (userData.Record != null)
                {
                    userData.Record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.TransmitFailed, e.Message);
                    this.OutputStream.WriteProgress(userData.Record);
                }

                throw;
            }
        }
        protected async Task RunTransferJob(BlobTransferJob transferJob, DataMovementUserData userData)
        {
            this.SetRequestOptionsInTransferJob(transferJob);
            transferJob.OverwritePromptCallback = ConfirmOverwrite;

            try
            {
                await this.transferJobRunner.RunTransferJob(
                    transferJob,
                    (percent, speed) =>
                    {
                        if (userData.Record != null)
                        {
                            userData.Record.PercentComplete = (int)percent;
                            userData.Record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.FileTransmitStatus, (int)percent, Util.BytesToHumanReadableSize(speed));
                            this.OutputStream.WriteProgress(userData.Record);
                        }
                    },
                    this.CmdletCancellationToken);

                if (userData.Record != null)
                {
                    userData.Record.PercentComplete = 100;
                    userData.Record.StatusDescription = Resources.TransmitSuccessfully;
                    this.OutputStream.WriteProgress(userData.Record);
                }
            }
            catch (OperationCanceledException)
            {
                if (userData.Record != null)
                {
                    userData.Record.StatusDescription = Resources.TransmitCancelled;
                    this.OutputStream.WriteProgress(userData.Record);
                }
            }
            catch (Exception e)
            {
                if (userData.Record != null)
                {
                    userData.Record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.TransmitFailed, e.Message);
                    this.OutputStream.WriteProgress(userData.Record);
                }

                throw;
            }
        }
        protected void SetRequestOptionsInTransferJob(BlobTransferJob transferJob)
        {
            BlobRequestOptions cmdletOptions = RequestOptions;

            if (cmdletOptions == null)
            {
                return;
            }

            BlobRequestOptions requestOptions = transferJob.BlobRequestOptions;

            if (cmdletOptions.MaximumExecutionTime != null)
            {
                requestOptions.MaximumExecutionTime = cmdletOptions.MaximumExecutionTime;
            }

            if (cmdletOptions.ServerTimeout != null)
            {
                requestOptions.ServerTimeout = cmdletOptions.ServerTimeout;
            }

            transferJob.BlobRequestOptions = requestOptions;
        }
        protected void SetRequestOptionsInTransferJob(BlobTransferJob transferJob)
        {
            BlobRequestOptions cmdletOptions = RequestOptions;

            if (cmdletOptions == null)
            {
                return;
            }

            BlobRequestOptions requestOptions = transferJob.BlobRequestOptions;

            if (cmdletOptions.MaximumExecutionTime != null)
            {
                requestOptions.MaximumExecutionTime = cmdletOptions.MaximumExecutionTime;
            }

            if (cmdletOptions.ServerTimeout != null)
            {
                requestOptions.ServerTimeout = cmdletOptions.ServerTimeout;
            }

            transferJob.BlobRequestOptions = requestOptions;
        }
Beispiel #5
0
        protected void EnqueueTransferJob(BlobTransferJob transferJob, DataMovementUserData userData)
        {
            this.AppendEventHandlers(transferJob, userData);
            this.SetRequestOptionsInTransferJob(transferJob);
            transferJob.OverwritePromptCallback = ConfirmOverwrite;

            transferManager.EnqueueJob(transferJob, CmdletCancellationToken);
        }