Пример #1
0
 public static FoundryTarget PaasTargetToFoundryTarget(PaasTarget paas, FoundryTarget target)
 {
     target.Applications = paas.CloudApplications;
     target.Build = paas.CloudInfo.Build;
     target.Description = paas.CloudInfo.Description;
     target.Frameworks = paas.CloudInfo.Frameworks;
     target.Limits = paas.CloudInfo.Limits;
     target.Usage = paas.CloudInfo.Usage;
     target.Version = paas.CloudInfo.Version;
     target.Support = paas.CloudInfo.Support;
     return target;
 }
        public void LoadActiveFoundryTarget()
        {
            var wrapper = new SettingsWrapper();
            var target = wrapper.GetActiveFoundryTarget();
            PasswordTextBox.Password = target.Password;
            TargetNameTextBox.Text = target.Name;
            TargetUriTextBox.Text = target.Path.ToString();
            UsernameTextBox.Text = target.Username;

            // TODO: Make this an asynchronous call
            try
            {
                // temporary pre-error handling & validation.
                var paas = new PaasTarget(target.Username, target.Password, target.Path);
                new SettingsWrapper().SetActiveFoundryTarget(Mappers.Map.PaasTargetToFoundryTarget(paas, target));

                var applications = paas.CloudApplications;
                foreach (var application in applications)
                {
                    var appDetail =
                        new CloudsAppDetails
                            {
                                ApplicationTile =
                                    {
                                        Title = application.Name,
                                        Count = FoundryApplication.GetInstanceCount(application),
                                    },
                                ApplicationInformationTextBlock =
                                    {
                                        Text =
                                            Properties.Resources.ApplicationMemory + application.Resources.Memory + "\n" +
                                            Properties.Resources.ApplicationDisk + application.Resources.Disk + "\n" +
                                            Properties.Resources.ApplicationStack + application.State + "\n" +
                                            Properties.Resources.ApplicationModel + application.Staging.Model + "\n" +
                                            Properties.Resources.ApplicationStack + application.Staging.Stack + "\n" +
                                            Properties.Resources.ApplicationUris + GetUris(application.Uris)
                                    }
                            };


                    CloudTargetApplications.Children.Add(appDetail);
                }
            }
            catch (Exception ex)
            {
                // Logging here.
                // Temporarily ignoring exceptions until I can look at and determine the unique results from Cloud Foundry.
                MessageBox.Show("This cloud was not found: " + ex.Message);
            }
        }