예제 #1
0
        private void txtName_TextChanged(object sender, EventArgs e)
        {
            TextBox txtSender = (TextBox)sender;

            ArmResourceGroup armResourceGroup = (ArmResourceGroup)_ResourceGroupNode.Tag;

            armResourceGroup.Name   = txtSender.Text;
            _ResourceGroupNode.Text = armResourceGroup.GetFinalTargetName();
            _ResourceGroupNode.Name = armResourceGroup.Name;
        }
예제 #2
0
        public void Write()
        {
            if (!Directory.Exists(_OutputPath))
            {
                throw new ArgumentException("Output path '" + _OutputPath + "' does not exist.");
            }

            StreamWriter templateWriter = null;

            try
            {
                templateWriter = new StreamWriter(GetTemplatePath());
                templateWriter.Write(GetTemplateString());
            }
            finally
            {
                if (templateWriter != null)
                {
                    templateWriter.Close();
                    templateWriter.Dispose();
                }
            }

            // save blob copy details file
            StreamWriter copyBlobDetailWriter = null;

            try
            {
                string jsontext = JsonConvert.SerializeObject(this.CopyBlobDetails, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings {
                    NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
                });
                copyBlobDetailWriter = new StreamWriter(GetCopyBlobDetailPath());
                copyBlobDetailWriter.Write(jsontext);
            }
            finally
            {
                if (copyBlobDetailWriter != null)
                {
                    copyBlobDetailWriter.Close();
                    copyBlobDetailWriter.Dispose();
                }
            }

            var          instructionPath   = Path.Combine(_OutputPath, "DeployInstructions.html");
            StreamWriter instructionWriter = null;

            try
            {
                var    assembly     = Assembly.GetExecutingAssembly();
                var    resourceName = "MigAz.Azure.Generator.AsmToArm.DeployDocTemplate.html";
                string instructionContent;

                using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        instructionContent = reader.ReadToEnd();
                    }

                instructionContent = instructionContent.Replace("{subscriptionId}", _TargetSubscription.SubscriptionId.ToString());
                instructionContent = instructionContent.Replace("{templatePath}", GetTemplatePath());
                instructionContent = instructionContent.Replace("{blobDetailsPath}", GetCopyBlobDetailPath());
                instructionContent = instructionContent.Replace("{resourceGroupName}", _TargetResourceGroup.GetFinalTargetName());
                instructionContent = instructionContent.Replace("{location}", _TargetResourceGroup.Location.Name);
                instructionContent = instructionContent.Replace("{migAzPath}", AppDomain.CurrentDomain.BaseDirectory);
                instructionContent = instructionContent.Replace("{migAzMessages}", BuildMigAzMessages());

                if (_TargetSubscription.AzureEnvironment == AzureEnvironment.AzureCloud)
                {
                    instructionContent = instructionContent.Replace("{migAzAzureEnvironmentSwitch}", String.Empty); // Default Azure Environment in Powershell, no AzureEnvironment switch needed
                }
                else
                {
                    instructionContent = instructionContent.Replace("{migAzAzureEnvironmentSwitch}", " -Environment \"" + _TargetSubscription.AzureEnvironment.ToString() + "\"");
                }

                instructionWriter = new StreamWriter(instructionPath);
                instructionWriter.Write(instructionContent);
            }
            finally
            {
                if (instructionWriter != null)
                {
                    instructionWriter.Close();
                    instructionWriter.Dispose();
                }
            }
        }