public string ParseLicenseKey(string text64) { //LicenseKey is: // During trial periods, it contains an expiry date. // After payment honored, it changes to GUID. So,... try{ Guid guid = new Guid(text64); foreach (KeyValuePair <string, ActivationSet> item in actCache) { if (guid == item.Value.Id) { string xml = ActivationSet.ToXmlString(item.Value); return(xml); } } }catch (Exception) {} using (LicenseGenerator Lg = new LicenseGenerator()) { string text = Lg.ParseLicenseKey(text64); DateTime trialExpiry; bool isDateTime = DateTime.TryParse(text, out trialExpiry); if (isDateTime) { return(text); } } return(String.Empty); }
public static string ToXmlString(ActivationSet target) { XmlSerializer X = new XmlSerializer(target.GetType()); using (StringWriter Sw = new StringWriter()) { X.Serialize(Sw, target); return(Sw.ToString()); } }
public string DownloadActivationSets(string password) { if ("boss" != DecryptPassword(password)) { return(null); } ActivationSet[] items = new ActivationSet[actCache.Count]; actCache.Values.CopyTo(items, 0); return(ActivationSet.FromArray(items)); }
public string GetActivationSet(string key) { lock (actCache){ if (actCache.ContainsKey(key.ToUpper())) { ActivationSet item = actCache[key.ToUpper()]; return(item.ToXmlString()); } } return(null); }
public void GenerateTestData() { lock (actCache){ actCache.Clear(); for (int i = 0; i < 10; ++i) { ActivationSet item = new ActivationSet(String.Format("Machine_{0:00}", i), typeof(ActivationSet).FullName); actCache.Add(item.MachineName.ToUpper(), item); } } Save(); }
public static void SaveData(string path) { lock (actCache){ ActivationSet[] items = new ActivationSet[actCache.Count]; actCache.Values.CopyTo(items, 0); using (StreamWriter sw = new StreamWriter(path)){ using (ComSpex.XmlPersist <ActivationSet[]> Xp = new ComSpex.XmlPersist <ActivationSet[]>(items)){ Xp.Save(sw); } } } }
public ActivationSet(string xml) { if (!String.IsNullOrEmpty(xml)) { ActivationSet item = ToClass(xml); Id = item.Id; DateUpdated = item.DateUpdated; MachineName = item.MachineName; TargetType = item.TargetType; Count = item.Count; DateRegistered = item.DateRegistered; Expiry = item.Expiry; User = new UserInfo(item.User); Sales = new PaymentInfo[item.Sales.Length]; Array.Copy(item.Sales, Sales, Sales.Length); Setup = new InstallerInfo(item.Setup); Status = item.Status; } }
public void UploadActivationSets(string password, string data, bool isMerged) { if ("boss" != DecryptPassword(password)) { return; } ActivationSet[] items = ActivationSet.ToArray(data); if (!isMerged) { actCache.Clear(); } foreach (ActivationSet item in items) { if (!actCache.ContainsKey(item.MachineName.ToUpper())) { actCache.Add(item.MachineName.ToUpper(), item); } } Save(); }
public string AddActivationSet(string data) { try{ ActivationSet item = new ActivationSet(data); lock (actCache){ if (!actCache.ContainsKey(item.MachineName.ToUpper())) { actCache.Add(item.MachineName.ToUpper(), item); } else { ulong count = actCache[item.MachineName].Count; actCache[item.MachineName] = item; actCache[item.MachineName].Count = ++count; } } Save(); }catch (Exception ex) { return(ex.ToString()); } return(null); }
public string ToXmlString() { return(ActivationSet.ToXmlString(this)); }