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


C# Database.DatabaseConnection类代码示例

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


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

示例1: DumpStatistics

        public static void DumpStatistics()
        {
            int playerCount = 0;
            int staffCount = 0;
            foreach (Client i in ClientManager.GetClients()) {
                if (i.Player != null) {
                    if (i.IsPlaying()) {
                        playerCount++;
                        if (Players.Ranks.IsAllowed(i, Enums.Rank.Moniter)) {
                            staffCount++;
                        }
                    }
                }
            }
            int partyCount = Server.Players.Parties.PartyManager.CountActiveParties();
            int activeMapCount = Server.Maps.MapManager.CountActiveMaps();
            int activeNetworkClients = Server.Network.ClientManager.CountActiveClients();

            Process serverProcess = Process.GetCurrentProcess();
            long workingSet = serverProcess.WorkingSet64;
            long elapsedHours = (long)Globals.LiveTime.Elapsed.TotalHours;

            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data)) {
                dbConnection.Database.AddRow("stats_performance", new IDataColumn[] {
                    dbConnection.Database.CreateColumn(false, "Time", DateTime.UtcNow.ToString()),
                    dbConnection.Database.CreateColumn(false, "PlayerCount", playerCount.ToString()),
                    dbConnection.Database.CreateColumn(false, "StaffCount", staffCount.ToString()),
                    dbConnection.Database.CreateColumn(false, "ActiveNetworkClients", activeNetworkClients.ToString()),
                    dbConnection.Database.CreateColumn(false, "ActiveMaps", activeMapCount.ToString()),
                    dbConnection.Database.CreateColumn(false, "ActiveParties", partyCount.ToString()),
                    dbConnection.Database.CreateColumn(false, "WorkingSet", workingSet.ToString()),
                    dbConnection.Database.CreateColumn(false, "ElapsedHours", elapsedHours.ToString())
                });
            }
        }
开发者ID:pzaps,项目名称:Server,代码行数:35,代码来源:PerformanceStatistics.cs

示例2: LoadExps

        public static void LoadExps(object object1)
        {
            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data))
            {
                try
                {
                    MySql database = dbConnection.Database;

                    string query = "SELECT * " +
                        "FROM experience";

                    foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query))
                    {
                        int level = columnCollection["level_num"].ValueString.ToInt();

                        exp[level - 1] = columnCollection["med_slow"].ValueString.ToUlng();

                        if (LoadUpdate != null)
                            LoadUpdate(null, new LoadingUpdateEventArgs(level, exp.MaxLevels));
                    }

                    if (LoadComplete != null)
                        LoadComplete(null, null);
                }
                catch (Exception ex)
                {
                    Exceptions.ErrorLogger.WriteToErrorLog(ex);
                }
            }
        }
开发者ID:pzaps,项目名称:Server,代码行数:30,代码来源:ExpManager.cs

示例3: RunTest

        public static void RunTest(Client client)
        {
            Messenger.PlayerMsg(client, client.IP.ToString(), Text.BrightRed);

            return;
            int playerCount = 0;
            PacketHitList hitlist = null;
            PacketHitList.MethodStart(ref hitlist);
            IMap map = client.Player.Map;

            Stopwatch watch = new Stopwatch();
            watch.Start();
            using (DatabaseConnection db = new DatabaseConnection(DatabaseID.Players)) {
                PlayerManager.RetrieveCharacterID(db, "luigiDUDE");
            }
            //Messenger.PlayerWarp(client, map.MapID, 0, 25);
            watch.Stop();
            PacketHitList.MethodEnded(ref hitlist);
            Messenger.PlayerMsg(client, "Time: " + watch.ElapsedMilliseconds + "\nPlayer Count: " + playerCount, Text.BrightGreen);
            Messenger.PlayerMsg(client, "RNG: " + Server.Math.Rand(0, 1000), Text.BrightGreen);
            Messenger.PlayerMsg(client, "Tick Count: " + Server.Core.GetTickCount().Tick, Text.BrightGreen);
            //exPlayer.Get(client).EvolutionActive = !exPlayer.Get(client).EvolutionActive;
            //Messenger.PlayerMsg(client, "Evolution active: " + exPlayer.Get(client).EvolutionActive, Text.Yellow);
            //BossBattles.StartBossBattle(client, "CliffsideRelic");

            //map.SetTile(9, 3, 3, 0, 4, 3);
            //map.SetAttribute(9, 3, Server.Enums.TileType.Scripted, 46, 0, 0, "2", "1015", "25:25");
            //Messenger.SendTile(9, 3, map);
        }
