private static void LoadLicenses() { // Retrieves the web response. string webResponse = ByteGuardInterface.Globals.Variables.WebResponse; if (webResponse.Split('[', ']')[1] == "SUCCESS") { // Got the list of licenses successfully, parse the response. ByteGuardInterface.Globals.Variables.MyLicenses.Clear(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(ByteGuardInterface.Globals.Variables.WebResponse.Replace("[SUCCESS]", "")); // Iterates through each program node. foreach (XmlNode xmlNode in xmlDocument) { foreach (XmlNode xmlLicenseNode in xmlNode) { ByteGuardInterface.Globals.Variables.ByteGuardLicense byteguardLicense = new ByteGuardInterface.Globals.Variables.ByteGuardLicense(); foreach (XmlNode xmlInformationNode in xmlLicenseNode) { switch (xmlInformationNode.Name) { case "programid": byteguardLicense.Programid = xmlInformationNode.InnerText; break; case "code": byteguardLicense.LicenseCode = xmlInformationNode.InnerText; break; case "value": byteguardLicense.LicenseValue = xmlInformationNode.InnerText; break; case "creationtime": byteguardLicense.CreationTime = xmlInformationNode.InnerText; break; case "redeemedtime": byteguardLicense.RedeemedTime = xmlInformationNode.InnerText; break; case "redeemedusername": byteguardLicense.RedeemedTo = xmlInformationNode.InnerText; break; case "expiration": byteguardLicense.ExpirationTime = xmlInformationNode.InnerText; break; case "type": byteguardLicense.LicenseType = Convert.ToInt32(xmlInformationNode.InnerText); break; case "description": byteguardLicense.TrackingDescription = xmlInformationNode.InnerText; break; case "banned": byteguardLicense.IsBanned = (Convert.ToInt32(xmlInformationNode.InnerText) == 1); break; case "locktime": byteguardLicense.LockTime = Convert.ToInt32(xmlInformationNode.InnerText); break; case "lockreason": byteguardLicense.LockReason = xmlInformationNode.InnerText; break; case "frozen": byteguardLicense.IsFrozen = (Convert.ToInt32(xmlInformationNode.InnerText) == 1); break; case "mplicense": byteguardLicense.MarketplaceLicense = (Convert.ToInt32(xmlInformationNode.InnerText) == 1); break; } } ByteGuardInterface.Globals.Variables.MyLicenses.Add(byteguardLicense); } } if (ByteGuardInterface.Globals.Variables.MyLicenses.Count != 0) { DisplayLicenses(); } else { try { CreateLicenseButton.Invoke((MethodInvoker) delegate { CreateLicenseButton.Enabled = true; }); } catch { // IsDisposed. } ByteGuardInterface.Globals.Variables.Containers.Main.SetStatus("Create and manage your programs.", 3); } } else { ByteGuardInterface.Globals.Variables.Containers.Main.SetStatus(ByteGuardInterface.Globals.Variables.WebResponse.Replace("[ERROR]", ""), 1); } }
private static void AddLicenseToListview(object bgLicense) { ByteGuardInterface.Globals.Variables.ByteGuardLicense byteguardLicense = (ByteGuardInterface.Globals.Variables.ByteGuardLicense)bgLicense; ListViewItem listviewItem = new ListViewItem(byteguardLicense.RedeemedTo); // LicenseCode listviewItem.SubItems.Add(byteguardLicense.LicenseCode); if (byteguardLicense.MarketplaceLicense) { listviewItem.SubItems[0].ForeColor = System.Drawing.Color.FromArgb(40, 95, 125); } // IsBanned if (byteguardLicense.IsBanned || byteguardLicense.IsFrozen) { listviewItem.SubItems.Add("True"); } else { listviewItem.SubItems.Add("False"); } if (byteguardLicense.LicenseType == 0) // If LicenseType = Duration. { listviewItem.SubItems.Add("Duration"); /*/ LicenseValue * if (ByteguardLicense.LicenseValue == "0") * { * LVI.SubItems.Add("0"); * } * else * {*/ listviewItem.SubItems.Add(byteguardLicense.LicenseValue); if (byteguardLicense.IsFrozen) { // Banned. listviewItem.SubItems.Add("Frozen"); } else if (byteguardLicense.IsBanned) { // Frozen. listviewItem.SubItems.Add("Banned"); } else if (byteguardLicense.LicenseValue == "0") { listviewItem.SubItems.Add("Never"); } else if (byteguardLicense.ExpirationTime == "-1") { // Unredeemed. listviewItem.SubItems.Add("Not Redeemed"); } else { // Redeemed. listviewItem.SubItems.Add(Methods.TimeStampToDate(Convert.ToDouble(byteguardLicense.ExpirationTime))); } } else { listviewItem.SubItems.Add("Points"); listviewItem.SubItems.Add(byteguardLicense.LicenseValue); listviewItem.SubItems.Add("N/A"); } ByteGuardInterface.Globals.Variables.Forms.Main.Invoke((MethodInvoker) delegate { ListViewLicenses.Items.Add(listviewItem); }); }