상속: ILicenseActivation
예제 #1
0
        public Dictionary<string, ILicenseActivation> GetActivations()
        {
            SqlConnection conn = new SqlConnection(_conStr);
            SqlDataAdapter a = new SqlDataAdapter("select * from " + _dbo + _qualifier + _table, conn);
            DataSet s = new DataSet(); a.Fill(s);

            Dictionary<string, ILicenseActivation> activations = new Dictionary<string, ILicenseActivation>();
            foreach (DataRow dr in s.Tables[0].Rows) {
                LicenseActivation act = new LicenseActivation();
                act.Host = dr["Host"].ToString();
                act.RegistrationCode = dr["RegistrationCode"].ToString();
                act.ActivationCode = dr["ActivationCode"].ToString();
                act.ProductKey = dr["ProductKey"].ToString();
                act.BaseProductVersion = dr["BaseProductVersion"].ToString();
                act.BaseProductCode = dr["BaseProductCode"].ToString();
                //Console.WriteLine(dr[0].ToString());
                activations[act.Host] = act;
            }

            return activations;
        }
예제 #2
0
        public ILicenseActivation Activate(string regCode, string productCode, string version, string host, string productKey)
        {
            RegCode r = new RegCode(regCode);

            // remove www, dev, staging, etc
            host = SanitizeHost(host, "", r.VariantCode);

            Dictionary<string, string> data = new Dictionary<string, string>();
            Dictionary<string, string> prvData = new Dictionary<string, string>();
            data["product"] = productCode; // this is not encrypted because we need to extract the private key on the server side
            prvData["regcode"] = regCode;
            prvData["version"] = version;
            prvData["minorversion"] = version;
            prvData["hostname"] = host;

            XmlDocument xmlAct = new XmlDocument();
            try {
                xmlAct.LoadXml(SendData(_regCoreSrv.Address + "?cmd=activate", productKey, data, prvData));
            } catch (Exception e) {
                throw new Exception("An error occured (" + e.Message + ")");
            }

            if (xmlAct["error"] != null) {
                throw new Exception(xmlAct["error"].InnerText);
            }

            LicenseActivation act = new LicenseActivation();
            act.RegistrationCode = regCode;
            act.Host = xmlAct.FirstChild["host"].InnerText;
            act.ActivationCode = xmlAct.FirstChild["activation_code"].InnerText;
            act.ProductKey = xmlAct.FirstChild["product_key"].InnerText;
            act.BaseProductCode = r.ProductCode;
            act.BaseProductVersion = xmlAct.FirstChild["version"].InnerText;

            if (!act.IsValid(productCode, version)) {
                throw new Exception("Invalid activation");
            }

            // add activation
            _src.AddActivation(act);
            _initActivations[act.Host] = act;
            _validActivations[act.Host] = act;

            return act;
        }
예제 #3
0
        public ILicenseActivation Activate(string regCode, string productCode, string version, string host, string productKey, string actCode)
        {
            RegCode r = new RegCode(regCode);

            host = SanitizeHost(host, "", r.VariantCode);

            LicenseActivation act = new LicenseActivation();
            act.RegistrationCode = regCode;
            act.Host = host;
            act.ActivationCode = actCode;
            act.ProductKey = productKey;
            act.BaseProductCode = r.ProductCode;
            act.BaseProductVersion = version;

            if (!act.IsValid(productCode, version)) {
                throw new Exception("Invalid activation");
            }

            // add activation
            _src.AddActivation(act);
            _initActivations[act.Host] = act;
            _validActivations[act.Host] = act;

            return act;
        }
예제 #4
0
 public ILicenseActivation Clone()
 {
     LicenseActivation act = new LicenseActivation();
     act.ActivationCode = ActivationCode;
     act.RegistrationCode = RegistrationCode;
     act.Host = Host;
     act.ProductKey = ProductKey;
     act.BaseProductVersion = BaseProductVersion;
     act.BaseProductCode = BaseProductCode;
     return act;
 }
예제 #5
0
 public void AddActivation(string regCode, string host, string actCode, string productKey, string baseProductCode, string baseVersionCode)
 {
     LicenseActivation act = new LicenseActivation();
     act.RegistrationCode = regCode;
     act.Host = host;
     act.ActivationCode = actCode;
     act.ProductKey = productKey;
     act.BaseProductCode = baseProductCode;
     act.BaseProductVersion = baseVersionCode;
     AddActivation(act);
 }