当前位置: 首页>>代码示例>>C#>>正文


C# Database.GetPet方法代码示例

本文整理汇总了C#中db.Database.GetPet方法的典型用法代码示例。如果您正苦于以下问题:C# Database.GetPet方法的具体用法?C# Database.GetPet怎么用?C# Database.GetPet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db.Database的用法示例。


在下文中一共展示了Database.GetPet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleRequest

        protected override void HandleRequest()
        {
            string result = "";
            using (Database dbx = new Database())
            {
                Account acc = dbx.Verify(Query["guid"], Query["password"], Program.GameData);
                if (String.IsNullOrEmpty(Query["guid"]) ||
                    String.IsNullOrEmpty(Query["password"]) ||
                    String.IsNullOrEmpty(Query["type"]) ||
                    acc == null)
                {
                    Context.Response.StatusCode = 400;
                    result = "<Error>Invalid GUID/password combination</Error>";
                }
                else
                {
                    string[][] ranks = dbx.GetArenaLeaderboards(Query["type"], acc);
                    result += "<ArenaRecords>";
                    foreach (string[] i in ranks)
                    {
                        MySqlCommand cmd = dbx.CreateQuery();
                        cmd.CommandText = "select skin, tex1, tex2, items, charType, petId from characters where charid = @charid";
                        cmd.Parameters.AddWithValue("@charid", i[2]);
                        string skin, tex1, tex2, inventory, cclass, petid;
                        skin = tex1 = tex2 = inventory = cclass = petid = null;
                        using (MySqlDataReader drdr = cmd.ExecuteReader())
                        {
                            while (drdr.Read())
                            {
                                skin = drdr.GetString("skin");
                                tex1 = drdr.GetString("tex1");
                                tex2 = drdr.GetString("tex2");
                                inventory = drdr.GetString("items");
                                cclass = drdr.GetString("charType");
                                petid = drdr.GetString("petId");
                            }
                        }

                        var _pet = dbx.GetPet(int.Parse(petid), acc);
                        result += $"<Record><WaveNumber>{i[0]}</WaveNumber><Time>{i[4]}</Time><PlayData><CharacterData>";
                        if (acc.Guild.Name != null) result += [email protected]"<GuildName>{acc.Guild.Name}</GuildName><GuildRank>{acc.Guild.Rank}</GuildRank>";
                        result += $"<Id>{i[2]}</Id><Texture>{skin}</Texture><Tex1>{tex1}</Tex1><Tex2>{tex2}</Tex2><Inventory>{inventory}</Inventory><Name>{acc.Name}</Name><Class>{cclass}</Class></CharacterData>";
                        result += "<Pet name=\"" + _pet.SkinName + "\" type=\"" + _pet.Type + "\" instanceId=\"" + _pet.InstanceId + "\" rarity=\"" + _pet.Rarity + "\" maxAbilityPower=\"" + _pet.MaxAbilityPower + "\" skin=\"" + _pet.Skin + "\" family=\"" + "Farm" + "\"><Abilities>";
                        for (int e = 0; e < 3; e++)
                            result += "<Ability type=\"" + _pet.Abilities[e].Type + "\" power=\"" + _pet.Abilities[e].Power + "\" points=\"" + _pet.Abilities[e].Points + "\"/>";
                        result += "</Abilities></Pet></PlayData></Record>";
                    }
                    result += "</ArenaRecords>";
                }
            }
            byte[] buf = Encoding.UTF8.GetBytes(result);
            Context.Response.ContentType = "text/*";
            Context.Response.OutputStream.Write(buf, 0, buf.Length);
        }
开发者ID:OryxAwakening,项目名称:Fabiano_Swagger_of_Doom,代码行数:54,代码来源:getRecords.cs


注:本文中的db.Database.GetPet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。