开发者ID:pzaps,项目名称:Server,代码行数:29,代码来源:Debug.cs

示例4: FindMoveName

        /*
        public static int FindMoveName(string moveName){
            for (int i = 1; i <= moves.MaxMoves; i++) {
                if (Moves.Moves[i].Name == moveName) {
                    return i;
                }
            }
            return -1;
        }
        */
        public static void Initialize()
        {
            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data))
            {
                //method for getting count
                string query = "SELECT COUNT(num) FROM move";
                DataColumnCollection row = dbConnection.Database.RetrieveRow(query);

                int count = row["COUNT(num)"].ValueString.ToInt();
                moves = new MoveCollection(count);

            }
            standardAttack = new Move();

            //Set standard attack
            standardAttack.Name = "its regular attack";
            standardAttack.RangeType = Enums.MoveRange.FrontOfUser;
            standardAttack.Range = 1;
            standardAttack.Accuracy = 90;
            standardAttack.TargetType = Enums.MoveTarget.Foes;
            standardAttack.Element = Enums.PokemonType.None;
            standardAttack.MoveCategory = Enums.MoveCategory.Physical;
            standardAttack.EffectType = Enums.MoveType.SubHP;
            standardAttack.HitTime = 900;
            standardAttack.HitFreeze = false;
            standardAttack.Data1 = Server.Constants.STANDARDATTACKBASEPOWER;
            standardAttack.AttackerAnim.AnimationIndex = -1;
            standardAttack.TravelingAnim.AnimationIndex = -1;
            standardAttack.DefenderAnim.AnimationIndex = -1;
            standardAttack.Sound = -1;
        }
开发者ID:ScruffyKnight,项目名称:PMU-Server,代码行数:41,代码来源:MoveManager.cs

示例5: AccountExists

 public static bool AccountExists(DatabaseConnection dbConnection, string accountName)
 {
     if (!string.IsNullOrEmpty(accountName)) {
         return PlayerDataManager.IsAccountNameTaken(dbConnection.Database, accountName);
     } else {
         return false;
     }
 }
开发者ID:pzaps,项目名称:Server,代码行数:8,代码来源:PlayerManagerDB.cs

示例6: CharacterNameExists

 public static bool CharacterNameExists(DatabaseConnection dbConnection, string characterName)
 {
     string retrievedCharID = RetrieveCharacterID(dbConnection, characterName);
     if (!string.IsNullOrEmpty(retrievedCharID)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:pzaps,项目名称:Server,代码行数:9,代码来源:PlayerManagerDB.cs

示例7: Party

        public Party(string partyID, Client leader)
        {
            PartyID = partyID;

            Members = new List<string>();
            Members.Add(leader.Player.CharID);
            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                PartyManager.SaveParty(dbConnection.Database, this);
            }
        }
开发者ID:pzaps,项目名称:Server,代码行数:10,代码来源:Party.cs

示例8: CreateNewAccount

        /// <summary>
        /// Creates a new account. Return codes: -1: Unknown error, 0: Success, 1: Account already exists
        /// </summary>
        /// <param name="accountName">Name of the account.</param>
        /// <param name="encryptedPassword">The encrypted password.</param>
        /// <returns></returns>
        public static int CreateNewAccount(DatabaseConnection dbConnection, string accountName, string encryptedPassword, string email)
        {
            int result = -1;
            if (PlayerDataManager.IsAccountNameTaken(dbConnection.Database, accountName) == false) {
                PlayerDataManager.CreateNewAccount(dbConnection.Database, accountName, encryptedPassword, email);
                result = 0;
            } else {
                result = 1;
            }

            return result;
        }
开发者ID:pzaps,项目名称:Server,代码行数:18,代码来源:PlayerManagerDB.cs

示例9: Initialize

        public static void Initialize()
        {
            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data))
            {
                //method for getting count
                string query = "SELECT COUNT(num) FROM item";
                DataColumnCollection row = dbConnection.Database.RetrieveRow(query);

                int count = row["COUNT(num)"].ValueString.ToInt();
                items = new ItemCollection(count);
            }
        }
