private int ScrapeFileCounter(MSI.Database db) { int count = 0; using (MSI.View view = Application.ExecView(db, "SELECT `File` FROM `File`")) { for (MSI.Record rec = view.Fetch(); rec != null; rec = view.Fetch()) { count++; rec.Dispose(); } } return(count); }
private void CommitFeatures(MSI.Database db, string root) { int display = 0; using (MSI.View view = Application.ExecView(db, "SELECT `Display` FROM `Feature` ORDER BY `Display`")) { for (MSI.Record rec = view.Fetch(); rec != null; rec = view.Fetch()) { if (!rec.IsNull(1)) { display = Math.Max(rec.GetInteger(1) / 2, display); } rec.Dispose(); } view.Close(); } display = (0 == display) ? 100 : display + 1; using (MSI.View view = db.OpenView("INSERT INTO `Feature`(" + "`Feature`,`Feature_Parent`,`Title`,`Description`," + "`Display`,`Level`,`Directory_`,`Attributes`) " + "VALUES (?,?,?,?,?,?,?,0)")) { for (int i = 0; i < m_components.Count; i++) { Component component = m_components[i] as Component; using (MSI.Record rec = new MSI.Record(7)) { rec.SetString(1, component.Name); rec.SetString(2, root); rec.SetString(3, component.Name); rec.SetString(4, component.Name); rec.SetInteger(5, 2 * (i + display)); rec.SetInteger(6, 1); rec.SetString(7, ""); view.Execute(rec); } } view.Close(); } }
private void BuildFeatures() { ArrayList roots = new ArrayList(); Hashtable tree = new Hashtable(); using (MSI.View view = Application.ExecView(m_project.Database, "SELECT `Feature`,`Feature_Parent` FROM `Feature` " + "ORDER BY `Feature_Parent`")) { for (MSI.Record rec = view.Fetch(); rec != null; rec = view.Fetch()) { if (rec.IsNull(2)) { roots.Add(rec.GetString(1)); } else { string parent = rec.GetString(2); if (!tree.ContainsKey(parent)) { tree[parent] = new ArrayList(); } (tree[parent] as ArrayList).Add(rec.GetString(1)); } rec.Dispose(); } } roots.Sort(); rootFeatureTreeView.Nodes.Clear(); for (int i = 0; i < roots.Count; i++) { string feature = roots[i] as string; TreeNode root = new TreeNode(feature); root.Tag = "R" + i.ToString(); rootFeatureTreeView.Nodes.Add(root); AddFeatures(tree, rootFeatureTreeView, root.Tag as string, feature); } rootFeatureTreeView.SelectedNode = rootFeatureTreeView.Nodes[0]; }