Beispiel #1
0
        private void Go_Window2()
        {
            if (inputsAreValid(source2_CB, profile2_CB, templateOrStack2_TB, validation2_LB))
            {
                AmazonCloudFormationClient CFclient  = null;
                AmazonEC2Client            EC2client = null;

                StackOriginal2 = new CFStack();
                StackCopy2     = new CFStack();

                try
                {
                    profileName2 = profile2_CB.Text;
                    if (validateTemplate_CB.Checked || source2_CB.Text == "AWS")
                    {
                        var creds = new StoredProfileAWSCredentials(profileName2);
                        CFclient  = new AmazonCloudFormationClient(creds);
                        EC2client = new AmazonEC2Client(creds);
                    }

                    switch (source2_CB.Text)
                    {
                    case "Template":
                        templatePath2 = templateOrStack2_TB.Text.Trim();
                        using (StreamReader sr = new StreamReader(templatePath2))
                        {
                            jasonString2 = sr.ReadToEnd();
                            if (validateTemplate_CB.Checked)
                            {
                                if (validateTemplate(jasonString2, CFclient))
                                {
                                    ProcessTemplate(jasonString2, richTextBox2, templatePath2, StackOriginal2);
                                }
                            }
                            else
                            {
                                ProcessTemplate(jasonString2, richTextBox2, templatePath2, StackOriginal2);
                            }
                        }
                        break;

                    case "AWS":
                        stackName2 = templateOrStack2_TB.Text.Trim();
                        ProcessLiveStack(stackName2, CFclient, EC2client, richTextBox2, StackOriginal2);
                        break;
                    }
                    profileName2 = profile2_CB.Text.Trim();
                }
                catch (Exception ex)
                {
                    richTextBox2.Text = ex.Message;
                }
                finally
                {
                    if (CFclient != null)
                    {
                        CFclient.Dispose();
                    }
                    if (EC2client != null)
                    {
                        EC2client.Dispose();
                    }
                }
            }
        }
Beispiel #2
0
        private void Go_Window1()
        {
            if (inputsAreValid(source1_CB, profile1_CB, templateOrStack1_TB, validation1_LB))
            {
                AmazonCloudFormationClient CFclient  = null;
                AmazonEC2Client            EC2client = null;

                StackOriginal1 = new CFStack();
                StackCopy1     = new CFStack();

                try
                {
                    profileName1 = profile1_CB.Text;
                    if (validateTemplate_CB.Checked || source1_CB.Text == "AWS")
                    {
                        var creds = new StoredProfileAWSCredentials(profileName1);
                        CFclient  = new AmazonCloudFormationClient(creds);
                        EC2client = new AmazonEC2Client(creds);
                    }

                    switch (source1_CB.Text)
                    {
                    case "Template":
                        templatePath1 = templateOrStack1_TB.Text.Trim();
                        using (StreamReader sr = new StreamReader(templatePath1))
                        {
                            jasonString1 = sr.ReadToEnd();
                            if (validateTemplate_CB.Checked)
                            {
                                if (validateTemplate(jasonString1, CFclient))
                                {
                                    ProcessTemplate(jasonString1, richTextBox1, templatePath1, StackOriginal1);
                                }
                            }
                            else
                            {
                                ProcessTemplate(jasonString1, richTextBox1, templatePath1, StackOriginal1);
                            }
                        }
                        break;

                    case "AWS":
                        stackName1 = templateOrStack1_TB.Text.Trim();
                        ProcessLiveStack(stackName1, CFclient, EC2client, richTextBox1, StackOriginal1);
                        break;
                    }
                    profileName1 = profile1_CB.Text.Trim();
                }
                catch (Exception ex)
                {
                    richTextBox1.Text = ex.Message + Environment.NewLine + ex.StackTrace;
                }
                finally
                {
                    if (CFclient != null)
                    {
                        CFclient.Dispose();
                    }
                    if (EC2client != null)
                    {
                        EC2client.Dispose();
                    }
                }
            }
        }