예제 #1
0
        async void ModifyPassword(object sender, RoutedEventArgs e)
        {
            string instanceId = GetSelectedInstance();

            if (instanceId != "Not found")
            {
                var url = ECSAPI.ModifyPassword(instanceId);
                using (var httpClient = new HttpClient())
                {
                    try
                    {
                        var response = await httpClient.GetAsync(url);

                        response.EnsureSuccessStatusCode();
                        MessageBox.Show("Action succeeded.");
                        GetInstanceList(this, new RoutedEventArgs());
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.ToString());
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select an instance.");
            }
        }
예제 #2
0
        async void CreateInstance(object sender, RoutedEventArgs e)
        {
            Window instanceTypeWnd = new SpecifyInstanceType();

            instanceTypeWnd.Owner = this;
            Hide();
            instanceTypeWnd.ShowDialog();
            var url = ECSAPI.CreateInstance(imageType);

            using (var httpClient = new HttpClient())
            {
                try
                {
                    var response = await httpClient.GetAsync(url);

                    response.EnsureSuccessStatusCode();
                    MessageBox.Show("Action succeeded.");
                    GetInstanceList(this, new RoutedEventArgs());
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.ToString());
                    return;
                }
            }
        }
예제 #3
0
        async void DeleteInstance(object sender, RoutedEventArgs e)
        {
            string instanceId = GetSelectedInstance();

            if (instanceId != "Not found")
            {
                var    url           = ECSAPI.DeleteInstance(instanceId);
                var    radios        = InstanceList.Children.OfType <RadioButton>();
                string instanceAlias = "";
                foreach (var ctrl in radios)
                {
                    if (ctrl.IsChecked == true)
                    {
                        instanceAlias = ctrl.Content.ToString();
                        break;
                    }
                }
                MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to delete instance " + instanceAlias + "?", "Confirm your operation", MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.No)
                {
                    return;
                }
                using (var httpClient = new HttpClient())
                {
                    try
                    {
                        var response = await httpClient.GetAsync(url);

                        response.EnsureSuccessStatusCode();
                        MessageBox.Show("Action succeeded.");
                        GetInstanceList(this, new RoutedEventArgs());
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.ToString());
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select an instance.");
            }
        }
예제 #4
0
        async void GetInstanceList(object sender, RoutedEventArgs e)
        {
            var    url = ECSAPI.GetInstanceList();
            string content;

            //Clipboard.SetText(url); return;
            using (var httpClient = new HttpClient())
            {
                try
                {
                    var response = await httpClient.GetAsync(url);

                    response.EnsureSuccessStatusCode();
                    content = await response.Content.ReadAsStringAsync();

                    RefreshInstanceList(content);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.ToString());
                    return;
                }
            }
        }