示例#1
0
        /// <summary>
        /// Helper function to convert ps recovery points list model from service response.
        /// </summary>
        public static List <RecoveryPointBase> GetPSAzureRecoveryPoints(ServiceClientModel.RecoveryPointListResponse rpList, AzureVmItem item)
        {
            if (rpList == null || rpList.RecoveryPointList == null ||
                rpList.RecoveryPointList.RecoveryPoints == null)
            {
                throw new ArgumentNullException("RPList");
            }

            Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id);
            string containerUri      = HelperUtils.GetContainerUri(uriDict, item.Id);
            string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id);

            List <RecoveryPointBase> result = new List <RecoveryPointBase>();

            foreach (ServiceClientModel.RecoveryPointResource rp in rpList.RecoveryPointList.RecoveryPoints)
            {
                ServiceClientModel.RecoveryPoint recPoint = rp.Properties as ServiceClientModel.RecoveryPoint;

                DateTime             recPointTime = DateTime.ParseExact(recPoint.RecoveryPointTime, @"MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                AzureVmRecoveryPoint rpBase       = new AzureVmRecoveryPoint()
                {
                    RecoveryPointId      = rp.Name,
                    BackupManagementType = item.BackupManagementType,
                    ItemName             = protectedItemName,
                    ContainerName        = containerUri,
                    ContainerType        = item.ContainerType,
                    RecoveryPointTime    = recPointTime,
                    RecoveryPointType    = recPoint.RecoveryPointType,
                    Id           = rp.Id,
                    WorkloadType = item.WorkloadType,
                    RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                    SourceVMStorageType         = recPoint.SourceVMStorageType,
                    SourceResourceId            = item.SourceResourceId,
                };
                result.Add(rpBase);
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Helper function to convert ps recovery points list model from service response.
        /// </summary>
        public static List <RecoveryPointBase> GetPSAzureRecoveryPoints(
            ServiceClientModel.RecoveryPointListResponse rpList,
            ItemBase item)
        {
            if (rpList == null || rpList.RecoveryPointList == null ||
                rpList.RecoveryPointList.RecoveryPoints == null)
            {
                throw new ArgumentNullException("RPList");
            }

            Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id);
            string containerUri     = HelperUtils.GetContainerUri(uriDict, item.Id);
            string protectedItemUri = HelperUtils.GetProtectedItemUri(uriDict, item.Id);

            string containerName     = IdUtils.GetNameFromUri(containerUri);
            string protectedItemName = IdUtils.GetNameFromUri(protectedItemUri);

            List <RecoveryPointBase> result = new List <RecoveryPointBase>();

            foreach (ServiceClientModel.RecoveryPointResource rp in rpList.RecoveryPointList.RecoveryPoints)
            {
                if (rp.Properties.GetType() == typeof(ServiceClientModel.RecoveryPoint))
                {
                    ServiceClientModel.RecoveryPoint recPoint =
                        rp.Properties as ServiceClientModel.RecoveryPoint;

                    DateTime recPointTime = DateTime.ParseExact(
                        recPoint.RecoveryPointTime,
                        @"MM/dd/yyyy HH:mm:ss",
                        CultureInfo.InvariantCulture);

                    AzureVmRecoveryPoint rpBase = new AzureVmRecoveryPoint()
                    {
                        RecoveryPointId      = rp.Name,
                        BackupManagementType = item.BackupManagementType,
                        ItemName             = protectedItemName,
                        ContainerName        = containerName,
                        ContainerType        = item.ContainerType,
                        RecoveryPointTime    = recPointTime,
                        RecoveryPointType    = recPoint.RecoveryPointType,
                        Id           = rp.Id,
                        WorkloadType = item.WorkloadType,
                        RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                        SourceVMStorageType         = recPoint.SourceVMStorageType,
                        SourceResourceId            = item.SourceResourceId,
                        EncryptionEnabled           = recPoint.IsSourceVMEncrypted.HasValue ?
                                                      recPoint.IsSourceVMEncrypted.Value : false,
                        IlrSessionActive = recPoint.IsInstantILRSessionActive,
                    };

                    result.Add(rpBase);
                }

                if (rp.Properties.GetType() == typeof(ServiceClientModel.GenericRecoveryPoint))
                {
                    ServiceClientModel.GenericRecoveryPoint recPoint =
                        rp.Properties as ServiceClientModel.GenericRecoveryPoint;

                    DateTime recPointTime = DateTime.ParseExact(
                        recPoint.RecoveryPointTime,
                        @"MM/dd/yyyy HH:mm:ss",
                        CultureInfo.InvariantCulture);

                    AzureSqlRecoveryPoint rpBase = new AzureSqlRecoveryPoint()
                    {
                        RecoveryPointId      = rp.Name,
                        BackupManagementType = item.BackupManagementType,
                        ItemName             = protectedItemName,
                        ContainerName        = containerUri,
                        ContainerType        = item.ContainerType,
                        RecoveryPointTime    = recPointTime,
                        RecoveryPointType    = recPoint.RecoveryPointType,
                        Id           = rp.Id,
                        WorkloadType = item.WorkloadType,
                        RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                        FriendlyName = recPoint.FriendlyName,
                    };

                    result.Add(rpBase);
                }
            }

            return(result);
        }