Show number of battle videos in header

This commit is contained in:
Greg Edwards
2014-09-02 00:27:26 -04:00
parent 07bd2a7078
commit 1f8234cf37
4 changed files with 51 additions and 0 deletions

View File

@@ -31,6 +31,8 @@
<li>DNS: <strong>75.127.5.215</strong></li>
<li><asp:Literal ID="litPokemon" runat="server" />
Pokémon available for offer.</li>
<li><asp:Literal ID="litVideos" runat="server" />
battle videos.</li>
</ul>
</div>

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PkmnFoundations.Data;
namespace PkmnFoundations.GTS
{
@@ -11,9 +12,35 @@ namespace PkmnFoundations.GTS
{
protected void Page_Load(object sender, EventArgs e)
{
// todo: I should store the available pokemon count
// on the cache in the same way so the website doesn't
// have a dependency on running in the same application
// as the gamestats server.
GtsSessionManager manager = GtsSessionManager.FromContext(Context);
int availTotal = manager.AvailablePokemon4 + manager.AvailablePokemon5;
litPokemon.Text = availTotal.ToString();
ulong bvCount4, bvCount5;
if (Cache["BattleVideoCount4"] == null ||
Cache["BattleVideoCount5"] == null)
{
bvCount4 = DataAbstract.Instance.BattleVideoCount4();
bvCount5 = DataAbstract.Instance.BattleVideoCount5();
Cache.Insert("BattleVideoCount4", bvCount4, null,
DateTime.Now.AddMinutes(1),
System.Web.Caching.Cache.NoSlidingExpiration);
Cache.Insert("BattleVideoCount5", bvCount5, null,
DateTime.Now.AddMinutes(1),
System.Web.Caching.Cache.NoSlidingExpiration);
}
else
{
bvCount4 = Convert.ToUInt64(Cache["BattleVideoCount4"]);
bvCount5 = Convert.ToUInt64(Cache["BattleVideoCount5"]);
}
litVideos.Text = (bvCount4 + bvCount5).ToString();
}
public String HeaderCssClass

View File

@@ -118,6 +118,8 @@ namespace PkmnFoundations.Data
public abstract ulong BattleVideoUpload4(BattleVideoRecord4 record);
public abstract BattleVideoHeader4[] BattleVideoSearch4(ushort species, BattleVideoRankings4 ranking, BattleVideoMetagames4 metagame, byte country, byte region, int count);
public abstract BattleVideoRecord4 BattleVideoGet4(ulong serial, bool incrementViews = false);
public abstract ulong BattleVideoCount4();
#endregion
#region Global Terminal 5
@@ -130,6 +132,8 @@ namespace PkmnFoundations.Data
public abstract ulong BattleVideoUpload5(BattleVideoRecord5 record);
public abstract BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoRankings5 ranking, BattleVideoMetagames5 metagame, byte country, byte region, int count);
public abstract BattleVideoRecord5 BattleVideoGet5(ulong serial, bool incrementViews = false);
public abstract ulong BattleVideoCount5();
#endregion
}
}

View File

@@ -2113,6 +2113,15 @@ namespace PkmnFoundations.Data
return new BattleVideoRecord4(header.PID, header.SerialNumber, header, data);
}
public override ulong BattleVideoCount4()
{
using (MySqlConnection db = CreateConnection())
{
db.Open();
return Convert.ToUInt64(db.ExecuteScalar("SELECT Count(*) FROM TerminalBattleVideos4"));
}
}
#endregion
#region Global Terminal 5
@@ -2463,6 +2472,15 @@ namespace PkmnFoundations.Data
return new BattleVideoRecord5(header.PID, header.SerialNumber, header, data);
}
public override ulong BattleVideoCount5()
{
using (MySqlConnection db = CreateConnection())
{
db.Open();
return Convert.ToUInt64(db.ExecuteScalar("SELECT Count(*) FROM TerminalBattleVideos5"));
}
}
#endregion
}
}