Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/18/12 14:58:17 (13 years ago)
Author:
spimming
Message:

#1680:

  • Check if password is valid for pfx file
  • progress bar is now marquee style
  • control flow refactored
Location:
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.Designer.cs

    r7354 r7362  
    5252      this.btnOk = new System.Windows.Forms.Button();
    5353      this.btnCancel = new System.Windows.Forms.Button();
     54      this.lblCertificateFile = new System.Windows.Forms.Label();
    5455      this.gbNewHostedService.SuspendLayout();
    5556      this.panelDeploymentOptions.SuspendLayout();
     
    321322      this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
    322323      //
     324      // lblCertificateFile
     325      //
     326      this.lblCertificateFile.AutoSize = true;
     327      this.lblCertificateFile.Location = new System.Drawing.Point(118, 341);
     328      this.lblCertificateFile.Name = "lblCertificateFile";
     329      this.lblCertificateFile.Size = new System.Drawing.Size(0, 13);
     330      this.lblCertificateFile.TabIndex = 19;
     331      //
    323332      // AddAzureServiceDialog
    324333      //
     
    326335      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    327336      this.ClientSize = new System.Drawing.Size(496, 436);
     337      this.Controls.Add(this.lblCertificateFile);
    328338      this.Controls.Add(this.lblCores);
    329339      this.Controls.Add(this.btnCancel);
     
    383393    private System.Windows.Forms.Button btnOk;
    384394    private System.Windows.Forms.Button btnCancel;
     395    private System.Windows.Forms.Label lblCertificateFile;
    385396  }
    386397}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs

    r7357 r7362  
    1818    private bool bwCompleted;
    1919    private bool closePending;
     20
     21    private string certificateFile;
     22    private string certificatePassword;
    2023
    2124    public AddAzureServiceDialog(IItemList<Subscription> subs) {
     
    124127      using (var form = new AddCertificate()) {
    125128        form.ShowDialog();
     129        if (!form.ErrorOccured) {
     130          certificateFile = form.CertificateFile;
     131          certificatePassword = form.CertificatePassword;
     132          lblCertificateFile.Text = certificateFile;
     133        }
    126134      }
    127135    }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddCertificate.Designer.cs

    r7339 r7362  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddCertificate));
    2627      this.label1 = new System.Windows.Forms.Label();
    2728      this.tbCertificateFile = new System.Windows.Forms.TextBox();
     
    121122      this.Controls.Add(this.tbCertificateFile);
    122123      this.Controls.Add(this.label1);
     124      this.Icon = HeuristicLab.Common.Resources.HeuristicLab.Icon;
    123125      this.Name = "AddCertificate";
    124126      this.Text = "AddCertificate";
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddCertificate.cs

    r7339 r7362  
    11using System;
    22using System.ComponentModel;
    3 using System.Threading;
     3using System.Security.Cryptography.X509Certificates;
    44using System.Windows.Forms;
    55
     
    88    private BackgroundWorker worker = new BackgroundWorker();
    99    public bool ErrorOccured { get; set; }
     10    public string CertificateFile { get; set; }
     11    public string CertificatePassword { get; set; }
    1012
    1113    public AddCertificate() {
    1214      InitializeComponent();
     15      ErrorOccured = true;
     16
    1317      worker.DoWork += new DoWorkEventHandler(AddCertificateTask);
    1418      worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
     
    2832
    2933    private void btnOk_Click(object sender, EventArgs e) {
    30       if (tbCertificateFile.Text.Length == 0) {
     34      CertificateFile = tbCertificateFile.Text;
     35      CertificatePassword = tbCertificatePassword.Text;
     36
     37      if (CertificateFile.Length == 0) {
    3138        MessageBox.Show("Certificate file is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    32       } else if (tbCertificatePassword.Text.Length == 0) {
     39      } else if (CertificatePassword.Length == 0) {
    3340        MessageBox.Show("Password is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    3441      } else {
    3542        SetControlsEnabled(false);
    3643        progressBar.Visible = true;
    37         worker.RunWorkerAsync();
     44        var parameters = Tuple.Create<string, string>(CertificateFile, CertificatePassword);
     45        worker.RunWorkerAsync(parameters);
    3846      }
    39 
    4047    }
    4148
     
    4855
    4956    private void AddCertificateTask(object sender, DoWorkEventArgs e) {
    50       try {
    51         // simulate service call
    52         Thread.Sleep(3000);
    53       }
    54       catch (Exception ex) {
    55         ErrorOccured = true;
    56         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    57       }
     57      Tuple<string, string> parameters = e.Argument as Tuple<string, string>;
     58      string file = parameters.Item1;
     59      string pw = parameters.Item2;
     60
     61      X509Certificate cert = new X509Certificate(file, pw);
    5862    }
    5963
    6064    private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    6165      progressBar.Visible = false;
    62       if (!ErrorOccured) {
     66
     67      if (e.Error == null) {
     68        ErrorOccured = false;
    6369        this.Close();
    6470      } else {
     71        MessageBox.Show(e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     72        CertificateFile = string.Empty;
     73        CertificateFile = string.Empty;
     74        ErrorOccured = true;
    6575        this.Show();
    6676        SetControlsEnabled(true);
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddSubscriptionDialog.Designer.cs

    r7324 r7362  
    122122      //
    123123      this.progressBar.Location = new System.Drawing.Point(15, 107);
     124      this.progressBar.MarqueeAnimationSpeed = 10;
    124125      this.progressBar.Name = "progressBar";
    125126      this.progressBar.Size = new System.Drawing.Size(340, 23);
     127      this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
    126128      this.progressBar.TabIndex = 29;
    127129      this.progressBar.Visible = false;
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddSubscriptionDialog.cs

    r7324 r7362  
    1 using System;
    2 using System.ComponentModel;
    3 using System.Threading;
     1using System.ComponentModel;
    42using System.Windows.Forms;
    53using HeuristicLab.Clients.Hive.CloudManager.Model;
     
    2018      cbDiscoverServices.Checked = true;
    2119
    22       SetWorkerEvents();
     20      worker.DoWork += new DoWorkEventHandler(LoadSubscription);
     21      worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
     22
    2323      ErrorOccured = true;
    2424    }
     
    2626    private void btnOk_Click(object sender, System.EventArgs e) {
    2727      this.progressBar.Visible = true;
    28       //this.progressBar.Style = ProgressBarStyle.Continuous;
    2928      worker.RunWorkerAsync();
    3029    }
     
    3433    }
    3534
    36     private void SetWorkerEvents() {
    37       worker.WorkerReportsProgress = true;
    38       worker.DoWork += new DoWorkEventHandler(LoadSubscription);
    39       worker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged);
    40       worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
    41     }
    42 
    43     private void ProgressChanged(object sender, ProgressChangedEventArgs e) {
    44       progressBar.Value = e.ProgressPercentage;
     35    private void LoadSubscription(object sender, DoWorkEventArgs e) {
     36      e.Result = CloudManagerClient.Instance.AzureProvider.GetSubscriptionInfo(txtSubscriptionId.Text, txtCertThumbprint.Text);
    4537    }
    4638
    4739    private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    4840      progressBar.Visible = false;
    49       if (!ErrorOccured) {
     41      if (e.Error == null) {
     42        ErrorOccured = false;
     43        Subscription = (Subscription)e.Result;
     44        Subscription.SaveToConfig = cbSaveSubscription.Checked;
     45        Subscription.DiscoverServices = cbDiscoverServices.Checked;
    5046        this.Close();
    5147      } else {
     48        MessageBox.Show(e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     49        ErrorOccured = true;
     50        Subscription = null;
    5251        this.Show();
    53       }
    54     }
    55 
    56     private void LoadSubscription(object sender, DoWorkEventArgs e) {
    57       try {
    58         worker.ReportProgress(25, "Add Subscription");
    59         Subscription = CloudManagerClient.Instance.AzureProvider.GetSubscriptionInfo(txtSubscriptionId.Text, txtCertThumbprint.Text);
    60         Subscription.SaveToConfig = cbSaveSubscription.Checked;
    61         Subscription.DiscoverServices = cbDiscoverServices.Checked;
    62         ErrorOccured = false;
    63       }
    64       catch (SystemException ex) {
    65         ErrorOccured = true;
    66         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    67       }
    68       try {
    69 
    70         if (!ErrorOccured) {
    71           worker.ReportProgress(50, "Get Subscription Info");
    72           //TODO: operation
    73           ErrorOccured = false;
    74         }
    75       }
    76       catch (SystemException ex) {
    77         ErrorOccured = true;
    78         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    79         worker.ReportProgress(25, "Rollback: Remove hosted service");
    80         // Rollback operation
    81       }
    82 
    83       if (!ErrorOccured) {
    84         worker.ReportProgress(100, "");
    85         Thread.Sleep(1000);
    8652      }
    8753    }
Note: See TracChangeset for help on using the changeset viewer.