mirror of
https://github.com/Queercon/QC14-Badge-Webview.git
synced 2025-08-20 13:23:36 -07:00
showing update times and curr icon
This commit is contained in:
parent
2c8477e0a4
commit
bee565db20
3 changed files with 130 additions and 5 deletions
|
@ -59,15 +59,17 @@ namespace qcbadge.Controllers
|
|||
if ((String.Compare(Startup.scode, s, true) == 0))
|
||||
{
|
||||
ViewData["Message"] = "";
|
||||
ViewData["0"] = 0;
|
||||
ViewData["1"] = 0;
|
||||
ViewData["38"] = 0;
|
||||
ViewData["lastseen"] = "";
|
||||
ViewData["indv"] = 0;
|
||||
ViewData["curr"] = 99;
|
||||
|
||||
bool[] imglist = new bool[48];
|
||||
|
||||
|
||||
if (String.IsNullOrEmpty(id))
|
||||
{
|
||||
imglist = sql.selectGlobalView();
|
||||
ViewData["lastseen"] = sql.selectGlobalLastSeen();
|
||||
|
||||
for (int i = 0; i < 48; i++)
|
||||
{
|
||||
|
@ -76,9 +78,17 @@ namespace qcbadge.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
ViewData["indv"] = 1;
|
||||
int badgeid = Convert.ToInt32(id);
|
||||
badgeid = badgeid + 1;
|
||||
imglist = sql.selectIndervidualView(badgeid);
|
||||
string[] listdata = sql.selectIndervidualLastSeen(badgeid);
|
||||
ViewData["lastseen"] = listdata[0];
|
||||
|
||||
if(!String.IsNullOrEmpty(listdata[1]))
|
||||
{
|
||||
ViewData["curr"] = Convert.ToInt32(listdata[1]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 48; i++)
|
||||
{
|
||||
|
|
|
@ -73,6 +73,105 @@ namespace qcbadge.Helpers
|
|||
return rtn;
|
||||
}
|
||||
|
||||
public string selectGlobalLastSeen()
|
||||
{
|
||||
//System.Diagnostics.Debug.WriteLine("Got to selectGlobalView");
|
||||
string rtn = "";
|
||||
|
||||
|
||||
//System.Diagnostics.Debug.WriteLine("Into loop " + i);
|
||||
|
||||
try
|
||||
{
|
||||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
|
||||
builder.DataSource = DataSource;
|
||||
builder.UserID = UserID;
|
||||
builder.Password = Password;
|
||||
builder.InitialCatalog = db;
|
||||
|
||||
using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("SELECT [lastseen] ");
|
||||
sb.Append("FROM " + table);
|
||||
sb.Append(" WHERE [lastseen] IN (SELECT max([lastseen]) FROM [qcbadge]);");
|
||||
String sql = sb.ToString();
|
||||
//System.Diagnostics.Debug.WriteLine(sql);
|
||||
|
||||
|
||||
using (SqlCommand command = new SqlCommand(sql, connection))
|
||||
{
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
rtn = reader[0].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SqlException e)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public string[] selectIndervidualLastSeen(int badgeid)
|
||||
{
|
||||
//System.Diagnostics.Debug.WriteLine("Got to selectGlobalView");
|
||||
string[] rtn = new string[2];
|
||||
|
||||
|
||||
//System.Diagnostics.Debug.WriteLine("Into loop " + i);
|
||||
|
||||
try
|
||||
{
|
||||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
|
||||
builder.DataSource = DataSource;
|
||||
builder.UserID = UserID;
|
||||
builder.Password = Password;
|
||||
builder.InitialCatalog = db;
|
||||
|
||||
using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
|
||||
{
|
||||
connection.Open();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("SELECT [lastseen], [curr] ");
|
||||
sb.Append("FROM " + table);
|
||||
sb.Append(" WHERE [badgeid] = '" + badgeid + "';");
|
||||
String sql = sb.ToString();
|
||||
//System.Diagnostics.Debug.WriteLine(sql);
|
||||
|
||||
|
||||
using (SqlCommand command = new SqlCommand(sql, connection))
|
||||
{
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
rtn[0] = reader[0].ToString();
|
||||
rtn[1] = reader[1].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SqlException e)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public bool[] selectIndervidualView(int badgeid)
|
||||
{
|
||||
bool[] rtn = new bool[48];
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
ViewData["Title"] = "Map View";
|
||||
|
||||
bool[] showimg = new bool[50];
|
||||
bool indv = Convert.ToBoolean(ViewData["indv"]);
|
||||
int curr = Convert.ToInt32(ViewData["curr"]);
|
||||
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
|
@ -114,7 +117,7 @@
|
|||
imgdesc[47] = "/images/48-eb4ce412-61c2-11e7-a915-d794e6b54cea.png";
|
||||
|
||||
|
||||
imgdesc[99] = "???????";
|
||||
imgdesc[99] = " ";
|
||||
|
||||
string[] img = new string[48];
|
||||
string[] desc = new string[48];
|
||||
|
@ -151,4 +154,17 @@
|
|||
|
||||
}
|
||||
</table>
|
||||
<div>@ViewData["Message"]</div>
|
||||
@if (indv)
|
||||
{
|
||||
|
||||
<tr>
|
||||
<td>Your Current Icon</td>
|
||||
<td><img class="icon" src="@img[curr]" /></td>
|
||||
</tr>
|
||||
|
||||
}
|
||||
<div>Last Updated: @ViewData["lastseen"]</div>
|
||||
<div>@ViewData["Message"]</div>
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue