/// <summary> /// Try to set new license for actual domain. /// </summary> public void SetLicenseKey() { if (txtLicense.Text == "") { throw new Exception(ResHelper.GetFileString("Install.LicenseEmpty")); } LicenseKeyInfo lki = new LicenseKeyInfo(); lki.LoadLicense(txtLicense.Text, FullHostName); switch (lki.ValidationResult) { case LicenseValidationEnum.Expired: throw new Exception(ResHelper.GetFileString("Install.LicenseNotValid.Expired")); case LicenseValidationEnum.Invalid: throw new Exception(ResHelper.GetFileString("Install.LicenseNotValid.Invalid")); case LicenseValidationEnum.NotAvailable: throw new Exception(ResHelper.GetFileString("Install.LicenseNotValid.NotAvailable")); case LicenseValidationEnum.WrongFormat: throw new Exception(ResHelper.GetFileString("Install.LicenseNotValid.WrongFormat")); case LicenseValidationEnum.Valid: // Try to store license into database if ((FullHostName == "localhost") || (FullHostName == "127.0.0.1") || (lki.Domain == FullHostName)) { LicenseKeyInfoProvider.SetLicenseKeyInfo(lki); } else { throw new Exception(ResHelper.GetFileString("Install.LicenseForDifferentDomain")); } break; } }
protected void btnOK_Click(object sender, EventArgs e) { errorOccured = false; try { LicenseKeyInfo lk = new LicenseKeyInfo(); lk.LoadLicense(tbLicenseKey.Text.Trim(), ""); if (lk != null) { switch (lk.ValidationResult) { case LicenseValidationEnum.Expired: ShowError(GetString("Licenses_License_New.LicenseNotValid.Expired")); break; case LicenseValidationEnum.Invalid: ShowError(GetString("Licenses_License_New.LicenseNotValid.Invalid")); break; case LicenseValidationEnum.NotAvailable: ShowError(GetString("Licenses_License_New.LicenseNotValid.NotAvailable")); break; case LicenseValidationEnum.WrongFormat: ShowError(GetString("Licenses_License_New.LicenseNotValid.WrongFormat")); break; case LicenseValidationEnum.Valid: if (LicenseKeyInfoProvider.IsLicenseExistForDomain(lk)) { // License for domain already exist ShowError(GetString("Licenses_License_New.DomainAlreadyExists").Replace("%%name%%", lk.Domain)); } else { // Insert license LicenseKeyInfoProvider.SetLicenseKeyInfo(lk); UserInfoProvider.ClearLicenseValues(); Functions.ClearHashtables(); } break; } } } catch (Exception ex) { EventLogProvider.LogException("License", "NEW", ex); ShowError(GetString("general.saveerror"), ex.Message, null); } if (!errorOccured) { URLHelper.Redirect("License_List.aspx"); } }
private void Control_OnAfterValidate(object sender, EventArgs e) { try { string licenseKey = ValidationHelper.GetString(Control.GetFieldValue("LicenseKey"), String.Empty).Trim(); LicenseKeyInfo lk = new LicenseKeyInfo(); lk.LoadLicense(licenseKey, ""); switch (lk.ValidationResult) { case LicenseValidationEnum.Valid: using (new CMSActionContext { AllowLicenseRedirect = false }) { UserInfoProvider.ClearLicenseValues(); Functions.ClearHashtables(); } return; case LicenseValidationEnum.Expired: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.Expired"); break; case LicenseValidationEnum.Invalid: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.Invalid"); break; case LicenseValidationEnum.NotAvailable: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.NotAvailable"); break; case LicenseValidationEnum.WrongFormat: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.WrongFormat"); break; } Control.StopProcessing = true; Control.ShowValidationErrorMessage = true; } catch (Exception ex) { EventLogProvider.LogException("License", "NEW", ex); Control.ValidationErrorMessage = ResHelper.GetString("general.saveerror"); } }
/// <summary> /// External data binding handler. /// </summary> private object Control_OnExternalDataBound(object sender, string sourcename, object parameter) { switch (sourcename.ToLowerCSafe()) { case "editionname": string edition = ValidationHelper.GetString(parameter, "").ToUpperCSafe(); try { return(LicenseHelper.GetEditionName(EnumStringRepresentationExtensions.ToEnum <ProductEditionEnum>(edition))); } catch { return("#UNKNOWN#"); } case "expiration": var row = (DataRowView)parameter; LicenseKeyInfo licenseInfo = new LicenseKeyInfo(); licenseInfo.LoadLicense(ValidationHelper.GetString(row["LicenseKey"], string.Empty), ValidationHelper.GetString(row["LicenseDomain"], string.Empty)); if (licenseInfo.LicenseGuid == null) { return(ResHelper.GetString(Convert.ToString(row["LicenseExpiration"]))); } else { // subtract grace period for subscription license return(licenseInfo.ExpirationDateReal.AddDays(-SUBSCRIPTION_LICENSE_EXPIRATION_GRACE_DAYS).ToString(LicenseKeyInfo.LICENSE_EXPIRATION_DATE_FORMAT, CultureInfo.InvariantCulture)); } case "licenseservers": int count = ValidationHelper.GetInteger(parameter, -1); if (count == LicenseKeyInfo.SERVERS_UNLIMITED) { return(ResHelper.GetString("general.unlimited")); } if (count > 0) { return(count.ToString()); } return(String.Empty); } return(parameter); }
/// <summary> /// Try to set new license for actual domain. /// </summary> public void SetLicenseKey() { if (txtLicense.Text == "") { throw new InvalidOperationException(ResHelper.GetFileString("Install.LicenseEmpty")); } LicenseKeyInfo lki = new LicenseKeyInfo(); lki.LoadLicense(txtLicense.Text, FullHostName); switch (lki.ValidationResult) { case LicenseValidationEnum.Expired: throw new InvalidOperationException(ResHelper.GetFileString("Install.LicenseNotValid.Expired")); case LicenseValidationEnum.Invalid: throw new InvalidOperationException(ResHelper.GetFileString("Install.LicenseNotValid.Invalid")); case LicenseValidationEnum.NotAvailable: throw new InvalidOperationException(ResHelper.GetFileString("Install.LicenseNotValid.NotAvailable")); case LicenseValidationEnum.WrongFormat: throw new InvalidOperationException(ResHelper.GetFileString("Install.LicenseNotValid.WrongFormat")); case LicenseValidationEnum.Valid: // Try to store license into database if ((FullHostName == "localhost") || (FullHostName == "127.0.0.1") || (lki.Domain == FullHostName)) { LicenseKeyInfoProvider.SetLicenseKeyInfo(lki); } else { throw new InvalidOperationException(ResHelper.GetFileString("Install.LicenseForDifferentDomain")); } break; } }
private void Control_OnAfterValidate(object sender, EventArgs e) { try { string licenseKey = ValidationHelper.GetString(Control.GetFieldValue("LicenseKey"), String.Empty).Trim(); LicenseKeyInfo lk = new LicenseKeyInfo(); lk.LoadLicense(licenseKey, ""); switch (lk.ValidationResult) { case LicenseValidationEnum.Valid: return; case LicenseValidationEnum.Expired: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.Expired"); break; case LicenseValidationEnum.Invalid: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.Invalid"); break; case LicenseValidationEnum.NotAvailable: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.NotAvailable"); break; case LicenseValidationEnum.WrongFormat: Control.ValidationErrorMessage = ResHelper.GetString("Licenses_License_New.LicenseNotValid.WrongFormat"); break; } Control.StopProcessing = true; Control.ShowValidationErrorMessage = true; } catch (Exception ex) { Service.Resolve <IEventLogService>().LogException("License", "NEW", ex); Control.ValidationErrorMessage = ResHelper.GetString("general.saveerror"); } }
protected void btnOK_Click(object sender, EventArgs e) { lblError.Text = ""; try { LicenseKeyInfo lk = new LicenseKeyInfo(); lk.LoadLicense(tbLicenseKey.Text.Trim(), ""); if (lk != null) { switch (lk.ValidationResult) { case LicenseValidationEnum.Expired: lblError.Text = GetString("Licenses_License_New.LicenseNotValid.Expired"); break; case LicenseValidationEnum.Invalid: lblError.Text = GetString("Licenses_License_New.LicenseNotValid.Invalid"); break; case LicenseValidationEnum.NotAvailable: lblError.Text = GetString("Licenses_License_New.LicenseNotValid.NotAvailable"); break; case LicenseValidationEnum.WrongFormat: lblError.Text = GetString("Licenses_License_New.LicenseNotValid.WrongFormat"); break; case LicenseValidationEnum.Valid: if (LicenseKeyInfoProvider.IsLicenseExistForDomain(lk)) { // License for domain already exist lblInfo.Visible = false; lblError.Visible = true; lblError.Text = GetString("Licenses_License_New.DomainAlreadyExists").Replace("%%name%%", lk.Domain); } else { // Insert license LicenseKeyInfoProvider.SetLicenseKeyInfo(lk); CMS.SiteProvider.UserInfoProvider.ClearLicenseValues(); Functions.ClearHashtables(); URLHelper.Redirect("License_List.aspx"); } break; } } if (lblError.Text != "") { lblInfo.Visible = false; lblError.Visible = true; } } catch (Exception ex) { lblInfo.Visible = false; lblError.Visible = true; lblError.Text = ex.Message; } }
/// <summary> /// Inserts license to database. /// </summary> /// <param name="license">License to insert</param> private void InsertLicense(string license) { string error = string.Empty; string exists = string.Empty; LicenseKeyInfo lk = new LicenseKeyInfo(); try { // Load license lk.LoadLicense(license.Trim(), ""); switch (lk.ValidationResult) { case LicenseValidationEnum.Expired: error = GetString("Licenses_License_New.LicenseNotValid.Expired"); break; case LicenseValidationEnum.Invalid: error = GetString("Licenses_License_New.LicenseNotValid.Invalid"); break; case LicenseValidationEnum.NotAvailable: error = GetString("Licenses_License_New.LicenseNotValid.NotAvailable"); break; case LicenseValidationEnum.WrongFormat: error = GetString("Licenses_License_New.LicenseNotValid.WrongFormat"); break; case LicenseValidationEnum.Valid: if (!LicenseKeyInfoProvider.IsLicenseExistForDomain(lk)) { LicenseKeyInfoProvider.SetLicenseKeyInfo(lk); } else { // If override if (chkOverrideExisting.Checked) { // Get old license lk = LicenseKeyInfoProvider.GetLicenseKeyInfo(lk.Domain); if (lk != null) { // Delete old license LicenseKeyInfoProvider.DeleteLicenseKeyInfo(lk); // Create new and load lk = new LicenseKeyInfo(); lk.LoadLicense(license.Trim(), ""); // Save switch (lk.ValidationResult) { case LicenseValidationEnum.Valid: LicenseKeyInfoProvider.SetLicenseKeyInfo(lk); break; } } } else { exists = GetString("license.import.skipped") + " " + GetString("Licenses_License_New.DomainAlreadyExists").Replace("%%name%%", lk.Domain); } } break; } } catch (Exception) { error = GetString("license.import.failed"); } // Result if (!string.IsNullOrEmpty(error)) { string msg = ""; if (string.IsNullOrEmpty(lk.Domain)) { msg = GetString("license.import.failed"); } else { msg = string.Format(GetString("license.import.faileddomain"), lk.Domain); } msg += ResHelper.Colon + " " + error; msg = "<span class=\"LineErrorLabel\">" + msg + "</span>"; ImportManager.Settings.LogProgressState(LogStatusEnum.Info, msg); } else if (!string.IsNullOrEmpty(exists)) { ImportManager.Settings.LogProgressState(LogStatusEnum.Info, exists); } else { ImportManager.Settings.LogProgressState(LogStatusEnum.Info, string.Format(GetString("license.import.success"), lk.Domain)); } }
/// <summary> /// Inserts license to database. /// </summary> /// <param name="license">License to insert</param> private void InsertLicense(string license) { string error = string.Empty; string exists = string.Empty; LicenseKeyInfo lk = new LicenseKeyInfo(); try { // Load license lk.LoadLicense(license.Trim(), ""); switch (lk.ValidationResult) { case LicenseValidationEnum.Expired: error = GetString("Licenses_License_New.LicenseNotValid.Expired"); break; case LicenseValidationEnum.Invalid: error = GetString("Licenses_License_New.LicenseNotValid.Invalid"); break; case LicenseValidationEnum.NotAvailable: error = GetString("Licenses_License_New.LicenseNotValid.NotAvailable"); break; case LicenseValidationEnum.WrongFormat: error = GetString("Licenses_License_New.LicenseNotValid.WrongFormat"); break; case LicenseValidationEnum.Valid: if(!LicenseKeyInfoProvider.IsLicenseExistForDomain(lk)) { LicenseKeyInfoProvider.SetLicenseKeyInfo(lk); } else { // If override if (chkOverrideExisting.Checked) { // Get old license lk = LicenseKeyInfoProvider.GetLicenseKeyInfo(lk.Domain); if (lk != null) { // Delete old license LicenseKeyInfoProvider.DeleteLicenseKeyInfo(lk); // Create new and load lk = new LicenseKeyInfo(); lk.LoadLicense(license.Trim(), ""); // Save switch (lk.ValidationResult) { case LicenseValidationEnum.Valid: LicenseKeyInfoProvider.SetLicenseKeyInfo(lk); break; } } } else { exists = GetString("license.import.skipped") + " " + GetString("Licenses_License_New.DomainAlreadyExists").Replace("%%name%%", lk.Domain); } } break; } } catch (Exception) { error = GetString("license.import.failed"); } // Result if (!string.IsNullOrEmpty(error)) { string msg = ""; if (string.IsNullOrEmpty(lk.Domain)) { msg = GetString("license.import.failed") ; } else { msg = string.Format(GetString("license.import.faileddomain"), lk.Domain) ; } msg += ResHelper.Colon + " " + error; msg = "<span class=\"LineErrorLabel\">" + msg + "</span>"; ImportManager.Settings.LogProgressState(LogStatusEnum.Info, msg); } else if (!string.IsNullOrEmpty(exists)) { ImportManager.Settings.LogProgressState(LogStatusEnum.Info, exists); } else { ImportManager.Settings.LogProgressState(LogStatusEnum.Info, string.Format(GetString("license.import.success"), lk.Domain)); } }
/// <summary> /// Creates requested license keys. Returns false if something fail. /// </summary> /// <param name="connectionString">Connection string</param> public bool ProcessRegistration(string connectionString) { string result = ""; string lickey = ""; // Delete all existing license keys DataSet ds = LicenseKeyInfoProvider.GetAllLicenseKeys(); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { LicenseKeyInfo lki = new LicenseKeyInfo(dr); if (lki != null) { LicenseKeyInfoProvider.DeleteLicenseKeyInfo(lki.LicenseKeyID); } } } // Create license keys for localhost and 127.0.0.1 LicenseKeyInfo flki = new LicenseKeyInfo(); flki.LoadLicense("DOMAIN:localhost\nPRODUCT:CF06\nEXPIRATION:00000000\nPACKAGES:\nSERVERS:1\n" + "DH0g3D1mDvNiMgqujyU5TspX3oB3TlsFUgSgR2p3MHe3VY+xgQvsn1kMRA6w+ZOLwLFbjjziznLX73V2DAzBXBBxQH1sSP6pnvua1qYyPXN5Mb3v9bd53nT1wgwiPvJSGLEKzsV/sf0RgtsrcBJTlGNSOAUG9qnkrSQlrLRkSdUzfZl4HdAidy53yZB4ydmGstxDOZWjCZvl7pOSL+PrOsYv5QbXz3eC4/dQJDNKG+lJkeuq/wXyMmhz/jj+JkSJQnvr9DIuEiYAqp1j4YNRVvGPv7FQqfPIixwQPXn73K7dBGwzUmmGzFUSXR0gLPpdG4nD5eoTOp1qaeKo4qy68A==", "localhost"); LicenseKeyInfoProvider.SetLicenseKeyInfo(flki); flki = new LicenseKeyInfo(); flki.LoadLicense("DOMAIN:127.0.0.1\nPRODUCT:CF06\nEXPIRATION:00000000\nPACKAGES:\nSERVERS:1\n" + "Mo0XU+buTy0eaW57psUxemEkBfo5pNAzGupE05V+LZmfykV75XnfFxX4Ac5O6kD4QQwDBKMBYf4qNYxOMI6JAXe0j3Qv8W9FJ6TG7TLD4ga/Ru9OOapXH6R86wepeLSdG0PKDL96JR4QNsUz1fZbRodxdOhvIEy8FvpF1JHUj04rc8DVFCJvkcrvmbfd+ZlfjGxo7GnfMOXE4FRlf3joK13jxiJypiGe4Tu71LiQgRlFFIWfXTm/WKgMT+wpQnIm/lUnWug5g0N2CkcEZ/dNfCOGBUqU4ImPjWGKdyfcYyS+F1FgvPI2sdzxIUnLtYu834fqgoEUzBsIuME3tNr8UQ==", "127.0.0.1"); LicenseKeyInfoProvider.SetLicenseKeyInfo(flki); // Create free license keys for user defined domain string domainName = URLHelper.CorrectDomainName(txtUserDomain.Text.Trim()); string firstName = txtUserFirstName.Text.Trim(); string lastName = txtUserLastName.Text.Trim(); string email = txtUserEmail.Text.Trim(); bool userForm = !String.IsNullOrEmpty(firstName) || !String.IsNullOrEmpty(lastName) || !String.IsNullOrEmpty(email) || !String.IsNullOrEmpty(txtPassword.Text); // Ignore localhost/127.0.0.1 licenses if ((String.Compare(domainName, "localhost", true) == 0) || (String.Compare(domainName, "127.0.0.1") == 0)) { domainName = ""; } // Do not modify anything if form is blank if (!String.IsNullOrEmpty(domainName) || userForm) { if (userForm) { result = new Validator().NotEmpty(firstName, ResHelper.GetString(strPrefix + "firstnamerequired")) .NotEmpty(lastName, ResHelper.GetString(strPrefix + "lastnamerequired")) .NotEmpty(email, ResHelper.GetString(strPrefix + "emailrequired")) .IsEmail(email, ResHelper.GetString(strPrefix + "emailinvalidformat")) .Result; if (String.IsNullOrEmpty(result) && plcPass.Visible && String.IsNullOrEmpty(txtPassword.Text)) { result = ResHelper.GetString(strPrefix + "passwordrequired"); } } if (String.IsNullOrEmpty(result)) { LS.CMSLicenseService ls = new LS.CMSLicenseService(); if (userForm) { if (ls.UserExists(email)) { // If user with specified name (e-mail) already exist ask for her password if (!plcPass.Visible) { plcPass.Visible = true; result = ResHelper.GetString(strPrefix + "passwordrequired"); } else { lickey = ls.GetFreeEditionKeyGeneral(domainName, firstName, lastName, email, txtPassword.Text, 6); } } else { // Register new user and get license key lickey = ls.GetFreeEditionKeyGeneral(domainName, firstName, lastName, email, UserInfoProvider.GenerateNewPassword(), 6); } } else { lickey = ls.GetFreeEditionKeyGeneral(domainName, null, null, null, null, 6); } if (String.IsNullOrEmpty(result) && !lickey.StartsWith("DOMAIN")) { result = lickey; } } if (String.IsNullOrEmpty(result)) { if (!String.IsNullOrEmpty(lickey)) { LicenseKeyInfo lki = new LicenseKeyInfo(); lki.LoadLicense(lickey, ""); LicenseKeyInfoProvider.SetLicenseKeyInfo(lki); } } } if (!String.IsNullOrEmpty(result)) { lblError.Visible = true; lblError.Text = result; } return String.IsNullOrEmpty(result); }
/// <summary> /// Creates requested license keys. Returns false if something fail. /// </summary> /// <param name="connectionString">Connection string</param> public bool ProcessRegistration(string connectionString) { string result = ""; string lickey = ""; // Delete all existing license keys DataSet ds = LicenseKeyInfoProvider.GetAllLicenseKeys(); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { LicenseKeyInfo lki = new LicenseKeyInfo(dr); if (lki != null) { LicenseKeyInfoProvider.DeleteLicenseKeyInfo(lki.LicenseKeyID); } } } // Create license keys for localhost and 127.0.0.1 LicenseKeyInfo flki = new LicenseKeyInfo(); flki.LoadLicense("DOMAIN:localhost\nPRODUCT:CF06\nEXPIRATION:00000000\nPACKAGES:\nSERVERS:1\n" + "DH0g3D1mDvNiMgqujyU5TspX3oB3TlsFUgSgR2p3MHe3VY+xgQvsn1kMRA6w+ZOLwLFbjjziznLX73V2DAzBXBBxQH1sSP6pnvua1qYyPXN5Mb3v9bd53nT1wgwiPvJSGLEKzsV/sf0RgtsrcBJTlGNSOAUG9qnkrSQlrLRkSdUzfZl4HdAidy53yZB4ydmGstxDOZWjCZvl7pOSL+PrOsYv5QbXz3eC4/dQJDNKG+lJkeuq/wXyMmhz/jj+JkSJQnvr9DIuEiYAqp1j4YNRVvGPv7FQqfPIixwQPXn73K7dBGwzUmmGzFUSXR0gLPpdG4nD5eoTOp1qaeKo4qy68A==", "localhost"); LicenseKeyInfoProvider.SetLicenseKeyInfo(flki); flki = new LicenseKeyInfo(); flki.LoadLicense("DOMAIN:127.0.0.1\nPRODUCT:CF06\nEXPIRATION:00000000\nPACKAGES:\nSERVERS:1\n" + "Mo0XU+buTy0eaW57psUxemEkBfo5pNAzGupE05V+LZmfykV75XnfFxX4Ac5O6kD4QQwDBKMBYf4qNYxOMI6JAXe0j3Qv8W9FJ6TG7TLD4ga/Ru9OOapXH6R86wepeLSdG0PKDL96JR4QNsUz1fZbRodxdOhvIEy8FvpF1JHUj04rc8DVFCJvkcrvmbfd+ZlfjGxo7GnfMOXE4FRlf3joK13jxiJypiGe4Tu71LiQgRlFFIWfXTm/WKgMT+wpQnIm/lUnWug5g0N2CkcEZ/dNfCOGBUqU4ImPjWGKdyfcYyS+F1FgvPI2sdzxIUnLtYu834fqgoEUzBsIuME3tNr8UQ==", "127.0.0.1"); LicenseKeyInfoProvider.SetLicenseKeyInfo(flki); // Create free license keys for user defined domain string domainName = URLHelper.CorrectDomainName(txtUserDomain.Text.Trim()); string firstName = txtUserFirstName.Text.Trim(); string lastName = txtUserLastName.Text.Trim(); string email = txtUserEmail.Text.Trim(); bool userForm = !String.IsNullOrEmpty(firstName) || !String.IsNullOrEmpty(lastName) || !String.IsNullOrEmpty(email) || !String.IsNullOrEmpty(txtPassword.Text); // Ignore localhost/127.0.0.1 licenses if ((String.Compare(domainName, "localhost", true) == 0) || (String.Compare(domainName, "127.0.0.1") == 0)) { domainName = ""; } // Do not modify anything if form is blank if (!String.IsNullOrEmpty(domainName) || userForm) { if (userForm) { result = new Validator().NotEmpty(firstName, ResHelper.GetString(strPrefix + "firstnamerequired")) .NotEmpty(lastName, ResHelper.GetString(strPrefix + "lastnamerequired")) .NotEmpty(email, ResHelper.GetString(strPrefix + "emailrequired")) .IsEmail(email, ResHelper.GetString(strPrefix + "emailinvalidformat")) .Result; if (String.IsNullOrEmpty(result) && plcPass.Visible && String.IsNullOrEmpty(txtPassword.Text)) { result = ResHelper.GetString(strPrefix + "passwordrequired"); } } if (String.IsNullOrEmpty(result)) { LS.CMSLicenseService ls = new LS.CMSLicenseService(); if (userForm) { if (ls.UserExists(email)) { // If user with specified name (e-mail) already exist ask for her password if (!plcPass.Visible) { plcPass.Visible = true; result = ResHelper.GetString(strPrefix + "passwordrequired"); } else { lickey = ls.GetFreeEditionKeyGeneral(domainName, firstName, lastName, email, txtPassword.Text, 6); } } else { // Register new user and get license key lickey = ls.GetFreeEditionKeyGeneral(domainName, firstName, lastName, email, UserInfoProvider.GenerateNewPassword(), 6); } } else { lickey = ls.GetFreeEditionKeyGeneral(domainName, null, null, null, null, 6); } if (String.IsNullOrEmpty(result) && !lickey.StartsWith("DOMAIN")) { result = lickey; } } if (String.IsNullOrEmpty(result)) { if (!String.IsNullOrEmpty(lickey)) { LicenseKeyInfo lki = new LicenseKeyInfo(); lki.LoadLicense(lickey, ""); LicenseKeyInfoProvider.SetLicenseKeyInfo(lki); } } } if (!String.IsNullOrEmpty(result)) { lblError.Visible = true; lblError.Text = result; } return(String.IsNullOrEmpty(result)); }
/// <summary> /// Creates requested license keys. Returns false if something fail. /// </summary> /// <param name="connectionString">Connection string</param> public bool ProcessRegistration(string connectionString) { string result = ""; string lickey = ""; // Delete all existing license keys DataSet ds = LicenseKeyInfoProvider.GetAllLicenseKeys(); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { LicenseKeyInfo lki = new LicenseKeyInfo(dr); if (lki != null) { LicenseKeyInfoProvider.DeleteLicenseKeyInfo(lki.LicenseKeyID); } } } // Create license keys for localhost and 127.0.0.1 LicenseKeyInfo flki = new LicenseKeyInfo(); flki.LoadLicense(@"DOMAIN:localhost PRODUCT:CF07 EXPIRATION:00000000 PACKAGES: SERVERS:1 p8NrcXDSRiiEdH6Paef6MFISFY4Mihhwz9E+75fDKp1srPgxhTxEoLt0P2XXMkmCRSwhQk85/zjp017iCUIpwHhfgNQv/83ILVx3bIAEIZReY2Grs4Lah5jHSLlq3RUCX6d5ZL2Q2lxhKckPxMWjVhBlvDKLMttek+56QZmMp8oQlEMlqGYCIV+HMgD66Ob5ukdKYKvCw0Zcd2nhi+7W2KqJcWCRtRVxIY/Xi69ZgpT/Mae/8cxEfxZ+xzfw0Tn81Qf5vxVUkfG5UwVdmBQ1NFMqA6OTvx60kkRjGkUFNbsJVogsJ+WdMXr/MNhHx+qFAuMLdCOL13h4WMr/y8M+yA==", "localhost"); LicenseKeyInfoProvider.SetLicenseKeyInfo(flki); flki = new LicenseKeyInfo(); flki.LoadLicense(@"DOMAIN:127.0.0.1 PRODUCT:CF07 EXPIRATION:00000000 PACKAGES: SERVERS:1 4499yoWyus2S1g0D45bHh+OoGIS3pTC9UXm1L0Q/ElZj/II0BiebhvgWI0bLj+HMlPMl5xLRM3OJOId2IlAX/4yO4rH7YWa3ftzMX7g/sKrmmCmYXWeNDEKD0jeCKr30qaGFc6+xkI2YwULt+5lyyEVcVMGKeZd2QgIbb6i9nRfuUaww4f3JlS8FHxmUJGR1HjJ+FVZlCQFRDsb59tw2OAWSF5FKrBK3BFkIoCjEtuvoOyfvx3nUEC4OnnsqtguhjFygG7RBgRBjEyL0BXhNkhBFxZg/AZsdUDxBwwkPhrXDjJ6Dsl+DQF83qTZ+vvphOpajQ0UgB7Raep1Xul4Gqw==", "127.0.0.1"); LicenseKeyInfoProvider.SetLicenseKeyInfo(flki); // Create free license keys for user defined domain string domainName = URLHelper.CorrectDomainName(txtUserDomain.Text.Trim()); string firstName = txtUserFirstName.Text.Trim(); string lastName = txtUserLastName.Text.Trim(); string email = txtUserEmail.Text.Trim(); bool userForm = !String.IsNullOrEmpty(firstName) || !String.IsNullOrEmpty(lastName) || !String.IsNullOrEmpty(email) || !String.IsNullOrEmpty(txtPassword.Text); // Ignore localhost/127.0.0.1 licenses if ((String.Compare(domainName, "localhost", true) == 0) || (String.Compare(domainName, "127.0.0.1") == 0)) { domainName = ""; } // Do not modify anything if form is blank if (!String.IsNullOrEmpty(domainName) || userForm) { if (userForm) { result = new Validator().NotEmpty(firstName, ResHelper.GetString(strPrefix + "firstnamerequired")) .NotEmpty(lastName, ResHelper.GetString(strPrefix + "lastnamerequired")) .NotEmpty(email, ResHelper.GetString(strPrefix + "emailrequired")) .IsEmail(email, ResHelper.GetString(strPrefix + "emailinvalidformat")) .Result; if (String.IsNullOrEmpty(result) && plcPass.Visible && String.IsNullOrEmpty(txtPassword.Text)) { result = ResHelper.GetString(strPrefix + "passwordrequired"); } } if (String.IsNullOrEmpty(result)) { if (userForm) { LS.CMSLicenseService ls = new LS.CMSLicenseService(); if (ls.UserExists(email)) { // If user with specified name (e-mail) already exist ask for her password if (!plcPass.Visible) { plcPass.Visible = true; result = ResHelper.GetString(strPrefix + "passwordrequired"); } else { lickey = ls.GetFreeEditionKeyGeneral(domainName, firstName, lastName, email, txtPassword.Text, 7); } } else { // Register new user and get license key lickey = ls.GetFreeEditionKeyGeneral(domainName, firstName, lastName, email, UserInfoProvider.GenerateNewPassword(), 7); } } if (String.IsNullOrEmpty(result) && !lickey.StartsWith("DOMAIN")) { result = lickey; } } if (String.IsNullOrEmpty(result)) { if (!String.IsNullOrEmpty(lickey)) { LicenseKeyInfo lki = new LicenseKeyInfo(); lki.LoadLicense(lickey, ""); LicenseKeyInfoProvider.SetLicenseKeyInfo(lki); } } } if (!String.IsNullOrEmpty(result)) { lblError.Visible = true; lblError.Text = result; } return(String.IsNullOrEmpty(result)); }