Exemple #1
0
        private int PMParse(string data)
        {
            string strPMTitles = HtmlUtility.GetElement(data, "tbody");

            if (strPMTitles == null)
            {
                return(-1);
            }
            string[] strPMTitleList = HtmlUtility.GetElements(strPMTitles, "tr");
            int      len            = strPMTitleList.Length;
            int      cnt            = 0;

            foreach (string eachPMTitle in strPMTitleList)
            {
                Match m = Regex.Match(
                    eachPMTitle, "class=\"status \" title=\"unread\" alt=\"unread\" />");
                if (!m.Success)
                {
                    continue;
                }

                m = Regex.Match(
                    eachPMTitle, "<a href=\"spieler\\.php\\?uid=(\\d+)\">([^<]*?)</a>");
                if (!m.Success)
                {
                    continue;
                }
                int    uid  = Convert.ToInt32(m.Groups[1].Value);
                string name = m.Groups[2].Value;
                if (!DicPMSender.ContainsKey(uid))
                {
                    PMSender sender = new PMSender
                    {
                        _uid  = uid,
                        _name = name
                    };
                    DicPMSender.Add(uid, sender);
                }

                m = Regex.Match(
                    eachPMTitle, "<a href=\"(nachrichten\\.php\\?id=\\d+)\">([^<]*?)</a>");
                if (!m.Success)
                {
                    continue;
                }
                string link    = m.Groups[1].Value;
                string subject = m.Groups[2].Value.Trim();

                m = Regex.Match(
                    eachPMTitle, "<td class=\"dat\">([^<]*?)</td>");
                if (!m.Success)
                {
                    continue;
                }
                string date = m.Groups[1].Value;

                PMInfo info = new PMInfo
                {
                    _subject = subject,
                    _date    = date
                };

                string content = UpCall.PageQuery(VillageID, link);
                m = Regex.Match(content, @"<div id=""message"">(.+?)</div>", RegexOptions.Singleline);
                if (!m.Success)
                {
                    continue;
                }
                info._content = m.Groups[1].Value;
                DicPMSender[uid].PMInfoList.Add(info);
                cnt++;
            }

            if (cnt > 0 && cnt == len)
            {
                return(1);
            }
            else if (cnt > 0 && cnt < len)
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        }
        private int PMParse(string data)
        {
            string strPMTitles = HtmlUtility.GetElement(data, "tbody");
            if (strPMTitles == null)
                return -1;
            string[] strPMTitleList = HtmlUtility.GetElements(strPMTitles, "tr");
            int len = strPMTitleList.Length;
            int cnt = 0;
            foreach (string eachPMTitle in strPMTitleList)
            {
                Match m = Regex.Match(
                    eachPMTitle, "class=\"status \" title=\"unread\" alt=\"unread\" />");
                if (!m.Success)
                    continue;

                m = Regex.Match(
                    eachPMTitle, "<a href=\"spieler\\.php\\?uid=(\\d+)\">([^<]*?)</a>");
                if (!m.Success)
                    continue;
                int uid = Convert.ToInt32(m.Groups[1].Value);
                string name = m.Groups[2].Value;
                if (!DicPMSender.ContainsKey(uid))
                {
                    PMSender sender = new PMSender
                    {
                        _uid = uid,
                        _name = name
                    };
                    DicPMSender.Add(uid, sender);
                }

                m = Regex.Match(
                    eachPMTitle, "<a href=\"(nachrichten\\.php\\?id=\\d+)\">([^<]*?)</a>");
                if (!m.Success)
                    continue;
                string link = m.Groups[1].Value;
                string subject = m.Groups[2].Value.Trim();

                m = Regex.Match(
                    eachPMTitle, "<td class=\"dat\">([^<]*?)</td>");
                if (!m.Success)
                    continue;
                string date = m.Groups[1].Value;

                PMInfo info = new PMInfo
                {
                    _subject = subject,
                    _date = date
                };

                string content = UpCall.PageQuery(VillageID, link);
                m = Regex.Match(content, @"<div id=""message"">(.+?)</div>", RegexOptions.Singleline);
                if (!m.Success)
                    continue;
                info._content = m.Groups[1].Value;
                DicPMSender[uid].PMInfoList.Add(info);
                cnt++;
            }

            if (cnt > 0 && cnt == len)
                return 1;
            else if (cnt > 0 && cnt < len)
                return 0;
            else
                return -1;
        }