Code Cleanup

This commit is contained in:
Thomas Hounsell 2015-07-05 23:19:01 +01:00
parent 80d5b79376
commit e34a41351c
18 changed files with 235 additions and 223 deletions

View File

@ -5,9 +5,9 @@
@helper PaginationBlock(int currentPage, int totalPages, string view, RouteValueDictionary rd)
{
string multiView = view + "Page";
if (totalPages > 1)
{
string multiView = view + "Page";
if (totalPages > 1)
{
<div class="text-center">
<ul class="pagination">
@if (currentPage == 2)
@ -53,5 +53,5 @@ if (totalPages > 1)
}
</ul>
</div>
}
}
}

View File

@ -35,23 +35,25 @@ orderby b.Key.ToString()
Type = MetaType.Lab,
Value = l
}
}).Concat(from v in MetaItem.SelectUnusedVersions()
select new MetaItem()
{
Id = new MetaItemKey()
{
Type = MetaType.Version,
Value = v
}
}).Concat(from y in MetaItem.SelectUnusedYears()
select new MetaItem()
{
Id = new MetaItemKey()
{
Type = MetaType.Year,
Value = y
}
})
}).Concat(
from v in MetaItem.SelectUnusedVersions()
select new MetaItem()
{
Id = new MetaItemKey()
{
Type = MetaType.Version,
Value = v
}
}).Concat(
from y in MetaItem.SelectUnusedYears()
select new MetaItem()
{
Id = new MetaItemKey()
{
Type = MetaType.Year,
Value = y
}
})
group i by i.Id.Type into b
orderby b.Key.ToString()
select b

View File

@ -1,8 +1,6 @@
using BuildFeed.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BuildFeed.Areas.admin.Models.ViewModel
{

View File

@ -51,8 +51,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
<Reference Include="Humanizer, Version=1.36.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
<HintPath>..\packages\Humanizer.1.36.0\lib\portable-win+net40+sl50+wp8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Humanizer.dll</HintPath>
<Reference Include="Humanizer, Version=1.37.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
<HintPath>..\packages\Humanizer.1.37.0\lib\portable-win+net40+sl50+wp8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Humanizer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ApplicationInsights, Version=1.0.0.4220, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
namespace BuildFeed.Code
{
@ -11,9 +7,6 @@ public class CustomContentTypeAttribute : ActionFilterAttribute
{
public string ContentType { get; set; }
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
filterContext.HttpContext.Response.ContentType = ContentType;
}
public override void OnResultExecuted(ResultExecutedContext filterContext) { filterContext.HttpContext.Response.ContentType = ContentType; }
}
}

View File

@ -11,7 +11,7 @@ public override object BindModel(ControllerContext controllerContext, ModelBindi
var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
DateTime retValue;
bool success = DateTime.TryParse(value.AttemptedValue, CultureInfo.CurrentUICulture.DateTimeFormat, DateTimeStyles.AllowWhiteSpaces, out retValue);
if(!success)
if (!success)
{
success = DateTime.TryParseExact(value.AttemptedValue, "yyMMdd-HHmm", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out retValue);
}

View File

@ -8,20 +8,10 @@ namespace BuildFeed.Code
{
public static class MvcIntrinsics
{
public static System.Web.Mvc.HtmlHelper Html
{
get { return ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page).Html; }
}
public static System.Web.Mvc.HtmlHelper Html => ((System.Web.Mvc.WebViewPage) WebPageContext.Current.Page).Html;
public static System.Web.Mvc.AjaxHelper Ajax
{
get { return ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page).Ajax; }
}
public static System.Web.Mvc.UrlHelper Url
{
get { return ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page).Url; }
}
public static System.Web.Mvc.AjaxHelper Ajax => ((System.Web.Mvc.WebViewPage) WebPageContext.Current.Page).Ajax;
public static System.Web.Mvc.UrlHelper Url => ((System.Web.Mvc.WebViewPage) WebPageContext.Current.Page).Url;
}
}

View File

