示例#1
0
        public CharacterInfo(SqlDatabaseClient MySqlClient, uint SessionId, uint Id, string Username, string RealName, string Figure,
                             CharacterGender Gender, string Motto, int Credits, int ActivityPoints, double ActivityPointsLastUpdate,
                             bool PrivacyAcceptFriends, uint HomeRoom, int Score, int ConfigVolume, int ModerationTickets,
                             int ModerationTicketsAbusive, double ModerationTicketCooldown, int ModerationBans, int ModerationCautions,
                             double TimestampLastOnline, double TimestampRegistered, int RespectPoints, int RespectCreditHuman,
                             int RespectCreditPets, double ModerationMutedUntil)
        {
            mSessionId = SessionId;
            mId        = Id;
            mUsername  = Username;
            mRealName  = RealName;
            mFigure    = Figure;
            mGender    = Gender;
            mMotto     = Motto;
            mCredits   = Credits;

            mActivityPoints       = ActivityPoints;
            mPrivacyAcceptFriends = PrivacyAcceptFriends;
            mHomeRoom             = HomeRoom;
            mScore        = Score;
            mConfigVolume = ConfigVolume;

            mRespectPoints      = RespectPoints;
            mRespectCreditHuman = RespectCreditHuman;
            mRespectCreditPets  = RespectCreditPets;

            mModerationTickets         = ModerationTickets;
            mModerationTicketsAbusive  = ModerationTicketsAbusive;
            mModerationTicketsCooldown = ModerationTicketCooldown;
            mModerationCautions        = ModerationCautions;
            mModerationBans            = ModerationBans;
            mModerationMutedUntil      = ModerationMutedUntil;

            mCacheAge = UnixTimestamp.GetCurrent();
            mTimestampLastActivityPointsUpdate = ActivityPointsLastUpdate;
            mTimestampLastOnline = TimestampLastOnline;
            mTimestampRegistered = TimestampRegistered;

            mWardrobe = new Dictionary <int, WardrobeItem>();
            mTags     = new List <string>();

            if (MySqlClient != null)
            {
                MySqlClient.SetParameter("userid", mId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM wardrobe WHERE user_id = @userid LIMIT 10");

                foreach (DataRow Row in Table.Rows)
                {
                    mWardrobe.Add((int)Row["slot_id"], new WardrobeItem((string)Row["figure"], (Row["gender"].ToString().ToLower() == "m" ? CharacterGender.Male : CharacterGender.Female)));
                }

                MySqlClient.SetParameter("userid", mId);
                DataTable TagsTable = MySqlClient.ExecuteQueryTable("SELECT * FROM tags WHERE user_id = @userid");

                foreach (DataRow Row in TagsTable.Rows)
                {
                    mTags.Add((string)Row["tag"]);
                }
            }
        }
示例#2
0
        public static void ReloadFlatCategories(SqlDatabaseClient MySqlClient)
        {
            int NumberLoaded = 0;

            lock (mFlatCategories)
            {
                mFlatCategories.Clear();
                mEventSearchQueries.Clear();

                MySqlClient.SetParameter("enabled", "1");
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM flat_categories WHERE enabled = @enabled ORDER BY order_num ASC");

                foreach (DataRow Row in Table.Rows)
                {
                    mFlatCategories.Add(new FlatCategory((int)Row["id"], (Row["visible"].ToString() == "1"),
                                                         (string)Row["title"], (Row["allow_trading"].ToString() == "1")));
                    NumberLoaded++;
                }

                DataTable EventQueries = MySqlClient.ExecuteQueryTable("SELECT * FROM navigator_event_search_categories");

                foreach (DataRow Row in EventQueries.Rows)
                {
                    mEventSearchQueries.Add(Row["query"].ToString().ToLower(), (int)Row["category_id"]);
                }
            }

            Output.WriteLine("Loaded " + NumberLoaded + " flat " + ((NumberLoaded != 1) ? "categories" : "category") + ".", OutputLevel.DebugInformation);
        }
示例#3
0
        public static void Reload(SqlDatabaseClient MySqlClient)
        {
            int i = 0;

            mUserMessagePresets.Clear();
            mRoomMessagePresets.Clear();
            mUserActionPresetCategories.Clear();
            mUserActionPresetMessages.Clear();

            DataTable BasicPresetTable = MySqlClient.ExecuteQueryTable("SELECT type,message FROM moderation_presets");

            foreach (DataRow Row in BasicPresetTable.Rows)
            {
                string Message = (string)Row["message"];

                switch ((string)Row["type"])
                {
                case "room":

                    mRoomMessagePresets.Add(Message);
                    break;

                case "user":

                    mUserMessagePresets.Add(Message);
                    break;
                }

                i++;
            }

            DataTable UserActionCategoryTable = MySqlClient.ExecuteQueryTable("SELECT id,caption FROM moderation_preset_action_categories");

            foreach (DataRow Row in UserActionCategoryTable.Rows)
            {
                mUserActionPresetCategories.Add((uint)Row["id"], (string)Row["caption"]);
                i++;
            }

            DataTable UserActionMsgTable = MySqlClient.ExecuteQueryTable("SELECT id,parent_id,caption,message_text FROM moderation_preset_action_messages");

            foreach (DataRow Row in UserActionMsgTable.Rows)
            {
                uint ParentId = (uint)Row["parent_id"];

                if (!mUserActionPresetMessages.ContainsKey(ParentId))
                {
                    mUserActionPresetMessages.Add(ParentId, new Dictionary <string, string>());
                }

                mUserActionPresetMessages[ParentId].Add((string)Row["caption"], (string)Row["message_text"]);
                i++;
            }

            Output.WriteLine("Loaded " + i + " moderation categories and presets.", OutputLevel.DebugInformation);
        }
示例#4
0
        public static void RebuildCache(SqlDatabaseClient MySqlClient)
        {
            lock (mRights)
            {
                mRights.Clear();
                mRightSets.Clear();
                mRightsBages.Clear();

                DataTable RankTable   = MySqlClient.ExecuteQueryTable("SELECT rank_id,rights_sets,badge_code FROM ranks");
                DataTable RightsTable = MySqlClient.ExecuteQueryTable("SELECT set_id,right_id FROM rights");

                foreach (DataRow Row in RankTable.Rows)
                {
                    List <uint> Sets    = new List <uint>();
                    string[]    SetBits = ((string)Row["rights_sets"]).Split(',');


                    uint rank = (uint)Row["rank_id"];

                    if (!mRights.ContainsKey(rank))
                    {
                        mRights.Add(rank, new List <int>());
                    }

                    if (!mRightsBages.ContainsKey(rank))
                    {
                        mRightsBages.Add(rank, (String)Row["badge_code"]);
                    }

                    foreach (string SetBit in SetBits)
                    {
                        int Set = 0;

                        int.TryParse(SetBit, out Set);

                        if (Set > 0)
                        {
                            mRights[rank].Add(Set);
                        }
                    }
                }

                foreach (DataRow Row in RightsTable.Rows)
                {
                    uint SetId = (uint)Row["set_id"];

                    if (!mRightSets.ContainsKey(SetId))
                    {
                        mRightSets.Add(SetId, new List <string>());
                    }

                    mRightSets[SetId].Add((string)Row["right_id"]);
                }
            }
        }
示例#5
0
        public static void GetUserRooms(Session Session, ClientMessage Message)
        {
            ServerMessage Response = TryGetResponseFromCache(Session.CharacterId, Message);

            if (Response != null)
            {
                Session.SendData(Response);
                return;
            }

            List <RoomInfo> Rooms = new List <RoomInfo>();

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                MySqlClient.SetParameter("ownerid", Session.CharacterId);
                MySqlClient.SetParameter("limit", MaxRoomsPerUser);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM rooms WHERE owner_id = @ownerid ORDER BY name ASC LIMIT @limit");

                foreach (DataRow Row in Table.Rows)
                {
                    Rooms.Add(RoomInfoLoader.GenerateRoomInfoFromRow(Row));
                }
            }

            Response = NavigatorRoomListComposer.Compose(0, 5, string.Empty, Rooms);
            AddToCacheIfNeeded(Session.CharacterId, Message, Response);
            Session.SendData(Response);
        }
