Ejemplo n.º 1
0
        private void okBTN_Click(object sender, EventArgs e)
        {
            if (demoRB.Checked)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else if (onlineRB.Checked)
            {
                this.Enabled = false;
                if (_activationForm.ShowDialog() == DialogResult.OK)
                {
                    FileStream fs = null;
                    try
                    {
                        ActivationService activator = new ActivationService();
                        //activator.Url = "http://localhost:6422/Services/ActivationService.asmx";
                        string hardwareId = Status.HardwareID;

                        AmphibianSoftware.VisualSail.WebServices.ActivationResponse response =
                            activator.RequestActivation(hardwareId,
                                                        "VISUALSAIL1",
                                                        _activationForm.GoogleOrderNumber,
                                                        _activationForm.SerialNumber,
                                                        _activationForm.Email,
                                                        _activationForm.FirstName,
                                                        _activationForm.LastName,
                                                        _activationForm.BoatClass,
                                                        _activationForm.HomePort);

                        if (response.License != null && response.License.Length > 0)
                        {
                            fs = new FileStream(_activatedLicensePath, FileMode.OpenOrCreate, FileAccess.Write);
                            fs.Write(response.License, 0, response.License.Length);
                            fs.Flush();
                            fs.Close();
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(response.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Online Activation Unavailible at this time, please try again later." + Environment.NewLine + ex.Message);
                    }
                }
                this.Enabled = true;
            }
            else if (fileRB.Checked)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "License Files|*.license";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    bool exeptionOccured = false;
                    try
                    {
                        FileInfo fi = new FileInfo(ofd.FileName);
                        fi.CopyTo(_activatedLicensePath, true);
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("License could not be loaded");
                    }
                }
            }
        }