@ -1,11 +1,9 @@
using System;
using BuildFeed.Models;
using BuildFeed.Models.ApiModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using BuildFeed.Models;
using BuildFeed.Models.ApiModel;
using System.Web.Security;
namespace BuildFeed.Controllers
@ -23,7 +21,7 @@ public IEnumerable<string> GetWin10Labs()
labs.AddRange(Build.SelectBuildLabs(6, 4));
labs.AddRange(Build.SelectBuildLabs(10, 0));
return labs.GroupBy(l => l).Select(l => l.Key).Where(l => !l.Any(c => c == '(')).ToArray();
return labs.GroupBy(l => l).Select(l => l.Key).Where(l => l.All(c => c != '(')).ToArray();
}
[HttpPost]
@ -62,9 +60,9 @@ public IEnumerable<SearchResult> GetSearchResult(string query)
List<SearchResult> results = new List<SearchResult>();
var sourceResults = from s in Enum.GetValues(typeof(BuildFeed.Models.TypeOfSource)).Cast<BuildFeed.Models.TypeOfSource>().Select(s => new { Text = DisplayHelpers.GetDisplayTextForEnum(s), Value = s })
var sourceResults = from s in Enum.GetValues(typeof(TypeOfSource)).Cast<TypeOfSource>().Select(s => new { Text = DisplayHelpers.GetDisplayTextForEnum(s), Value = s })
where s.Text.ToLower().Contains(query.ToLower())
orderby s.Text.ToLower().IndexOf(query.ToLower()) ascending
orderby s.Text.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending
select new SearchResult()
{
Url = Url.Route("Source Root", new { controller = "front", action = "viewSource", source = s.Value }),
@ -77,12 +75,12 @@ orderby s.Text.ToLower().IndexOf(query.ToLower()) ascending
var versionResults = from v in Build.SelectBuildVersions()
where string.Format("{0}.{1}", v.Major, v.Minor).StartsWith(query)
where $"{v.Major}.{v.Minor}".StartsWith(query)
orderby v.Major descending, v.Minor descending
select new SearchResult()
{
Url = Url.Route("Version Root", new { controller = "front", action = "viewVersion", major = v.Major, minor = v.Minor }),
Label = string.Format("{0}.{1}", v.Major, v.Minor).Replace(query, "<strong>" + query + "</strong>"),
Label = $"{v.Major}.{v.Minor}".Replace(query, "<strong>" + query + "</strong>"),
Title = "",
Group = "Version"
};
@ -106,7 +104,7 @@ orderby y descending
var labResults = from l in Build.SelectBuildLabs()
where l.ToLower().Contains(query.ToLower())
orderby l.ToLower().IndexOf(query.ToLower()) ascending
orderby l.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending
select new SearchResult()
{
Url = Url.Route("Lab Root", new { controller = "front", action = "viewLab", lab = l }),
@ -120,7 +118,7 @@ orderby l.ToLower().IndexOf(query.ToLower()) ascending
var buildResults = from b in Build.Select()
where b.FullBuildString.ToLower().Contains(query.ToLower())
orderby b.FullBuildString.ToLower().IndexOf(query.ToLower()) ascending,
orderby b.FullBuildString.ToLower().IndexOf(query.ToLower(), StringComparison.Ordinal) ascending,
b.BuildTime descending
select new SearchResult()
{

View File

@ -2,21 +2,18 @@
using BuildFeed.Models;
using BuildFeed.Models.ViewModel.Front;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
namespace BuildFeed.Controllers
{
public class frontController : Controller
{
public const int _pageSize = 96;
public const int PAGE_SIZE = 96;
[Route("", Order = 1)]
#if !DEBUG
@ -33,7 +30,7 @@ public ActionResult index()
#endif
public ActionResult indexPage(int page)
{
var buildGroups = from b in Build.Select()
var buildGroups = (from b in Build.Select()
group b by new BuildGroup()
{
Major = b.MajorVersion,
@ -50,17 +47,17 @@ bg.Key.Revision descending
Key = bg.Key,
LastBuild = bg.Max(m => m.BuildTime),
BuildCount = bg.Count()
};
}).ToArray();
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(buildGroups.Count()) / Convert.ToDouble(_pageSize));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(buildGroups.Length) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
return new HttpNotFoundResult();
}
return View("index", buildGroups.Skip((page - 1) * _pageSize).Take(_pageSize));
return View("index", buildGroups.Skip((page - 1) * PAGE_SIZE).Take(PAGE_SIZE));
}
[Route("group/{major}.{minor}.{number}.{revision}/")]
@ -120,9 +117,9 @@ public ActionResult twitterCard(long id)
gr.FillRectangle(new SolidBrush(Color.FromArgb(0x30, 0x30, 0x30)), 0, 0, 560, 300);
gp.AddString("BUILDFEED", new FontFamily("Segoe UI"), (int)FontStyle.Bold, 16, new Point(20, 20), StringFormat.GenericTypographic);
gp.AddString(string.Format("Windows NT {0}.{1} build", b.MajorVersion, b.MinorVersion), new FontFamily("Segoe UI"), 0, 24, new Point(20, 40), StringFormat.GenericTypographic);
gp.AddString($"Windows NT {b.MajorVersion}.{b.MinorVersion} build", new FontFamily("Segoe UI"), 0, 24, new Point(20, 40), StringFormat.GenericTypographic);
gp.AddString(b.Number.ToString(), new FontFamily("Segoe UI Light"), 0, 180, new Point(12, 20), StringFormat.GenericTypographic);
gp.AddString(string.Format("{0}", b.Lab), new FontFamily("Segoe UI"), 0, 40, new Point(16, 220), StringFormat.GenericTypographic);
gp.AddString($"{b.Lab}", new FontFamily("Segoe UI"), 0, 40, new Point(16, 220), StringFormat.GenericTypographic);
gr.FillPath(Brushes.White, gp);
Response.ContentType = "image/png";
@ -150,17 +147,17 @@ public ActionResult viewLabPage(string lab, int page)
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Lab, Value = lab });
ViewBag.ItemId = lab;
var builds = Build.SelectInBuildOrder().Where(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower()));
var builds = Build.SelectInBuildOrder().Where(b => b.Lab != null && (b.Lab.ToLower() == lab.ToLower())).ToArray();
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(_pageSize));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Length) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
return new HttpNotFoundResult();
}
return View("viewLab", builds.Skip((page - 1) * _pageSize).Take(_pageSize));
return View("viewLab", builds.Skip((page - 1) * PAGE_SIZE).Take(PAGE_SIZE));
}
[Route("source/{source}/", Order = 1, Name = "Source Root")]
@ -181,17 +178,17 @@ public ActionResult viewSourcePage(TypeOfSource source, int page)
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Source, Value = source.ToString() });
ViewBag.ItemId = DisplayHelpers.GetDisplayTextForEnum(source);
var builds = Build.SelectInBuildOrder().Where(b => b.SourceType == source);
var builds = Build.SelectInBuildOrder().Where(b => b.SourceType == source).ToArray();
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(_pageSize));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Length) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
return new HttpNotFoundResult();
}
return View("viewSource", builds.Skip((page - 1) * _pageSize).Take(_pageSize));
return View("viewSource", builds.Skip((page - 1) * PAGE_SIZE).Take(PAGE_SIZE));
}
[Route("year/{year}/", Order = 1, Name = "Year Root")]
@ -212,17 +209,17 @@ public ActionResult viewYearPage(int year, int page)
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Year, Value = year.ToString() });
ViewBag.ItemId = year.ToString();
var builds = Build.SelectInBuildOrder().Where(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year);
var builds = Build.SelectInBuildOrder().Where(b => b.BuildTime.HasValue && b.BuildTime.Value.Year == year).ToArray();
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(_pageSize));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Length) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
return new HttpNotFoundResult();
}
return View("viewYear", builds.Skip((page - 1) * _pageSize).Take(_pageSize));
return View("viewYear", builds.Skip((page - 1) * PAGE_SIZE).Take(PAGE_SIZE));
}
[Route("version/{major}.{minor}/", Order = 1, Name = "Version Root")]
@ -240,21 +237,21 @@ public ActionResult viewVersion(int major, int minor)
#endif
public ActionResult viewVersionPage(int major, int minor, int page)
{
string valueString = string.Format("{0}.{1}", major, minor);
string valueString = $"{major}.{minor}";
ViewBag.MetaItem = MetaItem.SelectById(new MetaItemKey() { Type = MetaType.Version, Value = valueString });
ViewBag.ItemId = valueString;
var builds = Build.SelectInBuildOrder().Where(b => b.MajorVersion == major && b.MinorVersion == minor);
var builds = Build.SelectInBuildOrder().Where(b => b.MajorVersion == major && b.MinorVersion == minor).ToArray();
ViewBag.PageNumber = page;
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Count()) / Convert.ToDouble(_pageSize));
ViewBag.PageCount = Math.Ceiling(Convert.ToDouble(builds.Length) / Convert.ToDouble(PAGE_SIZE));
if (ViewBag.PageNumber > ViewBag.PageCount)
{
return new HttpNotFoundResult();
}
return View("viewVersion", builds.Skip((page - 1) * _pageSize).Take(_pageSize));
return View("viewVersion", builds.Skip((page - 1) * PAGE_SIZE).Take(PAGE_SIZE));
}
[Route("add/"), Authorize]