示例#6
0
        private static void GetRatedRooms(Session Session, ClientMessage Message)
        {
            ServerMessage Response = TryGetResponseFromCache(0, Message);

            if (Response != null)
            {
                Session.SendData(Response);
                return;
            }

            List <RoomInfo> Rooms = new List <RoomInfo>();

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM rooms WHERE type = 'flat' AND score > 0 ORDER BY score DESC LIMIT 50");

                foreach (DataRow Row in Table.Rows)
                {
                    Rooms.Add(RoomInfoLoader.GenerateRoomInfoFromRow(Row));
                }
            }

            Response = NavigatorRoomListComposer.Compose(0, 2, string.Empty, Rooms);
            AddToCacheIfNeeded(0, Message, Response);
            Session.SendData(Response);
        }
示例#7
0
        public static void ReloadOfficialItems(SqlDatabaseClient MySqlClient)
        {
            int NumberLoaded = 0;

            lock (mOfficialItems)
            {
                mOfficialItems.Clear();

                MySqlClient.SetParameter("enabled", "1");
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM navigator_frontpage WHERE enabled = @enabled ORDER BY order_num ASC");

                foreach (DataRow Row in Table.Rows)
                {
                    mOfficialItems.Add(new NavigatorOfficialItem((uint)Row["id"], (uint)Row["parent_id"], (uint)Row["room_id"],
                                                                 (Row["is_category"].ToString() == "1"), (Row["display_type"].ToString() == "details" ?
                                                                                                          NavigatorOfficialItemDisplayType.Detailed : NavigatorOfficialItemDisplayType.Banner),
                                                                 (string)Row["name"], (string)Row["descr"], (Row["image_type"].ToString() == "internal" ?
                                                                                                             NavigatorOfficialItemImageType.Internal : NavigatorOfficialItemImageType.External),
                                                                 (string)Row["image_src"], (string)Row["banner_label"], (Row["category_autoexpand"].ToString() == "1")));
                    NumberLoaded++;
                }
            }

            Output.WriteLine("Loaded " + NumberLoaded + " navigator frontpage item(s).", OutputLevel.DebugInformation);
        }
