Beispiel #1
0
        private void buttonTab4GetMainBoardWithSameSN_Click(object sender, EventArgs e)
        {
            this.listBoxTab5ListSerail.Items.Clear();
            List <string>       arrNamePC = new List <string>();
            ComputerInfo        infoPC;
            List <ComputerInfo> lsinfoPC = new List <ComputerInfo>();
            MainBoardInfo       mb       = new MainBoardInfo();
            List <ComputerInfo> dicpc    = dicPC.Where(x => x.Value.MainBoard.MAC != null).Select(x => x.Value).ToList();

            foreach (ComputerInfo item in dicpc.ToArray())
            {
                infoPC = item;
                mb     = infoPC.MainBoard;

                dicpc.Remove(item);
                lsinfoPC = dicpc.Where(x => x.MainBoard.IsSameMAC(mb)).ToList();
                if (lsinfoPC.Count > 0)
                {
                    this.listBoxTab5ListSerail.Items.Add(infoPC.Name);
                    foreach (ComputerInfo infopc in lsinfoPC)
                    {
                        this.listBoxTab5ListSerail.Items.Add(infopc.Name);
                        dicpc.Remove(infopc);
                    }
                }
            }



            //string SN = String.Empty;
            //int i

            //foreach (KeyValuePair<string, ComputerInfo> item in dicPC) {
            //    i = 0;
            //    SN = item.Value.MainBoard.SerialNumber;
            //    foreach (KeyValuePair<string, ComputerInfo> item1 in dicPC) {
            //        if (SN == item1.Value.MainBoard.SerialNumber)
            //            i++;
            //    }
            //    if (i >1)

            //}

            //var var1 = from item in dicPC
            //           group item by item.Value.MainBoard.SerialNumber
            //           into ws
            //           where ws.Count() > 1
            //           select ws;

            //foreach (IGrouping<string, KeyValuePair<string, ComputerInfo>> item1 in var1)
            //{
            //    this.listBoxTab5ListSerail.Items.AddRange(item1.Select(x => x.Value.Name).ToArray());

            //}

            //    //dicPC.GroupBy(x=>x.Value.MainBoard.SerialNumber, (PC, var1)=> new { pc.Name,var1.Count})
        }
Beispiel #2
0
 public bool IsSameMAC(MainBoardInfo mainBoardInfo)
 {
     foreach (string mac in this.MAC)
     {
         if (mainBoardInfo.MAC.Contains(mac))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
 private void dgShowMainBoard_SelectionChanged(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dgShowMainBoard.SelectedRows)
     {
         MainBoardInfo mb = new MainBoardInfo()
         {
             Product           = row.Cells["ModelMainBoard"].Value?.ToString(),
             Manufacturer      = row.Cells["Manufacturer"].Value?.ToString(),
             SerialNumber      = "",
             SMBIOSBIOSVersion = ""
         };
         ShowPCtoList(dicPC, mb);
     }
 }
Beispiel #4
0
        public bool IsSame(object obj)
        {
            if (obj is MainBoardInfo)
            {
                MainBoardInfo mb = obj as MainBoardInfo;
                if (this.Product == mb.Product &&
                    this.Manufacturer == mb.Manufacturer)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            MessageBox.Show("this obj not a MainBoard");

            return(false);
        }