예제 #1
0
        private async Task LoadDataTask()
        {
            var loadRoute = UpdateRoute();

            IPList.Clear();

            int o = 0;

            while (true)
            {
                string reqUri         = "index.php?action=ip_db&a2=pub&_o=" + o;
                string responseString = await SendRequest.GET(reqUri);

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(responseString);

                HtmlNode node = doc.DocumentNode.SelectSingleNode(@"//form[@name='frm_mis']");

                HtmlNodeCollection childs = node.SelectNodes(@"//form[@name='frm_mis']/tr");

                int count = 0;

                for (int i = 0; i < childs.Count; i++)
                {
                    if (i == 0 || i == childs.Count - 1 || childs[i] == null)
                    {
                        continue;
                    }

                    string ip      = childs[i].SelectSingleNode(@"./td[@class='green']/a").InnerText;
                    string name    = StringHelper.RemoveSpecial(childs[i].SelectSingleNode(@"./td[4]").InnerText);
                    string admin   = childs[i].SelectSingleNode(@"./td[5]/i").InnerText;
                    string owned   = childs[i].SelectSingleNode(@"./td[6]").InnerText;
                    string connect = childs[i].SelectSingleNode(@".//tr[@class='m2']/td[1]/a").GetAttributeValue("href", "");
                    string bounce  = childs[i].SelectSingleNode(@".//tr[@class='m2']/td[2]/a").GetAttributeValue("href", "");

                    IPDBModel newData = new IPDBModel()
                    {
                        IP      = ip,
                        Name    = name,
                        Admin   = admin,
                        Owned   = owned,
                        Connect = connect,
                        Bounce  = bounce
                    };
                    IPList.Add(newData);
                    count++;
                }

                if (count == 0)
                {
                    break;
                }

                o += 20;
            }
            await loadRoute;
        }
        public FliterWindowViewModel(MainWindowViewModel dataContext)
        {
            refreshMessage = (date) => dataContext.TcpPacket = date;

            ErrorList = from iteam
                        in dataContext.HttpList
                        where iteam.ErrorCode == ErrorCode.RESPONSE_ERROR || iteam.ErrorCode == ErrorCode.NET_NO_RESPONSE
                        select iteam;

            WarningList = from iteam
                          in dataContext.HttpList
                          where iteam.ErrorCode == ErrorCode.NET_TIMEOUT || iteam.ErrorCode == ErrorCode.HTTP_ERROR
                          select iteam;

            Dictionary <string, List <HttpModel> > mp = new Dictionary <string, List <HttpModel> >();

            IPList.Clear();
            foreach (var item in ErrorList)
            {
                if (!mp.ContainsKey(item.IP_DestinationAddress))
                {
                    List <HttpModel> newlist = new List <HttpModel>();
                    newlist.Add(item);
                    mp.Add(item.IP_DestinationAddress, newlist);
                }
                else
                {
                    List <HttpModel> oldlist;
                    mp.TryGetValue(item.IP_DestinationAddress, out oldlist);
                    oldlist.Add(item);
                }
            }

            foreach (var key in mp.Keys)
            {
                IPList.Add(key);
            }
        }