View File

@ -24,7 +24,7 @@ public async Task<ActionResult> index()
Title = "BuildFeed RSS - Recently Compiled",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
@ -32,7 +32,7 @@ public async Task<ActionResult> index()
select new RssItem()
{
Title = build.FullBuildString,
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id }))),
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"),
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
}).ToList()
}
@ -57,7 +57,7 @@ public async Task<ActionResult> added()
Title = "BuildFeed RSS - Recently Added",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
@ -65,8 +65,9 @@ public async Task<ActionResult> added()
select new RssItem()
{
Title = build.FullBuildString,
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id }))),
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
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 })}"
},
InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
}).ToList()
}
@ -91,7 +92,7 @@ public async Task<ActionResult> leaked()
Title = "BuildFeed RSS - Recently Leaked",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
@ -99,8 +100,9 @@ public async Task<ActionResult> leaked()
select new RssItem()
{
Title = build.FullBuildString,
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id }))),
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
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 })}"
},
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()
}
@ -127,7 +129,7 @@ public async Task<ActionResult> version()
Title = "BuildFeed RSS - Highest Version",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
@ -135,8 +137,9 @@ public async Task<ActionResult> version()
select new RssItem()
{
Title = build.FullBuildString,
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id }))),
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
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 })}"
},
}).ToList()
}
};
@ -160,10 +163,10 @@ public async Task<ActionResult> flight(LevelOfFlight id)
{
Channel = new RssChannel()
{
Title = string.Format("BuildFeed RSS - {0} Flight Level", id),
Title = $"BuildFeed RSS - {id} Flight Level",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
@ -171,8 +174,9 @@ public async Task<ActionResult> flight(LevelOfFlight id)
select new RssItem()
{
Title = build.FullBuildString,
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id }))),
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
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 })}"
},
}).ToList()
}
};
@ -196,10 +200,10 @@ public async Task<ActionResult> lab(string lab)
{
Channel = new RssChannel()
{
Title = string.Format("BuildFeed RSS - {0} Lab", lab),
Title = $"BuildFeed RSS - {lab} Lab",
Description = "",
Generator = "BuildFeed.net RSS Controller",
Link = new RssUrl(string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority)),
Link = new RssUrl($"{Request.Url.Scheme}://{Request.Url.Authority}"),
SkipHours = new List<Hour>(),
SkipDays = new List<Day>(),
@ -207,8 +211,9 @@ public async Task<ActionResult> lab(string lab)
select new RssItem()
{
Title = build.FullBuildString,
Link = new RssUrl(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id }))),
Guid = new RssGuid() { IsPermaLink = true, Value = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Action("viewBuild", new { controller = "front", id = build.Id })) },
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 })}"
},
}).ToList()
}
};

