Lotsa fixes, some Localisation

This commit is contained in:
Thomas Hounsell 2015-09-12 00:45:17 +01:00
parent b17e622280
commit 3d41bcba1d
16 changed files with 1262 additions and 900 deletions

View File

@ -2,30 +2,38 @@
using System.Web.Mvc;
using BuildFeed.Areas.admin.Models.ViewModel;
using BuildFeed.Models;
using System.Threading.Tasks;
namespace BuildFeed.Areas.admin.Controllers
{
[Authorize(Roles = "Administrators")]
public class metaController : Controller
{
// GET: admin/meta
public ActionResult index()
private MetaItem mModel;
public metaController() : base()
{
var currentItems = from i in new MetaItem().Select()
mModel = new MetaItem();
}
// GET: admin/meta
public async Task<ActionResult> index()
{
var currentItems = from i in await mModel.Select()
group i by i.Id.Type
into b
select b;
var pendingLabs = new MetaItem().SelectUnusedLabs();
var pendingLabs = mModel.SelectUnusedLabs();
return View(new MetaListing
{
CurrentItems = from i in new MetaItem().Select()
CurrentItems = from i in await mModel.Select()
group i by i.Id.Type
into b
orderby b.Key.ToString()
select b,
NewItems = from i in (from l in new MetaItem().SelectUnusedLabs()
NewItems = from i in (from l in await mModel.SelectUnusedLabs()
select new MetaItemModel
{
Id = new MetaItemKey
@ -34,7 +42,7 @@ orderby b.Key.ToString()
Value = l
}
})
.Concat(from v in new MetaItem().SelectUnusedVersions()
.Concat(from v in await mModel.SelectUnusedVersions()
select new MetaItemModel
{
Id = new MetaItemKey
@ -43,7 +51,7 @@ orderby b.Key.ToString()
Value = v
}
})
.Concat(from y in new MetaItem().SelectUnusedYears()
.Concat(from y in await mModel.SelectUnusedYears()
select new MetaItemModel
{
Id = new MetaItemKey
@ -72,20 +80,20 @@ public ActionResult create(MetaType type, string value)
}
[HttpPost]
public ActionResult create(MetaItemModel meta)
public async Task<ActionResult> create(MetaItemModel meta)
{
if (ModelState.IsValid)
{
new MetaItem().Insert(meta);
await mModel.Insert(meta);
return RedirectToAction("index");
}
return View(meta);
}
public ActionResult edit(MetaType type, string value)
public async Task<ActionResult> edit(MetaType type, string value)
{
return View("create", new MetaItem().SelectById(new MetaItemKey
return View("create", await mModel.SelectById(new MetaItemKey
{
Type = type,
Value = value
@ -93,11 +101,11 @@ public ActionResult edit(MetaType type, string value)
}
[HttpPost]
public ActionResult edit(MetaItemModel meta)
public async Task<ActionResult> edit(MetaItemModel meta)
{
if (ModelState.IsValid)
{
new MetaItem().Update(meta);
await mModel.Update(meta);
return RedirectToAction("index");
}

View File

@ -253,6 +253,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Model.resx</DependentUpon>
</Compile>
<Compile Include="Local\Support.qps-ploc.Designer.cs">
<DependentUpon>Support.qps-ploc.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Local\Support.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -437,6 +442,10 @@
<LastGenOutput>Model.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Local\Support.qps-ploc.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Support.qps-ploc.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Local\Support.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Support.Designer.cs</LastGenOutput>

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Security;
@ -18,22 +19,22 @@ public apiController() : base()
bModel = new Build();
}
public IEnumerable<BuildModel> GetBuilds()
public async Task<IEnumerable<BuildModel>> GetBuilds()
{
return bModel.SelectInBuildOrder();
return await bModel.SelectInBuildOrder();
}
public IEnumerable<string> GetWin10Labs()
public async Task<IEnumerable<string>> GetWin10Labs()
{
List<string> labs = new List<string>();
labs.AddRange(bModel.SelectBuildLabs(6, 4));
labs.AddRange(bModel.SelectBuildLabs(10, 0));
labs.AddRange(await bModel.SelectBuildLabs(6, 4));
labs.AddRange(await bModel.SelectBuildLabs(10, 0));
return labs.GroupBy(l => l).Select(l => l.Key).Where(l => l.All(c => c != '(')).ToArray();
}
[HttpPost]
public bool AddWin10Builds(NewBuild apiModel)
public async Task<bool> AddWin10Builds(NewBuild apiModel)
{
if (apiModel == null)
{
@ -41,7 +42,7 @@ public bool AddWin10Builds(NewBuild apiModel)
}
if (Membership.ValidateUser(apiModel.Username, apiModel.Password))
{
bModel.InsertAll(apiModel.NewBuilds.Select(nb => new BuildModel()
await bModel.InsertAll(apiModel.NewBuilds.Select(nb => new BuildModel()
{
MajorVersion = nb.MajorVersion,
MinorVersion = nb.MinorVersion,
@ -59,7 +60,7 @@ public bool AddWin10Builds(NewBuild apiModel)
}
}
public IEnumerable<SearchResult> GetSearchResult(string query)
public async Task<IEnumerable<SearchResult>> GetSearchResult(string query)
{
if (string.IsNullOrWhiteSpace(query))
{
@ -82,7 +83,7 @@ orderby s.Text.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) asce
results.AddRange(sourceResults);
var versionResults = from v in bModel.SelectBuildVersions()
var versionResults = from v in await bModel.SelectBuildVersions()
where $"{v.Major}.{v.Minor}".StartsWith(query)
orderby v.Major descending, v.Minor descending
select new SearchResult()
@ -96,7 +97,7 @@ orderby s.Text.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) asce
results.AddRange(versionResults);
var yearResults = from y in bModel.SelectBuildYears()
var yearResults = from y in await bModel.SelectBuildYears()
where y.ToString().Contains(query)
orderby y descending
select new SearchResult()
@ -110,7 +111,7 @@ orderby y descending
results.AddRange(yearResults);
var labResults = from l in bModel.SearchBuildLabs(query)
var labResults = from l in await bModel.SearchBuildLabs(query)
orderby l.IndexOf(query.ToLower()) ascending,
l.Length ascending
select new SearchResult()
@ -124,7 +125,7 @@ l.Length ascending
results.AddRange(labResults);
var buildResults = from b in bModel.Select()
var buildResults = from b in await bModel.Select()
where b.FullBuildString.ToLower().Contains(query.ToLower())
orderby b.FullBuildString.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending,
b.BuildTime descending

View File

@ -5,6 +5,7 @@
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace BuildFeed.Controllers
@ -24,19 +25,19 @@ public frontController() : base()
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult index() { return indexPage(1); }
public async Task<ActionResult> index() { return await indexPage(1); }
[Route("page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public ActionResult indexPage(int page)
public async Task<ActionResult> indexPage(int page)
{
var buildGroups = bModel.SelectBuildGroups(PAGE_SIZE, (page - 1) * PAGE_SIZE);
var buildGroups = await bModel.SelectBuildGroups(PAGE_SIZE, (page - 1) * PAGE_SIZE);
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(
Convert.ToDouble(bModel.SelectBuildGroupsCount()) /
Convert.ToDouble(await bModel.SelectBuildGroupsCount()) /
Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
@ -51,9 +52,9 @@ public ActionResult indexPage(int page)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewGroup(byte major, byte minor, ushort number, ushort? revision = null)
public async Task<ActionResult> viewGroup(byte major, byte minor, ushort number, ushort? revision = null)
{
var builds = bModel.SelectSingleBuildGroup(new BuildGroup()
var builds = await bModel.SelectSingleBuildGroup(new BuildGroup()
{
Major = major,
Minor = minor,
@ -70,9 +71,9 @@ public ActionResult viewGroup(byte major, byte minor, ushort number, ushort? rev
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewBuild(Guid id)
public async Task<ActionResult> viewBuild(Guid id)
{
BuildModel b = bModel.SelectById(id);
BuildModel b = await bModel.SelectById(id);
return View(b);
}
@ -81,9 +82,9 @@ public ActionResult viewBuild(Guid id)
[OutputCache(Duration = 600, VaryByParam = "none")]
[CustomContentType(ContentType = "image/png", Order = 2)]
#endif
public ActionResult twitterCard(Guid id)
public async Task<ActionResult> twitterCard(Guid id)
{
BuildModel b = bModel.SelectById(id);
BuildModel b = await bModel.SelectById(id);
using (Bitmap bm = new Bitmap(560, 300))
{
@ -116,13 +117,13 @@ public ActionResult twitterCard(Guid id)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewLab(string lab) { return viewLabPage(lab, 1); }
public async Task<ActionResult> viewLab(string lab) { return await viewLabPage(lab, 1); }
[Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public ActionResult viewLabPage(string lab, int page)
public async Task<ActionResult> viewLabPage(string lab, int page)
{
ViewBag.MetaItem = new MetaItem().SelectById(new MetaItemKey
{
@ -131,10 +132,10 @@ public ActionResult viewLabPage(string lab, int page)
});
ViewBag.ItemId = lab;
var builds = bModel.SelectLab(lab, (page - 1) * PAGE_SIZE, PAGE_SIZE);
var builds = await bModel.SelectLab(lab, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(bModel.SelectLabCount(lab)) / Convert.ToDouble(PAGE_SIZE));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await bModel.SelectLabCount(lab)) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@ -148,13 +149,13 @@ public ActionResult viewLabPage(string lab, int page)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewSource(TypeOfSource source) { return viewSourcePage(source, 1); }
public async Task<ActionResult> viewSource(TypeOfSource source) { return await viewSourcePage(source, 1); }
[Route("source/{source}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public ActionResult viewSourcePage(TypeOfSource source, int page)
public async Task<ActionResult> viewSourcePage(TypeOfSource source, int page)
{
ViewBag.MetaItem = new MetaItem().SelectById(new MetaItemKey
{
@ -163,10 +164,10 @@ public ActionResult viewSourcePage(TypeOfSource source, int page)
});
ViewBag.ItemId = DisplayHelpers.GetDisplayTextForEnum(source);
var builds = bModel.SelectSource(source, (page - 1) * PAGE_SIZE, PAGE_SIZE);
var builds = await bModel.SelectSource(source, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(bModel.SelectSourceCount(source)) / Convert.ToDouble(PAGE_SIZE));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await bModel.SelectSourceCount(source)) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@ -180,13 +181,13 @@ public ActionResult viewSourcePage(TypeOfSource source, int page)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewYear(int year) { return viewYearPage(year, 1); }
public async Task<ActionResult> viewYear(int year) { return await viewYearPage(year, 1); }
[Route("year/{year}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "page", VaryByCustom = "userName")]
#endif
public ActionResult viewYearPage(int year, int page)
public async Task<ActionResult> viewYearPage(int year, int page)
{
ViewBag.MetaItem = new MetaItem().SelectById(new MetaItemKey
{
@ -195,10 +196,10 @@ public ActionResult viewYearPage(int year, int page)
});
ViewBag.ItemId = year.ToString();
var builds = bModel.SelectYear(year, (page - 1) * PAGE_SIZE, PAGE_SIZE);
var builds = await bModel.SelectYear(year, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(bModel.SelectYearCount(year) / Convert.ToDouble(PAGE_SIZE));
ViewBag.PageCount = Math.Ceiling(await bModel.SelectYearCount(year) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@ -212,13 +213,13 @@ public ActionResult viewYearPage(int year, int page)
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewVersion(int major, int minor) { return viewVersionPage(major, minor, 1); }
public async Task<ActionResult> viewVersion(int major, int minor) { return await viewVersionPage(major, minor, 1); }
[Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)]
#if !DEBUG
[OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult viewVersionPage(int major, int minor, int page)
public async Task<ActionResult> viewVersionPage(int major, int minor, int page)
{
string valueString = $"{major}.{minor}";
ViewBag.MetaItem = new MetaItem().SelectById(new MetaItemKey
@ -228,10 +229,10 @@ public ActionResult viewVersionPage(int major, int minor, int page)
});
ViewBag.ItemId = valueString;
var builds = bModel.SelectVersion(major, minor, (page - 1) * PAGE_SIZE, PAGE_SIZE);
var builds = await bModel.SelectVersion(major, minor, (page - 1) * PAGE_SIZE, PAGE_SIZE);
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(bModel.SelectVersionCount(major, minor)) / Convert.ToDouble(PAGE_SIZE));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(await bModel.SelectVersionCount(major, minor)) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
@ -245,7 +246,7 @@ public ActionResult viewVersionPage(int major, int minor, int page)
public ActionResult addBuild() { return View("editBuild"); }
[Route("add/"), Authorize, HttpPost]
public ActionResult addBuild(BuildModel build)
public async Task<ActionResult> addBuild(BuildModel build)
{
if (ModelState.IsValid)
{
@ -253,7 +254,7 @@ public ActionResult addBuild(BuildModel build)
{
build.Added = DateTime.Now;
build.Modified = DateTime.Now;
new Build().Insert(build);
await bModel.Insert(build);
}
catch
{
@ -268,20 +269,20 @@ public ActionResult addBuild(BuildModel build)
}
[Route("edit/{id}/"), Authorize]
public ActionResult editBuild(Guid id)
public async Task<ActionResult> editBuild(Guid id)
{
BuildModel b = new Build().SelectById(id);
BuildModel b = await bModel.SelectById(id);
return View(b);
}
[Route("edit/{id}/"), Authorize, HttpPost]
public ActionResult editBuild(long id, BuildModel build)
public async Task<ActionResult> editBuild(long id, BuildModel build)
{
if (ModelState.IsValid)
{
try
{
new Build().Update(build);
await bModel.Update(build);
}
catch
{
@ -294,9 +295,9 @@ public ActionResult editBuild(long id, BuildModel build)
}
[Route("delete/{id}/"), Authorize(Roles = "Administrators")]
public ActionResult deleteBuild(Guid id)
public async Task<ActionResult> deleteBuild(Guid id)
{
new Build().DeleteById(id);
await bModel.DeleteById(id);
return RedirectToAction("index");
}
}

View File

@ -12,10 +12,18 @@ namespace BuildFeed.Controllers
{
public class rssController : Controller
{
private Build bModel;
private const int RSS_SIZE = 20;
public rssController() : base()
{
bModel = new Build();
}
[Route("rss/compiled")]
public async Task<ActionResult> index()
{
var builds = new Build().SelectInBuildOrder().Take(20);
var builds = await bModel.SelectInBuildOrder(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
@ -48,7 +56,7 @@ public async Task<ActionResult> index()
[Route("rss/added")]
public async Task<ActionResult> added()
{
var builds = new Build().Select().OrderByDescending(b => b.Added).Take(20);
var builds = await bModel.SelectLatest(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
@ -66,7 +74,10 @@ public async Task<ActionResult> added()
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
Guid = new RssGuid() { IsPermaLink = true, Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
},
InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
}).ToList()
@ -83,7 +94,7 @@ public async Task<ActionResult> added()
[Route("rss/leaked")]
public async Task<ActionResult> leaked()
{
var builds = new Build().Select().Where(b => b.LeakDate.HasValue).OrderByDescending(b => b.LeakDate.Value).Take(20);
var builds = await bModel.SelectLatestLeaked(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
{
@ -101,7 +112,10 @@ public async Task<ActionResult> leaked()
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
Guid = new RssGuid() { IsPermaLink = true, Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
},
InternalPubDate = new RssDate(build.LeakDate.Value).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
}).ToList()
@ -118,8 +132,7 @@ public async Task<ActionResult> leaked()
[Route("rss/version")]
public async Task<ActionResult> version()
{
var builds = new Build().SelectInVersionOrder()
.Take(20);
var builds = await bModel.SelectInVersionOrder(RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
@ -138,7 +151,10 @@ public async Task<ActionResult> version()
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
Guid = new RssGuid() { IsPermaLink = true, Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
},
}).ToList()
}
@ -154,9 +170,7 @@ public async Task<ActionResult> version()
[Route("rss/flight/{id}")]
public async Task<ActionResult> flight(LevelOfFlight id)
{
var builds = new Build().SelectInBuildOrder()
.Where(b => b.FlightLevel == id)
.Take(20);
var builds = await bModel.SelectFlight(id, RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
@ -175,7 +189,10 @@ public async Task<ActionResult> flight(LevelOfFlight id)
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
Guid = new RssGuid() { IsPermaLink = true, Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
},
}).ToList()
}
@ -191,9 +208,7 @@ public async Task<ActionResult> flight(LevelOfFlight id)
[Route("rss/lab/{lab}")]
public async Task<ActionResult> lab(string lab)
{
var builds = new Build().SelectInBuildOrder()
.Where(b => b.Lab == lab)
.Take(20);
var builds = await bModel.SelectLab(lab, RSS_SIZE, 0);
RssDocument rdoc = new RssDocument()
@ -212,7 +227,10 @@ public async Task<ActionResult> lab(string lab)
{
Title = build.FullBuildString,
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
Guid = new RssGuid() { IsPermaLink = true, Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
Guid = new RssGuid()
{
IsPermaLink = true,
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
},
}).ToList()
}

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
@ -13,6 +14,13 @@ namespace BuildFeed.Controllers
{
public class supportController : Controller
{
private Build bModel;
public supportController() : base()
{
bModel = new Build();
}
[Route("login/")]
public ActionResult login()
{
@ -128,7 +136,7 @@ public ActionResult thanks_register()
[Route("rss")]
public ActionResult rss()
{
ViewBag.Labs = new Build().SelectBuildLabs();
ViewBag.Labs = bModel.SelectBuildLabs();
return View();
}
@ -136,9 +144,9 @@ public ActionResult rss()
#if !DEBUG
[OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult sitemap()
public async Task<ActionResult> sitemap()
{
var builds = new Build().SelectInVersionOrder();
var builds = await bModel.SelectInVersionOrder();
Dictionary<string, SitemapPagedAction[]> actions = new Dictionary<string, SitemapPagedAction[]>
{
{
@ -245,7 +253,7 @@ orderby bv.Key
SitemapData model = new SitemapData()
{
Builds = (from b in new Build().Select()
Builds = (from b in await bModel.Select()
group b by new BuildGroup()
{
Major = b.MajorVersion,
@ -281,7 +289,7 @@ group b by b.Lab into lab
#if !DEBUG
[OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult xmlsitemap()
public async Task<ActionResult> xmlsitemap()
{
XNamespace xn = XNamespace.Get("http://www.sitemaps.org/schemas/sitemap/0.9");
List<XElement> xlist = new List<XElement>();
@ -292,7 +300,7 @@ public ActionResult xmlsitemap()
home.Add(new XElement(xn + "changefreq", "daily"));
xlist.Add(home);
foreach (var b in new Build().Select())
foreach (var b in await bModel.Select())
{
XElement url = new XElement(xn + "url");
url.Add(new XElement(xn + "loc", Request.Url.GetLeftPart(UriPartial.Authority) + Url.Action("viewBuild", "front", new { id = b.Id })));
@ -319,9 +327,9 @@ public ActionResult xmlsitemap()
#if !DEBUG
[OutputCache(Duration = 3600, VaryByParam = "none", VaryByCustom = "userName")]
#endif
public ActionResult stats()
public async Task<ActionResult> stats()
{
var builds = new Build().Select().ToArray();
var builds = await bModel.Select();
List<MonthCount> additions = new List<MonthCount>();
var rawAdditions = (from b in builds

View File

@ -69,6 +69,24 @@ public static string AccountValidation {
}
}
/// <summary>
/// Looks up a localized string similar to Additions to BuildFeed.
/// </summary>
public static string AdditionsToBuildFeed {
get {
return ResourceManager.GetString("AdditionsToBuildFeed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Builds Compiled.
/// </summary>
public static string BuildsCompiled {
get {
return ResourceManager.GetString("BuildsCompiled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Change your password.
/// </summary>
@ -141,6 +159,15 @@ public static string HighestVersion {
}
}
/// <summary>
/// Looks up a localized string similar to Labs.
/// </summary>
public static string Labs {
get {
return ResourceManager.GetString("Labs", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Log in.
/// </summary>
@ -204,6 +231,42 @@ public static string RememberMe {
}
}
/// <summary>
/// Looks up a localized string similar to Builds compiled each quarter.
/// </summary>
public static string StatsCompiled {
get {
return ResourceManager.GetString("StatsCompiled", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Recorded builds in each lab.
/// </summary>
public static string StatsLab {
get {
return ResourceManager.GetString("StatsLab", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Only labs with 100 or more recorded builds are included..
/// </summary>
public static string StatsLabIncluded {
get {
return ResourceManager.GetString("StatsLabIncluded", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to New additions to BuildFeed over the previous year.
/// </summary>
public static string StatsNewAdditions {
get {
return ResourceManager.GetString("StatsNewAdditions", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Thank you for registering.
/// </summary>
@ -221,5 +284,14 @@ public static string UserName {
return ResourceManager.GetString("UserName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Week.
/// </summary>
public static string Week {
get {
return ResourceManager.GetString("Week", resourceCulture);
}
}
}
}

View File

View File

@ -0,0 +1,198 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AccountValidation" xml:space="preserve">
<value>[!!! ÉƲèř¥ áççôúñƭ ïƨ Ʋáℓïδáƭèδ β¥ áñ Âδ₥ïñïƨƭřáƭôř, ƨô βè ƥáƭïèñƭ áñδ çλèçƙ áϱáïñ ℓáƭèř. ℓôřè₥ ïƥƨú₥ δôℓôř ƨïƭ á₥ !!!]</value>
</data>
<data name="AdditionsToBuildFeed" xml:space="preserve">
<value>[!!! Âδδïƭïôñƨ ƭô ßúïδFèèδ ℓôřè₥ !!!]</value>
</data>
<data name="BuildsCompiled" xml:space="preserve">
<value>[!!! ßúïℓδƨ Çô₥ƥïℓèδ ℓôř !!!]</value>
</data>
<data name="ChangePassword" xml:space="preserve">
<value>[!!! Çλáñϱè ¥ôúř ƥáƨƨωôřδ ℓôřè₥ !!!]</value>
</data>
<data name="ConfirmNewPassword" xml:space="preserve">
<value>[!!! Çôñƒïř₥ ñèω ƥáƨƨωôřδ ℓôřè₥ !!!]</value>
</data>
<data name="ConfirmPassword" xml:space="preserve">
<value>[!!! Çôñƒïř₥ ƥáƨƨωôřδ ℓôřè !!!]</value>
</data>
<data name="EmailAddress" xml:space="preserve">
<value>[!!! É₥áïℓ áδδřèƨƨ ℓôř !!!]</value>
</data>
<data name="EnterCurrentPassword" xml:space="preserve">
<value>[!!! Éñƭèř çúřřèñƭ ƥáƨƨωôřδ ℓôřè₥ !!!]</value>
</data>
<data name="EnterNewPassword" xml:space="preserve">
<value>[!!! Éñƭèř ñèω ƥáƨƨωôřδ ℓôřè !!!]</value>
</data>
<data name="EnterPassword" xml:space="preserve">
<value>[!!! Éñƭèř ƥáƨƨωôřδ ℓôř !!!]</value>
</data>
<data name="HighestVersion" xml:space="preserve">
<value>[!!! Hïϱλèƨƭ Ʋèřƨïôñ ℓôřè !!!]</value>
</data>
<data name="Labs" xml:space="preserve">
<value>[!!! £áβƨ !!!]</value>
</data>
<data name="Login" xml:space="preserve">
<value>[!!! £ôϱ ïñ !!!]</value>
</data>
<data name="Password" xml:space="preserve">
<value>[!!! Þáƨƨωôřδ !!!]</value>
</data>
<data name="RecentlyAdded" xml:space="preserve">
<value>[!!! Rèçèñƭ¥ áδδèδ ℓôř !!!]</value>
</data>
<data name="RecentlyCompiled" xml:space="preserve">
<value>[!!! Rèçèñƭ¥ çô₥ƥïℓèδ ℓôřè !!!]</value>
</data>
<data name="RecentlyLeaked" xml:space="preserve">
<value>[!!! Rèçèñƭ¥ ℓèáƙèδ ℓôřè !!!]</value>
</data>
<data name="Register" xml:space="preserve">
<value>[!!! Rèϱïƨƭèř !!!]</value>
</data>
<data name="RememberMe" xml:space="preserve">
<value>[!!! Rè₥è₥βèř ₥è ℓô !!!]</value>
</data>
<data name="StatsCompiled" xml:space="preserve">
<value>[!!! ßúïℓδƨ çô₥ƥïℓèδ èáçλ 9úářƭèř ℓôřè₥ ï !!!]</value>
</data>
<data name="StatsLab" xml:space="preserve">
<value>[!!! Rèçôřδèδ βúïℓδƨ ïñ èáçλ ℓáβ ℓôřè₥ ï !!!]</value>
</data>
<data name="StatsLabIncluded" xml:space="preserve">
<value>[!!! Óñℓ¥ ℓáβƨ ωïƭλ 100 ôř ₥ôřè řèçôřδèδ βúïℓδƨ ářè ïñçℓúδèδ. ℓôřè₥ ïƥƨú₥ δôℓô !!!]</value>
</data>
<data name="StatsNewAdditions" xml:space="preserve">
<value>[!!! Nèω áδδïƭïôñƨ ƭô ßúïδFèèδ ôƲèř ƭλè ƥřèƲïôúƨ ¥èář ℓôřè₥ ïƥƨú₥ δô !!!]</value>
</data>
<data name="ThanksRegister" xml:space="preserve">
<value>[!!! Tλáñƙ ¥ôú ƒôř řèϱïƨƭèřïñϱ ℓôřè₥ ï !!!]</value>
</data>
<data name="UserName" xml:space="preserve">
<value>[!!! Ûƨèřñá₥è !!!]</value>
</data>
<data name="Week" xml:space="preserve">
<value>[!!! Wèèƙ !!!]</value>
</data>
</root>

View File

@ -120,6 +120,12 @@
<data name="AccountValidation" xml:space="preserve">
<value>Every account is validated by an Administrator, so be patient and check again later.</value>
</data>
<data name="AdditionsToBuildFeed" xml:space="preserve">
<value>Additions to BuildFeed</value>
</data>
<data name="BuildsCompiled" xml:space="preserve">
<value>Builds Compiled</value>
</data>
<data name="ChangePassword" xml:space="preserve">
<value>Change your password</value>
</data>
@ -144,6 +150,9 @@
<data name="HighestVersion" xml:space="preserve">
<value>Highest version</value>
</data>
<data name="Labs" xml:space="preserve">
<value>Labs</value>
</data>
<data name="Login" xml:space="preserve">
<value>Log in</value>
</data>
@ -165,10 +174,25 @@
<data name="RememberMe" xml:space="preserve">
<value>Remember me</value>
</data>
<data name="StatsCompiled" xml:space="preserve">
<value>Builds compiled each quarter</value>
</data>
<data name="StatsLab" xml:space="preserve">
<value>Recorded builds in each lab</value>
</data>
<data name="StatsLabIncluded" xml:space="preserve">
<value>Only labs with 100 or more recorded builds are included.</value>
</data>
<data name="StatsNewAdditions" xml:space="preserve">
<value>New additions to BuildFeed over the previous year</value>
</data>
<data name="ThanksRegister" xml:space="preserve">
<value>Thank you for registering</value>
</data>
<data name="UserName" xml:space="preserve">
<value>Username</value>
</data>
<data name="Week" xml:space="preserve">
<value>Week</value>
</data>
</root>

View File

@ -10,6 +10,7 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
@ -134,17 +135,35 @@ public Build()
}
[DataObjectMethod(DataObjectMethodType.Select, true)]
public List<BuildModel> Select()
public async Task<List<BuildModel>> Select()
{
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
return task.Result;
return await _buildCollection.Find(new BsonDocument()).ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, true)]
public async Task<List<BuildModel>> SelectLatest(int limit, int skip)
{
return await _buildCollection.Find(new BsonDocument())
.SortByDescending(b => b.Added)
.Skip(skip)
.Limit(limit)
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, true)]
public async Task<List<BuildModel>> SelectLatestLeaked(int limit, int skip)
{
return await _buildCollection.Find(b => b.Added != null)
.SortByDescending(b => b.Added)
.Skip(skip)
.Limit(limit)
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<FrontBuildGroup> SelectBuildGroups(int limit, int skip)
public async Task<List<FrontBuildGroup>> SelectBuildGroups(int limit, int skip)
{
var pipeline = _buildCollection.Aggregate()
return await _buildCollection.Aggregate()
.Group(b => new BuildGroup()
{
Major = b.MajorVersion,
@ -163,16 +182,12 @@ public List<FrontBuildGroup> SelectBuildGroups(int limit, int skip)
.ThenByDescending(b => b.Key.Build)
.ThenByDescending(b => b.Key.Revision)
.Skip(skip)
.Limit(limit);
var task = pipeline.ToListAsync();
task.Wait();
return task.Result;
.Limit(limit)
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, true)]
public int SelectBuildGroupsCount()
public async Task<int> SelectBuildGroupsCount()
{
var pipeline = _buildCollection.Aggregate()
.Group(b => new BuildGroup()
@ -184,14 +199,11 @@ public int SelectBuildGroupsCount()
},
bg => new BsonDocument());
var task = pipeline.ToListAsync();
task.Wait();
return task.Result.Count();
return (await pipeline.ToListAsync()).Count;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public Tuple<BuildGroup, IEnumerable<BuildModel>> SelectSingleBuildGroup(BuildGroup bGroup)
public async Task<Tuple<BuildGroup, List<BuildModel>>> SelectSingleBuildGroup(BuildGroup bGroup)
{
var pipeline = _buildCollection.Aggregate()
.Match(b => b.MajorVersion == bGroup.Major)
@ -200,60 +212,78 @@ public Tuple<BuildGroup, IEnumerable<BuildModel>> SelectSingleBuildGroup(BuildGr
.Match(b => b.Revision == bGroup.Revision)
.SortByDescending(b => b.BuildTime);
var task = pipeline.ToListAsync();
task.Wait();
return new Tuple<BuildGroup, IEnumerable<BuildModel>>(bGroup, task.Result);
return new Tuple<BuildGroup, List<BuildModel>>(bGroup, await pipeline.ToListAsync());
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public BuildModel SelectById(Guid id)
public async Task<BuildModel> SelectById(Guid id)
{
var task = _buildCollection.Find(f => f.Id == id).SingleOrDefaultAsync();
task.Wait();
return task.Result;
return await _buildCollection.Find(f => f.Id == id).SingleOrDefaultAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public BuildModel SelectByLegacyId(long id)
public async Task<BuildModel> SelectByLegacyId(long id)
{
var task = _buildCollection.Find(f => f.LegacyId == id).SingleOrDefaultAsync();
task.Wait();
return task.Result;
return await _buildCollection.Find(f => f.LegacyId == id).SingleOrDefaultAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<BuildModel> SelectInBuildOrder()
public async Task<List<BuildModel>> SelectInBuildOrder()
{
var task = _buildCollection.Find(new BsonDocument())
return await _buildCollection.Find(new BsonDocument())
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
.ThenByDescending(b => b.Number)
.ThenByDescending(b => b.Revision)
.ToListAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<BuildModel> SelectInVersionOrder()
public async Task<List<BuildModel>> SelectInBuildOrder(int limit, int skip)
{
var task = _buildCollection.Find(new BsonDocument())
return await _buildCollection.Find(new BsonDocument())
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
.ThenByDescending(b => b.Number)
.ThenByDescending(b => b.Revision)
.Skip(skip)
.Limit(limit)
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task<List<BuildModel>> SelectInVersionOrder()
{
return await _buildCollection.Find(new BsonDocument())
.SortByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
.ThenByDescending(b => b.Number)
.ThenByDescending(b => b.Revision)
.ThenByDescending(b => b.BuildTime)
.ToListAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<BuildModel> SelectLab(string lab, int skip, int limit)
public async Task<List<BuildModel>> SelectInVersionOrder(int limit, int skip)
{
var task = _buildCollection.Find(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower()))
return await _buildCollection.Find(new BsonDocument())
.SortByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
.ThenByDescending(b => b.Number)
.ThenByDescending(b => b.Revision)
.ThenByDescending(b => b.BuildTime)
.Skip(skip)
.Limit(limit)
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task<List<BuildModel>> SelectFlight(LevelOfFlight flight, int limit, int skip)
{
return await _buildCollection.Find(b => b.FlightLevel == flight)
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
@ -262,23 +292,12 @@ public List<BuildModel> SelectLab(string lab, int skip, int limit)
.Skip(skip)
.Limit(limit)
.ToListAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public long SelectLabCount(string lab)
public async Task<List<BuildModel>> SelectLab(string lab, int skip, int limit)
{
var task = _buildCollection.Find(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower()))
.CountAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<BuildModel> SelectSource(TypeOfSource source, int skip, int limit)
{
var task = _buildCollection.Find(b => b.SourceType == source)
return await _buildCollection.Find(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower()))
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
@ -287,23 +306,19 @@ public List<BuildModel> SelectSource(TypeOfSource source, int skip, int limit)
.Skip(skip)
.Limit(limit)
.ToListAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public long SelectSourceCount(TypeOfSource source)
public async Task<long> SelectLabCount(string lab)
{
var task = _buildCollection.Find(b => b.SourceType == source)
return await _buildCollection.Find(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower()))
.CountAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<BuildModel> SelectYear(int year, int skip, int limit)
public async Task<List<BuildModel>> SelectSource(TypeOfSource source, int skip, int limit)
{
var task = _buildCollection.Find(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year)
return await _buildCollection.Find(b => b.SourceType == source)
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
@ -312,23 +327,21 @@ public List<BuildModel> SelectYear(int year, int skip, int limit)
.Skip(skip)
.Limit(limit)
.ToListAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public long SelectYearCount(int year)
public async Task<long> SelectSourceCount(TypeOfSource source)
{
var task = _buildCollection.Find(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year)
return await _buildCollection.Find(b => b.SourceType == source)
.CountAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<BuildModel> SelectVersion(int major, int minor, int skip, int limit)
public async Task<List<BuildModel>> SelectYear(int year, int skip, int limit)
{
var task = _buildCollection.Find(b => b.MajorVersion == major && b.MinorVersion == minor)
return await _buildCollection.Find(b => b.BuildTime != null &&
(b.BuildTime > new DateTime(year, 1, 1, 0, 0, 0)) &&
(b.BuildTime < new DateTime(year, 12, 31, 23, 59, 59)))
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
@ -337,23 +350,42 @@ public List<BuildModel> SelectVersion(int major, int minor, int skip, int limit)
.Skip(skip)
.Limit(limit)
.ToListAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public long SelectVersionCount(int major, int minor)
public async Task<long> SelectYearCount(int year)
{
var task = _buildCollection.Find(b => b.MajorVersion == major && b.MinorVersion == minor)
return await _buildCollection.Find(b => b.BuildTime != null &&
(b.BuildTime > new DateTime(year, 1, 1, 0, 0, 0)) &&
(b.BuildTime < new DateTime(year, 12, 31, 23, 59, 59)))
.CountAsync();
task.Wait();
return task.Result;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<BuildVersion> SelectBuildVersions()
public async Task<List<BuildModel>> SelectVersion(int major, int minor, int skip, int limit)
{
var task = _buildCollection.Aggregate()
return await _buildCollection.Find(b => b.MajorVersion == major && b.MinorVersion == minor)
.SortByDescending(b => b.BuildTime)
.ThenByDescending(b => b.MajorVersion)
.ThenByDescending(b => b.MinorVersion)
.ThenByDescending(b => b.Number)
.ThenByDescending(b => b.Revision)
.Skip(skip)
.Limit(limit)
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task<long> SelectVersionCount(int major, int minor)
{
return await _buildCollection.Find(b => b.MajorVersion == major && b.MinorVersion == minor)
.CountAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public async Task<List<BuildVersion>> SelectBuildVersions()
{
var result = await _buildCollection.Aggregate()
.Group(b => new BuildVersion()
{
Major = b.MajorVersion,
@ -365,16 +397,14 @@ public List<BuildVersion> SelectBuildVersions()
.ThenByDescending(b => b.Item1.Minor)
.ToListAsync();
task.Wait();
// work ourselves out of aforementioned bullshit hack
return task.Result.Select(b => b.Item1).ToList();
return result.Select(b => b.Item1).ToList();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public IEnumerable<int> SelectBuildYears()
public async Task<List<int>> SelectBuildYears()
{
var task = _buildCollection.Aggregate()
var result = await _buildCollection.Aggregate()
.Match(b => b.BuildTime != null)
.Group(b => ((DateTime)b.BuildTime).Year,
// incoming bullshit hack
@ -382,16 +412,14 @@ public IEnumerable<int> SelectBuildYears()
.SortByDescending(b => b.Item1)
.ToListAsync();
task.Wait();
// work ourselves out of aforementioned bullshit hack
return task.Result.Select(b => b.Item1).ToList();
return result.Select(b => b.Item1).ToList();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public List<string> SearchBuildLabs(string query)
public async Task<List<string>> SearchBuildLabs(string query)
{
var task = _buildCollection.Aggregate()
var result = await _buildCollection.Aggregate()
.Match(b => b.Lab != null)
.Match(b => b.Lab != "")
.Match(b => b.Lab.ToLower().Contains(query.ToLower()))
@ -400,16 +428,14 @@ public List<string> SearchBuildLabs(string query)
bg => new Tuple<string>(bg.Key))
.ToListAsync();
task.Wait();
// work ourselves out of aforementioned bullshit hack
return task.Result.Select(b => b.Item1).ToList();
return result.Select(b => b.Item1).ToList();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public IEnumerable<string> SelectBuildLabs()
public async Task<List<string>> SelectBuildLabs()
{
var task = _buildCollection.Aggregate()
var result = await _buildCollection.Aggregate()
.Match(b => b.Lab != null)
.Match(b => b.Lab != "")
.Group(b => b.Lab.ToLower(),
@ -418,16 +444,14 @@ public IEnumerable<string> SelectBuildLabs()
.SortBy(b => b.Item1)
.ToListAsync();
task.Wait();
// work ourselves out of aforementioned bullshit hack
return task.Result.Select(b => b.Item1).ToList();
return result.Select(b => b.Item1).ToList();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public IEnumerable<string> SelectBuildLabs(byte major, byte minor)
public async Task<List<string>> SelectBuildLabs(byte major, byte minor)
{
var task = _buildCollection.Aggregate()
var result = await _buildCollection.Aggregate()
.Match(b => b.MajorVersion == major)
.Match(b => b.MinorVersion == minor)
.Match(b => b.Lab != null)
@ -438,43 +462,37 @@ public IEnumerable<string> SelectBuildLabs(byte major, byte minor)
.SortBy(b => b.Item1)
.ToListAsync();
task.Wait();
// work ourselves out of aforementioned bullshit hack
return task.Result.Select(b => b.Item1).ToList();
return result.Select(b => b.Item1).ToList();
}
[DataObjectMethod(DataObjectMethodType.Insert, true)]
public void Insert(BuildModel item)
public async Task Insert(BuildModel item)
{
item.Id = Guid.NewGuid();
var task = _buildCollection.InsertOneAsync(item);
task.Wait();
await _buildCollection.InsertOneAsync(item);
}
[DataObjectMethod(DataObjectMethodType.Insert, false)]
public void InsertAll(IEnumerable<BuildModel> items)
public async Task InsertAll(IEnumerable<BuildModel> items)
{
var task = _buildCollection.InsertManyAsync(items);
task.Wait();
await _buildCollection.InsertManyAsync(items);
}
[DataObjectMethod(DataObjectMethodType.Update, true)]
public void Update(BuildModel item)
public async Task Update(BuildModel item)
{
BuildModel old = SelectById(item.Id);
BuildModel old = await SelectById(item.Id);
item.Added = old.Added;
item.Modified = DateTime.Now;
var task = _buildCollection.ReplaceOneAsync(f => f.Id == item.Id, item);
task.Wait();
await _buildCollection.ReplaceOneAsync(f => f.Id == item.Id, item);
}
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public void DeleteById(Guid id)
public async Task DeleteById(Guid id)
{
var task = _buildCollection.DeleteOneAsync(f => f.Id == id);
task.Wait();
await _buildCollection.DeleteOneAsync(f => f.Id == id);
}
}

View File

@ -6,6 +6,7 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using System.Web.Mvc;
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
@ -33,6 +34,7 @@ public class MetaItem
private MongoClient _dbClient;
private IMongoCollection<MetaItemModel> _metaCollection;
private Build bModel;
public MetaItem()
{
@ -42,105 +44,108 @@ public MetaItem()
});
_metaCollection = _dbClient.GetDatabase(MongoConfig.Database).GetCollection<MetaItemModel>(_metaCollectionName);
bModel = new Build();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public IEnumerable<MetaItemModel> Select()
public async Task<IEnumerable<MetaItemModel>> Select()
{
var task = _metaCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
return task.Result;
return await _metaCollection
.Find(new BsonDocument())
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, true)]
public IEnumerable<MetaItemModel> SelectByType(MetaType type)
public async Task<IEnumerable<MetaItemModel>> SelectByType(MetaType type)
{
var task = _metaCollection.Find(f => f.Id.Type == type).ToListAsync();
task.Wait();
return task.Result;
return await _metaCollection
.Find(f => f.Id.Type == type)
.ToListAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public MetaItemModel SelectById(MetaItemKey id)
public async Task<MetaItemModel> SelectById(MetaItemKey id)
{
var task = _metaCollection.Find(f => f.Id.Type == id.Type && f.Id.Value == id.Value).SingleOrDefaultAsync();
task.Wait();
return task.Result;
return await _metaCollection
.Find(f => f.Id.Type == id.Type && f.Id.Value == id.Value)
.SingleOrDefaultAsync();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public IEnumerable<string> SelectUnusedLabs()
public async Task<IEnumerable<string>> SelectUnusedLabs()
{
var labs = new Build().SelectBuildLabs();
var labs = await bModel.SelectBuildLabs();
var usedLabs = _metaCollection.Find(f => f.Id.Type == MetaType.Lab).ToListAsync();
usedLabs.Wait();
var usedLabs = await _metaCollection.Find(f => f.Id.Type == MetaType.Lab).ToListAsync();
return from l in labs
where usedLabs.Result.All(ul => ul.Id.Value != l)
where usedLabs.All(ul => ul.Id.Value != l)
select l;
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public IEnumerable<string> SelectUnusedVersions()
public async Task<IEnumerable<string>> SelectUnusedVersions()
{
var versions = new Build().SelectBuildVersions();
var versions = await bModel.SelectBuildVersions();
var usedVersions = _metaCollection.Find(f => f.Id.Type == MetaType.Version).ToListAsync();
usedVersions.Wait();
var usedVersions = await _metaCollection.Find(f => f.Id.Type == MetaType.Version).ToListAsync();
return from v in versions
where usedVersions.Result.All(ul => ul.Id.Value != v.ToString())
where usedVersions.All(ul => ul.Id.Value != v.ToString())
select v.ToString();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public IEnumerable<string> SelectUnusedYears()
public async Task<IEnumerable<string>> SelectUnusedYears()
{
var years = new Build().SelectBuildYears();
var years = await bModel.SelectBuildYears();
var usedYears = _metaCollection.Find(f => f.Id.Type == MetaType.Year).ToListAsync();
usedYears.Wait();
var usedYears = await _metaCollection.Find(f => f.Id.Type == MetaType.Year).ToListAsync();
return from y in years
where usedYears.Result.All(ul => ul.Id.Value != y.ToString())
where usedYears.All(ul => ul.Id.Value != y.ToString())
select y.ToString();
}
[DataObjectMethod(DataObjectMethodType.Insert, true)]
public void Insert(MetaItemModel item)
public async Task Insert(MetaItemModel item)
{
var task = _metaCollection.InsertOneAsync(item);
task.Wait();
await _metaCollection
.InsertOneAsync(item);
}
[DataObjectMethod(DataObjectMethodType.Update, true)]
public void Update(MetaItemModel item)
public async Task Update(MetaItemModel item)
{
var task = _metaCollection.ReplaceOneAsync(f => f.Id.Type == item.Id.Type && f.Id.Value == item.Id.Value, item);
task.Wait();
await _metaCollection
.ReplaceOneAsync(f => f.Id.Type == item.Id.Type && f.Id.Value == item.Id.Value, item);
}
[DataObjectMethod(DataObjectMethodType.Insert, false)]
public void InsertAll(IEnumerable<MetaItemModel> items)
public async Task InsertAll(IEnumerable<MetaItemModel> items)
{
var task = _metaCollection.InsertManyAsync(items);
task.Wait();
await _metaCollection
.InsertManyAsync(items);
}
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public void DeleteById(MetaItemKey id)
public async Task DeleteById(MetaItemKey id)
{
var task = _metaCollection.DeleteOneAsync(f => f.Id.Type == id.Type && f.Id.Value == id.Value);
task.Wait();
await _metaCollection
.DeleteOneAsync(f => f.Id.Type == id.Type && f.Id.Value == id.Value);
}
}
public struct MetaItemKey
public class MetaItemKey
{
public string Value { get; set; }
public MetaType Type { get; set; }
public MetaItemKey()
{
}
public MetaItemKey(string id)
{
var items = id.Split(':');

View File

@ -13,7 +13,7 @@
}
else
{
string metaDesc = string.Format(BuildFeed.Local.Front.YearMetaGeneric, ViewBag.ViewId);
string metaDesc = string.Format(BuildFeed.Local.Front.YearMetaGeneric, ViewBag.ItemId);
<meta name="description" content="@metaDesc" />
<meta property="og:description" content="@metaDesc" />
}

View File

@ -1,6 +1,6 @@
@model BuildFeed.Models.ViewModel.SitemapData
@{
ViewBag.Title = string.Format("{0} | {1}".BuildFeed.Local.Common.Sitemap, BuildFeed.Local.Common.SiteName);
ViewBag.Title = string.Format("{0} | {1}", BuildFeed.Local.Common.Sitemap, BuildFeed.Local.Common.SiteName);
}
<h2>@BuildFeed.Local.Common.Sitemap</h2>

View File

@ -6,14 +6,14 @@
<h2>@BuildFeed.Local.Common.Statistics</h2>
<h4>New additions to BuildFeed over the previous year</h4>
<h4>@BuildFeed.Local.Support.StatsNewAdditions</h4>
<canvas id="stats-addition" width="960" height="320"></canvas>
<h4>Builds compiled each quarter</h4>
<h4>@BuildFeed.Local.Support.StatsCompiled</h4>
<canvas id="stats-compiled" width="960" height="320"></canvas>
<h4>Recorded builds in each lab</h4>
<p>Only labs with 100 or more recorded builds are included.</p>
<h4>@BuildFeed.Local.Support.StatsLab</h4>
<p>@BuildFeed.Local.Support.StatsLabIncluded</p>
<canvas id="stats-labs" width="960" height="320"></canvas>
@section scripts
@ -29,10 +29,10 @@
Chart.defaults.Line.scaleShowGridLines = false;
var additionData = {
labels: [ @Html.Raw(string.Join(", ", Model.AdditionsByMonth.Select(m => m.Month % 4 != 1 ? "\"\"" : string.Format("\"Week {0}, {1}\"", m.Month, m.Year)).ToArray()))],
labels: [ @Html.Raw(string.Join(", ", Model.AdditionsByMonth.Select(m => m.Month % 4 != 1 ? "\"\"" : string.Format("\"{0} {1}, {2}\"", BuildFeed.Local.Support.Week, m.Month, m.Year)).ToArray()))],
datasets: [
{
label: "Additions to BuildFeed",
label: "@BuildFeed.Local.Support.AdditionsToBuildFeed",
fillColor: "#008cba",
strokeColor: "#00526e",
pointColor: "#00526e",
@ -46,10 +46,10 @@
var compiledData = {
labels: [ @Html.Raw(string.Join(", ", Model.CompilesByMonth.Select(m => string.Format("\"{0} {1}\"", System.Globalization.DateTimeFormatInfo.InvariantInfo.GetMonthName(m.Month), m.Year)).ToArray()))],
labels: [ @Html.Raw(string.Join(", ", Model.CompilesByMonth.Select(m => string.Format("\"{0} {1}\"", System.Globalization.DateTimeFormatInfo.CurrentInfo.GetMonthName(m.Month), m.Year)).ToArray()))],
datasets: [
{
label: "Builds compiled",
label: "@BuildFeed.Local.Support.BuildsCompiled",
fillColor: "#008cba",
strokeColor: "#00526e",
pointColor: "#00526e",
@ -65,7 +65,7 @@
labels: [ @Html.Raw(string.Join(", ", Model.BuildsByLab.Select(l => string.Format("\"{0}\"", l.Item1))))],
datasets: [
{
label: "Labs",
label: "@BuildFeed.Local.Support.Labs",
fillColor: "#008cba",
strokeColor: "#00526e",
pointColor: "#00526e",