Пример #1
0
        /// <summary>
        /// 检查网卡是否被禁用或者不存在
        /// </summary>
        /// <returns></returns>
        public NetworkDoctorBackObj checkHandware()
        {
            statusUI(0, "start", true);
            refreshUI(0, "msg", "开始检查");
            Thread.Sleep(1000);
            NetworkDoctorBackObj backObj = new NetworkDoctorBackObj("handware");

            backObj.Status = true;
            //如果没有找到网卡
            if (this.netCardDic.Count == 0)
            {
                refreshUI(0, "msg", "未发现物理网卡,请检查交换机或重装iNode");
                backObj.addMsg("未发现物理网卡\r\n");
                backObj.addSugest("此种故障一般由iNode引起,请先卸载iNode,卸载密码www.h3c.com。卸载后重启,再重新安装iNode后,再次运行本工具..");
                statusUI(0, "end", false);
                backObj.Status = false;
                //如果网卡被禁用===========================
            }
            else
            {
                backObj.addMsg("网卡正常\r\n");
                refreshUI(0, "msg", "正常");
                statusUI(0, "end", true);
                backObj.Status = true;
            }

            TaskStepCallBack(backObj);
            return(backObj);
        }
Пример #2
0
        /// <summary>
        /// 检查DNS是否设置正确
        /// </summary>
        /// <returns></returns>
        public NetworkDoctorBackObj checkDNS()
        {
            NetworkDoctorBackObj backObj = new NetworkDoctorBackObj("dns");

            backObj.Status = true;
            statusUI(2, "start", true);
            refreshUI(2, "msg", "开始检查");
            Thread.Sleep(1000);
            if (!this.netCard.isEnableDns(sysConfigDic["defaultDNS1"], sysConfigDic["defaultDNS2"]))
            {
                refreshUI(2, "msg", "发现本地dns地址设置错误..");
                backObj.addMsg("发现本地dns地址设置错误..\r\n");
                backObj.Status = false;
                refreshUI(2, "msg", "尝试从本地恢复正确的DNS配置..");
                backObj.addMsg("尝试从本地恢复正确的DNS配置..\r\n");
                this.netCard.setDns(sysConfigDic["defaultDNS1"], sysConfigDic["defaultDNS2"]);
                refreshUI(2, "msg", "检查DNS是否设置成功..");
                backObj.addMsg("检查DNS是否设置成功..\r\n");
                this.netCard = refreshNetCard(this.netCard.Name);
                if (!this.netCard.isEnableDns(sysConfigDic["defaultDNS1"], sysConfigDic["defaultDNS2"]))
                {
                    refreshUI(2, "msg", "DNS地址设置失败..");
                    backObj.addMsg("DNS地址设置失败..\r\n");
                    backObj.addSugest("请尝试手动设置DNS地址\r\n");
                    refreshUI(2, "msg", "失败");
                    statusUI(2, "end", false);
                }
                else
                {
                    refreshUI(2, "msg", "DNS地址设置成功!");
                    statusUI(2, "end", true);
                    refreshUI(2, "msg", "正常");
                    backObj.addMsg("DNS地址正常\r\n");
                    backObj.Status = true;
                }
            }
            else
            {
                backObj.addMsg("DNS地址正常\r\n");
                refreshUI(2, "msg", "正常");
                statusUI(2, "end", true);
            }
            TaskStepCallBack(backObj);
            return(backObj);
        }
