public CatalogClubOffer(uint Id, string Name, int Price, int LengthDays, CatalogClubOfferType Type) { mId = Id; mName = Name; mPrice = Price; mLength = LengthDays; mType = Type; }
public static void RefreshCatalogData(SqlDatabaseClient MySqlClient, bool NotifyUsers = true) { int CountLoaded = 0; lock (mPages) { mCatalogItems.Clear(); mCatalogItemsIdIndex.Clear(); mCatalogItemsNameIndex.Clear(); mPages.Clear(); mClubOffers.Clear(); mPages.Add(-1, new CatalogPage(-1, 0, string.Empty, 0, 0, string.Empty, true, true, string.Empty, null, null, new List <CatalogItem>())); // root category MySqlClient.SetParameter("enabled", "1"); DataTable ItemTable = MySqlClient.ExecuteQueryTable("SELECT * FROM catalog_items WHERE enabled = @enabled ORDER BY name ASC"); foreach (DataRow Row in ItemTable.Rows) { int PageId = (int)Row["page_id"]; if (!mCatalogItems.ContainsKey(PageId)) { mCatalogItems[PageId] = new List <CatalogItem>(); } CatalogItem Item = new CatalogItem((uint)Row["id"], (uint)Row["base_id"], (string)Row["name"], (int)Row["cost_credits"], (int)Row["cost_pixels"], (int)Row["amount"], (string)Row["preset_flags"], (int)Row["club_restriction"]); if (Item.Definition == null) { Output.WriteLine("Warning: Catalog item " + (uint)Row["id"] + " has an invalid base_id reference.", OutputLevel.Warning); continue; } mCatalogItems[PageId].Add(Item); mCatalogItemsIdIndex[Item.Id] = Item; mCatalogItemsNameIndex[Item.DisplayName] = Item; } MySqlClient.SetParameter("enabled", "1"); DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM catalog WHERE enabled = @enabled ORDER BY order_num ASC"); foreach (DataRow Row in Table.Rows) { List <string> PageStrings1 = new List <string>(); List <string> PageStrings2 = new List <string>(); foreach (string String in Row["page_strings_1"].ToString().Split('|')) { PageStrings1.Add(String); } foreach (string String in Row["page_strings_2"].ToString().Split('|')) { PageStrings2.Add(String); } int Id = (int)Row["id"]; mPages.Add(Id, new CatalogPage((int)Row["id"], (int)Row["parent_id"], (string)Row["title"], (int)Row["icon"], (int)Row["color"], (string)Row["required_right"], (Row["visible"].ToString() == "1"), (Row["dummy_page"].ToString() == "1"), (string)Row["template"], PageStrings1, PageStrings2, mCatalogItems.ContainsKey(Id) ? mCatalogItems[Id] : new List <CatalogItem>())); CountLoaded++; } DataTable ClubTable = MySqlClient.ExecuteQueryTable("SELECT * FROM catalog_subscriptions"); foreach (DataRow Row in ClubTable.Rows) { CatalogClubOfferType OfferType = CatalogClubOfferType.Basic; switch ((string)Row["type"]) { case "vip": OfferType = CatalogClubOfferType.Vip; break; case "upgrade": OfferType = CatalogClubOfferType.VipUpgrade; break; } mClubOffers.Add((uint)Row["id"], new CatalogClubOffer((uint)Row["id"], (string)Row["name"], (int)Row["cost_credits"], (int)Row["length_days"], OfferType)); } } Output.WriteLine("Loaded " + CountLoaded + " catalog page(s).", OutputLevel.DebugInformation); if (NotifyUsers) { SessionManager.BroadcastPacket(CatalogUpdatedNotificationComposer.Compose()); } }