protected void Page_Load(object sender, EventArgs e) { int pageNr = PageUtility.GetQueryInt(Request, "page", 1); int pageIndex = pageNr - 1;//Change range from 0 to * instead of 1 to * int count = PageUtility.GetQueryInt(Request, "count", 100); if (count > 500) { count = 500; } var realm = RealmControl.Realm; if (realm == VF_RealmPlayersDatabase.WowRealm.Unknown) { return; } var wowVersion = StaticValues.GetWowVersion(realm); int itemID = PageUtility.GetQueryInt(Request, "item", 19364); int suffixID = PageUtility.GetQueryInt(Request, "suffix", 0); this.Title = "\"" + itemID + "\" ItemUsage @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers"; m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome() + PageUtility.BreadCrumb_AddFinish("ItemUsage")); var itemSummaryDB = Hidden.ApplicationInstance.Instance.GetItemSummaryDatabase(); using (VF.SQLComm comm = new VF.SQLComm()) { List <Tuple <DateTime, string> > players = null; players = itemSummaryDB.GetItemUsage(realm, itemID, suffixID);//, out players) == true) { string currentItemDatabase = DatabaseAccess.GetCurrentItemDatabaseAddress(); var itemInfo = DatabaseAccess.GetItemInfo(itemID, wowVersion); m_ItemUsageInfoHTML = new MvcHtmlString("<div style='overflow: hidden; display: table;'><div style='display: table-cell;'><h1>Players with <h1></div>" + "<div class='inventory' style='background: none; width: 58px; height: 58px; display: table-cell;'><div>" + "<img class='itempic' src='" + "http://realmplayers.com/" + itemInfo.GetIconImageAddress() + "'/>" + "<div class='quality' id='" + CharacterViewer.ItemQualityConversion[itemInfo.ItemQuality] + "'></div>" + "<img class='itemframe' src='assets/img/icons/ItemNormalFrame.png'/>" + CharacterViewer.GenerateItemLink(currentItemDatabase, itemID, suffixID, wowVersion) + "</div></div>" + "<span class='badge badge-inverse'>" + players.Count + " Players</span></div>" + "<p>Sorted by date \"aquired\"</p>"); Dictionary <PlayerColumn, string[]> extraColumns = new Dictionary <PlayerColumn, string[]>(); PlayerColumn ItemAndAquiredDateAfterColumn = PlayerColumn.Number; extraColumns.Add(ItemAndAquiredDateAfterColumn, new string[] { "Item", "Date Aquired" }); m_TableHeadHTML = new MvcHtmlString(PageUtility.CreatePlayerTableHeaderRow(Table_Columns, extraColumns)); string tableBody = ""; int nr = 0; Func <Tuple <DateTime, string>, DateTime> lambdaComparison = (_Tuple) => { return(_Tuple.Item1); }; players = players.OrderBy(lambdaComparison).ToList(); foreach (var playerDateAndName in players) { Player player = DatabaseAccess.FindRealmPlayer(this, realm, playerDateAndName.Item2); if (player != null) { ++nr; // style='position: absolute; margin: auto; width:58px; height:58px;' if (nr > pageIndex * count && nr <= (pageIndex + 1) * count) { //string itemLink = ""; VF_RealmPlayersDatabase.PlayerData.ItemInfo playerItemData = null; try { playerItemData = player.Gear.Items.First((_Item) => { return(_Item.Value.ItemID == itemID); }).Value; } catch (Exception) { playerItemData = null; } if (playerItemData != null) { //Data fanns i gearen som playern använder för tillfället! //itemLink = currentItemDatabase + "?item=" + playerItemData.ItemID + "' rel='rand=" + playerItemData.SuffixID + ";ench=" + playerItemData.EnchantID; } else { //Måste titta igenom history! #if NO_SQL PlayerHistory playerHistory = DatabaseAccess.FindRealmPlayerHistory(this, realm, playerDateAndName.Item2); if (playerHistory != null) { for (int i = playerHistory.GearHistory.Count - 1; i >= 0; --i) { try { playerItemData = playerHistory.GearHistory[i].Data.Items.First((_Item) => { return(_Item.Value.ItemID == itemID); }).Value; } catch (Exception) { playerItemData = null; } if (playerItemData != null) { //Data fanns i gearen som playern använder för tillfället! //itemLink = currentItemDatabase + "?item=" + playerItemData.ItemID + "' rel='rand=" + playerItemData.SuffixID + ";ench=" + playerItemData.EnchantID; break; } } } #else /*Disable this for now. it is too slow...*/ //playerItemData = comm.GetLatestItemInfoForPlayer(playerDateAndName.Item2, realm, itemID); #endif } if (playerItemData == null) { playerItemData = new VF_RealmPlayersDatabase.PlayerData.ItemInfo { Slot = VF_RealmPlayersDatabase.ItemSlot.Unknown, ItemID = itemID, SuffixID = 0, EnchantID = 0, UniqueID = 0, GemIDs = null }; } extraColumns[ItemAndAquiredDateAfterColumn] = new string[] { "<div class='inventory' style='background: none; width: 58px; height: 58px;'><div>" + "<img class='itempic' src='" + "http://realmplayers.com/" + itemInfo.GetIconImageAddress() + "'/>" + "<div class='quality' id='" + CharacterViewer.ItemQualityConversion[itemInfo.ItemQuality] + "'></div>" + "<img class='itemframe' src='assets/img/icons/ItemNormalFrame.png'/>" + CharacterViewer.GenerateItemLink(currentItemDatabase, playerItemData, wowVersion) + "</div></div>" , playerDateAndName.Item1.ToString("yyyy-MM-dd") }; tableBody += PageUtility.CreatePlayerRow(nr, realm, player, Table_Columns, null, extraColumns); } if (nr >= (pageIndex + 1) * count) { break; } } } if (nr != 0 && nr <= pageIndex * count) { pageIndex = (nr - 1) / count; Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString())); } m_TableBodyHTML = new MvcHtmlString(tableBody); int maxPageNr = 1000000 / count; m_PaginationHTML = new MvcHtmlString(PageUtility.CreatePagination(Request, pageNr, ((players.Count - 1) / count) + 1)); } } }
protected void Page_Load(object sender, EventArgs e) { string dataStr = PageUtility.GetQueryString(Request, "data"); string charStr = PageUtility.GetQueryString(Request, "char"); string itemsStr = PageUtility.GetQueryString(Request, "items"); WowRealm realm = PageUtility.GetQueryRealm(Request); if (realm == WowRealm.Unknown) { realm = WowRealm.All; } var wowVersion = PageUtility.GetQueryWowVersion(Request); if (PageUtility.GetQueryString(Request, "generateShortURL") != "null") { var fullURL = "http://realmplayers.com/CharacterDesigner.aspx?char=" + charStr + "&items=" + itemsStr; string shortURL = ""; if (g_CachedShortURLs.TryGetValue(fullURL, out shortURL) == false) { shortURL = VF.URLShortener.CreateShortURL(fullURL); if (shortURL == "") { Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "generateShortURL", "null")); } g_CachedShortURLs.TryAdd(fullURL, shortURL); g_CachedShortURLs.TryAdd(shortURL, fullURL); } //if (Request.Url.Host == "localhost") // Response.Redirect("localhost:4633/CharacterDesigner.aspx?char=" + charStr + "&items=" + itemsStr); //else Response.Redirect("CharacterDesigner.aspx?data=" + shortURL.Substring(shortURL.LastIndexOf("/") + 1)); } if (dataStr == "null" && itemsStr == "null") { return; } if (dataStr != "null" && itemsStr == "null") { try { string fullURL = ""; if (g_CachedShortURLs.TryGetValue("http://goo.gl/" + dataStr, out fullURL) == false) { fullURL = VF.URLShortener.GetFullURL("http://goo.gl/" + dataStr); if (fullURL == "") { return; } g_CachedShortURLs.TryAdd("http://goo.gl/" + dataStr, fullURL); } var url = new Uri(fullURL); var queryString = System.Web.HttpUtility.ParseQueryString(url.Query); itemsStr = queryString.Get("items"); if (itemsStr == null) { return; } var tempcharStr = queryString.Get("char"); if (tempcharStr != null) { charStr = tempcharStr; } } catch (Exception) { return; } } m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddFinish("Character Designer")); List <PlayerItemInfo> itemsList = new List <PlayerItemInfo>(); var itemsStrSplit = itemsStr.Split(',', '+', ' '); Func <PlayerItemInfo, PlayerItemInfo, bool> slotEqualFunc = (_Value1, _Value2) => _Value1.Slot == _Value2.Slot; foreach (string itemLink in itemsStrSplit) { try { itemsList.AddUnique(new PlayerItemInfo(itemLink, wowVersion), slotEqualFunc); } catch (Exception) { try { var splittedLink = itemLink.Split(':', 'x'); if (splittedLink.Length > 1) { PlayerItemInfo itemInfo = new PlayerItemInfo("1:0:0:0:0:0:0:0:0", wowVersion); if (Enum.TryParse(splittedLink[0], true, out itemInfo.Slot) == false) { itemInfo.Slot = (ItemSlot)int.Parse(splittedLink[0]); } itemInfo.ItemID = int.Parse(splittedLink[1]); if (splittedLink.Length > 2) { itemInfo.EnchantID = int.Parse(splittedLink[2]); } if (splittedLink.Length > 3) { itemInfo.SuffixID = int.Parse(splittedLink[3]); } if (splittedLink.Length > 4) { itemInfo.UniqueID = int.Parse(splittedLink[4]); } if (splittedLink.Length > 5 && wowVersion == WowVersionEnum.TBC) { itemInfo.GemIDs = new int[4]; itemInfo.GemIDs[0] = int.Parse(splittedLink[5]); itemInfo.GemIDs[1] = 0; itemInfo.GemIDs[2] = 0; itemInfo.GemIDs[3] = 0; if (splittedLink.Length > 6) { itemInfo.GemIDs[1] = int.Parse(splittedLink[6]); } if (splittedLink.Length > 7) { itemInfo.GemIDs[2] = int.Parse(splittedLink[7]); } if (splittedLink.Length > 8) { itemInfo.GemIDs[3] = int.Parse(splittedLink[8]); } } itemsList.AddUnique(itemInfo, slotEqualFunc); } } catch (Exception) {} } } PlayerRace playerRace = PlayerRace.Orc; PlayerClass playerClass = PlayerClass.Warrior; PlayerSex playerSex = PlayerSex.Male; if (charStr != "null") { try { var charStrSplit = charStr.Split(',', '+', ' '); if (charStrSplit.Length > 0) { if (Enum.TryParse(charStrSplit[0], true, out playerRace) == false) { playerRace = (PlayerRace)int.Parse(charStrSplit[0]); } } if (charStrSplit.Length > 1) { if (Enum.TryParse(charStrSplit[1], true, out playerClass) == false) { playerClass = (PlayerClass)int.Parse(charStrSplit[1]); } } if (charStrSplit.Length > 2) { if (Enum.TryParse(charStrSplit[2], true, out playerSex) == false) { playerSex = (PlayerSex)int.Parse(charStrSplit[2]); } } } catch (Exception) {} } if (playerRace == PlayerRace.Unknown) { playerRace = PlayerRace.Orc; } if (playerClass == PlayerClass.Unknown) { playerClass = PlayerClass.Warrior; } if (playerSex == PlayerSex.Unknown) { playerSex = PlayerSex.Male; } m_InventoryInfoHTML = new MvcHtmlString(CreateInventoryInfo(itemsList, playerRace, playerClass, playerSex, realm, wowVersion)); GenerateGearStats(itemsList, wowVersion); if (dataStr != "null") { m_CharacterDesignerInfo = new MvcHtmlString("Short link for this Character: <br /><a href='http://realmplayers.com/vchar/" + dataStr + ".aspx'>http://realmplayers.com/vchar/" + dataStr + ".aspx</a> or <a href='http://goo.gl/" + dataStr + "'>http://goo.gl/" + dataStr + "</a>"); } else { m_CharacterDesignerInfo = new MvcHtmlString("<a href='" + PageUtility.CreateUrlWithNewQueryValue(Request, "generateShortURL", "true") + "'>Click here to create a short link for this Character</a>"); } if (IsPostBack == false) { foreach (var item in itemsList) { int gemIDcount = item.GetGemIDCount(); string itemStr = item.ItemID.ToString(); if (item.EnchantID != 0 || item.SuffixID != 0 || item.UniqueID != 0 || gemIDcount != 0) { itemStr += "x" + item.EnchantID.ToString(); if (item.SuffixID != 0 || item.UniqueID != 0 || gemIDcount != 0) { itemStr += "x" + item.SuffixID.ToString(); } if (item.UniqueID != 0 || gemIDcount != 0) { itemStr += "x" + item.UniqueID.ToString(); } if (gemIDcount != 0) { for (int i = 0; i < gemIDcount; ++i) { itemStr += "x" + item.GemIDs[i].ToString(); } } } switch (item.Slot) { case ItemSlot.Head: txtHeadSlot.Text = itemStr; break; case ItemSlot.Neck: txtNeckSlot.Text = itemStr; break; case ItemSlot.Shoulder: txtShoulderSlot.Text = itemStr; break; case ItemSlot.Shirt: txtShirtSlot.Text = itemStr; break; case ItemSlot.Chest: txtChestSlot.Text = itemStr; break; case ItemSlot.Belt: txtBeltSlot.Text = itemStr; break; case ItemSlot.Legs: txtLegsSlot.Text = itemStr; break; case ItemSlot.Feet: txtFeetSlot.Text = itemStr; break; case ItemSlot.Wrist: txtWristSlot.Text = itemStr; break; case ItemSlot.Gloves: txtGlovesSlot.Text = itemStr; break; case ItemSlot.Finger_1: txtRing1Slot.Text = itemStr; break; case ItemSlot.Finger_2: txtRing2Slot.Text = itemStr; break; case ItemSlot.Trinket_1: txtTrinket1Slot.Text = itemStr; break; case ItemSlot.Trinket_2: txtTrinket2Slot.Text = itemStr; break; case ItemSlot.Back: txtBackSlot.Text = itemStr; break; case ItemSlot.Main_Hand: txtMainhandSlot.Text = itemStr; break; case ItemSlot.Off_Hand: txtOffhandSlot.Text = itemStr; break; case ItemSlot.Ranged: txtRangedSlot.Text = itemStr; break; case ItemSlot.Tabard: txtTabardSlot.Text = itemStr; break; default: break; } } ddlRace.SelectedValue = playerRace.ToString(); if (StaticValues.GetFaction(playerRace) == VF_RealmPlayersDatabase.PlayerFaction.Horde) { ddlRace.Style.Add("color", "#ff4546"); } else { ddlRace.Style.Add("color", "#45a3ff"); } ddlClass.SelectedValue = playerClass.ToString(); ddlClass.Style.Add("color", PageUtility.GetClassColor(playerClass)); ddlSex.SelectedValue = playerSex.ToString(); } }
public static Dictionary <DateTime, List <VF_RealmPlayersDatabase.PlayerData.ItemInfo> > GenerateLatestReceivedItems(PlayerHistory _PlayerHistory, VF_RealmPlayersDatabase.PlayerData.ExtraData _ExtraData, DateTime _EarliestDate) { Dictionary <DateTime, List <VF_RealmPlayersDatabase.PlayerData.ItemInfo> > recvItems = new Dictionary <DateTime, List <VF_RealmPlayersDatabase.PlayerData.ItemInfo> >(); List <int> itemIDs = new List <int>(); List <int> duplicateItemIDs = new List <int>(); foreach (var gearHistoryItem in _PlayerHistory.GearHistory) { DateTime historyDate = gearHistoryItem.Uploader.GetTime().Date; int oneRingID = -1; int oneTrinketID = -1; int oneWeaponID = -1; foreach (var item in gearHistoryItem.Data.Items) { int currItemID = item.Value.ItemID; if (itemIDs.Contains(currItemID) == false) { itemIDs.Add(currItemID); if (historyDate > _EarliestDate) { recvItems.AddToList(historyDate, item.Value); } } else { if (currItemID == oneRingID || currItemID == oneTrinketID || currItemID == oneWeaponID) { if (duplicateItemIDs.Contains(currItemID) == false) { duplicateItemIDs.Add(currItemID); if (historyDate > _EarliestDate) { recvItems.AddToList(historyDate, item.Value); } } } } if (item.Key == VF_RealmPlayersDatabase.ItemSlot.Finger_1 || item.Key == VF_RealmPlayersDatabase.ItemSlot.Finger_2) { oneRingID = currItemID; } else if (item.Key == VF_RealmPlayersDatabase.ItemSlot.Trinket_1 || item.Key == VF_RealmPlayersDatabase.ItemSlot.Trinket_2) { oneTrinketID = currItemID; } else if (item.Key == VF_RealmPlayersDatabase.ItemSlot.Main_Hand || item.Key == VF_RealmPlayersDatabase.ItemSlot.Off_Hand) { oneWeaponID = currItemID; } } } if (_ExtraData != null) { try { foreach (var mount in _ExtraData.Mounts) { var mountRecvDateTime = mount.GetEarliestUpload().GetTime(); var mountItem = new VF_RealmPlayersDatabase.PlayerData.ItemInfo { ItemID = VF.ItemTranslations.FindItemID(mount.Mount), SuffixID = 0, EnchantID = 0, UniqueID = 0, GemIDs = null, Slot = VF_RealmPlayersDatabase.ItemSlot.Unknown }; recvItems.AddToList(mountRecvDateTime, mountItem); } } catch (Exception ex) { Logger.LogException(ex); } } return(recvItems); }
public ItemSummary(ItemInfo _Item) { m_ItemID = _Item.ItemID; m_SuffixID = _Item.SuffixID; }
private ItemSummary GetItemSummary(ItemInfo _Item) { return(GetItemSummary(_Item.ItemID, _Item.SuffixID)); }
public int GetItemUsageCount(WowRealm _Realm, ItemInfo _Item) { return(GetItemUsageCount(_Realm, _Item.ItemID, _Item.SuffixID)); }