示例#8
0
        public static void RefreshCatalogData(SqlDatabaseClient MySqlClient, bool NotifyUsers = true)
        {
            int num = 0;

            dictionary_0.Clear();
            dictionary_1.Clear();
            dictionary_2.Clear();
            MySqlClient.SetParameter("enabled", "1");
            foreach (DataRow row in MySqlClient.ExecuteQueryTable("SELECT * FROM catalogo_objetos WHERE activado = @enabled ORDER BY id ASC").Rows)
            {
                int key = (int)row["pagina_catalogo"];
                if (!dictionary_0.ContainsKey(key))
                {
                    dictionary_0[key] = new List <CatalogItem>();
                }
                CatalogItem item = new CatalogItem((uint)row["id"], (string)row["nombre_base"], (string)row["nombre"], (string)row["descripcion"], (int)row["precio_oro"], (int)row["precio_plata"], (int)row["pagina_catalogo"], (string)row["color"], (string)row["color_servidor"], (string)row["color_partes"], (string)row["color_partes_servidor"], (string)row["parte_1"], (string)row["parte_2"], (string)row["parte_3"], (string)row["parte_4"], (double)row["tam_1"], (double)row["tam_2"], (double)row["tam_3"], (uint)row["tipo"], (uint)row["tam_relleno"], (uint)row["ubicacion"], row["activado"].ToString() == "1", (uint)row["tipo_rare"], (uint)row["sizable"], (uint)row["intercambiable"], (uint)row["vip"]);
                if (string.IsNullOrEmpty(item.BaseName))
                {
                    Output.WriteLine("Warning: Catalog item " + ((uint)row["id"]) + " has an invalid base_id reference.", OutputLevel.Warning);
                }
                else
                {
                    dictionary_0[key].Add(item);
                    dictionary_1[item.UInt32_0]    = item;
                    dictionary_2[item.DisplayName] = item;
                    list_0.Add(item);
                    num++;
                }
            }
            Output.WriteLine("Loaded " + num + " Catalog items in 11 Catalog pages.", OutputLevel.DebugInformation);
        }
