1 | using System.ComponentModel;
|
---|
2 | using System.Windows.Forms;
|
---|
3 | using HeuristicLab.Clients.Hive.CloudManager.Model;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Clients.Hive.CloudManager.Views {
|
---|
6 | public partial class AddSubscriptionDialog : Form {
|
---|
7 | public bool ErrorOccured { get; set; }
|
---|
8 | public Subscription Subscription { get; set; }
|
---|
9 |
|
---|
10 | private BackgroundWorker worker = new BackgroundWorker();
|
---|
11 |
|
---|
12 | public AddSubscriptionDialog() {
|
---|
13 | InitializeComponent();
|
---|
14 |
|
---|
15 | txtCertThumbprint.Text = "EFFD1808EF2F0658C52997CF00F7A86680F9FA62";
|
---|
16 | txtSubscriptionId.Text = "271e67e2-3132-4429-b0e7-ab94d3a95554";
|
---|
17 | cbSaveSubscription.Checked = false;
|
---|
18 | cbDiscoverServices.Checked = true;
|
---|
19 |
|
---|
20 | worker.DoWork += new DoWorkEventHandler(LoadSubscription);
|
---|
21 | worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
|
---|
22 |
|
---|
23 | ErrorOccured = true;
|
---|
24 | }
|
---|
25 |
|
---|
26 | private void btnOk_Click(object sender, System.EventArgs e) {
|
---|
27 | this.progressBar.Visible = true;
|
---|
28 | worker.RunWorkerAsync();
|
---|
29 | }
|
---|
30 |
|
---|
31 | private void btnCancel_Click(object sender, System.EventArgs e) {
|
---|
32 | this.Close();
|
---|
33 | }
|
---|
34 |
|
---|
35 | private void LoadSubscription(object sender, DoWorkEventArgs e) {
|
---|
36 | e.Result = CloudManagerClient.Instance.AzureProvider.GetSubscriptionInfo(txtSubscriptionId.Text, txtCertThumbprint.Text);
|
---|
37 | }
|
---|
38 |
|
---|
39 | private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
|
---|
40 | progressBar.Visible = false;
|
---|
41 | if (e.Error == null) {
|
---|
42 | ErrorOccured = false;
|
---|
43 | Subscription = (Subscription)e.Result;
|
---|
44 | Subscription.SaveToConfig = cbSaveSubscription.Checked;
|
---|
45 | Subscription.DiscoverServices = cbDiscoverServices.Checked;
|
---|
46 | this.Close();
|
---|
47 | } else {
|
---|
48 | MessageBox.Show(e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
---|
49 | ErrorOccured = true;
|
---|
50 | Subscription = null;
|
---|
51 | this.Show();
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|