예제 #1
0
 private static bool CU(string usuario)
 {
     using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
     {
         MySqlClient.SetParameter("@usuario", usuario);
         int result = MySqlClient.ReadInt32("SELECT COUNT(*) FROM usuarios WHERE usuario = @usuario");
         MySqlClient.ClearParameters();
         return((result > 0) ? true : false);
     }
 }
예제 #2
0
        public void UpdateAchievementBadge(SqlDatabaseClient MySqlClient, string AchievementGroup, Badge NewBadge)
        {
            MySqlClient.SetParameter("userid", mUserId);
            MySqlClient.SetParameter("sourcetype", "achievement");
            MySqlClient.SetParameter("sourcedata", AchievementGroup);
            MySqlClient.SetParameter("badgeid", NewBadge.Id);

            lock (mSyncRoot)
            {
                if (mAchievementBadges.ContainsKey(AchievementGroup))
                {
                    Badge OldBadge = mAchievementBadges[AchievementGroup];

                    if (OldBadge == NewBadge)
                    {
                        MySqlClient.ClearParameters();
                        return;
                    }

                    mIndexCache.Remove(OldBadge.Code);
                    mAchievementBadges[AchievementGroup] = NewBadge;

                    MySqlClient.ExecuteNonQuery("UPDATE badges SET badge_id = @badgeid WHERE user_id = @userid AND source_type = @sourcetype AND source_data = @sourcedata LIMIT 1");

                    foreach (KeyValuePair <int, Badge> Badge in mEquippedBadges)
                    {
                        if (Badge.Value.Id == OldBadge.Id)
                        {
                            mEquippedBadges[Badge.Key] = NewBadge;
                            break;
                        }
                    }
                }
                else
                {
                    mAchievementBadges.Add(AchievementGroup, NewBadge);
                    MySqlClient.ExecuteNonQuery("INSERT INTO badges (user_id,badge_id,source_type,source_data) VALUES (@userid,@badgeid,@sourcetype,@sourcedata)");
                }

                mRightsCache = RegenerateRights();
                mIndexCache.Add(NewBadge.Code);
            }
        }