private void initAddinNameList() { foreach (KeyValuePair <string, string> entry in this.mAddinNameList) { AddinNameItem item = new AddinNameItem(); item.Text = entry.Value; item.Value = entry.Key; this.cbLicenseFor.Items.Add(item); } this.cbLicenseFor.SelectedIndex = 0; }
private void genSerialKey() { try { FileStream fs = new FileStream(this.tbImportFile.Text, FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fs); strCode = reader.ReadToEnd(); SQLHID = strCode; reader.Close(); } catch { MessageBox.Show("Please insert a *.HID file."); return; } //Get file name string filename = Path.GetFileName(this.tbImportFile.Text); int index = filename.IndexOf("."); if (index > 0) { filename = filename.Substring(0, index); } AddinNameItem item = this.cbLicenseFor.SelectedItem as AddinNameItem; VersionItem itemver = this.cbVersionFor.SelectedItem as VersionItem; strCode = strCode + item.Value + itemver.Value + "|" + this.createExpiredTime(); String randomKey = this.randomKey() + EXTRA_KEY; strCode = this.encodeByDES(strCode, randomKey); strCode = strCode + "." + this.encodeByDES(randomKey, TRIDES_KEY); //FolderBrowserDialog openFileDiaglog = new FolderBrowserDialog(); SaveFileDialog openFileDiaglog = new SaveFileDialog(); openFileDiaglog.Filter = "All Files (*.cert)|*.cert"; openFileDiaglog.FileName = filename; if (openFileDiaglog.ShowDialog() == DialogResult.OK) { string filePath = Path.Combine(openFileDiaglog.FileName /*,filename+".cert"*/); FileStream fscert = new FileStream(filePath, FileMode.Create, FileAccess.Write); StreamWriter writer = new StreamWriter(fscert); writer.Write(strCode); writer.Close(); ConnectionString connection = new ConnectionString(); connection.ConnectSqlParam(); connection.insertInfo(tbCustomerName.Text, tbAddress.Text, this.cbLicenseFor.SelectedItem.ToString(), cbVersionFor.SelectedItem.ToString() , cbExpirationTime.SelectedItem.ToString(), SQLHID, TempSystem.UserName); //if (!File.Exists(filePath)) // { // } // else // { // MessageBox.Show("File " + filename + ".cert already exists."); // } } }