View File

@ -1,17 +1,13 @@
using System;
using BuildFeed.Models;
using BuildFeed.Models.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using BuildFeed.Models;
using BuildFeed.Models.ViewModel;
using System.Xml.Linq;
using System.Net.Mail;
using System.Configuration;
using System.Text;
using System.Threading.Tasks;
namespace BuildFeed.Controllers
{
@ -35,9 +31,11 @@ public ActionResult login(LoginUser ru)
int expiryLength = ru.RememberMe ? 129600 : 60;
var ticket = new FormsAuthenticationTicket(ru.UserName, true, expiryLength);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookieTicket = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
cookieTicket.Expires = DateTime.Now.AddMinutes(expiryLength);
cookieTicket.Path = FormsAuthentication.FormsCookiePath;
var cookieTicket = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
{
Expires = DateTime.Now.AddMinutes(expiryLength),
Path = FormsAuthentication.FormsCookiePath
};
Response.Cookies.Add(cookieTicket);
string returnUrl = string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]) ? "/" : Request.QueryString["ReturnUrl"];
@ -61,12 +59,16 @@ public ActionResult password(ChangePassword cp)
{
if (ModelState.IsValid)
{
var user = Membership.GetUser();
bool success = user.ChangePassword(cp.OldPassword, cp.NewPassword);
MembershipUser user = Membership.GetUser();
if (success)
if (user != null)
{
return Redirect("/");
bool success = user.ChangePassword(cp.OldPassword, cp.NewPassword);
if (success)
{
return Redirect("/");
}
}
}
@ -136,86 +138,110 @@ public ActionResult rss()
#endif
public ActionResult sitemap()
{
IEnumerable<Build> builds = Build.SelectInVersionOrder();
Dictionary<string, SitemapPagedAction[]> actions = new Dictionary<string, SitemapPagedAction[]>();
actions.Add("Pages", new SitemapPagedAction[] { new SitemapPagedAction()
var builds = Build.SelectInVersionOrder().ToArray();
Dictionary<string, SitemapPagedAction[]> actions = new Dictionary<string, SitemapPagedAction[]>
{
UrlParams = new RouteValueDictionary(new {
controller = "build",
action = "index",
page = 1
}),
Pages = (builds.Count() + (frontController._pageSize - 1)) / frontController._pageSize
} });
actions.Add("Versions", (from b in builds
group b by new BuildVersion() { Major = b.MajorVersion, Minor = b.MinorVersion } into bv
orderby bv.Key.Major descending,
bv.Key.Minor descending
select new SitemapPagedAction()
{
Name = string.Format("Windows NT {0}.{1}", bv.Key.Major, bv.Key.Minor),
UrlParams = new RouteValueDictionary(new
{
controller = "front",
action = "viewVersion",
major = bv.Key.Major,
minor = bv.Key.Minor,
page = 1
}),
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
}).ToArray());
actions.Add("Labs", (from b in builds
where !string.IsNullOrEmpty(b.Lab)
group b by b.Lab into bv
orderby bv.Key
select new SitemapPagedAction()
{
Name = bv.Key,
UrlParams = new RouteValueDictionary(new
{
controller = "front",
action = "viewLab",
lab = bv.Key,
page = 1
}),
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
}).ToArray());
actions.Add("Years", (from b in builds
where b.BuildTime.HasValue
group b by b.BuildTime.Value.Year into bv
orderby bv.Key descending
select new SitemapPagedAction()
{
Name = bv.Key.ToString(),
UrlParams = new RouteValueDictionary(new
{
controller = "front",
action = "viewYear",
year = bv.Key,
page = 1
}),
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
}).ToArray());
actions.Add("Sources", (from b in builds
group b by b.SourceType into bv
orderby bv.Key
select new SitemapPagedAction()
{
Name = DisplayHelpers.GetDisplayTextForEnum(bv.Key),
UrlParams = new RouteValueDictionary(new
{
"Pages", new SitemapPagedAction[]
{
new SitemapPagedAction()
{
UrlParams = new RouteValueDictionary(new
{
controller = "build",
action = "index",
page = 1
}),
Pages = (builds.Length + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
}
}
},
{
"Versions", (from b in builds
group b by new BuildVersion()
{
Major = b.MajorVersion,
Minor = b.MinorVersion
}
into bv
orderby bv.Key.Major descending,
bv.Key.Minor descending
select new SitemapPagedAction()
{
controller = "front",
action = "viewSource",
source = bv.Key,
page = 1
}),
Pages = (bv.Count() + (frontController._pageSize - 1)) / frontController._pageSize
}).ToArray());
Name = $"Windows NT {bv.Key.Major}.{bv.Key.Minor}",
UrlParams = new RouteValueDictionary(new
{
controller = "front",
action = "viewVersion",
major = bv.Key.Major,
minor = bv.Key.Minor,
page = 1
}),
Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
}).ToArray()
},
{
"Labs", (from b in builds
where !string.IsNullOrEmpty(b.Lab)
group b by b.Lab
into bv
orderby bv.Key
select new SitemapPagedAction()
{
Name = bv.Key,
UrlParams = new RouteValueDictionary(new
{
controller = "front",
action = "viewLab",
lab = bv.Key,
page = 1
}),
Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
}).ToArray()
},
{
"Years", (from b in builds
where b.BuildTime.HasValue
group b by b.BuildTime.Value.Year
into bv
orderby bv.Key descending
select new SitemapPagedAction()
{
Name = bv.Key.ToString(),
UrlParams = new RouteValueDictionary(new
{
controller = "front",
action = "viewYear",
year = bv.Key,
page = 1
}),
Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
}).ToArray()
},
{
"Sources", (from b in builds
group b by b.SourceType
into bv
orderby bv.Key
select new SitemapPagedAction()
{
Name = DisplayHelpers.GetDisplayTextForEnum(bv.Key),
UrlParams = new RouteValueDictionary(new
{
controller = "front",
action = "viewSource",
source = bv.Key,
page = 1
}),
Pages = (bv.Count() + (frontController.PAGE_SIZE - 1)) / frontController.PAGE_SIZE
}).ToArray()
}
};
SitemapData model = new SitemapData()
{
@ -295,10 +321,10 @@ public ActionResult xmlsitemap()
#endif
public ActionResult stats()
{
var builds = Build.Select();
var builds = Build.Select().ToArray();
List<MonthCount> Additions = new List<MonthCount>();
var rawAdditions = from b in builds
List<MonthCount> additions = new List<MonthCount>();
var rawAdditions = (from b in builds
where b.Added > DateTime.Now.AddYears(-1)
group b by new { Year = b.Added.Year, Week = Convert.ToInt32(Math.Floor(b.Added.DayOfYear / 7m)) } into bm
select new MonthCount()
@ -306,12 +332,12 @@ public ActionResult stats()
Month = bm.Key.Week,
Year = bm.Key.Year,
Count = bm.Count()
};
}).ToArray();
for (int i = -52; i <= 0; i++)
{
DateTime dt = DateTime.Now.AddDays(i * 7);
Additions.Add(new MonthCount()
additions.Add(new MonthCount()
{
Month = Convert.ToInt32(Math.Floor(dt.DayOfYear / 7m)),
Year = dt.Year,
@ -319,7 +345,7 @@ public ActionResult stats()
});
}
List<MonthCount> Compiles = new List<MonthCount>();
List<MonthCount> compiles = new List<MonthCount>();
var rawCompiles = from b in builds
where b.BuildTime.HasValue
group b by new { Year = b.BuildTime.Value.Year, Month = Convert.ToInt32(Math.Floor((b.BuildTime.Value.Month - 0.1m) / 3m) * 3) + 1 } into bm
@ -341,7 +367,7 @@ orderby bl.Count() descending
StatsPage m = new StatsPage()
{
AdditionsByMonth = Additions,
AdditionsByMonth = additions,
CompilesByMonth = rawCompiles.OrderBy(r => r.Year).ThenBy(r => r.Month),
BuildsByLab = rawLabCounts
};

View File

@ -237,7 +237,7 @@ public static void Insert(Build item)
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static void Update(Build item)
{
Build old = Build.SelectById(item.Id);
Build old = SelectById(item.Id);
item.Added = old.Added;
item.Modified = DateTime.Now;
@ -314,7 +314,7 @@ public struct BuildVersion
public override string ToString()
{
return string.Format("{0}.{1}", Major, Minor);
return $"{Major}.{Minor}";
}
}
@ -328,8 +328,8 @@ public struct BuildGroup
public override string ToString()
{
return Revision.HasValue ?
string.Format("{0}.{1}.{2}.{3}", Major, Minor, Build, Revision.Value) :
string.Format("{0}.{1}.{2}", Major, Minor, Build);
$"{Major}.{Minor}.{Build}.{Revision.Value}" :
$"{Major}.{Minor}.{Build}";
}
}
}

