2014-10-11 06:57:02 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using NServiceKit.DataAnnotations;
|
|
|
|
|
using NServiceKit.DesignPatterns.Model;
|
|
|
|
|
using NServiceKit.Redis;
|
|
|
|
|
|
|
|
|
|
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
|
2014-12-12 03:42:40 +08:00
|
|
|
|
using System.Web.Mvc;
|
2014-10-11 06:57:02 +08:00
|
|
|
|
|
|
|
|
|
namespace BuildFeed.Models
|
|
|
|
|
{
|
|
|
|
|
[DataObject]
|
|
|
|
|
public class Build : IHasId<long>
|
|
|
|
|
{
|
|
|
|
|
[Key]
|
|
|
|
|
[AutoIncrement]
|
|
|
|
|
[Index]
|
|
|
|
|
public long Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[@Required]
|
|
|
|
|
[DisplayName("Major Version")]
|
|
|
|
|
public byte MajorVersion { get; set; }
|
|
|
|
|
|
|
|
|
|
[@Required]
|
|
|
|
|
[DisplayName("Minor Version")]
|
|
|
|
|
public byte MinorVersion { get; set; }
|
|
|
|
|
|
|
|
|
|
[@Required]
|
|
|
|
|
[DisplayName("Build Number")]
|
|
|
|
|
public ushort Number { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Build Revision")]
|
|
|
|
|
[DisplayFormat(ConvertEmptyStringToNull = true)]
|
|
|
|
|
public ushort? Revision { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Lab String")]
|
|
|
|
|
public string Lab { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Build Time")]
|
|
|
|
|
[DisplayFormat(ConvertEmptyStringToNull = true, ApplyFormatInEditMode = true, DataFormatString = "{0:yyMMdd-HHmm}")]
|
|
|
|
|
public DateTime? BuildTime { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[@Required]
|
2014-11-01 03:28:16 +08:00
|
|
|
|
[DisplayName("Time Created")]
|
2014-10-11 06:57:02 +08:00
|
|
|
|
public DateTime Added { get; set; }
|
|
|
|
|
|
2014-11-01 03:28:16 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[DisplayName("Time Modified")]
|
|
|
|
|
public DateTime Modified { get; set; }
|
|
|
|
|
|
2014-10-11 06:57:02 +08:00
|
|
|
|
[@Required]
|
|
|
|
|
[DisplayName("Source Type")]
|
|
|
|
|
[EnumDataType(typeof(TypeOfSource))]
|
|
|
|
|
public TypeOfSource SourceType { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Source Details")]
|
2014-12-12 03:42:40 +08:00
|
|
|
|
[AllowHtml]
|
2014-10-11 06:57:02 +08:00
|
|
|
|
public string SourceDetails { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[RegularExpression("http://betawiki\\.net/.+")]
|
|
|
|
|
[DisplayName("BetaWiki (Client)")]
|
|
|
|
|
public Uri BetaWikiUri { get; set; }
|
|
|
|
|
|
|
|
|
|
[RegularExpression("http://betawiki\\.net/.+")]
|
|
|
|
|
[DisplayName("BetaWiki (Server)")]
|
|
|
|
|
public Uri BetaWikiServerUri { get; set; }
|
|
|
|
|
|
|
|
|
|
[RegularExpression("http://www\\.betaarchive\\.com/wiki/.+")]
|
|
|
|
|
[DisplayName("BetaArchive Wiki")]
|
|
|
|
|
public Uri BetaArchiveUri { get; set; }
|
|
|
|
|
|
|
|
|
|
[RegularExpression("http://longhorn\\.ms/.+")]
|
|
|
|
|
[DisplayName("Longhorn.ms")]
|
|
|
|
|
public Uri LonghornMsUri { get; set; }
|
|
|
|
|
|
|
|
|
|
[RegularExpression("https://winworldpc\\.com/.+")]
|
|
|
|
|
[DisplayName("WinWorldPC Library")]
|
|
|
|
|
public Uri WinWorldPCUri { get; set; }
|
|
|
|
|
|
2014-10-20 21:09:42 +08:00
|
|
|
|
[DisplayName("Flight Level")]
|
|
|
|
|
[EnumDataType(typeof(LevelOfFlight))]
|
|
|
|
|
public LevelOfFlight FlightLevel { get; set; }
|
|
|
|
|
|
2014-10-27 18:14:31 +08:00
|
|
|
|
public bool IsLeaked
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-11-01 03:28:16 +08:00
|
|
|
|
switch (SourceType)
|
2014-10-27 18:14:31 +08:00
|
|
|
|
{
|
|
|
|
|
case TypeOfSource.PublicRelease:
|
|
|
|
|
case TypeOfSource.InternalLeak:
|
|
|
|
|
case TypeOfSource.UpdateGDR:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 06:57:02 +08:00
|
|
|
|
public string FullBuildString
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.AppendFormat("{0}.{1}.{2}", MajorVersion, MinorVersion, Number);
|
|
|
|
|
|
|
|
|
|
if (Revision.HasValue)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat(".{0}", Revision);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Lab))
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat(".{0}", Lab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BuildTime.HasValue)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendFormat(".{0:yyMMdd-HHmm}", BuildTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, true)]
|
|
|
|
|
public static IEnumerable<Build> Select()
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
return client.GetAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
|
|
|
|
public static Build SelectById(long id)
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
return client.GetById(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
|
|
|
|
public static IEnumerable<Build> SelectInBuildOrder()
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
return client.GetAll()
|
|
|
|
|
.OrderByDescending(b => b.BuildTime)
|
|
|
|
|
.ThenByDescending(b => b.MajorVersion)
|
|
|
|
|
.ThenByDescending(b => b.MinorVersion)
|
|
|
|
|
.ThenByDescending(b => b.Number)
|
|
|
|
|
.ThenByDescending(b => b.Revision);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-01 03:28:16 +08:00
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
|
|
|
|
public static IEnumerable<Build> SelectInVersionOrder()
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
return client.GetAll()
|
|
|
|
|
.OrderByDescending(b => b.MajorVersion)
|
|
|
|
|
.ThenByDescending(b => b.MinorVersion)
|
|
|
|
|
.ThenByDescending(b => b.Number)
|
|
|
|
|
.ThenByDescending(b => b.Revision)
|
|
|
|
|
.ThenByDescending(b => b.BuildTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 06:57:02 +08:00
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
|
|
|
|
public static IEnumerable<BuildVersion> SelectBuildVersions()
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
var results = client.GetAll()
|
|
|
|
|
.GroupBy(b => new BuildVersion() { Major = b.MajorVersion, Minor = b.MinorVersion })
|
|
|
|
|
.Select(b => new BuildVersion() { Major = b.First().MajorVersion, Minor = b.First().MinorVersion })
|
|
|
|
|
.OrderByDescending(y => y.Major)
|
|
|
|
|
.ThenByDescending(y => y.Minor);
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
|
|
|
|
public static IEnumerable<int> SelectBuildYears()
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
var results = client.GetAll().Where(b => b.BuildTime.HasValue)
|
|
|
|
|
.GroupBy(b => b.BuildTime.Value.Year)
|
2014-12-12 05:26:04 +08:00
|
|
|
|
.Select(b => b.Key)
|
2014-10-11 06:57:02 +08:00
|
|
|
|
.OrderByDescending(y => y);
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
|
|
|
|
public static IEnumerable<string> SelectBuildLabs()
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
var results = client.GetAll()
|
|
|
|
|
.Where(b => !string.IsNullOrWhiteSpace(b.Lab))
|
|
|
|
|
.GroupBy(b => b.Lab.ToLower())
|
2014-12-12 05:26:04 +08:00
|
|
|
|
.Select(b => b.Key)
|
2014-10-11 06:57:02 +08:00
|
|
|
|
.OrderBy(s => s);
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-27 18:14:31 +08:00
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Select, false)]
|
|
|
|
|
public static IEnumerable<string> SelectBuildLabs(byte major, byte minor)
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
var results = client.GetAll()
|
|
|
|
|
.Where(b => !string.IsNullOrWhiteSpace(b.Lab))
|
|
|
|
|
.Where(b => b.MajorVersion == major)
|
|
|
|
|
.Where(b => b.MinorVersion == minor)
|
|
|
|
|
.GroupBy(b => b.Lab.ToLower())
|
2014-12-12 05:26:04 +08:00
|
|
|
|
.Select(b => b.Key)
|
2014-10-27 18:14:31 +08:00
|
|
|
|
.OrderBy(s => s);
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 06:57:02 +08:00
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Insert, true)]
|
|
|
|
|
public static void Insert(Build item)
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
item.Id = client.GetNextSequence();
|
|
|
|
|
client.Store(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Update, true)]
|
|
|
|
|
public static void Update(Build item)
|
|
|
|
|
{
|
|
|
|
|
Build old = Build.SelectById(item.Id);
|
|
|
|
|
item.Added = old.Added;
|
2014-11-01 03:28:16 +08:00
|
|
|
|
item.Modified = DateTime.Now;
|
2014-10-11 06:57:02 +08:00
|
|
|
|
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
client.Store(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Insert, false)]
|
|
|
|
|
public static void InsertAll(IEnumerable<Build> items)
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
client.StoreAll(items);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[DataObjectMethod(DataObjectMethodType.Delete, true)]
|
|
|
|
|
public static void DeleteById(long id)
|
|
|
|
|
{
|
|
|
|
|
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
|
|
|
|
|
{
|
|
|
|
|
var client = rClient.As<Build>();
|
|
|
|
|
client.DeleteById(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum TypeOfSource
|
|
|
|
|
{
|
|
|
|
|
[Display(Name = "Public Release")]
|
|
|
|
|
PublicRelease,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Public Leak")]
|
|
|
|
|
InternalLeak,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Update (GDR)")]
|
|
|
|
|
UpdateGDR,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Update (LDR)")]
|
|
|
|
|
UpdateLDR,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "App Package")]
|
|
|
|
|
AppPackage,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Build Tools")]
|
|
|
|
|
BuildTools,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Documentation")]
|
|
|
|
|
Documentation,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Logging")]
|
|
|
|
|
Logging,
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Private Leak")]
|
|
|
|
|
PrivateLeak
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-20 21:09:42 +08:00
|
|
|
|
public enum LevelOfFlight
|
|
|
|
|
{
|
|
|
|
|
None = 0,
|
|
|
|
|
Low = 1,
|
2014-10-30 18:10:15 +08:00
|
|
|
|
Medium = 2,
|
2014-10-20 21:09:42 +08:00
|
|
|
|
High = 3
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 06:57:02 +08:00
|
|
|
|
public struct BuildVersion
|
|
|
|
|
{
|
|
|
|
|
public byte Major { get; set; }
|
|
|
|
|
public byte Minor { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|