开发者ID:ScruffyKnight,项目名称:PMU-Server,代码行数:12,代码来源:ItemManager.cs

示例10: AddToParty

        public bool AddToParty(Client client)
        {
            if (CanAddToParty(client)) {
                Add(client.Player.CharID);
                //SwitchOutExtraMembers();

                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                    PartyManager.SaveParty(dbConnection.Database, this);
                }
                return true;
            } else {
                return false;
            }
        }
开发者ID:pzaps,项目名称:Server,代码行数:14,代码来源:Party.cs

示例11: BanPlayer

 // Bans a player
 public static void BanPlayer(DatabaseConnection dbConnection, string ip, string bannedID, string bannedAccount,
     string bannedMac, string bannerID, string bannerIP, string unbanDate, Enums.BanType banType)
 {
     IDataColumn[] columns = new IDataColumn[] {
         dbConnection.Database.CreateColumn(true, "BannedPlayerID", bannedID),
         dbConnection.Database.CreateColumn(false, "BannedPlayerAccount", bannedAccount),
         dbConnection.Database.CreateColumn(false, "BannedPlayerIP", ip),
         dbConnection.Database.CreateColumn(false, "BannedPlayerMac", bannedMac),
         dbConnection.Database.CreateColumn(false, "BannerPlayerID", bannerID),
         dbConnection.Database.CreateColumn(false, "BannerPlayerIP",bannerIP),
         dbConnection.Database.CreateColumn(false, "BannedDate", DateTime.Now.ToString()),
         dbConnection.Database.CreateColumn(false, "UnbanDate", unbanDate),
         dbConnection.Database.CreateColumn(false, "BanType", ((int)banType).ToString())
     };
     dbConnection.Database.AddRow("bans", columns);
 }
开发者ID:ScruffyKnight,项目名称:PMU-Server,代码行数:17,代码来源:Bans.cs

示例12: LoadMissionPool

        public static void LoadMissionPool(DatabaseConnection dbConnection, int difficulty)
        {
            MissionPool missionPool = new MissionPool();
            MySql database = dbConnection.Database;

            string query = "SELECT mission_client.DexNum, mission_client.FormNum " +
                "FROM mission_client " +
                "WHERE mission_client.Rank = \'" + difficulty + "\'  " +
                "ORDER BY mission_client.ClientIndex";

            foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query))
            {
                MissionClientData data = new MissionClientData();
                data.Species = column["DexNum"].ValueString.ToInt();
                data.Form = column["FormNum"].ValueString.ToInt();
                missionPool.MissionClients.Add(data);
            }

            query = "SELECT mission_enemy.NpcNum " +
                "FROM mission_enemy " +
                "WHERE mission_enemy.Rank = \'" + difficulty + "\'  " +
                "ORDER BY mission_enemy.EnemyIndex";

            foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query))
            {
                MissionEnemyData data = new MissionEnemyData();
                data.NpcNum = column["NpcNum"].ValueString.ToInt();
                missionPool.Enemies.Add(data);
            }

            query = "SELECT mission_reward.ItemNum, mission_reward.ItemAmount, mission_reward.ItemTag " +
                "FROM mission_reward " +
                "WHERE mission_reward.Rank = \'" + difficulty + "\'  " +
                "ORDER BY mission_reward.RewardIndex";

            foreach (DataColumnCollection column in database.RetrieveRowsEnumerable(query))
            {
                MissionRewardData data = new MissionRewardData();
                data.ItemNum = column["ItemNum"].ValueString.ToInt();
                data.Amount = column["ItemAmount"].ValueString.ToInt();
                data.Tag = column["ItemTag"].ValueString;
                missionPool.Rewards.Add(data);
            }

            missionPools.MissionPools.Add(missionPool);
        }
