AdvancedLauncher.Providers.Korea.KoreaWebProvider.GetGuildInfo C# (CSharp) Метод

GetGuildInfo() защищенный Метод

protected GetGuildInfo ( Guild &guild, bool isDetailed ) : bool
guild AdvancedLauncher.SDK.Model.Entity.Guild
isDetailed bool
Результат bool
        protected override bool GetGuildInfo(ref Guild guild, bool isDetailed)
        {
            List<Tamer> tamerList = new List<Tamer>();
            HtmlDocument doc = new HtmlDocument();
            if (LogManager != null) {
                LogManager.InfoFormat("Obtaining info of {0}", guild.Name);
            }
            string html = DownloadContent(string.Format(STR_URL_GUILD_PAGE, guild.Identifier, "srv" + guild.Server.Identifier));
            doc.LoadHtml(html);

            HtmlNode ranking = doc.DocumentNode.SelectNodes("//table[@class='forum_list']//tbody")[1];
            HtmlNodeCollection tlist = ranking.SelectNodes(".//tr");
            if (tlist != null) {
                using (IDatabaseContext context = DatabaseManager.CreateContext()) {
                    for (int i = 0; i < tlist.Count; i++) {
                        try {
                            Tamer tamer = new Tamer() {
                                Guild = guild,
                                Name = ClearStr(tlist[i].SelectSingleNode(".//td[3]").InnerText),
                                Rank = CheckRankNode(tlist[i].SelectSingleNode(".//td[2]"))
                            };
                            OnStatusChanged(DMODownloadStatusCode.GETTING_TAMER, tamer.Name, i, tlist.Count);

                            Regex regex = new Regex(STR_TAMER_TYPE_REGEX, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                            Match match = regex.Match(tlist[i].SelectSingleNode(".//td[3]").InnerHtml);
                            if (match.Success) {
                                tamer.Type = context.FindTamerTypeByCode(Convert.ToInt32(match.Groups[2].ToString()));
                            }

                            regex = new Regex(STR_TAMER_LVL_REGEX, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                            match = regex.Match(tlist[i].SelectSingleNode(".//td[4]").InnerHtml);
                            if (match.Success) {
                                tamer.Level = Convert.ToByte(match.Groups[2].ToString());
                            }

                            regex = new Regex(STR_TAMER_ID_REGEX, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                            match = regex.Match(tlist[i].SelectSingleNode(".//td[7]").InnerHtml);
                            if (match.Success) {
                                tamer.AccountId = Convert.ToInt32(match.Groups[2].ToString());
                            }

                            if (tamer.Level != 0 && tamer.AccountId != 0) {
                                tamer.Digimons = GetDigimons(tamer, isDetailed);
                                if (tamer.Digimons.Count == 0) {
                                    return false;
                                }
                                Digimon partner = tamer.Digimons.FirstOrDefault(d => d.Type.IsStarter);
                                if (partner != null) {
                                    partner.Name = ClearStr(tlist[i].SelectSingleNode(".//td[5]").InnerText);
                                }
                                tamerList.Add(tamer);
                                if (LogManager != null) {
                                    LogManager.InfoFormat("Found tamer \"{0}\"", tamer.Name);
                                }
                            }
                        } catch {
                        }
                    }
                }
            }

            if (tamerList.Count == 0) {
                return false;
            }
            guild.Tamers = tamerList;
            return true;
        }