View File

@ -74,7 +74,7 @@ public static IEnumerable<string> SelectUnusedLabs()
select u;
return from l in labs
where !usedLabs.Any(ul => ul.Id.Value as string == l)
where usedLabs.All(ul => ul.Id.Value != l)
select l;
}
}
@ -93,7 +93,7 @@ public static IEnumerable<string> SelectUnusedVersions()
select u;
return from v in versions
where !usedLabs.Any(ul => ul.Id.Value == v.ToString())
where usedLabs.All(ul => ul.Id.Value != v.ToString())
select v.ToString();
}
}
@ -112,7 +112,7 @@ public static IEnumerable<string> SelectUnusedYears()
select u;
return from y in years
where !usedYears.Any(ul => ul.Id.Value == y.ToString())
where usedYears.All(ul => ul.Id.Value != y.ToString())
select y.ToString();
}
}
@ -172,7 +172,7 @@ public MetaItemKey(string id)
public override string ToString()
{
return string.Format("{0}:{1}", Type, Value);
return $"{Type}:{Value}";
}
}

View File

@ -38,6 +38,7 @@ h1
{
-ms-text-overflow: ellipsis;
-o-text-overflow: ellipsis;
-moz-text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
@ -116,11 +117,12 @@ label, .control-label, .help-block, .checkbox, .radio
overflow: hidden;
-ms-text-overflow: ellipsis;
-o-text-overflow: ellipsis;
-moz-text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
}
#search-results .list-group-item-heading h4
#search-results .list-group-item-heading h4
{
font-size: 16px;
}

