Пример #1
0
        public void LoadXML(string path)
        {
            ConfigXmlDocument xml = new ConfigXmlDocument();

            xml.Load("config.xml");
            XmlNode node = xml.SelectSingleNode("/configuration/appSettings");

            EDPCheckHelper.st.STID   = Convert.ToInt32(node.SelectSingleNode("st").Attributes["value"].Value);
            EDPCheckHelper.st.zctime = Convert.ToInt32(node.SelectSingleNode("zctime").Attributes["value"].Value);
            EDPCheckHelper.st.gztime = Convert.ToInt32(node.SelectSingleNode("gztime").Attributes["value"].Value);
            EDPCheckHelper.st.dd     = node.SelectSingleNode("dd").Attributes["value"].Value;
            EDPCheckHelper.st.ph     = node.SelectSingleNode("admin").Attributes["value"].Value;
            var ips = xml.SelectSingleNode("/configuration/Check/PC");

            foreach (XmlNode xn in ips.ChildNodes)
            {
                EDPCheckHelper.EDPMsg em = new EDPCheckHelper.EDPMsg();
                em.MacName = xn.Attributes["key"].Value;
                em.IP      = xn.Attributes["value"].Value;
                em.MsgTime = DateTime.Now;
                em.succes  = true;
                em.Type    = Convert.ToInt32(xn.Attributes["type"].Value);
                EDPCheckHelper.ems.Add(em.MacName, em);
            }
        }
Пример #2
0
        public static async Task <EDPCheckHelper.EDPMsg> PingMachiAsync(string emid, EDPCheckHelper.EDPMsg em)
        {
            await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);

            if (em.succes == true)         //上次通
            {
                if (PingPC(em.IP) == true) //本次通
                {
                    em.MsgTime = DateTime.Now;
                }
                else//本次不通
                {
                    EDPCheck.Helper.DingTalkHelper.RePost("源IP为"
                                                          + EDPCheckHelper.LocalIP + "的PC报警:" + em.MacName + ":" + em.IP +
                                                          "网络不通,请检查。ErrCode_1", EDPCheckHelper.st.ph);
                    em.succes  = false;
                    em.MsgTime = DateTime.Now;
                }
            }
            else
            {
                if (PingPC(em.IP) == true)//上次不通本次通
                {
                    EDPCheck.Helper.DingTalkHelper.RePost("源IP为"
                                                          + EDPCheckHelper.LocalIP + "的PC报警:" + em.MacName + ":" + em.IP +
                                                          "网络不通,请检查。MsgCode_1", EDPCheckHelper.st.ph);
                    em.succes  = true;
                    em.MsgTime = DateTime.Now;
                }
                else //上次不通本次也不通
                {
                    if ((DateTime.Now - em.MsgTime).TotalMinutes > 30) //上次报警超过30分钟
                    {
                        EDPCheck.Helper.DingTalkHelper.RePost("源IP为"
                                                              + EDPCheckHelper.LocalIP + "的PC报警:" + em.MacName + ":" + em.IP +
                                                              "网络不通,请检查。ErrCode_1", EDPCheckHelper.st.ph);
                        em.succes  = false;
                        em.MsgTime = DateTime.Now;
                    }
                    else
                    {
                    }
                }
            }
            return(em);
        }
Пример #3
0
 public CheckHelper(EDPCheckHelper.EDPMsg ems)
 {
     em = ems;
 }