Update project families

This commit is contained in:
Thomas Hounsell 2017-04-17 17:06:00 +01:00
parent 0a8a4485cc
commit f2d3810da1
6 changed files with 135 additions and 92 deletions

View File

@ -40,73 +40,7 @@ namespace BuildFeed.Model
public List<ItemHistory<BuildDetails>> History { get; set; }
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Search_Version))]
public ProjectFamily Family
{
get
{
if (Number >= 15140)
{
return ProjectFamily.Redstone3;
}
if (Number >= 14800)
{
return ProjectFamily.Redstone2;
}
if (Number >= 11000)
{
return ProjectFamily.Redstone;
}
if (Number >= 10500)
{
return ProjectFamily.Threshold2;
}
if (Number >= 9700)
{
return ProjectFamily.Threshold;
}
if (Number >= 9250)
{
return ProjectFamily.Windows81;
}
if (Number >= 7650)
{
return ProjectFamily.Windows8;
}
if (Number >= 6020)
{
return ProjectFamily.Windows7;
}
if (MajorVersion == 6
&& Number >= 5000)
{
return ProjectFamily.WindowsVista;
}
if (MajorVersion == 6)
{
return ProjectFamily.Longhorn;
}
if (MajorVersion == 5
&& Number >= 3000)
{
return ProjectFamily.Server2003;
}
if (MajorVersion == 5
&& Number >= 2205)
{
return ProjectFamily.WindowsXP;
}
if (MajorVersion == 5
&& MinorVersion == 50)
{
return ProjectFamily.Neptune;
}
if (MajorVersion == 5)
{
return ProjectFamily.Windows2000;
}
return ProjectFamily.None;
}
}
public ProjectFamily Family { get; private set; }
public string SourceDetailsFiltered
{
@ -135,6 +69,7 @@ namespace BuildFeed.Model
GenerateFullBuildString();
GenerateAlternateBuildString();
GenerateLabUrl();
GenerateFamily();
}
private void GenerateFullBuildString()
@ -193,5 +128,90 @@ namespace BuildFeed.Model
LabUrl = url;
}
private void GenerateFamily()
{
// start with lab-based overrides
if (string.Equals(Lab ?? "", "feature2"))
{
Family = ProjectFamily.Feature2;
}
else if (Lab?.StartsWith("rs2", StringComparison.InvariantCultureIgnoreCase) ?? false)
{
Family = ProjectFamily.Redstone2;
}
else if(Lab?.StartsWith("rs1", StringComparison.InvariantCultureIgnoreCase) ?? false)
{
Family = ProjectFamily.Redstone;
}
else if (Lab?.StartsWith("th2", StringComparison.InvariantCultureIgnoreCase) ?? false)
{
Family = ProjectFamily.Threshold2;
}
// move on to version number guesses
else if (Number >= 15140)
{
Family = ProjectFamily.Redstone3;
}
else if (Number >= 14800)
{
Family = ProjectFamily.Redstone2;
}
else if (Number >= 11000)
{
Family = ProjectFamily.Redstone;
}
else if (Number >= 10500)
{
Family = ProjectFamily.Threshold2;
}
else if (Number >= 9650)
{
Family = ProjectFamily.Threshold;
}
else if (Number >= 9250)
{
Family = ProjectFamily.WindowsBlue;
}
else if (Number >= 7650)
{
Family = ProjectFamily.Windows8;
}
else if (Number >= 6400)
{
Family = ProjectFamily.Windows7;
}
else if (MajorVersion == 6 && Number >= 5000)
{
Family = ProjectFamily.WindowsVista;
}
else if (MajorVersion == 6)
{
Family = ProjectFamily.Longhorn;
}
else if (MajorVersion == 5 && Number >= 3000)
{
Family = ProjectFamily.Server2003;
}
else if (MajorVersion == 5 && Number >= 2205)
{
Family = ProjectFamily.WindowsXP;
}
else if (MajorVersion == 5 && MinorVersion == 50)
{
Family = ProjectFamily.Neptune;
}
else if (MajorVersion == 5)
{
Family = ProjectFamily.Windows2000;
}
// ¯\_(ツ)_/¯
else
{
Family = ProjectFamily.None;
}
}
}
}

View File

@ -361,5 +361,15 @@ namespace BuildFeed.Model
await _buildCollection.ReplaceOneAsync(Builders<Build>.Filter.Eq(b => b.Id, bd.Id), bd);
}
}
public async Task RegenerateCachedProperties()
{
List<Build> builds = await Select();
foreach (Build bd in builds)
{
bd.RegenerateCachedProperties();
await _buildCollection.ReplaceOneAsync(Builders<Build>.Filter.Eq(b => b.Id, bd.Id), bd);
}
}
}
}

View File

@ -4,48 +4,51 @@ namespace BuildFeed.Model
{
public enum ProjectFamily
{
None,
None = 0,
[Display(Name = "Windows 2000")]
Windows2000,
[Display(Name = "NT 5.0", Description = "Windows 2000")]
Windows2000 = 1,
[Display(Name = "Neptune")]
Neptune,
Neptune = 2,
[Display(Name = "Windows XP")]
WindowsXP,
[Display(Name = "Whistler", Description = "Windows XP")]
WindowsXP = 3,
[Display(Name = "Server 2003")]
Server2003,
[Display(Name = ".NET Server", Description = "Server 2003")]
Server2003 = 4,
[Display(Name = "Longhorn")]
Longhorn,
Longhorn = 5,
[Display(Name = "Vista")]
WindowsVista,
[Display(Name = "Longhorn", Description = "Windows Vista")]
WindowsVista = 6,
[Display(Name = "Windows 7")]
Windows7,
Windows7 = 7,
[Display(Name = "Windows 8")]
Windows8,
Windows8 = 8,
[Display(Name = "Windows 8.1")]
Windows81,
[Display(Name = "Windows Blue", Description = "Windows 8.1")]
WindowsBlue = 9,
[Display(Name = "Threshold")]
Threshold,
[Display(Name = "Threshold", Description = "Windows 10 (Initial Release)")]
Threshold = 10,
[Display(Name = "Threshold 2")]
Threshold2,
[Display(Name = "Threshold 2", Description = "Windows 10 (November Update)")]
Threshold2 = 20,
[Display(Name = "Redstone")]
Redstone,
[Display(Name = "Redstone", Description = "Windows 10 (Anniversary Update)")]
Redstone = 30,
[Display(Name = "Redstone 2")]
Redstone2,
[Display(Name = "Redstone 2", Description = "Windows 10 (Creators Update)")]
Redstone2 = 40,
[Display(Name = "Redstone 2 (Feature Update)")]
Feature2 = 41,
[Display(Name = "Redstone 3")]
Redstone3
Redstone3 = 50
}
}

View File

@ -45,5 +45,14 @@ namespace BuildFeed.Areas.admin.Controllers
return RedirectToAction("index");
}
[Authorize(Users = "hounsell")]
public async Task<ActionResult> cache()
{
BuildRepository _bModel = new BuildRepository();
await _bModel.RegenerateCachedProperties();
return RedirectToAction("index");
}
}
}

View File

@ -18,5 +18,6 @@
{
<li>@Html.ActionLink("Exception test", "exception")</li>
<li>@Html.ActionLink("Initial setup", "setup")</li>
<li>@Html.ActionLink("Regenerate cached properties", "cache")</li>
}
</ul>

File diff suppressed because one or more lines are too long