Пример #3
0
        /// <summary>
        /// 检查IP地址是否设置正确
        /// </summary>
        /// <returns></returns>
        public NetworkDoctorBackObj checkIp()
        {
            NetworkDoctorBackObj backObj = new NetworkDoctorBackObj("ip");

            backObj.Status = true;
            statusUI(1, "start", true);
            refreshUI(1, "msg", "开始检查");
            Thread.Sleep(1000);

            //判断是否有NetCard符合ip规则
            string  enableNetCardName = "";
            NetCard enableNetCard     = null;

            foreach (KeyValuePair <string, NetCard> kv in netCardDic)
            {
                NetCard netCard = kv.Value;
                if (netCard.isEnableIp())
                {
                    enableNetCardName = kv.Key;
                    enableNetCard     = kv.Value;
                }
            }

            //检查IP地址是否可用
            refreshUI(1, "msg", "检查IP地址是否可用");
            if (enableNetCardName == "")
            {
                refreshUI(1, "msg", "发现本地ip地址设置错误..");
                backObj.addMsg("发现本地ip地址设置错误..\r\n");
                backObj.Status = false;
                if (this.localIpDic != null && this.localIpDic["netCardName"] != "")
                {
                    refreshUI(1, "msg", "尝试从本地恢复正确的IP配置..");
                    backObj.addMsg("尝试从本地恢复正确的IP配置..\r\n");
                    if (this.netCardDic.ContainsKey(this.localIpDic["netCardName"]))
                    {
                        this.netCard = this.netCardDic[this.localIpDic["netCardName"]];
                        this.netCard.setIp(this.localIpDic["ip"], this.localIpDic["mask"], this.localIpDic["gateway"]);
                        refreshUI(1, "msg", "检查IP是否设置成功..");
                        backObj.addMsg("检查IP是否设置成功..\r\n");
                        this.netCard = refreshNetCard(this.netCard.Name);
                        if (!this.netCard.isEnableIp())
                        {
                            refreshUI(1, "msg", "IP地址设置失败..");
                            backObj.addMsg("IP地址设置失败..\r\n");
                            backObj.addSugest("请尝试手动设置IP地址\r\n");
                            statusUI(1, "end", false);
                        }
                        else
                        {
                            refreshUI(1, "msg", "IP地址设置成功!");
                            statusUI(1, "end", true);
                            backObj.addMsg("IP地址正常\r\n");
                            backObj.Status = true;
                        }
                    }
                    else
                    {
                        refreshUI(1, "msg", "本地IP配置未存储,无法恢复");
                        Thread.Sleep(1000);
                        refreshUI(1, "msg", "失败");
                        statusUI(1, "end", false);
                    }
                }
            }
            //检查子网掩码是否可用
            //refreshUI(1, "msg", "检查子网掩码是否可用");
            //if (enableNetCard.isEnableMask())
            //{
            //    refreshUI(1, "msg", "子网掩码设置错误,尝试重新设置子网掩码..");
            //    backObj.addMsg("子网掩码设置错误,尝试重新设置子网掩码..\r\n");
            //    enableNetCard.setIp(enableNetCard.Ip, "255.255.255.0",enableNetCard.Gateway);
            //    refreshUI(1, "msg", "检查子网掩码是否设置成功..");
            //    backObj.addMsg("检查子网掩码是否设置成功..\r\n");
            //    this.netCard = refreshNetCard(enableNetCardName);
            //    if (!this.netCard.isEnableIp())
            //    {
            //        refreshUI(1, "msg", "子网掩码设置失败..");
            //        backObj.addMsg("子网掩码设置失败..\r\n");
            //        backObj.addSugest("请尝试手动设置子网掩码\r\n");
            //        statusUI(1, "end", false);
            //        return backObj;
            //    }
            //    else
            //    {
            //        refreshUI(1, "msg", "子网掩码设置成功!");
            //        statusUI(1, "end", true);
            //        backObj.addMsg("子网掩码正常\r\n");
            //        backObj.Status = true;
            //    }
            //}
            //检查默认网关是否可用
            refreshUI(1, "msg", "检查默认网关是否正确");
            if (enableNetCard != null)
            {
                string[] ipArr = enableNetCard.Ip.Split(new char[] { '.' });
                ipArr[3] = "1";
                string theoryGateway = string.Join(".", ipArr);
                if (enableNetCard.isEnableGateway())
                {
                    refreshUI(1, "msg", "网关设置错误,尝试重新设置网关..");
                    backObj.addMsg("网关设置错误,尝试重新设置网关..\r\n");
                    enableNetCard.setIp(enableNetCard.Ip, enableNetCard.Mask, theoryGateway);
                    refreshUI(1, "msg", "检查网关是否设置成功..");
                    backObj.addMsg("检查网关是否设置成功..\r\n");
                    this.netCard = refreshNetCard(enableNetCardName);
                    if (!this.netCard.isEnableGateway())
                    {
                        refreshUI(1, "msg", "网关地址设置失败..");
                        backObj.addMsg("网关地址设置失败..\r\n");
                        backObj.addSugest("请尝试手动设置网关地址\r\n");
                        statusUI(1, "end", false);
                        return(backObj);
                    }
                    else
                    {
                        refreshUI(1, "msg", "网关地址设置成功!");
                        statusUI(1, "end", true);
                        backObj.addMsg("网关地址正常\r\n");
                        backObj.Status = true;
                    }
                }
            }

            refreshUI(1, "msg", "正常");
            statusUI(1, "end", true);
            backObj.addMsg("IP地址正常\r\n");
            //任务完成了界面的返回
            TaskStepCallBack(backObj);
            return(backObj);
        }