示例#9
0
        public static void ReloadRewards(SqlDatabaseClient MySqlClient)
        {
            lock (mSyncRoot)
            {
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM recycler_rewards");

                int UniqueLevels = 0;

                foreach (DataRow Row in Table.Rows)
                {
                    int RewardLevel = (int)Row["chance_level"];

                    if (!mRewards.ContainsKey(RewardLevel))
                    {
                        mRewards.Add(RewardLevel, new List <uint>());
                        UniqueLevels++;
                    }

                    mRewards[RewardLevel].Add((uint)Row["item_id"]);
                }

                if (UniqueLevels != 5)
                {
                    Output.WriteLine("Recycler is not configured correctly and will *not* work properly. Please ensure there are 5 unique reward levels.", OutputLevel.Warning);
                    mEnabled = false;
                }
                else
                {
                    mEnabled = true;
                }
            }
        }
示例#10
0
        public static ReadOnlyCollection <ModerationChatlogEntry> GetLogsForRoom(uint RoomId, double FromTimestamp, double ToTimestamp)
        {
            List <ModerationChatlogEntry> Entries = new List <ModerationChatlogEntry>();

            if (!(bool)ConfigManager.GetValue("moderation.chatlogs.enabled"))
            {
                return(Entries.AsReadOnly());
            }

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                MySqlClient.SetParameter("roomid", RoomId);
                MySqlClient.SetParameter("timestamp_from", FromTimestamp);
                MySqlClient.SetParameter("timestamp_to", ToTimestamp);

                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT user_id,room_id,timestamp,message FROM moderation_chatlogs WHERE room_id = @roomid AND timestamp >= @timestamp_from AND timestamp <= @timestamp_to ORDER BY timestamp DESC");

                foreach (DataRow Row in Table.Rows)
                {
                    Entries.Add(new ModerationChatlogEntry((uint)Row["user_id"], (uint)Row["room_id"], (double)Row["timestamp"],
                                                           (string)Row["message"]));
                }
            }

            return(Entries.AsReadOnly());
        }
示例#11
0
        public static void Initialize(SqlDatabaseClient MySqlClient)
        {
            mSets = new Dictionary <int, DrinkSet>();

            DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM drink_sets");

            foreach (DataRow Row in Table.Rows)
            {
                int      Id        = (int)Row["id"];
                string[] DrinkData = Row["drinks"].ToString().Split(',');

                List <int> Drinks = new List <int>();

                foreach (string Drink in DrinkData)
                {
                    int i = 0;
                    int.TryParse(Drink, out i);

                    if (i > 0)
                    {
                        Drinks.Add(i);
                    }
                }

                if (Drinks.Count > 0)
                {
                    mSets.Add(Id, new DrinkSet(Id, Drinks));
                }
            }
        }
