private DataSet BuildDataSet(ManagementObjectCollection entries, Progress progress) { // Create the dataset that the datagrid is going to bind to DataSet ds = new DataSet(); DataTable table = new DataTable("Entries"); table.Columns.Add("EntryType"); table.Columns.Add("TimeWritten", typeof(DateTime)); table.Columns.Add("Category", typeof(ushort)); table.Columns.Add("Source"); table.Columns.Add("EventID", typeof(uint)); table.Columns.Add("Message"); table.Columns.Add("Index", typeof(uint)); ds.Tables.Add(table); groupNames = new List<String>(); // Enumerate through the events and add each item to the dataset using (System.Management.ManagementObjectCollection.ManagementObjectEnumerator enumerator = entries.GetEnumerator()) { while (enumerator.MoveNext()) { if (progress != null) { if (cancelFill) { return null; } MethodInvoker invoker = new MethodInvoker(progress.IncrementValue); invoker.BeginInvoke(null, null); } ManagementBaseObject entry = enumerator.Current; if (!groupNames.Contains((string)(entry["SourceName"]))) { groupNames.Add((string)(entry["SourceName"])); } AddTableRow(table, entry); Application.DoEvents(); } } FillSourceItems(groupNames); return ds; }
public WmiResult PopulateNamespaceList(ManagementObjectCollection pGatheredNamespaces) { Namespaces = new List<string>(); CollectedNamespaces = pGatheredNamespaces; ManagementObjectCollection.ManagementObjectEnumerator namespaceEnumerator = pGatheredNamespaces.GetEnumerator(); while (namespaceEnumerator.MoveNext()) { foreach (PropertyData item in namespaceEnumerator.Current.Properties) { Namespaces.Add(item.Value.ToString()); } } return this; }