2016-01-11 06:23:13 +08:00
|
|
|
|
using System;
|
2015-11-10 00:43:05 +08:00
|
|
|
|
using System.ComponentModel;
|
2016-08-21 07:09:56 +08:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using BuildFeed.Local;
|
|
|
|
|
using HtmlAgilityPack;
|
|
|
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
|
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
|
2015-11-10 00:43:05 +08:00
|
|
|
|
|
2016-08-20 05:10:55 +08:00
|
|
|
|
namespace BuildFeed.Model
|
2015-11-10 00:43:05 +08:00
|
|
|
|
{
|
2016-11-05 09:36:36 +08:00
|
|
|
|
[DataObject]
|
|
|
|
|
[BsonIgnoreExtraElements]
|
2016-08-21 07:09:56 +08:00
|
|
|
|
public class Build
|
2015-11-10 00:43:05 +08:00
|
|
|
|
{
|
2016-11-05 09:36:36 +08:00
|
|
|
|
[Key]
|
|
|
|
|
[BsonId]
|
2016-08-21 07:09:56 +08:00
|
|
|
|
public Guid Id { get; set; }
|
2016-01-12 05:16:29 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
public long? LegacyId { get; set; }
|
2015-11-10 00:43:05 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_MajorVersion))]
|
|
|
|
|
public uint MajorVersion { get; set; }
|
2015-11-10 00:43:05 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_MinorVersion))]
|
|
|
|
|
public uint MinorVersion { get; set; }
|
2016-01-11 01:04:32 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_BuildNumber))]
|
|
|
|
|
public uint Number { get; set; }
|
2016-01-18 06:40:18 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_Revision))]
|
|
|
|
|
[DisplayFormat(ConvertEmptyStringToNull = true)]
|
|
|
|
|
public uint? Revision { get; set; }
|
2016-01-09 02:23:23 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_LabString))]
|
|
|
|
|
public string Lab { get; set; }
|
2015-11-10 00:43:05 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_BuildTime))]
|
|
|
|
|
[DisplayFormat(ConvertEmptyStringToNull = true, ApplyFormatInEditMode = true, DataFormatString = "{0:yyMMdd-HHmm}")]
|
|
|
|
|
public DateTime? BuildTime { get; set; }
|
2015-11-10 00:43:05 +08:00
|
|
|
|
|
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_Added))]
|
|
|
|
|
public DateTime Added { get; set; }
|
2016-01-18 06:40:18 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_Modified))]
|
|
|
|
|
public DateTime Modified { get; set; }
|
2016-01-18 06:40:18 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_SourceType))]
|
|
|
|
|
[EnumDataType(typeof(TypeOfSource))]
|
|
|
|
|
public TypeOfSource SourceType { get; set; }
|
2016-01-18 06:40:18 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_SourceDetails))]
|
|
|
|
|
[AllowHtml]
|
|
|
|
|
public string SourceDetails { get; set; }
|
2016-07-11 01:53:23 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Model_LeakDate))]
|
|
|
|
|
[DisplayFormat(ConvertEmptyStringToNull = true, ApplyFormatInEditMode = true)]
|
|
|
|
|
public DateTime? LeakDate { get; set; }
|
|
|
|
|
|
|
|
|
|
public string LabUrl { get; set; }
|
2016-07-11 01:53:23 +08:00
|
|
|
|
|
2016-12-10 10:08:24 +08:00
|
|
|
|
public bool IsLeaked => SourceType == TypeOfSource.PublicRelease || SourceType == TypeOfSource.InternalLeak || SourceType == TypeOfSource.UpdateGDR || SourceType == TypeOfSource.UpdateLDR;
|
2016-07-11 01:53:23 +08:00
|
|
|
|
|
2016-12-10 10:08:24 +08:00
|
|
|
|
public string FullBuildString { get; set; }
|
2016-08-30 18:39:52 +08:00
|
|
|
|
|
2016-12-10 10:08:24 +08:00
|
|
|
|
public string AlternateBuildString { get; set; }
|
2016-08-30 18:39:52 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
public ProjectFamily Family
|
2016-01-18 06:40:18 +08:00
|
|
|
|
{
|
2016-08-21 07:09:56 +08:00
|
|
|
|
get
|
2016-01-18 06:40:18 +08:00
|
|
|
|
{
|
2016-08-21 07:09:56 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2016-12-10 10:08:24 +08:00
|
|
|
|
if (MajorVersion == 6
|
|
|
|
|
&& Number >= 5000)
|
2016-08-21 07:09:56 +08:00
|
|
|
|
{
|
|
|
|
|
return ProjectFamily.WindowsVista;
|
|
|
|
|
}
|
|
|
|
|
if (MajorVersion == 6)
|
|
|
|
|
{
|
|
|
|
|
return ProjectFamily.Longhorn;
|
|
|
|
|
}
|
2016-12-10 10:08:24 +08:00
|
|
|
|
if (MajorVersion == 5
|
|
|
|
|
&& Number >= 3000)
|
2016-08-21 07:09:56 +08:00
|
|
|
|
{
|
|
|
|
|
return ProjectFamily.Server2003;
|
|
|
|
|
}
|
2016-12-10 10:08:24 +08:00
|
|
|
|
if (MajorVersion == 5
|
|
|
|
|
&& Number >= 2205)
|
2016-08-21 07:09:56 +08:00
|
|
|
|
{
|
|
|
|
|
return ProjectFamily.WindowsXP;
|
|
|
|
|
}
|
2016-12-10 10:08:24 +08:00
|
|
|
|
if (MajorVersion == 5
|
|
|
|
|
&& MinorVersion == 50)
|
2016-08-21 07:09:56 +08:00
|
|
|
|
{
|
|
|
|
|
return ProjectFamily.Neptune;
|
|
|
|
|
}
|
|
|
|
|
if (MajorVersion == 5)
|
|
|
|
|
{
|
|
|
|
|
return ProjectFamily.Windows2000;
|
|
|
|
|
}
|
|
|
|
|
return ProjectFamily.None;
|
2016-01-18 06:40:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
public string SourceDetailsFiltered
|
2016-01-18 06:40:18 +08:00
|
|
|
|
{
|
2016-08-21 07:09:56 +08:00
|
|
|
|
get
|
2016-01-18 06:40:18 +08:00
|
|
|
|
{
|
2016-08-21 07:09:56 +08:00
|
|
|
|
HtmlDocument hDoc = new HtmlDocument();
|
|
|
|
|
hDoc.LoadHtml($"<div>{SourceDetails}</div>");
|
2016-01-18 06:40:18 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
if (string.IsNullOrWhiteSpace(hDoc.DocumentNode.InnerText))
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2015-11-10 00:43:05 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
if (Uri.IsWellFormedUriString(hDoc.DocumentNode.InnerText, UriKind.Absolute))
|
|
|
|
|
{
|
|
|
|
|
Uri uri = new Uri(hDoc.DocumentNode.InnerText, UriKind.Absolute);
|
|
|
|
|
return $"<a href=\"{uri}\" target=\"_blank\">{VariantTerms.Model_ExternalLink} <i class=\"fa fa-external-link\"></i></a>";
|
|
|
|
|
}
|
2016-05-02 20:02:42 +08:00
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
return SourceDetails;
|
2015-11-10 00:43:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-10 10:08:24 +08:00
|
|
|
|
public string GenerateFullBuildString()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append($"{MajorVersion}.{MinorVersion}.{Number}");
|
|
|
|
|
|
|
|
|
|
if (Revision.HasValue)
|
|
|
|
|
{
|
|
|
|
|
sb.Append($".{Revision}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Lab))
|
|
|
|
|
{
|
|
|
|
|
sb.Append($".{Lab}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BuildTime.HasValue)
|
|
|
|
|
{
|
|
|
|
|
sb.Append($".{BuildTime.Value.ToString("yyMMdd-HHmm", CultureInfo.InvariantCulture.DateTimeFormat)}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GenerateAlternateBuildString()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append($"{MajorVersion}.{MinorVersion}.{Number}");
|
|
|
|
|
|
|
|
|
|
if (Revision.HasValue)
|
|
|
|
|
{
|
|
|
|
|
sb.Append($".{Revision}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Lab))
|
|
|
|
|
{
|
|
|
|
|
sb.Append($" ({Lab}");
|
|
|
|
|
|
|
|
|
|
if (BuildTime.HasValue)
|
|
|
|
|
{
|
|
|
|
|
sb.Append($".{BuildTime.Value.ToString("yyMMdd-HHmm", CultureInfo.InvariantCulture.DateTimeFormat)}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sb.Append(")");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-21 07:09:56 +08:00
|
|
|
|
public string GenerateLabUrl() => !string.IsNullOrEmpty(Lab)
|
|
|
|
|
? Lab.Replace('/', '-').ToLower()
|
|
|
|
|
: "";
|
2015-11-10 00:43:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|