2011-12-12 77 views
1

首先,英文不是!我的第一/母语。VB.Net动态图表创建。需要布局帮助

对于我在这家公司的实习,我试图收集一些数据。网络中有200台PC。所有HP SFF PC。所有的PC将被包含软件和策略的公司磁盘映像覆盖。他们也获得了BIOS更新。但随着这些版本的月份过时了。并不是说它需要更新BIOS,我们现在想要哪个版本在哪个型号的PC上。

有几种PC型号。 例如HP DC7600,HP 7700.

有几个BIOS版本。 例如786G1 v01.10,786G1 v01.16

我正在用以下方法收集这些数据。每个人都有一个网络共享到某个磁盘(公司文档)。

对于客户端我使用WMI(Windows Management Instrumentation)来收集所需的信息。

Sub RetrieveInfo() 
    Dim _PCName As String = My.Computer.Name 
    Dim _Info As String = vbNullString 
    Dim _FileName As String = "G:\BiosVersion\" & _PCName & ".txt" 
    Dim _ManagmentC As New ManagementClass("Win32_ComputerSystem") 
    Dim _Moc As ManagementObjectCollection = _ManagmentC.GetInstances 

    For Each _Mo As ManagementObject In _Moc 
     Dim Model() As String = Split(_Mo.Properties("Model").Value.ToString, " ") 
     For i = 0 To Model.Length - 1 
      If Model(i).ToLower.Contains("dc") Then _Info &= Model(i) 
     Next 
    Next 

    _ManagmentC = New ManagementClass("win32_bios") 
    _Moc = _ManagmentC.GetInstances 
    For Each _Mo As ManagementObject In _Moc 
     _Info &= "|" & _Mo.Properties("SMBIOSBIOSVersion").Value.ToString 
    Next 

    Try 
     If IO.File.Exists(_FileName) Then 
      IO.File.Delete(_FileName) 
     End If 
    Catch ex As IO.IOException 
     _FileName = _FileName.Replace(_PCName, _PCName & "-" & New Random().Next(10, 10000)) 
    End Try 

    IO.File.WriteAllText(_FileName, _Info) 

End Sub 

正如您所看到的,这将创建为与字符串PCName(例如PC1001)共享的文本文件。 它将PC型号& Bios版本写入文本文件。 (例如DC7900 | 786G1 v01.16)


对于服务器侧,图表建筑物部分,我做如下。

Dim Path As String = "G:\BiosVersion\" 
Sub UpdateChart() 
    Dim PCModels As New List(Of String) 
    Dim BiosVersions As New List(Of String) 
    Dim Files As IO.FileInfo() = New IO.DirectoryInfo(Path).GetFiles 

    For Each File As IO.FileInfo In Files 
     If File.Extension = ".txt" Then 
      PCModels.Add(IO.File.ReadAllText(File.FullName).Split("|")(0)) 
      BiosVersions.Add(IO.File.ReadAllText(File.FullName).Split("|")(1)) 
     End If 
    Next 
    PCModels = RemoveDuplicates(PCModels) 
    BiosVersions = RemoveDuplicates(BiosVersions) 

    For i = 0 To chartBios.Series.Count - 1 
     chartBios.Series.Remove(chartBios.Series.Item(i)) 
    Next 

    Dim Dictionary As New Dictionary(Of String, Integer) 
    For Each Version As String In BiosVersions 
     chartBios.Series.Add(Version) 
     Dim Count As Integer = 0 
     For Each File As IO.FileInfo In Files 
      If IO.File.ReadAllText(File.FullName).Split("|")(1).ToLower.Trim = Version.ToLower.Trim Then 
       Count += 1 
      End If 
     Next 
     Dictionary.Add(Version, Count) 
    Next 

    For Each Entry As KeyValuePair(Of String, Integer) In Dictionary 
     chartBios.Series(Entry.Key).Points.AddY(Entry.Value) 
    Next 
End Sub 

Function RemoveDuplicates(ByVal inputList As List(Of String)) As List(Of String) 
    Dim uniqueStore As New Dictionary(Of String, Integer)() 
    Dim finalList As New List(Of String)() 
    For Each currValue As String In inputList 
     If Not uniqueStore.ContainsKey(currValue) Then 
      uniqueStore.Add(currValue, 0) 
      finalList.Add(currValue) 
     End If 
    Next 
    Return finalList 
End Function 

chartBios =图表控件。

导致以下: 我不能发表任何图像,但(防止垃圾邮件) http://i.imgur.com/bGpyH.jpg

我试图做的是以下几点。 我有3个Vars,Bios版本,每个版本安装了多少次&型号名称。

这是我想要的图表布局的一个例子。任何人都有如何创建这种布局的想法?在运行时或静态时,我不在乎它可以在运行时填充。

对于每个Bios版本号,每个PC型号必须有一个标签,表示安装bios版本的次数。

例子: 我不能发表任何图像,但(防止垃圾邮件) http://i.imgur.com/tP0Sf.jpg

回答