示例#12
0
        private void LoadAnnouncements()
        {
            try
            {
                using (SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient())
                {
                    var queryTable = mySqlClient.ExecuteQueryTable("SELECT * FROM server_announcements");
                    if (queryTable != null)
                    {
                        foreach (DataRow reader in queryTable.Rows)
                        {
                            int    id   = intConv(reader["ID"]);
                            string text = reader["ANNOUNCEMENT"].ToString();

                            ////add to Storage
                            Chat.StorageManager.Announcements.Add(id, new Announcement(
                                                                      id, text
                                                                      ));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Failed loading Chat Mods, " + e.Message);
            }
        }
示例#13
0
        public void LoadModerators()
        {
            try
            {
                using (SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient())
                {
                    var queryTable = mySqlClient.ExecuteQueryTable($"SELECT * FROM server_chat_moderators");
                    foreach (DataRow queryRow in queryTable.Rows)
                    {
                        var id = intConv(queryRow["PLAYER_ID"]);
                        //Informations
                        string name = queryRow["NAME"].ToString();
                        var    lvl  = (ModeratorLevelTypes)(intConv(queryRow["LEVEL"]));
                        ////add to Storage
                        var mod = new Moderator(
                            id,
                            name,
                            "",
                            Main.Global.StorageManager.Clans[0],
                            lvl
                            );

                        Chat.StorageManager.ChatModerators.Add(id, mod);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#14
0
        public static void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mSyncRoot)
            {
                mCharacterBlacklist.Clear();
                mRemoteAddressBlacklist.Clear();

                MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM bans WHERE timestamp_expire > @timestamp");

                foreach (DataRow Row in Table.Rows)
                {
                    uint   UserId     = (uint)Row["user_id"];
                    string RemoteAddr = (string)Row["remote_address"];

                    if (UserId > 0 && !mCharacterBlacklist.Contains(UserId))
                    {
                        mCharacterBlacklist.Add(UserId);
                    }

                    if (RemoteAddr.Length > 0 && !mRemoteAddressBlacklist.Contains(RemoteAddr))
                    {
                        mRemoteAddressBlacklist.Add(RemoteAddr);
                    }
                }
            }
        }
示例#15
0
        public void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mInner)
            {
                mInner.Clear();

                MySqlClient.SetParameter("userid", mCharacterId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM items WHERE user_id = @userid");

                foreach (DataRow Row in Table.Rows)
                {
                    Item Item = ItemFactory.CreateFromDatabaseRow(Row);

                    if (Item == null || Item.Definition == null || Item.InSoundManager)
                    {
                        continue;
                    }

                    if (Item.PendingExpiration && Item.ExpireTimeLeft <= 0)
                    {
                        Item.RemovePermanently(MySqlClient);
                        continue;
                    }

                    mInner.Add(Item.Id, Item);
                }
            }
        }
 public static void ReloadCache(SqlDatabaseClient MySqlClient)
 {
     lock (object_0)
     {
         list_0.Clear();
         list_1.Clear();
         dictionary_0.Clear();
         MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());
         foreach (DataRow row in MySqlClient.ExecuteQueryTable("SELECT * FROM baneos WHERE timestampex > @timestamp OR tipo_baneo > 0").Rows)
         {
             uint   item        = (uint)row["id_usuario"];
             uint   banType     = (uint)row["tipo_baneo"];
             string reason      = (string)row["detalles"];
             string moderator   = (string)row["moderador"];
             string str3        = (string)row["direccion_ip"];
             double timestamp   = (double)row["timestamp"];
             double timestampEx = (double)row["timestampex"];
             if ((item > 0) && !list_0.Contains(item))
             {
                 list_0.Add(item);
             }
             if ((str3.Length > 0) && !list_1.Contains(str3))
             {
                 list_1.Add(str3);
             }
             if ((item > 0) && !dictionary_0.ContainsKey(item))
             {
                 dictionary_0.Add(item, new BanDetails(item, banType, reason, timestamp, timestampEx, moderator));
             }
         }
     }
 }
示例#17
0
 public static void ReloadModels(SqlDatabaseClient MySqlClient)
 {
     concurrentDictionary_1.Clear();
     foreach (DataRow row in MySqlClient.ExecuteQueryTable("SELECT * FROM modelos").Rows)
     {
         concurrentDictionary_1.TryAdd((string)row["id"], new SpaceModel((string)row["id"], (((string)row["tipo"]) == "isla") ? SpaceModelType.Island : SpaceModelType.Area, new Heightmap((string)row["mapa_bits"]), new Vector3((int)row["pos_x"], (int)row["pos_y"], (int)row["pos_z"]), (int)row["rotacion"], (int)row["max_usuarios"]));
     }
 }
示例#18
0
 private static void smethod_1(Session session_0, ClientMessage clientMessage_0)
 {
     using (SqlDatabaseClient client = SqlDatabaseManager.GetClient())
     {
         client.SetParameter("receptor", session_0.CharacterId);
         DataTable table = client.ExecuteQueryTable("SELECT * FROM laptop_mensajes WHERE (receptor = @receptor AND leido = '0') OR general = '1'");
         session_0.SendData(Class0.smethod_0(table), false);
     }
 }
示例#19
0
 private static void LoadMessages(Session Session, ClientMessage Message)
 {
     using (SqlDatabaseClient client = SqlDatabaseManager.GetClient())
     {
         client.SetParameter("receptor", Session.CharacterId);
         DataTable table = client.ExecuteQueryTable("SELECT * FROM laptop_mensajes WHERE (receptor = @receptor AND leido = '0') OR general = '1'");
         Session.SendData(LaptopLoadMessagesComposer.Compose(table));
     }
 }
示例#20
0
        public static void RebuildCache(SqlDatabaseClient MySqlClient)
        {
            lock (mBadges)
            {
                mBadges.Clear();
                mRightSets.Clear();

                DataTable BadgeTable  = MySqlClient.ExecuteQueryTable("SELECT id,code,rights_sets FROM badge_definitions");
                DataTable RightsTable = MySqlClient.ExecuteQueryTable("SELECT set_id,right_id FROM rights");

                foreach (DataRow Row in BadgeTable.Rows)
                {
                    List <uint> Sets    = new List <uint>();
                    string[]    SetBits = ((string)Row["rights_sets"]).Split(',');

                    foreach (string SetBit in SetBits)
                    {
                        uint Set = 0;

                        uint.TryParse(SetBit, out Set);

                        if (Set > 0)
                        {
                            Sets.Add(Set);
                        }
                    }

                    mBadges.Add((uint)Row["id"], new Badge((uint)Row["id"], (string)Row["code"], Sets));
                }

                foreach (DataRow Row in RightsTable.Rows)
                {
                    uint SetId = (uint)Row["set_id"];

                    if (!mRightSets.ContainsKey(SetId))
                    {
                        mRightSets.Add(SetId, new List <string>());
                    }

                    mRightSets[SetId].Add((string)Row["right_id"]);
                }
            }
        }
示例#21
0
 public void ReloadContestItems(SqlDatabaseClient MySqlClient)
 {
     lock (this.dictionary_0)
     {
         this.dictionary_0.Clear();
         foreach (DataRow row in MySqlClient.ExecuteQueryTable("SELECT * FROM objetos_ranking WHERE activado = '1'").Rows)
         {
             this.dictionary_0.Add((uint)row["id"], new ContestItem((uint)row["id"], (uint)row["area_especifica"], (uint)row["id_objeto"], (uint)row["id_ranking"], new Vector2(0, 0), (uint)row["creditos_oro"], (uint)row["creditos_plata"], (uint)row["id_premio"], (string)row["nombre_objeto"], (string)row["nombre_mostrar"], (uint)row["tipo_caida"], (uint)row["tipo_captura"]));
         }
     }
 }
示例#22
0
        public static List <uint> GetFriendsForUser(SqlDatabaseClient MySqlClient, uint UserId, int Confirmed)
        {
            List <uint> list = new List <uint>();

            MySqlClient.SetParameter("id", UserId);
            MySqlClient.SetParameter("confirmed", Confirmed);
            foreach (DataRow row in MySqlClient.ExecuteQueryTable("SELECT id_amigo FROM laptop_amigos WHERE id_usuario = @id AND aceptado = @confirmed").Rows)
            {
                list.Add((uint)row[0]);
            }
            return(list);
        }
示例#23
0
        public static int GetNotifications(LocalUser user, out List <Log> logs)
        {
            logs = new List <Log>();

            DataTable table = null;

            try
            {
                using (SqlDatabaseClient client = SqlDatabaseManager.GetClient())
                {
                    client.SetParameter("@userid", user.UserID);
                    client.SetParameter("@date", user.TimeRegisteredLocal.ToString("yyyy-MM-dd HH:mm:ss"));

                    table = client.ExecuteQueryTable("SELECT l.id, l.member_id, l.date_added, l.info, m.name " +
                                                     "FROM Entry AS l " +
                                                     "LEFT JOIN EntryRead AS e ON e.member_id = @userid AND e.entry_id = l.id " +
                                                     "INNER JOIN Member AS m ON m.id = l.member_id " +
                                                     "WHERE e.entry_id IS NULL AND l.date_added >= @date;");
                }
            }
            catch (Exception e)
            {
                Logger.WriteLine(e.ToString(), Logger.LOG_LEVEL.WARN);
            }

            if (table == null)
            {
                return(-1);
            }

            foreach (DataRow row in table.Rows)
            {
                uint logId, userId;
                if (!UInt32.TryParse(row["id"].ToString(), out logId) || !UInt32.TryParse(row["member_id"].ToString(), out userId))
                {
                    continue;
                }

                Log newLog = new Log();
                newLog.LogID = logId;

                newLog.UserID       = userId;
                newLog.Name         = row["name"].ToString();
                newLog.ProfilePhoto = LocalUser.URL_USER_IMAGE + userId.ToString() + LocalUser.URL_USER_PROFILE_IMAGE;

                newLog.Info = row["info"].ToString();
                newLog.Date = DateTime.Parse(row["date_added"].ToString()).ToUniversalTime().ToString("dd/MM/yyyy-HH:mm:ss"); // DateTime.ParseExact(row["date_added"].ToString(), "yyyy-MM-dd HH:mm:ss", null, DateTimeStyles.AssumeLocal).ToUniversalTime().ToString("dd/MM/yyyy-HH:mm:ss");

                logs.Add(newLog);
            }

            return(0);
        }
示例#24
0
 public void ReloadCache(SqlDatabaseClient MySqlClient)
 {
     lock (this.object_0)
     {
         this.list_0.Clear();
         MySqlClient.SetParameter("user_id", this.uint_0);
         foreach (DataRow row in MySqlClient.ExecuteQueryTable("SELECT id_ignorada FROM ignorados WHERE id_usuario = @user_id").Rows)
         {
             this.list_0.Add((uint)row["id_ignorada"]);
         }
     }
 }
示例#25
0
        public static void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            mBlockedWords = new List <String>();
            DataTable words = MySqlClient.ExecuteQueryTable("SELECT word FROM wordfilter");

            foreach (DataRow Row in words.Rows)
            {
                if (!mBlockedWords.Contains((string)Row["word"]))
                {
                    mBlockedWords.Add((string)Row["word"]);
                }
            }
        }
示例#26
0
        public static void ReloadData(SqlDatabaseClient MySqlClient)
        {
            Dictionary <int, List <PetRaceData> > NewRaceData  = new Dictionary <int, List <PetRaceData> >();
            Dictionary <int, List <string> >      NewTrickData = new Dictionary <int, List <string> >();

            DataTable RaceTable = MySqlClient.ExecuteQueryTable("SELECT * FROM pet_races");

            foreach (DataRow Row in RaceTable.Rows)
            {
                int PetType = (int)Row["pet_type"];

                if (!NewRaceData.ContainsKey(PetType))
                {
                    NewRaceData.Add(PetType, new List <PetRaceData>());
                }

                NewRaceData[PetType].Add(new PetRaceData((int)Row["data1"], (int)Row["data2"], (int)Row["data3"]));
            }

            DataTable TrickTable = MySqlClient.ExecuteQueryTable("SELECT * FROM pet_tricks");

            foreach (DataRow Row in TrickTable.Rows)
            {
                int PetType = (int)Row["type"];

                if (!NewTrickData.ContainsKey(PetType))
                {
                    NewTrickData.Add(PetType, new List <string>());
                }

                NewTrickData[PetType].Add((string)Row["trick"]);
            }

            lock (mSyncRoot)
            {
                mRaces  = NewRaceData;
                mTricks = NewTrickData;
            }
        }
示例#27
0
        public static void DoWallItems(SqlDatabaseClient Phoenix, SqlDatabaseClient Butterfly)
        {
            DataTable items = Phoenix.ExecuteQueryTable("SELECT * FROM items WHERE room_id > 0 AND wall_pos LIKE ':w=%'");

            foreach (DataRow item in items.Rows)
            {
                int    Id      = Convert.ToInt32(item["id"]);
                int    RoomId  = Convert.ToInt32(item["room_id"]);
                string WallPos = (string)item["wall_pos"];

                int Position;

                string start  = WallPos.Replace(":w=", "");
                string start2 = start.Replace("l=", "");

                string[] furni1 = start.Split(' ');
                string[] furni2 = start2.Split(' ');

                string x  = furni1[0];
                string x1 = x.Replace(",", ".");

                string y  = furni2[1];
                string y1 = y.Replace(",", ".");

                if (furni2[2] == "l")
                {
                    Position = 8;
                }
                else
                {
                    Position = 7;
                }

                string   data   = x1;
                string[] furnix = data.Split('.');

                string   data1  = y1;
                string[] furniy = data1.Split('.');

                double x0  = Convert.ToDouble(furnix[0]);
                double x01 = Convert.ToDouble(furnix[1]);

                double y0  = Convert.ToDouble(furniy[0]);
                double y01 = Convert.ToDouble(furniy[1]);

                double g = Combine(x0, x01);
                double h = Combine(y0, y01);

                Butterfly.ExecuteNonQuery("REPLACE INTO items_rooms(item_id, room_id, x, y, n) VALUES ('" + Id + "', '" + RoomId + "', '" + g + "', '" + h + "', '" + Position + "')");
            }
        }
示例#28
0
        private static void smethod_0(SqlDatabaseClient sqlDatabaseClient_0)
        {
            DataTable table = sqlDatabaseClient_0.ExecuteQueryTable("SELECT * FROM site_noticias ORDER BY id DESC LIMIT 40");

            if (table != null)
            {
                foreach (DataRow row in table.Rows)
                {
                    list_0.Add(new Notice((uint)row["id"], (double)row["fecha"], (string)row["titulo"], (string)row["contenido"], (string)row["imagen"]));
                    uint_0++;
                }
            }
            Output.WriteLine("Loaded " + uint_0 + " news in to news cache.", OutputLevel.DebugInformation);
        }
示例#29
0
        public static void ReloadInterstitials(SqlDatabaseClient MySqlClient)
        {
            lock (mInterstitials)
            {
                mInterstitials.Clear();

                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM interstitials WHERE enabled = '1'");

                foreach (DataRow Row in Table.Rows)
                {
                    mInterstitials.Add((uint)Row["id"], new Interstitial((uint)Row["id"], (string)Row["url"],
                                                                         (string)Row["image"]));
                }
            }
        }
示例#30
0
        public void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mInner)
            {
                mInner.Clear();

                MySqlClient.SetParameter("characterid", mCharacterId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT room_id FROM user_favorites WHERE user_id = @characterid LIMIT " + Navigator.MaxFavoritesPerUser);

                foreach (DataRow Row in Table.Rows)
                {
                    mInner.Add((uint)Row["room_id"]);
                }
            }
        }