开发者ID:pzaps,项目名称:Server,代码行数:46,代码来源:WonderMailManager.cs

示例13: DumpStatistics

        public static void DumpStatistics()
        {
            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data)) {
                dbConnection.Database.ExecuteNonQuery("TRUNCATE TABLE packet_statistics");

                foreach (string key in statistics.Keys) {
                    PacketStatistic stats;
                    if (statistics.TryGetValue(key, out stats)) {
                        dbConnection.Database.UpdateOrInsert("packet_statistics", new IDataColumn[] {
                        dbConnection.Database.CreateColumn(true, "Header", key),
                        dbConnection.Database.CreateColumn(false, "Amount", stats.TimesReceived.ToString()),
                        dbConnection.Database.CreateColumn(false, "AverageTime", (stats.TotalProcessTime / stats.TimesReceived * 1000 / (double)System.Diagnostics.Stopwatch.Frequency).ToString()),
                        dbConnection.Database.CreateColumn(false, "AverageDataSplittingTime", (stats.TotalDataSplittingTime / stats.TimesReceived * 1000 / (double)System.Diagnostics.Stopwatch.Frequency).ToString()),
                        dbConnection.Database.CreateColumn(false, "AverageCPUUsage", (stats.CPUUsage / stats.TimesReceived).ToString())
                    });
                    }
                }
            }
        }
开发者ID:pzaps,项目名称:Server,代码行数:19,代码来源:PacketStatistics.cs

示例14: LoadStories

        public static void LoadStories(object object1)
        {
            try
            {

                using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data))
                {
                    for (int i = 0; i <= stories.MaxStories; i++)
                    {
                        LoadStory(i, dbConnection.Database);
                        if (LoadUpdate != null)
                            LoadUpdate(null, new LoadingUpdateEventArgs(i, stories.MaxStories));
                    }
                    if (LoadComplete != null)
                        LoadComplete(null, null);

                }
            } catch (Exception ex) {
                Exceptions.ErrorLogger.WriteToErrorLog(ex);
            }
        }
开发者ID:ScruffyKnight,项目名称:PMU-Server,代码行数:21,代码来源:StoryManagerBase.cs

示例15: DisbandGuild

        public static void DisbandGuild(Client client)
        {
            if (client.Player.GuildAccess < Enums.GuildRank.Founder) {
                Messenger.PlayerMsg(client, "You are not the owner of this guild!", Text.BrightRed);
                return;
            }

            string guildName = client.Player.GuildName;

            using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Players)) {
                DataManager.Players.PlayerDataManager.RemoveGuild(dbConnection.Database, guildName);
            }

            foreach (Client member in ClientManager.GetClients()) {
                if (member.Player.GuildName == guildName) {
                    member.Player.GuildName = "";
                    member.Player.GuildAccess = Enums.GuildRank.None;
                    Messenger.SendPlayerGuild(member);
                    Messenger.PlayerMsg(client, "Your guild has been disbanded.", Text.BrightRed);
                }
            }
        }
开发者ID:pzaps,项目名称:Server,代码行数:22,代码来源:GuildManager.cs


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