コード例 #1
0
        public static MigrationValidateContext ConvertToContext(
           OperationStatusResponse operationResponse, NetworkMigrationValidationResponse validationResponse)
        {
            if (operationResponse == null) return null;

            var result = new MigrationValidateContext
            {
                OperationId = operationResponse.Id,
                Result = operationResponse.Status.ToString()
            };

            if (validationResponse == null || validationResponse.ValidationMessages == null) return result;

            var errorCount = validationResponse.ValidationMessages.Count;

            if (errorCount > 0)
            {
                result.ValidationMessages = new ValidationMessage[errorCount];

                for (int i = 0; i < errorCount; i++)
                {
                    result.ValidationMessages[i] = new ValidationMessage
                    {
                        ResourceName = validationResponse.ValidationMessages[i].ResourceName,
                        ResourceType = validationResponse.ValidationMessages[i].ResourceType,
                        Category = validationResponse.ValidationMessages[i].Category,
                        Message = validationResponse.ValidationMessages[i].Message,
                        VirtualMachineName = validationResponse.ValidationMessages[i].VirtualMachineName
                    };
                }
                result.Result = "Validation failed.  Please see ValidationMessages for details";
            }

            return result;
        }
コード例 #2
0
        public static MigrationValidateContext ConvertToContext(OperationStatusResponse operationResponse,
                                                                NetworkMigrationValidationResponse validationResponse)
        {
            if (operationResponse == null)
            {
                return(null);
            }

            var  result          = new MigrationValidateContext();
            bool errorOccurred   = false;
            bool warningOccurred = false;

            if (validationResponse == null || validationResponse.ValidationMessages == null)
            {
                return(getResult(result, operationResponse, noMessage: true));
            }
            ;

            int messageCount = validationResponse.ValidationMessages.Count;

            result.ValidationMessages = new ValidationMessage[messageCount];
            for (int i = 0; i < messageCount; i++)
            {
                var validateMessage = validationResponse.ValidationMessages[i];

                result.ValidationMessages[i] = new ValidationMessage
                {
                    ResourceName       = validateMessage.ResourceName,
                    ResourceType       = validateMessage.ResourceType,
                    Category           = validateMessage.Category,
                    Message            = validateMessage.Message,
                    VirtualMachineName = validateMessage.VirtualMachineName
                };

                setFlag(validateMessage.Category, ref errorOccurred, ref warningOccurred);
            }

            return(getResult(result, operationResponse, errorOccurred, warningOccurred));;
        }
コード例 #3
0
        private static MigrationValidateContext getResult(MigrationValidateContext result, OperationStatusResponse operationResponse,
                                                          bool errorOccurred = false, bool warningOccurred = false, bool noMessage = false)
        {
            result.OperationId = operationResponse.Id;

            if (noMessage)
            {
                result.Result = "There are no ValidationMessages.";
            }
            else if (errorOccurred)
            {
                result.Result = "Validation Failed. Please see ValidationMessages object for additional details.";
            }
            else if (warningOccurred)
            {
                result.Result = "Validation Passed with warnings. Please see ValidationMessages object for a list of resources that will be migrated and additional detail on the warnings.";
            }
            else
            {
                result.Result = "Validation Passed. Please see ValidationMessages object for a list of resources that will be migrated.";
            }
            return(result);
        }