Beispiel #1
0
 public static bool ExistNames(string[] names)
 {
     if (Ls.ok(names))
     {
         foreach (var n in names)
         {
             if (ExistName(n.Trim()))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #2
0
 public static bool ExistPaths(string[] paths)
 {
     if (Ls.ok(paths))
     {
         foreach (var p in paths)
         {
             if (ExistPath(p.Trim()))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #3
0
        public void ForceSet()
        {
            this.Name = "张无忌";
            if (!Ls.ok(Job))
            {
                Job = new List <Tuple <string, string> >();
                Job.Add(new Tuple <string, string>("2010", "志愿者工作-01"));
                Job.Add(new Tuple <string, string>("2015", "志愿者工作-02"));
            }

            if (Book == null)
            {
                Book.AddItem(new UserBook()
                {
                    Number = 0, Name = "三国演义", Page = 5000, Price = 200
                });
            }
            Book.AddItem(new UserBook()
            {
                Number = 1, Name = "红楼梦", Page = 8000, Price = 260
            });
            Book.AddItem(new UserBook()
            {
                Number = 2, Name = "西游记", Page = 9000, Price = 180
            });
            Book.AddItem(new UserBook()
            {
                Number = 3, Name = "水浒传", Page = 2000, Price = 100
            });
            Book.AddItem(new UserBook()
            {
                Name = "C#", Page = 1000, Price = 80
            });
            Book.AddItem(new UserBook()
            {
                Number = 15, Name = "JAVA", Page = 1200, Price = 20.99
            });
            Book.OrderByNumber();


            Job.Add(new Tuple <string, string>("2010", "志愿者工作-99"));
        }
Beispiel #4
0
        private void BtnTest_Click(object sender, EventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    string manage = "SELECT * From Win32_NetworkAdapter";
                    ManagementObjectSearcher searcher     = new ManagementObjectSearcher(manage);
                    ManagementObjectCollection collection = searcher.Get();
                    foreach (ManagementObject obj in collection)
                    {
                        foreach (var item in obj.Properties)
                        {
                            log.i("   :::   " + item.Name + "   :::   " + item.Value);
                        }
                        log.i("==============================");
                        log.i("==============================");
                    }
                }
                catch { }
                //====================================
                log.v("STEP 1:获取网卡列表");
                var list = NetCardInfoTool.GetNetworkCardInfoId();
                if (Ls.ok(list))
                {
                    foreach (var item in list)
                    {
                        log.v($"{item.Item1} | {item.Item2} | {item.Item3} | {item.Item4} | {item.Item5}");
                    }
                }
                //====================================
                log.v("STEP 2:检查网卡状态");
                if (Ls.ok(list))
                {
                    foreach (var item in list)
                    {
                        var status = NetCardInfoTool.GetOpStatus(item.Item3);
                        log.v($"{item.Item1} | {item.Item2} | {item.Item3} | {status.ToString()}");
                    }
                }
                //====================================
                log.v("STEP 3:Ping 10.49.129.7");
                bool pingflag1 = PingTool.Ping("10.49.129.7");
                if (pingflag1)
                {
                    log.v("Ping 正常");
                }
                else
                {
                    log.v("Ping 异常");
                }
                //====================================
                log.v("STEP 4:禁用网卡");
                NetConLibTool.Disconnect();
                //if (Ls.ok(list))
                //{
                //    foreach (var item in list)
                //    {
                //        ManagementObject network = NetcardControlTool.GetNetWorkByConnectId(item.Item1);
                //        if (network != null)
                //        {
                //            bool disflag = NetcardControlTool.Disable(network);
                //            log.v($"{item.Item1} | {item.Item2} | {item.Item3} | 禁用: {(disflag ? "成功" : "失败")}");
                //        }
                //    }
                //}
                //====================================
                log.v("STEP 5:检查网卡状态");
                if (Ls.ok(list))
                {
                    foreach (var item in list)
                    {
                        var status = NetCardInfoTool.GetOpStatus(item.Item3);
                        log.v($"{item.Item1} | {item.Item2} | {item.Item3} | {status.ToString()}");
                    }
                }
                //====================================
                log.v("STEP 6:Ping 10.49.129.7");
                bool pingflag2 = PingTool.Ping("10.49.129.7");
                if (pingflag2)
                {
                    log.v("Ping 正常");
                }
                else
                {
                    log.v("Ping 异常");
                }
                //====================================
                log.v("STEP 7:遍历启用网卡");
                NetConLibTool.Connect();
                //if (Ls.ok(list))
                //{
                //    foreach (var item in list)
                //    {
                //        ManagementObject network = NetcardControlTool.GetNetWorkByConnectId(item.Item1);
                //        if (network != null)
                //        {
                //            bool disflag = NetcardControlTool.Enable(network);
                //            log.v($"{item.Item1} | {item.Item2} | {item.Item3} | 启用: {(disflag ? "成功" : "失败")}");
                //        }
                //    }
                //}
                //====================================
                log.v("STEP 8:等待一下");
                Sleep.S(20);
                //====================================
                log.v("STEP 9:检查网卡状态");
                if (Ls.ok(list))
                {
                    foreach (var item in list)
                    {
                        var status = NetCardInfoTool.GetOpStatus(item.Item3);
                        log.v($"{item.Item1} | {item.Item2} | {item.Item3} | {status.ToString()}");
                    }
                }
                //====================================
                log.v("STEP 10:Ping 10.49.129.7");
                bool pingflag3 = PingTool.Ping("10.49.129.7");
                if (pingflag3)
                {
                    log.v("Ping 正常");
                }
                else
                {
                    log.v("Ping 异常");
                }
                //====================================

                SetResult("测试结束,已生成测试报告");
            });
        }