protected static bool LoadProductKey(HttpSessionState Session) { DatabaseConnection dbConn = HROne.Common.WebUtility.GetDatabaseConnection(Session); HROne.ProductLicense tmpProductKey = new HROne.ProductLicense(); // will create dummy product license if not exists tmpProductKey.LoadProductLicense(dbConn); //tmpProductKey.SetFeatureByCode(ESystemParameter.getParameter(dbConn, ESystemParameter.PARAM_CODE_PRODUCTFEATURECODE)); Session[SESSION_PRODUCTLICENSE] = tmpProductKey; if (tmpProductKey.IsValidProductKey) { return(true); } else { return(false); } }
public void SetNewTrialKey(DatabaseConnection dbConn) { ProductLicense originalProductKey = new ProductLicense(); originalProductKey.LoadProductLicense(dbConn); if (ProductKey != originalProductKey.ProductKey && (originalProductKey.IsValidProductKey || string.IsNullOrEmpty(originalProductKey.ProductKey))) { Crypto crypto = new Crypto(Crypto.SymmProvEnum.DES); string trialKey = string.Empty; if (IsValidProductKey) { trialKey = crypto.Encrypting(AppUtils.ServerDateTime().Date.AddDays(PRODUCT_TRIALPERIOD).ToString("yyyyMMdd"), m_ProductType.ToString()); } else { trialKey = crypto.Encrypting(AppUtils.ServerDateTime().Date.AddDays(DEFAULT_TRIALPERIOD).ToString("yyyyMMdd"), m_ProductType.ToString()); } trialKey = base32.ConvertBase64ToBase32(trialKey); LoadTrialKey(trialKey, dbConn); } }
protected void OK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtProductKey.Text) && string.IsNullOrEmpty(txtTrialKey.Text)) { return; } HROne.ProductLicense productKey = new HROne.ProductLicense(); productKey.LoadProductLicense(dbConn); bool IsRedirect = true; if (!string.IsNullOrEmpty(txtProductKey.Text)) { productKey.LoadProductKey(txtProductKey.Text); if (productKey.IsValidProductKey) { //if (!txtProductKey.Text.Equals(ESystemParameter.getParameter(ESystemParameter.PARAM_CODE_PRODUCTKEY), StringComparison.CurrentCultureIgnoreCase)) //{ //} //else //{ // if (AppUtils.ServerDateTime().Date > WebUtils.getLastTrialDate()) // { // Prompt.Text = "Trial Period Expiry"; // return; // } //} Session["TrialVersion"] = false; } else { Prompt.Text += "Invalid Product Key.<br/>"; IsRedirect = false; } } if (!string.IsNullOrEmpty(txtTrialKey.Text)) { string trialKey = txtTrialKey.Text; productKey.LoadTrialKey(trialKey, dbConn); if (productKey.TrialKey == string.Empty) { Prompt.Text += "Invalid Trial Key.<br/>"; IsRedirect = false; } else { if (Session["TrialVersion"] == null) { Session["TrialVersion"] = true; } } } if (!string.IsNullOrEmpty(txtAuthorizationCode.Text)) { if (!productKey.IsValidAuthorizationCode(txtAuthorizationCode.Text)) { Prompt.Text += "Invalid Authorization Code.<br/>"; IsRedirect = false; } } if (IsRedirect) { productKey.SaveProductLicense(dbConn); // reset the connection for new key WebUtils.SetSessionDatabaseConnection(Session, dbConn); Response.Redirect(PreviousURL.Value); } }