Exemplo n.º 1
0
        /// <summary>
        ///     获取一个链接下的图标模型集合
        /// </summary>
        /// <param name="url"></param>
        /// <param name="cgKey"></param>
        /// <returns></returns>
        private static List <CardModel> GetCardPreviewModels(string url, int cgKey)
        {
            var race   = CardUtils.GetRace(cgKey);
            var rarity = CardUtils.GetRarity(cgKey);
            var web    = new HtmlWeb {
                OverrideEncoding = Encoding.GetEncoding("EUC-JP")
            };
            var frame = web.Load(url);
            var nodes =
                frame.DocumentNode.SelectNodes(@"//table")
                .First(x => x.Attributes["id"].Value.Equals("content_block_1"));
            var childNodes =
                nodes.SelectNodes(@"//a")
                .Where(x => (null != x.Attributes["href"]) && (3 == x.ChildNodes.Count))
                .ToList();

            return((from childNode in childNodes
                    let hrefUrl = childNode.Attributes["href"].Value
                                  let imageUrl = childNode.ChildNodes[0].Attributes["src"].Value
                                                 let name = childNode.ChildNodes[2].InnerText
                                                            select new CardModel
            {
                Md5 = Md5Utils.GetMd5(name),
                Name = name,
                IconUrl = imageUrl,
                IconStats = 0,
                HrefUrl = hrefUrl,
                ImagesUrl = string.Empty,
                ImagesStats = 0,
                Race = race,
                Rarity = rarity
            })
                   .ToList());
        }
Exemplo n.º 2
0
        private string GetUpdateSql(CardModel card, string number)
        {
            var builder = new StringBuilder();

            builder.Append($"UPDATE {SqliteConst.TableName} SET ");
            builder.Append($"{SqliteConst.ColumnMd5}='{Md5Utils.GetMd5(card.JName + card.Cost + card.Power)}',");
            builder.Append($"{SqliteConst.ColumnType}='{card.Type}',");
            builder.Append($"{SqliteConst.ColumnCamp}= '{card.Camp}',");
            builder.Append($"{SqliteConst.ColumnRace}= '{card.Race}',");
            builder.Append($"{SqliteConst.ColumnSign}= '{card.Sign}',");
            builder.Append($"{SqliteConst.ColumnRare}= '{card.Rare}',");
            builder.Append($"{SqliteConst.ColumnPack}= '{card.Pack}',");
            builder.Append($"{SqliteConst.ColumnCName}= '{card.CName}',");
            builder.Append($"{SqliteConst.ColumnJName}= '{card.JName}',");
            builder.Append($"{SqliteConst.ColumnIllust}= '{card.Illust}',");
            builder.Append($"{SqliteConst.ColumnNumber}= '{card.Number}',");
            builder.Append($"{SqliteConst.ColumnCost}= '{card.Cost}',");
            builder.Append($"{SqliteConst.ColumnPower}= '{card.Power}',");
            builder.Append($"{SqliteConst.ColumnAbility}= '{card.Ability}',");
            builder.Append($"{SqliteConst.ColumnLines}= '{card.Lines}',");
            builder.Append($"{SqliteConst.ColumnImage}= '{card.ImageJson}'");
            // 详细能力处理
            builder.Append($" WHERE {SqliteConst.ColumnNumber}='{number}'");
            return(builder.ToString());
        }