Ejemplo n.º 1
0
        private static ItemBase GetAzureSqlItemModel(ServiceClientModel.ProtectedItemResource protectedItem)
        {
            ItemBase itemModel;

            ServiceClientModel.AzureSqlProtectedItem azureSqlProtectedItem =
                (ServiceClientModel.AzureSqlProtectedItem)protectedItem.Properties;
            string policyName = null;
            string policyId   = azureSqlProtectedItem.PolicyId;

            if (!string.IsNullOrEmpty(policyId))
            {
                Dictionary <UriEnums, string> keyVauleDict =
                    HelperUtils.ParseUri(policyId);
                policyName = HelperUtils.GetPolicyNameFromPolicyId(keyVauleDict, policyId);
            }

            string containerUri = HelperUtils.GetContainerUri(
                HelperUtils.ParseUri(protectedItem.Id),
                protectedItem.Id);

            itemModel = new AzureSqlItem(
                protectedItem,
                IdUtils.GetNameFromUri(containerUri),
                ContainerType.AzureSQL,
                policyName);
            return(itemModel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper function to convert ps backup policy item from service response.
        /// </summary>
        public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource protectedItem)
        {
            ItemBase itemModel = null;

            if (protectedItem != null &&
                protectedItem.Properties != null)
            {
                if (protectedItem.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectedItem)))
                {
                    string policyName = null;
                    string policyId   = ((ServiceClientModel.AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
                    if (!string.IsNullOrEmpty(policyId))
                    {
                        Dictionary <UriEnums, string> keyValueDict =
                            HelperUtils.ParseUri(policyId);
                        policyName = HelperUtils.GetPolicyNameFromPolicyId(keyValueDict, policyId);
                    }

                    string containerUri = HelperUtils.GetContainerUri(
                        HelperUtils.ParseUri(protectedItem.Id),
                        protectedItem.Id);

                    itemModel = new AzureVmItem(
                        protectedItem,
                        IdUtils.GetNameFromUri(containerUri),
                        ContainerType.AzureVM,
                        policyName);
                }

                if (protectedItem.Properties.GetType() ==
                    typeof(ServiceClientModel.AzureSqlProtectedItem))
                {
                    ServiceClientModel.AzureSqlProtectedItem azureSqlProtectedItem =
                        (ServiceClientModel.AzureSqlProtectedItem)protectedItem.Properties;
                    string policyName = null;
                    string policyId   = azureSqlProtectedItem.PolicyId;
                    if (!string.IsNullOrEmpty(policyId))
                    {
                        Dictionary <UriEnums, string> keyVauleDict =
                            HelperUtils.ParseUri(policyId);
                        policyName = HelperUtils.GetPolicyNameFromPolicyId(keyVauleDict, policyId);
                    }

                    string containerUri = HelperUtils.GetContainerUri(
                        HelperUtils.ParseUri(protectedItem.Id),
                        protectedItem.Id);

                    itemModel = new AzureSqlItem(
                        protectedItem,
                        IdUtils.GetNameFromUri(containerUri),
                        ContainerType.AzureSQL,
                        policyName);
                }
            }

            return(itemModel);
        }