View File

@ -2,7 +2,7 @@
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" userInstalled="true" />
<package id="Chart.js" version="1.0.2" targetFramework="net45" userInstalled="true" />
<package id="Humanizer" version="1.36.0" targetFramework="net452" userInstalled="true" />
<package id="Humanizer" version="1.37.0" targetFramework="net452" userInstalled="true" />
<package id="jQuery" version="2.1.4" targetFramework="net452" userInstalled="true" />
<package id="jquery.TypeScript.DefinitelyTyped" version="2.2.5" targetFramework="net452" userInstalled="true" />
<package id="jQuery.Validation" version="1.13.1" targetFramework="net45" userInstalled="true" />

View File

@ -5,12 +5,12 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RedisAuth")]
[assembly: AssemblyTitle("Redis Authentication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RedisAuth")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyProduct("BuildFeed")]
[assembly: AssemblyCopyright("Copyright © 2015, Thomas Hounsell")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>ExtendedDesignGuidelineRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -33,16 +34,16 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="NServiceKit.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Common.dll</HintPath>
<Reference Include="NServiceKit.Common, Version=1.0.35.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Common.1.0.35\lib\net35\NServiceKit.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NServiceKit.Interfaces, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Interfaces.dll</HintPath>
<Reference Include="NServiceKit.Interfaces, Version=1.0.35.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Common.1.0.35\lib\net35\NServiceKit.Interfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NServiceKit.Redis, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Redis.1.0.10\lib\net35\NServiceKit.Redis.dll</HintPath>
<Reference Include="NServiceKit.Redis, Version=1.0.16.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Redis.1.0.16\lib\net35\NServiceKit.Redis.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NServiceKit.Text, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NServiceKit.Common" version="1.0.27" targetFramework="net45" userInstalled="true" />
<package id="NServiceKit.Redis" version="1.0.10" targetFramework="net45" userInstalled="true" />
<package id="NServiceKit.Common" version="1.0.35" targetFramework="net452" userInstalled="true" />
<package id="NServiceKit.Redis" version="1.0.16" targetFramework="net452" userInstalled="true" />
<package id="NServiceKit.Text" version="1.0.10" targetFramework="net45" userInstalled="true" />
</packages>