diff --git a/BuildFeed/App_Code/PaginationHelpers.cshtml b/BuildFeed/App_Code/PaginationHelpers.cshtml index 71172f3..93f981e 100644 --- a/BuildFeed/App_Code/PaginationHelpers.cshtml +++ b/BuildFeed/App_Code/PaginationHelpers.cshtml @@ -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) + {
- } + } } \ No newline at end of file diff --git a/BuildFeed/Areas/admin/Controllers/metaController.cs b/BuildFeed/Areas/admin/Controllers/metaController.cs index 1f6700b..13027fe 100644 --- a/BuildFeed/Areas/admin/Controllers/metaController.cs +++ b/BuildFeed/Areas/admin/Controllers/metaController.cs @@ -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 diff --git a/BuildFeed/Areas/admin/Models/ViewModel/MetaListing.cs b/BuildFeed/Areas/admin/Models/ViewModel/MetaListing.cs index de3d5c7..562000e 100644 --- a/BuildFeed/Areas/admin/Models/ViewModel/MetaListing.cs +++ b/BuildFeed/Areas/admin/Models/ViewModel/MetaListing.cs @@ -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 { diff --git a/BuildFeed/BuildFeed.csproj b/BuildFeed/BuildFeed.csproj index 4b242ab..3665c40 100644 --- a/BuildFeed/BuildFeed.csproj +++ b/BuildFeed/BuildFeed.csproj @@ -51,8 +51,8 @@ False ..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll - - ..\packages\Humanizer.1.36.0\lib\portable-win+net40+sl50+wp8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Humanizer.dll + + ..\packages\Humanizer.1.37.0\lib\portable-win+net40+sl50+wp8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Humanizer.dll True diff --git a/BuildFeed/Code/CustomContentTypeAttribute.cs b/BuildFeed/Code/CustomContentTypeAttribute.cs index aadde75..38f264d 100644 --- a/BuildFeed/Code/CustomContentTypeAttribute.cs +++ b/BuildFeed/Code/CustomContentTypeAttribute.cs @@ -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; } } } \ No newline at end of file diff --git a/BuildFeed/Code/DateTimeModelBinder.cs b/BuildFeed/Code/DateTimeModelBinder.cs index f6c1404..17430c9 100644 --- a/BuildFeed/Code/DateTimeModelBinder.cs +++ b/BuildFeed/Code/DateTimeModelBinder.cs @@ -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); } @@ -19,4 +19,4 @@ public override object BindModel(ControllerContext controllerContext, ModelBindi return success ? retValue as DateTime? : null as DateTime?; } } -} +} \ No newline at end of file diff --git a/BuildFeed/Code/MvcIntrinsics.cs b/BuildFeed/Code/MvcIntrinsics.cs index 8e7b470..210d334 100644 --- a/BuildFeed/Code/MvcIntrinsics.cs +++ b/BuildFeed/Code/MvcIntrinsics.cs @@ -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; } } \ No newline at end of file diff --git a/BuildFeed/Controllers/apiController.cs b/BuildFeed/Controllers/apiController.cs index b3dda4c..857c713 100644 --- a/BuildFeed/Controllers/apiController.cs +++ b/BuildFeed/Controllers/apiController.cs @@ -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 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 GetSearchResult(string query) List results = new List(); - var sourceResults = from s in Enum.GetValues(typeof(BuildFeed.Models.TypeOfSource)).Cast().Select(s => new { Text = DisplayHelpers.GetDisplayTextForEnum(s), Value = s }) + var sourceResults = from s in Enum.GetValues(typeof(TypeOfSource)).Cast().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, "" + query + ""), + Label = $"{v.Major}.{v.Minor}".Replace(query, "" + query + ""), 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() { diff --git a/BuildFeed/Controllers/frontController.cs b/BuildFeed/Controllers/frontController.cs index 8efaed5..eebd250 100644 --- a/BuildFeed/Controllers/frontController.cs +++ b/BuildFeed/Controllers/frontController.cs @@ -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] diff --git a/BuildFeed/Controllers/rssController.cs b/BuildFeed/Controllers/rssController.cs index 87b672c..9b67c79 100644 --- a/BuildFeed/Controllers/rssController.cs +++ b/BuildFeed/Controllers/rssController.cs @@ -24,7 +24,7 @@ public async Task 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(), SkipDays = new List(), @@ -32,7 +32,7 @@ public async Task 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 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(), SkipDays = new List(), @@ -65,8 +65,9 @@ public async Task 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 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(), SkipDays = new List(), @@ -99,8 +100,9 @@ public async Task 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 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(), SkipDays = new List(), @@ -135,8 +137,9 @@ public async Task 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 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(), SkipDays = new List(), @@ -171,8 +174,9 @@ public async Task 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 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(), SkipDays = new List(), @@ -207,8 +211,9 @@ public async Task 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() } }; diff --git a/BuildFeed/Controllers/supportController.cs b/BuildFeed/Controllers/supportController.cs index 0ac595c..0ebe54e 100644 --- a/BuildFeed/Controllers/supportController.cs +++ b/BuildFeed/Controllers/supportController.cs @@ -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 builds = Build.SelectInVersionOrder(); - Dictionary actions = new Dictionary(); - - actions.Add("Pages", new SitemapPagedAction[] { new SitemapPagedAction() + var builds = Build.SelectInVersionOrder().ToArray(); + Dictionary actions = new Dictionary { - 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 Additions = new List(); - var rawAdditions = from b in builds + List additions = new List(); + 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 Compiles = new List(); + List compiles = new List(); 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 }; diff --git a/BuildFeed/Models/Build.cs b/BuildFeed/Models/Build.cs index fb2f1ef..ecd4cea 100644 --- a/BuildFeed/Models/Build.cs +++ b/BuildFeed/Models/Build.cs @@ -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}"; } } } \ No newline at end of file diff --git a/BuildFeed/Models/MetaItem.cs b/BuildFeed/Models/MetaItem.cs index 13ba3f3..aa6d42b 100644 --- a/BuildFeed/Models/MetaItem.cs +++ b/BuildFeed/Models/MetaItem.cs @@ -74,7 +74,7 @@ public static IEnumerable 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 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 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}"; } } diff --git a/BuildFeed/content/style.css b/BuildFeed/content/style.css index 4305bb2..0394df8 100644 --- a/BuildFeed/content/style.css +++ b/BuildFeed/content/style.css @@ -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; } diff --git a/BuildFeed/packages.config b/BuildFeed/packages.config index c421bf8..aafb608 100644 --- a/BuildFeed/packages.config +++ b/BuildFeed/packages.config @@ -2,7 +2,7 @@ - + diff --git a/RedisAuth/Properties/AssemblyInfo.cs b/RedisAuth/Properties/AssemblyInfo.cs index fb41e60..2ca1c09 100644 --- a/RedisAuth/Properties/AssemblyInfo.cs +++ b/RedisAuth/Properties/AssemblyInfo.cs @@ -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("")] diff --git a/RedisAuth/RedisAuth.csproj b/RedisAuth/RedisAuth.csproj index 80e1d93..84a2bbb 100644 --- a/RedisAuth/RedisAuth.csproj +++ b/RedisAuth/RedisAuth.csproj @@ -22,6 +22,7 @@ prompt 4 false + ExtendedDesignGuidelineRules.ruleset pdbonly @@ -33,16 +34,16 @@ false - - ..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Common.dll + + ..\packages\NServiceKit.Common.1.0.35\lib\net35\NServiceKit.Common.dll True - - ..\packages\NServiceKit.Common.1.0.27\lib\net35\NServiceKit.Interfaces.dll + + ..\packages\NServiceKit.Common.1.0.35\lib\net35\NServiceKit.Interfaces.dll True - - ..\packages\NServiceKit.Redis.1.0.10\lib\net35\NServiceKit.Redis.dll + + ..\packages\NServiceKit.Redis.1.0.16\lib\net35\NServiceKit.Redis.dll True diff --git a/RedisAuth/packages.config b/RedisAuth/packages.config index a4e3fbe..bf6fbfb 100644 --- a/RedisAuth/packages.config +++ b/RedisAuth/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file