internal override async Task <RestorePointEnumerationResult> RunAsync(TimeSpan timeout, CancellationToken cancellationToken)
        {
            RestorePointEnumerationResult restorePoints = new RestorePointEnumerationResult();

            this.ThrowInvalidArgumentIfNull(this.backupStorage);
            BackupStorageModel backupStorageModel = BackupStorageModel.FromBackupStorageView(this.backupStorage);

            await this.PopulateApplicationServiceAndPartitionWithBackupStorage(timeout, cancellationToken);

            try
            {
                List <RestorePoint> fetchedRestorePoints = await
                                                           backupStorageModel.GetBackupEnumerationsTask(this.ApplicationName, this.ServiceName,
                                                                                                        this.PartitionId, this.startDateTime, this.endDateTime, cancellationToken);

                if (fetchedRestorePoints != null && fetchedRestorePoints.Count > 0)
                {
                    restorePoints.RestorePoints = fetchedRestorePoints;
                }
            }
            catch (Exception exception)
            {
                List <RestorePointEnumerationFailureInfo> restorePointEnumerationFailureInfo =
                    new List <RestorePointEnumerationFailureInfo>();
                AggregateException aggregateException = exception as AggregateException;
                if (aggregateException != null)
                {
                    foreach (var innerException in aggregateException.InnerExceptions)
                    {
                        restorePointEnumerationFailureInfo.Add(new RestorePointEnumerationFailureInfo
                                                                   ()
                        {
                            Error =
                                new FabricError()
                            {
                                Code    = (NativeTypes.FABRIC_ERROR_CODE)innerException.HResult,
                                Message = innerException.Message
                            }
                        });
                    }
                }
                else
                {
                    restorePointEnumerationFailureInfo.Add(new RestorePointEnumerationFailureInfo
                                                               ()
                    {
                        Error =
                            new FabricError()
                        {
                            Code    = (NativeTypes.FABRIC_ERROR_CODE)exception.HResult,
                            Message = exception.Message
                        }
                    });
                }
            }
            return(restorePoints);
        }
コード例 #2
0
        internal override async Task <PagedBackupInfoList> RunAsync(TimeSpan timeout, CancellationToken cancellationToken)
        {
            BRSContinuationToken continuationTokenForNextStage = new BRSContinuationToken();

            if (continuationToken != null)
            {
                continuationTokenForNextStage.IncomingContinuationToken = continuationToken;
            }
            List <RestorePoint> restorePoints = new List <RestorePoint>();

            this.ThrowInvalidArgumentIfNull(this.backupByStorageQueryDescription.Storage);
            BackupStorageModel backupStorageModel = BackupStorageModel.FromBackupStorageView(this.backupByStorageQueryDescription.Storage);

            this.PopulateApplicationServiceAndPartitionWithBackupEntity(this.backupByStorageQueryDescription.BackupEntity,
                                                                        timeout, cancellationToken);
            try
            {
                List <RestorePoint> fetchedRestorePoints = await
                                                           backupStorageModel.GetBackupEnumerationsTask(
                    this.ApplicationName,
                    this.ServiceName,
                    this.PartitionId,
                    this.backupByStorageQueryDescription.StartDateTimeFilter,
                    this.backupByStorageQueryDescription.EndDateTimeFilter,
                    this.backupByStorageQueryDescription.Latest,
                    cancellationToken, continuationTokenForNextStage, maxResults);

                if (fetchedRestorePoints != null && fetchedRestorePoints.Count > 0)
                {
                    restorePoints = fetchedRestorePoints;
                }
            }
            catch (Exception exception)
            {
                List <RestorePointEnumerationFailureInfo> restorePointEnumerationFailureInfo =
                    new List <RestorePointEnumerationFailureInfo>();
                AggregateException aggregateException = exception as AggregateException;
                if (aggregateException != null)
                {
                    foreach (var innerException in aggregateException.InnerExceptions)
                    {
                        restorePoints.Add(new RestorePoint
                                              ()
                        {
                            FailureError =
                                new FabricError()
                            {
                                Code    = (NativeTypes.FABRIC_ERROR_CODE)innerException.HResult,
                                Message = innerException.Message
                            }
                        });
                    }
                }
                else
                {
                    restorePoints.Add(new RestorePoint
                                          ()
                    {
                        FailureError =
                            new FabricError()
                        {
                            Code    = (NativeTypes.FABRIC_ERROR_CODE)exception.HResult,
                            Message = exception.Message
                        }
                    });
                }
            }

            return(new PagedBackupInfoList()
            {
                Items = restorePoints,
                ContinuationToken = continuationTokenForNextStage.OutgoingContinuationToken
            });
        }