private void btnAdd_Click(object sender, EventArgs e) { if (txtName.Text == "") MessageBox.Show("Name shouldn't be empty"); else if (txtCode.Text == "") MessageBox.Show("Code shouldn't be empty"); else { LicenseItem item = new LicenseItem { Name = txtName.Text, Code = txtCode.Text, State = CheckState.Checked }; if (!NewWDS.LicenseManager.instance().checkLicenseIntegrity(item.Name, item.Code, true, true)) MessageBox.Show("Code Integrity Check Failed"); else { _licenseList.Add(item); NewWDS.LicenseManager.instance().saveLicenseFile(_licenseList); populateListView(); txtName.Text = ""; txtCode.Text = ""; GlobalServices.reloadLicenseFile(); } } }
public void addLicense(LicenseItem license) { this._licenseList.Add(license); }
public void addLicense(string a_deviceType, LicenseItem license) { foreach (DeviceType type in this._deviceTypeList) { if (type.TypeID.ToString() == a_deviceType) { type.addLicense(license); } } }
private List<LicenseItem> parseLicenseContent(string license) { XmlDocument document = new XmlDocument(); document.LoadXml(license); XmlNode license_table = document.SelectSingleNode("/License_Table"); List<LicenseItem> list = new List<LicenseItem>(); foreach (XmlNode license_record in license_table.ChildNodes) { LicenseItem licenseItem = new LicenseItem(); foreach (XmlNode licenseNode in license_record.ChildNodes) { if (licenseNode.Name != null) { switch (licenseNode.Name) { case "Code": licenseItem.Code = licenseNode.InnerText; break; case "State": if (licenseNode.InnerText == CheckState.Checked.ToString()) licenseItem.State = CheckState.Checked; else licenseItem.State = CheckState.Unchecked; break; case "Name": licenseItem.Name = licenseNode.InnerText; break; } } } if (checkLicenseIntegrity(licenseItem.Name, licenseItem.Code, false, true)) list.Add(licenseItem); } return list; }
private void loadADCRRecordsFromXml() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); executingAssembly.GetManifestResourceNames(); Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("NewWDS.WDS_Resources.ADCR.xml"); List<ADCRRecord> list = new List<ADCRRecord>(); try { XmlDocument document = new XmlDocument(); document.Load(manifestResourceStream); foreach (XmlNode node in document.GetElementsByTagName("ADCR_Record")) { ApplicationDescriptor app = new ApplicationDescriptor(); CompatibleDeviceDescriptor comaptibleDevices = new CompatibleDeviceDescriptor(); CompatibleChipDescriptor chips = new CompatibleChipDescriptor(); CompatibleLicenseDescriptor licenses = new CompatibleLicenseDescriptor(); foreach (XmlNode node2 in node.ChildNodes) { string name = node2.Name; if (name != null) { if (!(name == "Application")) { if (name == "Chips") { goto Label_0377; } if (name == "Devices") { goto Label_053F; } } else { foreach (XmlNode node3 in node2.ChildNodes) { switch (node3.Name) { case "Type": app.AppType = this.getAppTypeItemByName(node3.InnerText); break; case "Class": app.AppClass = this.getAppClassItemByName(node3.InnerText); break; case "Name": app.AppName = node3.InnerText; break; case "Description": app.ApplicationDescription = node3.InnerText; break; case "Simulation": app.SimulationCapable = bool.Parse(node3.InnerText); break; case "Advanced": app.Advanced = bool.Parse(node3.InnerText); break; case "StartupApplication": app.StartupApplication = node3.InnerText; break; case "EBIDRequired": app.EBIDRequired = bool.Parse(node3.InnerText); break; case "AllowedToRunOnDifferentFwType": app.AllowedToRunOnDifferentFwType = bool.Parse(node3.InnerText); break; case "TopOnAppList": app.TopOnAppList = bool.Parse(node3.InnerText); break; case "Licenses": foreach (XmlNode node4 in node3.ChildNodes) { if ((node4.NodeType != XmlNodeType.Comment) && (node4.Name == "Name")) { LicenseItem item = new LicenseItem { Name = node4.InnerText }; licenses.LicenseList.Add(item); } } break; } } } } continue; Label_0377: foreach (XmlNode node5 in node2.ChildNodes) { CDTRecord record = new CDTRecord(); foreach (XmlNode node6 in node5.ChildNodes) { string str3 = node6.Name; if (str3 != null) { if (!(str3 == "Type")) { if (str3 == "Revision") { goto Label_042D; } if (str3 == "DefaultRev") { goto Label_0440; } if (str3 == "Advanced") { goto Label_0458; } if (str3 == "Licenses") { goto Label_046D; } } else { record.ChipType = node6.InnerText; } } continue; Label_042D: record.ChipRevision = node6.InnerText; continue; Label_0440: record.DefaultRev = bool.Parse(node6.InnerText); continue; Label_0458: record.Advanced = bool.Parse(node6.InnerText); continue; Label_046D: foreach (XmlNode node7 in node6.ChildNodes) { if ((node7.NodeType != XmlNodeType.Comment) && (node7.Name == "Name")) { LicenseItem item2 = new LicenseItem { Name = node7.InnerText }; record.LicenseList.Add(item2); } } } chips.ChipList.Add(record); } continue; Label_053F: this.parseCompatibleDevices(comaptibleDevices, node2); } list.Add(new ADCRRecord(app, comaptibleDevices, chips, licenses)); } this._adcrRecordSet = list.ToArray(); } catch (Exception exception) { MessageBox.Show("ADCR XML Reading error! \n" + exception.Message, "ADCRManager.loadADCRRecordsFromXml()"); } }
public void parseCompatibleDevices(List<CompatibleDeviceDescriptor> comaptibleDeviceList, XmlNode subNode) { foreach (XmlNode node in subNode.ChildNodes) { if ((node.NodeType != XmlNodeType.Comment) && (node.Attributes != null)) { CompatibleDeviceDescriptor descriptor = new CompatibleDeviceDescriptor(); descriptor.addDeviceType(node.Attributes[0].InnerText); foreach (XmlNode node2 in node.ChildNodes) { string name = node2.Name; if (name != null) { if (!(name == "DeviceVersion")) { if (name == "DeviceComponents") { goto Label_0221; } if (name == "Licenses") { goto Label_029E; } } else if (node2.Attributes != null) { descriptor.addDeviceVersion(node.Attributes[0].InnerText, node2.Attributes[0].InnerText); foreach (XmlNode node3 in node2.ChildNodes) { string str2; if ((((str2 = node3.Name) != null) && (str2 == "FirmwareType")) && (node3.Attributes != null)) { descriptor.addFirmwareType(node.Attributes[0].InnerText, node2.Attributes[0].InnerText, node3.Attributes[0].InnerText); foreach (XmlNode node4 in node3.ChildNodes) { if (node4.Attributes != null) { descriptor.addFirmwareVersion(node.Attributes[0].InnerText, node2.Attributes[0].InnerText, node3.Attributes[0].InnerText, node4.Attributes[0].InnerText); } } } } } } continue; Label_0221: foreach (XmlNode node5 in node2.ChildNodes) { if ((node5.NodeType != XmlNodeType.Comment) && (node5.Name == "DeviceType")) { this.parseCompatibleDevices(descriptor.getCompatibleComponentDescriptor(node.Attributes[0].InnerText), node2); break; } } continue; Label_029E: foreach (XmlNode node6 in node2.ChildNodes) { if ((node6.NodeType != XmlNodeType.Comment) && (node6.Name == "Name")) { LicenseItem license = new LicenseItem { Name = node6.InnerText }; descriptor.addLicense(node.Attributes[0].InnerText, license); } } } comaptibleDeviceList.Add(descriptor); } } }